Small optimizations
This commit is contained in:
parent
8407a9d2b6
commit
f19b4811ae
|
@ -2676,14 +2676,13 @@ inline void FString::_assign (const wchar_t s[])
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FString::_insert (uInt pos, uInt len, const wchar_t s[])
|
||||
inline void FString::_insert (uInt len, const wchar_t s[])
|
||||
{
|
||||
if ( len == 0 ) // String s is a null or a empty string
|
||||
return;
|
||||
|
||||
if ( ! string )
|
||||
{
|
||||
// string is null
|
||||
if ( string )
|
||||
delete[](string);
|
||||
|
||||
length = len;
|
||||
bufsize = FWDBUFFER + length + 1;
|
||||
|
@ -2700,15 +2699,21 @@ inline void FString::_insert (uInt pos, uInt len, const wchar_t s[])
|
|||
|
||||
std::wcsncpy (string, s, bufsize);
|
||||
string[bufsize - 1] = L'\0';
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FString::_insert (uInt pos, uInt len, const wchar_t s[])
|
||||
{
|
||||
if ( len == 0 ) // String s is a null or a empty string
|
||||
return;
|
||||
|
||||
if ( ! string ) // string is null
|
||||
{
|
||||
_insert (len, s);
|
||||
}
|
||||
else
|
||||
{
|
||||
uInt x;
|
||||
uInt insert_len = uInt(std::wcslen(s));
|
||||
|
||||
if ( len > insert_len )
|
||||
len = insert_len;
|
||||
|
||||
if ( (length + len + 1) <= bufsize )
|
||||
{
|
||||
|
|
101
src/fterm.cpp
101
src/fterm.cpp
|
@ -1259,6 +1259,46 @@ void FTerm::init_termcap_strings (char*& buffer)
|
|||
tcap[i].string = tgetstr(tcap[i].tname, &buffer);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FTerm::init_termcap_keys_vt100 (char*& buffer)
|
||||
{
|
||||
// Some terminals (e.g. PuTTY) send vt100 key codes for
|
||||
// the arrow and function keys.
|
||||
|
||||
char* key_up_string = tgetstr(C_STR("ku"), &buffer);
|
||||
|
||||
if ( (key_up_string && (std::strcmp(key_up_string, CSI "A") == 0))
|
||||
|| ( TCAP(fc::t_cursor_up)
|
||||
&& (std::strcmp(TCAP(fc::t_cursor_up), CSI "A") == 0) ) )
|
||||
{
|
||||
for (int i = 0; fc::Fkey[i].tname[0] != 0; i++)
|
||||
{
|
||||
if ( std::strncmp(fc::Fkey[i].tname, "kux", 3) == 0 )
|
||||
fc::Fkey[i].string = C_STR(CSI "A"); // Key up
|
||||
|
||||
if ( std::strncmp(fc::Fkey[i].tname, "kdx", 3) == 0 )
|
||||
fc::Fkey[i].string = C_STR(CSI "B"); // Key down
|
||||
|
||||
if ( std::strncmp(fc::Fkey[i].tname, "krx", 3) == 0 )
|
||||
fc::Fkey[i].string = C_STR(CSI "C"); // Key right
|
||||
|
||||
if ( std::strncmp(fc::Fkey[i].tname, "klx", 3) == 0 )
|
||||
fc::Fkey[i].string = C_STR(CSI "D"); // Key left
|
||||
|
||||
if ( std::strncmp(fc::Fkey[i].tname, "k1X", 3) == 0 )
|
||||
fc::Fkey[i].string = C_STR(ESC "OP"); // PF1
|
||||
|
||||
if ( std::strncmp(fc::Fkey[i].tname, "k2X", 3) == 0 )
|
||||
fc::Fkey[i].string = C_STR(ESC "OQ"); // PF2
|
||||
|
||||
if ( std::strncmp(fc::Fkey[i].tname, "k3X", 3) == 0 )
|
||||
fc::Fkey[i].string = C_STR(ESC "OR"); // PF3
|
||||
|
||||
if ( std::strncmp(fc::Fkey[i].tname, "k4X", 3) == 0 )
|
||||
fc::Fkey[i].string = C_STR(ESC "OS"); // PF4
|
||||
}
|
||||
}
|
||||
}
|
||||
//----------------------------------------------------------------------
|
||||
void FTerm::init_termcap_keys (char*& buffer)
|
||||
{
|
||||
|
@ -1308,42 +1348,8 @@ void FTerm::init_termcap_keys (char*& buffer)
|
|||
fc::Fkey[i].string = C_STR(ESC "Ok"); // Keypad plus sign
|
||||
}
|
||||
|
||||
// Some terminals (e.g. PuTTY) send the wrong code for the arrow keys
|
||||
// http://www.unix.com/shell-programming-scripting/..
|
||||
// ..110380-using-arrow-keys-shell-scripts.html
|
||||
char* key_up_string = tgetstr(C_STR("ku"), &buffer);
|
||||
|
||||
if ( (key_up_string && (std::strcmp(key_up_string, CSI "A") == 0))
|
||||
|| ( TCAP(fc::t_cursor_up)
|
||||
&& (std::strcmp(TCAP(fc::t_cursor_up), CSI "A") == 0) ) )
|
||||
{
|
||||
for (int i = 0; fc::Fkey[i].tname[0] != 0; i++)
|
||||
{
|
||||
if ( std::strncmp(fc::Fkey[i].tname, "kux", 3) == 0 )
|
||||
fc::Fkey[i].string = C_STR(CSI "A"); // Key up
|
||||
|
||||
if ( std::strncmp(fc::Fkey[i].tname, "kdx", 3) == 0 )
|
||||
fc::Fkey[i].string = C_STR(CSI "B"); // Key down
|
||||
|
||||
if ( std::strncmp(fc::Fkey[i].tname, "krx", 3) == 0 )
|
||||
fc::Fkey[i].string = C_STR(CSI "C"); // Key right
|
||||
|
||||
if ( std::strncmp(fc::Fkey[i].tname, "klx", 3) == 0 )
|
||||
fc::Fkey[i].string = C_STR(CSI "D"); // Key left
|
||||
|
||||
if ( std::strncmp(fc::Fkey[i].tname, "k1X", 3) == 0 )
|
||||
fc::Fkey[i].string = C_STR(ESC "OP"); // PF1
|
||||
|
||||
if ( std::strncmp(fc::Fkey[i].tname, "k2X", 3) == 0 )
|
||||
fc::Fkey[i].string = C_STR(ESC "OQ"); // PF2
|
||||
|
||||
if ( std::strncmp(fc::Fkey[i].tname, "k3X", 3) == 0 )
|
||||
fc::Fkey[i].string = C_STR(ESC "OR"); // PF3
|
||||
|
||||
if ( std::strncmp(fc::Fkey[i].tname, "k4X", 3) == 0 )
|
||||
fc::Fkey[i].string = C_STR(ESC "OS"); // PF4
|
||||
}
|
||||
}
|
||||
// VT100 key codes for the arrow and function keys
|
||||
init_termcap_keys_vt100(buffer);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -1982,14 +1988,8 @@ void FTerm::init (bool disable_alt_screen)
|
|||
// Save the used xterm font and window title
|
||||
init_captureFontAndTitle();
|
||||
|
||||
if ( isKdeTerminal() )
|
||||
setKDECursor(fc::UnderlineCursor);
|
||||
|
||||
if ( isCygwinTerminal() )
|
||||
init_cygwin_charmap();
|
||||
|
||||
if ( isTeraTerm() )
|
||||
init_teraterm_charmap();
|
||||
// KDE terminal cursor and cygwin + teraterm charmap correction
|
||||
initTermspecifics();
|
||||
|
||||
// Redefine the color palette
|
||||
if ( init_values.color_change )
|
||||
|
@ -2055,6 +2055,19 @@ void FTerm::initOSspecifics()
|
|||
#endif
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FTerm::initTermspecifics()
|
||||
{
|
||||
if ( isKdeTerminal() )
|
||||
setKDECursor(fc::UnderlineCursor);
|
||||
|
||||
if ( isCygwinTerminal() )
|
||||
init_cygwin_charmap();
|
||||
|
||||
if ( isTeraTerm() )
|
||||
init_teraterm_charmap();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FTerm::finish()
|
||||
{
|
||||
|
|
|
@ -382,6 +382,7 @@ class FString
|
|||
// Methods
|
||||
void initLength (uInt);
|
||||
void _assign (const wchar_t[]);
|
||||
void _insert (uInt, const wchar_t[]);
|
||||
void _insert (uInt, uInt, const wchar_t[]);
|
||||
void _remove (uInt, uInt);
|
||||
char* wc_to_c_str (const wchar_t[]) const;
|
||||
|
|
|
@ -387,6 +387,7 @@ class FTerm
|
|||
static void init_termcap_booleans();
|
||||
static void init_termcap_numerics();
|
||||
static void init_termcap_strings (char*&);
|
||||
static void init_termcap_keys_vt100 (char*&);
|
||||
static void init_termcap_keys (char*&);
|
||||
static void init_OptiMove();
|
||||
static void init_OptiAttr();
|
||||
|
@ -412,6 +413,7 @@ class FTerm
|
|||
void deallocationValues();
|
||||
void init (bool);
|
||||
void initOSspecifics();
|
||||
void initTermspecifics();
|
||||
void finish();
|
||||
void finishOSspecifics1();
|
||||
void finish_encoding();
|
||||
|
|
|
@ -181,6 +181,9 @@ inline FTermData::FTermData()
|
|||
, termfilename()
|
||||
, xterm_font()
|
||||
, xterm_title()
|
||||
#if DEBUG
|
||||
, framebuffer_bpp(-1)
|
||||
#endif
|
||||
{
|
||||
// Initialize arrays with '\0'
|
||||
std::fill_n (termtype, sizeof(termtype), '\0');
|
||||
|
@ -370,7 +373,7 @@ inline void FTermData::setTermFileName (const char file_name[])
|
|||
return;
|
||||
|
||||
std::strncpy (termfilename, file_name, sizeof(termfilename));
|
||||
termtype[sizeof(termfilename) - 1] = '\0';
|
||||
termfilename[sizeof(termfilename) - 1] = '\0';
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
|
|
@ -287,7 +287,6 @@ void FTermcapQuirksTest::generalTest()
|
|||
, C_STR(CSI "29m") );
|
||||
CPPUNIT_ASSERT_CSTRING ( printSequence(caps[finalcut::fc::t_enter_ca_mode].string).c_str()
|
||||
, C_STR("Esc 7 Esc [ ? 4 7 h ") );
|
||||
//delete[] caps;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in New Issue