diff --git a/application.py b/application.py index 31421bc..64daaff 100755 --- a/application.py +++ b/application.py @@ -842,16 +842,19 @@ class Application(object): # the cursor shouldn't be in the last column unless it's the end of a # line. k = x // swidth - if x < lines[y] and x == swidth: - k += 1 + #if x < len(lines[y]) and x == swidth - 1: + # k += 1 while count < slot.height: if lit: rlines = w.render_line_lit(y, swidth) else: rlines = w.render_line_raw(y, swidth) - if w.first.y > 0: - msg = '(%r + %r - 1) // %r == %r, %r' % (x, swidth, swidth, k, rlines[k:]) + if w.first.y == 65: + rlines2 = [[z.string for z in l] for l in rlines] + msg = '%r // %r == %r [%r] (%r)' % (x, swidth, k, + len(lines[y]), + rlines2) #raise Exception(msg) for j in range(k, len(rlines)): if lm: diff --git a/mode/__init__.py b/mode/__init__.py index 03823ce..923f2af 100644 --- a/mode/__init__.py +++ b/mode/__init__.py @@ -405,6 +405,7 @@ class Fundamental(Handler): return '%d%s' % (b.indentlvl, t) def _get_mark(self): w = self.window + return '(%d,%d)' % (w.first.y + 1, w.first.x + 1), if w.mark: return '(%d,%d)' % (w.mark.y + 1, w.mark.x + 1) else: diff --git a/mode/sql.py b/mode/sql.py index e077a7f..b4fb9e6 100644 --- a/mode/sql.py +++ b/mode/sql.py @@ -46,6 +46,12 @@ class FunctionGrammar(Grammar): PatternRule(r'eol', r'\n'), ] +class BitStringGrammar(Grammar): + rules = [PatternRule(r'data', r'[01]+')] + +class HexStringGrammar(Grammar): + rules = [NocasePatternRule(r'data', r'[0-9a-f]+')] + class SqlGrammar(Grammar): rules = [ PatternRule(r'spaces', r' +'), @@ -63,6 +69,8 @@ class SqlGrammar(Grammar): NocasePatternRule(r'pseudokeyword', r'(?:returns|language|right join|left join|inner join|outer join|join|where|unknown|null|true|false|into|values|as|from|order by|asc|desc|limit|distinct|cascade|using|on)(?![A-Za-z0-9_])'), NocasePatternRule(r'sql_type', r'(?:void|row|serial|varchar|float|integer|int|text|timestamptz|timestamp|datetz|date|timetz|time|boolean|bool)(?![A-Za-z0-9_])'), PatternRule(r'sql_builtin', r'(?:nextval|current_timestamp|current_time|current_date)(?![A-Za-z0-9_])'), + RegionRule(r'string', "B'", BitStringGrammar, "'"), + RegionRule(r'string', "X'", HexStringGrammar, "'"), RegionRule(r'string', "'", StringGrammar1, "'"), RegionRule(r'sql_quoted', '"', StringGrammar2, '"'), PatternRule(r'sql_bareword', r'[A-Za-z0-9_]+'), diff --git a/window.py b/window.py index d97b00e..5be7fca 100644 --- a/window.py +++ b/window.py @@ -239,7 +239,7 @@ class Window(object): # (x2, y2) = self.last_visible_coords() # if y2 < y or x2 < x: # x, y = x2, y2 - self.first = Point(x - (x % self.width), y) + self.first = Point(x, y) self.redraw() def lower_view(self): (x, y) = self.logical_cursor().xy() @@ -478,6 +478,7 @@ class Window(object): else: x -= 1 counter = 0 + # 3 means last line we see + one blank line of context while counter < self.height - 3: if x > self.width: x -= self.width