PageRenderTime 46ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/share/examples/bootforth/menu.4th

https://repo.or.cz/dfdiff.git
Forth | 100 lines | 93 code | 7 blank | 0 comment | 3 complexity | c8a34bea606fef1e03e3ed97786c7e31 MD5 | raw file
Possible License(s): AGPL-1.0, GPL-3.0, CC-BY-SA-3.0, BSD-3-Clause, ISC, GPL-2.0
  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: src/share/examples/bootforth/menu.4th,v 1.4 1999/08/28 00:19:10 peter Exp $
  5. \ $DragonFly: src/share/examples/bootforth/menu.4th,v 1.2 2003/06/17 04:36:57 dillon Exp $
  6. : title
  7. f_single
  8. 60 11 10 4 box
  9. 29 4 at-xy 15 fg 7 bg
  10. ." Welcome to BootFORTH!"
  11. me
  12. ;
  13. : menu
  14. 2 fg
  15. 20 7 at-xy
  16. ." 1. Start FreeBSD /kernel."
  17. 20 8 at-xy
  18. ." 2. Interact with BootFORTH."
  19. 20 9 at-xy
  20. ." 3. Reboot."
  21. me
  22. ;
  23. : tkey ( d -- flag | char )
  24. seconds +
  25. begin 1 while
  26. dup seconds u< if
  27. drop
  28. -1
  29. exit
  30. then
  31. key? if
  32. drop
  33. key
  34. exit
  35. then
  36. repeat
  37. ;
  38. : prompt
  39. 14 fg
  40. 20 11 at-xy
  41. ." Enter your option (1,2,3): "
  42. 10 tkey
  43. dup 32 = if
  44. drop key
  45. then
  46. dup 0< if
  47. drop 49
  48. then
  49. dup emit
  50. me
  51. ;
  52. : help_text
  53. 10 18 at-xy ." * Choose 1 if you just want to run FreeBSD."
  54. 10 19 at-xy ." * Choose 2 if you want to use bootloader facilities."
  55. 12 20 at-xy ." See '?' for available commands, and 'words' for"
  56. 12 21 at-xy ." complete list of Forth words."
  57. 10 22 at-xy ." * Choose 3 in order to warm boot your machine."
  58. ;
  59. : (boot) 0 boot ;
  60. : (reboot) 0 reboot ;
  61. : main_menu
  62. begin 1 while
  63. clear
  64. f_double
  65. 79 23 1 1 box
  66. title
  67. menu
  68. help_text
  69. prompt
  70. cr cr cr
  71. dup 49 = if
  72. drop
  73. 1 25 at-xy cr
  74. ." Loading kernel. Please wait..." cr
  75. ['] (boot) catch abort" Error booting"
  76. then
  77. dup 50 = if
  78. drop
  79. 1 25 at-xy cr
  80. exit
  81. then
  82. dup 51 = if
  83. drop
  84. 1 25 at-xy cr
  85. ['] (reboot) catch abort" Error rebooting"
  86. then
  87. 20 12 at-xy
  88. ." Key " emit ." is not a valid option!"
  89. 20 13 at-xy
  90. ." Press any key to continue..."
  91. key drop
  92. repeat
  93. ;