package main import ( "fmt" "log" "red-green/door" "runtime/debug" "strconv" "strings" "time" "github.com/mitchellh/go-wordwrap" ) func pctUpdate(pct *int64) func() int64 { return func() int64 { return *pct } } // Can I add a function to Door? // NO: cannot define new methods on non-local type door.Door /* func (d *door.Door) PressAKey() { d.Write(door.Reset + door.CRNL + "Press a key to continue...") d.Key() d.Write(door.CRNL) } */ func press_keys(d *door.Door) { d.Write(door.Reset + door.CRNL + "Press some keys...") var r rune var ex door.Extended var err error for (r != 0x0d) && (err == nil) { r, ex, err = d.WaitKey(door.Inactivity) if ex == door.MOUSE { m, ok := d.GetMouse() if ok { // var m door.MouseInfo = door.Mouse d.Write(fmt.Sprintf("M %d (%d,%d) ", m.Button, m.X, m.Y)) } } else { if ex == door.NOP { d.Write(fmt.Sprintf("%d (%x) ", r, r)) } else { d.Write(fmt.Sprintf("<%s> ", ex.String())) } } } d.Write(door.Reset + door.CRNL) } func press_a_key(d *door.Door) error { d.Write(door.Reset + door.CRNL + "Press a key to continue...") _, _, err := d.WaitKey(door.Inactivity) d.Write(door.CRNL) return err } func about_test_door(d *door.Door) { 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, BorderColor: door.ColorText("BOLD YELLOW ON BLUE"), } about.Lines = append(about.Lines, door.Line{Text: fmt.Sprintf("%*s", -W, "About This Door"), DefaultColor: door.ColorText("BOLD CYAN ON BLUE")}) about.Lines = append(about.Lines, about.Spacer()) about.Lines = append(about.Lines, door.Line{Text: fmt.Sprintf("%*s", -W, "Test Door written in go, using go door.")}) var copyright string = "(C) 2022 Bugz, Red Green Software" if door.Unicode { copyright = strings.Replace(copyright, "(C)", "\u00a9", -1) } about.Lines = append(about.Lines, door.Line{Text: copyright, Width: W, DefaultColor: door.ColorText("BOLD WHITE ON BLUE")}) for _, text := range []string{"", "This door was written by Bugz.", "", "It is written in Go, understands CP437 and unicode, adapts", "to screen sizes, uses door32.sys, supports TheDraw Fonts", "(the fonts are compiled into the door), has NoMoreSecrets", "effect, and runs on Linux and Windows."} { about.Lines = append(about.Lines, door.Line{Text: text, Width: W}) } var better door.NoMoreSecretsConfig = door.NoMoreSecretsDefault better.Jumble_Loop_Speed = 75 // 35 better.Reveal_Loop_Speed = 100 // 50 better.Color = door.ColorText("BRI CYAN ON BLUE") door.NoMoreSecrets(about.Output(), d, &better) } func MainMenu() door.Menu { // Make the main menu var menu door.Menu = door.Menu{Panel: door.Panel{Width: 45, X: 2, Y: 5, Style: door.DOUBLE, Title: "[ Main Menu: ]", TitleOffset: 3, BorderColor: door.ColorText("BRI CYAN ON BLA")}} menu.SelectedR = door.MakeMenuRender(door.ColorText("BOLD CYAN"), door.ColorText("BOLD BLUE"), door.ColorText("BOLD WHITE"), door.ColorText("BOLD CYAN")) menu.UnselectedR = door.MakeMenuRender(door.ColorText("BOLD YEL ON BLUE"), door.ColorText("BOLD WHI ON BLUE"), door.ColorText("BOLD YEL ON BLUE"), door.ColorText("BOLD CYAN ON BLUE")) menu.AddSelection("A", "ANSI Display") // m.AddSelection("C", "Crash") menu.AddSelection("D", "Display Information (dropfile, screen)") menu.AddSelection("F", "Font Demo") menu.AddSelection("I", "Input Prompt Demo") menu.AddSelection("M", "Menu Demo") menu.AddSelection("P", "Progress Bars Demo") menu.AddSelection("S", "Show Panel") menu.AddSelection("T", "Test Door About") menu.AddSelection("W", "Screen Width") menu.AddSelection("Q", "Quit") var descriptions []string = []string{ // 12345678901234567890123456789012345678901234567890 "Display an ANSI file. It is compiled into the door itself.", // "Crash go, see a handled error.", // The error shows up in the logs. "Display dropfile information.", "Display TheDraw Fonts. Font information is compiled into the door.", "Input some values, while updating the time.", "Isn't this is a menu?", "Display various progress bar styles. Half step, display percentage, and gradient.", "Show multiple panels.", "Show more information about the door, using NoMoreSecrets effect.", "Examples using the full width of the screen.", "Exit this door.", } var widthLeft int = door.Width - (menu.Width + menu.X + 2) var panelWidth int = widthLeft - (2 + 2) var maxLines int = 1 var maxLineLength int // Calculate the max lines needed for each line. for _, line := range descriptions { var wrapped string = wordwrap.WrapString(line, uint(panelWidth)) var lines int = len(strings.Split(wrapped, "\n")) if lines > maxLines { maxLines = lines } if len(line) > maxLineLength { maxLineLength = len(line) } } if maxLines == 1 { // Ok! Everything fits into one line, SO use max line length as width of panel. panelWidth = maxLineLength } // Position the description panel beside the menu. m.Width + m.X + 2 (1 one to give it a space) var descPanel door.Panel = door.Panel{X: menu.Width + menu.X + 2 + 1, Y: menu.Y, Width: panelWidth, Style: door.SINGLE, BorderColor: door.ColorText("WHI ON BLU")} for x := 0; x < maxLines; x++ { descPanel.Lines = append(descPanel.Lines, door.Line{Text: "", Width: panelWidth}) } menu.Activated = func(item int, d *door.Door) { var line string = descriptions[item] var lines []string = strings.Split(wordwrap.WrapString(line, uint(panelWidth)), "\n") for idx := range descPanel.Lines { if idx >= len(lines) { descPanel.Lines[idx].Text = "" } else { descPanel.Lines[idx].Text = lines[idx] } } d.Write(door.SavePos + descPanel.Output() + door.RestorePos) } return menu } func display_information(d *door.Door) { d.Write(door.Clrscr + door.CRNL) 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 } 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)) 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))) 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))) time = d.TimeUsed() d.Write(nice_format("Door Time Used", fmt.Sprintf("%d Minutes, %d Seconds", int(time.Minutes()), int(time.Seconds())%60))) } func display_ansi(d *door.Door) { var art []string = ANSIGrowl() d.Write(door.Clrscr) for _, line := range art { d.Write(line + door.CRNL) } } func font_demo(d *door.Door) { var output []string var l int var centering string d.Write(door.Clrscr + door.CRNL) // + door.CRNL + door.CRNL) var fac door.ColorFont = FontAmazonCyan() output, l = fac.Output("ABCDEFGHIJKL") if l > door.Width { output, l = fac.Output("Cyan") } if l < door.Width { centering = strings.Repeat(" ", (door.Width-l)/2) for _, o := range output { d.Write(fmt.Sprintf("%s%s%s", centering, o, door.Reset) + door.CRNL) } d.Write(door.CRNL) } var patch door.ColorMap = fac.Scan(6) // log.Printf("Patch: %#v\n", patch) fac.Modify(4, patch) output, l = fac.Output("Blue") centering = strings.Repeat(" ", (door.Width-l)/2) for _, o := range output { d.Write(fmt.Sprintf("%s%s%s", centering, o, door.Reset) + door.CRNL) } d.Write(door.CRNL) fac.Modify(1, patch) output, l = fac.Output("Red") centering = strings.Repeat(" ", (door.Width-l)/2) for _, o := range output { d.Write(fmt.Sprintf("%s%s%s", centering, o, door.Reset) + door.CRNL) } d.Write(door.CRNL) press_a_key(d) var fab door.ColorFont = FontAnarchyBlue() output, l = fab.Output("Bugz is Here!") if l > door.Width { output, l = fab.Output("Hello") } if l < door.Width { centering = strings.Repeat(" ", (door.Width-l)/2) for _, o := range output { d.Write(centering + o + door.Reset + door.CRNL) } d.Write(door.CRNL) } var unchain door.ColorFont = FontUnchained() output, l = unchain.Output("Hi There!") if l > door.Width { output, l = unchain.Output("Meow") } if l < door.Width { centering = strings.Repeat(" ", (door.Width-l)/2) for _, o := range output { d.Write(centering + o + door.Reset + door.CRNL) } d.Write(door.CRNL) } press_a_key(d) var asylum door.ColorFont = FontAsylum() output, l = asylum.Output("Bugz ROCKS") if l > door.Width { output, l = asylum.Output("Aslym") } if l < door.Width { centering = strings.Repeat(" ", (door.Width-l)/2) for _, o := range output { d.Write(centering + o + door.Reset + door.CRNL) } d.Write(door.CRNL) } var brain door.ColorFont = FontBrainDmgBlu() output, l = brain.Output("I'm so BLUE") if l > door.Width { output, l = brain.Output("Blue") } if l < door.Width { centering = strings.Repeat(" ", (door.Width-l)/2) for _, o := range output { d.Write(centering + o + door.Reset + door.CRNL) } d.Write(door.CRNL) } var boner door.ColorFont = FontBoner() output, l = boner.Output("Welcome!") if l < door.Width { centering = strings.Repeat(" ", (door.Width-l)/2) for _, o := range output { d.Write(centering + o + door.Reset + door.CRNL) } d.Write(door.CRNL) } press_a_key(d) var descent door.ColorFont = FontDescent() output, l = descent.Output("Meanwhile...") if l > door.Width { output, l = descent.Output("BUGZ") } if l < door.Width { centering = strings.Repeat(" ", (door.Width-l)/2) for _, o := range output { d.Write(centering + o + door.Reset + door.CRNL) } d.Write(door.CRNL) } var remorse door.ColorFont = FontRemorse() output, l = remorse.Output("Enjoy the fonts") if l > door.Width { output, l = remorse.Output("Amazing") } if l < door.Width { centering = strings.Repeat(" ", (door.Width-l)/2) for _, o := range output { d.Write(centering + o + door.Reset + door.CRNL) } d.Write(door.CRNL) } var dungeon door.ColorFont = FontDungeon() output, l = dungeon.Output("Until NEXT time") if l > door.Width { output, l = dungeon.Output("Beware") } if l < door.Width { centering = strings.Repeat(" ", (door.Width-l)/2) for _, o := range output { d.Write(centering + o + door.Reset + door.CRNL) } d.Write(door.CRNL) } /* redgreen := FontArmageddon() white := redgreen.Scan(7) blue := redgreen.Scan(4) redgreen.Modify(1, white) redgreen.Modify(2, blue) */ redgreen := FontRedGreen() output, l = redgreen.Output("Red-Green") if l < door.Width { press_a_key(d) centering = strings.Repeat(" ", (door.Width-l)/2) for _, o := range output { d.Write(centering + o + door.Reset + door.CRNL) } d.Write(door.CRNL) output, l = redgreen.Output("Software") centering = strings.Repeat(" ", (door.Width-l)/2) for _, o := range output { d.Write(centering + o + door.Reset + door.CRNL) } d.Write(door.CRNL) } } func input_demo(d *door.Door) { var ticker *time.Ticker = time.NewTicker(time.Second) go func() { for t := range ticker.C { const tf = "January 2, 2006 03:04:05 PM MST" output := door.SavePos + door.Goto(5, 2) + door.ColorText("BRI WHI ON CYAN") + t.Format(tf) + door.RestorePos d.Write(output) } }() 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) var name string = d.Input(25) d.Write(door.Reset + door.CRNL) prompt.Text = "What is Your Quest: " d.Write(prompt.Output() + inputColor2) var quest string = d.Input(35) d.Write(door.Reset + door.CRNL) prompt.Text = "What is your Favorite CoLoR: " d.Write(prompt.Output() + inputColor) 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)) } func progress_bars(d *door.Door) { d.Write(door.Clrscr) 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{ {Percent: 2500, Color: door.ColorText("RED")}, {Percent: 5000, Color: door.ColorText("BROWN")}, {Percent: 7500, Color: door.ColorText("BOLD YEL")}, {Percent: 9500, Color: door.ColorText("GREEN")}, {Percent: 10100, Color: door.ColorText("BRI GRE")}} 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) bar2.UpdateP = pctUpdate(&percentage) bar3.UpdateP = pctUpdate(&percentage) update_bars := func() { bar.Update() bar2.Update() bar3.Update() } d.Write(door.Goto(3, 12) + "Half-Step") d.Write(door.Goto(25, 12) + "% with space and Color Range") d.Write(door.Goto(57, 12) + "Gradient") d.Write(door.HideCursor) bar_start := door.Goto(3, 15) for f := 0; f <= 100; f++ { d.Write(door.Goto(3, 10) + door.Reset + fmt.Sprintf("Value: %d", f)) percentage = int64(f * 100) update_bars() d.Write(bar_start + bar.Output() + " " + door.Reset + bar2.Output() + door.Reset + " " + bar3.Output()) if d.Disconnect() { // don't continue to sleep if we're disconnected break } time.Sleep(time.Millisecond * 100) } d.Write(door.ShowCursor) } func width_demo(d *door.Door) { 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++ { if y%10 == 0 { line = strings.Repeat("1234567890", w/10) for x := len(line); x < w; x++ { line += strconv.Itoa((x + 1) % 10) } } else { line = "" for x := 1; x < w; x++ { if x%10 == 0 { line += strconv.Itoa(y % 10) } else { line += " " } } } var l door.Line = door.Line{Text: line, DefaultColor: lineColor} panel.Lines = append(panel.Lines, l) } var message string = fmt.Sprintf("Screen Size: %d X %d", door.Width, door.Height) d.Write(panel.Output()) // Output alert on top of panel 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) } d.Write(door.Reset + panel.GotoEnd()) // Pause for key d.WaitKey(door.Inactivity) panel.Lines = make([]door.Line, 0) 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:] for len(line) < w { if len(line)+bl <= w { line += background } else { line += background[0 : w-len(line)] } } var l door.Line = door.Line{Text: line, RenderF: door.RenderBlueYellow} panel.Lines = append(panel.Lines, l) } d.Write(panel.Output()) d.WaitKey(door.Inactivity) } func panel_demo(d *door.Door) { var width int = 55 var panel door.Panel = door.Panel{X: 5, Y: 5, Width: width, Style: door.DOUBLE, BorderColor: door.ColorText("CYAN ON BLUE"), Title: "[ Panel Demo ]"} 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) } var l door.Line = door.Line{Text: line, Width: width, DefaultColor: lineColor} panel.Lines = append(panel.Lines, l) } panel.Lines = append(panel.Lines, panel.Spacer()) panel.Lines = append(panel.Lines, door.Line{Text: "Welcome to golang!", Width: width, DefaultColor: lineColor}) width = 10 var single door.Panel = door.Panel{X: 6, Y: 12, Width: width, Style: door.SINGLE, BorderColor: door.ColorText("WHITE ON BLUE"), Title: "< Single >"} single.Lines = append(single.Lines, door.Line{Text: "Example", Width: width, DefaultColor: door.ColorText("WHI ON BLACK")}) single.Lines = append(single.Lines, single.Spacer()) single.Lines = append(single.Lines, door.Line{Text: "More Text", Width: width, DefaultColor: door.ColorText("BRI GREEN ON BLACK")}) width = 15 var double_single door.Panel = door.Panel{X: 26, Y: 12, Width: width, Style: door.DOUBLE_SINGLE, BorderColor: door.ColorText("BRI CYAN ON GREEN"), Title: "Double", TitleOffset: 3} double_single.Lines = append(double_single.Lines, door.Line{Text: "Double / Single", Width: width, DefaultColor: door.ColorText("BRI WHI ON GREEN")}) double_single.Lines = append(double_single.Lines, double_single.Spacer()) double_single.Lines = append(double_single.Lines, door.Line{Text: "Some Other Text", Width: width, DefaultColor: door.ColorText("BRI CYAN ON GREEN")}) var single_double door.Panel = door.Panel{X: 46, Y: 12, Width: width, Style: door.SINGLE_DOUBLE, BorderColor: door.ColorText("BRI YELL ON RED")} single_double.Lines = append(single_double.Lines, door.Line{Text: "Single / Double", Width: width, DefaultColor: door.ColorText("BRI WHI ON RED")}) single_double.Lines = append(single_double.Lines, single_double.Spacer()) single_double.Lines = append(single_double.Lines, door.Line{Text: "Text Goes Here ", Width: width, DefaultColor: door.ColorText("BRI GREEN ON RED")}) d.Write(door.Clrscr) d.Write(panel.Output()) d.Write(single.Output()) d.Write(double_single.Output()) d.Write(single_double.Output()) } func main() { var message string fmt.Println("Starting testdoor.go") var d door.Door = door.Door{} d.Init("testdoor") defer func() { if err := recover(); err != nil { // This displays stack trace stderr debug.PrintStack() fmt.Println("ERROR:", err) log.Println("FAILURE:", err) // Display error to user d.Write(fmt.Sprintf(door.Reset+door.CRNL+"Exception: %v"+door.CRNL, err)) } }() defer d.Close() // var ticker *time.Ticker = time.NewTicker(time.Second) 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"}) go func() { var output string 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 if !d.Disconnect() { d.Write(output) } else { ticker.Stop() return } } }() 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 wopr.Init(d.TimeUsed(), d.TimeLeft(), "") wopr.ElapsedPanel.X = door.Width - 19 wopr.ElapsedPanel.Y = door.Height - 15 wopr.RemainingPanel.X = door.Width - 19 wopr.RemainingPanel.Y = door.Height - 8 wopr.Animate(&d) // 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.AnyEvent) // 1006 does not work in xterm or syncterm. press_keys(&d) // press_a_key(&d) d.Write(door.CRNL) 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) 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_keys(&d) // press_a_key(&d) var mainmenu door.Menu = MainMenu() var choice int for choice >= 0 { d.Write(door.Clrscr + door.HideCursor) choice = mainmenu.Choose(&d) d.Write(door.ShowCursor) if choice < 0 { break } option := mainmenu.GetOption(choice) // fmt.Printf("Choice: %d, Option: %c\n", choice, option) switch option { case 'A': display_ansi(&d) press_a_key(&d) case 'D': display_information(&d) press_a_key(&d) case 'F': font_demo(&d) press_a_key(&d) case 'I': d.Write(door.Reset + door.CRNL + door.CRNL) input_demo(&d) press_a_key(&d) case 'M': d.Write(door.Reset + door.CRNL + "TO DO: Provide menu of options to select from..." + door.CRNL) press_a_key(&d) case 'P': progress_bars(&d) press_a_key(&d) case 'S': panel_demo(&d) press_a_key(&d) case 'T': about_test_door(&d) press_a_key(&d) case 'W': width_demo(&d) case 'Q': choice = -1 case 'C': // Disabled var a, z int z = 0 a = 10 / z z = a _ = a _ = z } } // d.Write("\x1b[?1000l") // disable mouse // d.Write("\x1b[?1002l") d.DisableMouse() d.Write(door.Reset + door.CRNL) message = fmt.Sprintf("Returning to the %s BBS..."+door.CRNL, d.Config.BBSID) d.Write(message) d.WaitKey(time.Second) left = d.TimeLeft() ticker.Stop() message = fmt.Sprintf("You had %0.2f minutes remaining!"+door.CRNL, left.Minutes()) d.Write(message) left = d.TimeUsed() d.Write(fmt.Sprintf("You used %0.2f seconds / %0.2f minutes."+door.CRNL, left.Seconds(), left.Minutes())) fmt.Println("Ending testdoor.go") }