New functions.

tty_noecho() is used instead of noecho() function or macro.
tty_flush_input() is used instead of flushinp() function or macro.
tty_reset_screen() is used instead of endwin() function or macro.
tty_shutdown() is based on slang_shutdown(). Also implemented for
NCurses as wrapper for endwin().
This commit is contained in:
Andrew Borodin 2009-06-02 21:40:37 +04:00
parent 55e626726c
commit 16a15c0ee2
7 changed files with 84 additions and 45 deletions

View File

@ -48,7 +48,7 @@ edition_post_exec (void)
/* FIXME: Missing on slang endwin? */
tty_reset_prog_mode ();
flushinp ();
tty_flush_input ();
tty_keypad (TRUE);
tty_raw_mode ();
@ -74,7 +74,7 @@ edition_pre_exec (void)
tty_reset_shell_mode ();
tty_keypad (FALSE);
endwin ();
tty_reset_screen ();
numeric_keypad_mode ();
@ -234,10 +234,10 @@ toggle_panels (void)
* is no tty_raw_mode supported
*/
tty_reset_shell_mode ();
noecho ();
#endif /* !HAVE_SLANG */
tty_noecho ();
tty_keypad (FALSE);
endwin ();
tty_reset_screen ();
do_exit_ca_mode ();
tty_raw_mode ();
if (console_flag)

View File

@ -722,7 +722,7 @@ change_screen_size (void)
#ifndef NCURSES_VERSION
tty_noraw_mode ();
endwin ();
tty_reset_screen ();
#endif
low_level_change_screen_size ();
check_split ();

View File

@ -2371,10 +2371,7 @@ main (int argc, char *argv[])
flush_extension_file (); /* does only free memory */
endwin ();
#ifdef HAVE_SLANG
slang_shutdown ();
#endif
tty_shutdown ();
if (console_flag && !(quit & SUBSHELL_EXIT))
handle_console (CONSOLE_RESTORE);

View File

@ -92,6 +92,12 @@ init_curses (void)
}
}
void
tty_shutdown (void)
{
endwin ();
}
void
tty_reset_prog_mode (void)
{
@ -116,6 +122,18 @@ tty_noraw_mode (void)
noraw ();
}
void
tty_noecho (void)
{
noecho ();
}
int
tty_flush_input (void)
{
return flushinp ();
}
void
tty_keypad (gboolean set)
{
@ -134,6 +152,12 @@ tty_baudrate (void)
return baudrate();
}
int
tty_reset_screen (void)
{
return endwin ();
}
void
tty_touch_screen (void)
{

View File

@ -217,6 +217,16 @@ load_terminfo_keys (void)
/*** public functions **************************************************/
void
init_curses (void)
{
SLsmg_init_smg ();
do_enter_ca_mode ();
tty_init_colors ();
tty_keypad (TRUE);
tty_nodelay (FALSE);
}
void
init_slang (void)
{
@ -269,6 +279,26 @@ init_slang (void)
SLtt_Blink_Mode = 0;
}
void
tty_shutdown (void)
{
char *op_cap;
SLsmg_reset_smg ();
tty_reset_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 ((char *) "op");
if (op_cap != NULL){
fputs (op_cap, stdout);
fflush (stdout);
}
}
/* Done each time we come back from done mode */
void
tty_reset_prog_mode (void)
@ -296,6 +326,17 @@ tty_noraw_mode (void)
{
}
void
tty_noecho (void)
{
}
int
tty_flush_input (void)
{
return 0; /* OK */
}
void
tty_keypad (gboolean set)
{
@ -320,35 +361,6 @@ tty_baudrate (void)
return SLang_TT_Baud_Rate;
}
void
slang_shutdown (void)
{
char *op_cap;
tty_reset_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 ((char *) "op");
if (op_cap != NULL) {
fputs (op_cap, stdout);
fflush (stdout);
}
}
void
init_curses (void)
{
SLsmg_init_smg ();
do_enter_ca_mode ();
tty_init_colors ();
tty_keypad (TRUE);
tty_nodelay (FALSE);
}
void
hline (int ch, int len)
{
@ -412,6 +424,13 @@ getch (void)
return c;
}
int
tty_reset_screen (void)
{
SLsmg_reset_smg ();
return 0; /* OK */
}
void
tty_touch_screen (void)
{

View File

@ -26,22 +26,15 @@ enum {
#define ACS_URCORNER SLSMG_URCORN_CHAR
#define ACS_LRCORNER SLSMG_LRCORN_CHAR
#define noecho()
#define ungetch(x) SLang_ungetkey (x)
#define flushinp()
void init_slang (void);
void init_curses (void);
void hline (int ch, int len);
void vline (int ch, int len);
int getch (void);
void slang_shutdown (void);
#define printw SLsmg_printf
#define COLS SLtt_Screen_Cols
#define LINES SLtt_Screen_Rows
#define endwin() SLsmg_reset_smg ()
#define SLsmg_draw_double_box(r, c, dr, dc) SLsmg_draw_box ((r), (c), (dr), (dc))

View File

@ -32,10 +32,15 @@ extern void tty_reset_shell_mode (void);
extern void tty_raw_mode (void);
extern void tty_noraw_mode (void);
extern void tty_noecho (void);
extern int tty_flush_input (void);
extern void tty_keypad (gboolean set);
extern void tty_nodelay (gboolean set);
extern int tty_baudrate (void);
extern void tty_shutdown (void);
/* {{{ Output }}} */
/*
@ -44,6 +49,7 @@ extern int tty_baudrate (void);
While SLang provides such a feature, ncurses does not.
*/
extern int tty_reset_screen (void);
extern void tty_touch_screen (void);
extern void tty_gotoyx(int y, int x);