home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2004 #2 / Amiga Plus CD - 2004 - No. 02.iso / AmigaPlus / Tools / Development / AmigaTalk / system / Console.st < prev    next >
Encoding:
Text File  |  2004-01-31  |  4.9 KB  |  216 lines

  1. " ----------------------------------------------------------------------- "
  2. " Console Class implements control of the console.device.                 "
  3. ""
  4. "  WARNING:  You should know what you're doing to the Amiga OS before     "
  5. "            messing with this Class, or any other System Class!          "
  6. " ----------------------------------------------------------------------- "
  7.  
  8. Class Console :Device ! private myWindow !
  9. [
  10.    dispose
  11.  
  12.      <primitive 222 0 0 private>.
  13.      
  14.      <primitive 250 5 0 private>.
  15.  
  16.      ^ nil
  17. |
  18.    initialize: consoleName for: aWindow
  19.  
  20.      private  <- <primitive 222 0 1 aWindow consoleName>.
  21.  
  22.      myWindow <- aWindow.
  23.      
  24.      ^ self
  25. |
  26.    backSpace 
  27.      self putChar: (8 asCharacter) 
  28. |
  29.    formFeed
  30.      self putChar: (12 asCharacter) 
  31. |
  32.    lineFeed
  33.      self putChar: (10 asCharacter) 
  34. |
  35.    carriageReturn
  36.      self putChar: (13 asCharacter) 
  37. |
  38.    bell
  39.      self putChar: (7 asCharacter)
  40. |
  41.    crlf
  42.      self carriageReturn.
  43.      self lineFeed
  44. |
  45.    cursorToHome
  46.      self putString: (self csi, 'H')
  47. |
  48.    moveCursorTo: aPoint ! moveCode x y !
  49.      x <- aPoint x.
  50.      y <- aPoint y.
  51.      
  52.      moveCode <- (self csi, y asString, ';', x asString, 'H').
  53.  
  54.      self putString: moveCode
  55. |
  56.    nextLineStart   " Go to beginning of next line: "
  57.      self putChar: (16r85 asCharacter)
  58. |
  59.    prevLineStart   " Go to beginning of previous line: "
  60.      self putString: (self csi, '1F')
  61. |
  62.    moveCursorUp: numlines
  63.      self putString: (self csi, (numlines asString), 'A')
  64. |
  65.    moveCursorDown: numlines
  66.      self putString: (self csi, (numlines asString), 'B')
  67. |
  68.    moveCursorRight: numChars
  69.      self putString: (self csi, (numChars asString), 'C')
  70. |
  71.    moveCursorLeft: numChars
  72.      self putString: (self csi, (numChars asString), 'D')
  73. |
  74.    insertLineBelowCurrent
  75.      self putString: (self csi, 'L')
  76. |
  77.    insertSpaces: numSpaces
  78.      self putString: (self csi, (numSpaces asString), '@')
  79. |
  80.    deleteCurrentLine
  81.      self putString: (self csi, 'M')
  82. |
  83.    deleteCurrentChar
  84.      self putString: (self csi, '0P')
  85. |
  86.    deleteCharacters: howMany
  87.      self putString: (self csi, (howMany asString), 'P')
  88. |
  89.    normalChars
  90.      self putString: (self csi, '0m')
  91. |
  92.    boldChars
  93.      self putString: (self csi, '1m')
  94. |
  95.    boldCharsOff
  96.      self putString: (self csi, '22m')
  97. |
  98.    italicChars
  99.      self putString: (self csi, '3m')
  100. |
  101.    italicCharsOff
  102.      self putString: (self csi, '23m')
  103. |
  104.    underlineChars
  105.      self putString: (self csi, '4m')
  106. |
  107.    underlineCharsOff
  108.      self putString: (self csi, '24m')
  109. |
  110.    invertedChars
  111.      self putString: (self csi, '7m')
  112. |
  113.    invertedCharsOff
  114.      self putString: (self csi, '27m')
  115. |
  116.    invisibleText
  117.      self putString: (self csi, '8m')
  118. |     
  119.    visibleText
  120.      self putString: (self csi, '28m')
  121. |     
  122.    cursorInvisible
  123.      self putString: (self csi, '0 p')
  124. |
  125.    cursorVisible
  126.      self putString: (self csi, ' p')
  127. |
  128.    textColor: colorNumber
  129.      " Valid values for colorNumber are: 0 to 7 and 9 (default color): "
  130.  
  131.      self putString: (self csi, ((colorNumber + 30) asString), 'm')
  132. |
  133.    backgroundColor: colorNumber
  134.      " Valid values for colorNumber are: 0 to 7 and 9 (default color): "
  135.  
  136.      self putString: (self csi, ((colorNumber + 40) asString), ';>',
  137.                                 ((colorNumber + 30) asString), 'm').
  138. |
  139.    enableScroll
  140.      self putString: (self csi, '>1h')
  141. |
  142.    disableScroll
  143.      self putString: (self csi, '>1l')
  144. |
  145.    autoWrapOff
  146.      self putString: (self csi, '?7l')
  147. |
  148.    autoWrapOn        " Default is autoWrap ON "
  149.      self putString: (self csi, '?7h')
  150. |
  151.    setPageLength: rasterLines
  152.      self putString: (self csi, (rasterLines asString), 't')
  153. |
  154.    setLineLength: charPositions
  155.      self putString: (self csi, (charPositions asString), 'u')
  156. |
  157.    setLeftOffset: rasterColumns
  158.      self putString: (self csi, (rasterColumns asString), 'x')
  159. |
  160.    setTopOffset: rasterLines 
  161.      " Take care, you could end up in the window Title Bar! "
  162.      self putString: (self csi, (rasterLines asString), 'y')
  163. |
  164.    clearTabs
  165.      self putString: (self csi, '5W')
  166. |
  167.    clearTab
  168.      self putString: (self csi, '2W')
  169. |
  170.    setTab
  171.      self putString: (self csi, '0W')
  172. |
  173.    backTab
  174.      self putString: (self csi, '1Z')
  175. |
  176.    tab
  177.      self putChar: (9 asCharacter)
  178. |
  179.    forwardTabs: numTabs
  180.      self putString: (self csi, (numTabs asString), 'I')
  181. |
  182.    reset: devName " Override parent method "
  183.      self reset
  184. |
  185.    esc                       " Return ESCAPE as a String: "
  186.      ^ <primitive 96 16r1B>
  187. |
  188.    reset     
  189.      self putString: (self esc, 'c')
  190. |
  191.    clear
  192.      self putString: (self esc, '2J')
  193. |
  194.    clearToBottom
  195.      self putString: (self esc, '0J')
  196. |
  197.    getChar
  198.      ^ <primitive 222 0 2 private>
  199. |
  200.    getString
  201.      ^ <primitive 222 0 3 private>
  202. |
  203.    putChar: aCharacter
  204.      <primitive 222 0 4 private aCharacter>
  205. |
  206.    putStringNoReturn: aString
  207.      <primitive 222 0 5 private aString>
  208. |
  209.    putString: aString
  210.      <primitive 222 0 5 private aString>.
  211.       self crlf
  212. |
  213.    csi                       " Return CSI as a String: "
  214.      ^ <primitive 96 16r9B>
  215. ]
  216.