incorrect parameter can now return an error message

This commit is contained in:
Markus Gans 2016-08-28 22:43:14 +02:00
parent 2904ed31b9
commit 44cb96e732
8 changed files with 101 additions and 65 deletions

1
.gitignore vendored
View File

@ -37,4 +37,3 @@ test/mandelbrot
test/keyboard test/keyboard
test/timer test/timer
test/ui test/ui

View File

@ -1,4 +1,11 @@
2016-08-25 Markus Gans <guru.mail@muenster.de> 2016-08-28 Markus Gans <guru.mail@muenster.de>
* Remove obsolete code from FDialog
* An incorrect parameter can now return an error message
on program exit
* Termcap S2 and S3 fallback only for the vte/gnome-terminal
and the linux terminal
2016-08-27 Markus Gans <guru.mail@muenster.de>
* A new inherit background option for characters * A new inherit background option for characters
* Use inherit background for the simple shadows * Use inherit background for the simple shadows
* Updating the transparent example program * Updating the transparent example program

View File

@ -104,6 +104,15 @@ void FApplication::init()
cmd_options(); cmd_options();
} }
//----------------------------------------------------------------------
void FApplication::setExitMessage (std::string message)
{
quit_now = true;
snprintf ( FTerm::exit_message
, sizeof(FTerm::exit_message)
, message.c_str() );
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FApplication::cmd_options () void FApplication::cmd_options ()
{ {
@ -141,16 +150,29 @@ void FApplication::cmd_options ()
{ {
setEncoding(encoding.c_str()); setEncoding(encoding.c_str());
} }
else
setExitMessage ( "Unknown encoding "
+ std::string(encoding.c_str()) );
} }
if ( strcmp(long_options[idx].name, "no-optimize-cursor") == 0 ) if ( strcmp(long_options[idx].name, "no-optimize-cursor") == 0 )
setCursorOptimisation (false); setCursorOptimisation (false);
if ( strcmp(long_options[idx].name, "vgafont") == 0 ) if ( strcmp(long_options[idx].name, "vgafont") == 0 )
setVGAFont(); {
bool ret = setVGAFont();
if ( ! ret )
setExitMessage ("VGAfont is not supported by this terminal");
}
if ( strcmp(long_options[idx].name, "newfont") == 0 ) if ( strcmp(long_options[idx].name, "newfont") == 0 )
setNewFont(); {
bool ret = setNewFont();
if ( ! ret )
setExitMessage ("Newfont is not supported by this terminal");
}
} }
} }
} }
@ -1753,6 +1775,10 @@ void FApplication::setMainWidget (FWidget* widget)
int FApplication::exec() // run int FApplication::exec() // run
{ {
FWidget* widget; FWidget* widget;
if ( quit_now )
return EXIT_FAILURE;
quit_now = false; quit_now = false;
quit_code = 0; quit_code = 0;

View File

@ -120,6 +120,7 @@ class FApplication : public FWidget
FApplication& operator = (const FApplication&); // and operator '=' FApplication& operator = (const FApplication&); // and operator '='
void init(); void init();
void setExitMessage (std::string);
void cmd_options(); void cmd_options();
bool KeyPressed(); bool KeyPressed();
ssize_t readKey(); ssize_t readKey();

View File

@ -780,21 +780,6 @@ void FDialog::onWindowRaised (FEvent*)
if ( window_list->empty() ) if ( window_list->empty() )
return; return;
// redraw shadow of the other windows
iter = window_list->begin();
end = window_list->end();
while ( iter != end )
{
if ( *iter != this && ! maximized
&& ((*iter)->getFlags() & fc::shadow) != 0 )
{
static_cast<FDialog*>(*iter)->drawDialogShadow();
}
++iter;
}
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -814,10 +799,6 @@ void FDialog::onWindowLowered (FEvent*)
while ( iter != end ) while ( iter != end )
{ {
putArea ((*iter)->getGlobalPos(), (*iter)->getVWin()); putArea ((*iter)->getGlobalPos(), (*iter)->getVWin());
if ( ! maximized && ((*iter)->getFlags() & fc::shadow) != 0 )
static_cast<FDialog*>(*iter)->drawDialogShadow();
++iter; ++iter;
} }
} }
@ -936,9 +917,6 @@ void FDialog::move (int x, int y)
restoreVTerm (old_x, old_y, width+rsw, height+bsh); restoreVTerm (old_x, old_y, width+rsw, height+bsh);
} }
// if ( ! maximized && (flags & fc::shadow) != 0 )
// drawDialogShadow();
// handle overlaid windows // handle overlaid windows
if ( window_list && ! window_list->empty() ) if ( window_list && ! window_list->empty() )
{ {
@ -950,13 +928,8 @@ void FDialog::move (int x, int y)
while ( iter != end ) while ( iter != end )
{ {
if ( overlaid ) if ( overlaid )
{
putArea ((*iter)->getGlobalPos(), (*iter)->getVWin()); putArea ((*iter)->getGlobalPos(), (*iter)->getVWin());
if ( ! maximized && ((*iter)->getFlags() & fc::shadow) != 0 )
static_cast<FDialog*>(*iter)->drawDialogShadow();
}
if ( vwin == (*iter)->getVWin() ) if ( vwin == (*iter)->getVWin() )
overlaid = true; overlaid = true;

View File

@ -89,6 +89,7 @@ FPoint* FTerm::mouse = 0;
FPoint* FTerm::cursor = 0; FPoint* FTerm::cursor = 0;
FRect* FTerm::term = 0; FRect* FTerm::term = 0;
char FTerm::exit_message[8192] = "";
fc::encoding FTerm::Encoding; fc::encoding FTerm::Encoding;
const FString* FTerm::xterm_font = 0; const FString* FTerm::xterm_font = 0;
const FString* FTerm::xterm_title = 0; const FString* FTerm::xterm_title = 0;
@ -161,6 +162,11 @@ FTerm::~FTerm() // destructor
delete term; delete term;
delete opti_attr; delete opti_attr;
delete opti_move; delete opti_move;
if ( exit_message[0] )
{
fprintf (stderr, "Warning: %s\n", exit_message);
}
} }
} }
@ -1155,7 +1161,9 @@ void FTerm::init_pc_charset()
if ( rxvt_terminal || urxvt_terminal ) if ( rxvt_terminal || urxvt_terminal )
return; return;
// fallback if "S2" is not found if ( gnome_terminal || linux_terminal )
{
// fallback if tcap "S2" is not found
if ( ! tcap[t_enter_pc_charset_mode].string ) if ( ! tcap[t_enter_pc_charset_mode].string )
{ {
if ( utf8_console ) if ( utf8_console )
@ -1175,7 +1183,7 @@ void FTerm::init_pc_charset()
reinit = true; reinit = true;
} }
// fallback if "S3" is not found // fallback if tcap "S3" is not found
if ( ! tcap[t_exit_pc_charset_mode].string ) if ( ! tcap[t_exit_pc_charset_mode].string )
{ {
if ( utf8_console ) if ( utf8_console )
@ -1194,6 +1202,7 @@ void FTerm::init_pc_charset()
opti_attr->set_exit_pc_charset_mode (tcap[t_exit_pc_charset_mode].string); opti_attr->set_exit_pc_charset_mode (tcap[t_exit_pc_charset_mode].string);
reinit = true; reinit = true;
} }
}
if ( reinit ) if ( reinit )
opti_attr->init(); opti_attr->init();
@ -1731,6 +1740,9 @@ void FTerm::init()
force_terminal_update = \ force_terminal_update = \
non_blocking_stdin = false; non_blocking_stdin = false;
// init arrays with '\0'
std::fill_n (exit_message, sizeof(exit_message), '\0');
stdin_no = fileno(stdin); stdin_no = fileno(stdin);
stdout_no = fileno(stdout); stdout_no = fileno(stdout);
stdin_status_flags = fcntl(stdin_no, F_GETFL); stdin_status_flags = fcntl(stdin_no, F_GETFL);
@ -3017,6 +3029,14 @@ bool FTerm::setVGAFont()
if ( VGAFont ) if ( VGAFont )
return VGAFont; return VGAFont;
if ( gnome_terminal
|| kde_konsole
|| putty_terminal
|| tera_terminal
|| cygwin_terminal
|| mintty_terminal )
return false;
VGAFont = true; VGAFont = true;
if ( xterm || screen_terminal || osc_support ) if ( xterm || screen_terminal || osc_support )
@ -3079,6 +3099,14 @@ bool FTerm::setNewFont()
if ( NewFont ) if ( NewFont )
return true; return true;
if ( gnome_terminal
|| kde_konsole
|| putty_terminal
|| tera_terminal
|| cygwin_terminal
|| mintty_terminal )
return false;
if ( xterm || screen_terminal || urxvt_terminal || osc_support ) if ( xterm || screen_terminal || urxvt_terminal || osc_support )
{ {
NewFont = true; NewFont = true;
@ -4644,7 +4672,7 @@ int FTerm::print (FTerm::term_area* area, register int c)
inline void FTerm::newFontChanges (FOptiAttr::char_data*& next_char) inline void FTerm::newFontChanges (FOptiAttr::char_data*& next_char)
{ {
// NewFont special cases // NewFont special cases
if ( isNewFont() ) if ( NewFont )
{ {
switch ( next_char->code ) switch ( next_char->code )
{ {

View File

@ -162,6 +162,7 @@ class FTerm
static int x_term_pos; static int x_term_pos;
static int y_term_pos; static int y_term_pos;
static bool resize_term; static bool resize_term;
static char exit_message[8192];
static struct termios term_init; static struct termios term_init;
static FOptiAttr::char_data term_attribute; static FOptiAttr::char_data term_attribute;

View File

@ -179,6 +179,7 @@ void MainWindow::draw()
{ {
FDialog::draw(); FDialog::draw();
updateVTerm(false); updateVTerm(false);
if ( isMonochron() ) if ( isMonochron() )
setReverse(true); setReverse(true);