PageRenderTime 42ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 0ms

/src/freebsd/share/examples/bootforth/menu.4th

https://bitbucket.org/killerpenguinassassins/open_distrib_devel
Forth | 99 lines | 92 code | 7 blank | 0 comment | 3 complexity | ef03d88c478c17d254d1168652fdedee MD5 | raw file
Possible License(s): CC0-1.0, MIT, LGPL-2.0, LGPL-3.0, WTFPL, GPL-2.0, BSD-2-Clause, AGPL-3.0, CC-BY-SA-3.0, MPL-2.0, JSON, BSD-3-Clause-No-Nuclear-License-2014, LGPL-2.1, CPL-1.0, AGPL-1.0, 0BSD, ISC, Apache-2.0, GPL-3.0, IPL-1.0, MPL-2.0-no-copyleft-exception, BSD-3-Clause
  1. \ Simple greeting screen, presenting basic options.
  2. \ XXX This is far too trivial - I don't have time now to think
  3. \ XXX about something more fancy... :-/
  4. \ $FreeBSD$
  5. : title
  6. f_single
  7. 60 11 10 4 box
  8. 29 4 at-xy 15 fg 7 bg
  9. ." Welcome to BootFORTH!"
  10. me
  11. ;
  12. : menu
  13. 2 fg
  14. 20 7 at-xy
  15. ." 1. Start FreeBSD /kernel."
  16. 20 8 at-xy
  17. ." 2. Interact with BootFORTH."
  18. 20 9 at-xy
  19. ." 3. Reboot."
  20. me
  21. ;
  22. : tkey ( d -- flag | char )
  23. seconds +
  24. begin 1 while
  25. dup seconds u< if
  26. drop
  27. -1
  28. exit
  29. then
  30. key? if
  31. drop
  32. key
  33. exit
  34. then
  35. repeat
  36. ;
  37. : prompt
  38. 14 fg
  39. 20 11 at-xy
  40. ." Enter your option (1,2,3): "
  41. 10 tkey
  42. dup 32 = if
  43. drop key
  44. then
  45. dup 0< if
  46. drop 49
  47. then
  48. dup emit
  49. me
  50. ;
  51. : help_text
  52. 10 18 at-xy ." * Choose 1 if you just want to run FreeBSD."
  53. 10 19 at-xy ." * Choose 2 if you want to use bootloader facilities."
  54. 12 20 at-xy ." See '?' for available commands, and 'words' for"
  55. 12 21 at-xy ." complete list of Forth words."
  56. 10 22 at-xy ." * Choose 3 in order to warm boot your machine."
  57. ;
  58. : (boot) 0 boot ;
  59. : (reboot) 0 reboot ;
  60. : main_menu
  61. begin 1 while
  62. clear
  63. f_double
  64. 79 23 1 1 box
  65. title
  66. menu
  67. help_text
  68. prompt
  69. cr cr cr
  70. dup 49 = if
  71. drop
  72. 1 25 at-xy cr
  73. ." Loading kernel. Please wait..." cr
  74. ['] (boot) catch abort" Error booting"
  75. then
  76. dup 50 = if
  77. drop
  78. 1 25 at-xy cr
  79. exit
  80. then
  81. dup 51 = if
  82. drop
  83. 1 25 at-xy cr
  84. ['] (reboot) catch abort" Error rebooting"
  85. then
  86. 20 12 at-xy
  87. ." Key " emit ." is not a valid option!"
  88. 20 13 at-xy
  89. ." Press any key to continue..."
  90. key drop
  91. repeat
  92. ;