Advertisement
Jan-Langevad

ANSItest.TXT

Jan 5th, 2025 (edited)
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.45 KB | Source Code | 0 0
  1. \ ANSI test Words escape Jan Langevad 10-Jan-2025
  2. \ Tested with ESP32FORTH
  3. \ ANSItest.TXT and https://pastebin.com/sHgQhgAz
  4.  
  5. : ESC ( -- ) 27 emit ;
  6.  
  7. \ Color codes:
  8. 0 constant Black
  9. 1 constant Red
  10. 2 constant Green
  11. 3 constant Yellow
  12. 4 constant Blue
  13. 5 constant Magenta
  14. 6 constant Cyan
  15. 7 constant White
  16.  
  17. : CLS ( -- ) \ Clear Screen
  18. ESC ." [H" \ Home to top left corner
  19. ESC ." [2J" \ Delete all from top left corner and down
  20. ;
  21.  
  22. : HOME ( -- ) ESC S" [H" type ;
  23.  
  24. : INT2ASCII ( n ---) <# # # #> ;
  25.  
  26. : GOTOXY ( x y -- ) \ Move cursor to (x, y)
  27. ESC
  28. ." [" INT2ASCII TYPE
  29. ." ;" INT2ASCII TYPE
  30. ." H"
  31. ;
  32.  
  33. : FG-COLOR ( n -- ) \ 0..7 Set foreground color (30-37, as text)
  34. 30 +
  35. ESC ." [" INT2ASCII TYPE ." m"
  36. ;
  37.  
  38. : BG-COLOR ( n -- ) \ 0..7 Set background color (40-47, as text)
  39. 40 +
  40. ESC ." [" INT2ASCII TYPE ." m"
  41. ;
  42.  
  43. : BOLD ESC ." [1m" ;
  44. : FAINT ESC ." [2m" ;
  45. : -BOLDFAINT ESC ." [22m" ;
  46.  
  47. : ITALIC ESC ." [3m" ; \ not always supported
  48. : -ITALIC ESC ." [23m" ;
  49.  
  50. : UNDERLINE ESC ." [4m" ;
  51. : -UNDERLINE ESC ." [24m" ;
  52.  
  53. : BLINK ESC ." [5m" ; \ not always supported
  54. : -BLINK ESC ." [25m" ;
  55.  
  56. : INVERT ESC ." [7m" ;
  57. : -INVERT ESC ." [27m" ;
  58.  
  59. : HIDDEN ESC ." [8m" ;
  60. : -HIDDEN ESC ." [28m"
  61. ;
  62.  
  63. : STRIKETHROUGH ESC ." [9m" ;
  64. : -STRIKETHROUGH ESC ." [29m" ;
  65.  
  66. : RESET ESC ." [0m" ; \ Reset colors and formatting
  67. \
  68. : TEST-ANSI ( -- )
  69. CLS HOME BOLD
  70. ." ANSI Escape Sequence Test:" CR
  71. 5 5 GOTOXY ." Normal text" CR
  72. 7 7 GOTOXY Red FG-color ." Red text" RESET CR
  73. 9 9 GOTOXY Green FG-Color ." Green text" RESET CR
  74. 11 11 GOTOXY Blue FG-Color ." Blue text" RESET CR
  75. 13 13 GOTOXY Yellow FG-Color ." Yellow text" RESET CR
  76.  
  77. 15 15 GOTOXY Red BG-Color ." Red background" RESET CR
  78. 17 17 GOTOXY Blue BG-Color ." Blue backgrund" RESET CR
  79.  
  80. BOLD ." This is BOLD " -BOLDFAINT CR
  81. FAINT ." This is FAINT " -BOLDFAINT CR
  82. ITALIC ." This is ITALIC " -ITALIC CR
  83. UNDERLINE ." This is UNDERLINE " -UNDERLINE CR
  84. BLINK ." This is BLINK " -BLINK CR
  85. INVERT ." This is INVERT " -INVERT CR
  86. HIDDEN ." This is HIDDEN " -HIDDEN ." <--This was HIDDEN :-) " CR
  87. STRIKETHROUGH ." This is STRIKETHROUGH " -STRIKETHROUGH CR
  88. RESET
  89. ;
  90.  
  91. \ EOF
  92.  
  93.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement