--HG--
branch : pmacs2
This commit is contained in:
moculus 2009-04-09 05:01:58 +00:00
parent 9f26df444c
commit a235355533
2 changed files with 42 additions and 39 deletions

12
IDEAS
View File

@ -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: 2009/04/06:
Think about what to do with IPerl/IPython. Think about what to do with IPerl/IPython.

View File

@ -284,20 +284,17 @@ class Application(object):
# auto-load the mode # auto-load the mode
def setmode(self, name, cls, paths=[], bases=[], exts=[], detection=[]): def setmode(self, name, cls, paths=[], bases=[], exts=[], detection=[]):
self.modes[name] = cls self.modes[name] = cls
for p in paths: for p in paths: self.mode_paths[p] = name
self.mode_paths[p] = name for b in bases: self.mode_basenames[b] = name
for b in bases: for e in exts: self.mode_extensions[e] = name
self.mode_basenames[b] = name for d in detection: self.mode_detection[d] = name
for e in exts:
self.mode_extensions[e] = name
for d in detection:
self.mode_detection[d] = name
def globals(self): # we are evil
return globals() def eval(self, s): return eval(s)
def locals(self): def globals(self): return globals()
return locals() def locals(self): return locals()
# slots
def add_slot(self): def add_slot(self):
b = self.bufferlist.slots[self.active_slot].window.buffer b = self.bufferlist.slots[self.active_slot].window.buffer
n = self.bufferlist.add_slot() n = self.bufferlist.add_slot()
@ -578,10 +575,6 @@ class Application(object):
f = getattr(self.window(), methodname) f = getattr(self.window(), methodname)
f() f()
# we are evil
def eval(self, s):
return eval(s)
# load user configuration NOW # load user configuration NOW
def loadrc(self): def loadrc(self):
path = os.path.join(os.getenv('HOME'), '.pmc', 'conf') path = os.path.join(os.getenv('HOME'), '.pmc', 'conf')
@ -612,22 +605,22 @@ class Application(object):
while not self.done: while not self.done:
i = self.win.getch() i = self.win.getch()
#if not self.mini_active and self.completion_window_is_open(): # if we get a resize event, wait for things to stabilize
# self.close_completion_buffer()
if i == curses.KEY_RESIZE: if i == curses.KEY_RESIZE:
while i == curses.KEY_RESIZE: while i == curses.KEY_RESIZE: i = self.win.getch()
i = self.win.getch()
self.resize_event() self.resize_event()
self.need_draw = True self.need_draw = True
# add the keycodes to our input handler
try: try:
self.input.parse(i) self.input.parse(i)
except Exception, e: except Exception, e:
self.set_error(str(e)) self.set_error(str(e))
if self.input.tokens: # if the mode has parsed keycodes into a key, we (possibly) handle
self.need_draw = True # some actions, and refresh the screen
while self.input.tokens: while self.input.tokens:
self.need_draw = True
t = self.input.tokens.pop(0) t = self.input.tokens.pop(0)
self.active_window().mode.handle_token(t) self.active_window().mode.handle_token(t)
@ -710,6 +703,20 @@ class Application(object):
self.try_manual_resize() 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): def draw_cursor(self):
if self.mini_active: if self.mini_active:
b = self.mini_buffer b = self.mini_buffer
@ -782,20 +789,6 @@ class Application(object):
for x in range(sx1, sx2): for x in range(sx1, sx2):
self.highlight_char(sy, x, fg, bg) 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): def highlight_simple_range(self, slot, y1, x1, x2, fg, bg):
count = slot.window.mode.header count = slot.window.mode.header
tx1, tx2 = slot.window.mode.lmargin, slot.width - 1 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') help='jump to line NUM of the first argument')
parser.add_option('-m', '--mode', dest='mode', metavar='MODE', parser.add_option('-m', '--mode', dest='mode', metavar='MODE',
help='open arguments in 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, parser.add_option('-x', '--exec', action='callback', callback=exec_cb,
type='string', metavar='CMD', help='run CMD after launching') type='string', metavar='CMD', help='run CMD after launching')