hp2648a.sl 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. %
  2. % HP2648A.SL - EMODE support for HP2648A terminals.
  3. %
  4. % Author: William F. Galway
  5. % Symbolic Computation Group
  6. % Computer Science Dept.
  7. % University of Utah
  8. % Date: 27 June 1982
  9. % Copyright (c) 1982 University of Utah
  10. %
  11. %%%%% Changes: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  12. % CSP 7/7/82
  13. % - Changed Meta- prefix char to C-\.
  14. % - Defined ESCAPE as genuine prefix character.
  15. % - Changed parity_mask for HP terminals to 8#377.
  16. % CSP 7/8/82
  17. % - This file now redefines quit.
  18. % AS 7/20/82
  19. % - Added ESC-x hooks for line and page scrolling (defined in hp-emodex).
  20. % AS 8/6/82
  21. % - Simple optimization of SetTerminalCursor to reduce number of characters
  22. % sent to the terminal.
  23. % AS 8/12/82
  24. % - Define Terminal-Enter-Raw-Mode and Terminal-Leave-Raw-Mode to
  25. % enable and disable keypad. Removed unnecessary redefinitions of
  26. % EMODE functions that now invoke these new functions.
  27. (fluid '(*EMODE ScreenBase ScreenDelta parity_mask))
  28. % Screen starts at (0,0), and other corner is offset by (79,23) (total
  29. % dimensions are 80 wide by 24 down)
  30. (setf ScreenBase (Coords 0 0))
  31. (setf ScreenDelta (Coords 79 23))
  32. % Parity mask is used to clear "parity bit" for those terminals that don't
  33. % have a meta key. It should be 8#177 in that case. Should be 8#377 for
  34. % terminals with a meta key.
  35. (setq parity_mask 8#377)
  36. (de EraseScreen ()
  37. % Cursor home
  38. (PBOUT (char ESC))
  39. (PBOUT (char H))
  40. % Now clear to end of screen
  41. (PBOUT (char ESC))
  42. (PBOUT (char J)))
  43. (de Ding ()
  44. (PBOUT (char BELL)))
  45. (de TerminalClearEol ()
  46. % Clear to end of line from current position (inclusive).
  47. (PBOUT (char ESC))
  48. (PBOUT (char K)))
  49. (de SetTerminalCursor (ColLoc RowLoc)
  50. % Move physical cursor to Column,Row
  51. (if (and (= RowLoc 0) (= ColLoc 0))
  52. (progn (PBOUT (char ESC)) (PBOUT (char H)))
  53. % Else
  54. (PBOUT (char ESC))
  55. (PBOUT (char '!&))
  56. (PBOUT (char !a))
  57. % Use "quick and dirty" conversion to decimal digits.
  58. (if (> RowLoc 9)
  59. (PBOUT (plus (char 0) (quotient RowLoc 10)))
  60. )
  61. (PBOUT (plus (char 0) (remainder RowLoc 10)))
  62. % Delimiter between row digits and column digits.
  63. (PBOUT (char (lower R)))
  64. (if (> ColLoc 9)
  65. (PBOUT (plus (char 0) (quotient ColLoc 10)))
  66. )
  67. (PBOUT (plus (char 0) (remainder ColLoc 10)))
  68. (PBOUT (char C)) % Terminate the sequence
  69. ))
  70. % EMODE must be loaded first!
  71. (define_prefix_character (char Escape) "Esc-")
  72. (mapc (list
  73. (list (char (cntrl !\)) 'EscapeAsMeta)
  74. (list (CharSequence escape J) 'FullRefresh)
  75. (list (CharSequence escape A) '!$BackwardLine)
  76. (list (CharSequence escape B) '!$ForwardLine)
  77. (list (CharSequence escape C) '!$ForwardCharacter)
  78. (list (CharSequence escape D) '!$BackwardCharacter)
  79. (list (CharSequence escape !h) '!$BeginningOfBuffer)
  80. (list (CharSequence escape F) '!$EndOfBuffer)
  81. (list (CharSequence escape 5) 'forward_word)
  82. (list (CharSequence escape 4) 'backward_word)
  83. (list (CharSequence escape U) 'scroll-window-up-page-command)
  84. (list (CharSequence escape V) 'scroll-window-down-page-command)
  85. (list (CharSequence escape P) '$DeleteForwardCharacter)
  86. (list (CharSequence escape M) 'kill_line)
  87. (list (CharSequence escape L) 'OpenLine)
  88. (list (CharSequence escape S) 'scroll-window-up-line-command)
  89. (list (CharSequence escape T) 'scroll-window-down-line-command)
  90. )
  91. (function
  92. (lambda (lis)
  93. (AddToKeyList 'BasicDispatchList (car lis) (cadr lis)))))
  94. (de terminal-enter-raw-mode ()
  95. % Enable Keypad
  96. (PBOUT (char escape))
  97. (pbout (char !&))
  98. (pbout (char !s))
  99. (pbout (char 1))
  100. (pbout (char A)))
  101. (de terminal-leave-raw-mode ()
  102. % Disable Keypad
  103. (PBOUT (char escape))
  104. (pbout (char !&))
  105. (pbout (char !s))
  106. (pbout (char 0))
  107. (pbout (char A)))