diff options
| author | Mattias Andrée <maandree@operamail.com> | 2013-07-28 13:58:07 +0200 |
|---|---|---|
| committer | Mattias Andrée <maandree@operamail.com> | 2013-07-28 13:58:07 +0200 |
| commit | f9522a1af43be4a2f1432595d39cf1a3c2e558b0 (patch) | |
| tree | 89258dac1c1109a10db20ba0a1020312a430a148 | |
| parent | add editor (diff) | |
| download | pytagomacs-f9522a1af43be4a2f1432595d39cf1a3c2e558b0.tar.gz pytagomacs-f9522a1af43be4a2f1432595d39cf1a3c2e558b0.tar.bz2 pytagomacs-f9522a1af43be4a2f1432595d39cf1a3c2e558b0.tar.xz | |
m
Signed-off-by: Mattias Andrée <maandree@operamail.com>
| -rw-r--r-- | src/editor.py | 29 |
1 files changed, 11 insertions, 18 deletions
diff --git a/src/editor.py b/src/editor.py index 8709ccf..d54ef48 100644 --- a/src/editor.py +++ b/src/editor.py @@ -54,9 +54,8 @@ class TextArea(): # TODO support small screens datalines = [] for key in self.fields: - for line in self.datamap[key].split('\n'): - leftlines.append(key) - datalines.append(line) + leftlines.append(key) + datalines.append(self.datamap[key]) (termh, termw) = self.termsize (y, x) = (0, 0) @@ -87,17 +86,21 @@ class TextArea(): # TODO support small screens alerted = False edited = False print('\033[%i;%iH' % (self.top + y, innerleft + x), end='') + + def t(y, x1, x2): + return datalines[y][x1 : x2] + while True: if (oldmark is not None) and (oldmark >= 0): if oldmark < oldx: - print('\033[%i;%iH\033[49m%s\033[%i;%iH' % (self.top + oldy, innerleft + oldmark, datalines[oldy][oldmark : oldx], self.top + y, innerleft + x), end='') + print('\033[%i;%iH\033[49m%s\033[%i;%iH' % (self.top + oldy, innerleft + oldmark, t(oldy, oldmark, oldx), self.top + y, innerleft + x), end='') elif oldmark > oldx: - print('\033[%i;%iH\033[49m%s\033[%i;%iH' % (self.top + oldy, innerleft + oldx, datalines[oldy][oldx : oldmark], self.top + y, innerleft + x), end='') + print('\033[%i;%iH\033[49m%s\033[%i;%iH' % (self.top + oldy, innerleft + oldx, t(oldy, oldx, oldmark), self.top + y, innerleft + x), end='') if (mark is not None) and (mark >= 0): if mark < x: - print('\033[%i;%iH\033[44;37m%s\033[49;39m\033[%i;%iH' % (self.top + y, innerleft + mark, datalines[y][mark : x], self.top + y, innerleft + x), end='') + print('\033[%i;%iH\033[44;37m%s\033[49;39m\033[%i;%iH' % (self.top + y, innerleft + mark, t(y, mark, x), self.top + y, innerleft + x), end='') elif mark > x: - print('\033[%i;%iH\033[44;37m%s\033[49;39m\033[%i;%iH' % (self.top + y, innerleft + x, datalines[y][x : mark], self.top + y, innerleft + x), end='') + print('\033[%i;%iH\033[44;37m%s\033[49;39m\033[%i;%iH' % (self.top + y, innerleft + x, t(y, x, mark), self.top + y, innerleft + x), end='') if y != oldy: if (oldy > 0) and (leftlines[oldy - 1] == leftlines[oldy]) and (leftlines[oldy] == leftlines[-1]): print('\033[%i;%iH\033[34m%s\033[39m' % (self.top + oldy, self.left, '>'), end='') @@ -182,17 +185,7 @@ class TextArea(): # TODO support small screens elif ord(d) == ord('S') - ord('@'): last = '' for row in range(0, len(datalines)): - current = leftlines[row] - if len(datalines[row].strip()) == 0: - if current is not 'comment': - if current != last: - self.datamap[current] = None - continue - if current == last: - self.datamap[current] += '\n' + datalines[row] - else: - self.datamap[current] = datalines[row] - last = current + self.datamap[leftlines[row]] = datalines[row] saver() status('unmodified' + (' override' if override else '')) alert('Saved') |
