ibm5250 0.1.0.dev13__tar.gz → 0.1.0.dev15__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: ibm5250
3
- Version: 0.1.0.dev13
3
+ Version: 0.1.0.dev15
4
4
  Summary: IBM 5250 terminal automation library
5
5
  License-File: LICENSE
6
6
  Requires-Python: >=3.11
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "ibm5250"
3
- version = "0.1.0.dev13"
3
+ version = "0.1.0.dev15"
4
4
  description = "IBM 5250 terminal automation library"
5
5
  requires-python = ">=3.11"
6
6
 
@@ -180,10 +180,6 @@ class TN5250Connection:
180
180
  Attempt TN5250E enhanced negotiation before falling back to basic.
181
181
  timeout:
182
182
  Socket timeout in seconds.
183
- terminal_type:
184
- Telnet terminal type reported to IBM i, which selects the display
185
- device model. The default ``IBM-3477-FC`` is a 27×132 colour display;
186
- monochrome types such as ``IBM-3477-FG`` make the host drop colours.
187
183
  """
188
184
 
189
185
  def __init__(
@@ -196,7 +192,6 @@ class TN5250Connection:
196
192
  device_name: str = "PYTERM01",
197
193
  use_tn5250e: bool = True,
198
194
  timeout: float = 30.0,
199
- terminal_type: str = "IBM-3477-FC",
200
195
  ) -> None:
201
196
  self.host = host
202
197
  self.port = port
@@ -216,7 +211,7 @@ class TN5250Connection:
216
211
  self._eor_sent = False
217
212
  self._eor_rcvd = False
218
213
  self._ttype_will_sent = False
219
- self._negotiated_ttype = terminal_type.upper() # screen model reported to IBM i
214
+ self._negotiated_ttype = "IBM-3477-FG" # screen model reported to IBM i
220
215
 
221
216
  # Byte 9 (opcode/var-header length) of the last received TN5250E record.
222
217
  # Used to detect header-only Cancel-Invite records (opcode 0x0A).
@@ -462,11 +457,6 @@ class TN5250Connection:
462
457
  def connected(self) -> bool:
463
458
  return self._sock is not None
464
459
 
465
- @property
466
- def terminal_type(self) -> str:
467
- """Telnet terminal type reported to the host (e.g. ``IBM-3477-FC``)."""
468
- return self._negotiated_ttype
469
-
470
460
  @property
471
461
  def tn5250e_active(self) -> bool:
472
462
  """True if TN5250E enhanced mode was successfully negotiated."""
@@ -245,6 +245,15 @@ next field once the current one is full. Only the modified-data tags are cleared
245
245
  locally; the resulting screen (often a Save/Restore popup handshake) is driven
246
246
  entirely by the host and handled by `_recv_and_apply()`.
247
247
 
248
+ ### Monocase fields
249
+
250
+ FFW byte 1 bit `0x20` is **Monocase** (`Field.is_monocase`). IBM i sets it on
251
+ every DDS character field defined without `CHECK(LC)`. The workstation, not the
252
+ host, is responsible for folding lower-case input to upper case, so
253
+ `Screen.set_field_text` (and therefore `type_into`, `FieldProxy.value` and
254
+ `send_command`) upper-cases text written to such a field. Note this is unrelated
255
+ to the FFW field type: _alpha shift_ (`000`) only means "accept any character".
256
+
248
257
  ### Waiting: `wait_for_text(text)`
249
258
 
250
259
  1. Checks if the text already appears on screen (from events already applied).
@@ -217,11 +217,6 @@ class DataStreamParser:
217
217
  yield from self._clear_unit(sub_command)
218
218
  # A clear is usually followed by further commands (typically
219
219
  # ESC + WTD) in the same record, so keep parsing.
220
- elif sub_command == Command.CLEAR_FORMAT_TABLE:
221
- # ESC 0x50 has no operands; a WTD usually follows in the
222
- # same record, so keep parsing.
223
- byte_offset += 1
224
- yield DSEvent(type=DSEventType.COMMAND, command=sub_command)
225
220
  elif sub_command == Command.WRITE_STRUCTURED_FIELD:
226
221
  # ESC 0xF3 — Write Structured Field
227
222
  byte_offset += 1
@@ -512,9 +507,6 @@ class DataStreamParser:
512
507
  yield DSEvent(type=DSEventType.COMMAND, command=next_byte)
513
508
  yield from self._clear_unit(next_byte)
514
509
  current_buffer_position = 0
515
- elif next_byte == Command.CLEAR_FORMAT_TABLE:
516
- byte_offset += 2 # ESC + command; no operands
517
- yield DSEvent(type=DSEventType.COMMAND, command=next_byte)
518
510
  # ESC + WTD (0x04 0x11): embedded Write to Display sub-command
519
511
  elif next_byte == Command.WRITE_TO_DISPLAY:
520
512
  if byte_offset + 4 > total_bytes:
@@ -117,6 +117,18 @@ class Field:
117
117
  """True when the field's display attribute is 'non-display' (password)."""
118
118
  return self.attribute & Attr.NON_DISPLAY_MASK == Attr.NON_DISPLAY_MASK
119
119
 
120
+ @property
121
+ def is_monocase(self) -> bool:
122
+ """True when the FFW Monocase bit is set.
123
+
124
+ The workstation folds lower-case input to upper case in such fields;
125
+ the host does not translate it. IBM i sets this bit on every DDS
126
+ character field defined without ``CHECK(LC)``.
127
+ """
128
+ return len(self.field_format_word) >= 2 and bool(
129
+ self.field_format_word[1] & FFW.MONOCASE
130
+ )
131
+
120
132
  @property
121
133
  def auto_enter(self) -> bool:
122
134
  """True when the FFW Auto-Enter bit is set.
@@ -408,9 +420,13 @@ class Screen:
408
420
  single-row write area.
409
421
 
410
422
  Sets the MDT bit so the field is included in the next AID response.
423
+ Text written to a monocase field is upper-cased, as a 5250 terminal
424
+ does for keyboard input.
411
425
  """
412
426
  if f.is_protected:
413
427
  raise FieldNotFound("Cannot write to a protected field")
428
+ if f.is_monocase:
429
+ text = text.upper()
414
430
  encoded = ebcdic_encode(text)
415
431
  # IBM i signon screens write label text for the *next* field into the
416
432
  # tail of the current field's formal area (on the following row). Only
@@ -722,13 +738,6 @@ class Screen:
722
738
  if 0 <= event.position < self._size:
723
739
  self._chars[event.position] = event.attribute_value or EBCDIC_NULL
724
740
  self._attrs[event.position] = event.attribute_value
725
- # Like a real workstation, end an input field with a normal attribute so
726
- # its display attribute (e.g. underline) stops at the end of the field
727
- # instead of running on to the next attribute byte on the screen.
728
- if event.field_format_word and event.field_length:
729
- end_pos = (event.position + 1 + event.field_length) % self._size
730
- self._chars[end_pos] = Attr.NORMAL
731
- self._attrs[end_pos] = Attr.NORMAL
732
741
 
733
742
  def _recalc_field_lengths(self) -> None:
734
743
  """Compute each field's length based on its successor's start_pos."""
@@ -82,7 +82,8 @@ class FieldProxy:
82
82
  """Write *text* into the field (marks MDT).
83
83
 
84
84
  Routed through :meth:`Terminal.type_into`, so filling a field whose FFW
85
- has the Auto-Enter bit set submits the host's Enter AID automatically.
85
+ has the Auto-Enter bit set submits the host's Enter AID automatically,
86
+ and text written to a monocase field is upper-cased.
86
87
  """
87
88
  self._term.type_into(self._field, text)
88
89
 
@@ -676,10 +677,8 @@ class Terminal:
676
677
 
677
678
  def _send_query_reply(self) -> None:
678
679
  """Respond to a server WSF Query with our terminal capabilities."""
679
- # Report the same device as the Telnet terminal type, e.g. IBM-3477-FC.
680
- _, device_type, device_model = f"{self._conn.terminal_type}--".split("-")[:3]
681
- log.debug("Sending Query Reply (%s-%s)", device_type, device_model)
682
- payload = build_query_reply(device_type=device_type, device_model=device_model)
680
+ log.debug("Sending Query Reply (IBM-3179-2, 24x80 colour)")
681
+ payload = build_query_reply(device_type="3477", device_model="FG")
683
682
  self._conn.send_record(payload, data_type=TN5250EDataType.INPUT, aid=0x88)
684
683
 
685
684
  def _wait_for(
@@ -1,5 +1,5 @@
1
1
  version = 1
2
- revision = 3
2
+ revision = 5
3
3
  requires-python = ">=3.11"
4
4
 
5
5
  [[package]]
@@ -13,7 +13,7 @@ wheels = [
13
13
 
14
14
  [[package]]
15
15
  name = "ibm5250"
16
- version = "0.1.0.dev13"
16
+ version = "0.1.0.dev15"
17
17
  source = { editable = "." }
18
18
 
19
19
  [package.dev-dependencies]
File without changes
File without changes
File without changes