From c83a79dc96d0745b390a46e272cbfb59533b23d3 Mon Sep 17 00:00:00 2001 From: Paul Oliver Date: Thu, 29 Feb 2024 02:29:14 +0100 Subject: Fast vertical pan on World page. [#24] Capital W and S keys now apply fast vertical pan on World page. --- bin/README.md | 1 + bin/handler.py | 2 ++ bin/world.py | 24 ++++++++++++++++++------ 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/bin/README.md b/bin/README.md index ec6ff17..0d95d18 100644 --- a/bin/README.md +++ b/bin/README.md @@ -19,6 +19,7 @@ $ ./bin/salis.py load --file 16.sim |Left/Right arrow |Previous/next page | |Up/Down arrows |Scroll page up/down if it can't fit terminal | |`wasd` |Scroll/pan (PROCESS and WORLD page) | +|`WS` |Fast vertical scroll (PROCESS and WORLD page) | |`Q` |Scroll to top (PROCESS and WORLD page) | |`A` |Scroll to left (PROCESS page) | |`zx` |Zoom in/out (WORLD page) | diff --git a/bin/handler.py b/bin/handler.py index 9c8ffaf..2bc8c25 100644 --- a/bin/handler.py +++ b/bin/handler.py @@ -70,8 +70,10 @@ class Handler: self.__printer.world.pan_up() self.__printer.proc_scroll_up() elif cmd == ord("S"): + self.__printer.world.pan_down(fast=True) self.__printer.proc_scroll_down(fast=True) elif cmd == ord("W"): + self.__printer.world.pan_up(fast=True) self.__printer.proc_scroll_up(fast=True) elif cmd == ord("Q"): self.__printer.world.pan_reset() diff --git a/bin/world.py b/bin/world.py index 31674f2..08f2734 100644 --- a/bin/world.py +++ b/bin/world.py @@ -113,18 +113,25 @@ class World: max_pos = self.__sim.lib.sal_mem_get_size() - 1 self.pos = min(self.pos + self.zoom, max_pos) - def pan_down(self): - """ Pan world downward (pos += zoom * columns). + def pan_down(self, fast=False): + """ Pan world downward. """ if self.__is_world_editable(): - self.pos = max(self.pos - self.__get_line_area(), 0) + if fast: + self.pos = max(self.pos - self.__get_world_area(), 0) + else: + self.pos = max(self.pos - self.__get_line_area(), 0) - def pan_up(self): - """ Pan world upward (pos -= zoom * columns). + def pan_up(self, fast=False): + """ Pan world upward. """ if self.__is_world_editable(): max_pos = self.__sim.lib.sal_mem_get_size() - 1 - self.pos = min(self.pos + self.__get_line_area(), max_pos) + + if fast: + self.pos = min(self.pos + self.__get_world_area(), max_pos) + else: + self.pos = min(self.pos + self.__get_line_area(), max_pos) def pan_reset(self): """ Set world position to zero. @@ -265,3 +272,8 @@ class World: line_size = self.__printer.size[1] - self.PADDING line_area = self.zoom * line_size return line_area + + def __get_world_area(self): + """ Return amount of bytes contained in the entire WORLD view. + """ + return self.__get_line_area() * self.__printer.size[0] -- cgit v1.2.1