mirror of
https://github.com/lowobservable/oec.git
synced 2026-03-05 19:09:04 +00:00
Implement dup and field mark
This commit is contained in:
@@ -6,9 +6,10 @@ oec.tn3270
|
||||
import logging
|
||||
from tn3270 import Telnet, Emulator, AttributeCell, CharacterCell, AID, OperatorError, \
|
||||
ProtectedCellOperatorError, FieldOverflowOperatorError
|
||||
from tn3270.ebcdic import DUP, FM
|
||||
|
||||
from .session import Session, SessionDisconnectedError
|
||||
from .display import encode_ebcdic_character, encode_string
|
||||
from .display import encode_ascii_character, encode_ebcdic_character, encode_string
|
||||
from .keyboard import Key, get_ebcdic_character_for_key
|
||||
|
||||
AID_KEY_MAP = {
|
||||
@@ -126,6 +127,10 @@ class TN3270Session(Session):
|
||||
self._handle_insert_key()
|
||||
elif key == Key.DELETE:
|
||||
self.emulator.delete()
|
||||
elif key == Key.DUP:
|
||||
self.emulator.dup()
|
||||
elif key == Key.FIELD_MARK:
|
||||
self.emulator.field_mark()
|
||||
else:
|
||||
byte = get_ebcdic_character_for_key(key)
|
||||
|
||||
@@ -163,7 +168,7 @@ class TN3270Session(Session):
|
||||
if isinstance(cell, AttributeCell):
|
||||
byte = self._map_attribute(cell.attribute)
|
||||
elif isinstance(cell, CharacterCell):
|
||||
byte = encode_ebcdic_character(cell.byte)
|
||||
byte = self._map_character(cell.byte)
|
||||
|
||||
self.terminal.display.buffered_write(byte, index=address)
|
||||
|
||||
@@ -204,6 +209,15 @@ class TN3270Session(Session):
|
||||
|
||||
return 0xc0
|
||||
|
||||
def _map_character(self, byte):
|
||||
if byte == DUP:
|
||||
return encode_ascii_character(ord('*'))
|
||||
|
||||
if byte == FM:
|
||||
return encode_ascii_character(ord(';'))
|
||||
|
||||
return encode_ebcdic_character(byte)
|
||||
|
||||
def _format_message_area(self):
|
||||
message_area = b''
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ ptyprocess==0.6.0
|
||||
pycoax==0.2.0
|
||||
pyserial==3.4
|
||||
pyte==0.8.0
|
||||
pytn3270==0.4.0
|
||||
pytn3270==0.5.0
|
||||
sliplib==0.3.0
|
||||
sortedcontainers==2.1.0
|
||||
wcwidth==0.1.7
|
||||
|
||||
@@ -183,6 +183,20 @@ class SessionHandleKeyTestCase(unittest.TestCase):
|
||||
# Assert
|
||||
self.session.emulator.delete.assert_called()
|
||||
|
||||
def test_dup(self):
|
||||
# Act
|
||||
self.session.handle_key(Key.DUP, KeyboardModifiers.NONE, None)
|
||||
|
||||
# Assert
|
||||
self.session.emulator.dup.assert_called()
|
||||
|
||||
def test_field_mark(self):
|
||||
# Act
|
||||
self.session.handle_key(Key.FIELD_MARK, KeyboardModifiers.NONE, None)
|
||||
|
||||
# Assert
|
||||
self.session.emulator.field_mark.assert_called()
|
||||
|
||||
def test_input(self):
|
||||
# Act
|
||||
self.session.handle_key(Key.LOWER_A, KeyboardModifiers.NONE, None)
|
||||
|
||||
Reference in New Issue
Block a user