Merge branch 'downarowiczd-master'
This commit is contained in:
commit
21f273b327
2 files changed
+26
-12
No files matched your search
+13
-8
@@ -33,6 +33,9 @@ var screen1 = go3270.Screen{
|
|||||||
{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: 7, Col: 0, Content: "Employee ID . . ."},
|
||||||
|
{Row: 7, Col: 19, Name: "employeeID", Write: true, Highlighting: go3270.Underscore, NumericOnly: true},
|
||||||
|
{Row: 7, 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."},
|
||||||
@@ -47,14 +50,16 @@ var screen2 = go3270.Screen{
|
|||||||
{Row: 4, Col: 19, Name: "fname"}, // We're giving this field a name to replace its value at runtime
|
{Row: 4, Col: 19, Name: "fname"}, // We're giving this field a name to replace its value at runtime
|
||||||
{Row: 5, Col: 0, Content: "And your last name is"},
|
{Row: 5, Col: 0, Content: "And your last name is"},
|
||||||
{Row: 5, Col: 22, Name: "lname"}, // We're giving this field a name to replace its value at runtime
|
{Row: 5, Col: 22, Name: "lname"}, // We're giving this field a name to replace its value at runtime
|
||||||
{Row: 6, Col: 0, Name: "passwordOutput"},
|
{Row: 6, Col: 0, Content: "And your employeed ID is"},
|
||||||
{Row: 8, Col: 0, Content: "Press"},
|
{Row: 6, Col: 22, Name: "employeeID"}, // We're giving this field a name to replace its value at runtime
|
||||||
{Row: 8, Col: 6, Intense: true, Content: "enter"},
|
{Row: 7, Col: 0, Name: "passwordOutput"},
|
||||||
{Row: 8, Col: 12, Content: "to enter your name again, or"},
|
{Row: 9, Col: 0, Content: "Press"},
|
||||||
{Row: 8, Col: 41, Intense: true, Content: "PF3"},
|
{Row: 9, Col: 6, Intense: true, Content: "enter"},
|
||||||
{Row: 8, Col: 45, Content: "to quit and disconnect."},
|
{Row: 9, Col: 12, Content: "to enter your name again, or"},
|
||||||
{Row: 11, Col: 0, Color: go3270.Turquoise, Highlighting: go3270.ReverseVideo, Content: "Here is a field with extended attributes."},
|
{Row: 9, Col: 41, Intense: true, Content: "PF3"},
|
||||||
{Row: 11, Col: 42}, // remember to "stop" fields with a regular field, to clear the reverse video for example
|
{Row: 9, Col: 45, Content: "to quit and disconnect."},
|
||||||
|
{Row: 12, Col: 0, Color: go3270.Turquoise, Highlighting: go3270.ReverseVideo, Content: "Here is a field with extended attributes."},
|
||||||
|
{Row: 12, Col: 42}, // remember to "stop" fields with a regular field, to clear the reverse video for example
|
||||||
{Row: 22, Col: 0, Content: "PF3 Exit"},
|
{Row: 22, Col: 0, Content: "PF3 Exit"},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,6 +40,11 @@ type Field struct {
|
|||||||
// password input field).
|
// password input field).
|
||||||
Hidden bool
|
Hidden bool
|
||||||
|
|
||||||
|
// NumericOnly indicates that only numbers may be entered into the field.
|
||||||
|
// Very fiew 3270 clients support this, so you must always still validate
|
||||||
|
// the input on the server side.
|
||||||
|
NumericOnly bool
|
||||||
|
|
||||||
// Color is the field color. The default value is the default color.
|
// Color is the field color. The default value is the default color.
|
||||||
Color Color
|
Color Color
|
||||||
|
|
||||||
@@ -193,7 +198,8 @@ 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, f.Autoskip))
|
buf.WriteByte(sfAttribute(f.Write, f.Intense, f.Hidden, f.Autoskip,
|
||||||
|
f.NumericOnly))
|
||||||
return buf.Bytes()
|
return buf.Bytes()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -210,7 +216,8 @@ 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, f.Autoskip))
|
buf.WriteByte(sfAttribute(f.Write, f.Intense, f.Hidden, f.Autoskip,
|
||||||
|
f.NumericOnly))
|
||||||
|
|
||||||
// Write the highlighting attribute
|
// Write the highlighting attribute
|
||||||
if f.Highlighting != DefaultHighlight {
|
if f.Highlighting != DefaultHighlight {
|
||||||
@@ -228,7 +235,7 @@ 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, skip bool) byte {
|
func sfAttribute(write, intense, hidden, skip, numeric bool) byte {
|
||||||
var attribute byte
|
var attribute byte
|
||||||
if !write {
|
if !write {
|
||||||
attribute |= 1 << 5 // set "bit 2"
|
attribute |= 1 << 5 // set "bit 2"
|
||||||
@@ -239,7 +246,9 @@ func sfAttribute(write, intense, hidden, skip bool) byte {
|
|||||||
// 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
|
||||||
attribute |= 1 // set "bit 7"
|
attribute |= 1 // set "bit 7"
|
||||||
|
if numeric {
|
||||||
|
attribute |= 1 << 4 // set "bit 3"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if intense {
|
if intense {
|
||||||
attribute |= 1 << 3 // set "bit 4"
|
attribute |= 1 << 3 // set "bit 4"
|
||||||
|
|||||||
Reference in new issue
Block a user