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

View File

@ -184,7 +184,8 @@ class Python(mode2.Fundamental):
# highlighting
self.colors = {
'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'),
'functionname': color.build('blue', 'default'),
'classname': color.build('green', 'default'),

View File

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

View File

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