##// END OF EJS Templates
Walter's ipipe patch #8:...
vivainio -
Show More
@@ -1781,6 +1781,8 b' class XAttr(object):'
1781 1781 doc = getattr(meta, "__doc__", None)
1782 1782 elif callable(name):
1783 1783 doc = getattr(name, "__doc__", None)
1784 if isinstance(doc, basestring):
1785 doc = doc.strip()
1784 1786 self.doc = doc
1785 1787
1786 1788 def __xattrs__(self, mode):
@@ -1877,6 +1879,9 b' sortattrdesc'
1877 1879 Sort the objects (in descending order) using the attribute under the cursor as
1878 1880 the sort key.
1879 1881
1882 goto
1883 Jump to a row. The row number can be entered at the bottom of the screen.
1884
1880 1885 help
1881 1886 This screen.
1882 1887 """
@@ -1918,9 +1923,11 b' if curses is not None:'
1918 1923 self.browser = browser
1919 1924
1920 1925 def __xrepr__(self, mode):
1926 yield (-1, True)
1921 1927 if mode == "header" or mode == "footer":
1922 return "ibrowse help screen"
1923 return repr(self)
1928 yield (style_default, "ibrowse help screen")
1929 else:
1930 yield (style_default, repr(self))
1924 1931
1925 1932 def __xiter__(self, mode):
1926 1933 # Get reverse key mapping
@@ -2298,6 +2305,9 b' if curses is not None:'
2298 2305 # Character to use for "empty" cell (i.e. for non-existing attributes)
2299 2306 nodatachar = "-"
2300 2307
2308 # Prompt for the goto command
2309 prompt_goto = "goto object #: "
2310
2301 2311 # Maps curses key codes to "function" names
2302 2312 keymap = {
2303 2313 ord("q"): "quit",
@@ -2333,6 +2343,7 b' if curses is not None:'
2333 2343 ord("r"): "markrange",
2334 2344 ord("v"): "sortattrasc",
2335 2345 ord("V"): "sortattrdesc",
2346 ord("g"): "goto",
2336 2347 }
2337 2348
2338 2349 def __init__(self, *attrs):
@@ -2376,6 +2387,13 b' if curses is not None:'
2376 2387 # value to be returned to the caller (set by commands)
2377 2388 self.returnvalue = None
2378 2389
2390 # The mode the browser is in
2391 # e.g. normal browsing or entering an argument for a command
2392 self.mode = "default"
2393
2394 # The partially entered row number for the goto command
2395 self.goto = ""
2396
2379 2397 def nextstepx(self, step):
2380 2398 """
2381 2399 Accelerate horizontally.
@@ -2827,6 +2845,10 b' if curses is not None:'
2827 2845 return None
2828 2846 level.sort(key, reverse=True)
2829 2847
2848 def cmd_goto(self):
2849 self.mode = "goto"
2850 self.goto = ""
2851
2830 2852 def cmd_help(self):
2831 2853 """
2832 2854 The help command
@@ -3004,6 +3026,8 b' if curses is not None:'
3004 3026 posx += self.addstr(posy, posx, 0, endx, text, self.style_footer)
3005 3027 if posx >= endx:
3006 3028 break
3029
3030 attrstyle = [(style_default, "no attribute")]
3007 3031 attrname = level.displayattr[1]
3008 3032 if attrname is not _default and attrname is not None:
3009 3033 posx += self.addstr(posy, posx, 0, endx, " | ", self.style_footer)
@@ -3015,17 +3039,20 b' if curses is not None:'
3015 3039 raise
3016 3040 except Exception, exc:
3017 3041 attr = exc
3018 for (nostyle, text) in xrepr(attr, "footer"):
3042 if attr is not _default:
3043 attrstyle = xrepr(attr, "footer")
3044 for (nostyle, text) in attrstyle:
3019 3045 if not isinstance(nostyle, int):
3020 3046 posx += self.addstr(posy, posx, 0, endx, text, self.style_footer)
3021 3047 if posx >= endx:
3022 3048 break
3023 3049
3024 #else:
3025 #msg += ": %s > no attribute" % xrepr(level.items[level.cury].item, "footer")
3026 #self.addstr(posy, 1, 1, self.scrsizex-len(helpmsg)-1, msg, self.style_footer)
3027
3050 try:
3051 # Display goto input prompt
3052 if self.mode == "goto":
3053 scr.addstr(self.scrsizey-1, 0, self.prompt_goto + self.goto, self.getstyle(style_default))
3028 3054 # Display report
3055 else:
3029 3056 if self._report is not None:
3030 3057 if isinstance(self._report, Exception):
3031 3058 style = self.getstyle(style_error)
@@ -3039,17 +3066,19 b' if curses is not None:'
3039 3066 else:
3040 3067 style = self.getstyle(self.style_report)
3041 3068 msg = self._report
3042 try:
3043 3069 scr.addstr(self.scrsizey-1, 0, msg[:self.scrsizex], style)
3044 except curses.err:
3045 # Protect against error from writing to the last line
3046 pass
3047 3070 self._report = None
3048 3071 else:
3049 3072 scr.move(self.scrsizey-1, 0)
3073 except curses.error:
3074 # Protect against error from writing to the last line
3075 pass
3050 3076 scr.clrtoeol()
3051 3077
3052 3078 # Position cursor
3079 if self.mode == "goto":
3080 scr.move(self.scrsizey-1, len(self.prompt_goto)+len(self.goto))
3081 else:
3053 3082 scr.move(
3054 3083 1+self._headerlines+level.cury-level.datastarty,
3055 3084 level.numbersizex+3+level.curx-level.datastartx
@@ -3059,6 +3088,24 b' if curses is not None:'
3059 3088 # Check keyboard
3060 3089 while True:
3061 3090 c = scr.getch()
3091 if self.mode == "goto":
3092 if ord("0") <= c <= ord("9"):
3093 self.goto += chr(c)
3094 break # Redisplay
3095 elif c in (8, 127, curses.KEY_BACKSPACE, ord("x")):
3096 if self.goto:
3097 self.goto = self.goto[:-1]
3098 break
3099 else:
3100 curses.beep()
3101 elif c == ord("\n"):
3102 self.mode = "default"
3103 if self.goto:
3104 level.moveto(level.curx, int(self.goto))
3105 break
3106 else:
3107 curses.beep()
3108 else:
3062 3109 # if no key is pressed slow down and beep again
3063 3110 if c == -1:
3064 3111 self.stepx = 1.
General Comments 0
You need to be logged in to leave comments. Login now