3 /* This is a driver to implement, when possible, "high-level"
4 routines using only low level calls. This is to make it possible
5 to have accelerated functions for the individual drivers...
6 or to simply not bother with them. */
8 /* When creating new drivers, you need to assign all the functions that
9 that driver supports into the driver struct. If it is a supplementary
10 driver, it should make sure to perserve the old values. */
19 /* Here, we only want to add a driver if there is not one already
22 TRACE(console, "GENERIC_Start\n");
24 if (!driver.clearWindow)
25 driver.clearWindow = GENERIC_ClearWindow;
27 if (!driver.scrollUpWindow)
28 driver.scrollUpWindow = GENERIC_ScrollUpWindow;
30 if (!driver.scrollDownWindow)
31 driver.scrollDownWindow = GENERIC_ScrollDownWindow;
33 if (!driver.getCharacter)
34 driver.getCharacter = GENERIC_GetCharacter;
37 void GENERIC_ClearWindow(char row1, char col1, char row2, char col2,
38 int bg_color, int attribute)
44 TRACE(console, "GENERIC_ClearWindow()\n");
45 /* Abort if we have only partial functionality */
46 if (!(driver.getCursorPosition && driver.moveCursor && driver.write))
49 old_refresh = CONSOLE_GetRefresh();
50 CONSOLE_SetRefresh(FALSE);
52 CONSOLE_GetCursorPosition(&trow, &tcol);
54 for (x = row1; x < row2; x++)
56 CONSOLE_MoveCursor(x, col1);
58 for (y = col1; y < col2; y++)
60 CONSOLE_Write(' ', 0, bg_color, attribute);
63 CONSOLE_MoveCursor(trow, tcol);
65 CONSOLE_SetRefresh(old_refresh);
67 TRACE(console, "GENERIC_ClearWindow() completed.\n");
70 /* These are in-progress. I just haven't finished them yet... */
71 void GENERIC_ScrollUpWindow(char row1, char col1, char row2, char col2,
72 char lines, int bg_color, int attribute)
80 TRACE(console, "GENERIC_ScrollUpWindow()\n");
82 /* Abort if we have only partial functionality */
83 if (!(driver.getCursorPosition && driver.moveCursor && driver.write
84 && driver.getCharacterAtCursor && driver.clearWindow))
87 old_refresh = CONSOLE_GetRefresh();
88 CONSOLE_SetRefresh(FALSE);
90 CONSOLE_GetCursorPosition(&trow, &tcol);
92 for (x = row1 + lines; x < row2; x++)
94 for (y = col1; y < col2; y++)
96 CONSOLE_MoveCursor(x, y);
97 CONSOLE_GetCharacterAtCursor(&ch, &fg, &bg, &attr);
98 CONSOLE_MoveCursor(x - lines, y);
99 CONSOLE_Write(ch, fg, bg, attr);
102 CONSOLE_ClearWindow(row2 - lines, col1, row2, col2, bg_color,
104 CONSOLE_MoveCursor(trow, tcol);
106 CONSOLE_SetRefresh(old_refresh);
108 TRACE(console, "GENERIC_ScrollUpWindow() completed.\n");
111 void GENERIC_ScrollDownWindow(char row1, char col1, char row2, char col2,
112 char lines, int bg_color, int attribute)
120 TRACE(console, "GENERIC_ScrollDownWindow()\n");
122 /* Abort if we have only partial functionality */
123 if (!(driver.getCursorPosition && driver.moveCursor && driver.write
124 && driver.getCharacterAtCursor && driver.clearWindow))
127 old_refresh = CONSOLE_GetRefresh();
128 CONSOLE_SetRefresh(FALSE);
130 CONSOLE_GetCursorPosition(&trow, &tcol);
132 for (x = row2 - lines; x > row1; x--)
134 for (y = col1; y < col2; y++)
136 CONSOLE_MoveCursor(x, y);
137 CONSOLE_GetCharacterAtCursor(&ch, &fg, &bg, &attr);
138 CONSOLE_MoveCursor(x + lines, y);
139 CONSOLE_Write(ch, fg, bg, attr);
142 CONSOLE_ClearWindow(row1, col1, row1 + lines, col2, bg_color,
144 CONSOLE_MoveCursor(trow, tcol);
146 CONSOLE_SetRefresh(old_refresh);
148 TRACE(console, "GENERIC_ScrollDownWindow() completed.\n");
152 char GENERIC_GetCharacter()
154 /* Keep getting keys until we get one with a char value */
155 char ch = (char) 0, scan;
159 CONSOLE_GetKeystroke(&ch, &scan);