diff --git a/mode/sql.py b/mode/sql.py index b4fb9e6..5450384 100644 --- a/mode/sql.py +++ b/mode/sql.py @@ -69,11 +69,14 @@ 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_])'), + PatternRule(r'number', r'[0-9]+(?:e[+-]?[0-9]+)?'), + PatternRule(r'number', r'[0-9]+\.(?:[0-9]+)?(?:e[+-]?[0-9]+)?'), + PatternRule(r'number', r'\.[0-9]+(?:e[+-]?[0-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_]+'), + NocasePatternRule(r'sql_bareword', r'[a-z_][a-z0-9_]*'), PatternRule(r'empty', r'^ *\n$'), PatternRule(r'eol', r'\n'), ] diff --git a/window.py b/window.py index 5be7fca..1dac58f 100644 --- a/window.py +++ b/window.py @@ -472,16 +472,20 @@ class Window(object): def last_visible_coords(self): (x, y) = self.buffer.get_buffer_end().xy() - if x == 0: - y -= 1 - x = len(self.buffer.lines[y]) - else: - x -= 1 + #if x == 0: + # y -= 1 + # x = len(self.buffer.lines[y]) + #else: + # x -= 1 counter = 0 - # 3 means last line we see + one blank line of context + # 3 means last line we see + 2 blank line of context while counter < self.height - 3: if x > self.width: - x -= self.width + d = x % self.width + if d: + x -= d + else: + x -= self.width elif y > 0: y -= 1 x = len(self.buffer.lines[y])