spreadsheet

terminal spreadsheet application
git clone https://git.ce9e.org/spreadsheet.git

commit
a976538ce74991e6307e195acb44cde280e8feb8
parent
57a4c0d7db05de8dd0ff807071229dd4a321bbed
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2024-07-06 17:06
refactor cursor

Diffstat

M sheet/__main__.py 12 ++++++++----

1 files changed, 8 insertions, 4 deletions


diff --git a/sheet/__main__.py b/sheet/__main__.py

@@ -36,6 +36,10 @@ class App(boon.App):
   36    36         self.widths = {}
   37    37         self.input = None
   38    38 
   -1    39     @property
   -1    40     def cursor(self):
   -1    41         return self.cursor_x, self.cursor_y
   -1    42 
   39    43     def scroll_into_view(self, rows, cols):
   40    44         if self.cursor_y < self.y0:
   41    45             self.y0 = self.cursor_y
@@ -92,7 +96,7 @@ class App(boon.App):
   92    96         if self.input:
   93    97             lines.append(self.input.render(cols))
   94    98         else:
   95    -1             lines.append(self.sheet.get_raw((self.cursor_x, self.cursor_y)))
   -1    99             lines.append(self.sheet.get_raw(self.cursor))
   96   100 
   97   101         return lines
   98   102 
@@ -107,7 +111,7 @@ class App(boon.App):
  107   111         self.set_width(x, old + d)
  108   112 
  109   113     def submit_input(self):
  110    -1         self.sheet.set((self.cursor_x, self.cursor_y), self.input.value)
   -1   114         self.sheet.set(self.cursor, self.input.value)
  111   115         self.input = None
  112   116 
  113   117     def cancel_input(self):
@@ -146,12 +150,12 @@ class App(boon.App):
  146   150         elif key == '<':
  147   151             self.change_width(self.cursor_x, -1)
  148   152         elif key == '\n':
  149    -1             raw = self.sheet.get_raw((self.cursor_x, self.cursor_y))
   -1   153             raw = self.sheet.get_raw(self.cursor)
  150   154             self.input = Input(raw, self.submit_input, self.cancel_input, full=True)
  151   155         elif key in '=0123456789':
  152   156             self.input = Input(key, self.submit_input, self.cancel_input, full=False)
  153   157         elif key == boon.KEY_DEL:
  154    -1             self.sheet.set((self.cursor_x, self.cursor_y), '')
   -1   158             self.sheet.set(self.cursor, '')
  155   159 
  156   160 
  157   161 app = App()