Moontalk server and client (provided by many parties)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

80 line
2.2KB

  1. 1024 constant MOTD_BUFFER_SIZE
  2. create motdbuffer MOTD_BUFFER_SIZE allot
  3. variable motd-length
  4. : (update) ( str -- )
  5. MOTD_BUFFER_SIZE min dup motd-length !
  6. motdbuffer swap move ;
  7. : motd-clear ( -- )
  8. motdbuffer MOTD_BUFFER_SIZE bl fill
  9. 0 motd-length ! ;
  10. : motd-append ( str -- )
  11. MOTD_BUFFER_SIZE motd-length @ - min
  12. motdbuffer motd-length @ + swap dup motd-length +! move ;
  13. : motd@ ( -- str )
  14. motdbuffer motd-length @ ;
  15. : motd-propagate ( -- )
  16. 0 EVENT_MOTD_CHANGED events.enqueue ;
  17. : .motd ( -- ) motd@ cr type ;
  18. : (strallot) ( str -- )
  19. here swap dup allot move ;
  20. : (append-banner) ( start-addr size-u -- start-addr size-u )
  21. BEGIN
  22. 10 parse
  23. 2dup s" end-motd-banner" search nip nip IF
  24. 2drop EXIT
  25. THEN
  26. dup 0<> IF
  27. dup -rot (strallot) + 10 c, 1+
  28. ELSE
  29. 2drop REFILL invert IF
  30. EXIT
  31. THEN
  32. THEN
  33. AGAIN ;
  34. : motd-banner ( "name" -- )
  35. create here 0 , 0 (append-banner) swap ! ;
  36. : end-motd-banner ( -- )
  37. true abort" run motd-banner first." ;
  38. : motd-banner@ ( addr -- str )
  39. dup cell + swap @ ;
  40. : motd-compose ( message-str banner-str -- )
  41. motd-clear
  42. ( banner-str ) motd-append
  43. s\" \n" motd-append
  44. ( message-str ) motd-append
  45. s\" \n" motd-append ;
  46. motd-banner motd-forth1
  47. ________ ___ _______ _________ ____ ____
  48. |_ __ | .' `.|_ __ \ | _ _ ||_ || _|
  49. | |_ \_|/ .-. \ | |__) ||_/ | | \_| | |__| |
  50. | _| | | | | | __ / | | | __ |
  51. _| |_ \ `-' /_| | \ \_ _| |_ _| | | |_
  52. |_____| `.___.'|____| |___||_____| |____||____|
  53. end-motd-banner
  54. motd-banner motd-forth2
  55. _______ _____ ______ _______ _ _
  56. |______ | | |_____/ | |_____|
  57. | |_____| | \_ | | |
  58. end-motd-banner
  59. motd-banner motd-forth3
  60. _/_/_/_/ _/_/ _/_/_/ _/_/_/_/_/ _/ _/
  61. _/ _/ _/ _/ _/ _/ _/ _/
  62. _/_/_/ _/ _/ _/_/_/ _/ _/_/_/_/
  63. _/ _/ _/ _/ _/ _/ _/ _/
  64. _/ _/_/ _/ _/ _/ _/ _/
  65. end-motd-banner
  66. : motd-current-banner ( -- str )
  67. motd-forth3 motd-banner@ ;
  68. s" Lorem ipsum magnam quae aperiam maiores dolor quis ut." motd-current-banner motd-compose