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 /* This function is only at the CONSOLE level. */
154 /* Admittably, calling the variable norefresh might be a bit dumb...*/
155 void CONSOLE_SetRefresh(int setting
)
158 driver
.norefresh
= FALSE
;
160 driver
.norefresh
= TRUE
;
163 /* This function is only at the CONSOLE level. */
164 int CONSOLE_GetRefresh()
166 if (driver
.norefresh
)
172 void CONSOLE_ClearScreen()
174 if (driver
.clearScreen
)
176 driver
.clearScreen();
177 if (!driver
.norefresh
)
182 char CONSOLE_GetCharacter()
184 /* I'm not sure if we need this really. This is a function that can be
185 accelerated that returns the next *non extended* keystroke */
186 if (driver
.getCharacter
)
187 return driver
.getCharacter();
189 return (char) 0; /* Sure, this will probably break programs... */
192 void CONSOLE_ResizeScreen(int x
, int y
)
194 if (driver
.resizeScreen
)
195 driver
.resizeScreen(x
, y
);
198 void CONSOLE_NotifyResizeScreen(int x
, int y
)
200 if (driver
.notifyResizeScreen
)
201 driver
.notifyResizeScreen(x
, y
);
204 void CONSOLE_WriteRawString(char *str
)
206 /* This is a special function that is only for internal use and
207 does not actually call any of the console drivers. It's
208 primary purpose is to provide a way for higher-level drivers
209 to write directly to the underlying terminal without worry that
210 there will be any retranslation done by the assorted drivers. Care
211 should be taken to ensure that this only gets called when the thing
212 written does not actually produce any output or a CONSOLE_Redraw()
213 is called immediately afterwards.
214 CONSOLE_Redraw() is not yet implemented.
216 fprintf(driver
.console_out
, "%s", str
);
219 /* Utility functions... */
221 int pop_driver(char **drivers
, char **single
, int *length
)
223 /* Take the string in drivers and extract the first "driver" entry */
224 /* Advance the pointer in drivers to the next entry, put the origional
225 pointer in single, and put the length in length. */
226 /* Return TRUE if we found one */
234 while ((*drivers
[0] != NULL
) && (*drivers
[0] != '+'))
240 while (*drivers
[0] == '+')