Skip to content

Commit

Permalink
Fixed Arrow Keys crash & Shift Keymapping. Added Backspace going to p…
Browse files Browse the repository at this point in the history
…revious line.
  • Loading branch information
Attomsk committed May 2, 2024
1 parent 5223cb4 commit 4eb7baf
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
10 changes: 8 additions & 2 deletions e-Paper/RaspberryPi_JetsonNano/python/examples/keymaps.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# keymaps

# Mapping of characters when Shift is active
# Note: hyphen is weird, there are at least three different hyphen characters
shift_mapping = {
'1': '!',
'2': '@',
Expand All @@ -12,7 +13,9 @@
'8': '*',
'9': '(',
'0': ')',
'-': '_',
chr(45): '_',
chr(8208): '_',
chr(8722): '_',
'=': '+',
'`': '~',
'q': 'Q',
Expand Down Expand Up @@ -46,4 +49,7 @@
',': '<',
'.': '>',
'/': '?',
}
'[':'{',
']':'}',
'\\':'|',
}
11 changes: 9 additions & 2 deletions e-Paper/RaspberryPi_JetsonNano/python/examples/zerowriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,13 @@ def delete_character(self):
self.input_content = self.input_content[:self.cursor_position - 1] + self.input_content[self.cursor_position:]
self.cursor_position -= 1 # Move the cursor back
#self.needs_input_update = True
#No characters on the line, move up to previous line
elif len(self.previous_lines) > 0:
self.input_content = ""
self.input_content = self.previous_lines[len(self.previous_lines)-1]
self.previous_lines.pop(len(self.previous_lines)-1)
self.cursor_position = len(self.input_content)
self.needs_display_update = True

def handle_key_down(self, e):
if e.name == 'shift': #if shift is released
Expand Down Expand Up @@ -637,7 +644,7 @@ def handle_key_press(self, e):
if e.name == "esc":
self.show_menu()

if e.name== "down" or e.name== "right" and display_updating==False:
if e.name== "down" or e.name== "right" and self.display_updating==False:
self.scrollindex = self.scrollindex - 1
if self.scrollindex < 1:
self.scrollindex = 1
Expand All @@ -646,7 +653,7 @@ def handle_key_press(self, e):
time.sleep(delay)


if e.name== "up" or e.name== "left" and display_updating==False:
if e.name== "up" or e.name== "left" and self.display_updating==False:
self.scrollindex = self.scrollindex + 1
if self.scrollindex > round(len(self.previous_lines)/self.lines_on_screen+1):
self.scrollindex = round(len(self.previous_lines)/self.lines_on_screen+1)
Expand Down

0 comments on commit 4eb7baf

Please sign in to comment.