|
@@ -9,8 +9,8 @@ import (
|
|
"strings"
|
|
"strings"
|
|
"time"
|
|
"time"
|
|
|
|
|
|
- "net/http"
|
|
|
|
- _ "net/http/pprof"
|
|
|
|
|
|
+ // "net/http"
|
|
|
|
+ // _ "net/http/pprof"
|
|
|
|
|
|
"github.com/mitchellh/go-wordwrap"
|
|
"github.com/mitchellh/go-wordwrap"
|
|
)
|
|
)
|
|
@@ -51,8 +51,23 @@ func press_keys(d *door.Door) {
|
|
}
|
|
}
|
|
|
|
|
|
func press_a_key(d *door.Door) error {
|
|
func press_a_key(d *door.Door) error {
|
|
- d.Write(door.Reset + door.CRNL + "Press a key to continue...")
|
|
|
|
- _, _, err := d.WaitKey(door.Inactivity)
|
|
|
|
|
|
+ var err error
|
|
|
|
+ var ex door.Extended
|
|
|
|
+
|
|
|
|
+ d.Write(door.Reset + door.CRNL + "Press a key, or LEFT mouse click to continue...")
|
|
|
|
+ for {
|
|
|
|
+ _, ex, err = d.WaitKey(door.Inactivity)
|
|
|
|
+ if ex == door.MOUSE {
|
|
|
|
+ m, ok := d.GetMouse()
|
|
|
|
+ if ok {
|
|
|
|
+ if m.Button == 1 {
|
|
|
|
+ break
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ break
|
|
|
|
+ }
|
|
|
|
+ }
|
|
d.Write(door.CRNL)
|
|
d.Write(door.CRNL)
|
|
return err
|
|
return err
|
|
}
|
|
}
|
|
@@ -101,7 +116,8 @@ func about_test_door(d *door.Door) {
|
|
|
|
|
|
func MainMenu() door.Menu {
|
|
func MainMenu() door.Menu {
|
|
// Make the main menu
|
|
// Make the main menu
|
|
- var menu door.Menu = door.Menu{Panel: door.Panel{Width: 45,
|
|
|
|
|
|
+ // Width was 45
|
|
|
|
+ var menu door.Menu = door.Menu{Panel: door.Panel{Width: 35,
|
|
X: 2,
|
|
X: 2,
|
|
Y: 5,
|
|
Y: 5,
|
|
Style: door.DOUBLE,
|
|
Style: door.DOUBLE,
|
|
@@ -119,7 +135,7 @@ func MainMenu() door.Menu {
|
|
|
|
|
|
menu.AddSelection("A", "ANSI Display")
|
|
menu.AddSelection("A", "ANSI Display")
|
|
// m.AddSelection("C", "Crash")
|
|
// m.AddSelection("C", "Crash")
|
|
- menu.AddSelection("D", "Display Information (dropfile, screen)")
|
|
|
|
|
|
+ menu.AddSelection("D", "Display Information")
|
|
menu.AddSelection("F", "Font Demo")
|
|
menu.AddSelection("F", "Font Demo")
|
|
menu.AddSelection("I", "Input Prompt Demo")
|
|
menu.AddSelection("I", "Input Prompt Demo")
|
|
menu.AddSelection("M", "Menu Demo")
|
|
menu.AddSelection("M", "Menu Demo")
|
|
@@ -187,35 +203,58 @@ func MainMenu() door.Menu {
|
|
}
|
|
}
|
|
|
|
|
|
func display_information(d *door.Door) {
|
|
func display_information(d *door.Door) {
|
|
- d.Write(door.Clrscr + door.CRNL)
|
|
|
|
|
|
+ d.Write(door.Clrscr)
|
|
|
|
|
|
|
|
+ var headerColor string = door.ColorText("BRI CYAN")
|
|
var keyColor string = door.ColorText("BRI GREEN")
|
|
var keyColor string = door.ColorText("BRI GREEN")
|
|
var sepColor string = door.ColorText("BRI YEL")
|
|
var sepColor string = door.ColorText("BRI YEL")
|
|
var valColor string = door.ColorText("CYAN")
|
|
var valColor string = door.ColorText("CYAN")
|
|
|
|
+
|
|
var nice_format func(string, string) string = func(key string, value string) string {
|
|
var nice_format func(string, string) string = func(key string, value string) string {
|
|
return fmt.Sprintf("%s%-20s %s: %s%s", keyColor, key, sepColor, valColor, value) + door.CRNL
|
|
return fmt.Sprintf("%s%-20s %s: %s%s", keyColor, key, sepColor, valColor, value) + door.CRNL
|
|
}
|
|
}
|
|
|
|
|
|
- d.Write(nice_format("BBS Software", d.Config.BBSID))
|
|
|
|
- d.Write(nice_format("Time Left", strconv.Itoa(d.Config.Time_left)))
|
|
|
|
- d.Write(nice_format("Real Name", d.Config.Real_name))
|
|
|
|
|
|
+ var offset string
|
|
|
|
+ var header string = "DropFile: "
|
|
|
|
+ offset = strings.Repeat(" ", len(header))
|
|
|
|
+
|
|
|
|
+ d.Write(headerColor + header)
|
|
d.Write(nice_format("Comm Type", strconv.Itoa(d.Config.Comm_type)))
|
|
d.Write(nice_format("Comm Type", strconv.Itoa(d.Config.Comm_type)))
|
|
- d.Write(nice_format("Comm Handle", strconv.Itoa(d.Config.Comm_handle)))
|
|
|
|
- d.Write(nice_format("Baudrate", strconv.Itoa(d.Config.Baudrate)))
|
|
|
|
- d.Write(nice_format("Handle", d.Config.Handle))
|
|
|
|
- d.Write(nice_format("User #", strconv.Itoa(d.Config.User_number)))
|
|
|
|
- d.Write(nice_format("Security Level", strconv.Itoa(d.Config.Security_level)))
|
|
|
|
- d.Write(nice_format("Node #", strconv.Itoa(d.Config.Node)))
|
|
|
|
- d.Write(nice_format("Emulation", strconv.Itoa(d.Config.Emulation)))
|
|
|
|
- d.Write(nice_format("Unicode", strconv.FormatBool(door.Unicode)))
|
|
|
|
- d.Write(nice_format("CP437", strconv.FormatBool(door.CP437)))
|
|
|
|
- d.Write(nice_format("Full CP437", strconv.FormatBool(door.Full_CP437)))
|
|
|
|
- d.Write(nice_format("Screen Size", fmt.Sprintf("%d X %d", door.Width, door.Height)))
|
|
|
|
|
|
|
|
|
|
+ if d.Config.BBSID != "" {
|
|
|
|
+ d.Write(offset + nice_format("BBS Software", d.Config.BBSID))
|
|
|
|
+ }
|
|
|
|
+ d.Write(offset + nice_format("Time Left", strconv.Itoa(d.Config.Time_left)))
|
|
|
|
+ d.Write(offset + nice_format("Real Name", d.Config.Real_name))
|
|
|
|
+ // d.Write(nice_format("Comm Handle", strconv.Itoa(d.Config.Comm_handle)))
|
|
|
|
+ d.Write(offset + nice_format("Handle", d.Config.Handle))
|
|
|
|
+ d.Write(offset + nice_format("User #", strconv.Itoa(d.Config.User_number)))
|
|
|
|
+ d.Write(offset + nice_format("Security Level", strconv.Itoa(d.Config.Security_level)))
|
|
|
|
+ d.Write(offset + nice_format("Node #", strconv.Itoa(d.Config.Node)))
|
|
|
|
+
|
|
|
|
+ header = "Detected: "
|
|
|
|
+ offset = strings.Repeat(" ", len(header))
|
|
|
|
+ d.Write(headerColor + header)
|
|
|
|
+ d.Write(nice_format("Unicode", strconv.FormatBool(door.Unicode)))
|
|
|
|
+ d.Write(offset + nice_format("CP437", strconv.FormatBool(door.CP437)))
|
|
|
|
+ d.Write(offset + nice_format("Full CP437", strconv.FormatBool(door.Full_CP437)))
|
|
|
|
+ d.Write(offset + nice_format("Screen Size", fmt.Sprintf("%d X %d", door.Width, door.Height)))
|
|
var time time.Duration = d.TimeLeft()
|
|
var time time.Duration = d.TimeLeft()
|
|
- d.Write(nice_format("Door Time Left", fmt.Sprintf("%d Hours, %d Minutes, %d Seconds", int(time.Hours()), int(time.Minutes())%60, int(time.Seconds())%60)))
|
|
|
|
|
|
+ d.Write(offset + nice_format("Door Time Left", fmt.Sprintf("%d Hours, %d Minutes, %d Seconds", int(time.Hours()), int(time.Minutes())%60, int(time.Seconds())%60)))
|
|
time = d.TimeUsed()
|
|
time = d.TimeUsed()
|
|
- d.Write(nice_format("Door Time Used", fmt.Sprintf("%d Minutes, %d Seconds", int(time.Minutes()), int(time.Seconds())%60)))
|
|
|
|
|
|
+ d.Write(offset + nice_format("Door Time Used", fmt.Sprintf("%d Minutes, %d Seconds", int(time.Minutes()), int(time.Seconds())%60)))
|
|
|
|
+
|
|
|
|
+ modules := GetModules()
|
|
|
|
+ header = "Build: "
|
|
|
|
+ offset = strings.Repeat(" ", len(header))
|
|
|
|
+ d.Write(headerColor + header)
|
|
|
|
+ gover, gitver := GetVersion()
|
|
|
|
+ d.Write(nice_format("go version", gover))
|
|
|
|
+ d.Write(offset + nice_format("git commit", gitver))
|
|
|
|
+
|
|
|
|
+ for mod, version := range modules {
|
|
|
|
+ d.Write(offset + nice_format(mod, version))
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
func display_ansi(d *door.Door) {
|
|
func display_ansi(d *door.Door) {
|
|
@@ -599,11 +638,12 @@ func panel_demo(d *door.Door) {
|
|
func main() {
|
|
func main() {
|
|
var message string
|
|
var message string
|
|
|
|
|
|
- go func() {
|
|
|
|
- http.ListenAndServe(":6060", nil)
|
|
|
|
- }()
|
|
|
|
|
|
+ /*
|
|
|
|
+ go func() {
|
|
|
|
+ http.ListenAndServe(":6060", nil)
|
|
|
|
+ }()
|
|
|
|
+ */
|
|
|
|
|
|
- fmt.Println("Starting testdoor.go")
|
|
|
|
var d door.Door = door.Door{}
|
|
var d door.Door = door.Door{}
|
|
|
|
|
|
d.Init("testdoor")
|
|
d.Init("testdoor")
|
|
@@ -620,17 +660,27 @@ func main() {
|
|
}()
|
|
}()
|
|
|
|
|
|
defer d.Close()
|
|
defer d.Close()
|
|
- // var ticker *time.Ticker = time.NewTicker(time.Second)
|
|
|
|
|
|
+
|
|
|
|
+ // Updaters work best when the screen doesn't scroll, so start
|
|
|
|
+ // us off at the very top.
|
|
|
|
+
|
|
|
|
+ d.Write(door.Clrscr)
|
|
|
|
+
|
|
|
|
+ // Start spinrite effects
|
|
var ticker *time.Ticker = time.NewTicker(time.Millisecond * time.Duration(100))
|
|
var ticker *time.Ticker = time.NewTicker(time.Millisecond * time.Duration(100))
|
|
|
|
|
|
- var spin door.SpinRite = door.SpinRiteInit(13, 5, door.ColorText("RED ON GREEN"))
|
|
|
|
- var spin2 door.SpinRiteMsg = door.SpinRiteMsgInit(15, 5, door.ColorText("BRI CYA ON BLUE"), []string{"Press", "ANY", "key"})
|
|
|
|
|
|
+ var spin door.SpinRiteMsg = door.SpinRiteMsgInit(15, 5,
|
|
|
|
+ door.ColorText("RED ON GREEN"),
|
|
|
|
+ []string{"RED", "GREEN"})
|
|
|
|
+
|
|
|
|
+ var spin2 door.SpinRite = door.SpinRiteInit(13, 5,
|
|
|
|
+ door.ColorText("BRI CYA ON BLUE"))
|
|
|
|
|
|
go func() {
|
|
go func() {
|
|
var output string
|
|
var output string
|
|
for range ticker.C {
|
|
for range ticker.C {
|
|
- output = door.SavePos + door.Goto(door.Width-15, 1) + spin.Output() +
|
|
|
|
- door.Goto(door.Width-16, 3) + spin2.Output() + door.RestorePos
|
|
|
|
|
|
+ output = door.SavePos + door.Goto(door.Width-16, 1) + spin.Output() +
|
|
|
|
+ door.Goto(door.Width-15, 3) + spin2.Output() + door.RestorePos
|
|
if !d.Disconnect() {
|
|
if !d.Disconnect() {
|
|
d.Write(output)
|
|
d.Write(output)
|
|
} else {
|
|
} else {
|
|
@@ -640,32 +690,6 @@ func main() {
|
|
}
|
|
}
|
|
}()
|
|
}()
|
|
|
|
|
|
- if false {
|
|
|
|
- go func() {
|
|
|
|
- var maxlen int = 0 // max length of timeinfo (sysops have 4 digits of mins)
|
|
|
|
- for t := range ticker.C {
|
|
|
|
- const tf = "03:04:05 PM"
|
|
|
|
- var timeinfo string = " " + t.Format(tf) + " " + fmt.Sprintf("(%3.1f mins)", d.TimeLeft().Minutes()) + " "
|
|
|
|
- if maxlen == 0 {
|
|
|
|
- maxlen = len(timeinfo)
|
|
|
|
- } else {
|
|
|
|
- if len(timeinfo) < maxlen {
|
|
|
|
- timeinfo += strings.Repeat(" ", maxlen-len(timeinfo))
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // maxlen = 12 + 7 + 5 = 24
|
|
|
|
- output := door.SavePos + door.Goto(door.Width-(maxlen+1), 0) + door.ColorText("BRI WHI ON BLUE") + timeinfo + door.RestorePos
|
|
|
|
- if !d.Disconnect() {
|
|
|
|
- d.Write(output)
|
|
|
|
- } else {
|
|
|
|
- ticker.Stop()
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }()
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
var wopr door.WOPR
|
|
var wopr door.WOPR
|
|
wopr.Init(d.StartTime, d.TimeOut, "") // TimeUsed(), d.TimeLeft(), "")
|
|
wopr.Init(d.StartTime, d.TimeOut, "") // TimeUsed(), d.TimeLeft(), "")
|
|
wopr.ElapsedPanel.X = door.Width - 19
|
|
wopr.ElapsedPanel.X = door.Width - 19
|
|
@@ -676,30 +700,25 @@ func main() {
|
|
wopr.Animate(&d)
|
|
wopr.Animate(&d)
|
|
|
|
|
|
// bold := door.Color(1, 37, 40)
|
|
// bold := door.Color(1, 37, 40)
|
|
- var bolder string = door.ColorText("BLI BOLD YEL ON BLUE")
|
|
|
|
- d.Write("Welcome to " + bolder + "door32.sys" + door.Reset + door.CRNL + "..." + door.CRNL)
|
|
|
|
-
|
|
|
|
- // cterm.txt +687
|
|
|
|
- // d.Write("\x1b[?9h") // enable mouse X10 support
|
|
|
|
- // d.Write("\x1b[?1000h") // enable any-event mouse
|
|
|
|
- // d.Write("\x1b[?1002h")
|
|
|
|
- // d.Write("\x1b[?1006h") // SGR style mouse. -- not supported in term
|
|
|
|
- d.EnableMouse(door.Normal) // AnyEvent)
|
|
|
|
- // 1006 does not work in xterm or syncterm.
|
|
|
|
- press_keys(&d)
|
|
|
|
- // press_a_key(&d)
|
|
|
|
|
|
+ var bolder string = door.ColorText("BOLD YEL ON BLUE")
|
|
|
|
+ d.Write("Welcome to " + bolder + "go door go TestDoor." + door.Reset + door.CRNL + "..." + door.CRNL)
|
|
|
|
+
|
|
|
|
+ d.EnableMouse(door.Normal)
|
|
|
|
+
|
|
|
|
+ press_a_key(&d)
|
|
d.Write(door.CRNL)
|
|
d.Write(door.CRNL)
|
|
|
|
|
|
var b []string
|
|
var b []string
|
|
if door.CP437 {
|
|
if door.CP437 {
|
|
- b = door.AlertBox("Warning: golang \xfb is in use!", 1)
|
|
|
|
|
|
+ b = door.AlertBox("Alert: go \xfb is in use!", 1)
|
|
} else {
|
|
} else {
|
|
- b = door.AlertBox("Warning: golang \u221a is in use!", 1)
|
|
|
|
|
|
+ b = door.AlertBox("Alert: go \u221a is in use!", 1)
|
|
}
|
|
}
|
|
|
|
|
|
- d.Write(door.ColorText("BRI WHI ON GREEN"))
|
|
|
|
|
|
+ warningColor := door.ColorText("BRI WHI ON GREEN")
|
|
for _, line := range b {
|
|
for _, line := range b {
|
|
- d.Write(line + door.CRNL)
|
|
|
|
|
|
+ // Prevent color bleeding.
|
|
|
|
+ d.Write(warningColor + line + door.Reset + door.CRNL)
|
|
}
|
|
}
|
|
d.Write(door.Reset + door.CRNL)
|
|
d.Write(door.Reset + door.CRNL)
|
|
|
|
|
|
@@ -708,8 +727,7 @@ func main() {
|
|
message = fmt.Sprintf("You have %0.2f minutes / %0.2f seconds remaining..."+door.CRNL, left.Minutes(), left.Seconds())
|
|
message = fmt.Sprintf("You have %0.2f minutes / %0.2f seconds remaining..."+door.CRNL, left.Minutes(), left.Seconds())
|
|
d.Write(message)
|
|
d.Write(message)
|
|
|
|
|
|
- press_keys(&d)
|
|
|
|
- // press_a_key(&d)
|
|
|
|
|
|
+ press_a_key(&d)
|
|
|
|
|
|
var mainmenu door.Menu = MainMenu()
|
|
var mainmenu door.Menu = MainMenu()
|
|
var choice int
|
|
var choice int
|
|
@@ -745,6 +763,7 @@ func main() {
|
|
input_demo(&d)
|
|
input_demo(&d)
|
|
press_a_key(&d)
|
|
press_a_key(&d)
|
|
case 'M':
|
|
case 'M':
|
|
|
|
+ // Why is this so far down on the screen? (Scrolls)
|
|
d.Write(door.Reset + door.CRNL + "TO DO: Provide menu of options to select from..." + door.CRNL)
|
|
d.Write(door.Reset + door.CRNL + "TO DO: Provide menu of options to select from..." + door.CRNL)
|
|
press_a_key(&d)
|
|
press_a_key(&d)
|
|
case 'P':
|
|
case 'P':
|
|
@@ -759,6 +778,7 @@ func main() {
|
|
case 'W':
|
|
case 'W':
|
|
width_demo(&d)
|
|
width_demo(&d)
|
|
case 'Q':
|
|
case 'Q':
|
|
|
|
+ // This is also far down on the screen ...
|
|
choice = -1
|
|
choice = -1
|
|
case 'C': // Disabled
|
|
case 'C': // Disabled
|
|
var a, z int
|
|
var a, z int
|
|
@@ -777,7 +797,12 @@ func main() {
|
|
d.DisableMouse()
|
|
d.DisableMouse()
|
|
d.Write(door.Reset + door.CRNL)
|
|
d.Write(door.Reset + door.CRNL)
|
|
|
|
|
|
- message = fmt.Sprintf("Returning to the %s BBS..."+door.CRNL, d.Config.BBSID)
|
|
|
|
|
|
+ if d.Config.BBSID != "" {
|
|
|
|
+ message = fmt.Sprintf("Returning to the %s BBS..."+door.CRNL, d.Config.BBSID)
|
|
|
|
+ } else {
|
|
|
|
+ message = "Returning to the BBS..." + door.CRNL
|
|
|
|
+ }
|
|
|
|
+
|
|
d.Write(message)
|
|
d.Write(message)
|
|
|
|
|
|
d.WaitKey(time.Second)
|
|
d.WaitKey(time.Second)
|