Add auto-skip support to protected fields
This commit is contained in:
1 parent
b6d2a09532
commit
d39b10e79d
3 files changed
+17
-9
No files matched your search
@@ -26,13 +26,13 @@ var screen1 = go3270.Screen{
|
|||||||
{Row: 2, Col: 0, Content: "Welcome to the go3270 example application. Please enter your name."},
|
{Row: 2, Col: 0, Content: "Welcome to the go3270 example application. Please enter your name."},
|
||||||
{Row: 4, Col: 0, Content: "First Name . . ."},
|
{Row: 4, Col: 0, Content: "First Name . . ."},
|
||||||
{Row: 4, Col: 19, Name: "fname", Write: true, Highlighting: go3270.Underscore},
|
{Row: 4, Col: 19, Name: "fname", Write: true, Highlighting: go3270.Underscore},
|
||||||
{Row: 4, Col: 40}, // field "stop" character
|
{Row: 4, Col: 40, Autoskip: true}, // field "stop" character
|
||||||
{Row: 5, Col: 0, Content: "Last Name . . . ."},
|
{Row: 5, Col: 0, Content: "Last Name . . . ."},
|
||||||
{Row: 5, Col: 19, Name: "lname", Write: true, Highlighting: go3270.Underscore},
|
{Row: 5, Col: 19, Name: "lname", Write: true, Highlighting: go3270.Underscore},
|
||||||
{Row: 5, Col: 40}, // field "stop" character,
|
{Row: 5, Col: 40, Autoskip: true}, // field "stop" character
|
||||||
{Row: 6, Col: 0, Content: "Password . . . ."},
|
{Row: 6, Col: 0, Content: "Password . . . ."},
|
||||||
{Row: 6, Col: 19, Name: "password", Write: true, Hidden: true},
|
{Row: 6, Col: 19, Name: "password", Write: true, Hidden: true},
|
||||||
{Row: 6, Col: 40}, // field "stop" character,
|
{Row: 6, Col: 40}, // field "stop" character
|
||||||
{Row: 8, Col: 0, Content: "Press"},
|
{Row: 8, Col: 0, Content: "Press"},
|
||||||
{Row: 8, Col: 6, Intense: true, Content: "enter"},
|
{Row: 8, Col: 6, Intense: true, Content: "enter"},
|
||||||
{Row: 8, Col: 12, Content: "to submit your name."},
|
{Row: 8, Col: 12, Content: "to submit your name."},
|
||||||
|
|||||||
@@ -26,13 +26,13 @@ var screen1 = go3270.Screen{
|
|||||||
{Row: 2, Col: 0, Content: "Welcome to the go3270 example application. Please enter your name."},
|
{Row: 2, Col: 0, Content: "Welcome to the go3270 example application. Please enter your name."},
|
||||||
{Row: 4, Col: 0, Content: "First Name . . ."},
|
{Row: 4, Col: 0, Content: "First Name . . ."},
|
||||||
{Row: 4, Col: 19, Name: "fname", Write: true, Highlighting: go3270.Underscore},
|
{Row: 4, Col: 19, Name: "fname", Write: true, Highlighting: go3270.Underscore},
|
||||||
{Row: 4, Col: 40}, // field "stop" character
|
{Row: 4, Col: 40, Autoskip: true}, // field "stop" character
|
||||||
{Row: 5, Col: 0, Content: "Last Name . . . ."},
|
{Row: 5, Col: 0, Content: "Last Name . . . ."},
|
||||||
{Row: 5, Col: 19, Name: "lname", Write: true, Highlighting: go3270.Underscore},
|
{Row: 5, Col: 19, Name: "lname", Write: true, Highlighting: go3270.Underscore},
|
||||||
{Row: 5, Col: 40}, // field "stop" character,
|
{Row: 5, Col: 40, Autoskip: true}, // field "stop" character,
|
||||||
{Row: 6, Col: 0, Content: "Password . . . ."},
|
{Row: 6, Col: 0, Content: "Password . . . ."},
|
||||||
{Row: 6, Col: 19, Name: "password", Write: true, Hidden: true},
|
{Row: 6, Col: 19, Name: "password", Write: true, Hidden: true},
|
||||||
{Row: 6, Col: 40}, // field "stop" character,
|
{Row: 6, Col: 40, Autoskip: true}, // field "stop" character,
|
||||||
{Row: 7, Col: 0, Content: "Change me . . ."},
|
{Row: 7, Col: 0, Content: "Change me . . ."},
|
||||||
{Row: 7, Col: 19, Name: "changeme", Content: "change me", Write: true, Highlighting: go3270.Underscore},
|
{Row: 7, Col: 19, Name: "changeme", Content: "change me", Write: true, Highlighting: go3270.Underscore},
|
||||||
{Row: 7, Col: 40}, // field "stop" character
|
{Row: 7, Col: 40}, // field "stop" character
|
||||||
|
|||||||
@@ -28,6 +28,11 @@ type Field struct {
|
|||||||
// Write allows the user to edit the value of the field.
|
// Write allows the user to edit the value of the field.
|
||||||
Write bool
|
Write bool
|
||||||
|
|
||||||
|
// Autoskip causes protected (Write = false) fields to automatically be
|
||||||
|
// skipped and the cursor should move to the next field upon encountering
|
||||||
|
// this field. Autoskip is ignored on fields with Write = true.
|
||||||
|
Autoskip bool
|
||||||
|
|
||||||
// Intense indicates this field should be displayed with high intensity.
|
// Intense indicates this field should be displayed with high intensity.
|
||||||
Intense bool
|
Intense bool
|
||||||
|
|
||||||
@@ -188,7 +193,7 @@ func buildField(f Field) []byte {
|
|||||||
if f.Color == DefaultColor && f.Highlighting == DefaultHighlight {
|
if f.Color == DefaultColor && f.Highlighting == DefaultHighlight {
|
||||||
// this is a traditional field, issue a normal sf command
|
// this is a traditional field, issue a normal sf command
|
||||||
buf.WriteByte(0x1d) // sf - "start field"
|
buf.WriteByte(0x1d) // sf - "start field"
|
||||||
buf.WriteByte(sfAttribute(f.Write, f.Intense, f.Hidden))
|
buf.WriteByte(sfAttribute(f.Write, f.Intense, f.Hidden, f.Autoskip))
|
||||||
return buf.Bytes()
|
return buf.Bytes()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -205,7 +210,7 @@ func buildField(f Field) []byte {
|
|||||||
|
|
||||||
// Write the basic field attribute
|
// Write the basic field attribute
|
||||||
buf.WriteByte(0xc0)
|
buf.WriteByte(0xc0)
|
||||||
buf.WriteByte(sfAttribute(f.Write, f.Intense, f.Hidden))
|
buf.WriteByte(sfAttribute(f.Write, f.Intense, f.Hidden, f.Autoskip))
|
||||||
|
|
||||||
// Write the highlighting attribute
|
// Write the highlighting attribute
|
||||||
if f.Highlighting != DefaultHighlight {
|
if f.Highlighting != DefaultHighlight {
|
||||||
@@ -223,10 +228,13 @@ func buildField(f Field) []byte {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// sfAttribute builds the attribute byte for the "start field" 3270 command
|
// sfAttribute builds the attribute byte for the "start field" 3270 command
|
||||||
func sfAttribute(write, intense, hidden bool) byte {
|
func sfAttribute(write, intense, hidden, skip bool) byte {
|
||||||
var attribute byte
|
var attribute byte
|
||||||
if !write {
|
if !write {
|
||||||
attribute |= 1 << 5 // set "bit 2"
|
attribute |= 1 << 5 // set "bit 2"
|
||||||
|
if skip {
|
||||||
|
attribute |= 1 << 4 // set "bit 3"
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// The MDT bit -- we always want writable field values returned,
|
// The MDT bit -- we always want writable field values returned,
|
||||||
// even if unchanged
|
// even if unchanged
|
||||||
|
|||||||
Reference in new issue
Block a user