Minor fixes to comments.
[AROS.git] / rom / devs / console / console_gcc.h
blobb1b36620d97ea98ea9926bcc7040c8991fca5a4a
1 /*
2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang:
7 */
8 #ifndef CONSOLE_GCC_H
9 #define CONSOLE_GCC_H
11 #include <aros/libcall.h>
12 #include <exec/execbase.h>
13 #include <exec/devices.h>
14 #include <exec/semaphores.h>
15 #include <dos/dos.h>
16 #include <devices/conunit.h>
17 #include <intuition/classes.h>
19 #include <proto/alib.h>
21 /* Predeclaration */
22 struct ConsoleBase;
24 /* Constants */
25 #define COTASK_STACKSIZE (AROS_STACKSIZE + 4)
26 #define COTASK_PRIORITY 10
29 /* Minimum x & y char positions */
31 #define DEF_CHAR_XMIN 0
32 #define DEF_CHAR_YMIN 0
35 #define CHAR_XMIN(o) DEF_CHAR_XMIN
36 #define CHAR_YMIN(o) DEF_CHAR_YMIN
38 #define CHAR_XMAX(o) (CU(o)->cu_XMax)
39 #define CHAR_YMAX(o) (CU(o)->cu_YMax)
42 #define XCP (CU(o)->cu_XCP) /* Character X pos */
43 #define YCP (CU(o)->cu_YCP) /* Character Y pos */
45 #define XCCP (CU(o)->cu_XCCP) /* Cursor X pos */
46 #define YCCP (CU(o)->cu_YCCP) /* Cusror Y pos */
48 #define XRSIZE (CU(o)->cu_XRSize)
49 #define YRSIZE (CU(o)->cu_YRSize)
51 #define CP_X(o) (GFX_X(o, CU(o)->cu_XCCP))
52 #define CP_Y(o) (GFX_Y(o, CU(o)->cu_YCCP))
54 /* Macros that convert from char to gfx coords */
56 #define GFX_X(o, x) (CU(o)->cu_XROrigin + ((x) * CU(o)->cu_XRSize))
57 #define GFX_Y(o, y) (CU(o)->cu_YROrigin + ((y) * CU(o)->cu_YRSize))
59 #define GFX_XMIN(o) (GFX_X((o), CHAR_XMIN(o)))
60 #define GFX_YMIN(o) (GFX_Y((o), CHAR_YMIN(o)))
62 #define GFX_XMAX(o) ((GFX_X((o), CHAR_XMAX(o) + 1)) - 1)
63 #define GFX_YMAX(o) ((GFX_Y((o), CHAR_YMAX(o) + 1)) - 1)
65 /* Macros to set/reset/check rawevents */
67 #define SET_RAWEVENT(o, which) (CU(o)->cu_RawEvents[(which) / 8] |= (1 << ((which) & 7)))
68 #define RESET_RAWEVENT(o, which) (CU(o)->cu_RawEvents[(which) / 8] &= ~(1 << ((which) & 7)))
69 #define CHECK_RAWEVENT(o, which) (CU(o)->cu_RawEvents[(which) / 8] & (1 << ((which) & 7)))
71 #define SET_MODE(o, which) (CU(o)->cu_Modes[(which) / 8] |= (1 << ((which) & 7)))
72 #define CLEAR_MODE(o, which) (CU(o)->cu_Modes[(which) / 8] &= ~(1 << ((which) & 7)))
73 #define CHECK_MODE(o, which) (CU(o)->cu_Modes[(which) / 8] & (1 << ((which) & 7)))
75 #define CONSOLECLASSPTR (ConsoleDevice->consoleClass)
76 #define STDCONCLASSPTR (ConsoleDevice->stdConClass)
77 #define CHARMAPCLASSPTR (ConsoleDevice->charMapClass)
78 #define SNIPMAPCLASSPTR (ConsoleDevice->snipMapClass)
80 #define CU(x) ((struct ConUnit *)x)
82 #define ICU(x) ((struct intConUnit *)x)
84 #define WINDOW(o) CU(o)->cu_Window
85 #define RASTPORT(o) WINDOW(o)->RPort
88 #define MAX(a, b) ((a) > (b) ? a : b)
89 #define MIN(a, b) ((a) < (b) ? a : b)
92 #define CON_TXTFLAGS_MASK (FSF_BOLD | FSF_ITALIC | FSF_UNDERLINED)
93 #define CON_TXTFLAGS_BOLD FSF_BOLD
94 #define CON_TXTFLAGS_ITALIC FSF_ITALIC
95 #define CON_TXTFLAGS_UNDERLINED FSF_UNDERLINED
96 #define CON_TXTFLAGS_REVERSED 0x08
97 #define CON_TXTFLAGS_CONCEALED 0x10
99 /* Console write commands */
100 enum
102 C_NIL = 0,
104 C_ASCII,
105 C_ESC,
106 C_BELL,
107 C_BACKSPACE,
108 C_HTAB,
109 C_LINEFEED,
110 C_VTAB,
111 C_FORMFEED,
112 C_CARRIAGE_RETURN,
113 C_SHIFT_IN,
114 C_SHIFT_OUT,
115 C_INDEX,
116 C_NEXT_LINE,
117 C_H_TAB_SET,
118 C_REVERSE_IDX,
120 C_SET_LF_MODE,
121 C_RESET_LF_MODE,
122 C_DEVICE_STATUS_REPORT,
124 C_INSERT_CHAR,
125 C_CURSOR_UP,
126 C_CURSOR_DOWN,
127 C_CURSOR_FORWARD,
128 C_CURSOR_BACKWARD,
129 C_CURSOR_NEXT_LINE,
130 C_CURSOR_PREV_LINE,
131 C_CURSOR_POS,
132 C_CURSOR_HTAB,
133 C_ERASE_IN_DISPLAY,
134 C_ERASE_IN_LINE,
135 C_INSERT_LINE,
136 C_DELETE_LINE,
137 C_DELETE_CHAR,
138 C_SCROLL_UP,
139 C_SCROLL_DOWN,
140 C_CURSOR_TAB_CTRL,
141 C_CURSOR_BACKTAB,
143 C_SELECT_GRAPHIC_RENDITION,
144 C_WINDOW_STATUS_REQUEST,
146 C_CURSOR_VISIBLE,
147 C_CURSOR_INVISIBLE,
149 C_SET_RAWEVENTS,
150 C_RESET_RAWEVENTS,
152 C_SET_AUTOWRAP_MODE,
153 C_RESET_AUTOWRAP_MODE,
154 C_SET_AUTOSCROLL_MODE,
155 C_RESET_AUTOSCROLL_MODE,
156 C_SET_PAGE_LENGTH,
157 C_SET_LINE_LENGTH,
158 C_SET_LEFT_OFFSET,
159 C_SET_TOP_OFFSET,
161 C_ASCII_STRING,
163 NUM_CONSOLE_COMMANDS
166 /**************
167 ** structs **
168 **************/
170 struct coTaskParams
172 struct ConsoleBase *consoleDevice;
173 struct Task *parentTask;
174 ULONG initSignal;
177 struct intPasteData
179 struct MinNode node;
180 struct intConUnit * unit;
181 STRPTR pasteBuffer;
182 ULONG pasteBufferSize;
185 #define CON_INPUTBUF_SIZE 512
186 struct intConUnit
188 struct ConUnit unit;
189 ULONG conFlags;
191 /* Buffer where characters received from the console input handler
192 will be stored
194 UBYTE inputBuf[CON_INPUTBUF_SIZE];
195 /* Number of charcters currently stored in the buffer */
196 ULONG numStoredChars;
198 /* Data to be copied into the inputBuf for processing */
199 struct MinList pasteData;
201 /* Position in the first pasteData element */
202 ULONG pasteBufferPos;
205 /* The conFlags */
206 #define CF_DELAYEDDISPOSE (1L << 0)
207 #define CF_DISPOSE (1L << 1)
209 #if 0
210 /* Determining whether linefeed (LF==LF+CR) mode is on */
211 #define CF_LF_MODE_ON (1L << 2)
212 #endif
214 struct cdihMessage
216 struct Message msg;
217 /* The unit that the user input should go to */
218 Object *unit;
220 struct InputEvent ie;
223 /* Data passed to the console device input handler */
225 struct cdihData
227 struct ConsoleBase *consoleDevice;
228 /* Port to which we send input to the console device
229 from the console device input handler.
231 struct MsgPort *inputPort;
233 /* The port the console.device task replies to telling
234 the console.device input handler that it is finished
235 with the output.
237 struct MsgPort *cdihReplyPort;
239 /* The message struct used to pass user input to the console device */
240 struct cdihMessage *cdihMsg;
247 /*****************
248 ** Prototypes **
249 *****************/
251 struct Interrupt *initCDIH(struct ConsoleBase *ConsoleDevice);
252 VOID cleanupCDIH(struct Interrupt *cdihandler, struct ConsoleBase *ConsoleDevice);
254 VOID consoleTaskEntry(struct ConsoleBase *ConsoleDevice);
256 struct Task *createConsoleTask(APTR taskparams, struct ConsoleBase *ConsoleDevice);
258 /* Prototypes */
259 ULONG writeToConsole(struct ConUnit *unit, STRPTR buf, ULONG towrite
260 , struct ConsoleBase *ConsoleDevice);
262 Class *makeConsoleClass(struct ConsoleBase *ConsoleDevice);
263 Class *makeStdConClass(struct ConsoleBase *ConsoleDevice);
264 Class *makeCharMapConClass(struct ConsoleBase *ConsoleDevice);
265 Class *makeSnipMapConClass(struct ConsoleBase *ConsoleDevice);
267 VOID con_inject(struct ConsoleBase *ConsoleDevice, struct ConUnit *cu, const UBYTE *data, LONG size);
269 VOID printstring(STRPTR string, ULONG len, struct ConsoleBase *ConsoleDevice);
271 VOID setabpen(struct Library *GfxBase, struct RastPort *rp, UBYTE tflags, UBYTE FgPen, UBYTE BgPen);
273 struct ConsoleBase
275 struct Device device;
277 struct MinList unitList;
278 struct SignalSemaphore unitListLock;
279 struct SignalSemaphore consoleTaskLock;
281 struct Interrupt *inputHandler;
282 struct Task *consoleTask;
283 struct MsgPort *commandPort;
285 /* Queued read requests */
286 struct MinList readRequests;
288 Class *consoleClass;
289 Class *stdConClass;
290 Class *charMapClass;
291 Class *snipMapClass;
293 /* Copy buffer
295 This buffer is shared across all console units. It is used by
296 conunits of type CONU_SNIPMAP to provide built in copy/paste.
298 If ConClip is running, this buffer is passed to ConClip on copy,
299 and is not used on Paste. Instead, <CSI> 0 v (Hex 9B 30 20 76)
300 is put into the console units input buffer to signal to the app
301 (console handler or otherwise) to paste.
303 Access to the copyBuffer is protected by a semaphore.
305 const char * copyBuffer;
306 ULONG copyBufferSize;
307 struct SignalSemaphore copyBufferLock;
308 struct MinList sniphooks;
310 struct Library *cb_IntuitionBase;
311 struct Library *cb_KeymapBase;
314 #undef CB
315 #define CB(x) ((struct ConsoleBase *)x)
317 #undef IntuitionBase
318 #define IntuitionBase (((const struct ConsoleBase *)ConsoleDevice)->cb_IntuitionBase)
320 #undef KeymapBase
321 #define KeymapBase (((const struct ConsoleBase *)ConsoleDevice)->cb_KeymapBase)
323 #endif /* CONSOLE_GCC_H */