|
@@ -29,16 +29,16 @@ func (d *door.Door) PressAKey() {
|
|
|
|
|
|
func press_a_key(d *door.Door) int {
|
|
|
d.Write(door.Reset + door.CRNL + "Press a key to continue...")
|
|
|
- k := d.Key()
|
|
|
+ var k int = d.Key()
|
|
|
d.Write(door.CRNL)
|
|
|
return k
|
|
|
}
|
|
|
|
|
|
func about_test_door(d *door.Door) {
|
|
|
- W := 60
|
|
|
- center_x := (door.Width - W) / 2
|
|
|
- center_y := (door.Height - 16) / 2
|
|
|
- about := door.Panel{X: center_x,
|
|
|
+ var W int = 60
|
|
|
+ var center_x int = (door.Width - W) / 2
|
|
|
+ var center_y int = (door.Height - 16) / 2
|
|
|
+ var about door.Panel = door.Panel{X: center_x,
|
|
|
Y: center_y,
|
|
|
Width: W,
|
|
|
Style: door.SINGLE_DOUBLE,
|
|
@@ -63,11 +63,11 @@ func about_test_door(d *door.Door) {
|
|
|
"",
|
|
|
"It is written in Go, understands CP437 and unicode, adapts",
|
|
|
"to screen sizes, uses door32.sys, supports TheDraw Fonts,",
|
|
|
- "and runs on Linux and Windows."} {
|
|
|
+ "has NoMoreSecrets effect, and runs on Linux and Windows."} {
|
|
|
about.Lines = append(about.Lines, door.Line{Text: fmt.Sprintf("%*s", -W, text)})
|
|
|
}
|
|
|
|
|
|
- better := door.NoMoreSecretsDefault
|
|
|
+ var better door.NoMoreSecretsConfig = door.NoMoreSecretsDefault
|
|
|
better.Color = door.ColorText("BRI CYAN ON BLUE")
|
|
|
|
|
|
door.NoMoreSecrets(about.Output(), d, &better)
|
|
@@ -75,7 +75,7 @@ func about_test_door(d *door.Door) {
|
|
|
|
|
|
func MainMenu() door.Menu {
|
|
|
// Make the main menu
|
|
|
- m := door.Menu{Panel: door.Panel{Width: 45,
|
|
|
+ var m door.Menu = door.Menu{Panel: door.Panel{Width: 45,
|
|
|
X: 5,
|
|
|
Y: 5,
|
|
|
Style: door.DOUBLE,
|
|
@@ -109,10 +109,10 @@ func MainMenu() door.Menu {
|
|
|
func display_information(d *door.Door) {
|
|
|
d.Write(door.Clrscr + door.CRNL)
|
|
|
|
|
|
- keyColor := door.ColorText("BRI GREEN")
|
|
|
- sepColor := door.ColorText("BRI YEL")
|
|
|
- valColor := door.ColorText("CYAN")
|
|
|
- nice_format := func(key string, value string) string {
|
|
|
+ var keyColor string = door.ColorText("BRI GREEN")
|
|
|
+ var sepColor string = door.ColorText("BRI YEL")
|
|
|
+ var valColor string = door.ColorText("CYAN")
|
|
|
+ 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
|
|
|
}
|
|
|
|
|
@@ -134,7 +134,7 @@ func display_information(d *door.Door) {
|
|
|
}
|
|
|
|
|
|
func display_ansi(d *door.Door) {
|
|
|
- art := ANSIGrowl()
|
|
|
+ var art []string = ANSIGrowl()
|
|
|
d.Write(door.Clrscr)
|
|
|
for _, line := range art {
|
|
|
d.Write(line + door.CRNL)
|
|
@@ -147,7 +147,7 @@ func font_demo(d *door.Door) {
|
|
|
var centering string
|
|
|
|
|
|
d.Write(door.Clrscr + door.CRNL) // + door.CRNL + door.CRNL)
|
|
|
- fac := FontAmazonCyan()
|
|
|
+ var fac door.ColorFont = FontAmazonCyan()
|
|
|
output, l = fac.Output("ABCDEFGHIJKL")
|
|
|
if l > door.Width {
|
|
|
output, l = fac.Output("Cyan")
|
|
@@ -162,7 +162,7 @@ func font_demo(d *door.Door) {
|
|
|
d.Write(door.CRNL)
|
|
|
}
|
|
|
|
|
|
- patch := fac.Scan(6)
|
|
|
+ var patch door.ColorMap = fac.Scan(6)
|
|
|
// log.Printf("Patch: %#v\n", patch)
|
|
|
|
|
|
fac.Modify(4, patch)
|
|
@@ -183,7 +183,7 @@ func font_demo(d *door.Door) {
|
|
|
d.Write(door.CRNL)
|
|
|
press_a_key(d)
|
|
|
|
|
|
- fab := FontAnarchyBlue()
|
|
|
+ var fab door.ColorFont = FontAnarchyBlue()
|
|
|
output, l = fab.Output("Bugz is Here!")
|
|
|
if l > door.Width {
|
|
|
output, l = fab.Output("Hello")
|
|
@@ -198,7 +198,7 @@ func font_demo(d *door.Door) {
|
|
|
d.Write(door.CRNL)
|
|
|
}
|
|
|
|
|
|
- unchain := FontUnchained()
|
|
|
+ var unchain door.ColorFont = FontUnchained()
|
|
|
output, l = unchain.Output("Hi There!")
|
|
|
if l > door.Width {
|
|
|
output, l = unchain.Output("Meow")
|
|
@@ -214,7 +214,7 @@ func font_demo(d *door.Door) {
|
|
|
}
|
|
|
press_a_key(d)
|
|
|
|
|
|
- asylum := FontAsylum()
|
|
|
+ var asylum door.ColorFont = FontAsylum()
|
|
|
output, l = asylum.Output("Bugz ROCKS")
|
|
|
if l > door.Width {
|
|
|
output, l = asylum.Output("Aslym")
|
|
@@ -229,7 +229,7 @@ func font_demo(d *door.Door) {
|
|
|
d.Write(door.CRNL)
|
|
|
}
|
|
|
|
|
|
- brain := FontBrainDmgBlu()
|
|
|
+ var brain door.ColorFont = FontBrainDmgBlu()
|
|
|
output, l = brain.Output("I'm so BLUE")
|
|
|
if l > door.Width {
|
|
|
output, l = brain.Output("Blue")
|
|
@@ -244,7 +244,7 @@ func font_demo(d *door.Door) {
|
|
|
d.Write(door.CRNL)
|
|
|
}
|
|
|
|
|
|
- boner := FontBoner()
|
|
|
+ var boner door.ColorFont = FontBoner()
|
|
|
output, l = boner.Output("Welcome!")
|
|
|
if l < door.Width {
|
|
|
centering = strings.Repeat(" ", (door.Width-l)/2)
|
|
@@ -256,7 +256,7 @@ func font_demo(d *door.Door) {
|
|
|
}
|
|
|
press_a_key(d)
|
|
|
|
|
|
- descent := FontDescent()
|
|
|
+ var descent door.ColorFont = FontDescent()
|
|
|
output, l = descent.Output("Meanwhile...")
|
|
|
if l > door.Width {
|
|
|
output, l = descent.Output("BUGZ")
|
|
@@ -271,7 +271,7 @@ func font_demo(d *door.Door) {
|
|
|
d.Write(door.CRNL)
|
|
|
}
|
|
|
|
|
|
- remorse := FontRemorse()
|
|
|
+ var remorse door.ColorFont = FontRemorse()
|
|
|
output, l = remorse.Output("Enjoy the fonts")
|
|
|
if l > door.Width {
|
|
|
output, l = remorse.Output("Amazing")
|
|
@@ -285,7 +285,7 @@ func font_demo(d *door.Door) {
|
|
|
d.Write(door.CRNL)
|
|
|
}
|
|
|
|
|
|
- dungeon := FontDungeon()
|
|
|
+ var dungeon door.ColorFont = FontDungeon()
|
|
|
output, l = dungeon.Output("Until NEXT time")
|
|
|
if l > door.Width {
|
|
|
output, l = dungeon.Output("Beware")
|
|
@@ -329,7 +329,7 @@ func font_demo(d *door.Door) {
|
|
|
}
|
|
|
|
|
|
func input_demo(d *door.Door) {
|
|
|
- ticker := time.NewTicker(time.Second)
|
|
|
+ var ticker *time.Ticker = time.NewTicker(time.Second)
|
|
|
|
|
|
go func() {
|
|
|
for t := range ticker.C {
|
|
@@ -339,20 +339,20 @@ func input_demo(d *door.Door) {
|
|
|
}
|
|
|
}()
|
|
|
|
|
|
- inputColor := door.ColorText("BRI WHI ON BLUE")
|
|
|
- inputColor2 := door.ColorText("BRI WHI ON GREEN")
|
|
|
- prompt := door.Line{Text: "What is YOUR Name: "}
|
|
|
+ var inputColor string = door.ColorText("BRI WHI ON BLUE")
|
|
|
+ var inputColor2 string = door.ColorText("BRI WHI ON GREEN")
|
|
|
+ var prompt door.Line = door.Line{Text: "What is YOUR Name: "}
|
|
|
prompt.RenderF = door.RenderBlueYellow
|
|
|
d.Write(prompt.Output() + inputColor)
|
|
|
- name := d.Input(25)
|
|
|
+ var name string = d.Input(25)
|
|
|
d.Write(door.Reset + door.CRNL)
|
|
|
prompt.Text = "What is Your Quest: "
|
|
|
d.Write(prompt.Output() + inputColor2)
|
|
|
- quest := d.Input(35)
|
|
|
+ var quest string = d.Input(35)
|
|
|
d.Write(door.Reset + door.CRNL)
|
|
|
prompt.Text = "What is your Favorite CoLoR: "
|
|
|
d.Write(prompt.Output() + inputColor2)
|
|
|
- color := d.Input(15)
|
|
|
+ var color string = d.Input(15)
|
|
|
d.Write(door.Reset + door.CRNL)
|
|
|
ticker.Stop()
|
|
|
d.Write(fmt.Sprintf("You're %s on the %s quest, and fond of %s."+door.CRNL, name, quest, color))
|
|
@@ -361,8 +361,8 @@ func input_demo(d *door.Door) {
|
|
|
func progress_bars(d *door.Door) {
|
|
|
d.Write(door.Clrscr)
|
|
|
|
|
|
- bar := door.BarLine{Line: door.Line{DefaultColor: door.ColorText("BOLD YELLOW")}, Width: 20, Style: door.HALF_STEP}
|
|
|
- bar2 := door.BarLine{Width: 30, Style: door.SOLID, PercentStyle: door.PERCENT_SPACE}
|
|
|
+ var bar door.BarLine = door.BarLine{Line: door.Line{DefaultColor: door.ColorText("BOLD YELLOW")}, Width: 20, Style: door.HALF_STEP}
|
|
|
+ var bar2 door.BarLine = door.BarLine{Width: 30, Style: door.SOLID, PercentStyle: door.PERCENT_SPACE}
|
|
|
|
|
|
bar2.ColorRange = []door.BarRange{
|
|
|
{2500, door.ColorText("RED")},
|
|
@@ -371,7 +371,7 @@ func progress_bars(d *door.Door) {
|
|
|
{9500, door.ColorText("GREEN")},
|
|
|
{10100, door.ColorText("BRI GRE")}}
|
|
|
|
|
|
- bar3 := door.BarLine{Width: 15, Style: door.GRADIENT, Line: door.Line{DefaultColor: door.ColorText("CYAN")}}
|
|
|
+ var bar3 door.BarLine = door.BarLine{Width: 15, Style: door.GRADIENT, Line: door.Line{DefaultColor: door.ColorText("CYAN")}}
|
|
|
|
|
|
var percentage int64
|
|
|
bar.UpdateP = pctUpdate(&percentage)
|
|
@@ -408,9 +408,9 @@ func progress_bars(d *door.Door) {
|
|
|
}
|
|
|
|
|
|
func width_demo(d *door.Door) {
|
|
|
- w := door.Width
|
|
|
- panel := door.Panel{X: 1, Y: 1, Width: w}
|
|
|
- lineColor := door.ColorText("WHI")
|
|
|
+ var w int = door.Width
|
|
|
+ var panel door.Panel = door.Panel{X: 1, Y: 1, Width: w}
|
|
|
+ var lineColor string = door.ColorText("WHI")
|
|
|
var line string
|
|
|
|
|
|
for y := 1; y <= door.Height; y++ {
|
|
@@ -429,16 +429,17 @@ func width_demo(d *door.Door) {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- l := door.Line{Text: line, DefaultColor: lineColor}
|
|
|
+ var l door.Line = door.Line{Text: line, DefaultColor: lineColor}
|
|
|
panel.Lines = append(panel.Lines, l)
|
|
|
}
|
|
|
- message := fmt.Sprintf("Screen Size: %d X %d", door.Width, door.Height)
|
|
|
+ var message string = fmt.Sprintf("Screen Size: %d X %d", door.Width, door.Height)
|
|
|
d.Write(panel.Output())
|
|
|
|
|
|
// Output alert on top of panel
|
|
|
- cx := (door.Width - len(message) + 2) / 2
|
|
|
- cy := (door.Height - 3) / 2
|
|
|
- alert := door.AlertBox(message, 1)
|
|
|
+ var cx, cy int
|
|
|
+ cx = (door.Width - len(message) + 2) / 2
|
|
|
+ cy = (door.Height - 3) / 2
|
|
|
+ var alert []string = door.AlertBox(message, 1)
|
|
|
d.Write(door.ColorText("BRI YEL ON BLUE"))
|
|
|
for idx, ab := range alert {
|
|
|
d.Write(door.Goto(cx, cy+idx) + ab)
|
|
@@ -449,8 +450,8 @@ func width_demo(d *door.Door) {
|
|
|
d.Key()
|
|
|
|
|
|
panel.Lines = make([]door.Line, 0)
|
|
|
- background := "BUGZ Test Door in GO "
|
|
|
- bl := len(background)
|
|
|
+ var background string = "BUGZ Test Door in GO "
|
|
|
+ var bl int = len(background)
|
|
|
for y := 1; y <= door.Height; y++ {
|
|
|
offset := (y - 1) % bl
|
|
|
line = background[offset:]
|
|
@@ -461,7 +462,7 @@ func width_demo(d *door.Door) {
|
|
|
line += background[0 : w-len(line)]
|
|
|
}
|
|
|
}
|
|
|
- l := door.Line{Text: line, RenderF: door.RenderBlueYellow}
|
|
|
+ var l door.Line = door.Line{Text: line, RenderF: door.RenderBlueYellow}
|
|
|
panel.Lines = append(panel.Lines, l)
|
|
|
}
|
|
|
d.Write(panel.Output())
|
|
@@ -469,33 +470,33 @@ func width_demo(d *door.Door) {
|
|
|
}
|
|
|
|
|
|
func panel_demo(d *door.Door) {
|
|
|
- width := 55
|
|
|
- fmtStr := "%-55s"
|
|
|
- p := door.Panel{X: 5, Y: 5, Width: width, Style: door.DOUBLE, BorderColor: door.ColorText("CYAN ON BLUE"), Title: "[ Panel Demo ]"}
|
|
|
+ var width int = 55
|
|
|
+ var fmtStr string = "%-55s"
|
|
|
+ var p door.Panel = door.Panel{X: 5, Y: 5, Width: width, Style: door.DOUBLE, BorderColor: door.ColorText("CYAN ON BLUE"), Title: "[ Panel Demo ]"}
|
|
|
|
|
|
- lineColor := door.ColorText("BRIGHT WHI ON BLUE")
|
|
|
+ var lineColor string = door.ColorText("BRIGHT WHI ON BLUE")
|
|
|
// Add lines to the panel
|
|
|
for _, line := range []string{"The BBS Door Panel Demo", "(C) 2021 Red Green Software, https://red-green.com"} {
|
|
|
if door.Unicode {
|
|
|
line = strings.Replace(line, "(C)", "\u00a9", -1)
|
|
|
}
|
|
|
- l := door.Line{Text: fmt.Sprintf(fmtStr, line), DefaultColor: lineColor}
|
|
|
+ var l door.Line = door.Line{Text: fmt.Sprintf(fmtStr, line), DefaultColor: lineColor}
|
|
|
p.Lines = append(p.Lines, l)
|
|
|
}
|
|
|
p.Lines = append(p.Lines, p.Spacer())
|
|
|
p.Lines = append(p.Lines, door.Line{Text: fmt.Sprintf(fmtStr, "Welcome to golang!"), DefaultColor: lineColor})
|
|
|
|
|
|
- single := door.Panel{X: 6, Y: 12, Width: 10, Style: door.SINGLE, BorderColor: door.ColorText("WHITE ON BLUE"), Title: "< Single >"}
|
|
|
+ var single door.Panel = door.Panel{X: 6, Y: 12, Width: 10, Style: door.SINGLE, BorderColor: door.ColorText("WHITE ON BLUE"), Title: "< Single >"}
|
|
|
single.Lines = append(single.Lines, door.Line{Text: "Example ", DefaultColor: door.ColorText("WHI ON BLACK")})
|
|
|
single.Lines = append(single.Lines, single.Spacer())
|
|
|
single.Lines = append(single.Lines, door.Line{Text: "More Text ", DefaultColor: door.ColorText("BRI GREEN ON BLACK")})
|
|
|
|
|
|
- ds := door.Panel{X: 26, Y: 12, Width: 15, Style: door.DOUBLE_SINGLE, BorderColor: door.ColorText("BRI CYAN ON GREEN"), Title: "Double", TitleOffset: 3}
|
|
|
+ var ds door.Panel = door.Panel{X: 26, Y: 12, Width: 15, Style: door.DOUBLE_SINGLE, BorderColor: door.ColorText("BRI CYAN ON GREEN"), Title: "Double", TitleOffset: 3}
|
|
|
ds.Lines = append(ds.Lines, door.Line{Text: "Double / Single", DefaultColor: door.ColorText("BRI WHI ON GREEN")})
|
|
|
ds.Lines = append(ds.Lines, ds.Spacer())
|
|
|
ds.Lines = append(ds.Lines, door.Line{Text: "Some Other Text", DefaultColor: door.ColorText("BRI CYAN ON GREEN")})
|
|
|
|
|
|
- sd := door.Panel{X: 46, Y: 12, Width: 15, Style: door.SINGLE_DOUBLE, BorderColor: door.ColorText("BRI YELL ON RED")}
|
|
|
+ var sd door.Panel = door.Panel{X: 46, Y: 12, Width: 15, Style: door.SINGLE_DOUBLE, BorderColor: door.ColorText("BRI YELL ON RED")}
|
|
|
sd.Lines = append(sd.Lines, door.Line{Text: "Single / Double", DefaultColor: door.ColorText("BRI WHI ON RED")})
|
|
|
sd.Lines = append(sd.Lines, sd.Spacer())
|
|
|
sd.Lines = append(sd.Lines, door.Line{Text: "Text Goes Here ", DefaultColor: door.ColorText("BRI GREEN ON RED")})
|
|
@@ -511,7 +512,7 @@ func main() {
|
|
|
var message string
|
|
|
|
|
|
fmt.Println("Starting testdoor.go")
|
|
|
- d := door.Door{}
|
|
|
+ var d door.Door = door.Door{}
|
|
|
|
|
|
d.Init("testdoor")
|
|
|
|
|
@@ -526,10 +527,10 @@ func main() {
|
|
|
}()
|
|
|
|
|
|
defer d.Close()
|
|
|
- ticker := time.NewTicker(time.Second)
|
|
|
+ var ticker *time.Ticker = time.NewTicker(time.Second)
|
|
|
|
|
|
go func() {
|
|
|
- var maxlen int = 0
|
|
|
+ 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()) + " "
|
|
@@ -553,26 +554,26 @@ func main() {
|
|
|
}()
|
|
|
|
|
|
// bold := door.Color(1, 37, 40)
|
|
|
- bolder := door.ColorText("BLI BOLD YEL ON BLUE")
|
|
|
+ var bolder string = door.ColorText("BLI BOLD YEL ON BLUE")
|
|
|
d.Write("Welcome to " + bolder + "door32.sys" + door.Reset + door.CRNL + "..." + door.CRNL)
|
|
|
press_a_key(&d)
|
|
|
d.Write(door.CRNL)
|
|
|
|
|
|
- b := door.AlertBox("Warning: golang is in use!", 1)
|
|
|
+ var b []string = door.AlertBox("Warning: golang is in use!", 1)
|
|
|
d.Write(door.ColorText("BRI WHI ON GREEN"))
|
|
|
for _, line := range b {
|
|
|
d.Write(line + door.CRNL)
|
|
|
}
|
|
|
d.Write(door.Reset + door.CRNL)
|
|
|
|
|
|
- left := d.TimeLeft()
|
|
|
+ var left time.Duration = d.TimeLeft()
|
|
|
|
|
|
message = fmt.Sprintf("You have %0.2f minutes / %0.2f seconds remaining..."+door.CRNL, left.Minutes(), left.Seconds())
|
|
|
d.Write(message)
|
|
|
|
|
|
press_a_key(&d)
|
|
|
|
|
|
- mainmenu := MainMenu()
|
|
|
+ var mainmenu door.Menu = MainMenu()
|
|
|
var choice int
|
|
|
|
|
|
for choice >= 0 {
|
|
@@ -618,9 +619,12 @@ func main() {
|
|
|
case 'Q':
|
|
|
choice = -1
|
|
|
case 'C':
|
|
|
- z := 0
|
|
|
- a := 10 / z
|
|
|
+ var a, z int
|
|
|
+ z = 0
|
|
|
+ a = 10 / z
|
|
|
z = a
|
|
|
+ _ = a
|
|
|
+ _ = z
|
|
|
}
|
|
|
|
|
|
}
|