From c10a88008c23a821d4c7f58799421f147a868450 Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Thu, 14 Dec 2017 00:35:10 +0100 Subject: [PATCH] Add Sun Microsystems workstation console support --- ChangeLog | 3 + config.h.in | 24 +++++ configure | 22 ++++ configure.ac | 11 ++ doc/Makefile.in | 4 +- examples/Makefile.in | 4 +- fonts/Makefile.in | 4 +- include/final/fconfig.h | 40 +++++++ include/final/fterm.h | 15 ++- src/Makefile.in | 4 +- src/fterm.cpp | 230 ++++++++++++++++++++++++++-------------- src/fvterm.cpp | 4 +- 12 files changed, 272 insertions(+), 93 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0f46851c..cdd20daf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2017-12-14 Markus Gans + * Add Sun Microsystems workstation console support + 2017-12-10 Markus Gans * Refactoring of the FMenu mouse event handler diff --git a/config.h.in b/config.h.in index 44727074..04be9dea 100644 --- a/config.h.in +++ b/config.h.in @@ -15,6 +15,15 @@ /* Define to 1 if you have the header file. */ #undef HAVE_FCNTL_H +/* Define to 1 if you have the `geteuid' function. */ +#undef HAVE_GETEUID + +/* Define to 1 if you have the `getttynam' function. */ +#undef HAVE_GETTTYNAM + +/* Define to 1 if you have the `getuid' function. */ +#undef HAVE_GETUID + /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H @@ -39,18 +48,27 @@ /* Define to 1 if you have the header file. */ #undef HAVE_QUEUE +/* Define to 1 if you have the `select' function. */ +#undef HAVE_SELECT + /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H +/* Define to 1 if you have the `strdup' function. */ +#undef HAVE_STRDUP + /* Define to 1 if you have the header file. */ #undef HAVE_STRINGS_H /* Define to 1 if you have the header file. */ #undef HAVE_STRING_H +/* Define to 1 if you have the `strstr' function. */ +#undef HAVE_STRSTR + /* Define to 1 if you have the header file. */ #undef HAVE_SYS_IO_H @@ -72,12 +90,18 @@ /* Define to 1 if you have the header file. */ #undef HAVE_TERM_H +/* Define to 1 if you have the header file. */ +#undef HAVE_TTYENT_H + /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H /* Define to 1 if you have the header file. */ #undef HAVE_VECTOR +/* Define to 1 if you have the `vsnprintf' function. */ +#undef HAVE_VSNPRINTF + /* Define to the sub-directory in which libtool stores uninstalled libraries. */ #undef LT_OBJDIR diff --git a/configure b/configure index 94a7162b..824d867f 100755 --- a/configure +++ b/configure @@ -4799,6 +4799,7 @@ for ac_header in \ langinfo.h \ term.h \ termios.h \ + ttyent.h \ unistd.h \ cmath \ csignal \ @@ -4820,6 +4821,27 @@ fi done +# Checks for library functions. +for ac_func in \ + getuid \ + geteuid \ + getttynam \ + select \ + strdup \ + strstr \ + vsnprintf +do : + as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` +ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" +if eval test \"x\$"$as_ac_var"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + + # Checks for 'tgetent' { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing tgetent" >&5 $as_echo_n "checking for library containing tgetent... " >&6; } diff --git a/configure.ac b/configure.ac index e2b6c6bb..ab2b6c55 100644 --- a/configure.ac +++ b/configure.ac @@ -24,6 +24,7 @@ AC_CHECK_HEADERS( \ langinfo.h \ term.h \ termios.h \ + ttyent.h \ unistd.h \ cmath \ csignal \ @@ -33,6 +34,16 @@ AC_CHECK_HEADERS( \ queue \ vector) +# Checks for library functions. +AC_CHECK_FUNCS( \ + getuid \ + geteuid \ + getttynam \ + select \ + strdup \ + strstr \ + vsnprintf ) + # Checks for 'tgetent' AC_SEARCH_LIBS([tgetent], [termcap tinfo curses ncurses]) # Checks for 'tparm' diff --git a/doc/Makefile.in b/doc/Makefile.in index 6219f685..a4339ff2 100644 --- a/doc/Makefile.in +++ b/doc/Makefile.in @@ -320,9 +320,9 @@ $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) exit 1;; \ esac; \ done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign doc/Makefile'; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu doc/Makefile'; \ $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --foreign doc/Makefile + $(AUTOMAKE) --gnu doc/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ diff --git a/examples/Makefile.in b/examples/Makefile.in index 16b396a9..4a9bb8a2 100644 --- a/examples/Makefile.in +++ b/examples/Makefile.in @@ -411,9 +411,9 @@ $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) exit 1;; \ esac; \ done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign examples/Makefile'; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu examples/Makefile'; \ $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --foreign examples/Makefile + $(AUTOMAKE) --gnu examples/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ diff --git a/fonts/Makefile.in b/fonts/Makefile.in index 4200e618..f69e2f96 100644 --- a/fonts/Makefile.in +++ b/fonts/Makefile.in @@ -264,9 +264,9 @@ $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) exit 1;; \ esac; \ done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign fonts/Makefile'; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu fonts/Makefile'; \ $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --foreign fonts/Makefile + $(AUTOMAKE) --gnu fonts/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ diff --git a/include/final/fconfig.h b/include/final/fconfig.h index f1a8357d..a7d7dd4f 100644 --- a/include/final/fconfig.h +++ b/include/final/fconfig.h @@ -24,6 +24,21 @@ #define F_HAVE_FCNTL_H 1 #endif +/* Define to 1 if you have the `geteuid' function. */ +#ifndef F_HAVE_GETEUID +#define F_HAVE_GETEUID 1 +#endif + +/* Define to 1 if you have the `getttynam' function. */ +#ifndef F_HAVE_GETTTYNAM +#define F_HAVE_GETTTYNAM 1 +#endif + +/* Define to 1 if you have the `getuid' function. */ +#ifndef F_HAVE_GETUID +#define F_HAVE_GETUID 1 +#endif + /* Define to 1 if you have the header file. */ #ifndef F_HAVE_INTTYPES_H #define F_HAVE_INTTYPES_H 1 @@ -58,6 +73,11 @@ /* Define to 1 if you have the header file. */ /* #undef HAVE_QUEUE */ +/* Define to 1 if you have the `select' function. */ +#ifndef F_HAVE_SELECT +#define F_HAVE_SELECT 1 +#endif + /* Define to 1 if you have the header file. */ #ifndef F_HAVE_STDINT_H #define F_HAVE_STDINT_H 1 @@ -68,6 +88,11 @@ #define F_HAVE_STDLIB_H 1 #endif +/* Define to 1 if you have the `strdup' function. */ +#ifndef F_HAVE_STRDUP +#define F_HAVE_STRDUP 1 +#endif + /* Define to 1 if you have the header file. */ #ifndef F_HAVE_STRINGS_H #define F_HAVE_STRINGS_H 1 @@ -78,6 +103,11 @@ #define F_HAVE_STRING_H 1 #endif +/* Define to 1 if you have the `strstr' function. */ +#ifndef F_HAVE_STRSTR +#define F_HAVE_STRSTR 1 +#endif + /* Define to 1 if you have the header file. */ #ifndef F_HAVE_SYS_IO_H #define F_HAVE_SYS_IO_H 1 @@ -113,6 +143,11 @@ #define F_HAVE_TERM_H 1 #endif +/* Define to 1 if you have the header file. */ +#ifndef F_HAVE_TTYENT_H +#define F_HAVE_TTYENT_H 1 +#endif + /* Define to 1 if you have the header file. */ #ifndef F_HAVE_UNISTD_H #define F_HAVE_UNISTD_H 1 @@ -121,6 +156,11 @@ /* Define to 1 if you have the header file. */ /* #undef HAVE_VECTOR */ +/* Define to 1 if you have the `vsnprintf' function. */ +#ifndef F_HAVE_VSNPRINTF +#define F_HAVE_VSNPRINTF 1 +#endif + /* Define to the sub-directory in which libtool stores uninstalled libraries. */ #ifndef F_LT_OBJDIR diff --git a/include/final/fterm.h b/include/final/fterm.h index f8a14c39..7f571532 100644 --- a/include/final/fterm.h +++ b/include/final/fterm.h @@ -85,7 +85,12 @@ #include #include // termcap #include -#include + +#if F_HAVE_GETTTYNAM && F_HAVE_TTYENT_H + #include +#endif + + #include #include @@ -188,6 +193,7 @@ class FTerm static bool isGnomeTerminal(); static bool isKtermTerminal(); static bool isTeraTerm(); + static bool isSunTerminal(); static bool isCygwinTerminal(); static bool isMinttyTerm(); static bool isLinuxTerm(); @@ -479,6 +485,7 @@ class FTerm static void init_termcaps_vte_quirks(); static void init_termcaps_putty_quirks(); static void init_termcaps_teraterm_quirks(); + static void init_termcaps_sun_quirks(); static void init_termcaps_screen_quirks(); static void init_termcaps_general_quirks(); static void init_termcaps_keys (char*&); @@ -531,6 +538,7 @@ class FTerm static bool gnome_terminal; static bool kterm_terminal; static bool tera_terminal; + static bool sun_terminal; static bool cygwin_terminal; static bool mintty_terminal; static bool linux_terminal; @@ -545,6 +553,7 @@ class FTerm static FRect* term; // current terminal geometry static FPoint* mouse; // mouse click position + static int gnome_terminal_id; static int stdin_status_flags; static int fd_tty; static uInt baudrate; @@ -674,6 +683,10 @@ inline bool FTerm::isKtermTerminal() inline bool FTerm::isTeraTerm() { return tera_terminal; } +//---------------------------------------------------------------------- +inline bool FTerm::isSunTerminal() +{ return sun_terminal; } + //---------------------------------------------------------------------- inline bool FTerm::isCygwinTerminal() { return cygwin_terminal; } diff --git a/src/Makefile.in b/src/Makefile.in index a2ff4116..2464bad3 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -438,9 +438,9 @@ $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) exit 1;; \ esac; \ done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/Makefile'; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/Makefile'; \ $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --foreign src/Makefile + $(AUTOMAKE) --gnu src/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ diff --git a/src/fterm.cpp b/src/fterm.cpp index 8d6fc62a..6e971170 100644 --- a/src/fterm.cpp +++ b/src/fterm.cpp @@ -49,6 +49,7 @@ int (*FTerm::Fputchar)(int); int FTerm::stdin_no; int FTerm::stdout_no; int FTerm::fd_tty; +int FTerm::gnome_terminal_id; int FTerm::stdin_status_flags; int FTerm::erase_ch_length; int FTerm::repeat_char_length; @@ -76,6 +77,7 @@ bool FTerm::kde_konsole; bool FTerm::gnome_terminal; bool FTerm::kterm_terminal; bool FTerm::tera_terminal; +bool FTerm::sun_terminal; bool FTerm::cygwin_terminal; bool FTerm::mintty_terminal; bool FTerm::linux_terminal; @@ -1191,6 +1193,9 @@ void FTerm::resetXTermColors() { // Reset the entire color table + if ( gnome_terminal && gnome_terminal_id < 3502 ) + return; + if ( putty_terminal ) return; @@ -1208,6 +1213,9 @@ void FTerm::resetXTermForeground() { // Reset the VT100 text foreground color + if ( gnome_terminal && gnome_terminal_id < 3502 ) + return; + if ( putty_terminal ) return; @@ -1225,6 +1233,9 @@ void FTerm::resetXTermBackground() { // Reset the VT100 text background color + if ( gnome_terminal && gnome_terminal_id < 3502 ) + return; + if ( putty_terminal ) return; @@ -1242,6 +1253,9 @@ void FTerm::resetXTermCursorColor() { // Reset the text cursor color + if ( gnome_terminal && gnome_terminal_id < 3502 ) + return; + if ( putty_terminal ) return; @@ -1259,6 +1273,9 @@ void FTerm::resetXTermMouseForeground() { // Reset the mouse foreground color + if ( gnome_terminal && gnome_terminal_id < 3502 ) + return; + if ( putty_terminal ) return; @@ -1276,6 +1293,9 @@ void FTerm::resetXTermMouseBackground() { // Reset the mouse background color + if ( gnome_terminal && gnome_terminal_id < 3502 ) + return; + if ( putty_terminal ) return; @@ -1293,6 +1313,9 @@ void FTerm::resetXTermHighlightBackground() { // Reset the highlight background color + if ( gnome_terminal && gnome_terminal_id < 3502 ) + return; + if ( putty_terminal ) return; @@ -2198,6 +2221,8 @@ void FTerm::getSystemTermType() std::fclose(fp); } +#if F_HAVE_GETTTYNAM + // Analyse /etc/ttys // -------------------- struct ttyent* ttys_entryt; @@ -2216,6 +2241,7 @@ void FTerm::getSystemTermType() } endttyent(); +#endif } // use vt100 if not found @@ -2637,6 +2663,11 @@ void FTerm::init_global_values() // Teletype (tty) file descriptor is still undefined fd_tty = -1; + // Gnome terminal id from SecDA + // Example: vte version 0.40.0 = 0 * 100 + 40 * 100 + 0 = 4000 + // a.b.c = a * 100 + b * 100 + c + gnome_terminal_id = 0; + // Preset to false utf8_console = \ utf8_input = \ @@ -2653,6 +2684,7 @@ void FTerm::init_global_values() decscusr_support = \ force_vt100 = \ tera_terminal = \ + sun_terminal = \ kterm_terminal = \ gnome_terminal = \ kde_konsole = \ @@ -2677,6 +2709,9 @@ void FTerm::init_global_values() // init arrays with '\0' std::fill_n (exit_message, sizeof(exit_message), '\0'); + + if ( ! init_values.terminal_detection ) + terminal_detection = false; } //---------------------------------------------------------------------- @@ -2772,6 +2807,13 @@ void FTerm::termtypeAnalysis() ansi_terminal = true; } + // Sun Microsystems workstation console + if ( std::strncmp(termtype, "sun", 3) == 0 ) + { + terminal_detection = false; + sun_terminal = true; + } + // Linux console if ( std::strncmp(termtype, const_cast("linux"), 5) == 0 || std::strncmp(termtype, const_cast("con"), 3) == 0 ) @@ -3047,9 +3089,10 @@ char* FTerm::parseSecDA (char*& current_termtype) // Each gnome-terminal should be able to use 256 colors color256 = true; new_termtype = const_cast("gnome-256color"); + gnome_terminal_id = terminal_id_version; // VTE 0.40.0 or higher and gnome-terminal 3.16 or higher - if ( terminal_id_version >= 4000 ) + if ( gnome_terminal_id >= 4000 ) decscusr_support = true; } break; @@ -3474,6 +3517,10 @@ void FTerm::init_termcaps_quirks() { init_termcaps_teraterm_quirks(); } + else if ( sun_terminal ) + { + init_termcaps_sun_quirks(); + } else if ( putty_terminal ) { init_termcaps_putty_quirks(); @@ -3753,6 +3800,13 @@ void FTerm::init_termcaps_teraterm_quirks() const_cast(CSI "39;49m"); } +//---------------------------------------------------------------------- +void FTerm::init_termcaps_sun_quirks() +{ + // Sun Microsystems workstation console eat_nl_glitch fix + FTermcap::eat_nl_glitch = true; +} + //---------------------------------------------------------------------- void FTerm::init_termcaps_screen_quirks() { @@ -4056,6 +4110,11 @@ void FTerm::init_locale() if ( tera_terminal && ! std::strcmp(nl_langinfo(CODESET), "UTF-8") ) locale_name = std::setlocale (LC_ALL, "C"); + // Sun (color) workstation console can't show UTF-8 character + if ( std::strncmp(termtype, "sun", 3) == 0 + && ! std::strcmp(nl_langinfo(CODESET), "UTF-8") ) + locale_name = std::setlocale (LC_ALL, "C"); + // Try to found a meaningful content for locale_name if ( locale_name ) locale_name = std::setlocale (LC_CTYPE, 0); @@ -4157,67 +4216,71 @@ void FTerm::init_encoding() //---------------------------------------------------------------------- void FTerm::redefineColorPalette() { - if ( ! cygwin_terminal - && ! kde_konsole - && ! tera_terminal - && ! ansi_terminal ) - { - resetColorMap(); - saveColorMap(); + if ( cygwin_terminal + || kde_konsole + || tera_terminal + || sun_terminal + || ansi_terminal ) + return; - if ( FTermcap::max_color >= 16 ) - { - setPalette (fc::Black, 0x00, 0x00, 0x00); - setPalette (fc::Blue, 0x22, 0x22, 0xb2); - setPalette (fc::Green, 0x18, 0x78, 0x18); - setPalette (fc::Cyan, 0x4a, 0x4a, 0xe4); - setPalette (fc::Red, 0xb2, 0x18, 0x18); - setPalette (fc::Magenta, 0xb2, 0x18, 0xb2); - setPalette (fc::Brown, 0xe8, 0x87, 0x1f); - setPalette (fc::LightGray, 0xbc, 0xbc, 0xbc); - setPalette (fc::DarkGray, 0x50, 0x50, 0x50); - setPalette (fc::LightBlue, 0x80, 0xa4, 0xec); - setPalette (fc::LightGreen, 0x5e, 0xeb, 0x5c); - setPalette (fc::LightCyan, 0x62, 0xbf, 0xf8); - setPalette (fc::LightRed, 0xed, 0x57, 0x31); - setPalette (fc::LightMagenta, 0xe9, 0xad, 0xff); - setPalette (fc::Yellow, 0xfb, 0xe8, 0x67); - setPalette (fc::White, 0xff, 0xff, 0xff); - } - else // 8 colors - { - setPalette (fc::Black, 0x00, 0x00, 0x00); - setPalette (fc::Blue, 0x22, 0x22, 0xb2); - setPalette (fc::Green, 0x18, 0x78, 0x18); - setPalette (fc::Cyan, 0x66, 0x66, 0xff); - setPalette (fc::Red, 0xb2, 0x18, 0x18); - setPalette (fc::Magenta, 0xb2, 0x18, 0xb2); - setPalette (fc::Brown, 0xe8, 0x87, 0x1f); - setPalette (fc::LightGray, 0xd0, 0xd0, 0xd0); - } + resetColorMap(); + saveColorMap(); + + if ( FTermcap::max_color >= 16 ) + { + setPalette (fc::Black, 0x00, 0x00, 0x00); + setPalette (fc::Blue, 0x22, 0x22, 0xb2); + setPalette (fc::Green, 0x18, 0x78, 0x18); + setPalette (fc::Cyan, 0x4a, 0x4a, 0xe4); + setPalette (fc::Red, 0xb2, 0x18, 0x18); + setPalette (fc::Magenta, 0xb2, 0x18, 0xb2); + setPalette (fc::Brown, 0xe8, 0x87, 0x1f); + setPalette (fc::LightGray, 0xbc, 0xbc, 0xbc); + setPalette (fc::DarkGray, 0x50, 0x50, 0x50); + setPalette (fc::LightBlue, 0x80, 0xa4, 0xec); + setPalette (fc::LightGreen, 0x5e, 0xeb, 0x5c); + setPalette (fc::LightCyan, 0x62, 0xbf, 0xf8); + setPalette (fc::LightRed, 0xed, 0x57, 0x31); + setPalette (fc::LightMagenta, 0xe9, 0xad, 0xff); + setPalette (fc::Yellow, 0xfb, 0xe8, 0x67); + setPalette (fc::White, 0xff, 0xff, 0xff); + } + else // 8 colors + { + setPalette (fc::Black, 0x00, 0x00, 0x00); + setPalette (fc::Blue, 0x22, 0x22, 0xb2); + setPalette (fc::Green, 0x18, 0x78, 0x18); + setPalette (fc::Cyan, 0x66, 0x66, 0xff); + setPalette (fc::Red, 0xb2, 0x18, 0x18); + setPalette (fc::Magenta, 0xb2, 0x18, 0xb2); + setPalette (fc::Brown, 0xe8, 0x87, 0x1f); + setPalette (fc::LightGray, 0xe0, 0xe0, 0xe0); } } //---------------------------------------------------------------------- void FTerm::restoreColorPalette() { - if ( ! (kde_konsole || tera_terminal || ansi_terminal) ) - { - // Reset screen settings - if ( FTermcap::max_color >= 16 ) - { - setPalette (fc::Cyan, 0x18, 0xb2, 0xb2); - setPalette (fc::LightGray, 0xb2, 0xb2, 0xb2); - setPalette (fc::DarkGray, 0x68, 0x68, 0x68); - setPalette (fc::LightBlue, 0x54, 0x54, 0xff); - setPalette (fc::LightGreen, 0x54, 0xff, 0x54); - } - else // 8 colors - setPalette (fc::Cyan, 0x18, 0xb2, 0xb2); + if ( kde_konsole + || tera_terminal + || sun_terminal + || ansi_terminal ) + return; - resetXTermColors(); - resetColorMap(); + // Reset screen settings + if ( FTermcap::max_color >= 16 ) + { + setPalette (fc::Cyan, 0x18, 0xb2, 0xb2); + setPalette (fc::LightGray, 0xb2, 0xb2, 0xb2); + setPalette (fc::DarkGray, 0x68, 0x68, 0x68); + setPalette (fc::LightBlue, 0x54, 0x54, 0xff); + setPalette (fc::LightGreen, 0x54, 0xff, 0x54); } + else // 8 colors + setPalette (fc::Cyan, 0x18, 0xb2, 0xb2); + + resetXTermColors(); + resetColorMap(); } //---------------------------------------------------------------------- @@ -4291,9 +4354,6 @@ void FTerm::init() // Initialize global values for all objects init_global_values(); - if ( ! init_values.terminal_detection ) - terminal_detection = false; - // Get file descriptor for standard input and standard output stdin_no = fileno(stdin); stdout_no = fileno(stdout); @@ -4363,32 +4423,35 @@ void FTerm::init() // Enable the terminal mouse support enableMouse(); - // activate meta key sends escape + // Activate meta key sends escape if ( xterm_terminal ) xtermMetaSendsESC(true); - // enter 'keyboard_transmit' mode + // Enter 'keyboard_transmit' mode if ( TCAP(fc::t_keypad_xmit) ) { putstring (TCAP(fc::t_keypad_xmit)); std::fflush(stdout); } - // save current cursor position - if ( use_alternate_screen && TCAP(fc::t_save_cursor) ) + if ( use_alternate_screen ) { - putstring (TCAP(fc::t_save_cursor)); - std::fflush(stdout); + // Save current cursor position + if ( TCAP(fc::t_save_cursor) ) + { + putstring (TCAP(fc::t_save_cursor)); + std::fflush(stdout); + } + + // Saves the screen and the cursor position + if ( TCAP(fc::t_enter_ca_mode) ) + { + putstring (TCAP(fc::t_enter_ca_mode)); + std::fflush(stdout); + } } - // saves the screen and the cursor position - if ( use_alternate_screen && TCAP(fc::t_enter_ca_mode) ) - { - putstring (TCAP(fc::t_enter_ca_mode)); - std::fflush(stdout); - } - - // enable alternate charset + // Enable alternate charset if ( TCAP(fc::t_enable_acs) ) { putstring (TCAP(fc::t_enable_acs)); @@ -4424,10 +4487,10 @@ void FTerm::init() // (depending on the initialization values) init_font(); - // turn off hardware echo + // Turn off hardware echo noHardwareEcho(); - // switch to the raw mode + // Switch to the raw mode setRawMode(); // The terminal is now initialized @@ -4508,18 +4571,21 @@ void FTerm::finish() if ( xterm_terminal ) xtermMetaSendsESC(false); - // restores the screen and the cursor position - if ( use_alternate_screen && TCAP(fc::t_exit_ca_mode) ) + if ( use_alternate_screen ) { - putstring (TCAP(fc::t_exit_ca_mode)); - std::fflush(stdout); - } + // restores the screen and the cursor position + if ( TCAP(fc::t_exit_ca_mode) ) + { + putstring (TCAP(fc::t_exit_ca_mode)); + std::fflush(stdout); + } - // restore cursor to position of last save_cursor - if ( use_alternate_screen && TCAP(fc::t_restore_cursor) ) - { - putstring (TCAP(fc::t_restore_cursor)); - std::fflush(stdout); + // restore cursor to position of last save_cursor + if ( TCAP(fc::t_restore_cursor) ) + { + putstring (TCAP(fc::t_restore_cursor)); + std::fflush(stdout); + } } // leave 'keyboard_transmit' mode diff --git a/src/fvterm.cpp b/src/fvterm.cpp index 0216b50e..c0600e88 100644 --- a/src/fvterm.cpp +++ b/src/fvterm.cpp @@ -2380,7 +2380,7 @@ bool FVTerm::canClearLeadingWS (uInt& xmin, uInt y) { uInt leading_whitespace = 1; bool normal = isNormal(first_char); - bool& ut = FTermcap::background_color_erase; + bool& ut = FTermcap::background_color_erase; for (uInt x = 1; x < uInt(vt->width); x++) { @@ -2411,7 +2411,6 @@ bool FVTerm::canClearTailingWS (uInt& xmax, uInt y) // => clear from xmax to end of line term_area*& vt = vterm; - bool& ut = FTermcap::background_color_erase; char*& ce = TCAP(fc::t_clr_eol); char_data* last_char = &vt->text[(y + 1) * uInt(vt->width) - 1]; @@ -2419,6 +2418,7 @@ bool FVTerm::canClearTailingWS (uInt& xmax, uInt y) { uInt tailing_whitespace = 1; bool normal = isNormal(last_char); + bool& ut = FTermcap::background_color_erase; for (uInt x = uInt(vt->width) - 1; x > 0 ; x--) {