Alternate screen size support.

This is a relatively big new feature, which introduces small breaking changes
to the API:

 * NegotiateTelnet() now returns (DevInfo, error) instead of just error.  The
   function signature for the Tx type now has one additional DevInfo parameter.
 * RunTransactions() requires one additional parameter, the DevInfo (which is
   allowed to be nil).

Otherwise, existing behavior continues to work as-is and everything still
defaults to operating on the default 24x80 terminal size.

See example5 for a larger-terminal-aware application.

Pending some time to make sure no new bugs cropped up in this release and that
the alternate screen size support works in the wild, I anticipate this will
become the v1.0.0 release of go3270.
This commit is contained in:
Matthew R. Wilson committed 2025-06-29 12:58:18 -07:00
1 parent 3a38ce6e4a
commit b6fa48f37f
19 files changed
+820 -126

No files matched your search

+15 -1
View File
@@ -86,9 +86,23 @@ type FieldRules struct {
// fields pass validation, OR 2) the user presses a key in exitkeys. In all
// other cases, HandleScreen will re-present the screen to the user again,
// possibly with an error message set in the errorField field.
//
// For alternate screen support (larger than 24x80), use HandleScreenAlt().
func HandleScreen(screen Screen, rules Rules, values map[string]string,
pfkeys, exitkeys []AID, errorField string, crow, ccol int,
conn net.Conn) (Response, error) {
return HandleScreenAlt(screen, rules, values, pfkeys, exitkeys, errorField,
crow, ccol, conn, nil)
}
// HandleScreenAlt is identical to HandleScreen, but writes to the "alternate"
// screen size provided by dev. To write a non-24-by-80 screen, use this
// HandleScreenAlt function with a non-nil dev. If dev is nil, the behavior is
// identical to HandleScreen, which is limited to 24x80 and will set larger
// terminals to the default 24x80 mode.
func HandleScreenAlt(screen Screen, rules Rules, values map[string]string,
pfkeys, exitkeys []AID, errorField string, crow, ccol int,
conn net.Conn, dev DevInfo) (Response, error) {
// Save the original field values for any named fields to support
// the MustChange rule. Also build a map of named fields.
@@ -128,7 +142,7 @@ mainloop:
}
resp, err := ShowScreenOpts(screen, myValues, conn,
ScreenOpts{CursorRow: crow, CursorCol: ccol})
ScreenOpts{CursorRow: crow, CursorCol: ccol, AltScreen: dev})
if err != nil {
return resp, err
}