From a2353555331d4392b6f06692a962fe416160d7f2 Mon Sep 17 00:00:00 2001 From: moculus Date: Thu, 9 Apr 2009 05:01:58 +0000 Subject: [PATCH] ideas --HG-- branch : pmacs2 --- IDEAS | 12 +++++++++ application.py | 69 ++++++++++++++++++++++---------------------------- 2 files changed, 42 insertions(+), 39 deletions(-) diff --git a/IDEAS b/IDEAS index 339c488..15e9313 100644 --- a/IDEAS +++ b/IDEAS @@ -1,3 +1,15 @@ +2009/04/09: + +Fix the kludge that is completer initialization. Make application a global? Try +to make bufferlist nicer. Add support for vim/emacs mode-setting stuff. Fix +map_point, and refactor draw_cursor, draw_slot, etc. so that they all use it +(thus ending once and for all these goddamn cursor-sync bugs). ARGH! + +Try to create a buffer abstraction so that things like BinaryBuffer, AESBuffer, +MboxBuffer, etc, etc don't need special open commands (e.g. you can open a +buffer, switch it into hex mode, then switch it into AES mode, and have what +you'd "want" to happen). Maybe this means BufferViews or something? + 2009/04/06: Think about what to do with IPerl/IPython. diff --git a/application.py b/application.py index fe9a567..836ed4e 100755 --- a/application.py +++ b/application.py @@ -284,20 +284,17 @@ class Application(object): # auto-load the mode def setmode(self, name, cls, paths=[], bases=[], exts=[], detection=[]): self.modes[name] = cls - for p in paths: - self.mode_paths[p] = name - for b in bases: - self.mode_basenames[b] = name - for e in exts: - self.mode_extensions[e] = name - for d in detection: - self.mode_detection[d] = name + for p in paths: self.mode_paths[p] = name + for b in bases: self.mode_basenames[b] = name + for e in exts: self.mode_extensions[e] = name + for d in detection: self.mode_detection[d] = name - def globals(self): - return globals() - def locals(self): - return locals() + # we are evil + def eval(self, s): return eval(s) + def globals(self): return globals() + def locals(self): return locals() + # slots def add_slot(self): b = self.bufferlist.slots[self.active_slot].window.buffer n = self.bufferlist.add_slot() @@ -578,10 +575,6 @@ class Application(object): f = getattr(self.window(), methodname) f() - # we are evil - def eval(self, s): - return eval(s) - # load user configuration NOW def loadrc(self): path = os.path.join(os.getenv('HOME'), '.pmc', 'conf') @@ -612,22 +605,22 @@ class Application(object): while not self.done: i = self.win.getch() - #if not self.mini_active and self.completion_window_is_open(): - # self.close_completion_buffer() - + # if we get a resize event, wait for things to stabilize if i == curses.KEY_RESIZE: - while i == curses.KEY_RESIZE: - i = self.win.getch() + while i == curses.KEY_RESIZE: i = self.win.getch() self.resize_event() self.need_draw = True + + # add the keycodes to our input handler try: self.input.parse(i) except Exception, e: self.set_error(str(e)) - if self.input.tokens: - self.need_draw = True + # if the mode has parsed keycodes into a key, we (possibly) handle + # some actions, and refresh the screen while self.input.tokens: + self.need_draw = True t = self.input.tokens.pop(0) self.active_window().mode.handle_token(t) @@ -710,6 +703,20 @@ class Application(object): self.try_manual_resize() + # NOTE: this is totally broken + def map_point(self, w, p): + count = 0 + x, y = w.first.xy() + while count < slot.height: + if p1.y == y and p1.x >= x and p1.x - x < slot.width: + return (count, x) + if x + slot.width > len(w.buffer.lines[y]): + x = 0 + y += 1 + else: + x += slot.width + count += 1 + def draw_cursor(self): if self.mini_active: b = self.mini_buffer @@ -782,20 +789,6 @@ class Application(object): for x in range(sx1, sx2): self.highlight_char(sy, x, fg, bg) - # NOTE: this is totally broken - def map_point(self, w, p): - count = 0 - x, y = w.first.xy() - while count < slot.height: - if p1.y == y and p1.x >= x and p1.x - x < slot.width: - return (count, x) - if x + slot.width > len(w.buffer.lines[y]): - x = 0 - y += 1 - else: - x += slot.width - count += 1 - def highlight_simple_range(self, slot, y1, x1, x2, fg, bg): count = slot.window.mode.header tx1, tx2 = slot.window.mode.lmargin, slot.width - 1 @@ -1086,8 +1079,6 @@ if __name__ == "__main__": help='jump to line NUM of the first argument') parser.add_option('-m', '--mode', dest='mode', metavar='MODE', help='open arguments in MODE') - #parser.add_option('-x', '--exec', dest='cmd', metavar='CMD', - # help='run CMD after launching') parser.add_option('-x', '--exec', action='callback', callback=exec_cb, type='string', metavar='CMD', help='run CMD after launching')