Create X11 palette on DirectDrawSurface::SetPalette, not before (we
[wine/multimedia.git] / console / ncurses.c
blobd34299fe6cbf2520ce9af29913fd35d5e743d210
1 /* ncurses.c */
3 #include "config.h"
5 #ifdef WINE_NCURSES
7 /* This is the console driver for systems that support the ncurses
8 interface.
9 */
11 /* Actually, this should work for curses, as well. But there may be
12 individual functions that are unsupported in plain curses or other
13 variants. Those should be detected and special-cased by autoconf.
16 /* When creating new drivers, you need to assign all the functions that
17 that driver supports into the driver struct. If it is a supplementary
18 driver, it should make sure to perserve the old values.
21 #include "console.h"
22 #include "debug.h"
23 #undef ERR /* Use ncurses's err() */
24 #include <curses.h>
26 void NCURSES_Start()
28 /* This should be the root driver so we can ignore anything
29 already in the struct. */
31 driver.norefresh = FALSE;
33 driver.init = NCURSES_Init;
34 driver.write = NCURSES_Write;
35 driver.close = NCURSES_Close;
36 driver.moveCursor = NCURSES_MoveCursor;
37 driver.getCursorPosition = NCURSES_GetCursorPosition;
38 driver.getCharacterAtCursor = NCURSES_GetCharacterAtCursor;
39 driver.clearScreen = NCURSES_ClearScreen;
41 driver.checkForKeystroke = NCURSES_CheckForKeystroke;
42 driver.getKeystroke = NCURSES_GetKeystroke;
44 driver.refresh = NCURSES_Refresh;
47 void NCURSES_Init()
49 initscr();
50 cbreak();
51 noecho();
52 nonl();
53 intrflush(stdscr, FALSE);
54 keypad(stdscr, TRUE);
55 nodelay(stdscr, TRUE);
58 void NCURSES_Write(char output, int fg, int bg, int attribute)
60 /* We can discard all extended information. */
61 addch(output);
64 void NCURSES_Close()
66 endwin();
69 void NCURSES_GetKeystroke(char *scan, char *ascii)
71 while (!NCURSES_CheckForKeystroke(scan, ascii))
72 {} /* Wait until keystroke is detected */
74 /* When it is detected, we will already have the right value
75 in scan and ascii, but we need to take this keystroke
76 out of the buffer. */
77 getch();
80 int NCURSES_CheckForKeystroke(char *scan, char *ascii)
82 /* We don't currently support scan codes here */
83 /* FIXME */
84 int temp;
85 temp = getch();
86 if (temp == ERR)
88 return FALSE;
90 else
92 ungetch(temp); /* Keystroke not removed from buffer */
93 *ascii = (char) temp;
94 return TRUE;
98 void NCURSES_MoveCursor(char row, char col)
100 move(row, col);
103 void NCURSES_GetCursorPosition(char *row, char *col)
105 int trow, tcol;
107 getyx(stdscr, trow, tcol); /* MACRO, no need to pass pointer */
109 *row = (char) trow;
110 *col = (char) tcol;
113 void NCURSES_GetCharacterAtCursor(char *ch, int *fg_color, int
114 *bg_color, int *attribute)
116 /* We will eventually have to convert the color data */
117 *ch = (char) inch();
118 *fg_color = 0;
119 *bg_color = 0;
120 *attribute = 0;
123 void NCURSES_Refresh()
125 refresh();
128 void NCURSES_ClearScreen()
130 erase();
133 #endif /* WINE_NCURSES */