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> 2017-06-25 Markus Gans <guru.mail@muenster.de>
* All termcap values required in FOptiAttr can now be passed * All termcap values required in FOptiAttr can now be passed
with a single struct with a single struct

View File

@ -93,6 +93,13 @@ void move (int xold, int yold, int xnew, int ynew)
char* buffer; char* buffer;
char from[10], to[10], byte[20]; char from[10], to[10], byte[20];
uInt len; 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(xold, yold);
term_boundaries(xnew, ynew); 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++) for (uInt i = 0; i < len; i++)
{ {
switch ( buffer[i] ) char ch = buffer[i];
{
case 0x08:
sequence += "BS ";
break;
case 0x09: if ( ch < 0x20 )
sequence += "TAB "; sequence += ctrl_character[uInt(ch)];
break; else
sequence += ch;
case 0x0a:
sequence += "LF ";
break;
case 0x0d:
sequence += "CR ";
break;
case 0x1b:
sequence += "Esc ";
break;
default:
sequence += buffer[i];
sequence += ' '; sequence += ' ';
} }
}
std::cout << std::setw(21) << sequence << " "; std::cout << std::setw(21) << sequence << " ";

View File

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

View File

@ -75,6 +75,34 @@
class FOptiMove class FOptiMove
{ {
public: 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 // Constructor
explicit FOptiMove (int = 0); explicit FOptiMove (int = 0);
@ -83,31 +111,52 @@ class FOptiMove
// Accessors // Accessors
const char* getClassName() const; 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 // Mutators
void setBaudRate (int); void setBaudRate (int);
void setTabStop (int); void setTabStop (int);
void setTermSize (int, int); void setTermSize (int, int);
uInt set_cursor_home (char[]); void setTermEnvironment (termEnv&);
uInt set_cursor_to_ll (char[]); void set_cursor_home (char[]);
uInt set_carriage_return (char[]); void set_cursor_to_ll (char[]);
uInt set_tabular (char[]); void set_carriage_return (char[]);
uInt set_back_tab (char[]); void set_tabular (char[]);
uInt set_cursor_up (char[]); void set_back_tab (char[]);
uInt set_cursor_down (char[]); void set_cursor_up (char[]);
uInt set_cursor_left (char[]); void set_cursor_down (char[]);
uInt set_cursor_right (char[]); void set_cursor_left (char[]);
uInt set_cursor_address (char[]); void set_cursor_right (char[]);
uInt set_column_address (char[]); void set_cursor_address (char[]);
uInt set_row_address (char[]); void set_column_address (char[]);
uInt set_parm_up_cursor (char[]); void set_row_address (char[]);
uInt set_parm_down_cursor (char[]); void set_parm_up_cursor (char[]);
uInt set_parm_left_cursor (char[]); void set_parm_down_cursor (char[]);
uInt set_parm_right_cursor (char[]); void set_parm_left_cursor (char[]);
uInt set_erase_chars (char[]); void set_parm_right_cursor (char[]);
uInt set_repeat_char (char[]); void set_erase_chars (char[]);
uInt set_clr_bol (char[]); void set_repeat_char (char[]);
uInt set_clr_eol (char[]); void set_clr_bol (char[]);
void set_clr_eol (char[]);
void set_auto_left_margin (const bool&); void set_auto_left_margin (const bool&);
void set_eat_newline_glitch (const bool&); void set_eat_newline_glitch (const bool&);
@ -196,6 +245,86 @@ class FOptiMove
inline const char* FOptiMove::getClassName() const inline const char* FOptiMove::getClassName() const
{ return "FOptiMove"; } { 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) inline void FOptiMove::set_auto_left_margin (const bool& bcap)
{ automatic_left_margin = bcap; } { automatic_left_margin = bcap; }

View File

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

View File

@ -391,6 +391,7 @@ class FVTerm : public FTerm
// Methods // Methods
void init(); void init();
static void init_characterLengths (FOptiMove*);
void finish(); void finish();
static void putAreaLine (charData*, charData*, int); static void putAreaLine (charData*, charData*, int);
static void putAreaCharacter ( int, int, FVTerm* static void putAreaCharacter ( int, int, FVTerm*
@ -442,6 +443,11 @@ class FVTerm : public FTerm
static bool force_terminal_update; static bool force_terminal_update;
static bool stop_terminal_updates; static bool stop_terminal_updates;
static int skipped_terminal_update; 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) #pragma pack(pop)

View File

@ -106,41 +106,41 @@ void FOptiAttr::setTermEnvironment (termEnv& term_env)
max_color = term_env.max_color; max_color = term_env.max_color;
attr_without_color = term_env.attr_without_color; attr_without_color = term_env.attr_without_color;
set_enter_bold_mode (term_env.F_enter_bold_mode); set_enter_bold_mode (term_env.t_enter_bold_mode);
set_exit_bold_mode (term_env.F_exit_bold_mode); set_exit_bold_mode (term_env.t_exit_bold_mode);
set_enter_dim_mode (term_env.F_enter_dim_mode); set_enter_dim_mode (term_env.t_enter_dim_mode);
set_exit_dim_mode (term_env.F_exit_dim_mode); set_exit_dim_mode (term_env.t_exit_dim_mode);
set_enter_italics_mode (term_env.F_enter_italics_mode); set_enter_italics_mode (term_env.t_enter_italics_mode);
set_exit_italics_mode (term_env.F_exit_italics_mode); set_exit_italics_mode (term_env.t_exit_italics_mode);
set_enter_underline_mode (term_env.F_enter_underline_mode); set_enter_underline_mode (term_env.t_enter_underline_mode);
set_exit_underline_mode (term_env.F_exit_underline_mode); set_exit_underline_mode (term_env.t_exit_underline_mode);
set_enter_blink_mode (term_env.F_enter_blink_mode); set_enter_blink_mode (term_env.t_enter_blink_mode);
set_exit_blink_mode (term_env.F_exit_blink_mode); set_exit_blink_mode (term_env.t_exit_blink_mode);
set_enter_reverse_mode (term_env.F_enter_reverse_mode); set_enter_reverse_mode (term_env.t_enter_reverse_mode);
set_exit_reverse_mode (term_env.F_exit_reverse_mode); set_exit_reverse_mode (term_env.t_exit_reverse_mode);
set_enter_standout_mode (term_env.F_enter_standout_mode); set_enter_standout_mode (term_env.t_enter_standout_mode);
set_exit_standout_mode (term_env.F_exit_standout_mode); set_exit_standout_mode (term_env.t_exit_standout_mode);
set_enter_secure_mode (term_env.F_enter_secure_mode); set_enter_secure_mode (term_env.t_enter_secure_mode);
set_exit_secure_mode (term_env.F_exit_secure_mode); set_exit_secure_mode (term_env.t_exit_secure_mode);
set_enter_protected_mode (term_env.F_enter_protected_mode); set_enter_protected_mode (term_env.t_enter_protected_mode);
set_exit_protected_mode (term_env.F_exit_protected_mode); set_exit_protected_mode (term_env.t_exit_protected_mode);
set_enter_crossed_out_mode (term_env.F_enter_crossed_out_mode); set_enter_crossed_out_mode (term_env.t_enter_crossed_out_mode);
set_exit_crossed_out_mode (term_env.F_exit_crossed_out_mode); set_exit_crossed_out_mode (term_env.t_exit_crossed_out_mode);
set_enter_dbl_underline_mode (term_env.F_enter_dbl_underline_mode); set_enter_dbl_underline_mode (term_env.t_enter_dbl_underline_mode);
set_exit_dbl_underline_mode (term_env.F_exit_dbl_underline_mode); set_exit_dbl_underline_mode (term_env.t_exit_dbl_underline_mode);
set_set_attributes (term_env.F_set_attributes); set_set_attributes (term_env.t_set_attributes);
set_exit_attribute_mode (term_env.F_exit_attribute_mode); set_exit_attribute_mode (term_env.t_exit_attribute_mode);
set_enter_alt_charset_mode (term_env.F_enter_alt_charset_mode); set_enter_alt_charset_mode (term_env.t_enter_alt_charset_mode);
set_exit_alt_charset_mode (term_env.F_exit_alt_charset_mode); set_exit_alt_charset_mode (term_env.t_exit_alt_charset_mode);
set_enter_pc_charset_mode (term_env.F_enter_pc_charset_mode); set_enter_pc_charset_mode (term_env.t_enter_pc_charset_mode);
set_exit_pc_charset_mode (term_env.F_exit_pc_charset_mode); set_exit_pc_charset_mode (term_env.t_exit_pc_charset_mode);
set_a_foreground_color (term_env.F_set_a_foreground); set_a_foreground_color (term_env.t_set_a_foreground);
set_a_background_color (term_env.F_set_a_background); set_a_background_color (term_env.t_set_a_background);
set_foreground_color (term_env.F_set_foreground); set_foreground_color (term_env.t_set_foreground);
set_background_color (term_env.F_set_background); set_background_color (term_env.t_set_background);
set_term_color_pair (term_env.F_set_color_pair); set_term_color_pair (term_env.t_set_color_pair);
set_orig_pair (term_env.F_orig_pair); set_orig_pair (term_env.t_orig_pair);
set_orig_orig_colors (term_env.F_orig_colors); set_orig_orig_colors (term_env.t_orig_colors);
initialize(); 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 ) if ( cap )
{ {
@ -119,12 +149,10 @@ uInt FOptiMove::set_cursor_home (char cap[])
F_cursor_home.duration = \ F_cursor_home.duration = \
F_cursor_home.length = LONG_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 ) if ( cap )
{ {
@ -138,12 +166,10 @@ uInt FOptiMove::set_cursor_to_ll (char cap[])
F_cursor_to_ll.duration = \ F_cursor_to_ll.duration = \
F_cursor_to_ll.length = LONG_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 ) if ( cap )
{ {
@ -157,12 +183,10 @@ uInt FOptiMove::set_carriage_return (char cap[])
F_carriage_return.duration = \ F_carriage_return.duration = \
F_carriage_return.length = LONG_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 ) if ( cap )
{ {
@ -176,12 +200,10 @@ uInt FOptiMove::set_tabular (char cap[])
F_tab.duration = \ F_tab.duration = \
F_tab.length = LONG_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 ) if ( cap )
{ {
@ -195,12 +217,10 @@ uInt FOptiMove::set_back_tab (char cap[])
F_back_tab.duration = \ F_back_tab.duration = \
F_back_tab.length = LONG_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 ) if ( cap )
{ {
@ -214,12 +234,10 @@ uInt FOptiMove::set_cursor_up (char cap[])
F_cursor_up.duration = \ F_cursor_up.duration = \
F_cursor_up.length = LONG_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 ) if ( cap )
{ {
@ -233,12 +251,10 @@ uInt FOptiMove::set_cursor_down (char cap[])
F_cursor_down.duration = \ F_cursor_down.duration = \
F_cursor_down.length = LONG_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 ) if ( cap )
{ {
@ -252,12 +268,10 @@ uInt FOptiMove::set_cursor_left (char cap[])
F_cursor_left.duration = \ F_cursor_left.duration = \
F_cursor_left.length = LONG_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 ) if ( cap )
{ {
@ -271,12 +285,10 @@ uInt FOptiMove::set_cursor_right (char cap[])
F_cursor_right.duration = \ F_cursor_right.duration = \
F_cursor_right.length = LONG_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 ) if ( cap )
{ {
@ -291,12 +303,10 @@ uInt FOptiMove::set_cursor_address (char cap[])
F_cursor_address.duration = \ F_cursor_address.duration = \
F_cursor_address.length = LONG_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 ) if ( cap )
{ {
@ -311,12 +321,10 @@ uInt FOptiMove::set_column_address (char cap[])
F_column_address.duration = \ F_column_address.duration = \
F_column_address.length = LONG_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 ) if ( cap )
{ {
@ -331,12 +339,10 @@ uInt FOptiMove::set_row_address (char cap[])
F_row_address.duration = \ F_row_address.duration = \
F_row_address.length = LONG_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 ) if ( cap )
{ {
@ -351,12 +357,10 @@ uInt FOptiMove::set_parm_up_cursor (char cap[])
F_parm_up_cursor.duration = \ F_parm_up_cursor.duration = \
F_parm_up_cursor.length = LONG_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 ) if ( cap )
{ {
@ -371,12 +375,10 @@ uInt FOptiMove::set_parm_down_cursor (char cap[])
F_parm_down_cursor.duration = \ F_parm_down_cursor.duration = \
F_parm_down_cursor.length = LONG_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 ) if ( cap )
{ {
@ -391,12 +393,10 @@ uInt FOptiMove::set_parm_left_cursor (char cap[])
F_parm_left_cursor.duration = \ F_parm_left_cursor.duration = \
F_parm_left_cursor.length = LONG_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 ) if ( cap )
{ {
@ -411,12 +411,10 @@ uInt FOptiMove::set_parm_right_cursor (char cap[])
F_parm_right_cursor.duration = \ F_parm_right_cursor.duration = \
F_parm_right_cursor.length = LONG_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 ) if ( cap )
{ {
@ -431,12 +429,10 @@ uInt FOptiMove::set_erase_chars (char cap[])
F_erase_chars.duration = \ F_erase_chars.duration = \
F_erase_chars.length = LONG_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 ) if ( cap )
{ {
@ -451,12 +447,10 @@ uInt FOptiMove::set_repeat_char (char cap[])
F_repeat_char.duration = \ F_repeat_char.duration = \
F_repeat_char.length = LONG_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 ) if ( cap )
{ {
@ -470,12 +464,10 @@ uInt FOptiMove::set_clr_bol (char cap[])
F_clr_bol.duration = \ F_clr_bol.duration = \
F_clr_bol.length = LONG_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 ) if ( cap )
{ {
@ -489,8 +481,6 @@ uInt FOptiMove::set_clr_eol (char cap[])
F_clr_eol.duration = \ F_clr_eol.duration = \
F_clr_eol.length = LONG_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 // static class attributes
int FTerm::fd_tty; int FTerm::fd_tty;
int FTerm::stdin_status_flags; 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; uInt FTerm::baudrate;
long FTerm::key_timeout; long FTerm::key_timeout;
bool FTerm::resize_term; bool FTerm::resize_term;
@ -1518,32 +1513,34 @@ void FTerm::init_OptiMove()
{ {
// Duration precalculation of the cursor movement strings // Duration precalculation of the cursor movement strings
opti_move->setTabStop(int(FTermcap::tabstop)); FOptiMove::termEnv optimove_env =
opti_move->set_cursor_home (TCAP(fc::t_cursor_home)); {
opti_move->set_cursor_to_ll (TCAP(fc::t_cursor_to_ll)); FTermcap::automatic_left_margin,
opti_move->set_carriage_return (TCAP(fc::t_carriage_return)); FTermcap::eat_nl_glitch,
opti_move->set_tabular (TCAP(fc::t_tab)); FTermcap::tabstop,
opti_move->set_back_tab (TCAP(fc::t_back_tab)); TCAP(fc::t_cursor_home),
opti_move->set_cursor_up (TCAP(fc::t_cursor_up)); TCAP(fc::t_carriage_return),
opti_move->set_cursor_down (TCAP(fc::t_cursor_down)); TCAP(fc::t_cursor_to_ll),
opti_move->set_cursor_left (TCAP(fc::t_cursor_left)); TCAP(fc::t_tab),
opti_move->set_cursor_right (TCAP(fc::t_cursor_right)); TCAP(fc::t_back_tab),
cursor_address_lengths = \ TCAP(fc::t_cursor_up),
opti_move->set_cursor_address (TCAP(fc::t_cursor_address)); TCAP(fc::t_cursor_down),
opti_move->set_column_address (TCAP(fc::t_column_address)); TCAP(fc::t_cursor_left),
opti_move->set_row_address (TCAP(fc::t_row_address)); TCAP(fc::t_cursor_right),
opti_move->set_parm_up_cursor (TCAP(fc::t_parm_up_cursor)); TCAP(fc::t_cursor_address),
opti_move->set_parm_down_cursor (TCAP(fc::t_parm_down_cursor)); TCAP(fc::t_column_address),
opti_move->set_parm_left_cursor (TCAP(fc::t_parm_left_cursor)); TCAP(fc::t_row_address),
opti_move->set_parm_right_cursor (TCAP(fc::t_parm_right_cursor)); TCAP(fc::t_parm_up_cursor),
opti_move->set_auto_left_margin (FTermcap::automatic_left_margin); TCAP(fc::t_parm_down_cursor),
opti_move->set_eat_newline_glitch (FTermcap::eat_nl_glitch); TCAP(fc::t_parm_left_cursor),
erase_char_length = \ TCAP(fc::t_parm_right_cursor),
opti_move->set_erase_chars (TCAP(fc::t_erase_chars)); TCAP(fc::t_erase_chars),
repeat_char_length = \ TCAP(fc::t_repeat_char),
opti_move->set_repeat_char (TCAP(fc::t_repeat_char)); TCAP(fc::t_clr_bol),
clr_bol_length = opti_move->set_clr_bol (TCAP(fc::t_clr_bol)); TCAP(fc::t_clr_eol)
clr_eol_length = opti_move->set_clr_eol (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::force_terminal_update;
bool FVTerm::stop_terminal_updates; bool FVTerm::stop_terminal_updates;
int FVTerm::skipped_terminal_update = 0; 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; std::queue<int>* FVTerm::output_buffer = 0;
FPoint* FVTerm::term_pos = 0; FPoint* FVTerm::term_pos = 0;
FVTerm::term_area* FVTerm::vterm = 0; FVTerm::term_area* FVTerm::vterm = 0;
@ -2084,14 +2089,14 @@ void FVTerm::init()
// next_attribute contains the state of the next printed character // next_attribute contains the state of the next printed character
std::memcpy (&next_attribute, &term_attribute, sizeof(charData)); std::memcpy (&next_attribute, &term_attribute, sizeof(charData));
// receive the terminal capabilities // Receive the terminal capabilities
tcap = FTermcap().getTermcapMap(); tcap = FTermcap().getTermcapMap();
// create virtual terminal // Create virtual terminal
FRect term_geometry (0, 0, getColumnNumber(), getLineNumber()); FRect term_geometry (0, 0, getColumnNumber(), getLineNumber());
createVTerm (term_geometry); createVTerm (term_geometry);
// create virtual desktop area // Create virtual desktop area
FPoint shadow_size(0,0); FPoint shadow_size(0,0);
createArea (term_geometry, shadow_size, vdesktop); createArea (term_geometry, shadow_size, vdesktop);
vdesktop->visible = true; vdesktop->visible = true;
@ -2099,6 +2104,30 @@ void FVTerm::init()
// Hide the input cursor // Hide the input cursor
hideCursor(); 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 if ( beginning_whitespace == uInt(vt->width) - xmin
&& (ut || normal) && (ut || normal)
&& getClrEolLength() < beginning_whitespace ) && clr_eol_length < beginning_whitespace )
return true; return true;
} }
@ -2382,7 +2411,7 @@ bool FVTerm::canClearLeadingWS (uInt& xmin, uInt y)
if ( leading_whitespace > xmin if ( leading_whitespace > xmin
&& (ut || normal) && (ut || normal)
&& getClrBolLength() < leading_whitespace ) && clr_bol_length < leading_whitespace )
{ {
xmin = leading_whitespace - 1; xmin = leading_whitespace - 1;
return true; return true;
@ -2420,7 +2449,7 @@ bool FVTerm::canClearTrailingWS (uInt& xmax, uInt y)
if ( trailing_whitespace > uInt(vt->width) - xmax if ( trailing_whitespace > uInt(vt->width) - xmax
&& (ut || normal) && (ut || normal)
&& getClrBolLength() < trailing_whitespace ) && clr_bol_length < trailing_whitespace )
{ {
xmax = uInt(vt->width) - trailing_whitespace; xmax = uInt(vt->width) - trailing_whitespace;
return true; return true;
@ -2453,7 +2482,7 @@ bool FVTerm::skipUnchangedCharacters(uInt& x, uInt xmax, uInt y)
break; break;
} }
if ( count > getCursorAddressLengths() ) if ( count > cursor_address_length )
{ {
setTermXY (int(x + count), int(y)); setTermXY (int(x + count), int(y));
x = x + count - 1; x = x + count - 1;
@ -2538,7 +2567,7 @@ FVTerm::exit_state FVTerm::eraseCharacters ( uInt& x, uInt xmax, uInt y
uInt start_pos = x; uInt start_pos = x;
bool& ut = FTermcap::background_color_erase; bool& ut = FTermcap::background_color_erase;
if ( whitespace > getEraseCharLength() + getCursorAddressLengths() if ( whitespace > erase_char_length + cursor_address_length
&& (ut || normal) ) && (ut || normal) )
{ {
appendAttributes (print_char); appendAttributes (print_char);
@ -2598,7 +2627,7 @@ FVTerm::exit_state FVTerm::repeatCharacter (uInt& x, uInt xmax, uInt y)
{ {
uInt start_pos = x; uInt start_pos = x;
if ( repetitions > getRepeatCharLength() if ( repetitions > repeat_char_length
&& print_char->code < 128 ) && print_char->code < 128 )
{ {
newFontChanges (print_char); newFontChanges (print_char);

View File

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