console.pas 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. {
  2. This file is part of the Free Pascal run time library.
  3. A file in Amiga system run time library.
  4. Copyright (c) 1998-2003 by Nils Sjoholm
  5. member of the Amiga RTL development team.
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. {
  13. To call the two routines defined below, you'll need to set
  14. ConsoleBase to an appropriate value.
  15. Added the define use_amiga_smartlink.
  16. 13 Jan 2003.
  17. [email protected] Nils Sjoholm
  18. }
  19. {$I useamigasmartlink.inc}
  20. {$ifdef use_amiga_smartlink}
  21. {$smartlink on}
  22. {$endif use_amiga_smartlink}
  23. unit console;
  24. INTERFACE
  25. uses exec, inputevent, keymap;
  26. const
  27. {***** Console commands *****}
  28. CD_ASKKEYMAP = CMD_NONSTD + 0;
  29. CD_SETKEYMAP = CMD_NONSTD + 1;
  30. CD_ASKDEFAULTKEYMAP = CMD_NONSTD + 2;
  31. CD_SETDEFAULTKEYMAP = CMD_NONSTD + 3;
  32. {***** SGR parameters *****}
  33. SGR_PRIMARY = 0;
  34. SGR_BOLD = 1;
  35. SGR_ITALIC = 3;
  36. SGR_UNDERSCORE = 4;
  37. SGR_NEGATIVE = 7;
  38. SGR_NORMAL = 22; { default foreground color, not bold }
  39. SGR_NOTITALIC = 23;
  40. SGR_NOTUNDERSCORE = 24;
  41. SGR_POSITIVE = 27;
  42. { these names refer to the ANSI standard, not the implementation }
  43. SGR_BLACK = 30;
  44. SGR_RED = 31;
  45. SGR_GREEN = 32;
  46. SGR_YELLOW = 33;
  47. SGR_BLUE = 34;
  48. SGR_MAGENTA = 35;
  49. SGR_CYAN = 36;
  50. SGR_WHITE = 37;
  51. SGR_DEFAULT = 39;
  52. SGR_BLACKBG = 40;
  53. SGR_REDBG = 41;
  54. SGR_GREENBG = 42;
  55. SGR_YELLOWBG = 43;
  56. SGR_BLUEBG = 44;
  57. SGR_MAGENTABG = 45;
  58. SGR_CYANBG = 46;
  59. SGR_WHITEBG = 47;
  60. SGR_DEFAULTBG = 49;
  61. { these names refer to the implementation, they are the preferred }
  62. { names for use with the Amiga console device. }
  63. SGR_CLR0 = 30;
  64. SGR_CLR1 = 31;
  65. SGR_CLR2 = 32;
  66. SGR_CLR3 = 33;
  67. SGR_CLR4 = 34;
  68. SGR_CLR5 = 35;
  69. SGR_CLR6 = 36;
  70. SGR_CLR7 = 37;
  71. SGR_CLR0BG = 40;
  72. SGR_CLR1BG = 41;
  73. SGR_CLR2BG = 42;
  74. SGR_CLR3BG = 43;
  75. SGR_CLR4BG = 44;
  76. SGR_CLR5BG = 45;
  77. SGR_CLR6BG = 46;
  78. SGR_CLR7BG = 47;
  79. {***** DSR parameters *****}
  80. DSR_CPR = 6;
  81. {***** CTC parameters *****}
  82. CTC_HSETTAB = 0;
  83. CTC_HCLRTAB = 2;
  84. CTC_HCLRTABSALL = 5;
  85. {***** TBC parameters *****}
  86. TBC_HCLRTAB = 0;
  87. TBC_HCLRTABSALL = 3;
  88. {***** SM and RM parameters *****}
  89. M_LNM = 20; { linefeed newline mode }
  90. M_ASM = '>1'; { auto scroll mode }
  91. M_AWM = '?7'; { auto wrap mode }
  92. VAR ConsoleDevice : pDevice;
  93. FUNCTION CDInputHandler(events : pInputEvent; consoleDev : pLibrary) : pInputEvent;
  94. FUNCTION RawKeyConvert(events : pInputEvent; buffer : pCHAR; length : LONGINT; keyMap : pKeyMap) : LONGINT;
  95. IMPLEMENTATION
  96. FUNCTION CDInputHandler(events : pInputEvent; consoleDev : pLibrary) : pInputEvent;
  97. BEGIN
  98. ASM
  99. MOVE.L A6,-(A7)
  100. MOVEA.L events,A0
  101. MOVEA.L consoleDev,A1
  102. MOVEA.L ConsoleDevice,A6
  103. JSR -042(A6)
  104. MOVEA.L (A7)+,A6
  105. MOVE.L D0,@RESULT
  106. END;
  107. END;
  108. FUNCTION RawKeyConvert(events : pInputEvent; buffer : pCHAR; length : LONGINT; keyMap : pKeyMap) : LONGINT;
  109. BEGIN
  110. ASM
  111. MOVE.L A6,-(A7)
  112. MOVEA.L events,A0
  113. MOVEA.L buffer,A1
  114. MOVE.L length,D1
  115. MOVEA.L keyMap,A2
  116. MOVEA.L ConsoleDevice,A6
  117. JSR -048(A6)
  118. MOVEA.L (A7)+,A6
  119. MOVE.L D0,@RESULT
  120. END;
  121. END;
  122. END. (* UNIT CONSOLE *)