1998-02-27 07:54:42 +03:00
|
|
|
/* Slang interface to the Midnight Commander
|
|
|
|
This emulates some features of ncurses on top of slang
|
|
|
|
|
2007-09-25 19:33:35 +04:00
|
|
|
Copyright (C) 1995, 1996, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
|
|
|
|
2005, 2007 Free Software Foundation, Inc.
|
1998-02-27 07:54:42 +03:00
|
|
|
|
|
|
|
Author Miguel de Icaza
|
|
|
|
Norbert Warmuth
|
2001-11-07 16:35:57 +03:00
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
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
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program 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 General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
2005-05-27 07:35:10 +04:00
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
2005-02-08 12:04:03 +03:00
|
|
|
|
2009-02-05 21:28:18 +03:00
|
|
|
/** \file slint.c
|
2009-02-06 17:46:15 +03:00
|
|
|
* \brief Source: slang %interface to the Midnight Commander
|
2009-02-05 21:28:18 +03:00
|
|
|
* \warning This module will be removed soon
|
|
|
|
*/
|
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
#include <config.h>
|
2005-02-08 12:04:03 +03:00
|
|
|
|
|
|
|
#include <signal.h>
|
1998-02-27 07:54:42 +03:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2001-09-03 09:55:22 +04:00
|
|
|
|
2005-02-08 12:04:03 +03:00
|
|
|
#ifdef HAVE_TERMIOS_H
|
|
|
|
#include <termios.h>
|
|
|
|
#endif
|
|
|
|
#include <unistd.h>
|
|
|
|
|
Glibing..... (2)
Wed Jan 27 03:17:44 1999 Timur Bakeyev <mc@bat.ru>
* Converted memory managment to Glib. Now we use g_new()/g_malloc()/
g_strdup()/g_free() routings. Also, copy_strings() replaced by
g_strconcat(), strcasecmp() -> g_strcasecmp(),and sprintf() by
g_snprintf().
* Some sequences of malloc()/sprintf() changed to g_strdup_printf().
* mad.[ch]: Modified, to work with new GLib's memory managment. Fixed
a missing #undef for tempnam, which caused dead loop. Add several new
functions to emulate GLib memory managment.
*main.c, mad.[ch]: Add a new switch "-M", which allows to redirect MAD
messages to the file.
* util.[ch], utilunix.c: Modified, deleted our variants of strcasecmp()
and strdup() - we have g_ equivalences. Remove get_full_name() - it is
similar to concat_dir_and_file(). Some other tricks with g_* functions.
* global.h: Modified, extended. Now it is main memory mangment include -
i.e. all inclusions of <stdlib.h>, <malloc.h>, <glib.h>, "fs.h", "mem.h",
"util.h" and "mad.h" done there. This elimanates problem with proper or-
der of #include's.
* All around the source - changed order of #include's, most of them gone
to global.h (see above), minor changes, like "0" -> NULL in string func-
tions.
1999-01-27 04:08:30 +03:00
|
|
|
#include "global.h"
|
2001-09-03 09:55:22 +04:00
|
|
|
#include "tty.h"
|
1998-02-27 07:54:42 +03:00
|
|
|
#include "color.h"
|
|
|
|
#include "mouse.h" /* Gpm_Event is required in key.h */
|
|
|
|
#include "key.h" /* define_sequence */
|
|
|
|
#include "main.h" /* extern: force_colors */
|
|
|
|
#include "win.h" /* do_exit_ca_mode */
|
|
|
|
#include "setup.h"
|
2003-10-27 20:34:57 +03:00
|
|
|
#include "background.h" /* we_are_background */
|
1998-02-27 07:54:42 +03:00
|
|
|
|
|
|
|
#ifdef HAVE_SLANG
|
|
|
|
|
|
|
|
/* Taken from S-Lang's slutty.c */
|
|
|
|
#ifdef ultrix /* Ultrix gets _POSIX_VDISABLE wrong! */
|
|
|
|
# define NULL_VALUE -1
|
|
|
|
#else
|
|
|
|
# ifdef _POSIX_VDISABLE
|
|
|
|
# define NULL_VALUE _POSIX_VDISABLE
|
|
|
|
# else
|
|
|
|
# define NULL_VALUE 255
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef SA_RESTART
|
|
|
|
# define SA_RESTART 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Various saved termios settings that we control here */
|
|
|
|
static struct termios boot_mode;
|
|
|
|
static struct termios new_mode;
|
|
|
|
|
|
|
|
/* Controls whether we should wait for input in getch */
|
|
|
|
static int no_slang_delay;
|
|
|
|
|
2005-03-19 22:31:23 +03:00
|
|
|
/* Forward declarations */
|
|
|
|
static void load_terminfo_keys (void);
|
|
|
|
|
2009-02-04 22:37:00 +03:00
|
|
|
#ifndef HAVE_SLANG_PRIVATE
|
|
|
|
/* Private interfaces have been stripped, so we cannot use them */
|
|
|
|
#define SLang_getkey2() SLang_getkey()
|
|
|
|
#define SLang_input_pending2(s) SLang_input_pending(s)
|
|
|
|
#else
|
|
|
|
/* Copied from ../slang/slgetkey.c, removed the DEC_8Bit_HACK. */
|
|
|
|
extern unsigned char SLang_Input_Buffer [];
|
|
|
|
#if SLANG_VERSION >= 10000
|
|
|
|
extern unsigned int _SLsys_getkey (void);
|
|
|
|
extern int _SLsys_input_pending (int);
|
|
|
|
#else
|
|
|
|
extern unsigned int SLsys_getkey (void);
|
|
|
|
extern int SLsys_input_pending (int);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static unsigned int SLang_getkey2 (void)
|
|
|
|
{
|
|
|
|
unsigned int imax;
|
|
|
|
unsigned int ch;
|
|
|
|
|
|
|
|
if (SLang_Input_Buffer_Len)
|
|
|
|
{
|
|
|
|
ch = (unsigned int) *SLang_Input_Buffer;
|
|
|
|
SLang_Input_Buffer_Len--;
|
|
|
|
imax = SLang_Input_Buffer_Len;
|
|
|
|
|
|
|
|
memmove ((char *) SLang_Input_Buffer,
|
|
|
|
(char *) (SLang_Input_Buffer + 1), imax);
|
|
|
|
return(ch);
|
|
|
|
}
|
|
|
|
#if SLANG_VERSION >= 10000
|
|
|
|
else return(_SLsys_getkey ());
|
|
|
|
#else
|
|
|
|
else return(SLsys_getkey());
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static int SLang_input_pending2 (int tsecs)
|
|
|
|
{
|
|
|
|
int n, i;
|
|
|
|
unsigned char c;
|
|
|
|
|
|
|
|
if (SLang_Input_Buffer_Len) return (int) SLang_Input_Buffer_Len;
|
|
|
|
#if SLANG_VERSION >= 10000
|
|
|
|
n = _SLsys_input_pending (tsecs);
|
|
|
|
#else
|
|
|
|
n = SLsys_input_pending (tsecs);
|
|
|
|
#endif
|
|
|
|
if (n <= 0) return 0;
|
|
|
|
|
|
|
|
i = SLang_getkey2 ();
|
|
|
|
if (i == SLANG_GETKEY_ERROR)
|
|
|
|
return 0; /* don't put crippled error codes into the input buffer */
|
|
|
|
c = (unsigned char)i;
|
|
|
|
SLang_ungetkey_string (&c, 1);
|
|
|
|
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
#endif /* HAVE_SLANG_PRIVATE */
|
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
/* Only done the first time */
|
|
|
|
void
|
|
|
|
slang_init (void)
|
|
|
|
{
|
|
|
|
SLtt_get_terminfo ();
|
2008-12-29 01:45:06 +03:00
|
|
|
#if SLANG_VERSION >= 20000
|
|
|
|
SLutf8_enable (-1);
|
|
|
|
#endif
|
2001-06-13 10:53:08 +04:00
|
|
|
/*
|
|
|
|
* If the terminal in not in terminfo but begins with a well-known
|
|
|
|
* string such as "linux" or "xterm" S-Lang will go on, but the
|
|
|
|
* terminal size and several other variables won't be initialized
|
|
|
|
* (as of S-Lang 1.4.4). Detect it and abort. Also detect extremely
|
|
|
|
* small, large and negative screen dimensions.
|
|
|
|
*/
|
2004-11-07 15:48:48 +03:00
|
|
|
if ((COLS < 10) || (LINES < 5) ||
|
|
|
|
(SLang_Version < 10407 && (COLS > 255 || LINES > 255)) ||
|
|
|
|
(SLang_Version >= 10407 && (COLS > 512 || LINES > 512))) {
|
|
|
|
|
2001-06-13 10:53:08 +04:00
|
|
|
fprintf (stderr,
|
|
|
|
_("Screen size %dx%d is not supported.\n"
|
|
|
|
"Check the TERM environment variable.\n"),
|
|
|
|
COLS, LINES);
|
|
|
|
exit (1);
|
|
|
|
}
|
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
tcgetattr (fileno (stdin), &boot_mode);
|
|
|
|
/* 255 = ignore abort char; XCTRL('g') for abort char = ^g */
|
|
|
|
SLang_init_tty (XCTRL('c'), 1, 0);
|
|
|
|
|
|
|
|
/* If SLang uses fileno(stderr) for terminal input MC will hang
|
|
|
|
if we call SLang_getkey between calls to open_error_pipe and
|
|
|
|
close_error_pipe, e.g. when we do a growing view of an gzipped
|
|
|
|
file. */
|
|
|
|
if (SLang_TT_Read_FD == fileno (stderr))
|
|
|
|
SLang_TT_Read_FD = fileno (stdin);
|
|
|
|
|
|
|
|
if (force_ugly_line_drawing)
|
|
|
|
SLtt_Has_Alt_Charset = 0;
|
|
|
|
if (tcgetattr (SLang_TT_Read_FD, &new_mode) == 0) {
|
|
|
|
#ifdef VDSUSP
|
|
|
|
new_mode.c_cc[VDSUSP] = NULL_VALUE; /* to ignore ^Y */
|
|
|
|
#endif
|
|
|
|
#ifdef VLNEXT
|
|
|
|
new_mode.c_cc[VLNEXT] = NULL_VALUE; /* to ignore ^V */
|
|
|
|
#endif
|
|
|
|
tcsetattr (SLang_TT_Read_FD, TCSADRAIN, &new_mode);
|
|
|
|
}
|
|
|
|
slang_prog_mode ();
|
|
|
|
load_terminfo_keys ();
|
|
|
|
SLtt_Blink_Mode = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
slang_set_raw_mode (void)
|
|
|
|
{
|
|
|
|
tcsetattr (SLang_TT_Read_FD, TCSANOW, &new_mode);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Done each time we come back from done mode */
|
|
|
|
void
|
|
|
|
slang_prog_mode (void)
|
|
|
|
{
|
|
|
|
tcsetattr (SLang_TT_Read_FD, TCSANOW, &new_mode);
|
|
|
|
SLsmg_init_smg ();
|
|
|
|
SLsmg_touch_lines (0, LINES);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Called each time we want to shutdown slang screen manager */
|
|
|
|
void
|
|
|
|
slang_shell_mode (void)
|
|
|
|
{
|
|
|
|
tcsetattr (SLang_TT_Read_FD, TCSANOW, &boot_mode);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-09-03 09:55:22 +04:00
|
|
|
slang_shutdown (void)
|
1998-02-27 07:54:42 +03:00
|
|
|
{
|
|
|
|
char *op_cap;
|
|
|
|
|
|
|
|
slang_shell_mode ();
|
|
|
|
do_exit_ca_mode ();
|
|
|
|
SLang_reset_tty ();
|
|
|
|
|
|
|
|
/* Load the op capability to reset the colors to those that were
|
|
|
|
* active when the program was started up
|
|
|
|
*/
|
|
|
|
op_cap = SLtt_tgetstr ("op");
|
|
|
|
if (op_cap){
|
|
|
|
fprintf (stdout, "%s", op_cap);
|
|
|
|
fflush (stdout);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* HP Terminals have capabilities (pfkey, pfloc, pfx) to program function keys.
|
|
|
|
elm 2.4pl15 invoked with the -K option utilizes these softkeys and the
|
|
|
|
consequence is that function keys don't work in MC sometimes.
|
|
|
|
Unfortunately I don't now the one and only escape sequence to turn off
|
|
|
|
softkeys (elm uses three different capabilities to turn on softkeys and two
|
|
|
|
capabilities to turn them off).
|
|
|
|
Among other things elm uses the pair we already use in slang_keypad. That's
|
|
|
|
the reason why I call slang_reset_softkeys from slang_keypad. In lack of
|
|
|
|
something better the softkeys are programmed to their defaults from the
|
|
|
|
termcap/terminfo database.
|
|
|
|
The escape sequence to program the softkeys is taken from elm and it is
|
|
|
|
hardcoded because neither slang nor ncurses 4.1 know how to 'printf' this
|
|
|
|
sequence. -- Norbert
|
|
|
|
*/
|
|
|
|
|
1998-12-03 00:27:27 +03:00
|
|
|
static void
|
1998-02-27 07:54:42 +03:00
|
|
|
slang_reset_softkeys (void)
|
|
|
|
{
|
|
|
|
int key;
|
|
|
|
char *send;
|
2003-01-25 00:36:29 +03:00
|
|
|
static const char display[] = " ";
|
Glibing..... (2)
Wed Jan 27 03:17:44 1999 Timur Bakeyev <mc@bat.ru>
* Converted memory managment to Glib. Now we use g_new()/g_malloc()/
g_strdup()/g_free() routings. Also, copy_strings() replaced by
g_strconcat(), strcasecmp() -> g_strcasecmp(),and sprintf() by
g_snprintf().
* Some sequences of malloc()/sprintf() changed to g_strdup_printf().
* mad.[ch]: Modified, to work with new GLib's memory managment. Fixed
a missing #undef for tempnam, which caused dead loop. Add several new
functions to emulate GLib memory managment.
*main.c, mad.[ch]: Add a new switch "-M", which allows to redirect MAD
messages to the file.
* util.[ch], utilunix.c: Modified, deleted our variants of strcasecmp()
and strdup() - we have g_ equivalences. Remove get_full_name() - it is
similar to concat_dir_and_file(). Some other tricks with g_* functions.
* global.h: Modified, extended. Now it is main memory mangment include -
i.e. all inclusions of <stdlib.h>, <malloc.h>, <glib.h>, "fs.h", "mem.h",
"util.h" and "mad.h" done there. This elimanates problem with proper or-
der of #include's.
* All around the source - changed order of #include's, most of them gone
to global.h (see above), minor changes, like "0" -> NULL in string func-
tions.
1999-01-27 04:08:30 +03:00
|
|
|
char tmp[BUF_SMALL];
|
2003-01-25 00:36:29 +03:00
|
|
|
|
|
|
|
for (key = 1; key < 9; key++) {
|
2009-02-06 01:49:00 +03:00
|
|
|
g_snprintf (tmp, sizeof (tmp), "k%d", key);
|
1998-02-27 07:54:42 +03:00
|
|
|
send = (char *) SLtt_tgetstr (tmp);
|
|
|
|
if (send) {
|
2009-02-06 01:49:00 +03:00
|
|
|
g_snprintf (tmp, sizeof (tmp), "\033&f%dk%dd%dL%s%s", key,
|
2003-01-25 00:36:29 +03:00
|
|
|
(int) (sizeof (display) - 1), (int) strlen (send),
|
|
|
|
display, send);
|
|
|
|
SLtt_write_string (tmp);
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* keypad routines */
|
|
|
|
void
|
|
|
|
slang_keypad (int set)
|
|
|
|
{
|
|
|
|
char *keypad_string;
|
|
|
|
extern int reset_hp_softkeys;
|
|
|
|
|
|
|
|
keypad_string = (char *) SLtt_tgetstr (set ? "ks" : "ke");
|
|
|
|
if (keypad_string)
|
|
|
|
SLtt_write_string (keypad_string);
|
|
|
|
if (set && reset_hp_softkeys)
|
|
|
|
slang_reset_softkeys ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
set_slang_delay (int v)
|
|
|
|
{
|
|
|
|
no_slang_delay = v;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
hline (int ch, int len)
|
|
|
|
{
|
|
|
|
int last_x, last_y;
|
|
|
|
|
|
|
|
last_x = SLsmg_get_column ();
|
|
|
|
last_y = SLsmg_get_row ();
|
|
|
|
|
|
|
|
if (ch == 0)
|
|
|
|
ch = ACS_HLINE;
|
|
|
|
|
|
|
|
if (ch == ACS_HLINE){
|
|
|
|
SLsmg_draw_hline (len);
|
|
|
|
} else {
|
|
|
|
while (len--)
|
|
|
|
addch (ch);
|
|
|
|
}
|
|
|
|
move (last_y, last_x);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
vline (int character, int len)
|
|
|
|
{
|
2009-04-24 02:47:22 +04:00
|
|
|
(void) character;
|
1998-02-27 07:54:42 +03:00
|
|
|
if (!slow_terminal){
|
|
|
|
SLsmg_draw_vline (len);
|
|
|
|
} else {
|
|
|
|
int last_x, last_y, pos = 0;
|
|
|
|
|
|
|
|
last_x = SLsmg_get_column ();
|
|
|
|
last_y = SLsmg_get_row ();
|
|
|
|
|
|
|
|
while (len--){
|
|
|
|
move (last_y + pos++, last_x);
|
|
|
|
addch (' ');
|
|
|
|
}
|
|
|
|
move (last_x, last_y);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-09-03 09:55:22 +04:00
|
|
|
int has_colors (void)
|
1998-02-27 07:54:42 +03:00
|
|
|
{
|
2004-09-25 17:46:23 +04:00
|
|
|
const char *terminal = getenv ("TERM");
|
1998-02-27 07:54:42 +03:00
|
|
|
char *cts = color_terminal_string, *s;
|
2004-08-16 07:12:05 +04:00
|
|
|
size_t i;
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2002-06-13 16:40:50 +04:00
|
|
|
if (force_colors)
|
|
|
|
SLtt_Use_Ansi_Colors = 1;
|
1998-02-27 07:54:42 +03:00
|
|
|
if (NULL != getenv ("COLORTERM"))
|
|
|
|
SLtt_Use_Ansi_Colors = 1;
|
|
|
|
|
|
|
|
/* We want to allow overwriding */
|
|
|
|
if (!disable_colors){
|
|
|
|
/* check color_terminal_string */
|
2002-07-15 10:01:29 +04:00
|
|
|
if (*cts)
|
1998-02-27 07:54:42 +03:00
|
|
|
{
|
|
|
|
while (*cts)
|
|
|
|
{
|
|
|
|
while (*cts == ' ' || *cts == '\t') cts++;
|
|
|
|
|
|
|
|
s = cts;
|
|
|
|
i = 0;
|
|
|
|
|
|
|
|
while (*cts && *cts != ',')
|
|
|
|
{
|
|
|
|
cts++;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
if (i && i == strlen(terminal) && strncmp(s, terminal, i) == 0)
|
|
|
|
SLtt_Use_Ansi_Colors = 1;
|
|
|
|
|
|
|
|
if (*cts == ',') cts++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Setup emulated colors */
|
|
|
|
if (SLtt_Use_Ansi_Colors){
|
|
|
|
if (use_colors){
|
2002-07-15 01:41:12 +04:00
|
|
|
mc_init_pair (A_REVERSE, "black", "white");
|
|
|
|
mc_init_pair (A_BOLD, "white", "black");
|
1998-02-27 07:54:42 +03:00
|
|
|
} else {
|
2002-07-15 01:41:12 +04:00
|
|
|
mc_init_pair (A_REVERSE, "black", "lightgray");
|
|
|
|
mc_init_pair (A_BOLD, "white", "black");
|
|
|
|
mc_init_pair (A_BOLD_REVERSE, "white", "lightgray");
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
SLtt_set_mono (A_BOLD, NULL, SLTT_BOLD_MASK);
|
|
|
|
SLtt_set_mono (A_REVERSE, NULL, SLTT_REV_MASK);
|
|
|
|
SLtt_set_mono (A_BOLD|A_REVERSE, NULL, SLTT_BOLD_MASK | SLTT_REV_MASK);
|
|
|
|
}
|
|
|
|
return SLtt_Use_Ansi_Colors;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
attrset (int color)
|
|
|
|
{
|
|
|
|
if (!SLtt_Use_Ansi_Colors){
|
|
|
|
SLsmg_set_color (color);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (color & A_BOLD){
|
|
|
|
if (color == A_BOLD)
|
|
|
|
SLsmg_set_color (A_BOLD);
|
|
|
|
else
|
|
|
|
SLsmg_set_color ((color & (~A_BOLD)) + 8);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (color == A_REVERSE)
|
|
|
|
SLsmg_set_color (A_REVERSE);
|
|
|
|
else
|
|
|
|
SLsmg_set_color (color);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* This table describes which capabilities we want and which values we
|
|
|
|
* assign to them.
|
|
|
|
*/
|
2001-11-07 16:35:57 +03:00
|
|
|
static const struct {
|
1998-02-27 07:54:42 +03:00
|
|
|
int key_code;
|
2004-08-30 03:27:40 +04:00
|
|
|
const char *key_name;
|
1998-02-27 07:54:42 +03:00
|
|
|
} key_table [] = {
|
|
|
|
{ KEY_F(0), "k0" },
|
|
|
|
{ KEY_F(1), "k1" },
|
|
|
|
{ KEY_F(2), "k2" },
|
|
|
|
{ KEY_F(3), "k3" },
|
|
|
|
{ KEY_F(4), "k4" },
|
|
|
|
{ KEY_F(5), "k5" },
|
|
|
|
{ KEY_F(6), "k6" },
|
|
|
|
{ KEY_F(7), "k7" },
|
|
|
|
{ KEY_F(8), "k8" },
|
|
|
|
{ KEY_F(9), "k9" },
|
|
|
|
{ KEY_F(10), "k;" },
|
|
|
|
{ KEY_F(11), "F1" },
|
|
|
|
{ KEY_F(12), "F2" },
|
|
|
|
{ KEY_F(13), "F3" },
|
|
|
|
{ KEY_F(14), "F4" },
|
|
|
|
{ KEY_F(15), "F5" },
|
|
|
|
{ KEY_F(16), "F6" },
|
|
|
|
{ KEY_F(17), "F7" },
|
|
|
|
{ KEY_F(18), "F8" },
|
|
|
|
{ KEY_F(19), "F9" },
|
|
|
|
{ KEY_F(20), "FA" },
|
|
|
|
{ KEY_IC, "kI" },
|
|
|
|
{ KEY_NPAGE, "kN" },
|
|
|
|
{ KEY_PPAGE, "kP" },
|
|
|
|
{ KEY_LEFT, "kl" },
|
|
|
|
{ KEY_RIGHT, "kr" },
|
|
|
|
{ KEY_UP, "ku" },
|
|
|
|
{ KEY_DOWN, "kd" },
|
|
|
|
{ KEY_DC, "kD" },
|
|
|
|
{ KEY_BACKSPACE, "kb" },
|
|
|
|
{ KEY_HOME, "kh" },
|
|
|
|
{ KEY_END, "@7" },
|
|
|
|
{ 0, 0}
|
|
|
|
};
|
|
|
|
|
2001-09-03 09:55:22 +04:00
|
|
|
static void
|
2004-08-30 03:27:40 +04:00
|
|
|
do_define_key (int code, const char *strcap)
|
1998-02-27 07:54:42 +03:00
|
|
|
{
|
|
|
|
char *seq;
|
|
|
|
|
2004-09-01 03:34:18 +04:00
|
|
|
seq = (char *) SLtt_tgetstr ((char*) strcap);
|
1998-02-27 07:54:42 +03:00
|
|
|
if (seq)
|
|
|
|
define_sequence (code, seq, MCKEY_NOACTION);
|
|
|
|
}
|
|
|
|
|
2001-09-03 09:55:22 +04:00
|
|
|
static void
|
|
|
|
load_terminfo_keys (void)
|
1998-02-27 07:54:42 +03:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; key_table [i].key_code; i++)
|
|
|
|
do_define_key (key_table [i].key_code, key_table [i].key_name);
|
|
|
|
}
|
|
|
|
|
2002-11-29 00:35:49 +03:00
|
|
|
int
|
|
|
|
getch (void)
|
1998-02-27 07:54:42 +03:00
|
|
|
{
|
1999-04-13 23:21:03 +04:00
|
|
|
int c;
|
1998-02-27 07:54:42 +03:00
|
|
|
if (no_slang_delay)
|
2009-02-04 22:37:00 +03:00
|
|
|
if (SLang_input_pending2 (0) == 0)
|
1998-02-27 07:54:42 +03:00
|
|
|
return -1;
|
|
|
|
|
2009-02-04 22:37:00 +03:00
|
|
|
c = SLang_getkey2 ();
|
1999-04-13 23:21:03 +04:00
|
|
|
if (c == SLANG_GETKEY_ERROR) {
|
2002-11-29 00:35:49 +03:00
|
|
|
fprintf (stderr,
|
|
|
|
"SLang_getkey returned SLANG_GETKEY_ERROR\n"
|
|
|
|
"Assuming EOF on stdin and exiting\n");
|
2003-02-03 21:00:34 +03:00
|
|
|
exit (1);
|
1999-04-13 23:21:03 +04:00
|
|
|
}
|
2002-11-29 00:35:49 +03:00
|
|
|
return c;
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
#endif /* HAVE_SLANG */
|
|
|
|
|
|
|
|
void
|
|
|
|
mc_refresh (void)
|
|
|
|
{
|
2003-10-27 20:34:57 +03:00
|
|
|
#ifdef WITH_BACKGROUND
|
|
|
|
if (!we_are_background)
|
|
|
|
#endif /* WITH_BACKGROUND */
|
1998-02-27 07:54:42 +03:00
|
|
|
refresh ();
|
|
|
|
}
|