Converted from DOS to UNIX format (CRLF->LF)

key_table renamed to fkt_table in key_nt.c to prevent name conflict with
slint.c
This commit is contained in:
Pavel Roskin 1998-06-08 15:29:23 +00:00
parent 29c55cee18
commit 79ddddb4ef
2 changed files with 527 additions and 527 deletions

View File

@ -1,218 +1,218 @@
/* Ch-Drive command for Windows NT and OS/2 /* Ch-Drive command for Windows NT and OS/2
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
Bug: Bug:
the code will not work if you have more drives than those that the code will not work if you have more drives than those that
can fit in a panel. can fit in a panel.
*/ */
#include <config.h> #include <config.h>
#ifdef _OS_NT #ifdef _OS_NT
#include <windows.h> #include <windows.h>
#include "util_win32.h" #include "util_win32.h"
#endif #endif
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <ctype.h> #include <ctype.h>
#include "../src/tty.h" #include "../src/tty.h"
#include "../src/mad.h" #include "../src/mad.h"
#include "../src/util.h" #include "../src/util.h"
#include "../src/win.h" #include "../src/win.h"
#include "../src/color.h" #include "../src/color.h"
#include "../src/dlg.h" #include "../src/dlg.h"
#include "../src/widget.h" #include "../src/widget.h"
#include "../src/dialog.h" #include "../src/dialog.h"
#include "../src/dir.h" #include "../src/dir.h"
#include "../src/panel.h" #include "../src/panel.h"
#include "../src/main.h" #include "../src/main.h"
#include "../src/cmd.h" #include "../src/cmd.h"
struct Dlg_head *drive_dlg; struct Dlg_head *drive_dlg;
WPanel *this_panel; WPanel *this_panel;
static int drive_dlg_callback (Dlg_head *h, int Par, int Msg); static int drive_dlg_callback (Dlg_head *h, int Par, int Msg);
static void drive_dlg_refresh (void); static void drive_dlg_refresh (void);
static void drive_cmd(void); static void drive_cmd(void);
#define B_DRIVE_BASE 100 #define B_DRIVE_BASE 100
#define MAX_LGH 13 /* Length for drives */ #define MAX_LGH 13 /* Length for drives */
static void drive_cmd() static void drive_cmd()
{ {
int i, nNewDrive, nDrivesAvail; int i, nNewDrive, nDrivesAvail;
char szTempBuf[7], szDrivesAvail[27*4], *p; char szTempBuf[7], szDrivesAvail[27*4], *p;
/* Dialogbox position */ /* Dialogbox position */
int x_pos; int x_pos;
int y_pos = (LINES-6)/2-3; int y_pos = (LINES-6)/2-3;
int y_height; int y_height;
int x_width; int x_width;
int m_drv; int m_drv;
/* Get drives name and count */ /* Get drives name and count */
#ifdef _OS_NT #ifdef _OS_NT
GetLogicalDriveStrings (255, szDrivesAvail); GetLogicalDriveStrings (255, szDrivesAvail);
for (nDrivesAvail = 0, p = szDrivesAvail; *p; nDrivesAvail++) for (nDrivesAvail = 0, p = szDrivesAvail; *p; nDrivesAvail++)
p+=4; p+=4;
#else #else
unsigned long uDriveNum, uDriveMap; unsigned long uDriveNum, uDriveMap;
nDrivesAvail = 0; nDrivesAvail = 0;
p = szDrivesAvail; p = szDrivesAvail;
DosQueryCurrentDisk(&uDriveNum, &uDriveMap); DosQueryCurrentDisk(&uDriveNum, &uDriveMap);
for (i = 0; i < 26; i++) { for (i = 0; i < 26; i++) {
if ( uDriveMap & (1 << i) ) { if ( uDriveMap & (1 << i) ) {
*p = 'A' + i; *p = 'A' + i;
p += 4; p += 4;
nDrivesAvail++; nDrivesAvail++;
} }
} }
*p = 0; *p = 0;
#endif #endif
/* Create Dialog */ /* Create Dialog */
do_refresh (); do_refresh ();
m_drv = ((nDrivesAvail > MAX_LGH) ? MAX_LGH: nDrivesAvail); m_drv = ((nDrivesAvail > MAX_LGH) ? MAX_LGH: nDrivesAvail);
/* Center on x, relative to panel */ /* Center on x, relative to panel */
x_pos = this_panel->widget.x + (this_panel->widget.cols - m_drv*3)/2 + 2; x_pos = this_panel->widget.x + (this_panel->widget.cols - m_drv*3)/2 + 2;
if (nDrivesAvail > MAX_LGH) { if (nDrivesAvail > MAX_LGH) {
y_height = 8; y_height = 8;
x_width = 33; x_width = 33;
} else { } else {
y_height = 6; y_height = 6;
x_width = (nDrivesAvail - 1) * 2 + 9; x_width = (nDrivesAvail - 1) * 2 + 9;
} }
drive_dlg = create_dlg (y_pos, x_pos, y_height, x_width, dialog_colors, drive_dlg = create_dlg (y_pos, x_pos, y_height, x_width, dialog_colors,
drive_dlg_callback, "[ChDrive]", "drive", DLG_NONE); drive_dlg_callback, "[ChDrive]", "drive", DLG_NONE);
x_set_dialog_title (drive_dlg, "Change Drive"); x_set_dialog_title (drive_dlg, "Change Drive");
if (nDrivesAvail>MAX_LGH) { if (nDrivesAvail>MAX_LGH) {
for (i = 0; i < nDrivesAvail - MAX_LGH; i++) { for (i = 0; i < nDrivesAvail - MAX_LGH; i++) {
p -= 4; p -= 4;
sprintf(szTempBuf, "&%c", *p); sprintf(szTempBuf, "&%c", *p);
add_widgetl(drive_dlg, add_widgetl(drive_dlg,
button_new (5, button_new (5,
(m_drv-i-1)*2+4 - (MAX_LGH*2 - nDrivesAvail) * 2, (m_drv-i-1)*2+4 - (MAX_LGH*2 - nDrivesAvail) * 2,
B_DRIVE_BASE + nDrivesAvail - i - 1, B_DRIVE_BASE + nDrivesAvail - i - 1,
HIDDEN_BUTTON, HIDDEN_BUTTON,
szTempBuf, 0, NULL, NULL), szTempBuf, 0, NULL, NULL),
XV_WLAY_RIGHTOF); XV_WLAY_RIGHTOF);
} }
} }
/* Add a button for each drive */ /* Add a button for each drive */
for (i = 0; i < m_drv; i++) { for (i = 0; i < m_drv; i++) {
p -= 4; p -= 4;
sprintf (szTempBuf, "&%c", *p); sprintf (szTempBuf, "&%c", *p);
add_widgetl(drive_dlg, add_widgetl(drive_dlg,
button_new (3, (m_drv-i-1)*2+4, B_DRIVE_BASE+m_drv-i-1, button_new (3, (m_drv-i-1)*2+4, B_DRIVE_BASE+m_drv-i-1,
HIDDEN_BUTTON, szTempBuf, 0, NULL, NULL), HIDDEN_BUTTON, szTempBuf, 0, NULL, NULL),
XV_WLAY_RIGHTOF); XV_WLAY_RIGHTOF);
} }
run_dlg(drive_dlg); run_dlg(drive_dlg);
/* do action */ /* do action */
if (drive_dlg->ret_value != B_CANCEL) { if (drive_dlg->ret_value != B_CANCEL) {
int errocc = 0; /* no error */ int errocc = 0; /* no error */
int rtn; int rtn;
char drvLetter; char drvLetter;
nNewDrive = drive_dlg->ret_value - B_DRIVE_BASE; nNewDrive = drive_dlg->ret_value - B_DRIVE_BASE;
drvLetter = (char) *(szDrivesAvail + (nNewDrive*4)); drvLetter = (char) *(szDrivesAvail + (nNewDrive*4));
#ifdef _OS_NT #ifdef _OS_NT
if (win32_GetPlatform() == OS_WinNT) { /* Windows NT */ if (win32_GetPlatform() == OS_WinNT) { /* Windows NT */
rtn = _chdrive(drvLetter - 'A' + 1); rtn = _chdrive(drvLetter - 'A' + 1);
} else { /* Windows 95 */ } else { /* Windows 95 */
rtn = 1; rtn = 1;
SetCurrentDirectory(szDrivesAvail+(nNewDrive*4)); SetCurrentDirectory(szDrivesAvail+(nNewDrive*4));
} }
#else #else
rtn = DosSetDefaultDisk(nNewDrive + 1); rtn = DosSetDefaultDisk(nNewDrive + 1);
#endif #endif
if (rtn == -1) if (rtn == -1)
errocc = 1; errocc = 1;
else { else {
getcwd (this_panel->cwd, sizeof (this_panel->cwd)-2); getcwd (this_panel->cwd, sizeof (this_panel->cwd)-2);
if (toupper(drvLetter) == toupper(*(this_panel->cwd))) { if (toupper(drvLetter) == toupper(*(this_panel->cwd))) {
clean_dir (&this_panel->dir, this_panel->count); clean_dir (&this_panel->dir, this_panel->count);
this_panel->count = do_load_dir(&this_panel->dir, this_panel->count = do_load_dir(&this_panel->dir,
this_panel->sort_type, this_panel->sort_type,
this_panel->reverse, this_panel->reverse,
this_panel->case_sensitive, this_panel->case_sensitive,
this_panel->filter); this_panel->filter);
this_panel->top_file = 0; this_panel->top_file = 0;
this_panel->selected = 0; this_panel->selected = 0;
this_panel->marked = 0; this_panel->marked = 0;
this_panel->total = 0; this_panel->total = 0;
show_dir(this_panel); show_dir(this_panel);
reread_cmd(); reread_cmd();
} else } else
errocc = 1; errocc = 1;
} }
if (errocc) if (errocc)
message (1, " Error ", " Can't access drive %c: ", message (1, " Error ", " Can't access drive %c: ",
*(szDrivesAvail+(nNewDrive*4)) ); *(szDrivesAvail+(nNewDrive*4)) );
} }
destroy_dlg (drive_dlg); destroy_dlg (drive_dlg);
repaint_screen (); repaint_screen ();
} }
void drive_cmd_a() void drive_cmd_a()
{ {
this_panel = left_panel; this_panel = left_panel;
drive_cmd(); drive_cmd();
} }
void drive_cmd_b() void drive_cmd_b()
{ {
this_panel = right_panel; this_panel = right_panel;
drive_cmd(); drive_cmd();
} }
void drive_chg(WPanel *panel) void drive_chg(WPanel *panel)
{ {
this_panel = panel; this_panel = panel;
drive_cmd(); drive_cmd();
} }
static int drive_dlg_callback (Dlg_head *h, int Par, int Msg) static int drive_dlg_callback (Dlg_head *h, int Par, int Msg)
{ {
switch (Msg) { switch (Msg) {
#ifndef HAVE_X #ifndef HAVE_X
case DLG_DRAW: case DLG_DRAW:
drive_dlg_refresh (); drive_dlg_refresh ();
break; break;
#endif #endif
} }
return 0; return 0;
} }
static void drive_dlg_refresh (void) static void drive_dlg_refresh (void)
{ {
attrset (dialog_colors[0]); attrset (dialog_colors[0]);
dlg_erase (drive_dlg); dlg_erase (drive_dlg);
draw_box (drive_dlg, 1, 1, drive_dlg->lines-2, drive_dlg->cols-2); draw_box (drive_dlg, 1, 1, drive_dlg->lines-2, drive_dlg->cols-2);
attrset (dialog_colors[2]); attrset (dialog_colors[2]);
dlg_move (drive_dlg, 1, drive_dlg->cols/2 - 7); dlg_move (drive_dlg, 1, drive_dlg->cols/2 - 7);
addstr (" Change Drive "); addstr (" Change Drive ");
} }

View File

@ -1,309 +1,309 @@
/* Keyboard support routines. /* Keyboard support routines.
for Windows NT system. for Windows NT system.
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
Bugs: Bugs:
Have trouble with non-US keyboards, "Alt-gr"+keys (API tells CTRL-ALT is pressed) Have trouble with non-US keyboards, "Alt-gr"+keys (API tells CTRL-ALT is pressed)
*/ */
#include <config.h> #include <config.h>
#ifndef _OS_NT #ifndef _OS_NT
#error This file is for Win32 systems. #error This file is for Win32 systems.
#else #else
#include <windows.h> #include <windows.h>
#include <stdio.h> #include <stdio.h>
#include "../src/mouse.h" #include "../src/mouse.h"
#include "../src/global.h" #include "../src/global.h"
#include "../src/main.h" #include "../src/main.h"
#include "../src/key.h" #include "../src/key.h"
#include "../vfs/vfs.h" #include "../vfs/vfs.h"
#include "../src/tty.h" #include "../src/tty.h"
#include "trace_nt.h" #include "trace_nt.h"
/* Global variables */ /* Global variables */
int old_esc_mode = 0; int old_esc_mode = 0;
HANDLE hConsoleInput; HANDLE hConsoleInput;
DWORD dwSaved_ControlState; DWORD dwSaved_ControlState;
Gpm_Event evSaved_Event; Gpm_Event evSaved_Event;
/* Unused variables */ /* Unused variables */
int double_click_speed; /* they are here to keep linker happy */ int double_click_speed; /* they are here to keep linker happy */
int mou_auto_repeat; int mou_auto_repeat;
int use_8th_bit_as_meta = 0; int use_8th_bit_as_meta = 0;
/* Static Tables */ /* Static Tables */
struct { struct {
int key_code; int key_code;
int vkcode; int vkcode;
} key_table [] = { } fkt_table [] = {
{ KEY_F(1), VK_F1 }, { KEY_F(1), VK_F1 },
{ KEY_F(2), VK_F2 }, { KEY_F(2), VK_F2 },
{ KEY_F(3), VK_F3 }, { KEY_F(3), VK_F3 },
{ KEY_F(4), VK_F4 }, { KEY_F(4), VK_F4 },
{ KEY_F(5), VK_F5 }, { KEY_F(5), VK_F5 },
{ KEY_F(6), VK_F6 }, { KEY_F(6), VK_F6 },
{ KEY_F(7), VK_F7 }, { KEY_F(7), VK_F7 },
{ KEY_F(8), VK_F8 }, { KEY_F(8), VK_F8 },
{ KEY_F(9), VK_F9 }, { KEY_F(9), VK_F9 },
{ KEY_F(10), VK_F10 }, { KEY_F(10), VK_F10 },
{ KEY_F(11), VK_F11 }, { KEY_F(11), VK_F11 },
{ KEY_F(12), VK_F12 }, { KEY_F(12), VK_F12 },
{ KEY_F(13), VK_F13 }, { KEY_F(13), VK_F13 },
{ KEY_F(14), VK_F14 }, { KEY_F(14), VK_F14 },
{ KEY_F(15), VK_F15 }, { KEY_F(15), VK_F15 },
{ KEY_F(16), VK_F16 }, { KEY_F(16), VK_F16 },
{ KEY_F(17), VK_F17 }, { KEY_F(17), VK_F17 },
{ KEY_F(18), VK_F18 }, { KEY_F(18), VK_F18 },
{ KEY_F(19), VK_F19 }, { KEY_F(19), VK_F19 },
{ KEY_F(20), VK_F20 }, { KEY_F(20), VK_F20 },
{ KEY_IC, VK_INSERT }, { KEY_IC, VK_INSERT },
{ KEY_DC, VK_DELETE }, { KEY_DC, VK_DELETE },
{ KEY_BACKSPACE, VK_BACK }, { KEY_BACKSPACE, VK_BACK },
{ KEY_PPAGE, VK_PRIOR }, { KEY_PPAGE, VK_PRIOR },
{ KEY_NPAGE, VK_NEXT }, { KEY_NPAGE, VK_NEXT },
{ KEY_LEFT, VK_LEFT }, { KEY_LEFT, VK_LEFT },
{ KEY_RIGHT, VK_RIGHT }, { KEY_RIGHT, VK_RIGHT },
{ KEY_UP, VK_UP }, { KEY_UP, VK_UP },
{ KEY_DOWN, VK_DOWN }, { KEY_DOWN, VK_DOWN },
{ KEY_HOME, VK_HOME }, { KEY_HOME, VK_HOME },
{ KEY_END, VK_END }, { KEY_END, VK_END },
{ ALT('*'), VK_MULTIPLY }, { ALT('*'), VK_MULTIPLY },
{ ALT('+'), VK_ADD }, { ALT('+'), VK_ADD },
{ ALT('-'), VK_SUBTRACT }, { ALT('-'), VK_SUBTRACT },
{ ESC_CHAR, VK_ESCAPE }, { ESC_CHAR, VK_ESCAPE },
{ 0, 0} { 0, 0}
}; };
/* init_key - Called in main.c to initialize ourselves /* init_key - Called in main.c to initialize ourselves
Get handle to console input Get handle to console input
*/ */
void init_key (void) void init_key (void)
{ {
win32APICALL_HANDLE (hConsoleInput, GetStdHandle (STD_INPUT_HANDLE)); win32APICALL_HANDLE (hConsoleInput, GetStdHandle (STD_INPUT_HANDLE));
} }
int ctrl_pressed () int ctrl_pressed ()
{ {
return dwSaved_ControlState & (RIGHT_CTRL_PRESSED | LEFT_CTRL_PRESSED); return dwSaved_ControlState & (RIGHT_CTRL_PRESSED | LEFT_CTRL_PRESSED);
} }
int shift_pressed () int shift_pressed ()
{ {
return dwSaved_ControlState & SHIFT_PRESSED; return dwSaved_ControlState & SHIFT_PRESSED;
} }
int alt_pressed () int alt_pressed ()
{ {
return dwSaved_ControlState & (RIGHT_ALT_PRESSED | LEFT_ALT_PRESSED); return dwSaved_ControlState & (RIGHT_ALT_PRESSED | LEFT_ALT_PRESSED);
} }
static int VKtoCurses (int a_vkc) static int VKtoCurses (int a_vkc)
{ {
int i; int i;
for (i = 0; key_table[i].vkcode != 0; i++) for (i = 0; fkt_table[i].vkcode != 0; i++)
if (a_vkc == key_table[i].vkcode) { if (a_vkc == fkt_table[i].vkcode) {
return key_table[i].key_code; return fkt_table[i].key_code;
} }
return 0; return 0;
} }
static int translate_key_code(int asc, int scan) static int translate_key_code(int asc, int scan)
{ {
int c; int c;
c = VKtoCurses (scan); c = VKtoCurses (scan);
if (!asc && !c) if (!asc && !c)
return 0; return 0;
if (asc && c) if (asc && c)
return c; return c;
if (!asc) if (!asc)
{ {
if (shift_pressed() && (c >= KEY_F(1)) && (c <= KEY_F(10))) if (shift_pressed() && (c >= KEY_F(1)) && (c <= KEY_F(10)))
c += 10; c += 10;
if (alt_pressed() && (c >= KEY_F(1)) && (c <= KEY_F(2))) if (alt_pressed() && (c >= KEY_F(1)) && (c <= KEY_F(2)))
c += 10; c += 10;
if (alt_pressed() && (c == KEY_F(7))) if (alt_pressed() && (c == KEY_F(7)))
c = ALT('?'); c = ALT('?');
if (ctrl_pressed() && c == '\t') if (ctrl_pressed() && c == '\t')
c = ALT('\t'); c = ALT('\t');
return c; return c;
} }
if (ctrl_pressed()) if (ctrl_pressed())
return XCTRL(asc); return XCTRL(asc);
if (alt_pressed()) if (alt_pressed())
return ALT(asc); return ALT(asc);
if (asc == 13) if (asc == 13)
return 10; return 10;
return asc; return asc;
} }
int get_key_code (int no_delay) int get_key_code (int no_delay)
{ {
INPUT_RECORD ir; /* Input record */ INPUT_RECORD ir; /* Input record */
DWORD dw; /* number of records actually read */ DWORD dw; /* number of records actually read */
int ch, vkcode, j; int ch, vkcode, j;
if (no_delay) { if (no_delay) {
/* Check if any input pending, otherwise return */ /* Check if any input pending, otherwise return */
nodelay (stdscr, TRUE); nodelay (stdscr, TRUE);
win32APICALL(PeekConsoleInput(hConsoleInput, &ir, 1, &dw)); win32APICALL(PeekConsoleInput(hConsoleInput, &ir, 1, &dw));
if (!dw) if (!dw)
return 0; return 0;
} }
do { do {
win32APICALL(ReadConsoleInput(hConsoleInput, &ir, 1, &dw)); win32APICALL(ReadConsoleInput(hConsoleInput, &ir, 1, &dw));
switch (ir.EventType) { switch (ir.EventType) {
case KEY_EVENT: case KEY_EVENT:
if (!ir.Event.KeyEvent.bKeyDown) /* Process key just once: when pressed */ if (!ir.Event.KeyEvent.bKeyDown) /* Process key just once: when pressed */
break; break;
vkcode = ir.Event.KeyEvent.wVirtualKeyCode; vkcode = ir.Event.KeyEvent.wVirtualKeyCode;
#ifndef __MINGW32__ #ifndef __MINGW32__
ch = ir.Event.KeyEvent.uChar.AsciiChar; ch = ir.Event.KeyEvent.uChar.AsciiChar;
#else #else
ch = ir.Event.KeyEvent.AsciiChar; ch = ir.Event.KeyEvent.AsciiChar;
#endif #endif
dwSaved_ControlState = ir.Event.KeyEvent.dwControlKeyState; dwSaved_ControlState = ir.Event.KeyEvent.dwControlKeyState;
j = translate_key_code (ch, vkcode); j = translate_key_code (ch, vkcode);
if (j) if (j)
return j; return j;
break; break;
case MOUSE_EVENT: case MOUSE_EVENT:
/* Save event as a GPM-like event */ /* Save event as a GPM-like event */
evSaved_Event.x = ir.Event.MouseEvent.dwMousePosition.X; evSaved_Event.x = ir.Event.MouseEvent.dwMousePosition.X;
evSaved_Event.y = ir.Event.MouseEvent.dwMousePosition.Y+1; evSaved_Event.y = ir.Event.MouseEvent.dwMousePosition.Y+1;
evSaved_Event.buttons = ir.Event.MouseEvent.dwButtonState; evSaved_Event.buttons = ir.Event.MouseEvent.dwButtonState;
switch (ir.Event.MouseEvent.dwEventFlags) { switch (ir.Event.MouseEvent.dwEventFlags) {
case 0: case 0:
evSaved_Event.type = GPM_DOWN | GPM_SINGLE; evSaved_Event.type = GPM_DOWN | GPM_SINGLE;
break; break;
case MOUSE_MOVED: case MOUSE_MOVED:
evSaved_Event.type = GPM_MOVE; evSaved_Event.type = GPM_MOVE;
break; break;
case DOUBLE_CLICK: case DOUBLE_CLICK:
evSaved_Event.type = GPM_DOWN | GPM_DOUBLE; evSaved_Event.type = GPM_DOWN | GPM_DOUBLE;
break; break;
}; };
return 0; return 0;
} }
} while (!no_delay); } while (!no_delay);
return 0; return 0;
} }
static int getch_with_delay (void) static int getch_with_delay (void)
{ {
int c; int c;
while (1) { while (1) {
/* Try to get a character */ /* Try to get a character */
c = get_key_code (0); c = get_key_code (0);
if (c != ERR) if (c != ERR)
break; break;
} }
/* Success -> return the character */ /* Success -> return the character */
return c; return c;
} }
/* Returns a character read from stdin with appropriate interpretation */ /* Returns a character read from stdin with appropriate interpretation */
int get_event (Gpm_Event *event, int redo_event, int block) int get_event (Gpm_Event *event, int redo_event, int block)
{ {
int c; int c;
static int flag; /* Return value from select */ static int flag; /* Return value from select */
static int dirty = 3; static int dirty = 3;
if ((dirty == 1) || is_idle ()){ if ((dirty == 1) || is_idle ()){
refresh (); refresh ();
doupdate (); doupdate ();
dirty = 1; dirty = 1;
} else } else
dirty++; dirty++;
vfs_timeout_handler (); vfs_timeout_handler ();
c = block ? getch_with_delay () : get_key_code (1); c = block ? getch_with_delay () : get_key_code (1);
if (!c) { if (!c) {
/* Code is 0, so this is a Control key or mouse event */ /* Code is 0, so this is a Control key or mouse event */
return EV_NONE; /* FIXME: mouse not supported */ return EV_NONE; /* FIXME: mouse not supported */
} }
return c; return c;
} }
/* Returns a key press, mouse events are discarded */ /* Returns a key press, mouse events are discarded */
int mi_getch () int mi_getch ()
{ {
Gpm_Event ev; Gpm_Event ev;
int key; int key;
while ((key = get_event (&ev, 0, 1)) == 0) while ((key = get_event (&ev, 0, 1)) == 0)
; ;
return key; return key;
} }
/* /*
is_idle - A function to check if we're idle. is_idle - A function to check if we're idle.
It checks for any waiting event (that can be a Key, Mouse event, It checks for any waiting event (that can be a Key, Mouse event,
and other internal events like focus or menu) and other internal events like focus or menu)
*/ */
int is_idle (void) int is_idle (void)
{ {
DWORD dw; DWORD dw;
if (GetNumberOfConsoleInputEvents (hConsoleInput, &dw)) if (GetNumberOfConsoleInputEvents (hConsoleInput, &dw))
if (dw > 15) if (dw > 15)
return 0; return 0;
return 1; return 1;
} }
/* get_modifier */ /* get_modifier */
int get_modifier() int get_modifier()
{ {
int retval = 0; int retval = 0;
if (dwSaved_ControlState & LEFT_ALT_PRESSED) /* code is not clean, because we return Linux-like bitcodes*/ if (dwSaved_ControlState & LEFT_ALT_PRESSED) /* code is not clean, because we return Linux-like bitcodes*/
retval |= ALTL_PRESSED; retval |= ALTL_PRESSED;
if (dwSaved_ControlState & RIGHT_ALT_PRESSED) if (dwSaved_ControlState & RIGHT_ALT_PRESSED)
retval |= ALTR_PRESSED; retval |= ALTR_PRESSED;
if (dwSaved_ControlState & RIGHT_CTRL_PRESSED || if (dwSaved_ControlState & RIGHT_CTRL_PRESSED ||
dwSaved_ControlState & LEFT_CTRL_PRESSED) dwSaved_ControlState & LEFT_CTRL_PRESSED)
retval |= CONTROL_PRESSED; retval |= CONTROL_PRESSED;
if (dwSaved_ControlState & SHIFT_PRESSED) if (dwSaved_ControlState & SHIFT_PRESSED)
retval |= SHIFT_PRESSED; retval |= SHIFT_PRESSED;
return retval; return retval;
} }
/* void functions for UNIX compatibility */ /* void functions for UNIX compatibility */
void define_sequence (int code, char* vkcode, int action) {} void define_sequence (int code, char* vkcode, int action) {}
void channels_up() {} void channels_up() {}
void channels_down() {} void channels_down() {}
void init_key_input_fd (void) {} void init_key_input_fd (void) {}
void numeric_keypad_mode (void) {} void numeric_keypad_mode (void) {}
void application_keypad_mode (void) {} void application_keypad_mode (void) {}
/* mouse is not yet supported, sorry */ /* mouse is not yet supported, sorry */
void init_mouse (void) {} void init_mouse (void) {}
void shut_mouse (void) {} void shut_mouse (void) {}
#endif /* _OS_NT */ #endif /* _OS_NT */