Show More
@@ -5,6 +5,14 b' import curses, textwrap' | |||||
5 | import astyle, ipipe |
|
5 | import astyle, ipipe | |
6 |
|
6 | |||
7 |
|
7 | |||
|
8 | # Python 2.3 compatibility | |||
|
9 | try: | |||
|
10 | set | |||
|
11 | except NameError: | |||
|
12 | import sets | |||
|
13 | set = sets.Set | |||
|
14 | ||||
|
15 | ||||
8 | _ibrowse_help = """ |
|
16 | _ibrowse_help = """ | |
9 | down |
|
17 | down | |
10 | Move the cursor to the next line. |
|
18 | Move the cursor to the next line. | |
@@ -96,6 +104,12 b' sortattrdesc' | |||||
96 | Sort the objects (in descending order) using the attribute under the cursor as |
|
104 | Sort the objects (in descending order) using the attribute under the cursor as | |
97 | the sort key. |
|
105 | the sort key. | |
98 |
|
106 | |||
|
107 | hideattr | |||
|
108 | Hide the attribute under the cursor. | |||
|
109 | ||||
|
110 | unhideattrs | |||
|
111 | Make all attributes visible again. | |||
|
112 | ||||
99 | goto |
|
113 | goto | |
100 | Jump to a row. The row number can be entered at the bottom of the screen. |
|
114 | Jump to a row. The row number can be entered at the bottom of the screen. | |
101 |
|
115 | |||
@@ -237,6 +251,9 b' class _BrowserLevel(object):' | |||||
237 | # Maps attribute names to column widths |
|
251 | # Maps attribute names to column widths | |
238 | self.colwidths = {} |
|
252 | self.colwidths = {} | |
239 |
|
253 | |||
|
254 | # Set of hidden attributes | |||
|
255 | self.hiddenattrs = set() | |||
|
256 | ||||
240 | # This takes care of all the caches etc. |
|
257 | # This takes care of all the caches etc. | |
241 | self.moveto(0, 0, refresh=True) |
|
258 | self.moveto(0, 0, refresh=True) | |
242 |
|
259 | |||
@@ -256,17 +273,21 b' class _BrowserLevel(object):' | |||||
256 | def calcdisplayattrs(self): |
|
273 | def calcdisplayattrs(self): | |
257 | # Calculate which attributes are available from the objects that are |
|
274 | # Calculate which attributes are available from the objects that are | |
258 | # currently visible on screen (and store it in ``self.displayattrs``) |
|
275 | # currently visible on screen (and store it in ``self.displayattrs``) | |
|
276 | ||||
259 | attrnames = set() |
|
277 | attrnames = set() | |
260 | # If the browser object specifies a fixed list of attributes, |
|
278 | self.displayattrs = [] | |
261 | # simply use it. |
|
|||
262 | if self.attrs: |
|
279 | if self.attrs: | |
263 | self.displayattrs = self.attrs |
|
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) | |||
264 | else: |
|
286 | else: | |
265 | self.displayattrs = [] |
|
|||
266 | endy = min(self.datastarty+self.mainsizey, len(self.items)) |
|
287 | endy = min(self.datastarty+self.mainsizey, len(self.items)) | |
267 | for i in xrange(self.datastarty, endy): |
|
288 | for i in xrange(self.datastarty, endy): | |
268 | for attrname in ipipe.xattrs(self.items[i].item, "default"): |
|
289 | 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: | |
270 | self.displayattrs.append(attrname) |
|
291 | self.displayattrs.append(attrname) | |
271 | attrnames.add(attrname) |
|
292 | attrnames.add(attrname) | |
272 |
|
293 | |||
@@ -744,7 +765,9 b' class ibrowse(ipipe.Display):' | |||||
744 | 127: "leave", |
|
765 | 127: "leave", | |
745 | curses.KEY_BACKSPACE: "leave", |
|
766 | curses.KEY_BACKSPACE: "leave", | |
746 | ord("x"): "leave", |
|
767 | ord("x"): "leave", | |
747 |
ord("h"): "h |
|
768 | ord("h"): "hideattr", | |
|
769 | ord("H"): "unhideattrs", | |||
|
770 | ord("?"): "help", | |||
748 | ord("e"): "enter", |
|
771 | ord("e"): "enter", | |
749 | ord("E"): "enterattr", |
|
772 | ord("E"): "enterattr", | |
750 | ord("d"): "detail", |
|
773 | ord("d"): "detail", | |
@@ -1237,6 +1260,21 b' class ibrowse(ipipe.Display):' | |||||
1237 |
|
1260 | |||
1238 | self.enter(_BrowserHelp(self), "default") |
|
1261 | self.enter(_BrowserHelp(self), "default") | |
1239 |
|
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) | |||
|
1277 | ||||
1240 | def _dodisplay(self, scr): |
|
1278 | def _dodisplay(self, scr): | |
1241 | """ |
|
1279 | """ | |
1242 | This method is the workhorse of the browser. It handles screen |
|
1280 | This method is the workhorse of the browser. It handles screen |
@@ -1,3 +1,11 b'' | |||||
|
1 | 2006-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 | ||||
1 | 2006-06-15 Ville Vainio <vivainio@gmail.com> |
|
9 | 2006-06-15 Ville Vainio <vivainio@gmail.com> | |
2 |
|
10 | |||
3 | * iplib.py, hooks.py: Added new generate_prompt hook that can be |
|
11 | * iplib.py, hooks.py: Added new generate_prompt hook that can be |
General Comments 0
You need to be logged in to leave comments.
Login now