Add Sun Microsystems workstation console support

This commit is contained in:
Markus Gans 2017-12-14 00:35:10 +01:00
parent fd75f5af42
commit c10a88008c
12 changed files with 272 additions and 93 deletions

View File

@ -1,3 +1,6 @@
2017-12-14 Markus Gans <guru.mail@muenster.de>
* Add Sun Microsystems workstation console support
2017-12-10 Markus Gans <guru.mail@muenster.de>
* Refactoring of the FMenu mouse event handler

View File

@ -15,6 +15,15 @@
/* Define to 1 if you have the <fcntl.h> 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 <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
@ -39,18 +48,27 @@
/* Define to 1 if you have the <queue> header file. */
#undef HAVE_QUEUE
/* Define to 1 if you have the `select' function. */
#undef HAVE_SELECT
/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
/* Define to 1 if you have the <stdlib.h> 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 <strings.h> header file. */
#undef HAVE_STRINGS_H
/* Define to 1 if you have the <string.h> 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 <sys/io.h> header file. */
#undef HAVE_SYS_IO_H
@ -72,12 +90,18 @@
/* Define to 1 if you have the <term.h> header file. */
#undef HAVE_TERM_H
/* Define to 1 if you have the <ttyent.h> header file. */
#undef HAVE_TTYENT_H
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* Define to 1 if you have the <vector> 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

22
configure vendored
View File

@ -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; }

View File

@ -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'

View File

@ -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 \

View File

@ -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 \

View File

@ -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 \

View File

@ -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 <inttypes.h> header file. */
#ifndef F_HAVE_INTTYPES_H
#define F_HAVE_INTTYPES_H 1
@ -58,6 +73,11 @@
/* Define to 1 if you have the <queue> 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 <stdint.h> 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 <strings.h> 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 <sys/io.h> 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 <ttyent.h> header file. */
#ifndef F_HAVE_TTYENT_H
#define F_HAVE_TTYENT_H 1
#endif
/* Define to 1 if you have the <unistd.h> header file. */
#ifndef F_HAVE_UNISTD_H
#define F_HAVE_UNISTD_H 1
@ -121,6 +156,11 @@
/* Define to 1 if you have the <vector> 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

View File

@ -85,7 +85,12 @@
#include <langinfo.h>
#include <term.h> // termcap
#include <termios.h>
#if F_HAVE_GETTTYNAM && F_HAVE_TTYENT_H
#include <ttyent.h>
#endif
#include <unistd.h>
#include <clocale>
@ -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; }

View File

@ -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 \

View File

@ -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<char*>("linux"), 5) == 0
|| std::strncmp(termtype, const_cast<char*>("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<char*>("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<char*>(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,11 +4216,13 @@ void FTerm::init_encoding()
//----------------------------------------------------------------------
void FTerm::redefineColorPalette()
{
if ( ! cygwin_terminal
&& ! kde_konsole
&& ! tera_terminal
&& ! ansi_terminal )
{
if ( cygwin_terminal
|| kde_konsole
|| tera_terminal
|| sun_terminal
|| ansi_terminal )
return;
resetColorMap();
saveColorMap();
@ -4193,16 +4254,19 @@ void FTerm::redefineColorPalette()
setPalette (fc::Red, 0xb2, 0x18, 0x18);
setPalette (fc::Magenta, 0xb2, 0x18, 0xb2);
setPalette (fc::Brown, 0xe8, 0x87, 0x1f);
setPalette (fc::LightGray, 0xd0, 0xd0, 0xd0);
}
setPalette (fc::LightGray, 0xe0, 0xe0, 0xe0);
}
}
//----------------------------------------------------------------------
void FTerm::restoreColorPalette()
{
if ( ! (kde_konsole || tera_terminal || ansi_terminal) )
{
if ( kde_konsole
|| tera_terminal
|| sun_terminal
|| ansi_terminal )
return;
// Reset screen settings
if ( FTermcap::max_color >= 16 )
{
@ -4218,7 +4282,6 @@ void FTerm::restoreColorPalette()
resetXTermColors();
resetColorMap();
}
}
//----------------------------------------------------------------------
void FTerm::enableMouse()
@ -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 )
{
// 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 ( use_alternate_screen && TCAP(fc::t_enter_ca_mode) )
// Saves the screen and the cursor position
if ( 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,19 +4571,22 @@ void FTerm::finish()
if ( xterm_terminal )
xtermMetaSendsESC(false);
if ( use_alternate_screen )
{
// restores the screen and the cursor position
if ( use_alternate_screen && TCAP(fc::t_exit_ca_mode) )
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) )
if ( TCAP(fc::t_restore_cursor) )
{
putstring (TCAP(fc::t_restore_cursor));
std::fflush(stdout);
}
}
// leave 'keyboard_transmit' mode
if ( TCAP(fc::t_keypad_local) )

View File

@ -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--)
{