testdoor.go 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637
  1. package main
  2. import (
  3. "fmt"
  4. "log"
  5. "red-green/door"
  6. "runtime/debug"
  7. "strconv"
  8. "strings"
  9. "time"
  10. )
  11. func pctUpdate(pct *int64) func() int64 {
  12. return func() int64 {
  13. return *pct
  14. }
  15. }
  16. // Can I add a function to Door?
  17. // NO: cannot define new methods on non-local type door.Door
  18. /*
  19. func (d *door.Door) PressAKey() {
  20. d.Write(door.Reset + door.CRNL + "Press a key to continue...")
  21. d.Key()
  22. d.Write(door.CRNL)
  23. }
  24. */
  25. func press_a_key(d *door.Door) int {
  26. d.Write(door.Reset + door.CRNL + "Press a key to continue...")
  27. k := d.Key()
  28. d.Write(door.CRNL)
  29. return k
  30. }
  31. func about_test_door(d *door.Door) {
  32. W := 60
  33. center_x := (door.Width - W) / 2
  34. center_y := (door.Height - 16) / 2
  35. about := door.Panel{X: center_x,
  36. Y: center_y,
  37. Width: W,
  38. Style: door.SINGLE_DOUBLE,
  39. BorderColor: door.ColorText("BOLD YELLOW ON BLUE"),
  40. }
  41. about.Lines = append(about.Lines, door.Line{Text: fmt.Sprintf("%*s", -W, "About This Door"),
  42. DefaultColor: door.ColorText("BOLD CYAN ON BLUE")})
  43. about.Lines = append(about.Lines, about.Spacer())
  44. about.Lines = append(about.Lines, door.Line{Text: fmt.Sprintf("%*s", -W, "Test Door written in go, using go door.")})
  45. var copyright string = "(C) 2022 Bugz, Red Green Software"
  46. if door.Unicode {
  47. copyright = strings.Replace(copyright, "(C)", "\u00a9", -1)
  48. }
  49. about.Lines = append(about.Lines,
  50. door.Line{Text: fmt.Sprintf("%*s", -W, copyright),
  51. DefaultColor: door.ColorText("BOLD WHITE ON BLUE")})
  52. for _, text := range []string{"",
  53. "This door was written by Bugz.",
  54. "",
  55. "It is written in Go, understands CP437 and unicode, adapts",
  56. "to screen sizes, uses door32.sys, supports TheDraw Fonts,",
  57. "and runs on Linux and Windows."} {
  58. about.Lines = append(about.Lines, door.Line{Text: fmt.Sprintf("%*s", -W, text)})
  59. }
  60. better := door.NoMoreSecretsDefault
  61. better.Color = door.ColorText("BRI CYAN ON BLUE")
  62. door.NoMoreSecrets(about.Output(), d, &better)
  63. }
  64. func MainMenu() door.Menu {
  65. // Make the main menu
  66. m := door.Menu{Panel: door.Panel{Width: 45,
  67. X: 5,
  68. Y: 5,
  69. Style: door.DOUBLE,
  70. Title: "[ Main Menu: ]",
  71. TitleOffset: 3,
  72. BorderColor: door.ColorText("BRI CYAN ON BLA")}}
  73. m.SelectedR = door.MakeMenuRender(door.ColorText("BOLD CYAN"),
  74. door.ColorText("BOLD BLUE"),
  75. door.ColorText("BOLD WHITE"),
  76. door.ColorText("BOLD CYAN"))
  77. m.UnselectedR = door.MakeMenuRender(door.ColorText("BOLD YEL ON BLUE"),
  78. door.ColorText("BOLD WHI ON BLUE"),
  79. door.ColorText("BOLD YEL ON BLUE"),
  80. door.ColorText("BOLD CYAN ON BLUE"))
  81. m.AddSelection("A", "ANSI Display")
  82. m.AddSelection("C", "Crash")
  83. m.AddSelection("D", "Display Information (dropfile, screen)")
  84. m.AddSelection("F", "Font Demo")
  85. m.AddSelection("I", "Input Prompt Demo")
  86. m.AddSelection("M", "Menu Demo")
  87. m.AddSelection("P", "Progress Bars Demo")
  88. m.AddSelection("S", "Show Panel")
  89. m.AddSelection("T", "Test Door About")
  90. m.AddSelection("W", "Screen Width")
  91. m.AddSelection("Q", "Quit")
  92. return m
  93. }
  94. func display_information(d *door.Door) {
  95. d.Write(door.Clrscr)
  96. keyColor := door.ColorText("BRI GREEN")
  97. sepColor := door.ColorText("BRI YEL")
  98. valColor := door.ColorText("CYAN")
  99. nice_format := func(key string, value string) string {
  100. return fmt.Sprintf("%s%-20s %s: %s%s", keyColor, key, sepColor, valColor, value) + door.CRNL
  101. }
  102. d.Write(nice_format("BBS Software", d.Config.BBSID))
  103. d.Write(nice_format("Time Left", strconv.Itoa(d.Config.Time_left)))
  104. d.Write(nice_format("Real Name", d.Config.Real_name))
  105. d.Write(nice_format("Comm Type", strconv.Itoa(d.Config.Comm_type)))
  106. d.Write(nice_format("Comm Handle", strconv.Itoa(d.Config.Comm_handle)))
  107. d.Write(nice_format("Baudrate", strconv.Itoa(d.Config.Baudrate)))
  108. d.Write(nice_format("Handle", d.Config.Handle))
  109. d.Write(nice_format("User #", strconv.Itoa(d.Config.User_number)))
  110. d.Write(nice_format("Security Level", strconv.Itoa(d.Config.Security_level)))
  111. d.Write(nice_format("Node #", strconv.Itoa(d.Config.Node)))
  112. d.Write(nice_format("Emulation", strconv.Itoa(d.Config.Emulation)))
  113. d.Write(nice_format("Unicode", strconv.FormatBool(door.Unicode)))
  114. d.Write(nice_format("CP437", strconv.FormatBool(door.CP437)))
  115. d.Write(nice_format("Full CP437", strconv.FormatBool(door.Full_CP437)))
  116. d.Write(nice_format("Screen Size", fmt.Sprintf("%d X %d", door.Width, door.Height)))
  117. }
  118. func display_ansi(d *door.Door) {
  119. art := ANSIGrowl()
  120. d.Write(door.Clrscr)
  121. for _, line := range art {
  122. d.Write(line + door.CRNL)
  123. }
  124. }
  125. func font_demo(d *door.Door) {
  126. var output []string
  127. var l int
  128. var centering string
  129. d.Write(door.Clrscr) // + door.CRNL + door.CRNL)
  130. fac := FontAmazonCyan()
  131. output, l = fac.Output("ABCDEFGHIJKL")
  132. if l > door.Width {
  133. output, l = fac.Output("Cyan")
  134. }
  135. if l < door.Width {
  136. centering = strings.Repeat(" ", (door.Width-l)/2)
  137. for _, o := range output {
  138. d.Write(fmt.Sprintf("%s%s%s", centering, o, door.Reset) + door.CRNL)
  139. }
  140. d.Write(door.CRNL)
  141. }
  142. patch := fac.Scan(6)
  143. // log.Printf("Patch: %#v\n", patch)
  144. fac.Modify(4, patch)
  145. output, l = fac.Output("Blue")
  146. centering = strings.Repeat(" ", (door.Width-l)/2)
  147. for _, o := range output {
  148. d.Write(fmt.Sprintf("%s%s%s", centering, o, door.Reset) + door.CRNL)
  149. }
  150. d.Write(door.CRNL)
  151. fac.Modify(1, patch)
  152. output, l = fac.Output("Red")
  153. centering = strings.Repeat(" ", (door.Width-l)/2)
  154. for _, o := range output {
  155. d.Write(fmt.Sprintf("%s%s%s", centering, o, door.Reset) + door.CRNL)
  156. }
  157. d.Write(door.CRNL)
  158. press_a_key(d)
  159. fab := FontAnarchyBlue()
  160. output, l = fab.Output("Bugz is Here!")
  161. if l > door.Width {
  162. output, l = fab.Output("Hello")
  163. }
  164. if l < door.Width {
  165. centering = strings.Repeat(" ", (door.Width-l)/2)
  166. for _, o := range output {
  167. d.Write(centering + o + door.Reset + door.CRNL)
  168. }
  169. d.Write(door.CRNL)
  170. }
  171. unchain := FontUnchained()
  172. output, l = unchain.Output("Hi There!")
  173. if l > door.Width {
  174. output, l = unchain.Output("Meow")
  175. }
  176. if l < door.Width {
  177. centering = strings.Repeat(" ", (door.Width-l)/2)
  178. for _, o := range output {
  179. d.Write(centering + o + door.Reset + door.CRNL)
  180. }
  181. d.Write(door.CRNL)
  182. }
  183. press_a_key(d)
  184. asylum := FontAsylum()
  185. output, l = asylum.Output("Bugz ROCKS")
  186. if l > door.Width {
  187. output, l = asylum.Output("Aslym")
  188. }
  189. if l < door.Width {
  190. centering = strings.Repeat(" ", (door.Width-l)/2)
  191. for _, o := range output {
  192. d.Write(centering + o + door.Reset + door.CRNL)
  193. }
  194. d.Write(door.CRNL)
  195. }
  196. brain := FontBrainDmgBlu()
  197. output, l = brain.Output("I'm so BLUE")
  198. if l > door.Width {
  199. output, l = brain.Output("Blue")
  200. }
  201. if l < door.Width {
  202. centering = strings.Repeat(" ", (door.Width-l)/2)
  203. for _, o := range output {
  204. d.Write(centering + o + door.Reset + door.CRNL)
  205. }
  206. d.Write(door.CRNL)
  207. }
  208. boner := FontBoner()
  209. output, l = boner.Output("Welcome!")
  210. if l < door.Width {
  211. centering = strings.Repeat(" ", (door.Width-l)/2)
  212. for _, o := range output {
  213. d.Write(centering + o + door.Reset + door.CRNL)
  214. }
  215. d.Write(door.CRNL)
  216. }
  217. press_a_key(d)
  218. descent := FontDescent()
  219. output, l = descent.Output("Meanwhile...")
  220. if l > door.Width {
  221. output, l = descent.Output("BUGZ")
  222. }
  223. if l < door.Width {
  224. centering = strings.Repeat(" ", (door.Width-l)/2)
  225. for _, o := range output {
  226. d.Write(centering + o + door.Reset + door.CRNL)
  227. }
  228. d.Write(door.CRNL)
  229. }
  230. remorse := FontRemorse()
  231. output, l = remorse.Output("Enjoy the fonts")
  232. if l > door.Width {
  233. output, l = remorse.Output("Amazing")
  234. }
  235. if l < door.Width {
  236. centering = strings.Repeat(" ", (door.Width-l)/2)
  237. for _, o := range output {
  238. d.Write(centering + o + door.Reset + door.CRNL)
  239. }
  240. d.Write(door.CRNL)
  241. }
  242. dungeon := FontDungeon()
  243. output, l = dungeon.Output("Until NEXT time")
  244. if l > door.Width {
  245. output, l = dungeon.Output("Beware")
  246. }
  247. if l < door.Width {
  248. centering = strings.Repeat(" ", (door.Width-l)/2)
  249. for _, o := range output {
  250. d.Write(centering + o + door.Reset + door.CRNL)
  251. }
  252. d.Write(door.CRNL)
  253. }
  254. /*
  255. redgreen := FontArmageddon()
  256. white := redgreen.Scan(7)
  257. blue := redgreen.Scan(4)
  258. redgreen.Modify(1, white)
  259. redgreen.Modify(2, blue)
  260. */
  261. redgreen := FontRedGreen()
  262. output, l = redgreen.Output("Red-Green")
  263. if l < door.Width {
  264. press_a_key(d)
  265. centering = strings.Repeat(" ", (door.Width-l)/2)
  266. for _, o := range output {
  267. d.Write(centering + o + door.Reset + door.CRNL)
  268. }
  269. d.Write(door.CRNL)
  270. output, l = redgreen.Output("Software")
  271. centering = strings.Repeat(" ", (door.Width-l)/2)
  272. for _, o := range output {
  273. d.Write(centering + o + door.Reset + door.CRNL)
  274. }
  275. d.Write(door.CRNL)
  276. }
  277. }
  278. func input_demo(d *door.Door) {
  279. ticker := time.NewTicker(time.Second)
  280. go func() {
  281. for t := range ticker.C {
  282. const tf = "January 2, 2006 03:04:05 PM MST"
  283. output := door.SavePos + door.Goto(5, 2) + door.ColorText("BRI WHI ON GREEN") + t.Format(tf) + door.RestorePos
  284. d.Write(output)
  285. }
  286. }()
  287. inputColor := door.ColorText("BRI WHI ON BLUE")
  288. inputColor2 := door.ColorText("BRI WHI ON GREEN")
  289. prompt := door.Line{Text: "What is YOUR Name: "}
  290. prompt.RenderF = door.RenderBlueYellow
  291. d.Write(prompt.Output() + inputColor)
  292. name := d.Input(25)
  293. d.Write(door.Reset + door.CRNL)
  294. prompt.Text = "What is Your Quest: "
  295. d.Write(prompt.Output() + inputColor2)
  296. quest := d.Input(35)
  297. d.Write(door.Reset + door.CRNL)
  298. prompt.Text = "What is your Favorite CoLoR: "
  299. d.Write(prompt.Output() + inputColor2)
  300. color := d.Input(15)
  301. d.Write(door.Reset + door.CRNL)
  302. ticker.Stop()
  303. d.Write(fmt.Sprintf("You're %s on the %s quest, and fond of %s."+door.CRNL, name, quest, color))
  304. }
  305. func progress_bars(d *door.Door) {
  306. d.Write(door.Clrscr)
  307. bar := door.BarLine{Line: door.Line{DefaultColor: door.ColorText("BOLD YELLOW")}, Width: 20, Style: door.HALF_STEP}
  308. bar2 := door.BarLine{Width: 30, Style: door.SOLID, PercentStyle: door.PERCENT_SPACE}
  309. bar2.ColorRange = []door.BarRange{
  310. {2500, door.ColorText("RED")},
  311. {5000, door.ColorText("BROWN")},
  312. {7500, door.ColorText("BOLD YEL")},
  313. {9500, door.ColorText("GREEN")},
  314. {10100, door.ColorText("BRI GRE")}}
  315. bar3 := door.BarLine{Width: 15, Style: door.GRADIENT, Line: door.Line{DefaultColor: door.ColorText("CYAN")}}
  316. var percentage int64
  317. bar.UpdateP = pctUpdate(&percentage)
  318. bar2.UpdateP = pctUpdate(&percentage)
  319. bar3.UpdateP = pctUpdate(&percentage)
  320. update_bars := func() {
  321. bar.Update()
  322. bar2.Update()
  323. bar3.Update()
  324. }
  325. d.Write(door.Goto(3, 12) + "Half-Step")
  326. d.Write(door.Goto(25, 12) + "% with space and Color Range")
  327. d.Write(door.Goto(57, 12) + "Gradient")
  328. d.Write(door.HideCursor)
  329. bar_start := door.Goto(3, 15)
  330. for f := 0; f <= 100; f++ {
  331. percentage = int64(f * 100)
  332. update_bars()
  333. d.Write(bar_start + bar.Output() + " " + door.Reset + bar2.Output() + door.Reset + " " + bar3.Output())
  334. if d.Disconnect() {
  335. // don't continue to sleep if we're disconnected
  336. break
  337. }
  338. time.Sleep(time.Millisecond * 100)
  339. }
  340. d.Write(door.ShowCursor)
  341. }
  342. func width_demo(d *door.Door) {
  343. w := door.Width
  344. panel := door.Panel{X: 1, Y: 1, Width: w}
  345. lineColor := door.ColorText("WHI")
  346. var line string
  347. for y := 1; y <= door.Height; y++ {
  348. if y%10 == 0 {
  349. line = strings.Repeat("1234567890", w/10)
  350. for x := len(line); x < w; x++ {
  351. line += strconv.Itoa((x + 1) % 10)
  352. }
  353. } else {
  354. line = ""
  355. for x := 1; x < w; x++ {
  356. if x%10 == 0 {
  357. line += strconv.Itoa(y % 10)
  358. } else {
  359. line += " "
  360. }
  361. }
  362. }
  363. l := door.Line{Text: line, DefaultColor: lineColor}
  364. panel.Lines = append(panel.Lines, l)
  365. }
  366. message := fmt.Sprintf("Screen Size: %d X %d", door.Width, door.Height)
  367. d.Write(panel.Output())
  368. // Output alert on top of panel
  369. cx := (door.Width - len(message) + 2) / 2
  370. cy := (door.Height - 3) / 2
  371. alert := door.AlertBox(message, 1)
  372. d.Write(door.ColorText("BRI YEL ON BLUE"))
  373. for idx, ab := range alert {
  374. d.Write(door.Goto(cx, cy+idx) + ab)
  375. }
  376. d.Write(door.Reset + panel.GotoEnd())
  377. // Pause for key
  378. d.Key()
  379. panel.Lines = make([]door.Line, 0)
  380. background := "BUGZ Test Door in GO "
  381. bl := len(background)
  382. for y := 1; y <= door.Height; y++ {
  383. offset := (y - 1) % bl
  384. line = background[offset:]
  385. for len(line) < w {
  386. if len(line)+bl <= w {
  387. line += background
  388. } else {
  389. line += background[0 : w-len(line)]
  390. }
  391. }
  392. l := door.Line{Text: line, RenderF: door.RenderBlueYellow}
  393. panel.Lines = append(panel.Lines, l)
  394. }
  395. d.Write(panel.Output())
  396. d.Key()
  397. }
  398. func panel_demo(d *door.Door) {
  399. width := 55
  400. fmtStr := "%-55s"
  401. p := door.Panel{X: 5, Y: 5, Width: width, Style: door.DOUBLE, BorderColor: door.ColorText("CYAN ON BLUE"), Title: "[ Panel Demo ]"}
  402. lineColor := door.ColorText("BRIGHT WHI ON BLUE")
  403. // Add lines to the panel
  404. for _, line := range []string{"The BBS Door Panel Demo", "(C) 2021 Red Green Software, https://red-green.com"} {
  405. if door.Unicode {
  406. line = strings.Replace(line, "(C)", "\u00a9", -1)
  407. }
  408. l := door.Line{Text: fmt.Sprintf(fmtStr, line), DefaultColor: lineColor}
  409. p.Lines = append(p.Lines, l)
  410. }
  411. p.Lines = append(p.Lines, p.Spacer())
  412. p.Lines = append(p.Lines, door.Line{Text: fmt.Sprintf(fmtStr, "Welcome to golang!"), DefaultColor: lineColor})
  413. single := door.Panel{X: 6, Y: 12, Width: 10, Style: door.SINGLE, BorderColor: door.ColorText("WHITE ON BLUE"), Title: "< Single >"}
  414. single.Lines = append(single.Lines, door.Line{Text: "Example ", DefaultColor: door.ColorText("WHI ON BLACK")})
  415. single.Lines = append(single.Lines, single.Spacer())
  416. single.Lines = append(single.Lines, door.Line{Text: "More Text ", DefaultColor: door.ColorText("BRI GREEN ON BLACK")})
  417. ds := door.Panel{X: 26, Y: 12, Width: 15, Style: door.DOUBLE_SINGLE, BorderColor: door.ColorText("BRI CYAN ON GREEN"), Title: "Double", TitleOffset: 3}
  418. ds.Lines = append(ds.Lines, door.Line{Text: "Double / Single", DefaultColor: door.ColorText("BRI WHI ON GREEN")})
  419. ds.Lines = append(ds.Lines, ds.Spacer())
  420. ds.Lines = append(ds.Lines, door.Line{Text: "Some Other Text", DefaultColor: door.ColorText("BRI CYAN ON GREEN")})
  421. sd := door.Panel{X: 46, Y: 12, Width: 15, Style: door.SINGLE_DOUBLE, BorderColor: door.ColorText("BRI YELL ON RED")}
  422. sd.Lines = append(sd.Lines, door.Line{Text: "Single / Double", DefaultColor: door.ColorText("BRI WHI ON RED")})
  423. sd.Lines = append(sd.Lines, sd.Spacer())
  424. sd.Lines = append(sd.Lines, door.Line{Text: "Text Goes Here ", DefaultColor: door.ColorText("BRI GREEN ON RED")})
  425. d.Write(door.Clrscr)
  426. d.Write(p.Output())
  427. d.Write(single.Output())
  428. d.Write(ds.Output())
  429. d.Write(sd.Output())
  430. }
  431. func main() {
  432. var message string
  433. fmt.Println("Starting testdoor.go")
  434. d := door.Door{}
  435. d.Init("testdoor")
  436. defer func() {
  437. if err := recover(); err != nil {
  438. log.Println("FAILURE:", err)
  439. // Display error to user
  440. d.Write(fmt.Sprintf(door.Reset+door.CRNL+"Exception: %v"+door.CRNL, err))
  441. // This displays stack trace stderr
  442. debug.PrintStack()
  443. }
  444. }()
  445. // defer d.Close()
  446. ticker := time.NewTicker(time.Second)
  447. go func() {
  448. for t := range ticker.C {
  449. const tf = "03:04:05 PM"
  450. var timeinfo string = fmt.Sprintf("(%3.1f mins)", d.TimeLeft().Minutes())
  451. // maxlen = 12 + 7 + 5 = 24
  452. output := door.SavePos + door.Goto(door.Width-25, 0) + door.ColorText("BRI WHI ON BLUE") + " " + t.Format(tf) + " " + timeinfo + " " + door.RestorePos
  453. if !d.Disconnect() {
  454. d.Write(output)
  455. } else {
  456. ticker.Stop()
  457. return
  458. }
  459. }
  460. }()
  461. bold := door.Color(1, 37, 40)
  462. bolder := door.ColorText("BLI BOLD YEL ON BLUE")
  463. d.Write("Welcome to " + bolder + "door32.sys" + door.Reset + door.CRNL + "..." + door.CRNL)
  464. key := press_a_key(&d)
  465. d.Write(fmt.Sprintf("Key %s%d / %x%s", bold, key, key, door.Reset) + door.CRNL)
  466. b := door.AlertBox("Warning: golang is in use!", 1)
  467. d.Write(door.ColorText("BRI WHI ON GREEN"))
  468. for _, line := range b {
  469. d.Write(line + door.CRNL)
  470. }
  471. d.Write(door.Reset + door.CRNL)
  472. left := d.TimeLeft()
  473. message = fmt.Sprintf("You have %0.2f minutes / %0.2f seconds remaining..."+door.CRNL, left.Minutes(), left.Seconds())
  474. d.Write(message)
  475. press_a_key(&d)
  476. mainmenu := MainMenu()
  477. var choice int
  478. for choice >= 0 {
  479. d.Write(door.Clrscr + door.HideCursor)
  480. choice = mainmenu.Choose(&d)
  481. d.Write(door.ShowCursor)
  482. if choice < 0 {
  483. break
  484. }
  485. option := mainmenu.GetOption(choice)
  486. // fmt.Printf("Choice: %d, Option: %c\n", choice, option)
  487. switch option {
  488. case 'A':
  489. display_ansi(&d)
  490. press_a_key(&d)
  491. case 'D':
  492. display_information(&d)
  493. press_a_key(&d)
  494. case 'F':
  495. font_demo(&d)
  496. press_a_key(&d)
  497. case 'I':
  498. d.Write(door.Reset + door.CRNL + door.CRNL)
  499. input_demo(&d)
  500. press_a_key(&d)
  501. case 'M':
  502. d.Write(door.Reset + door.CRNL + "TO DO: Provide menu of options to select from..." + door.CRNL)
  503. press_a_key(&d)
  504. case 'P':
  505. progress_bars(&d)
  506. press_a_key(&d)
  507. case 'S':
  508. panel_demo(&d)
  509. press_a_key(&d)
  510. case 'T':
  511. about_test_door(&d)
  512. press_a_key(&d)
  513. case 'W':
  514. width_demo(&d)
  515. case 'Q':
  516. choice = -1
  517. case 'C':
  518. z := 0
  519. a := 10 / z
  520. z = a
  521. }
  522. }
  523. d.Write(door.Reset + door.CRNL)
  524. message = fmt.Sprintf("Returning to the %s BBS..."+door.CRNL, d.Config.BBSID)
  525. d.Write(message)
  526. d.WaitKey(1, 0)
  527. left = d.TimeLeft()
  528. ticker.Stop()
  529. message = fmt.Sprintf("You had %0.2f minutes / %0.2f seconds remaining!"+door.CRNL, left.Minutes(), left.Seconds())
  530. d.Write(message)
  531. left = d.TimeUsed()
  532. d.Write(fmt.Sprintf("You used %0.2f seconds / %0.2f minutes."+door.CRNL, left.Seconds(), left.Minutes()))
  533. fmt.Println("Ending testdoor.go")
  534. }