2009-05-10 19:01:15 +04:00
|
|
|
|
|
|
|
/** \file
|
|
|
|
* \brief Source: S-Lang-based tty layer of Midnight Commander
|
2009-02-05 21:28:18 +03:00
|
|
|
*/
|
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
#include <config.h>
|
2005-02-08 12:04:03 +03:00
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2005-02-08 12:04:03 +03:00
|
|
|
#ifdef HAVE_TERMIOS_H
|
|
|
|
#include <termios.h>
|
|
|
|
#endif
|
|
|
|
#include <unistd.h>
|
2009-05-10 19:01:15 +04:00
|
|
|
#include <sys/types.h> /* size_t */
|
2005-02-08 12:04:03 +03:00
|
|
|
|
2009-05-08 14:01:05 +04:00
|
|
|
#include "../../src/global.h"
|
|
|
|
|
2009-05-14 19:18:03 +04:00
|
|
|
#include "../../src/tty/tty.h" /* tty_is_ugly_line_drawing() */
|
|
|
|
#include "../../src/tty/color-slang.h"
|
2009-05-13 17:05:55 +04:00
|
|
|
#include "../../src/tty/color-internal.h"
|
2009-05-08 14:01:05 +04:00
|
|
|
#include "../../src/tty/mouse.h" /* Gpm_Event is required in key.h */
|
|
|
|
#include "../../src/tty/key.h" /* define_sequence */
|
2009-05-13 17:05:55 +04:00
|
|
|
#include "../../src/tty/win.h"
|
2009-05-08 14:01:05 +04:00
|
|
|
|
2009-05-10 19:01:15 +04:00
|
|
|
#include "../../src/background.h" /* we_are_background */
|
2009-05-13 17:05:55 +04:00
|
|
|
#include "../../src/main.h" /* for slow_terminal */
|
2009-05-10 19:01:15 +04:00
|
|
|
#include "../../src/util.h" /* str_unconst */
|
|
|
|
#include "../../src/strutil.h" /* str_term_form */
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2009-05-10 19:01:15 +04:00
|
|
|
/*** global variables **************************************************/
|
2009-05-31 16:23:10 +04:00
|
|
|
extern int reset_hp_softkeys;
|
2009-05-10 19:01:15 +04:00
|
|
|
|
|
|
|
/*** file scope macro definitions **************************************/
|
1998-02-27 07:54:42 +03:00
|
|
|
|
|
|
|
/* Taken from S-Lang's slutty.c */
|
|
|
|
#ifdef ultrix /* Ultrix gets _POSIX_VDISABLE wrong! */
|
2009-05-10 19:01:15 +04:00
|
|
|
# define NULL_VALUE -1
|
1998-02-27 07:54:42 +03:00
|
|
|
#else
|
2009-05-10 19:01:15 +04:00
|
|
|
# ifdef _POSIX_VDISABLE
|
|
|
|
# define NULL_VALUE _POSIX_VDISABLE
|
|
|
|
# else
|
|
|
|
# define NULL_VALUE 255
|
|
|
|
# endif
|
|
|
|
#endif /* ultrix */
|
1998-02-27 07:54:42 +03:00
|
|
|
|
|
|
|
#ifndef SA_RESTART
|
2009-05-10 19:01:15 +04:00
|
|
|
# define SA_RESTART 0
|
1998-02-27 07:54:42 +03:00
|
|
|
#endif
|
|
|
|
|
2009-05-10 19:01:15 +04:00
|
|
|
/*** file scope type declarations **************************************/
|
|
|
|
|
|
|
|
/*** file scope variables **********************************************/
|
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
/* 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 */
|
2009-05-31 16:23:10 +04:00
|
|
|
static gboolean no_slang_delay;
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2009-05-10 19:01:15 +04:00
|
|
|
/* This table describes which capabilities we want and which values we
|
|
|
|
* assign to them.
|
|
|
|
*/
|
|
|
|
static const struct {
|
|
|
|
int key_code;
|
|
|
|
const char *key_name;
|
|
|
|
} 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, NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
/*** file scope functions **********************************************/
|
2005-03-19 22:31:23 +03:00
|
|
|
|
2009-02-04 22:37:00 +03:00
|
|
|
#ifndef HAVE_SLANG_PRIVATE
|
2009-05-10 19:01:15 +04:00
|
|
|
/* Private interfaces have been stripped, so we cannot use them */
|
|
|
|
# define SLang_getkey2() SLang_getkey ()
|
|
|
|
# define SLang_input_pending2(s) SLang_input_pending (s)
|
2009-02-04 22:37:00 +03:00
|
|
|
#else
|
2009-05-10 19:01:15 +04:00
|
|
|
static unsigned int
|
|
|
|
SLang_getkey2 (void)
|
2009-02-04 22:37:00 +03:00
|
|
|
{
|
2009-05-10 19:01:15 +04:00
|
|
|
if (SLang_Input_Buffer_Len) {
|
|
|
|
unsigned int ch;
|
|
|
|
unsigned int imax;
|
|
|
|
|
2009-02-04 22:37:00 +03:00
|
|
|
ch = (unsigned int) *SLang_Input_Buffer;
|
|
|
|
SLang_Input_Buffer_Len--;
|
|
|
|
imax = SLang_Input_Buffer_Len;
|
2009-05-10 19:01:15 +04:00
|
|
|
|
|
|
|
memmove ((char *) SLang_Input_Buffer,
|
2009-02-04 22:37:00 +03:00
|
|
|
(char *) (SLang_Input_Buffer + 1), imax);
|
2009-05-10 19:01:15 +04:00
|
|
|
|
|
|
|
return ch;
|
2009-02-04 22:37:00 +03:00
|
|
|
}
|
2009-05-10 19:01:15 +04:00
|
|
|
|
2009-02-04 22:37:00 +03:00
|
|
|
#if SLANG_VERSION >= 10000
|
2009-05-10 19:01:15 +04:00
|
|
|
return _SLsys_getkey ();
|
2009-02-04 22:37:00 +03:00
|
|
|
#else
|
2009-05-10 19:01:15 +04:00
|
|
|
return SLsys_getkey();
|
2009-02-04 22:37:00 +03:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2009-05-10 19:01:15 +04:00
|
|
|
static int
|
|
|
|
SLang_input_pending2 (int tsecs)
|
2009-02-04 22:37:00 +03:00
|
|
|
{
|
2009-05-10 19:01:15 +04:00
|
|
|
int n, i;
|
|
|
|
unsigned char c;
|
2009-02-04 22:37:00 +03:00
|
|
|
|
2009-05-10 19:01:15 +04:00
|
|
|
if (SLang_Input_Buffer_Len)
|
|
|
|
return (int) SLang_Input_Buffer_Len;
|
|
|
|
#if SLANG_VERSION >= 10000
|
|
|
|
n = _SLsys_input_pending (tsecs);
|
2009-02-04 22:37:00 +03:00
|
|
|
#else
|
2009-05-10 19:01:15 +04:00
|
|
|
n = SLsys_input_pending (tsecs);
|
2009-02-04 22:37:00 +03:00
|
|
|
#endif
|
2009-05-10 19:01:15 +04:00
|
|
|
if (n <= 0)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
i = SLang_getkey2 ();
|
|
|
|
if (i == SLANG_GETKEY_ERROR)
|
2009-02-04 22:37:00 +03:00
|
|
|
return 0; /* don't put crippled error codes into the input buffer */
|
2009-05-10 19:01:15 +04:00
|
|
|
|
|
|
|
c = (unsigned char) i;
|
|
|
|
SLang_ungetkey_string (&c, 1);
|
|
|
|
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* HAVE_SLANG_PRIVATE */
|
|
|
|
|
|
|
|
|
|
|
|
/* 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
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void
|
|
|
|
slang_reset_softkeys (void)
|
|
|
|
{
|
|
|
|
int key;
|
|
|
|
char *send;
|
|
|
|
static const char display[] = " ";
|
|
|
|
char tmp[BUF_SMALL];
|
|
|
|
|
|
|
|
for (key = 1; key < 9; key++) {
|
|
|
|
g_snprintf (tmp, sizeof (tmp), "k%d", key);
|
|
|
|
send = (char *) SLtt_tgetstr (tmp);
|
|
|
|
if (send != NULL) {
|
|
|
|
g_snprintf (tmp, sizeof (tmp), "\033&f%dk%dd%dL%s%s", key,
|
|
|
|
(int) (sizeof (display) - 1), (int) strlen (send),
|
|
|
|
display, send);
|
|
|
|
SLtt_write_string (tmp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
do_define_key (int code, const char *strcap)
|
|
|
|
{
|
|
|
|
char *seq;
|
|
|
|
|
|
|
|
seq = (char *) SLtt_tgetstr ((char *) strcap);
|
|
|
|
if (seq != NULL)
|
|
|
|
define_sequence (code, seq, MCKEY_NOACTION);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
load_terminfo_keys (void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; key_table [i].key_code; i++)
|
|
|
|
do_define_key (key_table [i].key_code, key_table [i].key_name);
|
2009-02-04 22:37:00 +03:00
|
|
|
}
|
|
|
|
|
2009-05-10 19:01:15 +04:00
|
|
|
/*** public functions **************************************************/
|
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
void
|
2009-05-13 17:05:55 +04:00
|
|
|
init_slang (void)
|
1998-02-27 07:54:42 +03:00
|
|
|
{
|
|
|
|
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.
|
|
|
|
*/
|
2009-05-10 19:01:15 +04: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,
|
2009-05-10 19:01:15 +04:00
|
|
|
_("Screen size %dx%d is not supported.\n"
|
|
|
|
"Check the TERM environment variable.\n"),
|
|
|
|
COLS, LINES);
|
2001-06-13 10:53:08 +04:00
|
|
|
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 */
|
2009-05-10 19:01:15 +04:00
|
|
|
SLang_init_tty (XCTRL('c'), 1, 0);
|
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
/* 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);
|
|
|
|
|
2009-05-13 17:05:55 +04:00
|
|
|
if (tty_is_ugly_line_drawing ())
|
1998-02-27 07:54:42 +03:00
|
|
|
SLtt_Has_Alt_Charset = 0;
|
|
|
|
if (tcgetattr (SLang_TT_Read_FD, &new_mode) == 0) {
|
|
|
|
#ifdef VDSUSP
|
2009-05-10 19:01:15 +04:00
|
|
|
new_mode.c_cc[VDSUSP] = NULL_VALUE; /* to ignore ^Y */
|
1998-02-27 07:54:42 +03:00
|
|
|
#endif
|
|
|
|
#ifdef VLNEXT
|
2009-05-10 19:01:15 +04:00
|
|
|
new_mode.c_cc[VLNEXT] = NULL_VALUE; /* to ignore ^V */
|
1998-02-27 07:54:42 +03:00
|
|
|
#endif
|
|
|
|
tcsetattr (SLang_TT_Read_FD, TCSADRAIN, &new_mode);
|
|
|
|
}
|
2009-05-10 19:01:15 +04:00
|
|
|
|
2009-05-31 16:23:10 +04:00
|
|
|
tty_reset_prog_mode ();
|
1998-02-27 07:54:42 +03:00
|
|
|
load_terminfo_keys ();
|
|
|
|
SLtt_Blink_Mode = 0;
|
|
|
|
}
|
|
|
|
|
2009-05-31 16:23:10 +04:00
|
|
|
/* Done each time we come back from done mode */
|
|
|
|
void
|
|
|
|
tty_reset_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
|
|
|
|
tty_reset_shell_mode (void)
|
|
|
|
{
|
|
|
|
tcsetattr (SLang_TT_Read_FD, TCSANOW, &boot_mode);
|
|
|
|
}
|
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
void
|
2009-05-19 20:12:29 +04:00
|
|
|
tty_raw_mode (void)
|
1998-02-27 07:54:42 +03:00
|
|
|
{
|
|
|
|
tcsetattr (SLang_TT_Read_FD, TCSANOW, &new_mode);
|
|
|
|
}
|
|
|
|
|
2009-05-19 20:12:29 +04:00
|
|
|
void
|
|
|
|
tty_noraw_mode (void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
void
|
2009-05-31 16:23:10 +04:00
|
|
|
tty_keypad (gboolean set)
|
1998-02-27 07:54:42 +03:00
|
|
|
{
|
2009-05-31 16:23:10 +04:00
|
|
|
char *keypad_string;
|
|
|
|
|
|
|
|
keypad_string = (char *) SLtt_tgetstr ((char *) (set ? "ks" : "ke"));
|
|
|
|
if (keypad_string != NULL)
|
|
|
|
SLtt_write_string (keypad_string);
|
|
|
|
if (set && reset_hp_softkeys)
|
|
|
|
slang_reset_softkeys ();
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-05-31 16:23:10 +04:00
|
|
|
tty_nodelay (gboolean set)
|
1998-02-27 07:54:42 +03:00
|
|
|
{
|
2009-05-31 16:23:10 +04:00
|
|
|
no_slang_delay = set;
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-09-03 09:55:22 +04:00
|
|
|
slang_shutdown (void)
|
1998-02-27 07:54:42 +03:00
|
|
|
{
|
|
|
|
char *op_cap;
|
2009-05-10 19:01:15 +04:00
|
|
|
|
2009-05-31 16:23:10 +04:00
|
|
|
tty_reset_shell_mode ();
|
1998-02-27 07:54:42 +03:00
|
|
|
do_exit_ca_mode ();
|
|
|
|
SLang_reset_tty ();
|
|
|
|
|
2009-05-10 19:01:15 +04:00
|
|
|
/* Load the op capability to reset the colors to those that were
|
|
|
|
* active when the program was started up
|
1998-02-27 07:54:42 +03:00
|
|
|
*/
|
2009-05-31 16:23:10 +04:00
|
|
|
op_cap = SLtt_tgetstr ((char *) "op");
|
2009-05-10 19:01:15 +04:00
|
|
|
if (op_cap != NULL) {
|
2009-07-15 22:53:13 +04:00
|
|
|
fputs (op_cap, stdout);
|
1998-02-27 07:54:42 +03:00
|
|
|
fflush (stdout);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-13 17:05:55 +04:00
|
|
|
void
|
|
|
|
init_curses (void)
|
|
|
|
{
|
|
|
|
SLsmg_init_smg ();
|
|
|
|
do_enter_ca_mode ();
|
2009-05-14 19:18:03 +04:00
|
|
|
tty_init_colors ();
|
2009-05-31 16:23:10 +04:00
|
|
|
tty_keypad (TRUE);
|
|
|
|
tty_nodelay (FALSE);
|
2009-05-13 17:05:55 +04:00
|
|
|
}
|
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
void
|
|
|
|
hline (int ch, int len)
|
|
|
|
{
|
|
|
|
int last_x, last_y;
|
|
|
|
|
|
|
|
last_x = SLsmg_get_column ();
|
|
|
|
last_y = SLsmg_get_row ();
|
2009-05-10 19:01:15 +04:00
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
if (ch == 0)
|
|
|
|
ch = ACS_HLINE;
|
|
|
|
|
2009-05-10 19:01:15 +04:00
|
|
|
if (ch == ACS_HLINE)
|
1998-02-27 07:54:42 +03:00
|
|
|
SLsmg_draw_hline (len);
|
2009-05-10 19:01:15 +04:00
|
|
|
else
|
1998-02-27 07:54:42 +03:00
|
|
|
while (len--)
|
2009-05-29 19:30:45 +04:00
|
|
|
tty_print_char (ch);
|
2009-05-10 19:01:15 +04:00
|
|
|
|
|
|
|
SLsmg_gotorc (last_y, last_x);
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
vline (int character, int len)
|
|
|
|
{
|
2009-04-24 02:47:22 +04:00
|
|
|
(void) character;
|
2009-05-10 19:01:15 +04:00
|
|
|
|
|
|
|
if (!slow_terminal)
|
1998-02-27 07:54:42 +03:00
|
|
|
SLsmg_draw_vline (len);
|
2009-05-10 19:01:15 +04:00
|
|
|
else {
|
1998-02-27 07:54:42 +03:00
|
|
|
int last_x, last_y, pos = 0;
|
|
|
|
|
|
|
|
last_x = SLsmg_get_column ();
|
|
|
|
last_y = SLsmg_get_row ();
|
|
|
|
|
2009-05-10 19:01:15 +04:00
|
|
|
while (len--) {
|
2009-05-11 16:13:58 +04:00
|
|
|
SLsmg_gotorc (last_y + pos, last_x);
|
2009-05-29 19:30:45 +04:00
|
|
|
tty_print_char (' ');
|
2009-05-11 16:13:58 +04:00
|
|
|
pos++;
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
2009-05-10 19:01:15 +04:00
|
|
|
|
|
|
|
SLsmg_gotorc (last_x, last_y);
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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;
|
2009-05-10 19:01:15 +04:00
|
|
|
|
|
|
|
if (no_slang_delay
|
|
|
|
&& (SLang_input_pending2 (0) == 0))
|
|
|
|
return -1;
|
1998-02-27 07:54:42 +03:00
|
|
|
|
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,
|
2009-05-10 19:01:15 +04:00
|
|
|
"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
|
|
|
}
|
2009-05-10 19:01:15 +04:00
|
|
|
|
2002-11-29 00:35:49 +03:00
|
|
|
return c;
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
2009-05-10 19:01:15 +04:00
|
|
|
|
|
|
|
void
|
|
|
|
tty_gotoyx (int y, int x)
|
|
|
|
{
|
|
|
|
SLsmg_gotorc (y, x);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
tty_getyx (int *py, int *px)
|
|
|
|
{
|
|
|
|
*py = SLsmg_get_row ();
|
2009-05-11 16:13:58 +04:00
|
|
|
*px = SLsmg_get_column ();
|
2009-05-10 19:01:15 +04:00
|
|
|
}
|
|
|
|
|
2009-05-11 18:43:00 +04:00
|
|
|
void
|
|
|
|
tty_draw_box (int y, int x, int rows, int cols)
|
|
|
|
{
|
|
|
|
SLsmg_draw_box (y, x, rows, cols);
|
|
|
|
}
|
|
|
|
|
2009-05-26 18:56:42 +04:00
|
|
|
void
|
|
|
|
tty_fill_region (int y, int x, int rows, int cols, unsigned char ch)
|
|
|
|
{
|
|
|
|
SLsmg_fill_region (y, x, rows, cols, ch);
|
|
|
|
}
|
|
|
|
|
2009-05-10 19:01:15 +04:00
|
|
|
void
|
|
|
|
tty_print_char (int c)
|
|
|
|
{
|
2009-05-29 19:30:45 +04:00
|
|
|
SLsmg_write_char ((SLwchar_Type) ((unsigned int) c));
|
2009-05-10 19:01:15 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
tty_print_alt_char (int c)
|
|
|
|
{
|
|
|
|
SLsmg_draw_object (SLsmg_get_row(), SLsmg_get_column(), c);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
tty_print_string (const char *s)
|
|
|
|
{
|
|
|
|
SLsmg_write_string (str_unconst (str_term_form (s)));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
tty_printf (const char *fmt, ...)
|
|
|
|
{
|
|
|
|
va_list args;
|
|
|
|
|
2009-05-13 12:38:11 +04:00
|
|
|
va_start (args, fmt);
|
2009-05-10 19:01:15 +04:00
|
|
|
SLsmg_vprintf (str_unconst(fmt), args);
|
|
|
|
va_end (args);
|
|
|
|
}
|
|
|
|
|
|
|
|
char *
|
|
|
|
tty_tgetstr (const char *cap)
|
|
|
|
{
|
|
|
|
return SLtt_tgetstr (str_unconst (cap));
|
|
|
|
}
|
1998-02-27 07:54:42 +03:00
|
|
|
|
|
|
|
void
|
2009-05-13 12:38:11 +04:00
|
|
|
tty_refresh (void)
|
1998-02-27 07:54:42 +03:00
|
|
|
{
|
2003-10-27 20:34:57 +03:00
|
|
|
#ifdef WITH_BACKGROUND
|
|
|
|
if (!we_are_background)
|
|
|
|
#endif /* WITH_BACKGROUND */
|
2009-05-10 19:01:15 +04:00
|
|
|
SLsmg_refresh ();
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
2009-05-31 16:23:10 +04:00
|
|
|
|
|
|
|
void
|
|
|
|
tty_beep (void)
|
|
|
|
{
|
|
|
|
SLtt_beep ();
|
|
|
|
}
|