Commit 06591f67 authored by Joseph Pranevich's avatar Joseph Pranevich Committed by Alexandre Julliard

Add support for selection of console mode drivers to use using the

-console option. Currently "tty", "ncurses", and "xterm" are supported. Add stubs for resizing the screen on mode changes.
parent c65f4a47
......@@ -7,14 +7,14 @@
may be provided here in the future. */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "windows.h"
#include "console.h"
#include "config.h"
/* I did this without realizing that CONSOLE_* was actually used by
the Win32 console driver. I will definately have to rename these
functions to avoid the name clash... */
static int pop_driver(char **, char **, int *);
void CONSOLE_Write(char out, int fg_color, int bg_color, int attribute)
{
......@@ -26,20 +26,39 @@ void CONSOLE_Write(char out, int fg_color, int bg_color, int attribute)
}
}
void CONSOLE_Init()
void CONSOLE_Init(char *drivers)
{
/* When this function is called drivers should be a string
that consists of driver names followed by plus (+) signs
to denote additions.
For example:
drivers = tty Load just the tty driver
drivers = ncurses+xterm Load ncurses then xterm
The "default" value is just tty.
*/
char *single;
int length;
/* Suitable defaults... */
driver.console_out = stdout;
driver.console_in = stdin;
/* Eventually, this will be a command-line choice */
#ifndef WINE_NCURSES
TTY_Start();
#else
NCURSES_Start();
#endif
GENERIC_Start();
/*XTERM_Start();*/
while (pop_driver(&drivers, &single, &length))
{
if (!strncmp(single, "tty", length))
TTY_Start();
#ifdef WINE_NCURSES
else if (!strncmp(single, "ncurses", length))
NCURSES_Start();
#endif /* WINE_NCURSES */
else if (!strncmp(single, "xterm", length))
XTERM_Start();
}
GENERIC_Start();
if (driver.init)
driver.init();
......@@ -110,25 +129,25 @@ int CONSOLE_CheckForKeystroke(char *scan, char *ascii)
void CONSOLE_GetKeystroke(char *scan, char *ascii)
{
if (driver.getKeystroke)
return driver.getKeystroke(scan, ascii);
driver.getKeystroke(scan, ascii);
}
void CONSOLE_GetCursorPosition(char *row, char *col)
{
if (driver.getCursorPosition)
return driver.getCursorPosition(row, col);
driver.getCursorPosition(row, col);
}
void CONSOLE_GetCharacterAtCursor(char *ch, int *fg, int *bg, int *a)
{
if (driver.getCharacterAtCursor)
return driver.getCharacterAtCursor(ch, fg, bg, a);
driver.getCharacterAtCursor(ch, fg, bg, a);
}
void CONSOLE_Refresh()
{
if (driver.refresh)
return driver.refresh();
driver.refresh();
}
/* This function is only at the CONSOLE level. */
......@@ -153,7 +172,11 @@ int CONSOLE_GetRefresh()
void CONSOLE_ClearScreen()
{
if (driver.clearScreen)
return driver.clearScreen();
{
driver.clearScreen();
if (!driver.norefresh)
CONSOLE_Refresh();
}
}
char CONSOLE_GetCharacter()
......@@ -165,3 +188,46 @@ char CONSOLE_GetCharacter()
else
return (char) 0; /* Sure, this will probably break programs... */
}
void CONSOLE_ResizeScreen(int x, int y)
{
if (driver.resizeScreen)
driver.resizeScreen(x, y);
}
void CONSOLE_NotifyResizeScreen(int x, int y)
{
if (driver.resizeScreen)
driver.resizeScreen(x, y);
}
/* Utility functions... */
int pop_driver(char **drivers, char **single, int *length)
{
/* Take the string in drivers and extract the first "driver" entry */
/* Advance the pointer in drivers to the next entry, put the origional
pointer in single, and put the length in length. */
/* Return TRUE if we found one */
if (!*drivers)
return FALSE;
*single = *drivers;
*length = 0;
while ((*drivers[0] != NULL) && (*drivers[0] != '+'))
{
(*drivers)++;
(*length)++;
}
while (*drivers[0] == '+')
(*drivers)++;
if (*length)
return TRUE;
else
return FALSE;
}
......@@ -11,6 +11,8 @@
#include "config.h"
#define CONSOLE_DEFAULT_DRIVER "tty"
typedef struct CONSOLE_DRIVER
{
void (*init)();
......@@ -25,6 +27,10 @@ typedef struct CONSOLE_DRIVER
int (*checkForKeystroke)(char *, char *);
void (*getKeystroke)(char *, char *);
/* Windowing Functions */
void (*resizeScreen)(int, int);
void (*notifyResizeScreen)(int, int); /* May be rethought later... */
/* Accellerator Functions (Screen) */
void (*clearWindow)(char, char, char, char, int, int);
void (*scrollUpWindow)(char, char, char, char, char, int, int);
......@@ -46,7 +52,7 @@ typedef struct CONSOLE_DRIVER
CONSOLE_device driver; /* Global driver struct */
/* Generic defines */
void CONSOLE_Init();
void CONSOLE_Init(char *drivers);
void CONSOLE_Close();
void CONSOLE_Write(char out, int fg_color, int bg_color, int attribute);
void CONSOLE_MoveCursor(char row, char col);
......@@ -62,6 +68,8 @@ void CONSOLE_SetRefresh(int);
int CONSOLE_GetRefresh();
void CONSOLE_ClearScreen();
char CONSOLE_GetCharacter();
void CONSOLE_ResizeScreen();
void CONSOLE_NotifyResizeScreen();
/* Generic Defines */
void GENERIC_Start();
......
......@@ -70,6 +70,7 @@ struct options
int perfectGraphics; /* Favor correctness over speed for graphics */
int noDGA; /* Disable XFree86 DGA extensions */
char * configFileName; /* Command line config file */
char * consoleDrivers; /* Console driver list */
};
extern struct options Options;
......
......@@ -42,7 +42,6 @@
#include "task.h"
#include "debug.h"
#include "psdrv.h"
#include "console.h"
int __winelib = 1; /* Winelib run-time flag */
......@@ -81,9 +80,6 @@ BOOL32 MAIN_MainInit(void)
/* registry initialisation */
SHELL_LoadRegistry();
/* Set up text-mode stuff */
CONSOLE_Init();
return TRUE;
}
......
......@@ -95,7 +95,8 @@ struct options Options =
FALSE, /* Managed windows */
FALSE, /* Perfect graphics */
FALSE, /* No DGA */
NULL /* Alternate config file name */
NULL, /* Alternate config file name */
NULL /* Console driver list */
};
......@@ -120,7 +121,8 @@ static XrmOptionDescRec optionsTable[] =
{ "-managed", ".managed", XrmoptionNoArg, (caddr_t)"off"},
{ "-winver", ".winver", XrmoptionSepArg, (caddr_t)NULL },
{ "-config", ".config", XrmoptionSepArg, (caddr_t)NULL },
{ "-nodga", ".nodga", XrmoptionNoArg, (caddr_t)"off"}
{ "-nodga", ".nodga", XrmoptionNoArg, (caddr_t)"off"},
{ "-console", ".console", XrmoptionSepArg, (caddr_t)NULL }
};
#define NB_OPTIONS (sizeof(optionsTable) / sizeof(optionsTable[0]))
......@@ -132,6 +134,7 @@ static XrmOptionDescRec optionsTable[] =
"Options:\n" \
" -backingstore Turn on backing store\n" \
" -config name Specify config file to use\n" \
" -console driver Select which driver(s) to use for the console\n" \
" -debug Enter debugger before starting application\n" \
" -debugmsg name Turn debugging-messages on or off\n" \
" -depth n Change the depth to use for multiple-depth screens\n" \
......@@ -877,6 +880,12 @@ static void MAIN_ParseOptions( int *argc, char *argv[] )
Options.configFileName = xstrdup((char *)value.addr);
if (MAIN_GetResource( db, ".nodga", &value))
Options.noDGA = TRUE;
if (MAIN_GetResource( db, ".console", &value))
Options.consoleDrivers = xstrdup((char *)value.addr);
else
Options.consoleDrivers = CONSOLE_DEFAULT_DRIVER;
CONSOLE_Init(Options.consoleDrivers);
}
......
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