Struct to pass the FOptiMove environment

This commit is contained in:
Markus Gans 2018-07-01 14:48:53 +02:00
parent 03c3c79946
commit bdb30c5a96
11 changed files with 401 additions and 264 deletions

View File

@ -1,3 +1,7 @@
2017-07-01 Markus Gans <guru.mail@muenster.de>
* All in FOptiMove required termcap values can now be passed
with a single struct
2017-06-25 Markus Gans <guru.mail@muenster.de>
* All termcap values required in FOptiAttr can now be passed
with a single struct

View File

@ -93,6 +93,13 @@ void move (int xold, int yold, int xnew, int ynew)
char* buffer;
char from[10], to[10], byte[20];
uInt len;
const std::string ctrl_character[] =
{
"NUL", "SOH", "STX", "ETX", "EOT", "ENQ", "ACK", "BEL",
"BS", "Tab", "LF", "VT", "FF", "CR", "SO", "SI",
"DLE", "DC1", "DC2", "DC3", "DC4", "NAK", "SYN", "ETB",
"CAN", "EM", "SUB", "Esc", "FS", "GS", "RS", "US"
};
term_boundaries(xold, yold);
term_boundaries(xnew, ynew);
@ -108,33 +115,15 @@ void move (int xold, int yold, int xnew, int ynew)
for (uInt i = 0; i < len; i++)
{
switch ( buffer[i] )
{
case 0x08:
sequence += "BS ";
break;
char ch = buffer[i];
case 0x09:
sequence += "TAB ";
break;
if ( ch < 0x20 )
sequence += ctrl_character[uInt(ch)];
else
sequence += ch;
case 0x0a:
sequence += "LF ";
break;
case 0x0d:
sequence += "CR ";
break;
case 0x1b:
sequence += "Esc ";
break;
default:
sequence += buffer[i];
sequence += ' ';
}
}
std::cout << std::setw(21) << sequence << " ";

View File

@ -116,41 +116,41 @@ class FOptiAttr
bool ansi_default_color;
int max_color;
int attr_without_color;
char* F_enter_bold_mode;
char* F_exit_bold_mode;
char* F_enter_dim_mode;
char* F_exit_dim_mode;
char* F_enter_italics_mode;
char* F_exit_italics_mode;
char* F_enter_underline_mode;
char* F_exit_underline_mode;
char* F_enter_blink_mode;
char* F_exit_blink_mode;
char* F_enter_reverse_mode;
char* F_exit_reverse_mode;
char* F_enter_standout_mode;
char* F_exit_standout_mode;
char* F_enter_secure_mode;
char* F_exit_secure_mode;
char* F_enter_protected_mode;
char* F_exit_protected_mode;
char* F_enter_crossed_out_mode;
char* F_exit_crossed_out_mode;
char* F_enter_dbl_underline_mode;
char* F_exit_dbl_underline_mode;
char* F_set_attributes;
char* F_exit_attribute_mode;
char* F_enter_alt_charset_mode;
char* F_exit_alt_charset_mode;
char* F_enter_pc_charset_mode;
char* F_exit_pc_charset_mode;
char* F_set_a_foreground;
char* F_set_a_background;
char* F_set_foreground;
char* F_set_background;
char* F_set_color_pair;
char* F_orig_pair;
char* F_orig_colors;
char* t_enter_bold_mode;
char* t_exit_bold_mode;
char* t_enter_dim_mode;
char* t_exit_dim_mode;
char* t_enter_italics_mode;
char* t_exit_italics_mode;
char* t_enter_underline_mode;
char* t_exit_underline_mode;
char* t_enter_blink_mode;
char* t_exit_blink_mode;
char* t_enter_reverse_mode;
char* t_exit_reverse_mode;
char* t_enter_standout_mode;
char* t_exit_standout_mode;
char* t_enter_secure_mode;
char* t_exit_secure_mode;
char* t_enter_protected_mode;
char* t_exit_protected_mode;
char* t_enter_crossed_out_mode;
char* t_exit_crossed_out_mode;
char* t_enter_dbl_underline_mode;
char* t_exit_dbl_underline_mode;
char* t_set_attributes;
char* t_exit_attribute_mode;
char* t_enter_alt_charset_mode;
char* t_exit_alt_charset_mode;
char* t_enter_pc_charset_mode;
char* t_exit_pc_charset_mode;
char* t_set_a_foreground;
char* t_set_a_background;
char* t_set_foreground;
char* t_set_background;
char* t_set_color_pair;
char* t_orig_pair;
char* t_orig_colors;
} termEnv;
// Constructor

View File

@ -75,6 +75,34 @@
class FOptiMove
{
public:
// Typedef
typedef struct
{
bool automatic_left_margin;
bool eat_nl_glitch;
int tabstop;
char* t_cursor_home;
char* t_carriage_return;
char* t_cursor_to_ll;
char* t_tab;
char* t_back_tab;
char* t_cursor_up;
char* t_cursor_down;
char* t_cursor_left;
char* t_cursor_right;
char* t_cursor_address;
char* t_column_address;
char* t_row_address;
char* t_parm_up_cursor;
char* t_parm_down_cursor;
char* t_parm_left_cursor;
char* t_parm_right_cursor;
char* t_erase_chars;
char* t_repeat_char;
char* t_clr_bol;
char* t_clr_eol;
} termEnv;
// Constructor
explicit FOptiMove (int = 0);
@ -83,31 +111,52 @@ class FOptiMove
// Accessors
const char* getClassName() const;
uInt getCursorHomeLength() const;
uInt getCarriageReturnLength() const;
uInt getCursorToLLLength() const;
uInt getTabLength() const;
uInt getBackTabLength() const;
uInt getCursorUpLength() const;
uInt getCursorDownLength() const;
uInt getCursorLeftLength() const;
uInt getCursorRightLength() const;
uInt getCursorAddressLength() const;
uInt getColumnAddressLength() const;
uInt getRowAddressLength() const;
uInt getParmUpCursorLength() const;
uInt getParmDownCursorLength() const;
uInt getParmLeftCursorLength() const;
uInt getParmRightCursorLength() const;
uInt getEraseCharsLength() const;
uInt getRepeatCharLength() const;
uInt getClrBolLength() const;
uInt getClrEolLength() const;
// Mutators
void setBaudRate (int);
void setTabStop (int);
void setTermSize (int, int);
uInt set_cursor_home (char[]);
uInt set_cursor_to_ll (char[]);
uInt set_carriage_return (char[]);
uInt set_tabular (char[]);
uInt set_back_tab (char[]);
uInt set_cursor_up (char[]);
uInt set_cursor_down (char[]);
uInt set_cursor_left (char[]);
uInt set_cursor_right (char[]);
uInt set_cursor_address (char[]);
uInt set_column_address (char[]);
uInt set_row_address (char[]);
uInt set_parm_up_cursor (char[]);
uInt set_parm_down_cursor (char[]);
uInt set_parm_left_cursor (char[]);
uInt set_parm_right_cursor (char[]);
uInt set_erase_chars (char[]);
uInt set_repeat_char (char[]);
uInt set_clr_bol (char[]);
uInt set_clr_eol (char[]);
void setTermEnvironment (termEnv&);
void set_cursor_home (char[]);
void set_cursor_to_ll (char[]);
void set_carriage_return (char[]);
void set_tabular (char[]);
void set_back_tab (char[]);
void set_cursor_up (char[]);
void set_cursor_down (char[]);
void set_cursor_left (char[]);
void set_cursor_right (char[]);
void set_cursor_address (char[]);
void set_column_address (char[]);
void set_row_address (char[]);
void set_parm_up_cursor (char[]);
void set_parm_down_cursor (char[]);
void set_parm_left_cursor (char[]);
void set_parm_right_cursor (char[]);
void set_erase_chars (char[]);
void set_repeat_char (char[]);
void set_clr_bol (char[]);
void set_clr_eol (char[]);
void set_auto_left_margin (const bool&);
void set_eat_newline_glitch (const bool&);
@ -196,6 +245,86 @@ class FOptiMove
inline const char* FOptiMove::getClassName() const
{ return "FOptiMove"; }
//----------------------------------------------------------------------
inline uInt FOptiMove::getCursorHomeLength() const
{ return uInt(F_cursor_home.length); }
//----------------------------------------------------------------------
inline uInt FOptiMove::getCarriageReturnLength() const
{ return uInt(F_carriage_return.length); }
//----------------------------------------------------------------------
inline uInt FOptiMove::getCursorToLLLength() const
{ return uInt(F_cursor_to_ll.length); }
//----------------------------------------------------------------------
inline uInt FOptiMove::getTabLength() const
{ return uInt(F_tab.length); }
//----------------------------------------------------------------------
inline uInt FOptiMove::getBackTabLength() const
{ return uInt(F_back_tab.length); }
//----------------------------------------------------------------------
inline uInt FOptiMove::getCursorUpLength() const
{ return uInt(F_cursor_up.length); }
//----------------------------------------------------------------------
inline uInt FOptiMove::getCursorDownLength() const
{ return uInt(F_cursor_down.length); }
//----------------------------------------------------------------------
inline uInt FOptiMove::getCursorLeftLength() const
{ return uInt(F_cursor_left.length); }
//----------------------------------------------------------------------
inline uInt FOptiMove::getCursorRightLength() const
{ return uInt(F_cursor_right.length); }
//----------------------------------------------------------------------
inline uInt FOptiMove::getCursorAddressLength() const
{ return uInt(F_cursor_address.length); }
//----------------------------------------------------------------------
inline uInt FOptiMove::getColumnAddressLength() const
{ return uInt(F_column_address.length); }
//----------------------------------------------------------------------
inline uInt FOptiMove::getRowAddressLength() const
{ return uInt(F_row_address.length); }
//----------------------------------------------------------------------
inline uInt FOptiMove::getParmUpCursorLength() const
{ return uInt(F_parm_up_cursor.length); }
//----------------------------------------------------------------------
inline uInt FOptiMove::getParmDownCursorLength() const
{ return uInt(F_parm_down_cursor.length); }
//----------------------------------------------------------------------
inline uInt FOptiMove::getParmLeftCursorLength() const
{ return uInt(F_parm_left_cursor.length); }
//----------------------------------------------------------------------
inline uInt FOptiMove::getParmRightCursorLength() const
{ return uInt(F_parm_right_cursor.length); }
//----------------------------------------------------------------------
inline uInt FOptiMove::getEraseCharsLength() const
{ return uInt(F_erase_chars.length); }
//----------------------------------------------------------------------
inline uInt FOptiMove::getRepeatCharLength() const
{ return uInt(F_repeat_char.length); }
//----------------------------------------------------------------------
inline uInt FOptiMove::getClrBolLength() const
{ return uInt(F_clr_bol.length); }
//----------------------------------------------------------------------
inline uInt FOptiMove::getClrEolLength() const
{ return uInt(F_clr_eol.length); }
//----------------------------------------------------------------------
inline void FOptiMove::set_auto_left_margin (const bool& bcap)
{ automatic_left_margin = bcap; }

View File

@ -314,11 +314,12 @@ class FTerm
static bool hasAlternateScreen();
// Accessors
static uInt getEraseCharLength();
FOptiMove* getFOptiMove();
static uInt getEraseCharsLength();
static uInt getRepeatCharLength();
static uInt getClrBolLength();
static uInt getClrEolLength();
static uInt getCursorAddressLengths();
static uInt getCursorAddressLength();
// Methods
static void initScreenSettings();
@ -473,11 +474,6 @@ class FTerm
static int stdin_status_flags;
static int fd_tty;
static uInt baudrate;
static uInt erase_char_length;
static uInt repeat_char_length;
static uInt clr_bol_length;
static uInt clr_eol_length;
static uInt cursor_address_lengths;
static long key_timeout;
static bool resize_term;
@ -730,24 +726,8 @@ inline bool FTerm::hasAlternateScreen()
{ return use_alternate_screen; }
//----------------------------------------------------------------------
inline uInt FTerm::getEraseCharLength()
{ return erase_char_length; }
//----------------------------------------------------------------------
inline uInt FTerm::getRepeatCharLength()
{ return repeat_char_length; }
//----------------------------------------------------------------------
inline uInt FTerm::getClrBolLength()
{ return clr_bol_length; }
//----------------------------------------------------------------------
inline uInt FTerm::getClrEolLength()
{ return clr_eol_length; }
//----------------------------------------------------------------------
inline uInt FTerm::getCursorAddressLengths()
{ return cursor_address_lengths; }
inline FOptiMove* FTerm::getFOptiMove()
{ return opti_move; }
//----------------------------------------------------------------------
inline void FTerm::changeTermSizeFinished()

View File

@ -391,6 +391,7 @@ class FVTerm : public FTerm
// Methods
void init();
static void init_characterLengths (FOptiMove*);
void finish();
static void putAreaLine (charData*, charData*, int);
static void putAreaCharacter ( int, int, FVTerm*
@ -442,6 +443,11 @@ class FVTerm : public FTerm
static bool force_terminal_update;
static bool stop_terminal_updates;
static int skipped_terminal_update;
static uInt erase_char_length;
static uInt repeat_char_length;
static uInt clr_bol_length;
static uInt clr_eol_length;
static uInt cursor_address_length;
};
#pragma pack(pop)

View File

@ -106,41 +106,41 @@ void FOptiAttr::setTermEnvironment (termEnv& term_env)
max_color = term_env.max_color;
attr_without_color = term_env.attr_without_color;
set_enter_bold_mode (term_env.F_enter_bold_mode);
set_exit_bold_mode (term_env.F_exit_bold_mode);
set_enter_dim_mode (term_env.F_enter_dim_mode);
set_exit_dim_mode (term_env.F_exit_dim_mode);
set_enter_italics_mode (term_env.F_enter_italics_mode);
set_exit_italics_mode (term_env.F_exit_italics_mode);
set_enter_underline_mode (term_env.F_enter_underline_mode);
set_exit_underline_mode (term_env.F_exit_underline_mode);
set_enter_blink_mode (term_env.F_enter_blink_mode);
set_exit_blink_mode (term_env.F_exit_blink_mode);
set_enter_reverse_mode (term_env.F_enter_reverse_mode);
set_exit_reverse_mode (term_env.F_exit_reverse_mode);
set_enter_standout_mode (term_env.F_enter_standout_mode);
set_exit_standout_mode (term_env.F_exit_standout_mode);
set_enter_secure_mode (term_env.F_enter_secure_mode);
set_exit_secure_mode (term_env.F_exit_secure_mode);
set_enter_protected_mode (term_env.F_enter_protected_mode);
set_exit_protected_mode (term_env.F_exit_protected_mode);
set_enter_crossed_out_mode (term_env.F_enter_crossed_out_mode);
set_exit_crossed_out_mode (term_env.F_exit_crossed_out_mode);
set_enter_dbl_underline_mode (term_env.F_enter_dbl_underline_mode);
set_exit_dbl_underline_mode (term_env.F_exit_dbl_underline_mode);
set_set_attributes (term_env.F_set_attributes);
set_exit_attribute_mode (term_env.F_exit_attribute_mode);
set_enter_alt_charset_mode (term_env.F_enter_alt_charset_mode);
set_exit_alt_charset_mode (term_env.F_exit_alt_charset_mode);
set_enter_pc_charset_mode (term_env.F_enter_pc_charset_mode);
set_exit_pc_charset_mode (term_env.F_exit_pc_charset_mode);
set_a_foreground_color (term_env.F_set_a_foreground);
set_a_background_color (term_env.F_set_a_background);
set_foreground_color (term_env.F_set_foreground);
set_background_color (term_env.F_set_background);
set_term_color_pair (term_env.F_set_color_pair);
set_orig_pair (term_env.F_orig_pair);
set_orig_orig_colors (term_env.F_orig_colors);
set_enter_bold_mode (term_env.t_enter_bold_mode);
set_exit_bold_mode (term_env.t_exit_bold_mode);
set_enter_dim_mode (term_env.t_enter_dim_mode);
set_exit_dim_mode (term_env.t_exit_dim_mode);
set_enter_italics_mode (term_env.t_enter_italics_mode);
set_exit_italics_mode (term_env.t_exit_italics_mode);
set_enter_underline_mode (term_env.t_enter_underline_mode);
set_exit_underline_mode (term_env.t_exit_underline_mode);
set_enter_blink_mode (term_env.t_enter_blink_mode);
set_exit_blink_mode (term_env.t_exit_blink_mode);
set_enter_reverse_mode (term_env.t_enter_reverse_mode);
set_exit_reverse_mode (term_env.t_exit_reverse_mode);
set_enter_standout_mode (term_env.t_enter_standout_mode);
set_exit_standout_mode (term_env.t_exit_standout_mode);
set_enter_secure_mode (term_env.t_enter_secure_mode);
set_exit_secure_mode (term_env.t_exit_secure_mode);
set_enter_protected_mode (term_env.t_enter_protected_mode);
set_exit_protected_mode (term_env.t_exit_protected_mode);
set_enter_crossed_out_mode (term_env.t_enter_crossed_out_mode);
set_exit_crossed_out_mode (term_env.t_exit_crossed_out_mode);
set_enter_dbl_underline_mode (term_env.t_enter_dbl_underline_mode);
set_exit_dbl_underline_mode (term_env.t_exit_dbl_underline_mode);
set_set_attributes (term_env.t_set_attributes);
set_exit_attribute_mode (term_env.t_exit_attribute_mode);
set_enter_alt_charset_mode (term_env.t_enter_alt_charset_mode);
set_exit_alt_charset_mode (term_env.t_exit_alt_charset_mode);
set_enter_pc_charset_mode (term_env.t_enter_pc_charset_mode);
set_exit_pc_charset_mode (term_env.t_exit_pc_charset_mode);
set_a_foreground_color (term_env.t_set_a_foreground);
set_a_background_color (term_env.t_set_a_background);
set_foreground_color (term_env.t_set_foreground);
set_background_color (term_env.t_set_background);
set_term_color_pair (term_env.t_set_color_pair);
set_orig_pair (term_env.t_orig_pair);
set_orig_orig_colors (term_env.t_orig_colors);
initialize();
}

View File

@ -105,7 +105,37 @@ void FOptiMove::setTermSize (int w, int h)
}
//----------------------------------------------------------------------
uInt FOptiMove::set_cursor_home (char cap[])
void FOptiMove::setTermEnvironment (termEnv& term_env)
{
// Set all required termcap values at once
set_auto_left_margin (term_env.automatic_left_margin);
set_eat_newline_glitch (term_env.eat_nl_glitch);
setTabStop (term_env.tabstop);
set_cursor_home (term_env.t_cursor_home);
set_cursor_to_ll (term_env.t_cursor_to_ll);
set_carriage_return (term_env.t_carriage_return);
set_tabular (term_env.t_tab);
set_back_tab (term_env.t_back_tab);
set_cursor_up (term_env.t_cursor_up);
set_cursor_down (term_env.t_cursor_down);
set_cursor_left (term_env.t_cursor_left);
set_cursor_right (term_env.t_cursor_right);
set_cursor_address (term_env.t_cursor_address);
set_column_address (term_env.t_column_address);
set_row_address (term_env.t_row_address);
set_parm_up_cursor (term_env.t_parm_up_cursor);
set_parm_down_cursor (term_env.t_parm_down_cursor);
set_parm_left_cursor (term_env.t_parm_left_cursor);
set_parm_right_cursor (term_env.t_parm_right_cursor);
set_erase_chars (term_env.t_erase_chars);
set_repeat_char (term_env.t_repeat_char);
set_clr_bol (term_env.t_clr_bol);
set_clr_eol (term_env.t_clr_eol);
}
//----------------------------------------------------------------------
void FOptiMove::set_cursor_home (char cap[])
{
if ( cap )
{
@ -119,12 +149,10 @@ uInt FOptiMove::set_cursor_home (char cap[])
F_cursor_home.duration = \
F_cursor_home.length = LONG_DURATION;
}
return uInt(F_cursor_home.length);
}
//----------------------------------------------------------------------
uInt FOptiMove::set_cursor_to_ll (char cap[])
void FOptiMove::set_cursor_to_ll (char cap[])
{
if ( cap )
{
@ -138,12 +166,10 @@ uInt FOptiMove::set_cursor_to_ll (char cap[])
F_cursor_to_ll.duration = \
F_cursor_to_ll.length = LONG_DURATION;
}
return uInt(F_cursor_to_ll.length);
}
//----------------------------------------------------------------------
uInt FOptiMove::set_carriage_return (char cap[])
void FOptiMove::set_carriage_return (char cap[])
{
if ( cap )
{
@ -157,12 +183,10 @@ uInt FOptiMove::set_carriage_return (char cap[])
F_carriage_return.duration = \
F_carriage_return.length = LONG_DURATION;
}
return uInt(F_carriage_return.length);
}
//----------------------------------------------------------------------
uInt FOptiMove::set_tabular (char cap[])
void FOptiMove::set_tabular (char cap[])
{
if ( cap )
{
@ -176,12 +200,10 @@ uInt FOptiMove::set_tabular (char cap[])
F_tab.duration = \
F_tab.length = LONG_DURATION;
}
return uInt(F_tab.length);
}
//----------------------------------------------------------------------
uInt FOptiMove::set_back_tab (char cap[])
void FOptiMove::set_back_tab (char cap[])
{
if ( cap )
{
@ -195,12 +217,10 @@ uInt FOptiMove::set_back_tab (char cap[])
F_back_tab.duration = \
F_back_tab.length = LONG_DURATION;
}
return uInt(F_back_tab.length);
}
//----------------------------------------------------------------------
uInt FOptiMove::set_cursor_up (char cap[])
void FOptiMove::set_cursor_up (char cap[])
{
if ( cap )
{
@ -214,12 +234,10 @@ uInt FOptiMove::set_cursor_up (char cap[])
F_cursor_up.duration = \
F_cursor_up.length = LONG_DURATION;
}
return uInt(F_cursor_up.length);
}
//----------------------------------------------------------------------
uInt FOptiMove::set_cursor_down (char cap[])
void FOptiMove::set_cursor_down (char cap[])
{
if ( cap )
{
@ -233,12 +251,10 @@ uInt FOptiMove::set_cursor_down (char cap[])
F_cursor_down.duration = \
F_cursor_down.length = LONG_DURATION;
}
return uInt(F_cursor_down.length);
}
//----------------------------------------------------------------------
uInt FOptiMove::set_cursor_left (char cap[])
void FOptiMove::set_cursor_left (char cap[])
{
if ( cap )
{
@ -252,12 +268,10 @@ uInt FOptiMove::set_cursor_left (char cap[])
F_cursor_left.duration = \
F_cursor_left.length = LONG_DURATION;
}
return uInt(F_cursor_left.length);
}
//----------------------------------------------------------------------
uInt FOptiMove::set_cursor_right (char cap[])
void FOptiMove::set_cursor_right (char cap[])
{
if ( cap )
{
@ -271,12 +285,10 @@ uInt FOptiMove::set_cursor_right (char cap[])
F_cursor_right.duration = \
F_cursor_right.length = LONG_DURATION;
}
return uInt(F_cursor_right.length);
}
//----------------------------------------------------------------------
uInt FOptiMove::set_cursor_address (char cap[])
void FOptiMove::set_cursor_address (char cap[])
{
if ( cap )
{
@ -291,12 +303,10 @@ uInt FOptiMove::set_cursor_address (char cap[])
F_cursor_address.duration = \
F_cursor_address.length = LONG_DURATION;
}
return uInt(F_cursor_address.length);
}
//----------------------------------------------------------------------
uInt FOptiMove::set_column_address (char cap[])
void FOptiMove::set_column_address (char cap[])
{
if ( cap )
{
@ -311,12 +321,10 @@ uInt FOptiMove::set_column_address (char cap[])
F_column_address.duration = \
F_column_address.length = LONG_DURATION;
}
return uInt(F_column_address.length);
}
//----------------------------------------------------------------------
uInt FOptiMove::set_row_address (char cap[])
void FOptiMove::set_row_address (char cap[])
{
if ( cap )
{
@ -331,12 +339,10 @@ uInt FOptiMove::set_row_address (char cap[])
F_row_address.duration = \
F_row_address.length = LONG_DURATION;
}
return uInt(F_row_address.length);
}
//----------------------------------------------------------------------
uInt FOptiMove::set_parm_up_cursor (char cap[])
void FOptiMove::set_parm_up_cursor (char cap[])
{
if ( cap )
{
@ -351,12 +357,10 @@ uInt FOptiMove::set_parm_up_cursor (char cap[])
F_parm_up_cursor.duration = \
F_parm_up_cursor.length = LONG_DURATION;
}
return uInt(F_parm_up_cursor.length);
}
//----------------------------------------------------------------------
uInt FOptiMove::set_parm_down_cursor (char cap[])
void FOptiMove::set_parm_down_cursor (char cap[])
{
if ( cap )
{
@ -371,12 +375,10 @@ uInt FOptiMove::set_parm_down_cursor (char cap[])
F_parm_down_cursor.duration = \
F_parm_down_cursor.length = LONG_DURATION;
}
return uInt(F_parm_down_cursor.length);
}
//----------------------------------------------------------------------
uInt FOptiMove::set_parm_left_cursor (char cap[])
void FOptiMove::set_parm_left_cursor (char cap[])
{
if ( cap )
{
@ -391,12 +393,10 @@ uInt FOptiMove::set_parm_left_cursor (char cap[])
F_parm_left_cursor.duration = \
F_parm_left_cursor.length = LONG_DURATION;
}
return uInt(F_parm_left_cursor.length);
}
//----------------------------------------------------------------------
uInt FOptiMove::set_parm_right_cursor (char cap[])
void FOptiMove::set_parm_right_cursor (char cap[])
{
if ( cap )
{
@ -411,12 +411,10 @@ uInt FOptiMove::set_parm_right_cursor (char cap[])
F_parm_right_cursor.duration = \
F_parm_right_cursor.length = LONG_DURATION;
}
return uInt(F_parm_right_cursor.length);
}
//----------------------------------------------------------------------
uInt FOptiMove::set_erase_chars (char cap[])
void FOptiMove::set_erase_chars (char cap[])
{
if ( cap )
{
@ -431,12 +429,10 @@ uInt FOptiMove::set_erase_chars (char cap[])
F_erase_chars.duration = \
F_erase_chars.length = LONG_DURATION;
}
return uInt(F_erase_chars.length);
}
//----------------------------------------------------------------------
uInt FOptiMove::set_repeat_char (char cap[])
void FOptiMove::set_repeat_char (char cap[])
{
if ( cap )
{
@ -451,12 +447,10 @@ uInt FOptiMove::set_repeat_char (char cap[])
F_repeat_char.duration = \
F_repeat_char.length = LONG_DURATION;
}
return uInt(F_repeat_char.length);
}
//----------------------------------------------------------------------
uInt FOptiMove::set_clr_bol (char cap[])
void FOptiMove::set_clr_bol (char cap[])
{
if ( cap )
{
@ -470,12 +464,10 @@ uInt FOptiMove::set_clr_bol (char cap[])
F_clr_bol.duration = \
F_clr_bol.length = LONG_DURATION;
}
return uInt(F_clr_bol.length);
}
//----------------------------------------------------------------------
uInt FOptiMove::set_clr_eol (char cap[])
void FOptiMove::set_clr_eol (char cap[])
{
if ( cap )
{
@ -489,8 +481,6 @@ uInt FOptiMove::set_clr_eol (char cap[])
F_clr_eol.duration = \
F_clr_eol.length = LONG_DURATION;
}
return uInt(F_clr_eol.length);
}
//----------------------------------------------------------------------

View File

@ -42,11 +42,6 @@ int (*FTerm::Fputchar)(int);
// static class attributes
int FTerm::fd_tty;
int FTerm::stdin_status_flags;
uInt FTerm::erase_char_length;
uInt FTerm::repeat_char_length;
uInt FTerm::clr_bol_length;
uInt FTerm::clr_eol_length;
uInt FTerm::cursor_address_lengths;
uInt FTerm::baudrate;
long FTerm::key_timeout;
bool FTerm::resize_term;
@ -1518,32 +1513,34 @@ void FTerm::init_OptiMove()
{
// Duration precalculation of the cursor movement strings
opti_move->setTabStop(int(FTermcap::tabstop));
opti_move->set_cursor_home (TCAP(fc::t_cursor_home));
opti_move->set_cursor_to_ll (TCAP(fc::t_cursor_to_ll));
opti_move->set_carriage_return (TCAP(fc::t_carriage_return));
opti_move->set_tabular (TCAP(fc::t_tab));
opti_move->set_back_tab (TCAP(fc::t_back_tab));
opti_move->set_cursor_up (TCAP(fc::t_cursor_up));
opti_move->set_cursor_down (TCAP(fc::t_cursor_down));
opti_move->set_cursor_left (TCAP(fc::t_cursor_left));
opti_move->set_cursor_right (TCAP(fc::t_cursor_right));
cursor_address_lengths = \
opti_move->set_cursor_address (TCAP(fc::t_cursor_address));
opti_move->set_column_address (TCAP(fc::t_column_address));
opti_move->set_row_address (TCAP(fc::t_row_address));
opti_move->set_parm_up_cursor (TCAP(fc::t_parm_up_cursor));
opti_move->set_parm_down_cursor (TCAP(fc::t_parm_down_cursor));
opti_move->set_parm_left_cursor (TCAP(fc::t_parm_left_cursor));
opti_move->set_parm_right_cursor (TCAP(fc::t_parm_right_cursor));
opti_move->set_auto_left_margin (FTermcap::automatic_left_margin);
opti_move->set_eat_newline_glitch (FTermcap::eat_nl_glitch);
erase_char_length = \
opti_move->set_erase_chars (TCAP(fc::t_erase_chars));
repeat_char_length = \
opti_move->set_repeat_char (TCAP(fc::t_repeat_char));
clr_bol_length = opti_move->set_clr_bol (TCAP(fc::t_clr_bol));
clr_eol_length = opti_move->set_clr_eol (TCAP(fc::t_clr_eol));
FOptiMove::termEnv optimove_env =
{
FTermcap::automatic_left_margin,
FTermcap::eat_nl_glitch,
FTermcap::tabstop,
TCAP(fc::t_cursor_home),
TCAP(fc::t_carriage_return),
TCAP(fc::t_cursor_to_ll),
TCAP(fc::t_tab),
TCAP(fc::t_back_tab),
TCAP(fc::t_cursor_up),
TCAP(fc::t_cursor_down),
TCAP(fc::t_cursor_left),
TCAP(fc::t_cursor_right),
TCAP(fc::t_cursor_address),
TCAP(fc::t_column_address),
TCAP(fc::t_row_address),
TCAP(fc::t_parm_up_cursor),
TCAP(fc::t_parm_down_cursor),
TCAP(fc::t_parm_left_cursor),
TCAP(fc::t_parm_right_cursor),
TCAP(fc::t_erase_chars),
TCAP(fc::t_repeat_char),
TCAP(fc::t_clr_bol),
TCAP(fc::t_clr_eol)
};
opti_move->setTermEnvironment(optimove_env);
}
//----------------------------------------------------------------------

View File

@ -38,6 +38,11 @@ bool FVTerm::terminal_update_pending;
bool FVTerm::force_terminal_update;
bool FVTerm::stop_terminal_updates;
int FVTerm::skipped_terminal_update = 0;
uInt FVTerm::erase_char_length;
uInt FVTerm::repeat_char_length;
uInt FVTerm::clr_bol_length;
uInt FVTerm::clr_eol_length;
uInt FVTerm::cursor_address_length;
std::queue<int>* FVTerm::output_buffer = 0;
FPoint* FVTerm::term_pos = 0;
FVTerm::term_area* FVTerm::vterm = 0;
@ -2084,14 +2089,14 @@ void FVTerm::init()
// next_attribute contains the state of the next printed character
std::memcpy (&next_attribute, &term_attribute, sizeof(charData));
// receive the terminal capabilities
// Receive the terminal capabilities
tcap = FTermcap().getTermcapMap();
// create virtual terminal
// Create virtual terminal
FRect term_geometry (0, 0, getColumnNumber(), getLineNumber());
createVTerm (term_geometry);
// create virtual desktop area
// Create virtual desktop area
FPoint shadow_size(0,0);
createArea (term_geometry, shadow_size, vdesktop);
vdesktop->visible = true;
@ -2099,6 +2104,30 @@ void FVTerm::init()
// Hide the input cursor
hideCursor();
// Initialize character lengths
init_characterLengths (getFOptiMove());
}
//----------------------------------------------------------------------
void FVTerm::init_characterLengths (FOptiMove* opti_move)
{
if ( opti_move )
{
cursor_address_length = opti_move->getCursorAddressLength();
erase_char_length = opti_move->getEraseCharsLength();
repeat_char_length = opti_move->getRepeatCharLength();
clr_bol_length = opti_move->getClrBolLength();
clr_eol_length = opti_move->getClrEolLength();
}
else
{
cursor_address_length = INT_MAX;
erase_char_length = INT_MAX;
repeat_char_length = INT_MAX;
clr_bol_length = INT_MAX;
clr_eol_length = INT_MAX;
}
}
//----------------------------------------------------------------------
@ -2347,7 +2376,7 @@ bool FVTerm::canClearToEOL (uInt xmin, uInt y)
if ( beginning_whitespace == uInt(vt->width) - xmin
&& (ut || normal)
&& getClrEolLength() < beginning_whitespace )
&& clr_eol_length < beginning_whitespace )
return true;
}
@ -2382,7 +2411,7 @@ bool FVTerm::canClearLeadingWS (uInt& xmin, uInt y)
if ( leading_whitespace > xmin
&& (ut || normal)
&& getClrBolLength() < leading_whitespace )
&& clr_bol_length < leading_whitespace )
{
xmin = leading_whitespace - 1;
return true;
@ -2420,7 +2449,7 @@ bool FVTerm::canClearTrailingWS (uInt& xmax, uInt y)
if ( trailing_whitespace > uInt(vt->width) - xmax
&& (ut || normal)
&& getClrBolLength() < trailing_whitespace )
&& clr_bol_length < trailing_whitespace )
{
xmax = uInt(vt->width) - trailing_whitespace;
return true;
@ -2453,7 +2482,7 @@ bool FVTerm::skipUnchangedCharacters(uInt& x, uInt xmax, uInt y)
break;
}
if ( count > getCursorAddressLengths() )
if ( count > cursor_address_length )
{
setTermXY (int(x + count), int(y));
x = x + count - 1;
@ -2538,7 +2567,7 @@ FVTerm::exit_state FVTerm::eraseCharacters ( uInt& x, uInt xmax, uInt y
uInt start_pos = x;
bool& ut = FTermcap::background_color_erase;
if ( whitespace > getEraseCharLength() + getCursorAddressLengths()
if ( whitespace > erase_char_length + cursor_address_length
&& (ut || normal) )
{
appendAttributes (print_char);
@ -2598,7 +2627,7 @@ FVTerm::exit_state FVTerm::repeatCharacter (uInt& x, uInt xmax, uInt y)
{
uInt start_pos = x;
if ( repetitions > getRepeatCharLength()
if ( repetitions > repeat_char_length
&& print_char->code < 128 )
{
newFontChanges (print_char);

View File

@ -608,22 +608,35 @@ void FOptiMoveTest::teratermTest()
FOptiMove om;
om.setTermSize (80, 25);
om.setBaudRate (38400);
om.setTabStop (8);
om.set_eat_newline_glitch (true);
om.set_tabular (C_STR("\t"));
om.set_cursor_home (C_STR(CSI "H"));
om.set_carriage_return (C_STR("\r"));
om.set_cursor_up (C_STR(CSI "A"));
om.set_cursor_down (C_STR("\n"));
om.set_cursor_right (C_STR(CSI "C"));
om.set_cursor_left (C_STR("\b"));
om.set_cursor_address (C_STR(CSI "%i%p1%d;%p2%dH"));
om.set_column_address (C_STR(CSI "%i%p1%dG"));
om.set_row_address (C_STR(CSI "%i%p1%dd"));
om.set_parm_up_cursor (C_STR(CSI "%p1%dA"));
om.set_parm_down_cursor (C_STR(CSI "%p1%dB"));
om.set_parm_right_cursor (C_STR(CSI "%p1%dC"));
om.set_parm_left_cursor (C_STR(CSI "%p1%dD"));
FOptiMove::termEnv optimove_env =
{
false, // Automatic left margin
true, // Eat newline glitch
8, // Tab stop
C_STR(CSI "H"), // Cursor home
C_STR("\r"), // Carriage return
0, // Cursor to ll
C_STR("\t"), // Tabular
0, // Back tabular
C_STR(CSI "A"), // Cursor up
C_STR("\n"), // Cursor down
C_STR("\b"), // Cursor left
C_STR(CSI "C"), // Cursor right
C_STR(CSI "%i%p1%d;%p2%dH"), // Cursor address
C_STR(CSI "%i%p1%dG"), // Column address
C_STR(CSI "%i%p1%dd"), // Row address
C_STR(CSI "%p1%dA"), // Parm up cursor
C_STR(CSI "%p1%dB"), // Parm down cursor
C_STR(CSI "%p1%dD"), // Parm left cursor
C_STR(CSI "%p1%dC"), // Parm right cursor
C_STR(CSI "%p1%dX"), // Erase characters
0, // Repeat character
C_STR(CSI "1K"), // Clear to beginning of line
C_STR(CSI "K") // Clear to end of line
};
om.setTermEnvironment(optimove_env);
//std::cout << "\nSequence: "
// << printSequence(om.moveCursor (1, 2, 3, 4))