diff options
| author | Mattias Andrée <maandree@operamail.com> | 2013-09-10 12:52:22 +0200 |
|---|---|---|
| committer | Mattias Andrée <maandree@operamail.com> | 2013-09-10 12:52:22 +0200 |
| commit | 5ffb460c743d9eda86a52d0eec57da14086abfba (patch) | |
| tree | 421f4863f6433e58186ba3c8921b5609003fb8a7 | |
| parent | fix some cursur issues and screen offset issues (diff) | |
| download | pytagomacs-5ffb460c743d9eda86a52d0eec57da14086abfba.tar.gz pytagomacs-5ffb460c743d9eda86a52d0eec57da14086abfba.tar.bz2 pytagomacs-5ffb460c743d9eda86a52d0eec57da14086abfba.tar.xz | |
implement up and down browsing
Signed-off-by: Mattias Andrée <maandree@operamail.com>
| -rw-r--r-- | src/editor.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/editor.py b/src/editor.py index f09c5b2..180e6e3 100644 --- a/src/editor.py +++ b/src/editor.py @@ -454,13 +454,22 @@ class TextArea(): self.alert(error_message) def update_status(): - below = len(self.lines) + 2 - self.height + below = len(self.lines) - (self.offy + self.height - 2) mode_text = 'modified' if modified else 'unmodified' ins_text = ' override' if override else '' above = ' +%i↑' % self.offy if self.offy > 0 else '' below = ' +%i↓' % below if below > 0 else '' self.status(mode_text + ins_text + above + below) + def ensure_y(): + nonlocal stored + if self.y - self.offy < 0: + self.offy -= 1 + if self.y - self.offy >= self.height - 2: + self.offy += 1 + update_status() + stored = ctrl('L') + update_status() while True: if atleast(oldmark, 0) or atleast(self.mark, 0): @@ -515,6 +524,7 @@ class TextArea(): self.alert('At first line') else: self.y -= 1 + ensure_y() self.mark, self.x, self.offx = None, 0, 0 update_status() elif d == ctrl('N'): @@ -522,6 +532,7 @@ class TextArea(): self.alert('At last line') else: self.y += 1 + ensure_y() self.mark, self.x, self.offx = None, 0, 0 update_status() elif d == ctrl('D'): edit(lambda L : L.delete(), 'At end') |
