Show More
@@ -149,12 +149,12 b' class _BrowserLevel(object):' | |||||
149 | # position of cursor and screen, etc.) of one browser level |
|
149 | # position of cursor and screen, etc.) of one browser level | |
150 | # An ``ibrowse`` object keeps multiple ``_BrowserLevel`` objects in |
|
150 | # An ``ibrowse`` object keeps multiple ``_BrowserLevel`` objects in | |
151 | # a stack. |
|
151 | # a stack. | |
152 |
def __init__(self, browser, input, |
|
152 | def __init__(self, browser, input,mainsizey, *attrs): | |
153 | self.browser = browser |
|
153 | self.browser = browser | |
154 | self.input = input |
|
154 | self.input = input | |
155 | self.header = [x for x in ipipe.xrepr(input, "header") if not isinstance(x[0], int)] |
|
155 | self.header = [x for x in ipipe.xrepr(input, "header") if not isinstance(x[0], int)] | |
156 | # iterator for the input |
|
156 | # iterator for the input | |
157 |
self.iterator = i |
|
157 | self.iterator = ipipe.xiter(input) | |
158 |
|
158 | |||
159 | # is the iterator exhausted? |
|
159 | # is the iterator exhausted? | |
160 | self.exhausted = False |
|
160 | self.exhausted = False | |
@@ -417,6 +417,37 b' class _BrowserLevel(object):' | |||||
417 |
|
417 | |||
418 | self.moveto(self.curx, cury, refresh=True) |
|
418 | self.moveto(self.curx, cury, refresh=True) | |
419 |
|
419 | |||
|
420 | def refresh(self): | |||
|
421 | """ | |||
|
422 | Restart iterating the input. | |||
|
423 | """ | |||
|
424 | self.iterator = ipipe.xiter(self.input) | |||
|
425 | self.items.clear() | |||
|
426 | self.exhausted = False | |||
|
427 | self.moveto(0, 0, refresh=True) | |||
|
428 | ||||
|
429 | def refreshfind(self): | |||
|
430 | """ | |||
|
431 | Restart iterating the input and go back to the same object as before | |||
|
432 | (if it can be found in the new iterator). | |||
|
433 | """ | |||
|
434 | try: | |||
|
435 | oldobject = self.items[self.cury].item | |||
|
436 | except IndexError: | |||
|
437 | oldobject = ipipe.noitem | |||
|
438 | self.iterator = ipipe.xiter(self.input) | |||
|
439 | self.items.clear() | |||
|
440 | self.exhausted = False | |||
|
441 | while True: | |||
|
442 | self.fetch(len(self.items)+1) | |||
|
443 | if self.exhausted: | |||
|
444 | curses.beep() | |||
|
445 | self.moveto(0, 0, refresh=True) | |||
|
446 | break | |||
|
447 | if self.items[-1].item == oldobject: | |||
|
448 | self.moveto(self.curx, len(self.items)-1, refresh=True) | |||
|
449 | break | |||
|
450 | ||||
420 |
|
451 | |||
421 | class _CommandInput(object): |
|
452 | class _CommandInput(object): | |
422 | keymap = Keymap() |
|
453 | keymap = Keymap() | |
@@ -749,12 +780,14 b' class ibrowse(ipipe.Display):' | |||||
749 | keymap.register("detail", "d") |
|
780 | keymap.register("detail", "d") | |
750 | keymap.register("detailattr", "D") |
|
781 | keymap.register("detailattr", "D") | |
751 | keymap.register("tooglemark", " ") |
|
782 | keymap.register("tooglemark", " ") | |
752 |
keymap.register("markrange", " |
|
783 | keymap.register("markrange", "%") | |
753 | keymap.register("sortattrasc", "v") |
|
784 | keymap.register("sortattrasc", "v") | |
754 | keymap.register("sortattrdesc", "V") |
|
785 | keymap.register("sortattrdesc", "V") | |
755 | keymap.register("goto", "g") |
|
786 | keymap.register("goto", "g") | |
756 | keymap.register("find", "f") |
|
787 | keymap.register("find", "f") | |
757 | keymap.register("findbackwards", "b") |
|
788 | keymap.register("findbackwards", "b") | |
|
789 | keymap.register("refresh", "r") | |||
|
790 | keymap.register("refreshfind", "R") | |||
758 |
|
791 | |||
759 | def __init__(self, *attrs): |
|
792 | def __init__(self, *attrs): | |
760 | """ |
|
793 | """ | |
@@ -889,22 +922,22 b' class ibrowse(ipipe.Display):' | |||||
889 | Enter the object ``item``. If ``attrs`` is specified, it will be used |
|
922 | Enter the object ``item``. If ``attrs`` is specified, it will be used | |
890 | as a fixed list of attributes to display. |
|
923 | as a fixed list of attributes to display. | |
891 | """ |
|
924 | """ | |
|
925 | oldlevels = len(self.levels) | |||
|
926 | self._calcheaderlines(oldlevels+1) | |||
892 | try: |
|
927 | try: | |
893 | iterator = ipipe.xiter(item) |
|
|||
894 | except (KeyboardInterrupt, SystemExit): |
|
|||
895 | raise |
|
|||
896 | except Exception, exc: |
|
|||
897 | curses.beep() |
|
|||
898 | self.report(exc) |
|
|||
899 | else: |
|
|||
900 | self._calcheaderlines(len(self.levels)+1) |
|
|||
901 | level = _BrowserLevel( |
|
928 | level = _BrowserLevel( | |
902 | self, |
|
929 | self, | |
903 | item, |
|
930 | item, | |
904 | iterator, |
|
|||
905 | self.scrsizey-1-self._headerlines-2, |
|
931 | self.scrsizey-1-self._headerlines-2, | |
906 | *attrs |
|
932 | *attrs | |
907 | ) |
|
933 | ) | |
|
934 | except (KeyboardInterrupt, SystemExit): | |||
|
935 | raise | |||
|
936 | except Exception, exc: | |||
|
937 | self._calcheaderlines(oldlevels) | |||
|
938 | curses.beep() | |||
|
939 | self.report(exc) | |||
|
940 | else: | |||
908 | self.levels.append(level) |
|
941 | self.levels.append(level) | |
909 |
|
942 | |||
910 | def startkeyboardinput(self, mode): |
|
943 | def startkeyboardinput(self, mode): | |
@@ -1339,6 +1372,23 b' class ibrowse(ipipe.Display):' | |||||
1339 | """ |
|
1372 | """ | |
1340 | self.startkeyboardinput("findbackwards") |
|
1373 | self.startkeyboardinput("findbackwards") | |
1341 |
|
1374 | |||
|
1375 | def cmd_refresh(self): | |||
|
1376 | """ | |||
|
1377 | Refreshes the display by restarting the iterator. | |||
|
1378 | """ | |||
|
1379 | level = self.levels[-1] | |||
|
1380 | self.report("refresh") | |||
|
1381 | level.refresh() | |||
|
1382 | ||||
|
1383 | def cmd_refreshfind(self): | |||
|
1384 | """ | |||
|
1385 | Refreshes the display by restarting the iterator and goes back to the | |||
|
1386 | same object as before (if it can be found in the new iterator). | |||
|
1387 | """ | |||
|
1388 | level = self.levels[-1] | |||
|
1389 | self.report("refreshfind") | |||
|
1390 | level.refreshfind() | |||
|
1391 | ||||
1342 | def cmd_help(self): |
|
1392 | def cmd_help(self): | |
1343 | """ |
|
1393 | """ | |
1344 | Opens the help screen as a new browser level, describing keyboard |
|
1394 | Opens the help screen as a new browser level, describing keyboard |
@@ -1,3 +1,10 b'' | |||||
|
1 | 2006-11-30 Walter Doerwald <walter@livinglogic.de> | |||
|
2 | * IPython/Extensions/ibrowse.py: Add two new commands to ibrowse: | |||
|
3 | "refresh" (mapped to "r") refreshes the screen by restarting the iterator. | |||
|
4 | "refreshfind" (mapped to "R") does the same but tries to go back to the same | |||
|
5 | object the cursor was on before the refresh. The command "markrange" is | |||
|
6 | mapped to "%" now. | |||
|
7 | ||||
1 | 2006-11-29 Fernando Perez <Fernando.Perez@colorado.edu> |
|
8 | 2006-11-29 Fernando Perez <Fernando.Perez@colorado.edu> | |
2 |
|
9 | |||
3 | * IPython/Magic.py (magic_debug): new %debug magic to activate the |
|
10 | * IPython/Magic.py (magic_debug): new %debug magic to activate the |
General Comments 0
You need to be logged in to leave comments.
Login now