Changeset 1367

Show
Ignore:
Timestamp:
06/16/06 07:51:43 (2 years ago)
Author:
walter.doerwald
Message:

Add two new commands to ibrowse: hideattr (mapped to "h")
hides the attribute under the cursor. "unhiderattrs" (mapped to "H")
reveals all hidden attributes again. Remapped the help command to "?".

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • ipython/trunk/IPython/Extensions/ibrowse.py

    r1364 r1367  
    44 
    55import astyle, ipipe 
     6 
     7 
     8# Python 2.3 compatibility 
     9try: 
     10    set 
     11except NameError: 
     12    import sets 
     13    set = sets.Set 
    614 
    715 
     
    96104Sort the objects (in descending order) using the attribute under the cursor as 
    97105the sort key. 
     106 
     107hideattr 
     108Hide the attribute under the cursor. 
     109 
     110unhideattrs 
     111Make all attributes visible again. 
    98112 
    99113goto 
     
    237251        # Maps attribute names to column widths 
    238252        self.colwidths = {} 
     253 
     254        # Set of hidden attributes 
     255        self.hiddenattrs = set() 
    239256 
    240257        # This takes care of all the caches etc. 
     
    257274        # Calculate which attributes are available from the objects that are 
    258275        # currently visible on screen (and store it in ``self.displayattrs``) 
     276 
    259277        attrnames = set() 
    260         # If the browser object specifies a fixed list of attributes, 
    261         # simply use it. 
     278        self.displayattrs = [] 
    262279        if self.attrs: 
    263             self.displayattrs = self.attrs 
    264         else: 
    265             self.displayattrs = [] 
     280            # If the browser object specifies a fixed list of attributes, 
     281            # simply use it (removing hidden attributes). 
     282            for attrname in self.attrs: 
     283                if attrname not in attrnames and attrname not in self.hiddenattrs: 
     284                    self.displayattrs.append(attrname) 
     285                    attrnames.add(attrname) 
     286        else: 
    266287            endy = min(self.datastarty+self.mainsizey, len(self.items)) 
    267288            for i in xrange(self.datastarty, endy): 
    268289                for attrname in ipipe.xattrs(self.items[i].item, "default"): 
    269                     if attrname not in attrnames
     290                    if attrname not in attrnames and attrname not in self.hiddenattrs
    270291                        self.displayattrs.append(attrname) 
    271292                        attrnames.add(attrname) 
     
    745766        curses.KEY_BACKSPACE: "leave", 
    746767        ord("x"): "leave", 
    747         ord("h"): "help", 
     768        ord("h"): "hideattr", 
     769        ord("H"): "unhideattrs", 
     770        ord("?"): "help", 
    748771        ord("e"): "enter", 
    749772        ord("E"): "enterattr", 
     
    12371260 
    12381261        self.enter(_BrowserHelp(self), "default") 
     1262 
     1263    def cmd_hideattr(self): 
     1264        level = self.levels[-1] 
     1265        if level.displayattr[0] is None: 
     1266            self.beep() 
     1267        else: 
     1268            self.report("hideattr") 
     1269            level.hiddenattrs.add(level.displayattr[1]) 
     1270            level.moveto(level.curx, level.cury, refresh=True) 
     1271 
     1272    def cmd_unhideattrs(self): 
     1273        level = self.levels[-1] 
     1274        self.report("unhideattrs") 
     1275        level.hiddenattrs.clear() 
     1276        level.moveto(level.curx, level.cury, refresh=True) 
    12391277 
    12401278    def _dodisplay(self, scr): 
  • ipython/trunk/doc/ChangeLog

    r1366 r1367  
     12006-06-16  Walter Doerwald  <walter@livinglogic.de> 
     2 
     3    * IPython/Extensions/ibrowse.py: Add two new commands to 
     4    ibrowse: hideattr (mapped to "h") hides the attribute under 
     5    the cursor. "unhiderattrs" (mapped to "H") reveals all hidden 
     6    attributes again. Remapped the help command to "?". 
     7 
     8 
    192006-06-15  Ville Vainio  <vivainio@gmail.com> 
    210