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:
1 parent
3a38ce6e4a
commit
b6fa48f37f
19 files changed
+820
-126
No files matched your search
@@ -75,8 +75,13 @@ func handle(conn net.Conn, db DB, gblstate *global) {
|
||||
}()
|
||||
|
||||
// Always begin new connection by negotiating the telnet options
|
||||
go3270.NegotiateTelnet(conn)
|
||||
err := go3270.RunTransactions(conn, state.login, nil)
|
||||
devinfo, err := go3270.NegotiateTelnet(conn)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
|
||||
err = go3270.RunTransactions(conn, devinfo, state.login, nil)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
|
||||
+2
-1
@@ -48,7 +48,8 @@ var helpScreen = go3270.Screen{
|
||||
// generator function for it is a stand-alone function and not a method on the
|
||||
// session.
|
||||
func help(returnTransaction go3270.Tx) go3270.Tx {
|
||||
return func(conn net.Conn, data any) (go3270.Tx, any, error) {
|
||||
return func(conn net.Conn, _ go3270.DevInfo, data any) (
|
||||
go3270.Tx, any, error) {
|
||||
_, err := go3270.HandleScreen(
|
||||
helpScreen, // the screen to display
|
||||
nil, // (no) rules to enforce
|
||||
|
||||
+4
-2
@@ -58,7 +58,8 @@ var loginScreenRules = go3270.Rules{
|
||||
|
||||
// login transaction accepts a string value in data if the login screen
|
||||
// should be initialized with an error message.
|
||||
func (sess *session) login(conn net.Conn, data any) (go3270.Tx, any, error) {
|
||||
func (sess *session) login(conn net.Conn, _ go3270.DevInfo,
|
||||
data any) (go3270.Tx, any, error) {
|
||||
|
||||
fieldValues := make(map[string]string)
|
||||
|
||||
@@ -169,7 +170,8 @@ type newuserData struct {
|
||||
errmsg string
|
||||
}
|
||||
|
||||
func (sess *session) newuser(conn net.Conn, data any) (go3270.Tx, any, error) {
|
||||
func (sess *session) newuser(conn net.Conn, _ go3270.DevInfo, data any) (
|
||||
go3270.Tx, any, error) {
|
||||
|
||||
fieldValues := make(map[string]string)
|
||||
|
||||
|
||||
@@ -79,7 +79,8 @@ type mainmenuData struct {
|
||||
|
||||
// mainmenu transaction accepts a mainmenuData struct as the data if the
|
||||
// option field or error message should be populated.
|
||||
func (sess *session) mainmenu(conn net.Conn, data any) (go3270.Tx, any, error) {
|
||||
func (sess *session) mainmenu(conn net.Conn, _ go3270.DevInfo, data any) (
|
||||
go3270.Tx, any, error) {
|
||||
|
||||
fieldValues := make(map[string]string)
|
||||
|
||||
@@ -182,8 +183,8 @@ var exampleScreen = go3270.Screen{
|
||||
// exampleFeature is a transaction that will act as a placeholder for real
|
||||
// application functionality. It accepts a string in the data which will
|
||||
// be displayed on the panel.
|
||||
func (sess *session) exampleFeature(conn net.Conn, data any) (go3270.Tx,
|
||||
any, error) {
|
||||
func (sess *session) exampleFeature(conn net.Conn, _ go3270.DevInfo,
|
||||
data any) (go3270.Tx, any, error) {
|
||||
|
||||
fieldValues := make(map[string]string)
|
||||
|
||||
|
||||
Reference in new issue
Block a user