Removed obsolete console driver.

This commit is contained in:
Alexandre Julliard 2002-04-11 21:50:16 +00:00
parent 13f92d3cdd
commit 7746e82122
12 changed files with 0 additions and 1328 deletions

View File

@ -1 +0,0 @@
Makefile

View File

@ -1,22 +0,0 @@
DEFS = @DLLFLAGS@ -D__WINE__
TOPSRCDIR = @top_srcdir@
TOPOBJDIR = ..
SRCDIR = @srcdir@
VPATH = @srcdir@
MODULE = console
C_SRCS = \
generic.c \
interface.c \
ncurses.c \
tty.c \
xterm.c
all: $(MODULE).o
@MAKE_RULES@
$(MODULE).o: $(OBJS) Makefile.in $(TOPSRCDIR)/Make.rules.in
$(LDCOMBINE) $(OBJS) -o $@
### Dependencies:

View File

@ -1,201 +0,0 @@
/*
* Copyright 1999 - Joseph Pranevich
*
* This is a driver to implement, when possible, "high-level"
* routines using only low level calls. This is to make it possible
* to have accelerated functions for the individual drivers...
* or to simply not bother with them.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* When creating new drivers, you need to assign all the functions that
that driver supports into the driver struct. If it is a supplementary
driver, it should make sure to preserve the old values. */
#include "config.h"
#include <stdio.h>
#include "console.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(console);
static void GENERIC_MoveLine(char row1, char row2, char col1, char col2);
static void GENERIC_ClearLine(char row, char col1, char col2, int bgcolor,
int attribute);
void GENERIC_Start(void)
{
/* Here, we only want to add a driver if there is not one already
defined. */
TRACE("GENERIC_Start\n");
if (!driver.clearWindow)
driver.clearWindow = GENERIC_ClearWindow;
if (!driver.scrollUpWindow)
driver.scrollUpWindow = GENERIC_ScrollUpWindow;
if (!driver.scrollDownWindow)
driver.scrollDownWindow = GENERIC_ScrollDownWindow;
if (!driver.getCharacter)
driver.getCharacter = GENERIC_GetCharacter;
}
void GENERIC_ClearWindow(char row1, char col1, char row2, char col2,
int bg_color, int attribute)
{
char trow, tcol, x;
int old_refresh;
/* Abort if we have only partial functionality */
if (!(driver.getCursorPosition && driver.moveCursor && driver.write))
return;
old_refresh = CONSOLE_GetRefresh();
CONSOLE_SetRefresh(FALSE);
CONSOLE_GetCursorPosition(&trow, &tcol);
for (x = row1; x <= row2; x++)
GENERIC_ClearLine(x, col1, col2, bg_color, attribute);
CONSOLE_MoveCursor(trow, tcol);
CONSOLE_SetRefresh(old_refresh);
}
void GENERIC_ScrollUpWindow(char row1, char col1, char row2, char col2,
char lines, int bg_color, int attribute)
{
/* Scroll Up Window: Characters go down */
char trow, tcol, x;
int old_refresh;
TRACE("Scroll Up %d lines from %d to %d.\n", lines, row1,
row2);
/* Abort if we have only partial functionality */
if (!(driver.getCursorPosition && driver.moveCursor && driver.write
&& driver.getCharacterAtCursor && driver.clearWindow))
return;
/* Save initial state... */
old_refresh = CONSOLE_GetRefresh();
CONSOLE_SetRefresh(FALSE);
CONSOLE_GetCursorPosition(&trow, &tcol);
for (x = row1 + lines; x <= row2; x++)
{
GENERIC_MoveLine(x, x - lines, col1, col2);
GENERIC_ClearLine(x, col1, col2, bg_color, attribute);
}
/* Restore State */
CONSOLE_MoveCursor(trow, tcol);
CONSOLE_SetRefresh(old_refresh);
}
void GENERIC_ScrollDownWindow(char row1, char col1, char row2, char col2,
char lines, int bg_color, int attribute)
{
/* Scroll Down Window: Characters go up */
char trow, tcol, x;
int old_refresh;
/* Abort if we have only partial functionality */
if (!(driver.getCursorPosition && driver.moveCursor && driver.write
&& driver.getCharacterAtCursor && driver.clearWindow))
return;
/* Save initial state... */
old_refresh = CONSOLE_GetRefresh();
CONSOLE_SetRefresh(FALSE);
CONSOLE_GetCursorPosition(&trow, &tcol);
for (x = row2; x >= row1 + lines; x--)
{
GENERIC_MoveLine(x, x + lines, col1, col2);
GENERIC_ClearLine(x, col1, col1, bg_color, attribute);
}
/* Restore State */
CONSOLE_MoveCursor(trow, tcol);
CONSOLE_SetRefresh(old_refresh);
}
char GENERIC_GetCharacter()
{
/* Keep getting keys until we get one with a char value */
char ch = (char) 0, scan;
while (!ch)
{
CONSOLE_GetKeystroke(&scan, &ch);
}
return ch;
}
static void GENERIC_ClearLine(char row, char col1, char col2, int bgcolor,
int attribute)
{
/* This function is here to simplify the logic of the scroll and clear
functions but may be useful elsewhere. If it can be used from
outside here, it should be made non-static */
char x;
TRACE("Clear Line: %d from %d to %d (unused: bgcolor %d, attrib %d).\n", row, col1, col2, bgcolor, attribute);
for (x = col1; x <= col2; x++)
{
CONSOLE_MoveCursor(row, x);
CONSOLE_Write(' ', 0, 0, 0);
}
/* Assume that the calling function will make sure that the cursor is
repositioned properly. If this becomes non-static, that will need to be
changed. */
}
static void GENERIC_MoveLine(char row1, char row2, char col1, char col2)
{
/* This function is here to simplify the logic of the scroll and clear
functions but may be useful elsewhere. If it can be used from
outside here, it should be made non-static */
char x;
int bg_color, fg_color, attribute;
char ch;
TRACE("Move Line: Move %d to %d.\n", row1, row2);
for (x = col1; x <= col2; x++)
{
CONSOLE_MoveCursor(row1, x);
CONSOLE_GetCharacterAtCursor(&ch, &fg_color, &bg_color, &attribute);
CONSOLE_MoveCursor(row2, x);
CONSOLE_Write(ch, fg_color, bg_color, attribute);
}
/* Assume that the calling function will make sure that the cursor is
repositioned properly. If this becomes non-static, that will need to be
changed. */
}

View File

@ -1,376 +0,0 @@
/*
* Copyright 1999 - Joseph Pranevich
*
* The primary purpose of this function is to provide CONSOLE_*
* routines that immediately call the appropriate driver handler.
* This cleans up code in the individual modules considerably.
* This could be done using a macro, but additional functionality
* may be provided here in the future.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "windef.h"
#include "console.h"
#include "options.h"
CONSOLE_device driver;
static int pop_driver(char **, char **, int *);
static int console_initialized = FALSE;
static int CONSOLE_Init(void)
{
char buffer[256];
char *single, *drivers = buffer;
int length;
char initial_rows[5];
char initial_columns[5];
/* Suitable defaults... */
driver.console_out = stdout;
driver.console_in = stdin;
/* 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.
*/
PROFILE_GetWineIniString( "console", "Drivers", CONSOLE_DEFAULT_DRIVER,
buffer, sizeof(buffer) );
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();
}
/* Read in generic configuration */
/* This is primarily to work around a limitation in nxterm where
this information is not correctly passed to the ncurses layer
through the terminal. At least, I'm not doing it correctly if there
is a way. But this serves as a generic way to do the same anyway. */
/* We are setting this to 80x25 here which is *not* the default for
most xterm variants... It is however the standard VGA resolution */
/* FIXME: We need to be able to be able to specify that the window's
dimensions should be used. This is required for correct emulation
of Win32's console and Win32's DOS emulation */
PROFILE_GetWineIniString("console", "InitialRows",
"24", initial_rows, 5);
PROFILE_GetWineIniString("console", "InitialColumns",
"80", initial_columns, 5);
sscanf(initial_rows, "%d", &driver.y_res);
sscanf(initial_columns, "%d", &driver.x_res);
GENERIC_Start();
if (driver.init)
driver.init();
/* Not all terminals let our programs know the proper resolution
if the resolution is set on the command-line... */
CONSOLE_NotifyResizeScreen(driver.x_res, driver.y_res);
atexit(CONSOLE_Close);
/* 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();
if (driver.write)
{
driver.write(out, fg_color, bg_color, attribute);
if (!driver.norefresh)
CONSOLE_Refresh();
}
}
void CONSOLE_Close(void)
{
if (driver.close)
driver.close();
}
void CONSOLE_MoveCursor(char row, char col)
{
if (!console_initialized)
console_initialized = CONSOLE_Init();
if (driver.moveCursor)
{
driver.moveCursor(row, col);
if (!driver.norefresh)
CONSOLE_Refresh();
}
}
void CONSOLE_ClearWindow(char row1, char col1, char row2, char col2,
int bg_color, int attribute)
{
if (!console_initialized)
console_initialized = CONSOLE_Init();
if (driver.clearWindow)
{
driver.clearWindow(row1, col1, row2, col2, bg_color, attribute);
if (!driver.norefresh)
CONSOLE_Refresh();
}
}
void CONSOLE_ScrollUpWindow(char row1, char col1, char row2, char col2,
char lines, int bg_color, int attribute)
{
if (!console_initialized)
console_initialized = CONSOLE_Init();
if (driver.scrollUpWindow)
{
driver.scrollUpWindow(row1, col1, row2, col2, lines, bg_color,
attribute);
if (!driver.norefresh)
CONSOLE_Refresh();
}
}
void CONSOLE_ScrollDownWindow(char row1, char col1, char row2, char col2,
char lines, int bg_color, int attribute)
{
if (!console_initialized)
console_initialized = CONSOLE_Init();
if (driver.scrollDownWindow)
{
driver.scrollDownWindow(row1, col1, row2, col2, lines, bg_color,
attribute);
if (!driver.norefresh)
CONSOLE_Refresh();
}
}
int CONSOLE_CheckForKeystroke(char *scan, char *ascii)
/* These functions need to go through a conversion layer. Scancodes
should *not* be determined by the driver, rather they should have
a conv_* function in int16.c. Yuck. */
{
if (!console_initialized)
console_initialized = CONSOLE_Init();
if (driver.checkForKeystroke)
return driver.checkForKeystroke(scan, ascii);
else
return FALSE;
}
void CONSOLE_GetKeystroke(char *scan, char *ascii)
{
if (!console_initialized)
console_initialized = CONSOLE_Init();
if (driver.getKeystroke)
driver.getKeystroke(scan, ascii);
}
void CONSOLE_GetCursorPosition(char *row, char *col)
{
if (!console_initialized)
console_initialized = CONSOLE_Init();
if (driver.getCursorPosition)
driver.getCursorPosition(row, col);
}
void CONSOLE_GetCharacterAtCursor(char *ch, int *fg, int *bg, int *a)
{
if (!console_initialized)
console_initialized = CONSOLE_Init();
if (driver.getCharacterAtCursor)
driver.getCharacterAtCursor(ch, fg, bg, a);
}
void CONSOLE_Refresh()
{
if (!console_initialized)
console_initialized = CONSOLE_Init();
if (driver.refresh)
driver.refresh();
}
int CONSOLE_AllocColor(int color)
{
if (!console_initialized)
console_initialized = CONSOLE_Init();
if (driver.allocColor)
return driver.allocColor(color);
else
return 0;
}
void CONSOLE_ClearScreen()
{
if (!console_initialized)
console_initialized = CONSOLE_Init();
if (driver.clearScreen)
{
driver.clearScreen();
if (!driver.norefresh)
CONSOLE_Refresh();
}
}
char CONSOLE_GetCharacter()
{
if (!console_initialized)
console_initialized = CONSOLE_Init();
/* I'm not sure if we need this really. This is a function that can be
accelerated that returns the next *non extended* keystroke */
if (driver.getCharacter)
return driver.getCharacter();
else
return (char) 0; /* Sure, this will probably break programs... */
}
void CONSOLE_ResizeScreen(int x, int y)
{
if (!console_initialized)
console_initialized = CONSOLE_Init();
if (driver.resizeScreen)
driver.resizeScreen(x, y);
}
void CONSOLE_NotifyResizeScreen(int x, int y)
{
if (driver.notifyResizeScreen)
driver.notifyResizeScreen(x, y);
}
void CONSOLE_SetBackgroundColor(int fg, int bg)
{
if (!console_initialized)
console_initialized = CONSOLE_Init();
if (driver.setBackgroundColor)
driver.setBackgroundColor(fg, bg);
}
void CONSOLE_GetBackgroundColor(int *fg, int *bg)
{
if (!console_initialized)
console_initialized = CONSOLE_Init();
if (driver.getBackgroundColor)
driver.getBackgroundColor(fg, bg);
}
void CONSOLE_WriteRawString(char *str)
{
if (!console_initialized)
console_initialized = CONSOLE_Init();
/* This is a special function that is only for internal use and
does not actually call any of the console drivers. It's
primary purpose is to provide a way for higher-level drivers
to write directly to the underlying terminal without worry that
there will be any retranslation done by the assorted drivers. Care
should be taken to ensure that this only gets called when the thing
written does not actually produce any output or a CONSOLE_Redraw()
is called immediately afterwards.
CONSOLE_Redraw() is not yet implemented.
*/
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... */
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] != '\0') && (*drivers[0] != '+'))
{
(*drivers)++;
(*length)++;
}
while (*drivers[0] == '+')
(*drivers)++;
if (*length)
return TRUE;
else
return FALSE;
}

View File

@ -1,300 +0,0 @@
/*
* Copyright 1999 - Joseph Pranevich
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "config.h"
#include <stdio.h>
#include "console.h" /* Must define WINE_NCURSES */
#ifdef WINE_NCURSES
/* This is the console driver for systems that support the ncurses
interface.
*/
/* Actually, this should work for curses, as well. But there may be
individual functions that are unsupported in plain curses or other
variants. Those should be detected and special-cased by autoconf.
*/
/* When creating new drivers, you need to assign all the functions that
that driver supports into the driver struct. If it is a supplementary
driver, it should make sure to perserve the old values.
*/
#include "wine/debug.h"
#include "options.h"
WINE_DEFAULT_DEBUG_CHANNEL(console);
#undef ERR /* Use ncurses's err() */
#ifdef HAVE_NCURSES_H
# include <ncurses.h>
#else
# ifdef HAVE_CURSES_H
# include <curses.h>
# endif
#endif
SCREEN *ncurses_screen;
static int get_color_pair(int fg_color, int bg_color);
const char *color_names[] = {"null", "black", "blue", "green",
"cyan", "magenta", "brown", "red", "light gray", "dark gray",
"light blue", "light green", "light red", "light magenta",
"light cyan", "yellow", "white"};
void NCURSES_Start()
{
/* This should be the root driver so we can ignore anything
already in the struct. */
driver.norefresh = FALSE;
driver.init = NCURSES_Init;
driver.write = NCURSES_Write;
driver.close = NCURSES_Close;
driver.moveCursor = NCURSES_MoveCursor;
driver.getCursorPosition = NCURSES_GetCursorPosition;
driver.getCharacterAtCursor = NCURSES_GetCharacterAtCursor;
driver.clearScreen = NCURSES_ClearScreen;
driver.allocColor = NCURSES_AllocColor;
#ifdef HAVE_GETBKGD
driver.setBackgroundColor = NCURSES_SetBackgroundColor;
#endif
#ifdef HAVE_RESIZETERM
driver.notifyResizeScreen = NCURSES_NotifyResizeScreen;
#endif /* HAVE_RESIZETERM */
driver.checkForKeystroke = NCURSES_CheckForKeystroke;
driver.getKeystroke = NCURSES_GetKeystroke;
driver.refresh = NCURSES_Refresh;
}
void NCURSES_Init()
{
char terminal_type[80];
PROFILE_GetWineIniString("console", "TerminalType",
"xterm", terminal_type, 79);
ncurses_screen = newterm(terminal_type, driver.console_out,
driver.console_in);
set_term(ncurses_screen);
start_color();
raw();
noecho();
nonl();
intrflush(stdscr, FALSE);
keypad(stdscr, TRUE);
nodelay(stdscr, TRUE);
}
void NCURSES_Write(char output, int fg, int bg, int attribute)
{
char row, col;
int pair;
if (!fg)
fg = COLOR_WHITE; /* Default */
if (!bg)
bg = COLOR_BLACK; /* Default */
pair = get_color_pair(fg, bg);
if (waddch(stdscr, output | COLOR_PAIR(pair)) == ERR)
{
NCURSES_GetCursorPosition(&row, &col);
FIXME("NCURSES: waddch() failed at %d, %d.\n", row, col);
}
}
void NCURSES_Close()
{
endwin();
}
void NCURSES_GetKeystroke(char *scan, char *ascii)
{
while (!NCURSES_CheckForKeystroke(scan, ascii))
{} /* Wait until keystroke is detected */
/* When it is detected, we will already have the right value
in scan and ascii, but we need to take this keystroke
out of the buffer. */
wgetch(stdscr);
}
int NCURSES_CheckForKeystroke(char *scan, char *ascii)
{
/* We don't currently support scan codes here */
/* FIXME */
int temp;
temp = wgetch(stdscr);
if (temp == ERR)
{
return FALSE;
}
else
{
ungetch(temp); /* Keystroke not removed from buffer */
*ascii = (char) temp;
return TRUE;
}
}
void NCURSES_MoveCursor(char row, char col)
{
if (wmove(stdscr, row, col) == ERR)
FIXME("NCURSES: wmove() failed to %d, %d.\n", row, col);
}
void NCURSES_GetCursorPosition(char *row, char *col)
{
int trow, tcol;
getyx(stdscr, trow, tcol); /* MACRO, no need to pass pointer */
*row = (char) trow;
*col = (char) tcol;
}
void NCURSES_GetCharacterAtCursor(char *ch, int *fg_color, int
*bg_color, int *attribute)
{
/* If any of the pointers are NULL, ignore them */
/* We will eventually have to convert the color data */
if (ch)
*ch = (char) winch(stdscr);
if (fg_color)
*fg_color = WINE_WHITE;
if (bg_color)
*bg_color = WINE_BLACK;
if (attribute)
*attribute = 0;
}
void NCURSES_Refresh()
{
wrefresh(stdscr);
}
void NCURSES_ClearScreen()
{
werase(stdscr);
}
int NCURSES_AllocColor(int color)
{
/* Currently support only internal colors */
switch (color)
{
case WINE_BLACK: return COLOR_BLACK;
case WINE_WHITE: return COLOR_WHITE;
case WINE_RED: return COLOR_RED;
case WINE_GREEN: return COLOR_GREEN;
case WINE_YELLOW: return COLOR_YELLOW;
case WINE_BLUE: return COLOR_BLUE;
case WINE_MAGENTA: return COLOR_MAGENTA;
case WINE_CYAN: return COLOR_CYAN;
}
FIXME("Unable to allocate color %d (%s)\n", color,
color_names[color]);
/* Don't allocate a color... yet */
return 0;
}
void NCURSES_SetBackgroundColor(int fg, int bg)
{
int pair;
pair = get_color_pair(fg, bg);
wbkgd(stdscr, COLOR_PAIR(pair));
}
#ifdef HAVE_GETBKGD
void NCURSES_GetBackgroundColor(int *fg, int *bg)
{
chtype background;
short pair, sfg, sbg;
background = getbkgd(stdscr);
pair = (!A_CHARTEXT & background);
pair_content(pair, &sfg, &sbg);
*fg = sfg;
*bg = sbg;
}
#endif /* HAVE_GETBKGD */
#ifdef HAVE_RESIZETERM
void NCURSES_NotifyResizeScreen(int x, int y)
{
/* Note: This function gets called *after* another driver in the chain
calls ResizeScreen(). It is meant to resize the ncurses internal
data structures to know about the new window dimensions. */
TRACE("Terminal resized to y: %d, x: %d\n", y, x);
resizeterm(y, x);
}
#endif /* HAVE_RESIZETERM */
static int get_color_pair(int fg_color, int bg_color)
{
/* ncurses internally uses "color pairs" in addition to the "pallet" */
/* This isn't the best way to do this. Or even close */
static int current = 0;
static int fg[255]; /* 16 x 16 is enough */
static int bg[255];
int x;
/* The first pair is hardwired into ncurses */
fg[0] = COLOR_WHITE;
bg[0] = COLOR_BLACK;
for (x = 0; x <= current; x++)
{
if ((fg_color == fg[x]) && (bg_color == bg[x]))
{
TRACE("Color pair: already allocated\n");
return x;
}
}
/* Need to allocate new color */
current++;
fg[current] = fg_color;
bg[current] = bg_color;
TRACE("Color pair: allocated.\n");
return init_pair(current, fg_color, bg_color);
}
#endif /* WINE_NCURSES */

View File

@ -1,57 +0,0 @@
/*
* Copyright 1999 - Joseph Pranevich
*
* This is the console driver for TTY-based consoles, i.e. consoles
* without cursor placement, etc. It's also a pretty decent starting
* point for other drivers.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* When creating new drivers, you need to assign all the functions that
that driver supports into the driver struct. If it is a supplementary
driver, it should make sure to perserve the old values. */
#include "config.h"
#include <stdio.h>
#include "console.h"
#include "windef.h"
void TTY_Start()
{
/* This should be the root driver so we can ignore anything
already in the struct. */
driver.norefresh = FALSE;
driver.write = TTY_Write;
driver.getKeystroke = TTY_GetKeystroke;
}
void TTY_Write(char output, int fg, int bg, int attribute)
{
/* We can discard all extended information. */
fprintf(driver.console_out, "%c", output);
}
void TTY_GetKeystroke(char *scan, char *ch)
{
/* All we have are character input things, nothing for extended */
/* This is just the TTY driver, after all. We'll cope. */
*ch = fgetc(driver.console_in);
}

View File

@ -1,188 +0,0 @@
/*
* Copyright 1999 - Joseph Pranevich
*
* This "driver" is designed to go on top of an existing driver
* to provide support for features only present if using an
* xterm or compatible program for your console output.
* Currently, it supports resizing and separating debug messages from
* program output.
* It does not currently support changing the title bar.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "config.h"
#include "wine/port.h"
#include <stdlib.h>
#include <stdio.h>
#include <signal.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <unistd.h>
#include <termios.h>
#ifdef HAVE_LIBUTIL_H
# include <libutil.h>
#endif
#ifdef HAVE_PTY_H
# include <pty.h>
#endif
#include "console.h"
#include "options.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(console);
char console_xterm_prog[80];
static BOOL wine_create_console(FILE **master, FILE **slave, pid_t *pid);
/* The console -- I chose to keep the master and slave
* (UNIX) file descriptors around in case they are needed for
* ioctls later. The pid is needed to destroy the xterm on close
*/
typedef struct _XTERM_CONSOLE {
FILE *master; /* xterm side of pty */
FILE *slave; /* wine side of pty */
pid_t pid; /* xterm's pid, -1 if no xterm */
} XTERM_CONSOLE;
static XTERM_CONSOLE xterm_console;
CONSOLE_device chain;
FILE *old_in, *old_out;
void XTERM_Start(void)
{
/* Here, this is a supplementary driver so we should remember to call
the chain. */
chain.init = driver.init;
driver.init = XTERM_Init;
chain.close = driver.close;
driver.close = XTERM_Close;
chain.resizeScreen = driver.resizeScreen;
driver.resizeScreen = XTERM_ResizeScreen;
/* Read in driver configuration */
PROFILE_GetWineIniString("console", "XtermProg",
"xterm", console_xterm_prog, 79);
}
void XTERM_Init()
{
wine_create_console(&xterm_console.master, &xterm_console.slave,
&xterm_console.pid);
old_in = driver.console_in;
driver.console_in = xterm_console.slave;
old_out = driver.console_out;
driver.console_out = xterm_console.slave;
/* Then call the chain... */
if (chain.init)
chain.init();
}
void XTERM_Close()
{
/* Call the chain first... */
if (chain.close)
chain.close();
driver.console_in = old_in;
driver.console_out = old_out;
/* make sure a xterm exists to kill */
if (xterm_console.pid != -1) {
kill(xterm_console.pid, SIGTERM);
}
}
void XTERM_ResizeScreen(int x, int y)
{
char temp[100];
/* Call the chain first, there shoudln't be any... */
if (chain.resizeScreen)
chain.resizeScreen(x, y);
sprintf(temp, "\x1b[8;%d;%dt", y, x);
CONSOLE_WriteRawString(temp);
CONSOLE_NotifyResizeScreen(x, y);
}
static BOOL wine_create_console(FILE **master, FILE **slave, pid_t *pid)
{
/* There is definately a bug in this routine that causes a lot
of garbage to be written to the screen, but I can't find it...
*/
struct termios term;
char buf[1024];
char c = '\0';
int status = 0;
int i;
int tmaster, tslave;
char xterm_resolution[10];
sprintf(xterm_resolution, "%dx%d", driver.x_res,
driver.y_res);
if (tcgetattr(0, &term) < 0) return FALSE;
term.c_lflag |= ICANON;
term.c_lflag &= ~ECHO;
if (openpty(&tmaster, &tslave, NULL, &term, NULL) < 0)
return FALSE;
*master = fdopen(tmaster, "r+");
*slave = fdopen(tslave, "r+");
if ((*pid=fork()) == 0) {
tcsetattr(fileno(*slave), TCSADRAIN, &term);
sprintf(buf, "-Sxx%d", fileno(*master));
execlp(console_xterm_prog, console_xterm_prog, buf, "-fg",
"white", "-bg", "black", "-g",
xterm_resolution, NULL);
ERR("error creating xterm (file not found?)\n");
exit(1);
}
/* most xterms like to print their window ID when used with -S;
* read it and continue before the user has a chance...
* NOTE: this is the reason we started xterm with ECHO off,
* we'll turn it back on below
*/
for (i=0; c!='\n'; (status=fread(&c, 1, 1, *slave)), i++) {
if (status == -1 && c == '\0') {
/* wait for xterm to be created */
usleep(100);
}
if (i > 10000) {
WARN("can't read xterm WID\n");
kill(*pid, SIGKILL);
return FALSE;
}
}
term.c_lflag |= ECHO;
tcsetattr(fileno(*master), TCSADRAIN, &term);
return TRUE;
}

View File

@ -4,7 +4,6 @@ SRCDIR = @srcdir@
VPATH = @srcdir@
MODULE = winedos.dll
IMPORTS = user32.dll kernel32.dll ntdll.dll
EXTRALIBS = @CURSESLIBS@ @UTILLIBS@
C_SRCS = \
dosaspi.c \
@ -26,15 +25,6 @@ C_SRCS = \
vga.c \
xms.c
EXTRA_OBJS = \
$(TOPOBJDIR)/console/console.o
SUBDIRS = \
$(TOPOBJDIR)/console
@MAKE_DLL_RULES@
$(EXTRA_OBJS): dummy
@cd `dirname $@` && $(MAKE) `basename $@`
### Dependencies:

View File

@ -26,7 +26,6 @@
#include "miscemu.h"
#include "vga.h"
#include "wine/debug.h"
#include "console.h"
#include "dosexe.h"
WINE_DEFAULT_DEBUG_CHANNEL(int);

View File

@ -31,7 +31,6 @@
#include "dosexe.h"
#include "miscemu.h"
#include "msdos.h"
#include "console.h"
#include "file.h"
#include "wine/debug.h"

View File

@ -22,7 +22,6 @@
#include "winnt.h"
#include "console.h"
#include "miscemu.h"
#include "dosexe.h"

View File

@ -1,170 +0,0 @@
/*
* Include file for definitions pertaining to Wine's text-console
* interface.
*
* Copyright 1998 - Joseph Pranevich
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __WINE_CONSOLE_H
#define __WINE_CONSOLE_H
#ifndef __WINE_CONFIG_H
# error You must include config.h to use this header
#endif
#include <stdio.h>
/* Can we compile with curses/ncurses? */
#if ( (defined(HAVE_LIBNCURSES) || defined(HAVE_LIBCURSES)) && \
(defined(HAVE_CURSES_H) || defined(HAVE_NCURSES_H)) \
)
# define WINE_NCURSES
#else
# undef WINE_NCURSES
#endif
#define CONSOLE_DEFAULT_DRIVER "tty"
typedef struct CONSOLE_DRIVER
{
void (*init)(void);
void (*close)(void);
void (*write)(char, int, int, int);
void (*moveCursor)(char, char);
void (*getCursorPosition)(char *, char *);
void (*getCharacterAtCursor)(char *, int *, int *, int *);
void (*clearScreen)(void);
/* Color-control functions */
int (*allocColor)(int color);
void (*setBackgroundColor)(int fg, int bg);
void (*getBackgroundColor)(int *fg, int *bg);
/* Keyboard Functions */
int (*checkForKeystroke)(char *, char *);
void (*getKeystroke)(char *, char *);
/* Windowing Functions */
void (*resizeScreen)(int, int);
void (*notifyResizeScreen)(int, int); /* May be rethought later... */
/* Accelerator Functions (Screen) */
void (*clearWindow)(char, char, char, char, int, int);
void (*scrollUpWindow)(char, char, char, char, char, int, int);
void (*scrollDownWindow)(char, char, char, char, char, int, int);
/* Accelerator Functions (Keyboard) */
char (*getCharacter)(void);
/* Other functions */
void (*refresh)(void);
/* Other data */
int norefresh;
FILE *console_out;
FILE *console_in;
int x_res;
int y_res;
} CONSOLE_device;
extern CONSOLE_device driver; /* Global driver struct */
/* Generic defines */
void CONSOLE_Close(void);
void CONSOLE_Write(char out, int fg_color, int bg_color, int attribute);
void CONSOLE_MoveCursor(char row, char col);
void CONSOLE_ClearWindow(char, char, char, char, int, int);
void CONSOLE_ScrollUpWindow(char, char, char, char, char, int, int);
void CONSOLE_ScrollDownWindow(char, char, char, char, char, int, int);
int CONSOLE_CheckForKeystroke(char *, char*);
void CONSOLE_GetKeystroke(char *, char *);
void CONSOLE_GetCursorPosition(char *, char *);
void CONSOLE_GetCharacterAtCursor(char *, int *, int *, int *);
void CONSOLE_Refresh(void);
void CONSOLE_SetRefresh(int);
int CONSOLE_GetRefresh(void);
void CONSOLE_ClearScreen(void);
char CONSOLE_GetCharacter(void);
void CONSOLE_ResizeScreen(int, int);
void CONSOLE_NotifyResizeScreen(int, int);
void CONSOLE_WriteRawString(char *);
int CONSOLE_AllocColor(int);
void CONSOLE_SetBackgroundColor(int fg, int bg);
void CONSOLE_GetBackgroundColor(int *fg, int *bg);
/* Generic Defines */
void GENERIC_Start(void);
void GENERIC_ClearWindow(char, char, char, char, int, int);
void GENERIC_ScrollUpWindow(char, char, char, char, char, int, int);
void GENERIC_ScrollDownWindow(char, char, char, char, char, int, int);
char GENERIC_GetCharacter(void);
/* TTY specific defines */
void TTY_Write(char out, int fg_color, int bg_color, int attribute);
void TTY_Start(void);
void TTY_GetKeystroke(char *, char *);
#ifdef WINE_NCURSES
/* ncurses defines */
void NCURSES_Write(char out, int fg_color, int bg_color, int attribute);
void NCURSES_Start(void);
void NCURSES_Init(void);
void NCURSES_Close(void);
int NCURSES_CheckForKeystroke(char *, char *);
void NCURSES_GetKeystroke(char *, char *);
void NCURSES_MoveCursor(char ,char);
void NCURSES_GetCursorPosition(char *, char *);
void NCURSES_GetCharacterAtCursor(char *, int *, int *, int *);
void NCURSES_Refresh(void);
void NCURSES_ClearScreen(void);
void NCURSES_NotifyResizeScreen(int x, int y);
int NCURSES_AllocColor(int);
void NCURSES_SetBackgroundColor(int fg, int bg);
void NCURSES_GetBackgroundColor(int *fg, int *bg);
#endif /* WINE_NCURSES */
/* Xterm specific defines */
void XTERM_Start(void);
void XTERM_Close(void);
void XTERM_Init(void);
void XTERM_ResizeScreen(int x, int y);
/* Color defines */
/* These will eventually be hex triples for dynamic allocation */
/* Triplets added by A.C. and commented out until the support */
/* code can be written into the console routines. */
#define WINE_BLACK 1 /* 0x000000 */
#define WINE_BLUE 2 /* 0x0000ff */
#define WINE_GREEN 3 /* 0x008000 */
#define WINE_CYAN 4 /* 0x00eeee */
#define WINE_MAGENTA 5 /* 0xcd00cd */
#define WINE_BROWN 6 /* 0xcd3333 */
#define WINE_RED 7 /* 0xff0000 */
#define WINE_LIGHT_GRAY 8 /* 0xc0c0c0 */
#define WINE_DARK_GRAY 9 /* 0x808080 */
#define WINE_LIGHT_BLUE 10 /* 0x98f5ff */
#define WINE_LIGHT_GREEN 11 /* 0x00ff00 */
#define WINE_LIGHT_RED 12 /* 0xee6363 */
#define WINE_LIGHT_MAGENTA 13 /* 0xff00ff */
#define WINE_LIGHT_CYAN 14 /* 0x00ffff */
#define WINE_YELLOW 15 /* 0xffff00 */
#define WINE_WHITE 16 /* 0xffffff */
#endif /* CONSOLE_H */