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

/share/examples/bootforth/menuconf.4th

https://github.com/okuoku/freebsd-head
Forth | 110 lines | 102 code | 8 blank | 0 comment | 1 complexity | e59d97e38712a939d2873e0b279553d0 MD5 | raw file
  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 with /boot/stable.conf."
  16. 20 8 at-xy
  17. ." 2. Start FreeBSD with /boot/current.conf."
  18. 20 9 at-xy
  19. ." 3. Start FreeBSD with standard configuration. "
  20. 20 10 at-xy
  21. ." 4. Reboot."
  22. me
  23. ;
  24. : tkey ( d -- flag | char )
  25. seconds +
  26. begin 1 while
  27. dup seconds u< if
  28. drop
  29. -1
  30. exit
  31. then
  32. key? if
  33. drop
  34. key
  35. exit
  36. then
  37. repeat
  38. ;
  39. : prompt
  40. 14 fg
  41. 20 12 at-xy
  42. ." Enter your option (1,2,3,4): "
  43. 10 tkey
  44. dup 32 = if
  45. drop key
  46. then
  47. dup 0< if
  48. drop 51
  49. then
  50. dup emit
  51. me
  52. ;
  53. : help_text
  54. 10 18 at-xy ." * Choose 1 or 2 to run special configuration file."
  55. 10 19 at-xy ." * Choose 3 to proceed with standard bootstrapping."
  56. 12 20 at-xy ." See '?' for available commands, and 'words' for"
  57. 12 21 at-xy ." complete list of Forth words."
  58. 10 22 at-xy ." * Choose 4 in order to warm boot your machine."
  59. ;
  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 /boot/stable.conf. Please wait..." cr
  75. s" /boot/stable.conf" read-conf
  76. 0 boot-conf exit
  77. then
  78. dup 50 = if
  79. drop
  80. 1 25 at-xy cr
  81. ." Loading /boot/current.conf. Please wait..." cr
  82. s" /boot/current.conf" read-conf
  83. 0 boot-conf exit
  84. then
  85. dup 51 = if
  86. drop
  87. 1 25 at-xy cr
  88. ." Proceeding with standard boot. Please wait..." cr
  89. 0 boot-conf exit
  90. then
  91. dup 52 = if
  92. drop
  93. 1 25 at-xy cr
  94. ['] (reboot) catch abort" Error rebooting"
  95. then
  96. 20 12 at-xy
  97. ." Key " emit ." is not a valid option!"
  98. 20 13 at-xy
  99. ." Press any key to continue..."
  100. key drop
  101. repeat
  102. ;