Ejemplo n.º 1
0
    def click ( self ):
        """ Handles the user left-clicking on the tag.
        """
        from facets.ui.vip_shell.items.output_item import OutputItem

        shell = self.shell
        shell.append_items( shell.history_item_for(
            OutputItem, replace_markers( self.text ),
            parent = self.shell_item.parent, lod = 2
        ) )
Ejemplo n.º 2
0
    def help_for_items ( self ):
        """ Returns help information about shell item keyboard and mouse
            shortcuts.
        """
        key_info    = {}
        method_info = set()
        self._item_keys_for( ShellItem, key_info, method_info )
        keys = key_info.keys()
        keys.sort( lambda l, r: cmp_key_name( l, r ) )
        max_len       = reduce( lambda x, y: max( x, len( y ) ), keys, 0 )
        format_tagged = '%%%ds = %%s%%s' % (-(max_len + 8))
        format_simple = '%%%ds = %%s%%s' % (-(max_len + 4))
        output        = []
        tags          = []
        for key in keys:
            for kind, info in key_info[ key ]:
                if kind == 'Shell':
                    kind = ''
                else:
                    kind = '\x00C[%s]\x000 ' % kind

                info = '\n'.join( [
                    line.strip() for line in info.split( '\n' )
                ] )
                items = info.split( '\n\n', 1 )
                info  = ('\n' + (' ' * (max_len + 3))).join(
                        items[0].split( '\n' ) )
                cc     = '\x00B'
                format = format_simple
                if len( items ) > 1:
                    cc     = color_tag_for( 'B', tags )
                    format = format_tagged
                    tags.append( TextTag( text = items[1] ) )

                output.append(
                    format % ( '%s%s\x000' % ( cc, key ), kind, info )
                )

        return self.shell.history_item_for(
            OutputItem, (replace_markers( ShellItems ) % ('\n'.join( output ))),
            tags = tags, lod = 2
        )