2002-12-14 00:37:06 +01:00
|
|
|
/*
|
|
|
|
* a GUI application for displaying a console
|
|
|
|
* (N)Curses back end
|
|
|
|
*
|
|
|
|
* Copyright 2002 Eric Pouech
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Known issues & FIXME:
|
|
|
|
* - not all key mapping functions have been written
|
|
|
|
* - allow dyn loading of curses library (extreme care should be taken for
|
|
|
|
* functions which can be implemented as macros)
|
2003-02-14 20:23:36 +01:00
|
|
|
* - finish buffer scrolling (mainly, need to decide of a nice way for
|
|
|
|
* requesting the UP/DOWN operations
|
2003-06-04 22:14:47 +02:00
|
|
|
* - Resizing (unix) terminal does not change (Win32) console size.
|
|
|
|
* - Initial console size comes from registry and not from terminal size.
|
2002-12-14 00:37:06 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
2003-08-20 06:19:01 +02:00
|
|
|
#include "wine/port.h"
|
2002-12-14 00:37:06 +01:00
|
|
|
|
|
|
|
#include <stdio.h>
|
2003-09-07 07:08:14 +02:00
|
|
|
#include <stdarg.h>
|
2002-12-14 00:37:06 +01:00
|
|
|
#include <stdlib.h>
|
|
|
|
#ifdef HAVE_CURSES_H
|
|
|
|
#include <curses.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_NCURSES_H
|
|
|
|
#include <ncurses.h>
|
|
|
|
#endif
|
2003-04-04 01:57:39 +02:00
|
|
|
#undef KEY_EVENT /* avoid redefinition warning */
|
2003-09-24 00:54:57 +02:00
|
|
|
#ifdef HAVE_UNISTD_H
|
2002-12-14 00:37:06 +01:00
|
|
|
#include <unistd.h>
|
2003-09-24 00:54:57 +02:00
|
|
|
#endif
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <windef.h>
|
2003-08-20 20:22:31 +02:00
|
|
|
#include <winbase.h>
|
2002-12-14 00:37:06 +01:00
|
|
|
#include <winnls.h>
|
|
|
|
#include "winecon_private.h"
|
|
|
|
|
2003-08-20 06:19:01 +02:00
|
|
|
#include "wine/library.h"
|
2002-12-14 00:37:06 +01:00
|
|
|
#include "wine/server.h"
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
2003-10-10 02:01:21 +02:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(curses);
|
2002-12-14 00:37:06 +01:00
|
|
|
|
|
|
|
#define PRIVATE(data) ((struct inner_data_curse*)((data)->private))
|
|
|
|
|
|
|
|
#if defined(HAVE_CURSES_H) || defined(HAVE_NCURSES_H)
|
|
|
|
|
2003-08-20 06:19:01 +02:00
|
|
|
#ifdef HAVE_NCURSES_H
|
|
|
|
#define CURSES_NAME "ncurses"
|
|
|
|
#else
|
|
|
|
#define CURSES_NAME "curses"
|
|
|
|
#endif
|
|
|
|
|
2002-12-14 00:37:06 +01:00
|
|
|
struct inner_data_curse
|
|
|
|
{
|
|
|
|
mmask_t initial_mouse_mask;
|
|
|
|
HANDLE hInput;
|
|
|
|
WINDOW* pad;
|
|
|
|
chtype* line;
|
2003-02-14 20:23:36 +01:00
|
|
|
int allow_scroll;
|
2002-12-14 00:37:06 +01:00
|
|
|
};
|
|
|
|
|
2003-06-04 22:14:47 +02:00
|
|
|
|
2003-08-20 06:19:01 +02:00
|
|
|
static void *nc_handle = NULL;
|
|
|
|
|
|
|
|
#define MAKE_FUNCPTR(f) static typeof(f) * p_##f;
|
|
|
|
|
|
|
|
MAKE_FUNCPTR(curs_set)
|
|
|
|
MAKE_FUNCPTR(delwin)
|
|
|
|
MAKE_FUNCPTR(endwin)
|
|
|
|
MAKE_FUNCPTR(getmouse)
|
|
|
|
MAKE_FUNCPTR(has_colors)
|
|
|
|
MAKE_FUNCPTR(init_pair)
|
|
|
|
#ifndef initscr
|
|
|
|
MAKE_FUNCPTR(initscr)
|
|
|
|
#endif
|
|
|
|
#ifndef intrflush
|
|
|
|
MAKE_FUNCPTR(intrflush)
|
|
|
|
#endif
|
|
|
|
MAKE_FUNCPTR(keypad)
|
|
|
|
MAKE_FUNCPTR(mouseinterval)
|
|
|
|
MAKE_FUNCPTR(mousemask)
|
|
|
|
MAKE_FUNCPTR(newpad)
|
|
|
|
#ifndef nodelay
|
|
|
|
MAKE_FUNCPTR(nodelay)
|
|
|
|
#endif
|
|
|
|
#ifndef noecho
|
|
|
|
MAKE_FUNCPTR(noecho)
|
|
|
|
#endif
|
|
|
|
MAKE_FUNCPTR(prefresh)
|
|
|
|
MAKE_FUNCPTR(raw)
|
|
|
|
MAKE_FUNCPTR(start_color)
|
|
|
|
MAKE_FUNCPTR(stdscr)
|
|
|
|
MAKE_FUNCPTR(waddchnstr)
|
|
|
|
MAKE_FUNCPTR(wmove)
|
|
|
|
MAKE_FUNCPTR(wgetch)
|
|
|
|
|
|
|
|
#undef MAKE_FUNCPTR
|
|
|
|
|
|
|
|
/**********************************************************************/
|
|
|
|
|
|
|
|
static BOOL WCCURSES_bind_libcurses(void)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_NCURSES_H
|
|
|
|
static const char *ncname = SONAME_LIBNCURSES;
|
|
|
|
#else
|
|
|
|
static const char *ncname = SONAME_LIBCURSES;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
nc_handle = wine_dlopen(ncname, RTLD_NOW, NULL, 0);
|
|
|
|
if(!nc_handle)
|
|
|
|
{
|
|
|
|
WINE_MESSAGE("Wine cannot find the " CURSES_NAME " library (%s).\n",
|
|
|
|
ncname);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define LOAD_FUNCPTR(f) \
|
|
|
|
if((p_##f = wine_dlsym(nc_handle, #f, NULL, 0)) == NULL) \
|
|
|
|
{ \
|
|
|
|
WINE_WARN("Can't find symbol %s\n", #f); \
|
|
|
|
goto sym_not_found; \
|
|
|
|
}
|
|
|
|
|
|
|
|
LOAD_FUNCPTR(curs_set)
|
|
|
|
LOAD_FUNCPTR(delwin)
|
|
|
|
LOAD_FUNCPTR(endwin)
|
|
|
|
LOAD_FUNCPTR(getmouse)
|
|
|
|
LOAD_FUNCPTR(has_colors)
|
|
|
|
LOAD_FUNCPTR(init_pair)
|
|
|
|
#ifndef initscr
|
|
|
|
LOAD_FUNCPTR(initscr)
|
|
|
|
#endif
|
|
|
|
#ifndef intrflush
|
|
|
|
LOAD_FUNCPTR(intrflush)
|
|
|
|
#endif
|
|
|
|
LOAD_FUNCPTR(keypad)
|
|
|
|
LOAD_FUNCPTR(mouseinterval)
|
|
|
|
LOAD_FUNCPTR(mousemask)
|
|
|
|
LOAD_FUNCPTR(newpad)
|
|
|
|
#ifndef nodelay
|
|
|
|
LOAD_FUNCPTR(nodelay)
|
|
|
|
#endif
|
|
|
|
#ifndef noecho
|
|
|
|
LOAD_FUNCPTR(noecho)
|
|
|
|
#endif
|
|
|
|
LOAD_FUNCPTR(prefresh)
|
|
|
|
LOAD_FUNCPTR(raw)
|
|
|
|
LOAD_FUNCPTR(start_color)
|
|
|
|
LOAD_FUNCPTR(stdscr)
|
|
|
|
LOAD_FUNCPTR(waddchnstr)
|
|
|
|
LOAD_FUNCPTR(wmove)
|
|
|
|
LOAD_FUNCPTR(wgetch)
|
|
|
|
|
|
|
|
#undef LOAD_FUNCPTR
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
sym_not_found:
|
|
|
|
WINE_MESSAGE(
|
|
|
|
"Wine cannot find certain functions that it needs inside the "
|
|
|
|
CURSES_NAME "\nlibrary. To enable Wine to use " CURSES_NAME
|
|
|
|
" please upgrade your " CURSES_NAME "\nlibraries\n");
|
|
|
|
wine_dlclose(nc_handle, NULL, 0);
|
|
|
|
nc_handle = NULL;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define curs_set p_curs_set
|
|
|
|
#define delwin p_delwin
|
|
|
|
#define endwin p_endwin
|
|
|
|
#define getmouse p_getmouse
|
|
|
|
#define has_colors p_has_colors
|
|
|
|
#define init_pair p_init_pair
|
|
|
|
#ifndef initscr
|
|
|
|
#define initscr p_initscr
|
|
|
|
#endif
|
|
|
|
#ifndef intrflush
|
|
|
|
#define intrflush p_intrflush
|
|
|
|
#endif
|
|
|
|
#define keypad p_keypad
|
|
|
|
#define mouseinterval p_mouseinterval
|
|
|
|
#define mousemask p_mousemask
|
|
|
|
#define newpad p_newpad
|
|
|
|
#ifndef nodelay
|
|
|
|
#define nodelay p_nodelay
|
|
|
|
#endif
|
|
|
|
#ifndef noecho
|
|
|
|
#define noecho p_noecho
|
|
|
|
#endif
|
|
|
|
#define prefresh p_prefresh
|
|
|
|
#define raw p_raw
|
|
|
|
#define start_color p_start_color
|
|
|
|
#define stdscr (*p_stdscr)
|
|
|
|
#define waddchnstr p_waddchnstr
|
|
|
|
#define wmove p_wmove
|
|
|
|
#define wgetch p_wgetch
|
|
|
|
|
2002-12-14 00:37:06 +01:00
|
|
|
/******************************************************************
|
2002-12-23 02:35:27 +01:00
|
|
|
* WCCURSES_ResizeScreenBuffer
|
2002-12-14 00:37:06 +01:00
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
2002-12-23 02:35:27 +01:00
|
|
|
static void WCCURSES_ResizeScreenBuffer(struct inner_data* data)
|
2002-12-14 00:37:06 +01:00
|
|
|
{
|
|
|
|
/* reallocate a new pad. next event would redraw the whole pad */
|
|
|
|
if (PRIVATE(data)->pad) delwin(PRIVATE(data)->pad);
|
|
|
|
PRIVATE(data)->pad = newpad(data->curcfg.sb_height, data->curcfg.sb_width);
|
|
|
|
if (!PRIVATE(data)->pad)
|
|
|
|
WINE_FIXME("Cannot create pad\n");
|
2003-10-15 23:01:05 +02:00
|
|
|
if (PRIVATE(data)->line)
|
|
|
|
PRIVATE(data)->line = HeapReAlloc(GetProcessHeap(), 0, PRIVATE(data)->line,
|
|
|
|
sizeof(chtype) * data->curcfg.sb_width);
|
|
|
|
else
|
|
|
|
PRIVATE(data)->line = HeapAlloc(GetProcessHeap(), 0,
|
2002-12-14 00:37:06 +01:00
|
|
|
sizeof(chtype) * data->curcfg.sb_width);
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
2002-12-23 02:35:27 +01:00
|
|
|
* WCCURSES_PosCursor
|
2002-12-14 00:37:06 +01:00
|
|
|
*
|
|
|
|
* Set a new position for the cursor (and refresh any modified part of our pad)
|
|
|
|
*/
|
2002-12-23 02:35:27 +01:00
|
|
|
static void WCCURSES_PosCursor(const struct inner_data* data)
|
2002-12-14 00:37:06 +01:00
|
|
|
{
|
2003-06-04 22:14:47 +02:00
|
|
|
int scr_width;
|
|
|
|
int scr_height;
|
|
|
|
|
2003-01-07 20:39:25 +01:00
|
|
|
if (data->curcfg.cursor_visible &&
|
|
|
|
data->cursor.Y >= data->curcfg.win_pos.Y &&
|
|
|
|
data->cursor.Y < data->curcfg.win_pos.Y + data->curcfg.win_height &&
|
|
|
|
data->cursor.X >= data->curcfg.win_pos.X &&
|
|
|
|
data->cursor.X < data->curcfg.win_pos.X + data->curcfg.win_width)
|
|
|
|
{
|
|
|
|
if (curs_set(2) == ERR) curs_set(1);
|
|
|
|
wmove(PRIVATE(data)->pad, data->cursor.Y, data->cursor.X);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
curs_set(0);
|
|
|
|
}
|
2003-09-22 21:31:32 +02:00
|
|
|
getmaxyx(stdscr, scr_height, scr_width);
|
2003-01-07 20:39:25 +01:00
|
|
|
prefresh(PRIVATE(data)->pad,
|
|
|
|
data->curcfg.win_pos.Y, data->curcfg.win_pos.X,
|
2003-09-22 21:31:32 +02:00
|
|
|
0, 0,
|
|
|
|
min(scr_height, data->curcfg.win_height) - 1,
|
|
|
|
min(scr_width, data->curcfg.win_width) - 1);
|
2002-12-14 00:37:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
2002-12-23 02:35:27 +01:00
|
|
|
* WCCURSES_ShapeCursor
|
2002-12-14 00:37:06 +01:00
|
|
|
*
|
|
|
|
* Sets a new shape for the cursor
|
|
|
|
*/
|
2004-11-29 19:00:10 +01:00
|
|
|
static void WCCURSES_ShapeCursor(struct inner_data* data, int size, int vis, BOOL force)
|
2002-12-14 00:37:06 +01:00
|
|
|
{
|
2003-01-07 20:39:25 +01:00
|
|
|
/* we can't do much about the size... */
|
|
|
|
data->curcfg.cursor_size = size;
|
|
|
|
data->curcfg.cursor_visible = vis ? TRUE : FALSE;
|
|
|
|
WCCURSES_PosCursor(data);
|
2002-12-14 00:37:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
2002-12-23 02:35:27 +01:00
|
|
|
* WCCURSES_ComputePositions
|
2002-12-14 00:37:06 +01:00
|
|
|
*
|
|
|
|
* Recomputes all the components (mainly scroll bars) positions
|
|
|
|
*/
|
2004-11-29 19:00:10 +01:00
|
|
|
static void WCCURSES_ComputePositions(struct inner_data* data)
|
2002-12-14 00:37:06 +01:00
|
|
|
{
|
2003-09-22 21:31:32 +02:00
|
|
|
int x, y;
|
|
|
|
|
|
|
|
getmaxyx(stdscr, y, x);
|
|
|
|
if ((data->curcfg.win_height && y < data->curcfg.win_height) ||
|
|
|
|
(data->curcfg.win_width && x < data->curcfg.win_width))
|
|
|
|
{
|
|
|
|
SMALL_RECT pos;
|
|
|
|
|
|
|
|
WINE_WARN("Window too large (%dx%d), adjusting to curses' size (%dx%d)\n",
|
|
|
|
data->curcfg.win_width, data->curcfg.win_height, x, y);
|
|
|
|
pos.Left = pos.Top = 0;
|
|
|
|
pos.Right = x - 1; pos.Bottom = y - 1;
|
|
|
|
SetConsoleWindowInfo(data->hConOut, FALSE, &pos);
|
|
|
|
return; /* we'll get called again upon event for new window size */
|
|
|
|
}
|
2002-12-23 02:35:27 +01:00
|
|
|
if (PRIVATE(data)->pad) WCCURSES_PosCursor(data);
|
2002-12-14 00:37:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
2002-12-23 02:35:27 +01:00
|
|
|
* WCCURSES_SetTitle
|
2002-12-14 00:37:06 +01:00
|
|
|
*
|
|
|
|
* Sets the title to the wine console
|
|
|
|
*/
|
2002-12-23 02:35:27 +01:00
|
|
|
static void WCCURSES_SetTitle(const struct inner_data* data)
|
2002-12-14 00:37:06 +01:00
|
|
|
{
|
|
|
|
WCHAR wbuf[256];
|
|
|
|
|
|
|
|
if (WINECON_GetConsoleTitle(data->hConIn, wbuf, sizeof(wbuf)/sizeof(WCHAR)))
|
|
|
|
{
|
|
|
|
char buffer[256];
|
|
|
|
|
|
|
|
WideCharToMultiByte(CP_ACP, 0, wbuf, -1, buffer, sizeof(buffer),
|
|
|
|
NULL, NULL);
|
|
|
|
fputs("\033]2;", stdout);
|
|
|
|
fputs(buffer, stdout);
|
|
|
|
fputc('\a', stdout);
|
|
|
|
fflush(stdout);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
2003-06-04 22:14:47 +02:00
|
|
|
* WCCURSES_Refresh
|
2002-12-14 00:37:06 +01:00
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
2002-12-23 02:35:27 +01:00
|
|
|
static void WCCURSES_Refresh(const struct inner_data* data, int tp, int bm)
|
2002-12-14 00:37:06 +01:00
|
|
|
{
|
2004-09-22 04:46:38 +02:00
|
|
|
unsigned int x;
|
|
|
|
int y;
|
2002-12-14 00:37:06 +01:00
|
|
|
CHAR_INFO* cell;
|
2002-12-23 02:35:27 +01:00
|
|
|
DWORD attr;
|
|
|
|
char ch;
|
2002-12-14 00:37:06 +01:00
|
|
|
|
|
|
|
for (y = tp; y <= bm; y++)
|
|
|
|
{
|
|
|
|
cell = &data->cells[y * data->curcfg.sb_width];
|
|
|
|
for (x = 0; x < data->curcfg.sb_width; x++)
|
|
|
|
{
|
2002-12-23 02:35:27 +01:00
|
|
|
WideCharToMultiByte(CP_ACP, 0, &cell[x].Char.UnicodeChar, 1,
|
|
|
|
&ch, 1, NULL, NULL);
|
2003-02-14 20:23:36 +01:00
|
|
|
attr = ((BYTE)ch < 32 || (BYTE)ch > 127) ? 32 : (BYTE)ch;
|
|
|
|
|
2002-12-23 02:35:27 +01:00
|
|
|
if (cell[x].Attributes & FOREGROUND_RED) attr |= COLOR_PAIR(COLOR_RED);
|
|
|
|
if (cell[x].Attributes & FOREGROUND_BLUE) attr |= COLOR_PAIR(COLOR_BLUE);
|
|
|
|
if (cell[x].Attributes & FOREGROUND_GREEN) attr |= COLOR_PAIR(COLOR_GREEN);
|
|
|
|
if (cell[x].Attributes & BACKGROUND_RED) attr |= COLOR_PAIR(COLOR_RED << 3);
|
|
|
|
if (cell[x].Attributes & BACKGROUND_BLUE) attr |= COLOR_PAIR(COLOR_BLUE << 3);
|
|
|
|
if (cell[x].Attributes & BACKGROUND_GREEN) attr |= COLOR_PAIR(COLOR_GREEN << 3);
|
|
|
|
|
|
|
|
if (cell[x].Attributes & FOREGROUND_INTENSITY) attr |= A_BOLD;
|
|
|
|
PRIVATE(data)->line[x] = attr;
|
2002-12-14 00:37:06 +01:00
|
|
|
}
|
|
|
|
mvwaddchnstr(PRIVATE(data)->pad, y, 0, PRIVATE(data)->line, data->curcfg.sb_width);
|
|
|
|
}
|
2003-06-04 22:14:47 +02:00
|
|
|
|
|
|
|
WCCURSES_PosCursor(data);
|
2002-12-14 00:37:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
2002-12-23 02:35:27 +01:00
|
|
|
* WCCURSES_Scroll
|
2002-12-14 00:37:06 +01:00
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
2002-12-23 02:35:27 +01:00
|
|
|
static void WCCURSES_Scroll(struct inner_data* data, int pos, BOOL horz)
|
2002-12-14 00:37:06 +01:00
|
|
|
{
|
|
|
|
if (horz)
|
|
|
|
{
|
|
|
|
data->curcfg.win_pos.X = pos;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
data->curcfg.win_pos.Y = pos;
|
|
|
|
}
|
2003-01-07 20:39:25 +01:00
|
|
|
WCCURSES_PosCursor(data);
|
2002-12-14 00:37:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
2002-12-23 02:35:27 +01:00
|
|
|
* WCCURSES_SetFont
|
2002-12-14 00:37:06 +01:00
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
2002-12-23 02:35:27 +01:00
|
|
|
static void WCCURSES_SetFont(struct inner_data* data, const WCHAR* font,
|
2002-12-14 00:37:06 +01:00
|
|
|
unsigned height, unsigned weight)
|
|
|
|
{
|
|
|
|
/* FIXME: really not much to do ? */
|
|
|
|
}
|
|
|
|
|
2003-02-14 20:23:36 +01:00
|
|
|
/******************************************************************
|
|
|
|
* WCCURSES_ScrollV
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static void WCCURSES_ScrollV(struct inner_data* data, int delta)
|
|
|
|
{
|
|
|
|
int pos = data->curcfg.win_pos.Y;
|
|
|
|
|
|
|
|
pos += delta;
|
|
|
|
if (pos < 0) pos = 0;
|
|
|
|
if (pos > data->curcfg.sb_height - data->curcfg.win_height)
|
|
|
|
pos = data->curcfg.sb_height - data->curcfg.win_height;
|
|
|
|
if (pos != data->curcfg.win_pos.Y)
|
|
|
|
{
|
|
|
|
data->curcfg.win_pos.Y = pos;
|
|
|
|
WCCURSES_PosCursor(data);
|
|
|
|
WINECON_NotifyWindowChange(data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-12-14 00:37:06 +01:00
|
|
|
/* Ascii -> VK, generated by calling VkKeyScanA(i) */
|
|
|
|
static int vkkeyscan_table[256] =
|
|
|
|
{
|
|
|
|
0,0,0,0,0,0,0,0,8,9,0,0,0,13,0,0,0,0,0,19,145,556,0,0,0,0,0,27,0,0,0,
|
|
|
|
0,32,305,478,307,308,309,311,222,313,304,312,443,188,189,190,191,48,
|
|
|
|
49,50,51,52,53,54,55,56,57,442,186,444,187,446,447,306,321,322,323,
|
|
|
|
324,325,326,327,328,329,330,331,332,333,334,335,336,337,338,339,340,
|
|
|
|
341,342,343,344,345,346,219,220,221,310,445,192,65,66,67,68,69,70,71,
|
|
|
|
72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,475,476,477,
|
|
|
|
448,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
|
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
|
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
|
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,400,0,0,0,0,0,0
|
|
|
|
};
|
|
|
|
|
|
|
|
static int mapvkey_0[256] =
|
|
|
|
{
|
|
|
|
0,0,0,0,0,0,0,0,14,15,0,0,0,28,0,0,42,29,56,69,58,0,0,0,0,0,0,1,0,0,
|
|
|
|
0,0,57,73,81,79,71,75,72,77,80,0,0,0,55,82,83,0,11,2,3,4,5,6,7,8,9,
|
|
|
|
10,0,0,0,0,0,0,0,30,48,46,32,18,33,34,35,23,36,37,38,50,49,24,25,16,
|
|
|
|
19,31,20,22,47,17,45,21,44,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,55,78,0,74,
|
|
|
|
0,53,59,60,61,62,63,64,65,66,67,68,87,88,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
|
|
0,0,0,0,0,0,69,70,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
|
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,39,13,51,12,52,53,41,0,0,0,0,0,0,0,0,0,
|
|
|
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,26,43,27,40,76,96,0,0,0,0,0,0,0,0,
|
|
|
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
|
|
|
};
|
|
|
|
|
2003-02-14 20:23:36 +01:00
|
|
|
/******************************************************************
|
|
|
|
* WCCURSES_InitComplexChar
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static inline void WCCURSES_InitComplexChar(INPUT_RECORD* ir, BOOL down, WORD vk, WORD kc, DWORD cks)
|
|
|
|
{
|
|
|
|
ir->EventType = KEY_EVENT;
|
|
|
|
ir->Event.KeyEvent.bKeyDown = down;
|
|
|
|
ir->Event.KeyEvent.wRepeatCount = 1;
|
|
|
|
|
|
|
|
ir->Event.KeyEvent.wVirtualScanCode = vk;
|
|
|
|
ir->Event.KeyEvent.wVirtualKeyCode = kc;
|
|
|
|
ir->Event.KeyEvent.dwControlKeyState = cks;
|
|
|
|
ir->Event.KeyEvent.uChar.UnicodeChar = 0;
|
|
|
|
}
|
|
|
|
|
2002-12-14 00:37:06 +01:00
|
|
|
/******************************************************************
|
2002-12-23 02:35:27 +01:00
|
|
|
* WCCURSES_FillSimpleChar
|
2002-12-14 00:37:06 +01:00
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
2003-02-14 20:23:36 +01:00
|
|
|
static unsigned WCCURSES_FillSimpleChar(INPUT_RECORD* ir, unsigned real_inchar)
|
2002-12-14 00:37:06 +01:00
|
|
|
{
|
2003-02-14 20:23:36 +01:00
|
|
|
unsigned vk;
|
|
|
|
unsigned inchar;
|
|
|
|
unsigned numEvent = 0;
|
|
|
|
DWORD cks = 0;
|
|
|
|
|
|
|
|
switch (real_inchar)
|
|
|
|
{
|
2003-10-09 06:26:29 +02:00
|
|
|
case 9: inchar = real_inchar;
|
|
|
|
real_inchar = 27; /* so that we don't think key is ctrl- something */
|
|
|
|
break;
|
|
|
|
case 10: inchar = '\r';
|
|
|
|
real_inchar = 27; /* Fixme: so that we don't think key is ctrl- something */
|
|
|
|
break;
|
|
|
|
case 127: inchar = '\b';
|
|
|
|
break;
|
2003-02-14 20:23:36 +01:00
|
|
|
case 27:
|
2003-10-09 06:26:29 +02:00
|
|
|
/* we assume that ESC & and the second character are atomically
|
|
|
|
* generated otherwise, we'll have a race here. FIXME: This gives 1 sec. delay
|
|
|
|
* because curses looks for a second character.
|
2003-02-14 20:23:36 +01:00
|
|
|
*/
|
|
|
|
if ((inchar = wgetch(stdscr)) != ERR)
|
|
|
|
{
|
|
|
|
/* we got a alt-something key... */
|
|
|
|
cks = LEFT_ALT_PRESSED;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
inchar = 27;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
inchar = real_inchar;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if ((inchar & ~0xFF) != 0) WINE_FIXME("What a char (%u)\n", inchar);
|
|
|
|
vk = vkkeyscan_table[inchar];
|
|
|
|
if (vk & 0x0100)
|
|
|
|
WCCURSES_InitComplexChar(&ir[numEvent++], 1, 0x2a, 0x10, SHIFT_PRESSED);
|
|
|
|
if ((vk & 0x0200) || (unsigned char)real_inchar <= 26)
|
|
|
|
WCCURSES_InitComplexChar(&ir[numEvent++], 1, 0x1d, 0x11, LEFT_CTRL_PRESSED);
|
|
|
|
if (vk & 0x0400)
|
|
|
|
WCCURSES_InitComplexChar(&ir[numEvent++], 1, 0x38, 0x12, LEFT_ALT_PRESSED);
|
|
|
|
|
|
|
|
ir[numEvent].EventType = KEY_EVENT;
|
|
|
|
ir[numEvent].Event.KeyEvent.bKeyDown = 1;
|
|
|
|
ir[numEvent].Event.KeyEvent.wRepeatCount = 1;
|
|
|
|
ir[numEvent].Event.KeyEvent.dwControlKeyState = cks;
|
|
|
|
if (vk & 0x0100)
|
|
|
|
ir[numEvent].Event.KeyEvent.dwControlKeyState |= SHIFT_PRESSED;
|
|
|
|
if ((vk & 0x0200) || (unsigned char)real_inchar <= 26)
|
|
|
|
ir[numEvent].Event.KeyEvent.dwControlKeyState |= LEFT_CTRL_PRESSED;
|
|
|
|
if (vk & 0x0400)
|
|
|
|
ir[numEvent].Event.KeyEvent.dwControlKeyState |= LEFT_ALT_PRESSED;
|
|
|
|
ir[numEvent].Event.KeyEvent.wVirtualKeyCode = vk;
|
|
|
|
ir[numEvent].Event.KeyEvent.wVirtualScanCode = mapvkey_0[vk & 0x00ff]; /* VirtualKeyCodes to ScanCode */
|
|
|
|
ir[numEvent].Event.KeyEvent.uChar.UnicodeChar = (unsigned char)inchar;
|
|
|
|
|
|
|
|
ir[numEvent + 1] = ir[numEvent];
|
|
|
|
ir[numEvent + 1].Event.KeyEvent.bKeyDown = 0;
|
|
|
|
|
|
|
|
numEvent += 2;
|
|
|
|
|
|
|
|
if (vk & 0x0400)
|
|
|
|
WCCURSES_InitComplexChar(&ir[numEvent++], 0, 0x38, 0x12, LEFT_ALT_PRESSED);
|
|
|
|
if ((vk & 0x0200) || (unsigned char)real_inchar <= 26)
|
|
|
|
WCCURSES_InitComplexChar(&ir[numEvent++], 0, 0x1d, 0x11, 0);
|
|
|
|
if (vk & 0x0100)
|
|
|
|
WCCURSES_InitComplexChar(&ir[numEvent++], 0, 0x2a, 0x10, 0);
|
|
|
|
|
|
|
|
return numEvent;
|
2002-12-14 00:37:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
2002-12-23 02:35:27 +01:00
|
|
|
* WCCURSES_FillComplexChar
|
2002-12-14 00:37:06 +01:00
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
2003-02-14 20:23:36 +01:00
|
|
|
static unsigned WCCURSES_FillComplexChar(INPUT_RECORD* ir, WORD vk, WORD kc, DWORD cks)
|
2002-12-14 00:37:06 +01:00
|
|
|
{
|
2003-02-14 20:23:36 +01:00
|
|
|
WCCURSES_InitComplexChar(&ir[0], 1, vk, kc, ENHANCED_KEY | cks);
|
|
|
|
WCCURSES_InitComplexChar(&ir[1], 0, vk, kc, ENHANCED_KEY | cks);
|
|
|
|
|
|
|
|
return 2;
|
2002-12-14 00:37:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
2002-12-23 02:35:27 +01:00
|
|
|
* WCCURSES_FillMouse
|
2002-12-14 00:37:06 +01:00
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
2002-12-23 02:35:27 +01:00
|
|
|
static unsigned WCCURSES_FillMouse(INPUT_RECORD* ir)
|
2002-12-14 00:37:06 +01:00
|
|
|
{
|
2003-02-14 20:23:36 +01:00
|
|
|
static unsigned bstate /* = 0 */;
|
|
|
|
static COORD pos /* = {0, 0} */;
|
|
|
|
|
|
|
|
MEVENT mevt;
|
|
|
|
|
|
|
|
if (getmouse(&mevt) == ERR)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
WINE_TRACE("[%u]: (%d, %d) %08lx\n",
|
|
|
|
mevt.id, mevt.x, mevt.y, (unsigned long)mevt.bstate);
|
|
|
|
|
|
|
|
/* macros to ease mapping ncurse button numbering to windows's one */
|
2002-12-14 00:37:06 +01:00
|
|
|
#define BTN1_BIT FROM_LEFT_1ST_BUTTON_PRESSED
|
|
|
|
#define BTN2_BIT RIGHTMOST_BUTTON_PRESSED
|
|
|
|
#define BTN3_BIT FROM_LEFT_2ND_BUTTON_PRESSED
|
|
|
|
#define BTN4_BIT 0 /* not done yet */
|
2003-02-14 20:23:36 +01:00
|
|
|
|
|
|
|
if (mevt.bstate & BUTTON1_PRESSED) bstate |= BTN1_BIT;
|
|
|
|
if (mevt.bstate & BUTTON1_RELEASED) bstate &= ~BTN1_BIT;
|
|
|
|
if (mevt.bstate & BUTTON2_PRESSED) bstate |= BTN2_BIT;
|
|
|
|
if (mevt.bstate & BUTTON2_RELEASED) bstate &= ~BTN2_BIT;
|
|
|
|
if (mevt.bstate & BUTTON3_PRESSED) bstate |= BTN3_BIT;
|
|
|
|
if (mevt.bstate & BUTTON3_RELEASED) bstate &= ~BTN3_BIT;
|
|
|
|
|
|
|
|
ir->EventType = MOUSE_EVENT;
|
|
|
|
ir->Event.MouseEvent.dwMousePosition.X = mevt.x;
|
|
|
|
ir->Event.MouseEvent.dwMousePosition.Y = mevt.y;
|
|
|
|
|
|
|
|
ir->Event.MouseEvent.dwButtonState = bstate;
|
|
|
|
|
|
|
|
/* partial conversion */
|
|
|
|
ir->Event.MouseEvent.dwControlKeyState = 0;
|
|
|
|
if (mevt.bstate & BUTTON_SHIFT) ir->Event.MouseEvent.dwControlKeyState |= SHIFT_PRESSED;
|
|
|
|
/* choose to map to left ctrl... could use both ? */
|
|
|
|
if (mevt.bstate & BUTTON_CTRL) ir->Event.MouseEvent.dwControlKeyState |= LEFT_CTRL_PRESSED;
|
|
|
|
/* choose to map to left alt... could use both ? */
|
|
|
|
if (mevt.bstate & BUTTON_ALT) ir->Event.MouseEvent.dwControlKeyState |= LEFT_ALT_PRESSED;
|
|
|
|
/* FIXME: unsupported yet flags: CAPSLOCK_ON, ENHANCED_KEY (??), NUMLOCK_ON, SCROLLLOCK_ON
|
|
|
|
* could be reported from the key events...
|
|
|
|
*/
|
|
|
|
|
|
|
|
ir->Event.MouseEvent.dwEventFlags = 0;
|
|
|
|
/* FIXME: we no longer generate double click events */
|
|
|
|
|
|
|
|
if (!(mevt.bstate & (BUTTON1_PRESSED|BUTTON1_RELEASED|BUTTON2_PRESSED|BUTTON2_RELEASED|BUTTON3_PRESSED|BUTTON3_RELEASED)) &&
|
|
|
|
(mevt.x != pos.X || mevt.y != pos.Y))
|
|
|
|
{
|
|
|
|
ir->Event.MouseEvent.dwEventFlags |= MOUSE_MOVED;
|
|
|
|
}
|
|
|
|
pos.X = mevt.x; pos.Y = mevt.y;
|
|
|
|
|
|
|
|
return 1;
|
2002-12-14 00:37:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
2002-12-23 02:35:27 +01:00
|
|
|
* WCCURSES_FillCode
|
2002-12-14 00:37:06 +01:00
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
2003-02-14 20:23:36 +01:00
|
|
|
static unsigned WCCURSES_FillCode(struct inner_data* data, INPUT_RECORD* ir, int inchar)
|
2002-12-14 00:37:06 +01:00
|
|
|
{
|
2003-02-14 20:23:36 +01:00
|
|
|
unsigned numEvent = 0;
|
|
|
|
|
2002-12-14 00:37:06 +01:00
|
|
|
switch (inchar)
|
|
|
|
{
|
|
|
|
case KEY_BREAK:
|
|
|
|
goto notFound;
|
|
|
|
case KEY_DOWN:
|
2003-02-14 20:23:36 +01:00
|
|
|
numEvent = WCCURSES_FillComplexChar(ir, 0x50, 0x28, 0);
|
2002-12-14 00:37:06 +01:00
|
|
|
break;
|
|
|
|
case KEY_UP:
|
2003-02-14 20:23:36 +01:00
|
|
|
numEvent = WCCURSES_FillComplexChar(ir, 0x48, 0x26, 0);
|
2002-12-14 00:37:06 +01:00
|
|
|
break;
|
|
|
|
case KEY_LEFT:
|
2003-02-14 20:23:36 +01:00
|
|
|
numEvent = WCCURSES_FillComplexChar(ir, 0x4b, 0x25, 0);
|
2002-12-14 00:37:06 +01:00
|
|
|
break;
|
|
|
|
case KEY_RIGHT:
|
2003-02-14 20:23:36 +01:00
|
|
|
numEvent = WCCURSES_FillComplexChar(ir, 0x4d, 0x27, 0);
|
2002-12-14 00:37:06 +01:00
|
|
|
break;
|
|
|
|
case KEY_HOME:
|
2003-02-14 20:23:36 +01:00
|
|
|
numEvent = WCCURSES_FillComplexChar(ir, 0x47, 0x24, 0);
|
2002-12-14 00:37:06 +01:00
|
|
|
break;
|
|
|
|
case KEY_BACKSPACE:
|
2003-09-22 21:31:32 +02:00
|
|
|
numEvent = WCCURSES_FillSimpleChar(ir, 127);
|
2002-12-14 00:37:06 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case KEY_F0: /* up to F63 */
|
|
|
|
goto notFound;
|
|
|
|
|
|
|
|
case KEY_F( 1):
|
|
|
|
case KEY_F( 2):
|
|
|
|
case KEY_F( 3):
|
|
|
|
case KEY_F( 4):
|
|
|
|
case KEY_F( 5):
|
|
|
|
case KEY_F( 6):
|
|
|
|
case KEY_F( 7):
|
|
|
|
case KEY_F( 8):
|
|
|
|
case KEY_F( 9):
|
|
|
|
case KEY_F(10):
|
2003-02-14 20:23:36 +01:00
|
|
|
numEvent = WCCURSES_FillComplexChar(ir, 0x3b + inchar - KEY_F(1), 0, 0);
|
2002-12-14 00:37:06 +01:00
|
|
|
break;
|
|
|
|
case KEY_F(11):
|
|
|
|
case KEY_F(12):
|
2003-02-14 20:23:36 +01:00
|
|
|
if (PRIVATE(data)->allow_scroll)
|
|
|
|
{
|
|
|
|
WCCURSES_ScrollV(data, inchar == KEY_F(11) ? 8 : -8);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
numEvent = WCCURSES_FillComplexChar(ir, 0xd9 + inchar - KEY_F(11), 0, 0);
|
|
|
|
}
|
2002-12-14 00:37:06 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case KEY_DL:
|
|
|
|
case KEY_IL:
|
2003-02-14 20:23:36 +01:00
|
|
|
goto notFound;
|
|
|
|
|
2002-12-14 00:37:06 +01:00
|
|
|
case KEY_DC:
|
2003-02-14 20:23:36 +01:00
|
|
|
numEvent = WCCURSES_FillComplexChar(ir, 0x53, 0x2e, 0);
|
|
|
|
break;
|
2002-12-14 00:37:06 +01:00
|
|
|
case KEY_IC:
|
2003-02-14 20:23:36 +01:00
|
|
|
numEvent = WCCURSES_FillComplexChar(ir, 0x52, 0x2d, 0);
|
|
|
|
break;
|
|
|
|
|
2002-12-14 00:37:06 +01:00
|
|
|
case KEY_EIC:
|
|
|
|
case KEY_CLEAR:
|
|
|
|
case KEY_EOS:
|
|
|
|
case KEY_EOL:
|
|
|
|
case KEY_SF:
|
|
|
|
case KEY_SR:
|
|
|
|
goto notFound;
|
|
|
|
|
|
|
|
case KEY_NPAGE:
|
2003-02-14 20:23:36 +01:00
|
|
|
numEvent = WCCURSES_FillComplexChar(ir, 0x51, 0x22, 0);
|
2002-12-14 00:37:06 +01:00
|
|
|
break;
|
|
|
|
case KEY_PPAGE:
|
2003-02-14 20:23:36 +01:00
|
|
|
numEvent = WCCURSES_FillComplexChar(ir, 0x49, 0x21, 0);
|
2002-12-14 00:37:06 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case KEY_STAB:
|
|
|
|
case KEY_CTAB:
|
|
|
|
case KEY_CATAB:
|
|
|
|
case KEY_ENTER:
|
|
|
|
case KEY_SRESET:
|
|
|
|
case KEY_RESET:
|
|
|
|
case KEY_PRINT:
|
|
|
|
case KEY_LL:
|
|
|
|
case KEY_A1:
|
|
|
|
case KEY_A3:
|
|
|
|
case KEY_B2:
|
|
|
|
case KEY_C1:
|
|
|
|
case KEY_C3:
|
2003-10-09 06:26:29 +02:00
|
|
|
goto notFound;
|
|
|
|
case KEY_BTAB: /* shift tab */
|
|
|
|
numEvent = WCCURSES_FillSimpleChar(ir, 0x9);
|
|
|
|
ir[0].Event.KeyEvent.dwControlKeyState |= SHIFT_PRESSED;
|
|
|
|
ir[1].Event.KeyEvent.dwControlKeyState |= SHIFT_PRESSED;
|
|
|
|
if (numEvent != 2) WINE_ERR("FillsimpleChar has changed");
|
|
|
|
break;
|
|
|
|
|
2002-12-14 00:37:06 +01:00
|
|
|
case KEY_BEG:
|
|
|
|
case KEY_CANCEL:
|
|
|
|
case KEY_CLOSE:
|
|
|
|
case KEY_COMMAND:
|
|
|
|
case KEY_COPY:
|
|
|
|
case KEY_CREATE:
|
2003-02-14 20:23:36 +01:00
|
|
|
goto notFound;
|
|
|
|
|
2002-12-14 00:37:06 +01:00
|
|
|
case KEY_END:
|
2003-02-14 20:23:36 +01:00
|
|
|
numEvent = WCCURSES_FillComplexChar(ir, 0x4f, 0x23, 0);
|
|
|
|
break;
|
|
|
|
|
2002-12-14 00:37:06 +01:00
|
|
|
case KEY_EXIT:
|
|
|
|
case KEY_FIND:
|
|
|
|
case KEY_HELP:
|
|
|
|
case KEY_MARK:
|
|
|
|
case KEY_MESSAGE:
|
|
|
|
goto notFound;
|
|
|
|
|
|
|
|
case KEY_MOUSE:
|
2003-02-14 20:23:36 +01:00
|
|
|
numEvent = WCCURSES_FillMouse(ir);
|
2002-12-14 00:37:06 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case KEY_MOVE:
|
|
|
|
case KEY_NEXT:
|
|
|
|
case KEY_OPEN:
|
|
|
|
case KEY_OPTIONS:
|
|
|
|
case KEY_PREVIOUS:
|
|
|
|
case KEY_REDO:
|
|
|
|
case KEY_REFERENCE:
|
|
|
|
case KEY_REFRESH:
|
|
|
|
case KEY_REPLACE:
|
|
|
|
case KEY_RESIZE:
|
|
|
|
case KEY_RESTART:
|
|
|
|
case KEY_RESUME:
|
|
|
|
case KEY_SAVE:
|
|
|
|
case KEY_SBEG:
|
|
|
|
case KEY_SCANCEL:
|
|
|
|
case KEY_SCOMMAND:
|
|
|
|
case KEY_SCOPY:
|
|
|
|
case KEY_SCREATE:
|
2003-02-14 20:23:36 +01:00
|
|
|
goto notFound;
|
|
|
|
|
2002-12-14 00:37:06 +01:00
|
|
|
case KEY_SDC:
|
2003-02-14 20:23:36 +01:00
|
|
|
numEvent = WCCURSES_FillComplexChar(ir, 0x53, 0x2e, SHIFT_PRESSED);
|
|
|
|
break;
|
2002-12-14 00:37:06 +01:00
|
|
|
case KEY_SDL:
|
|
|
|
case KEY_SELECT:
|
2003-02-14 20:23:36 +01:00
|
|
|
goto notFound;
|
|
|
|
|
2002-12-14 00:37:06 +01:00
|
|
|
case KEY_SEND:
|
2003-02-14 20:23:36 +01:00
|
|
|
numEvent = WCCURSES_FillComplexChar(ir, 0x4f, 0x23, SHIFT_PRESSED);
|
|
|
|
break;
|
|
|
|
|
2002-12-14 00:37:06 +01:00
|
|
|
case KEY_SEOL:
|
|
|
|
case KEY_SEXIT:
|
|
|
|
case KEY_SFIND:
|
|
|
|
case KEY_SHELP:
|
2003-02-14 20:23:36 +01:00
|
|
|
goto notFound;
|
|
|
|
|
2002-12-14 00:37:06 +01:00
|
|
|
case KEY_SHOME:
|
2003-02-14 20:23:36 +01:00
|
|
|
numEvent = WCCURSES_FillComplexChar(ir, 0x47, 0x24, SHIFT_PRESSED);
|
|
|
|
break;
|
2002-12-14 00:37:06 +01:00
|
|
|
case KEY_SIC:
|
2003-02-14 20:23:36 +01:00
|
|
|
numEvent = WCCURSES_FillComplexChar(ir, 0x52, 0x2d, SHIFT_PRESSED);
|
|
|
|
break;
|
2002-12-14 00:37:06 +01:00
|
|
|
case KEY_SLEFT:
|
2003-02-14 20:23:36 +01:00
|
|
|
numEvent = WCCURSES_FillComplexChar(ir, 0x4b, 0x25, SHIFT_PRESSED);
|
|
|
|
break;
|
|
|
|
|
2002-12-14 00:37:06 +01:00
|
|
|
case KEY_SMESSAGE:
|
|
|
|
case KEY_SMOVE:
|
|
|
|
case KEY_SNEXT:
|
|
|
|
case KEY_SOPTIONS:
|
|
|
|
case KEY_SPREVIOUS:
|
|
|
|
case KEY_SPRINT:
|
|
|
|
case KEY_SREDO:
|
|
|
|
case KEY_SREPLACE:
|
2003-02-14 20:23:36 +01:00
|
|
|
goto notFound;
|
|
|
|
|
2002-12-14 00:37:06 +01:00
|
|
|
case KEY_SRIGHT:
|
2003-02-14 20:23:36 +01:00
|
|
|
numEvent = WCCURSES_FillComplexChar(ir, 0x4d, 0x27, SHIFT_PRESSED);
|
|
|
|
break;
|
|
|
|
|
2002-12-14 00:37:06 +01:00
|
|
|
case KEY_SRSUME:
|
|
|
|
case KEY_SSAVE:
|
|
|
|
case KEY_SSUSPEND:
|
|
|
|
case KEY_SUNDO:
|
|
|
|
case KEY_SUSPEND:
|
|
|
|
case KEY_UNDO:
|
|
|
|
notFound:
|
2003-02-14 20:23:36 +01:00
|
|
|
WINE_FIXME("Not done yet (%o)\n", inchar);
|
2002-12-14 00:37:06 +01:00
|
|
|
break;
|
|
|
|
default:
|
2003-02-14 20:23:36 +01:00
|
|
|
WINE_ERR("Unknown val (%o)\n", inchar);
|
2002-12-14 00:37:06 +01:00
|
|
|
break;
|
|
|
|
}
|
2003-02-14 20:23:36 +01:00
|
|
|
return numEvent;
|
2002-12-14 00:37:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
2002-12-23 02:35:27 +01:00
|
|
|
* WCCURSES_GetEvents
|
2002-12-14 00:37:06 +01:00
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
2002-12-23 02:35:27 +01:00
|
|
|
static void WCCURSES_GetEvents(struct inner_data* data)
|
2002-12-14 00:37:06 +01:00
|
|
|
{
|
2003-02-14 20:23:36 +01:00
|
|
|
int inchar;
|
|
|
|
INPUT_RECORD ir[8];
|
|
|
|
unsigned numEvent;
|
|
|
|
DWORD n;
|
|
|
|
|
|
|
|
if ((inchar = wgetch(stdscr)) == ERR) {WINE_FIXME("Ooch. somebody beat us\n");return;}
|
|
|
|
|
2003-10-10 02:01:21 +02:00
|
|
|
WINE_TRACE("Got o%o (0x%x)\n", inchar,inchar);
|
2003-02-14 20:23:36 +01:00
|
|
|
|
|
|
|
if (inchar & KEY_CODE_YES)
|
|
|
|
{
|
|
|
|
numEvent = WCCURSES_FillCode(data, ir, inchar);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
numEvent = WCCURSES_FillSimpleChar(ir, inchar);
|
|
|
|
}
|
|
|
|
if (numEvent)
|
|
|
|
WriteConsoleInput(data->hConIn, ir, numEvent, &n);
|
2002-12-14 00:37:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
2002-12-23 02:35:27 +01:00
|
|
|
* WCCURSES_DeleteBackend
|
2002-12-14 00:37:06 +01:00
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
2002-12-23 02:35:27 +01:00
|
|
|
static void WCCURSES_DeleteBackend(struct inner_data* data)
|
2002-12-14 00:37:06 +01:00
|
|
|
{
|
|
|
|
mmask_t mm;
|
|
|
|
|
|
|
|
if (!PRIVATE(data)) return;
|
|
|
|
|
|
|
|
CloseHandle(PRIVATE(data)->hInput);
|
|
|
|
|
|
|
|
delwin(PRIVATE(data)->pad);
|
|
|
|
mousemask(PRIVATE(data)->initial_mouse_mask, &mm);
|
|
|
|
endwin();
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, PRIVATE(data)->line);
|
|
|
|
HeapFree(GetProcessHeap(), 0, PRIVATE(data));
|
2004-07-16 00:08:05 +02:00
|
|
|
data->private = NULL;
|
2002-12-14 00:37:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
2002-12-23 02:35:27 +01:00
|
|
|
* WCCURSES_MainLoop
|
2002-12-14 00:37:06 +01:00
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
2002-12-23 02:35:27 +01:00
|
|
|
static int WCCURSES_MainLoop(struct inner_data* data)
|
2002-12-14 00:37:06 +01:00
|
|
|
{
|
|
|
|
HANDLE hin[2];
|
|
|
|
|
|
|
|
hin[0] = PRIVATE(data)->hInput;
|
|
|
|
hin[1] = data->hSynchro;
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
unsigned ret = WaitForMultipleObjects(2, hin, FALSE, INFINITE);
|
|
|
|
switch (ret)
|
|
|
|
{
|
|
|
|
case WAIT_OBJECT_0:
|
2002-12-23 02:35:27 +01:00
|
|
|
WCCURSES_GetEvents(data);
|
2002-12-14 00:37:06 +01:00
|
|
|
break;
|
|
|
|
case WAIT_OBJECT_0+1:
|
|
|
|
if (!WINECON_GrabChanges(data)) return 0;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
WINE_ERR("got pb\n");
|
|
|
|
/* err */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
2002-12-23 02:35:27 +01:00
|
|
|
* WCCURSES_InitBackend
|
2002-12-14 00:37:06 +01:00
|
|
|
*
|
|
|
|
* Initialisation part II: creation of window.
|
|
|
|
*
|
|
|
|
*/
|
2003-06-13 18:32:52 +02:00
|
|
|
enum init_return WCCURSES_InitBackend(struct inner_data* data)
|
2002-12-14 00:37:06 +01:00
|
|
|
{
|
2003-08-20 06:19:01 +02:00
|
|
|
if( !WCCURSES_bind_libcurses() )
|
|
|
|
return init_failed;
|
|
|
|
|
2002-12-14 00:37:06 +01:00
|
|
|
data->private = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(struct inner_data_curse));
|
2003-06-13 18:32:52 +02:00
|
|
|
if (!data->private) return init_failed;
|
2002-12-14 00:37:06 +01:00
|
|
|
|
2002-12-23 02:35:27 +01:00
|
|
|
data->fnMainLoop = WCCURSES_MainLoop;
|
|
|
|
data->fnPosCursor = WCCURSES_PosCursor;
|
|
|
|
data->fnShapeCursor = WCCURSES_ShapeCursor;
|
|
|
|
data->fnComputePositions = WCCURSES_ComputePositions;
|
|
|
|
data->fnRefresh = WCCURSES_Refresh;
|
|
|
|
data->fnResizeScreenBuffer = WCCURSES_ResizeScreenBuffer;
|
|
|
|
data->fnSetTitle = WCCURSES_SetTitle;
|
|
|
|
data->fnScroll = WCCURSES_Scroll;
|
|
|
|
data->fnSetFont = WCCURSES_SetFont;
|
|
|
|
data->fnDeleteBackend = WCCURSES_DeleteBackend;
|
2002-12-14 00:37:06 +01:00
|
|
|
|
|
|
|
if (wine_server_fd_to_handle(0, GENERIC_READ|SYNCHRONIZE, FALSE,
|
|
|
|
(obj_handle_t*)&PRIVATE(data)->hInput))
|
|
|
|
{
|
|
|
|
WINE_FIXME("Cannot open 0\n");
|
2003-06-13 18:32:52 +02:00
|
|
|
return init_failed;
|
2002-12-14 00:37:06 +01:00
|
|
|
}
|
|
|
|
|
2003-02-14 20:23:36 +01:00
|
|
|
/* FIXME: should find a good way to enable buffer scrolling
|
|
|
|
* For the time being, setting this to 1 will allow scrolling up/down
|
|
|
|
* on buffer with F11/F12.
|
|
|
|
*/
|
2003-09-22 21:31:32 +02:00
|
|
|
/* PRIVATE(data)->allow_scroll = 1; */
|
2003-02-14 20:23:36 +01:00
|
|
|
|
2002-12-14 00:37:06 +01:00
|
|
|
initscr();
|
|
|
|
|
|
|
|
/* creating the basic colors - FIXME intensity not handled yet */
|
|
|
|
if (has_colors())
|
|
|
|
{
|
|
|
|
int i, j;
|
|
|
|
|
|
|
|
start_color();
|
|
|
|
for (i = 0; i < 8; i++)
|
|
|
|
for (j = 0; j < 8; j++)
|
|
|
|
init_pair(i | (j << 3), i, j);
|
|
|
|
}
|
|
|
|
|
|
|
|
raw();
|
|
|
|
noecho();
|
|
|
|
intrflush(stdscr, FALSE);
|
|
|
|
nodelay(stdscr, TRUE);
|
|
|
|
keypad(stdscr, TRUE);
|
2003-03-04 03:13:05 +01:00
|
|
|
if (data->curcfg.quick_edit)
|
|
|
|
{
|
|
|
|
mousemask(BUTTON1_PRESSED|BUTTON1_RELEASED|
|
|
|
|
BUTTON2_PRESSED|BUTTON2_RELEASED|
|
|
|
|
BUTTON3_PRESSED|BUTTON3_RELEASED|
|
|
|
|
BUTTON_SHIFT|BUTTON_CTRL|BUTTON_ALT|REPORT_MOUSE_POSITION,
|
|
|
|
&PRIVATE(data)->initial_mouse_mask);
|
|
|
|
/* no click event generation... we just need button up/down events
|
|
|
|
* it doesn't seem that mouseinterval(-1) behaves as documented...
|
|
|
|
* 0 seems to be better value to disable click event generation
|
|
|
|
*/
|
|
|
|
mouseinterval(0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
mousemask(0, &PRIVATE(data)->initial_mouse_mask);
|
|
|
|
}
|
|
|
|
|
2003-06-13 18:32:52 +02:00
|
|
|
return init_success;
|
2002-12-14 00:37:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
2003-06-14 03:34:53 +02:00
|
|
|
enum init_return WCCURSES_InitBackend(struct inner_data* data)
|
2002-12-14 00:37:06 +01:00
|
|
|
{
|
2003-06-13 18:32:52 +02:00
|
|
|
return init_not_supported;
|
2002-12-14 00:37:06 +01:00
|
|
|
}
|
|
|
|
#endif
|