some real bug fixes and improvements

--HG--
branch : pmacs2
This commit is contained in:
moculus 2007-07-03 00:05:58 +00:00
parent 6294113e20
commit 3e9abf3424
4 changed files with 28 additions and 28 deletions

View File

@ -198,10 +198,9 @@ class Application(object):
# set up curses # set up curses
self.win = curses.newwin(self.y, self.x, 0, 0) self.win = curses.newwin(self.y, self.x, 0, 0)
self.win.leaveok(1) self.win.leaveok(0)
curses.meta(1) curses.meta(1)
curses.halfdelay(1) curses.halfdelay(1)
self.hide_cursor()
def globals(self): def globals(self):
return globals() return globals()
@ -353,14 +352,6 @@ class Application(object):
# XYZ this method seems broken # XYZ this method seems broken
self.bufferlist.resize(x, y_sum) self.bufferlist.resize(x, y_sum)
# hide the curses cursor
def hide_cursor(self):
self.win.move(self.y-2, 0)
try:
curses.curs_set(0)
except:
pass
# exit # exit
def exit(self): def exit(self):
self.done = True self.done = True
@ -449,7 +440,6 @@ class Application(object):
self.draw_slots() self.draw_slots()
self.draw_input_bar() self.draw_input_bar()
self.draw_cursor() self.draw_cursor()
self.hide_cursor()
self.win.noutrefresh() self.win.noutrefresh()
curses.doupdate() curses.doupdate()
@ -460,12 +450,8 @@ class Application(object):
(cx, cy) = w.logical_cursor().xy() (cx, cy) = w.logical_cursor().xy()
if cy >= len(b.lines): if cy >= len(b.lines):
return return
elif cx == len(b.lines[cy]): (vy, vx) = (self.y - 1, cx + len(self.mini_prompt))
c = ' ' #self.win.move(self.y-1, cx + len(self.mini_prompt))
else:
c = b.lines[cy][cx]
self.win.addch(self.y-1, cx + len(self.mini_prompt), c, curses.A_REVERSE)
self.win.move(self.y-1, cx + len(self.mini_prompt))
else: else:
slot = self.bufferlist.slots[self.active_slot] slot = self.bufferlist.slots[self.active_slot]
w = slot.window w = slot.window
@ -475,9 +461,10 @@ class Application(object):
p = w.logical_cursor() p = w.logical_cursor()
count = 0 count = 0
(x, y) = w.first.xy() (x, y) = w.first.xy()
(vy, vx) = (None, None)
while count < slot.height: while count < slot.height:
if p.y == y and p.x >= x and p.x <= x + slot.width: if p.y == y and p.x >= x and p.x <= x + slot.width:
self.highlight_char(slot.offset + count, p.x - x) (vy, vx) = (slot.offset + count, p.x - x)
break break
if x + slot.width >= len(w.buffer.lines[y]): if x + slot.width >= len(w.buffer.lines[y]):
x = 0 x = 0
@ -485,7 +472,10 @@ class Application(object):
else: else:
x += slot.width x += slot.width
count += 1 count += 1
self.win.move(slot.offset + count, p.x - x) #self.win.move(slot.offset + count, p.x - x)
if vy is None or vx is None:
return
self.win.move(vy, vx)
# sub-drawing methods # sub-drawing methods
def draw_slots(self): def draw_slots(self):
@ -673,10 +663,11 @@ class Application(object):
perc = "%2d%%" % (first.y*100 / len(b.lines)) perc = "%2d%%" % (first.y*100 / len(b.lines))
# XYZ: we should actually use more of the 'state' variables # XYZ: we should actually use more of the 'state' variables
format = "----:%s-Fl %-18s (%s)--L%d--C%d--%s" #format = "%s %-18s (%s)--L%d--C%d--%s"
status = format % (modflag, name, w.mode.name(), cursor.y+1, cursor.x+1, perc) #status = format % (modflag, name, w.mode.name(), cursor.y+1, cursor.x+1, perc)
#format = "----:%s-Fl %-18s (%s)--L%d--C%d--%s--%s--%s--%s" format = "%s %-18s (%s)--L%d--C%d--%s %s %s %s"
#status = format % (modflag, name, w.mode.name(), cursor.y+1, cursor.x+1, w.first, cursor, w.last, perc) status = format % (modflag, name, w.mode.name(), cursor.y+1, cursor.x+1, perc, w.first, cursor, w.last)
status = status[:slot.width + 1] status = status[:slot.width + 1]
status += "-" * (slot.width - len(status) + 1) status += "-" * (slot.width - len(status) + 1)
self.win.addnstr(slot.height + slot.offset, 0, status, slot.width + 1, self.win.addnstr(slot.height + slot.offset, 0, status, slot.width + 1,

View File

@ -184,7 +184,8 @@ class Python(mode2.Fundamental):
# highlighting # highlighting
self.colors = { self.colors = {
'keyword': color.build('cyan', 'default'), 'keyword': color.build('cyan', 'default'),
'reserved': color.build('cyan', 'default'), #'reserved': color.build('cyan', 'default'),
'reserved': color.build('magenta', 'default'),
'builtin': color.build('cyan', 'default'), 'builtin': color.build('cyan', 'default'),
'functionname': color.build('blue', 'default'), 'functionname': color.build('blue', 'default'),
'classname': color.build('green', 'default'), 'classname': color.build('green', 'default'),

View File

@ -10,6 +10,8 @@ class Point(tuple):
raise AttributeError raise AttributeError
def __repr__(self): def __repr__(self):
return '<Point(%d, %d)>' % (self[1], self[0]) return '<Point(%d, %d)>' % (self[1], self[0])
def __str__(self):
return '(%d,%d)' % (self[1], self[0])
def xy(self): def xy(self):
return (self[1], self[0]) return (self[1], self[0])

View File

@ -116,7 +116,7 @@ class Window(object):
def _calc_last(self): def _calc_last(self):
(x, y) = self.first.xy() (x, y) = self.first.xy()
count = 0 count = 0
while count < self.height - 1 and y < len(self.buffer.lines): while count < self.height - 1 and y < len(self.buffer.lines) - 1:
line = self.buffer.lines[y] line = self.buffer.lines[y]
if x >= len(line) or len(line[x:]) <= self.width: if x >= len(line) or len(line[x:]) <= self.width:
x = 0 x = 0
@ -153,6 +153,7 @@ class Window(object):
self.cursor = Point(len(newlines[-1]) + x - p.x, y + l - 1) self.cursor = Point(len(newlines[-1]) + x - p.x, y + l - 1)
elif y == p.y and x >= p.x: elif y == p.y and x >= p.x:
self.cursor = Point(x + len(newlines[0]), y) self.cursor = Point(x + len(newlines[0]), y)
self.redraw()
self.mode.region_added(p, newlines) self.mode.region_added(p, newlines)
self.assure_visible_cursor() self.assure_visible_cursor()
@ -168,6 +169,7 @@ class Window(object):
self.cursor = Point(self.cursor.x - p2.x + p1.x, p1.y) self.cursor = Point(self.cursor.x - p2.x + p1.x, p1.y)
else: else:
self.cursor = Point(self.cursor.x, self.cursor.y - p2.y + p1.y) self.cursor = Point(self.cursor.x, self.cursor.y - p2.y + p1.y)
self.redraw()
self.mode.region_removed(p1, p2) self.mode.region_removed(p1, p2)
self.assure_visible_cursor() self.assure_visible_cursor()
@ -197,6 +199,7 @@ class Window(object):
self.redraw() self.redraw()
def assure_visible_cursor(self): def assure_visible_cursor(self):
if not self.cursor_is_visible(): if not self.cursor_is_visible():
#raise Exception, "%s < %s" % (self.last, self.logical_cursor())
self.center_view() self.center_view()
# moving in buffer # moving in buffer
@ -390,13 +393,16 @@ class Window(object):
def goto_beginning(self): def goto_beginning(self):
self.cursor = Point(0, 0) self.cursor = Point(0, 0)
self.assure_visible_cursor() self.assure_visible_cursor()
def goto_endZZZ(self):
self.cursor = self.buffer.get_buffer_end()
def goto_end(self): def goto_end(self):
self.cursor = self.buffer.get_buffer_end() self.cursor = self.buffer.get_buffer_end()
(x, y) = self.logical_cursor().xy() (x, y) = self.logical_cursor().xy()
if x == 0:
y -= 1
x = len(self.buffer.lines[y])
else:
x -= 1
counter = 0 counter = 0
while counter < self.height - 2: while counter < self.height - 3:
if x > self.width: if x > self.width:
x -= self.width x -= self.width
elif y > 0: elif y > 0: