diff options
| author | Mattias Andrée <maandree@operamail.com> | 2013-09-12 09:34:33 +0200 |
|---|---|---|
| committer | Mattias Andrée <maandree@operamail.com> | 2013-09-12 09:34:33 +0200 |
| commit | 5faad762f7fdabebc3d35d43af1f22d4811317d9 (patch) | |
| tree | f6f6cf015c8eff0b76cb6729cd9d3e27d17f7c1a /src/editor.py | |
| parent | implement S-left and S-right (diff) | |
| download | pytagomacs-5faad762f7fdabebc3d35d43af1f22d4811317d9.tar.gz pytagomacs-5faad762f7fdabebc3d35d43af1f22d4811317d9.tar.bz2 pytagomacs-5faad762f7fdabebc3d35d43af1f22d4811317d9.tar.xz | |
implement C-left and C-right
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'src/editor.py')
| -rw-r--r-- | src/editor.py | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/src/editor.py b/src/editor.py index 8b7b01f..d258a84 100644 --- a/src/editor.py +++ b/src/editor.py @@ -94,8 +94,6 @@ class Jump(): print(self.string, end = '') -## TODO additional key combinations C-<left>=prev-word C-<right>=next-word C-<up>=page-up C-<down>=page-down -## S-<left>=set-mark+left S-<right>=set-mark+right ## TODO colours should be configurable with rc file ## TODO ring limits should be configurable with rc file ## TODO widthless characters should be ignored when calculating the size a text @@ -566,6 +564,9 @@ class TextArea(): update_status() redraw() + def letter_type(char): + return char == ' ' + update_status() while True: if atleast(oldmark, 0) or atleast(self.mark, 0): @@ -610,8 +611,24 @@ class TextArea(): else: self.y = self.offy + self.height - 3 self.mark, self.x, self.offx = None, 0, 0 - elif d == -3: pass # TODO prev word - elif d == -4: pass # TODO next word + elif d == -3: + if self.x == 0: self.alert(_('At beginning')) + else: + x = self.x + text = self.lines[self.y].text + t = letter_type(text[x - 1]) + while (x > 0) and (letter_type(text[x - 1]) == t): + x -= 1 + self.lines[self.y].move_point(x - self.x) + elif d == -4: + if self.x == len(self.lines[self.y].text): self.alert(_('At end')) + else: + x = self.x + text = self.lines[self.y].text + t = letter_type(text[x]) + while (x < len(text)) and (letter_type(text[x]) == t): + x += 1 + self.lines[self.y].move_point(x - self.x) elif d == ctrl('@'): if self.mark is None: self.mark = self.x ; self.alert(_('Mark set')) elif self.mark == ~(self.x): self.mark = self.x ; self.alert(_('Mark activated')) |
