aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorPaul Oliver <contact@pauloliver.dev>2024-02-29 02:29:14 +0100
committerPaul Oliver <contact@pauloliver.dev>2024-02-29 02:29:14 +0100
commitc83a79dc96d0745b390a46e272cbfb59533b23d3 (patch)
tree8caa388e0c5b3b8f84ac6fe2c9b1dd0b70bd809c /bin
parent76979c3530ed5303946cbb94657b3ba50c757e01 (diff)
Fast vertical pan on World page.
[#24] Capital W and S keys now apply fast vertical pan on World page.
Diffstat (limited to 'bin')
-rw-r--r--bin/README.md1
-rw-r--r--bin/handler.py2
-rw-r--r--bin/world.py24
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]