Added the new TTY driver.
[wine/multimedia.git] / console / interface.c
blob8829e9526ccbef28c22b95d38467f40783af1b9c
1 /* interface.c */
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. */
9 #include "windows.h"
10 #include "console.h"
11 #include "config.h"
13 void CONSOLE_Write(char out, int fg_color, int bg_color, int attribute)
15 if (driver.write)
17 driver.write(out, fg_color, bg_color, attribute);
18 if (!driver.norefresh)
19 CONSOLE_Refresh();
23 void CONSOLE_Init()
25 /* Eventually, this will be a command-line choice */
26 #ifndef WINE_NCURSES
27 TTY_Start();
28 #else
29 NCURSES_Start();
30 #endif
31 GENERIC_Start();
33 if (driver.init)
34 driver.init();
37 void CONSOLE_Close()
39 if (driver.close)
40 driver.close();
43 void CONSOLE_MoveCursor(char row, char col)
45 if (driver.moveCursor)
47 driver.moveCursor(row, col);
48 if (!driver.norefresh)
49 CONSOLE_Refresh();
53 void CONSOLE_ClearWindow(char row1, char col1, char row2, char col2,
54 int bg_color, int attribute)
56 if (driver.clearWindow)
58 driver.clearWindow(row1, col1, row2, col2, bg_color, attribute);
59 if (!driver.norefresh)
60 CONSOLE_Refresh();
64 void CONSOLE_ScrollUpWindow(char row1, char col1, char row2, char col2,
65 char lines, int bg_color, int attribute)
67 if (driver.scrollUpWindow)
69 driver.scrollUpWindow(row1, col1, row2, col2, lines, bg_color,
70 attribute);
71 if (!driver.norefresh)
72 CONSOLE_Refresh();
76 void CONSOLE_ScrollDownWindow(char row1, char col1, char row2, char col2,
77 char lines, int bg_color, int attribute)
79 if (driver.scrollDownWindow)
81 driver.scrollDownWindow(row1, col1, row2, col2, lines, bg_color,
82 attribute);
83 if (!driver.norefresh)
84 CONSOLE_Refresh();
88 int CONSOLE_CheckForKeystroke(char *scan, char *ascii)
89 /* These functions need to go through a conversion layer. Scancodes
90 should *not* be determined by the driver, rather they should have
91 a conv_* function in int16.c. Yuck. */
93 if (driver.checkForKeystroke)
94 return driver.checkForKeystroke(scan, ascii);
95 else
96 return FALSE;
99 void CONSOLE_GetKeystroke(char *scan, char *ascii)
101 if (driver.getKeystroke)
102 return driver.getKeystroke(scan, ascii);
105 void CONSOLE_GetCursorPosition(char *row, char *col)
107 if (driver.getCursorPosition)
108 return driver.getCursorPosition(row, col);
111 void CONSOLE_GetCharacterAtCursor(char *ch, int *fg, int *bg, int *a)
113 if (driver.getCharacterAtCursor)
114 return driver.getCharacterAtCursor(ch, fg, bg, a);
117 void CONSOLE_Refresh()
119 if (driver.refresh)
120 return driver.refresh();
123 /* This function is only at the CONSOLE level. */
124 /* Admittably, calling the variable norefresh might be a bit dumb...*/
125 void CONSOLE_SetRefresh(int setting)
127 if (setting)
128 driver.norefresh = FALSE;
129 else
130 driver.norefresh = TRUE;
133 /* This function is only at the CONSOLE level. */
134 int CONSOLE_GetRefresh()
136 if (driver.norefresh)
137 return FALSE;
138 else
139 return TRUE;
142 void CONSOLE_ClearScreen()
144 if (driver.clearScreen)
145 return driver.clearScreen();
148 char CONSOLE_GetCharacter()
150 /* I'm not sure if we need this really. This is a function that can be
151 accelerated that returns the next *non extended* keystroke */
152 if (driver.getCharacter)
153 return driver.getCharacter();
154 else
155 return (char) 0; /* Sure, this will probably break programs... */