bugfixes for long-lines

--HG--
branch : pmacs2
This commit is contained in:
moculus 2007-06-26 19:26:32 +00:00
parent ed1dd1a125
commit d6d5e717d0
3 changed files with 17 additions and 12 deletions

View File

@ -14,6 +14,7 @@ import mode_blame, mode_diff
import mode_c, mode_python, mode_perl, mode_nasm, mode_sh, mode_javascript, mode_sql import mode_c, mode_python, mode_perl, mode_nasm, mode_sh, mode_javascript, mode_sql
import mode_xml, mode_tt import mode_xml, mode_tt
import mode_life, mode_text, mode_mutt import mode_life, mode_text, mode_mutt
import mode_bds
def run(buffers, jump_to_line=None, init_mode=None): def run(buffers, jump_to_line=None, init_mode=None):
# save terminal state so we can restore it when the program exits # save terminal state so we can restore it when the program exits
@ -102,6 +103,7 @@ class Application(object):
'javascript': mode_javascript.Javascript, 'javascript': mode_javascript.Javascript,
'sql': mode_sql.Sql, 'sql': mode_sql.Sql,
'template': mode_tt.Template, 'template': mode_tt.Template,
'bds': mode_bds.BDS
} }
# these are used in this order to determine which mode to open certain # these are used in this order to determine which mode to open certain
@ -110,9 +112,10 @@ class Application(object):
'/etc/profile': 'sh', '/etc/profile': 'sh',
} }
self.mode_basenames = { self.mode_basenames = {
'.bashrc': 'sh', '.bashrc': 'sh',
'.bash_profile': 'sh', '.bash_profile': 'sh',
'.profile': 'sh', '.profile': 'sh',
'components.xml': 'bds',
} }
self.mode_extensions = { self.mode_extensions = {
'.py': 'python', '.py': 'python',
@ -498,10 +501,10 @@ class Application(object):
while count < slot.height: while count < slot.height:
if p1.y == y and px >= x and px < x + slot.width: if p1.y == y and px >= x and px < x + slot.width:
if px + slot.width > p2.x: if px + slot.width > p2.x:
self.highlight_chars(slot.offset + count, px, p2.x) self.highlight_chars(slot.offset + count, px - x, p2.x -x)
break break
else: else:
self.highlight_chars(slot.offset + count, px, px + slot.width) self.highlight_chars(slot.offset + count, px - x, px + slot.width -x-1)
px += slot.width px += slot.width
if x + slot.width >= len(w.buffer.lines[y]): if x + slot.width >= len(w.buffer.lines[y]):
x = 0 x = 0
@ -593,14 +596,13 @@ class Application(object):
s_offset = max(x - token.x, 0) s_offset = max(x - token.x, 0)
x_offset = max(token.x - x, 0) x_offset = max(token.x - x, 0)
#assert x_offset < slot.width, '%d < %d' % (x_offset, slot.width)
assert x_offset <= slot.width, '%d <= %d' % (x_offset, slot.width) assert x_offset <= slot.width, '%d <= %d' % (x_offset, slot.width)
c = self._get_token_color(w, token) c = self._get_token_color(w, token)
s = token.string[s_offset:] s = token.string[s_offset:]
token_done = x_offset + len(s) <= slot.width token_done = x_offset + len(s) <= slot.width
token_wrap = x_offset + len(s) > slot.width token_wrap = x_offset + len(s) > slot.width
self.win.addstr(slot.offset + count, x_offset, s[:slot.width], c) self.win.addstr(slot.offset + count, x_offset, s[:slot.width - x_offset], c)
if token_wrap: if token_wrap:
self.win.addch(slot.offset + count, slot.width, '\\', redattr) self.win.addch(slot.offset + count, slot.width, '\\', redattr)
@ -608,6 +610,8 @@ class Application(object):
count += 1 count += 1
if token_done: if token_done:
j += 1 j += 1
if count >= slot.height:
break
# we have finished this logical line of tokens # we have finished this logical line of tokens
j = 0 j = 0

View File

@ -14,6 +14,7 @@ class PodGrammar(Grammar):
class StringGrammar(Grammar): class StringGrammar(Grammar):
rules = [ rules = [
PatternRule(name=r'octal', pattern=r'\\[0-7]{3}'),
PatternRule(name=r'escaped', pattern=r'\\.'), PatternRule(name=r'escaped', pattern=r'\\.'),
PatternRule(name=r'deref', pattern=r"\$+[A-Za-z0-9_](?:[A-Za-z0-9_]|::)*(?:->{\$?(?:[a-zA-Z_][a-zA-Z_0-9]*|'(?:\\.|[^'\\])*'|\"(\\.|[^\\\"])*\")}|->\[\$?[0-9a-zA-Z_]+\])+"), PatternRule(name=r'deref', pattern=r"\$+[A-Za-z0-9_](?:[A-Za-z0-9_]|::)*(?:->{\$?(?:[a-zA-Z_][a-zA-Z_0-9]*|'(?:\\.|[^'\\])*'|\"(\\.|[^\\\"])*\")}|->\[\$?[0-9a-zA-Z_]+\])+"),
PatternRule(name=r'length', pattern=r"\$#[A-Za-z0-9_](?:[A-Za-z0-9_]|::)*"), PatternRule(name=r'length', pattern=r"\$#[A-Za-z0-9_](?:[A-Za-z0-9_]|::)*"),

View File

@ -20,9 +20,9 @@ class XML(mode2.Fundamental):
grammar = XMLGrammar grammar = XMLGrammar
def __init__(self, w): def __init__(self, w):
mode2.Fundamental.__init__(self, w) mode2.Fundamental.__init__(self, w)
self.add_bindings('close-paren', (')',)) #self.add_bindings('close-paren', (')',))
self.add_bindings('close-brace', ('}',)) #self.add_bindings('close-brace', ('}',))
self.add_bindings('close-bracket', (']',)) #self.add_bindings('close-bracket', (']',))
self.colors = { self.colors = {
'comment': color.build('red', 'default'), 'comment': color.build('red', 'default'),
'opentag.start': color.build('default', 'default'), 'opentag.start': color.build('default', 'default'),