Commit ebc0e5e0 authored by Joseph Pranevich's avatar Joseph Pranevich Committed by Alexandre Julliard

Moved initialization until later. Also moved around code a bit to be

consistant.
parent 27a0ced6
/* generic.c */ /* generic.c */
/* Copyright 1999 - Joseph Pranevich */
/* This is a driver to implement, when possible, "high-level" /* This is a driver to implement, when possible, "high-level"
routines using only low level calls. This is to make it possible routines using only low level calls. This is to make it possible
......
...@@ -16,17 +16,9 @@ ...@@ -16,17 +16,9 @@
static int pop_driver(char **, char **, int *); static int pop_driver(char **, char **, int *);
void CONSOLE_Write(char out, int fg_color, int bg_color, int attribute) static int console_initialized = FALSE;
{
if (driver.write)
{
driver.write(out, fg_color, bg_color, attribute);
if (!driver.norefresh)
CONSOLE_Refresh();
}
}
void CONSOLE_Init(char *drivers) int CONSOLE_Init(char *drivers)
{ {
/* When this function is called drivers should be a string /* When this function is called drivers should be a string
that consists of driver names followed by plus (+) signs that consists of driver names followed by plus (+) signs
...@@ -62,6 +54,22 @@ void CONSOLE_Init(char *drivers) ...@@ -62,6 +54,22 @@ void CONSOLE_Init(char *drivers)
if (driver.init) if (driver.init)
driver.init(); driver.init();
/* For now, always return TRUE */
return TRUE;
}
void CONSOLE_Write(char out, int fg_color, int bg_color, int attribute)
{
if (!console_initialized)
console_initialized = CONSOLE_Init(driver.driver_list);
if (driver.write)
{
driver.write(out, fg_color, bg_color, attribute);
if (!driver.norefresh)
CONSOLE_Refresh();
}
} }
void CONSOLE_Close() void CONSOLE_Close()
...@@ -72,6 +80,9 @@ void CONSOLE_Close() ...@@ -72,6 +80,9 @@ void CONSOLE_Close()
void CONSOLE_MoveCursor(char row, char col) void CONSOLE_MoveCursor(char row, char col)
{ {
if (!console_initialized)
console_initialized = CONSOLE_Init(driver.driver_list);
if (driver.moveCursor) if (driver.moveCursor)
{ {
driver.moveCursor(row, col); driver.moveCursor(row, col);
...@@ -83,6 +94,9 @@ void CONSOLE_MoveCursor(char row, char col) ...@@ -83,6 +94,9 @@ void CONSOLE_MoveCursor(char row, char col)
void CONSOLE_ClearWindow(char row1, char col1, char row2, char col2, void CONSOLE_ClearWindow(char row1, char col1, char row2, char col2,
int bg_color, int attribute) int bg_color, int attribute)
{ {
if (!console_initialized)
console_initialized = CONSOLE_Init(driver.driver_list);
if (driver.clearWindow) if (driver.clearWindow)
{ {
driver.clearWindow(row1, col1, row2, col2, bg_color, attribute); driver.clearWindow(row1, col1, row2, col2, bg_color, attribute);
...@@ -94,6 +108,9 @@ void CONSOLE_ClearWindow(char row1, char col1, char row2, char col2, ...@@ -94,6 +108,9 @@ void CONSOLE_ClearWindow(char row1, char col1, char row2, char col2,
void CONSOLE_ScrollUpWindow(char row1, char col1, char row2, char col2, void CONSOLE_ScrollUpWindow(char row1, char col1, char row2, char col2,
char lines, int bg_color, int attribute) char lines, int bg_color, int attribute)
{ {
if (!console_initialized)
console_initialized = CONSOLE_Init(driver.driver_list);
if (driver.scrollUpWindow) if (driver.scrollUpWindow)
{ {
driver.scrollUpWindow(row1, col1, row2, col2, lines, bg_color, driver.scrollUpWindow(row1, col1, row2, col2, lines, bg_color,
...@@ -106,6 +123,9 @@ void CONSOLE_ScrollUpWindow(char row1, char col1, char row2, char col2, ...@@ -106,6 +123,9 @@ void CONSOLE_ScrollUpWindow(char row1, char col1, char row2, char col2,
void CONSOLE_ScrollDownWindow(char row1, char col1, char row2, char col2, void CONSOLE_ScrollDownWindow(char row1, char col1, char row2, char col2,
char lines, int bg_color, int attribute) char lines, int bg_color, int attribute)
{ {
if (!console_initialized)
console_initialized = CONSOLE_Init(driver.driver_list);
if (driver.scrollDownWindow) if (driver.scrollDownWindow)
{ {
driver.scrollDownWindow(row1, col1, row2, col2, lines, bg_color, driver.scrollDownWindow(row1, col1, row2, col2, lines, bg_color,
...@@ -120,6 +140,9 @@ int CONSOLE_CheckForKeystroke(char *scan, char *ascii) ...@@ -120,6 +140,9 @@ int CONSOLE_CheckForKeystroke(char *scan, char *ascii)
should *not* be determined by the driver, rather they should have should *not* be determined by the driver, rather they should have
a conv_* function in int16.c. Yuck. */ a conv_* function in int16.c. Yuck. */
{ {
if (!console_initialized)
console_initialized = CONSOLE_Init(driver.driver_list);
if (driver.checkForKeystroke) if (driver.checkForKeystroke)
return driver.checkForKeystroke(scan, ascii); return driver.checkForKeystroke(scan, ascii);
else else
...@@ -128,57 +151,56 @@ int CONSOLE_CheckForKeystroke(char *scan, char *ascii) ...@@ -128,57 +151,56 @@ int CONSOLE_CheckForKeystroke(char *scan, char *ascii)
void CONSOLE_GetKeystroke(char *scan, char *ascii) void CONSOLE_GetKeystroke(char *scan, char *ascii)
{ {
if (!console_initialized)
console_initialized = CONSOLE_Init(driver.driver_list);
if (driver.getKeystroke) if (driver.getKeystroke)
driver.getKeystroke(scan, ascii); driver.getKeystroke(scan, ascii);
} }
void CONSOLE_GetCursorPosition(char *row, char *col) void CONSOLE_GetCursorPosition(char *row, char *col)
{ {
if (!console_initialized)
console_initialized = CONSOLE_Init(driver.driver_list);
if (driver.getCursorPosition) if (driver.getCursorPosition)
driver.getCursorPosition(row, col); driver.getCursorPosition(row, col);
} }
void CONSOLE_GetCharacterAtCursor(char *ch, int *fg, int *bg, int *a) void CONSOLE_GetCharacterAtCursor(char *ch, int *fg, int *bg, int *a)
{ {
if (!console_initialized)
console_initialized = CONSOLE_Init(driver.driver_list);
if (driver.getCharacterAtCursor) if (driver.getCharacterAtCursor)
driver.getCharacterAtCursor(ch, fg, bg, a); driver.getCharacterAtCursor(ch, fg, bg, a);
} }
void CONSOLE_Refresh() void CONSOLE_Refresh()
{ {
if (!console_initialized)
console_initialized = CONSOLE_Init(driver.driver_list);
if (driver.refresh) if (driver.refresh)
driver.refresh(); driver.refresh();
} }
int CONSOLE_AllocColor(int color) int CONSOLE_AllocColor(int color)
{ {
if (!console_initialized)
console_initialized = CONSOLE_Init(driver.driver_list);
if (driver.allocColor) if (driver.allocColor)
return driver.allocColor(color); return driver.allocColor(color);
else else
return 0; return 0;
} }
/* This function is only at the CONSOLE level. */
/* Admittably, calling the variable norefresh might be a bit dumb...*/
void CONSOLE_SetRefresh(int setting)
{
if (setting)
driver.norefresh = FALSE;
else
driver.norefresh = TRUE;
}
/* This function is only at the CONSOLE level. */
int CONSOLE_GetRefresh()
{
if (driver.norefresh)
return FALSE;
else
return TRUE;
}
void CONSOLE_ClearScreen() void CONSOLE_ClearScreen()
{ {
if (!console_initialized)
console_initialized = CONSOLE_Init(driver.driver_list);
if (driver.clearScreen) if (driver.clearScreen)
{ {
driver.clearScreen(); driver.clearScreen();
...@@ -189,6 +211,9 @@ void CONSOLE_ClearScreen() ...@@ -189,6 +211,9 @@ void CONSOLE_ClearScreen()
char CONSOLE_GetCharacter() char CONSOLE_GetCharacter()
{ {
if (!console_initialized)
console_initialized = CONSOLE_Init(driver.driver_list);
/* I'm not sure if we need this really. This is a function that can be /* I'm not sure if we need this really. This is a function that can be
accelerated that returns the next *non extended* keystroke */ accelerated that returns the next *non extended* keystroke */
if (driver.getCharacter) if (driver.getCharacter)
...@@ -199,6 +224,9 @@ char CONSOLE_GetCharacter() ...@@ -199,6 +224,9 @@ char CONSOLE_GetCharacter()
void CONSOLE_ResizeScreen(int x, int y) void CONSOLE_ResizeScreen(int x, int y)
{ {
if (!console_initialized)
console_initialized = CONSOLE_Init(driver.driver_list);
if (driver.resizeScreen) if (driver.resizeScreen)
driver.resizeScreen(x, y); driver.resizeScreen(x, y);
} }
...@@ -211,12 +239,18 @@ void CONSOLE_NotifyResizeScreen(int x, int y) ...@@ -211,12 +239,18 @@ void CONSOLE_NotifyResizeScreen(int x, int y)
void CONSOLE_SetBackgroundColor(int fg, int bg) void CONSOLE_SetBackgroundColor(int fg, int bg)
{ {
if (!console_initialized)
console_initialized = CONSOLE_Init(driver.driver_list);
if (driver.setBackgroundColor) if (driver.setBackgroundColor)
driver.setBackgroundColor(fg, bg); driver.setBackgroundColor(fg, bg);
} }
void CONSOLE_WriteRawString(char *str) void CONSOLE_WriteRawString(char *str)
{ {
if (!console_initialized)
console_initialized = CONSOLE_Init(driver.driver_list);
/* This is a special function that is only for internal use and /* This is a special function that is only for internal use and
does not actually call any of the console drivers. It's does not actually call any of the console drivers. It's
primary purpose is to provide a way for higher-level drivers primary purpose is to provide a way for higher-level drivers
...@@ -230,6 +264,26 @@ void CONSOLE_WriteRawString(char *str) ...@@ -230,6 +264,26 @@ void CONSOLE_WriteRawString(char *str)
fprintf(driver.console_out, "%s", str); fprintf(driver.console_out, "%s", str);
} }
/* This function is only at the CONSOLE level. */
/* Admittably, calling the variable norefresh might be a bit dumb...*/
void CONSOLE_SetRefresh(int setting)
{
if (setting)
driver.norefresh = FALSE;
else
driver.norefresh = TRUE;
}
/* This function is only at the CONSOLE level. */
int CONSOLE_GetRefresh()
{
if (driver.norefresh)
return FALSE;
else
return TRUE;
}
/* Utility functions... */ /* Utility functions... */
int pop_driver(char **drivers, char **single, int *length) int pop_driver(char **drivers, char **single, int *length)
......
/* ncurses.c */ /* ncurses.c */
/* Copyright 1999 - Joseph Pranevich */
#include "config.h" #include "config.h"
#include "console.h" #include "console.h"
...@@ -146,11 +147,16 @@ void NCURSES_GetCursorPosition(char *row, char *col) ...@@ -146,11 +147,16 @@ void NCURSES_GetCursorPosition(char *row, char *col)
void NCURSES_GetCharacterAtCursor(char *ch, int *fg_color, int void NCURSES_GetCharacterAtCursor(char *ch, int *fg_color, int
*bg_color, int *attribute) *bg_color, int *attribute)
{ {
/* If any of the pointers are NULL, ignore them */
/* We will eventually have to convert the color data */ /* We will eventually have to convert the color data */
*ch = (char) winch(stdscr); if (ch)
*fg_color = 0; *ch = (char) winch(stdscr);
*bg_color = 0; if (fg_color)
*attribute = 0; *fg_color = WINE_WHITE;
if (bg_color)
*bg_color = WINE_BLACK;
if (attribute)
*attribute = 0;
}; };
void NCURSES_Refresh() void NCURSES_Refresh()
......
/* tty.c */ /* tty.c */
/* Copyright 1999 - Joseph Pranevich */
/* This is the console driver for TTY-based consoles, i.e. consoles /* This is the console driver for TTY-based consoles, i.e. consoles
without cursor placement, etc. It's also a pretty decent starting without cursor placement, etc. It's also a pretty decent starting
......
...@@ -60,6 +60,7 @@ typedef struct CONSOLE_DRIVER ...@@ -60,6 +60,7 @@ typedef struct CONSOLE_DRIVER
/* Other data */ /* Other data */
int norefresh; int norefresh;
char *driver_list;
FILE *console_out; FILE *console_out;
FILE *console_in; FILE *console_in;
...@@ -68,7 +69,7 @@ typedef struct CONSOLE_DRIVER ...@@ -68,7 +69,7 @@ typedef struct CONSOLE_DRIVER
CONSOLE_device driver; /* Global driver struct */ CONSOLE_device driver; /* Global driver struct */
/* Generic defines */ /* Generic defines */
void CONSOLE_Init(char *drivers); int CONSOLE_Init(char *drivers);
void CONSOLE_Close(); void CONSOLE_Close();
void CONSOLE_Write(char out, int fg_color, int bg_color, int attribute); void CONSOLE_Write(char out, int fg_color, int bg_color, int attribute);
void CONSOLE_MoveCursor(char row, char col); void CONSOLE_MoveCursor(char row, char col);
......
...@@ -73,7 +73,6 @@ struct options ...@@ -73,7 +73,6 @@ struct options
int perfectGraphics; /* Favor correctness over speed for graphics */ int perfectGraphics; /* Favor correctness over speed for graphics */
int noDGA; /* Disable XFree86 DGA extensions */ int noDGA; /* Disable XFree86 DGA extensions */
char * configFileName; /* Command line config file */ char * configFileName; /* Command line config file */
char * consoleDrivers; /* Console driver list */
int screenDepth; int screenDepth;
}; };
......
...@@ -43,7 +43,6 @@ ...@@ -43,7 +43,6 @@
#include "debug.h" #include "debug.h"
#include "psdrv.h" #include "psdrv.h"
#include "server.h" #include "server.h"
#include "console.h"
int __winelib = 1; /* Winelib run-time flag */ int __winelib = 1; /* Winelib run-time flag */
...@@ -86,9 +85,6 @@ BOOL32 MAIN_MainInit(void) ...@@ -86,9 +85,6 @@ BOOL32 MAIN_MainInit(void)
/* registry initialisation */ /* registry initialisation */
SHELL_LoadRegistry(); SHELL_LoadRegistry();
/* Set up text-mode stuff */
CONSOLE_ResizeScreen(80, 25);
/* Read DOS config.sys */ /* Read DOS config.sys */
if (!DOSCONF_ReadConfig()) return FALSE; if (!DOSCONF_ReadConfig()) return FALSE;
......
...@@ -93,7 +93,6 @@ struct options Options = ...@@ -93,7 +93,6 @@ struct options Options =
FALSE, /* Perfect graphics */ FALSE, /* Perfect graphics */
FALSE, /* No DGA */ FALSE, /* No DGA */
NULL, /* Alternate config file name */ NULL, /* Alternate config file name */
NULL, /* Console driver list */
0 /* screenDepth */ 0 /* screenDepth */
}; };
...@@ -742,8 +741,6 @@ static void MAIN_ParseOptions( int *argc, char *argv[] ) ...@@ -742,8 +741,6 @@ static void MAIN_ParseOptions( int *argc, char *argv[] )
#else /* X_DISPLAY_MISSING */ #else /* X_DISPLAY_MISSING */
TTYDRV_MAIN_ParseOptions(argc,argv); TTYDRV_MAIN_ParseOptions(argc,argv);
#endif /* X_DISPLAY_MISSING */ #endif /* X_DISPLAY_MISSING */
CONSOLE_Init(Options.consoleDrivers);
} }
/*********************************************************************** /***********************************************************************
......
...@@ -245,9 +245,9 @@ void X11DRV_MAIN_ParseOptions(int *argc, char *argv[]) ...@@ -245,9 +245,9 @@ void X11DRV_MAIN_ParseOptions(int *argc, char *argv[])
if (X11DRV_MAIN_GetResource( db, ".nodga", &value)) if (X11DRV_MAIN_GetResource( db, ".nodga", &value))
Options.noDGA = TRUE; Options.noDGA = TRUE;
if (X11DRV_MAIN_GetResource( db, ".console", &value)) if (X11DRV_MAIN_GetResource( db, ".console", &value))
Options.consoleDrivers = xstrdup((char *)value.addr); driver.driver_list = xstrdup((char *)value.addr);
else else
Options.consoleDrivers = CONSOLE_DEFAULT_DRIVER; driver.driver_list = CONSOLE_DEFAULT_DRIVER;
} }
/*********************************************************************** /***********************************************************************
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment