Implement fast cursor left and right

This commit is contained in:
Andrew Kay
2020-01-05 14:59:12 -06:00
parent 274b1a18a2
commit ada7c16af0
4 changed files with 22 additions and 2 deletions

View File

@@ -50,8 +50,10 @@ class Key(Enum):
DELETE = 265
LEFT = 266
LEFT_2 = 410
UP = 267
RIGHT = 268
RIGHT_2 = 411
DOWN = 269
ROLL_UP = 270
ROLL_DOWN = 271

View File

@@ -187,8 +187,8 @@ KEYMAP_ALT = {
# Right
95: Key.PA1,
94: Key.PA2,
# 22 - Unsure what this key is
# 26 - Unsure what this key is
22: Key.LEFT_2,
26: Key.RIGHT_2
}
MODIFIER_RELEASE_MAP = {

View File

@@ -121,8 +121,12 @@ class TN3270Session(Session):
self.emulator.cursor_down()
elif key == Key.LEFT:
self.emulator.cursor_left()
elif key == Key.LEFT_2:
self.emulator.cursor_left(rate=2)
elif key == Key.RIGHT:
self.emulator.cursor_right()
elif key == Key.RIGHT_2:
self.emulator.cursor_right(rate=2)
elif key == Key.INSERT:
self._handle_insert_key()
elif key == Key.DELETE:

View File

@@ -169,6 +169,13 @@ class SessionHandleKeyTestCase(unittest.TestCase):
# Assert
self.session.emulator.cursor_left.assert_called()
def test_left_2(self):
# Act
self.session.handle_key(Key.LEFT_2, KeyboardModifiers.NONE, None)
# Assert
self.session.emulator.cursor_left.assert_called_with(rate=2)
def test_right(self):
# Act
self.session.handle_key(Key.RIGHT, KeyboardModifiers.NONE, None)
@@ -176,6 +183,13 @@ class SessionHandleKeyTestCase(unittest.TestCase):
# Assert
self.session.emulator.cursor_right.assert_called()
def test_right_2(self):
# Act
self.session.handle_key(Key.RIGHT_2, KeyboardModifiers.NONE, None)
# Assert
self.session.emulator.cursor_right.assert_called_with(rate=2)
def test_delete(self):
# Act
self.session.handle_key(Key.DELETE, KeyboardModifiers.NONE, None)