Tell Solaris users where to get XPM.
[wine/dcerpc.git] / console / generic.c
blob6cb0181b5bbb57d974872b0203fd9b194423340e
1 /* generic.c */
2 /* Copyright 1999 - Joseph Pranevich */
4 /* This is a driver to implement, when possible, "high-level"
5 routines using only low level calls. This is to make it possible
6 to have accelerated functions for the individual drivers...
7 or to simply not bother with them. */
9 /* When creating new drivers, you need to assign all the functions that
10 that driver supports into the driver struct. If it is a supplementary
11 driver, it should make sure to preserve the old values. */
13 #include "config.h"
15 #include <stdio.h>
17 #include "console.h"
18 #include "debugtools.h"
20 DEFAULT_DEBUG_CHANNEL(console);
22 static void GENERIC_MoveLine(char row1, char row2, char col1, char col2);
23 static void GENERIC_ClearLine(char row, char col1, char col2, int bgcolor,
24 int attribute);
25 void GENERIC_Start(void)
27 /* Here, we only want to add a driver if there is not one already
28 defined. */
30 TRACE("GENERIC_Start\n");
32 if (!driver.clearWindow)
33 driver.clearWindow = GENERIC_ClearWindow;
35 if (!driver.scrollUpWindow)
36 driver.scrollUpWindow = GENERIC_ScrollUpWindow;
38 if (!driver.scrollDownWindow)
39 driver.scrollDownWindow = GENERIC_ScrollDownWindow;
41 if (!driver.getCharacter)
42 driver.getCharacter = GENERIC_GetCharacter;
45 void GENERIC_ClearWindow(char row1, char col1, char row2, char col2,
46 int bg_color, int attribute)
48 char trow, tcol, x;
49 int old_refresh;
51 /* Abort if we have only partial functionality */
52 if (!(driver.getCursorPosition && driver.moveCursor && driver.write))
53 return;
55 old_refresh = CONSOLE_GetRefresh();
56 CONSOLE_SetRefresh(FALSE);
58 CONSOLE_GetCursorPosition(&trow, &tcol);
60 for (x = row1; x <= row2; x++)
61 GENERIC_ClearLine(x, col1, col2, bg_color, attribute);
63 CONSOLE_MoveCursor(trow, tcol);
65 CONSOLE_SetRefresh(old_refresh);
68 void GENERIC_ScrollUpWindow(char row1, char col1, char row2, char col2,
69 char lines, int bg_color, int attribute)
71 /* Scroll Up Window: Characters go down */
73 char trow, tcol, x;
74 int old_refresh;
76 TRACE("Scroll Up %d lines from %d to %d.\n", lines, row1,
77 row2);
79 /* Abort if we have only partial functionality */
80 if (!(driver.getCursorPosition && driver.moveCursor && driver.write
81 && driver.getCharacterAtCursor && driver.clearWindow))
82 return;
84 /* Save initial state... */
85 old_refresh = CONSOLE_GetRefresh();
86 CONSOLE_SetRefresh(FALSE);
87 CONSOLE_GetCursorPosition(&trow, &tcol);
89 for (x = row1 + lines; x <= row2; x++)
91 GENERIC_MoveLine(x, x - lines, col1, col2);
92 GENERIC_ClearLine(x, col1, col2, bg_color, attribute);
95 /* Restore State */
96 CONSOLE_MoveCursor(trow, tcol);
97 CONSOLE_SetRefresh(old_refresh);
100 void GENERIC_ScrollDownWindow(char row1, char col1, char row2, char col2,
101 char lines, int bg_color, int attribute)
103 /* Scroll Down Window: Characters go up */
105 char trow, tcol, x;
106 int old_refresh;
108 /* Abort if we have only partial functionality */
109 if (!(driver.getCursorPosition && driver.moveCursor && driver.write
110 && driver.getCharacterAtCursor && driver.clearWindow))
111 return;
113 /* Save initial state... */
114 old_refresh = CONSOLE_GetRefresh();
115 CONSOLE_SetRefresh(FALSE);
116 CONSOLE_GetCursorPosition(&trow, &tcol);
118 for (x = row2; x >= row1 + lines; x--)
120 GENERIC_MoveLine(x, x + lines, col1, col2);
121 GENERIC_ClearLine(x, col1, col1, bg_color, attribute);
124 /* Restore State */
125 CONSOLE_MoveCursor(trow, tcol);
126 CONSOLE_SetRefresh(old_refresh);
129 char GENERIC_GetCharacter()
131 /* Keep getting keys until we get one with a char value */
132 char ch = (char) 0, scan;
134 while (!ch)
136 CONSOLE_GetKeystroke(&scan, &ch);
138 return ch;
141 static void GENERIC_ClearLine(char row, char col1, char col2, int bgcolor,
142 int attribute)
144 /* This function is here to simplify the logic of the scroll and clear
145 functions but may be useful elsewhere. If it can be used from
146 outside here, it should be made non-static */
148 char x;
150 TRACE("Clear Line: %d from %d to %d (unused: bgcolor %d, attrib %d).\n", row, col1, col2, bgcolor, attribute);
152 for (x = col1; x <= col2; x++)
154 CONSOLE_MoveCursor(row, x);
155 CONSOLE_Write(' ', 0, 0, 0);
158 /* Assume that the calling function will make sure that the cursor is
159 repositioned properly. If this becomes non-static, that will need to be
160 changed. */
163 static void GENERIC_MoveLine(char row1, char row2, char col1, char col2)
165 /* This function is here to simplify the logic of the scroll and clear
166 functions but may be useful elsewhere. If it can be used from
167 outside here, it should be made non-static */
169 char x;
170 int bg_color, fg_color, attribute;
171 char ch;
173 TRACE("Move Line: Move %d to %d.\n", row1, row2);
175 for (x = col1; x <= col2; x++)
177 CONSOLE_MoveCursor(row1, x);
178 CONSOLE_GetCharacterAtCursor(&ch, &fg_color, &bg_color, &attribute);
179 CONSOLE_MoveCursor(row2, x);
180 CONSOLE_Write(ch, fg_color, bg_color, attribute);
183 /* Assume that the calling function will make sure that the cursor is
184 repositioned properly. If this becomes non-static, that will need to be
185 changed. */