diff --git a/application.py b/application.py index 1396ae4..31421bc 100755 --- a/application.py +++ b/application.py @@ -834,15 +834,25 @@ class Application(object): lines = w.buffer.lines count = w.mode.header swidth = slot.width - lm - rm - k = (x + swidth - 1) // swidth modename = w.mode.name() lit = w.mode.name() in w.buffer.highlights ended = False + + # figure out which "physical line" is the first to be shown. note that + # 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 + 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:]) + #raise Exception(msg) for j in range(k, len(rlines)): if lm: lcont = j > 0 diff --git a/mode/__init__.py b/mode/__init__.py index c533964..03823ce 100644 --- a/mode/__init__.py +++ b/mode/__init__.py @@ -419,6 +419,7 @@ class Fundamental(Handler): 'perc': self._get_perc(), 'indent': self._get_indent(), 'cursor': '(%d,%d)' % (c.y + 1, c.x + 1), + 'first': '(%d,%d)' % (w.first.y + 1, w.first.x + 1), 'mark': self._get_mark(), } return d diff --git a/mode/python.py b/mode/python.py index 4021531..0f699e8 100644 --- a/mode/python.py +++ b/mode/python.py @@ -603,7 +603,7 @@ class Python(mode.Fundamental): 'python.lib': '.', } lconfig = { - 'ignore-suffix': ['.pyc'], + 'ignore-suffix': ['.pyc', '.pyo'], } actions = [PythonCommentRegion, PythonUncommentRegion, PythonInitNames, PythonListNames, PythonGotoName, @@ -616,15 +616,14 @@ class Python(mode.Fundamental): "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/%(first)s %(perc)s [%(name)s]" + format = "%(flag)s %(bname)-18s (%(mname)s) %(indent)s %(cursor)s/%(mark)s %(perc)s [%(name)s]" header_size = 3 def get_status_names(self): names = mode.Fundamental.get_status_names(self) c = self.window.logical_cursor() names['name'] = self.context.get_line_name(c.y) - names['first'] = self.window.first.xy() + #names['first'] = self.window.first.xy() return names # xyz diff --git a/mode/sql.py b/mode/sql.py index 72cc429..0baf31a 100644 --- a/mode/sql.py +++ b/mode/sql.py @@ -1,6 +1,7 @@ import mode, tab from lex import Grammar, PatternRule, NocasePatternRule, RegionRule, NocaseRegionRule from mode.python import StringGrammar1, StringGrammar2 +from method import CommentRegion, UncommentRegion class PlPgSqlGrammar(Grammar): rules = [ @@ -69,6 +70,11 @@ class SqlGrammar(Grammar): PatternRule(r'eol', r'\n'), ] +class SqlCommentRegion(CommentRegion): + commentc = '--' +class SqlUncommentRegion(UncommentRegion): + commentc = '--' + class SqlTabber(tab.StackTabber): wst = ('null', 'eol',) def is_base(self, y):