3 /* The primary purpose of this function is to provide CONSOLE_*
4 reotines that immediately call the appropiate driver handler.
5 This cleans up code in the individual modules considerably.
6 This could be done using a macro, but additional functionality
7 may be provided here in the future. */
17 static int pop_driver(char **, char **, int *);
19 void CONSOLE_Write(char out, int fg_color, int bg_color, int attribute)
23 driver.write(out, fg_color, bg_color, attribute);
24 if (!driver.norefresh)
29 void CONSOLE_Init(char *drivers)
31 /* When this function is called drivers should be a string
32 that consists of driver names followed by plus (+) signs
36 drivers = tty Load just the tty driver
37 drivers = ncurses+xterm Load ncurses then xterm
39 The "default" value is just tty.
45 /* Suitable defaults... */
46 driver.console_out = stdout;
47 driver.console_in = stdin;
49 while (pop_driver(&drivers, &single, &length))
51 if (!strncmp(single, "tty", length))
54 else if (!strncmp(single, "ncurses", length))
56 #endif /* WINE_NCURSES */
57 else if (!strncmp(single, "xterm", length))
73 void CONSOLE_MoveCursor(char row, char col)
75 if (driver.moveCursor)
77 driver.moveCursor(row, col);
78 if (!driver.norefresh)
83 void CONSOLE_ClearWindow(char row1, char col1, char row2, char col2,
84 int bg_color, int attribute)
86 if (driver.clearWindow)
88 driver.clearWindow(row1, col1, row2, col2, bg_color, attribute);
89 if (!driver.norefresh)
94 void CONSOLE_ScrollUpWindow(char row1, char col1, char row2, char col2,
95 char lines, int bg_color, int attribute)
97 if (driver.scrollUpWindow)
99 driver.scrollUpWindow(row1, col1, row2, col2, lines, bg_color,
101 if (!driver.norefresh)
106 void CONSOLE_ScrollDownWindow(char row1, char col1, char row2, char col2,
107 char lines, int bg_color, int attribute)
109 if (driver.scrollDownWindow)
111 driver.scrollDownWindow(row1, col1, row2, col2, lines, bg_color,
113 if (!driver.norefresh)
118 int CONSOLE_CheckForKeystroke(char *scan, char *ascii)
119 /* These functions need to go through a conversion layer. Scancodes
120 should *not* be determined by the driver, rather they should have
121 a conv_* function in int16.c. Yuck. */
123 if (driver.checkForKeystroke)
124 return driver.checkForKeystroke(scan, ascii);
129 void CONSOLE_GetKeystroke(char *scan, char *ascii)
131 if (driver.getKeystroke)
132 driver.getKeystroke(scan, ascii);
135 void CONSOLE_GetCursorPosition(char *row, char *col)
137 if (driver.getCursorPosition)
138 driver.getCursorPosition(row, col);
141 void CONSOLE_GetCharacterAtCursor(char *ch, int *fg, int *bg, int *a)
143 if (driver.getCharacterAtCursor)
144 driver.getCharacterAtCursor(ch, fg, bg, a);
147 void CONSOLE_Refresh()
153 int CONSOLE_AllocColor(int color)
155 if (driver.allocColor)
156 return driver.allocColor(color);
161 /* This function is only at the CONSOLE level. */
162 /* Admittably, calling the variable norefresh might be a bit dumb...*/
163 void CONSOLE_SetRefresh(int setting)
166 driver.norefresh = FALSE;
168 driver.norefresh = TRUE;
171 /* This function is only at the CONSOLE level. */
172 int CONSOLE_GetRefresh()
174 if (driver.norefresh)
180 void CONSOLE_ClearScreen()
182 if (driver.clearScreen)
184 driver.clearScreen();
185 if (!driver.norefresh)
190 char CONSOLE_GetCharacter()
192 /* I'm not sure if we need this really. This is a function that can be
193 accelerated that returns the next *non extended* keystroke */
194 if (driver.getCharacter)
195 return driver.getCharacter();
197 return (char) 0; /* Sure, this will probably break programs... */
200 void CONSOLE_ResizeScreen(int x, int y)
202 if (driver.resizeScreen)
203 driver.resizeScreen(x, y);
206 void CONSOLE_NotifyResizeScreen(int x, int y)
208 if (driver.notifyResizeScreen)
209 driver.notifyResizeScreen(x, y);
212 void CONSOLE_SetBackgroundColor(int fg, int bg)
214 if (driver.setBackgroundColor)
215 driver.setBackgroundColor(fg, bg);
218 void CONSOLE_WriteRawString(char *str)
220 /* This is a special function that is only for internal use and
221 does not actually call any of the console drivers. It's
222 primary purpose is to provide a way for higher-level drivers
223 to write directly to the underlying terminal without worry that
224 there will be any retranslation done by the assorted drivers. Care
225 should be taken to ensure that this only gets called when the thing
226 written does not actually produce any output or a CONSOLE_Redraw()
227 is called immediately afterwards.
228 CONSOLE_Redraw() is not yet implemented.
230 fprintf(driver.console_out, "%s", str);
233 /* Utility functions... */
235 int pop_driver(char **drivers, char **single, int *length)
237 /* Take the string in drivers and extract the first "driver" entry */
238 /* Advance the pointer in drivers to the next entry, put the origional
239 pointer in single, and put the length in length. */
240 /* Return TRUE if we found one */
248 while ((*drivers[0] != NULL) && (*drivers[0] != '+'))
254 while (*drivers[0] == '+')