fixed super annoying long-line bug

--HG--
branch : pmacs2
This commit is contained in:
moculus 2009-02-03 19:16:38 +00:00
parent bfa188627e
commit 482ef39720
4 changed files with 38 additions and 21 deletions

2
BUGS
View File

@ -13,6 +13,7 @@
2008/06/25: 2008/06/25:
* occasionally when the "first" point is wrapped things get confused. * occasionally when the "first" point is wrapped things get confused.
(fixed 2009/02/03)
* the "last visible" calculation doesn't handle long lines correctly. * the "last visible" calculation doesn't handle long lines correctly.
this affects page-up/page-down/etc. this affects page-up/page-down/etc.
@ -29,6 +30,7 @@
2008/05/03: 2008/05/03:
first-visible/cursor syncing with drawn window may be buggy. first-visible/cursor syncing with drawn window may be buggy.
(fixed 2009/02/03)
2007/09/14: 2007/09/14:
known deficiencies: known deficiencies:

View File

@ -1,5 +1,6 @@
#!/usr/bin/env python #!/usr/bin/env python
import curses, curses.ascii, getpass, os, re, string, sys, termios, time import curses, curses.ascii, getpass, os, re, string, sys, termios, time
import math
import traceback import traceback
from subprocess import Popen, PIPE, STDOUT from subprocess import Popen, PIPE, STDOUT
@ -715,6 +716,9 @@ class Application(object):
while count < slot.height: while count < slot.height:
if p.y == y and p.x >= x and p.x <= x + swidth: if p.y == y and p.x >= x and p.x <= x + swidth:
vy, vx = slot.y_offset + count, p.x - x + w.mode.lmargin vy, vx = slot.y_offset + count, p.x - x + w.mode.lmargin
if vx == swidth and p.x < len(w.buffer.lines[y]):
vx = 0
vy += 1
break break
if y >= blen or x + swidth >= len(w.buffer.lines[y]): if y >= blen or x + swidth >= len(w.buffer.lines[y]):
@ -828,15 +832,16 @@ class Application(object):
lm, rm = w.mode.lmargin, w.mode.rmargin lm, rm = w.mode.lmargin, w.mode.rmargin
lines = w.buffer.lines lines = w.buffer.lines
count = w.mode.header count = w.mode.header
k = x // (slot.width - lm - rm) swidth = slot.width - lm - rm
k = (x + swidth - 1) // swidth
modename = w.mode.name() modename = w.mode.name()
lit = w.mode.name() in w.buffer.highlights lit = w.mode.name() in w.buffer.highlights
ended = False ended = False
while count < slot.height: while count < slot.height:
if lit: if lit:
rlines = w.render_line_lit(y, slot.width - lm - rm) rlines = w.render_line_lit(y, swidth)
else: else:
rlines = w.render_line_raw(y, slot.width - lm - rm) rlines = w.render_line_raw(y, swidth)
for j in range(k, len(rlines)): for j in range(k, len(rlines)):
if lm: if lm:
lcont = j > 0 lcont = j > 0

View File

@ -37,6 +37,25 @@ class JavaGrammar(Grammar):
PatternRule(r"eol", r"\n$"), PatternRule(r"eol", r"\n$"),
] ]
CLASS_MATCH = And(Optional(Name('spaces')),
Matchs('keyword', ('public', 'protected', 'private')),
Name('spaces'),
Match('keyword', 'class'),
Name('spaces'),
Name('identifier'))
CLASS_OFFSET = 1
METHOD_MATCH = And(Optional(Name('spaces')),
Matchs('keyword', ('public', 'protected', 'private')),
Name('spaces'),
Optional(And(Match('keyword', 'static'), Name('spaces'))),
Any(),
Name('spaces'),
Name('identifier'),
Optional(Name('spaces')),
Match('delimiter', '('))
METHOD_OFFSET = 2
class JavaTabber2(tab.StackTabber2): class JavaTabber2(tab.StackTabber2):
open_tokens = {'delimiter': {'{': '}', '(': ')', '[': ']'}} open_tokens = {'delimiter': {'{': '}', '(': ')', '[': ']'}}
close_tokens = {'delimiter': {'}': '{', ')': '(', ']': '['}} close_tokens = {'delimiter': {'}': '{', ')': '(', ']': '['}}
@ -61,23 +80,10 @@ class JavaTabber2(tab.StackTabber2):
'comment.data', 'comment.null', 'comment.end') 'comment.data', 'comment.null', 'comment.end')
class JavaContext(context.Context): class JavaContext(context.Context):
class_match = And(Optional(Name('spaces')), class_match = CLASS_MATCH
Matchs('keyword', ('public', 'protected', 'private')), class_offset = CLASS_OFFSET
Name('spaces'), method_match = METHOD_MATCH
Match('keyword', 'class'), method_offset = METHOD_OFFSET
Name('spaces'),
Name('identifier'))
class_offset = 1
method_match = And(Optional(Name('spaces')),
Matchs('keyword', ('public', 'protected', 'private')),
Name('spaces'),
Optional(And(Match('keyword', 'static'), Name('spaces'))),
Any(),
Name('spaces'),
Name('identifier'),
Optional(Name('spaces')),
Match('delimiter', '('))
method_offset = 2
def _regen_stack(self, y): def _regen_stack(self, y):
if y > 0 and self.namelines[y - 1][1]: if y > 0 and self.namelines[y - 1][1]:
return list(self.namelines[y - 1][1]) return list(self.namelines[y - 1][1])
@ -149,10 +155,12 @@ class Java(mode.Fundamental):
} }
format = "%(flag)s %(bname)-18s (%(mname)s) %(indent)s %(cursor)s/%(mark)s %(perc)s [%(func)s]" format = "%(flag)s %(bname)-18s (%(mname)s) %(indent)s %(cursor)s/%(mark)s %(perc)s [%(func)s]"
#format = "%(flag)s %(bname)-18s (%(mname)s) %(indent)s %(cursor)s/%(first)s %(perc)s [%(func)s]"
def get_status_names(self): def get_status_names(self):
names = mode.Fundamental.get_status_names(self) names = mode.Fundamental.get_status_names(self)
c = self.window.logical_cursor() c = self.window.logical_cursor()
names['func'] = self.get_line_function(c.y) names['func'] = self.get_line_function(c.y)
#names['first'] = self.window.first.xy()
return names return names
def __init__(self, w): def __init__(self, w):

View File

@ -545,12 +545,14 @@ class Python(mode.Fundamental):
"pythonclass": PythonClassCompleter(None), "pythonclass": PythonClassCompleter(None),
} }
format = "%(flag)s %(bname)-18s (%(mname)s) %(indent)s %(cursor)s/%(mark)s %(perc)s [%(name)s]" #format = "%(flag)s %(bname)-18s (%(mname)s) %(indent)s %(cursor)s/%(mark)s %(perc)s [%(name)s]"
format = "%(flag)s %(bname)-18s (%(mname)s) %(indent)s %(cursor)s/%(first)s %(perc)s [%(name)s]"
def get_status_names(self): def get_status_names(self):
names = mode.Fundamental.get_status_names(self) names = mode.Fundamental.get_status_names(self)
c = self.window.logical_cursor() c = self.window.logical_cursor()
names['name'] = self.context.get_line_name(c.y) names['name'] = self.context.get_line_name(c.y)
names['first'] = self.window.first.xy()
return names return names
def __init__(self, w): def __init__(self, w):