Example #1
0
    def copy_clipboard ( self ):
        """ Copy the item to the clipboard.

            The [[c]] command copies the item, without any textual annotations
            such as item ids and line numbers, to the clipboard.

            You can use the [[Ctrl-c]] command to copy the item including all
            textual annotations to the clipboard.
        """
        toolkit().clipboard().text = remove_color( self.str( self.item ) )
Example #2
0
    def key_ctrl_c ( self, event ):
        """ Copy this item to the clipboard.

            The [[Ctrl-c]] command copies the item, including all textual
            annotations such as item ids and line numbers, to the clipboard.

            You can use the [[c]] command to copy the item without any
            annotations to the clipboard.
        """
        toolkit().clipboard().text = remove_color( self.text )
Example #3
0
    def text_value_for_0 ( self ):
        """ Returns the text to display for level of detail 0.
        """
        value   = self.str( self.item )
        lines   = value.split( '\n' )
        display = self.lookup( 'display' )
        if len( lines ) <= 1:
            return display( value )

        is_object = self.is_object( self.item )
        text      = ''
        len_text  = 0
        lens      = [ ( 0, 0 ) ]
        for line in lines:
            line = line.strip()
            if is_object:
                line = ' '.join( [ x.strip() for x in line.split( ' ', 1 ) ] )

            len_line = len( remove_color( line ) )
            if (len_text + len_line) > 90:
                break

            if len_text > 0:
                text     += ' '
                len_text += 1

            text     += line
            len_text += len_line
            lens.insert( 0, ( len_text, len( text ) ) )
        else:
            return display( text )

        for len1, len2 in lens:
            if len1 <= 70:
                return display( '%s  \x00A[...%d lines...]\x002' %
                                ( text[:len2], len( lines ) ) )
Example #4
0
    def save_file ( self ):
        """ Save the contents of the item to a file.

            The [[s]] key saves the current textual contents of a shell item,
            not including any textual annotations such as items ids or line
            numbers, to a file.

            A file dialog appears prompting you for the name and location of
            where to save the file. The file dialog defaults to saving the file
            in the shell's current working directory with a name of the form:
            vip_shell_<<item_id>>.txt, where <<item_id>> is the id associated
            with the shell item.
        """
        from file_item        import FileItem
        from python_file_item import PythonFileItem

        fd = FileDialog( default_path = self.file_name, action = 'save as' )
        if fd.open() == OK:
            self.file_name = file_name = fd.path
            ext            = splitext( file_name )[1]
            write_file( file_name, remove_color( self.str( self.item ) ) )
            self.shell.add_history_item_for(
                ( FileItem, PythonFileItem )[ ext == '.py' ], file_name
            )
Example #5
0
 def shell_value ( self ):
     """ Returns the item as a value the user can manipulate in the shell.
     """
     return remove_color( self.item )