Improve compatibility with initialize_color + better TeraTerm support
This commit is contained in:
parent
5f86dad265
commit
e4ec5cb8ff
|
@ -1,3 +1,7 @@
|
||||||
|
2015-10-05 Markus Gans <guru.mail@muenster.de>
|
||||||
|
* Improve compatibility with initialize_color
|
||||||
|
* Better support for TeraTerm
|
||||||
|
|
||||||
2015-10-02 Markus Gans <guru.mail@muenster.de>
|
2015-10-02 Markus Gans <guru.mail@muenster.de>
|
||||||
* No terminal updates until input data is pending.
|
* No terminal updates until input data is pending.
|
||||||
This speeds up the window moving with the mouse on terminals
|
This speeds up the window moving with the mouse on terminals
|
||||||
|
|
|
@ -1230,9 +1230,10 @@ bool FApplication::processNextEvent()
|
||||||
|
|
||||||
while ( iter != close_widget->end() )
|
while ( iter != close_widget->end() )
|
||||||
{
|
{
|
||||||
delete(*iter);
|
delete *iter;
|
||||||
close_widget->erase(iter);
|
++iter;
|
||||||
}
|
}
|
||||||
|
close_widget->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
sendQueuedEvents();
|
sendQueuedEvents();
|
||||||
|
|
|
@ -239,6 +239,8 @@ void FButton::draw()
|
||||||
// Cygwin terminal use IBM Codepage 850
|
// Cygwin terminal use IBM Codepage 850
|
||||||
if ( isCygwinTerminal() )
|
if ( isCygwinTerminal() )
|
||||||
print (fc::FullBlock); // █
|
print (fc::FullBlock); // █
|
||||||
|
else if ( isTeraTerm() )
|
||||||
|
print (0xdb);
|
||||||
else
|
else
|
||||||
print (fc::RightHalfBlock); // ▐
|
print (fc::RightHalfBlock); // ▐
|
||||||
gotoxy (xpos+xmin-1+d, ypos+ymin-1+y);
|
gotoxy (xpos+xmin-1+d, ypos+ymin-1+y);
|
||||||
|
@ -538,7 +540,9 @@ bool FButton::setFlat (bool on)
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
bool FButton::setShadow (bool on)
|
bool FButton::setShadow (bool on)
|
||||||
{
|
{
|
||||||
if ( on && Encoding != fc::VT100 && Encoding != fc::ASCII )
|
if ( on
|
||||||
|
&& (Encoding != fc::VT100 || isTeraTerm() )
|
||||||
|
&& Encoding != fc::ASCII )
|
||||||
flags |= SHADOW;
|
flags |= SHADOW;
|
||||||
else
|
else
|
||||||
flags &= ~SHADOW;
|
flags &= ~SHADOW;
|
||||||
|
|
|
@ -16,6 +16,8 @@ static uInt character[][fc::NUM_OF_ENCODINGS] =
|
||||||
{0x00d6,0xd6, 0x99, 'O'}, // Ö - O-umlaut
|
{0x00d6,0xd6, 0x99, 'O'}, // Ö - O-umlaut
|
||||||
{0x00c4,0xc4, 0x8e, 'A'}, // Ä - A-umlaut
|
{0x00c4,0xc4, 0x8e, 'A'}, // Ä - A-umlaut
|
||||||
{0x00dc,0xdc, 0x9a, 'U'}, // Ü - U-umlaut
|
{0x00dc,0xdc, 0x9a, 'U'}, // Ü - U-umlaut
|
||||||
|
{0x00db,0xdb, 0x96, 'U'}, // Û - U-circumflex
|
||||||
|
{0x00fb,0xfb, 0x96, 'u'}, // û - u-circumflex
|
||||||
{0x00df,0xdf, 0xe1, 's'}, // ß - sz-ligature
|
{0x00df,0xdf, 0xe1, 's'}, // ß - sz-ligature
|
||||||
{0x20ac, 'E', 0xee, 'E'}, // € - Euro
|
{0x20ac, 'E', 0xee, 'E'}, // € - Euro
|
||||||
{0x00a3, '}', 0x9c, 'P'}, // £ - Pound
|
{0x00a3, '}', 0x9c, 'P'}, // £ - Pound
|
||||||
|
|
|
@ -146,6 +146,8 @@ void FLineEdit::drawInputField()
|
||||||
setColor (wc.inputfield_active_focus_bg, wc.dialog_bg);
|
setColor (wc.inputfield_active_focus_bg, wc.dialog_bg);
|
||||||
if ( isCygwinTerminal() ) // IBM Codepage 850
|
if ( isCygwinTerminal() ) // IBM Codepage 850
|
||||||
print (fc::FullBlock); // █
|
print (fc::FullBlock); // █
|
||||||
|
else if ( isTeraTerm() )
|
||||||
|
print (0xdb);
|
||||||
else
|
else
|
||||||
print (fc::RightHalfBlock); // ▐
|
print (fc::RightHalfBlock); // ▐
|
||||||
}
|
}
|
||||||
|
@ -154,6 +156,8 @@ void FLineEdit::drawInputField()
|
||||||
setColor (wc.inputfield_active_bg, wc.dialog_bg);
|
setColor (wc.inputfield_active_bg, wc.dialog_bg);
|
||||||
if ( isCygwinTerminal() ) // IBM Codepage 850
|
if ( isCygwinTerminal() ) // IBM Codepage 850
|
||||||
print (fc::FullBlock); // █
|
print (fc::FullBlock); // █
|
||||||
|
else if ( isTeraTerm() )
|
||||||
|
print (0xdb);
|
||||||
else
|
else
|
||||||
print (fc::RightHalfBlock); // ▐
|
print (fc::RightHalfBlock); // ▐
|
||||||
}
|
}
|
||||||
|
@ -162,6 +166,8 @@ void FLineEdit::drawInputField()
|
||||||
setColor (wc.inputfield_inactive_bg, wc.dialog_bg);
|
setColor (wc.inputfield_inactive_bg, wc.dialog_bg);
|
||||||
if ( isCygwinTerminal() ) // IBM Codepage 850
|
if ( isCygwinTerminal() ) // IBM Codepage 850
|
||||||
print (fc::FullBlock); // █
|
print (fc::FullBlock); // █
|
||||||
|
else if ( isTeraTerm() )
|
||||||
|
print (0xdb);
|
||||||
else
|
else
|
||||||
print (fc::RightHalfBlock); // ▐
|
print (fc::RightHalfBlock); // ▐
|
||||||
}
|
}
|
||||||
|
@ -369,7 +375,9 @@ bool FLineEdit::setFocus (bool on)
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
bool FLineEdit::setShadow (bool on)
|
bool FLineEdit::setShadow (bool on)
|
||||||
{
|
{
|
||||||
if ( on )
|
if ( on
|
||||||
|
&& (Encoding != fc::VT100 || isTeraTerm() )
|
||||||
|
&& Encoding != fc::ASCII )
|
||||||
flags |= SHADOW;
|
flags |= SHADOW;
|
||||||
else
|
else
|
||||||
flags &= ~SHADOW;
|
flags &= ~SHADOW;
|
||||||
|
|
|
@ -2161,7 +2161,6 @@ bool FString::includes (const char* s)
|
||||||
if ( ! wc_string )
|
if ( ! wc_string )
|
||||||
return false;
|
return false;
|
||||||
ret = bool(wcsstr(string, wc_string) != 0);
|
ret = bool(wcsstr(string, wc_string) != 0);
|
||||||
if ( wc_string )
|
|
||||||
delete[] wc_string;
|
delete[] wc_string;
|
||||||
return (ret);
|
return (ret);
|
||||||
}
|
}
|
||||||
|
|
|
@ -574,14 +574,14 @@ void FTerm::init_termcaps()
|
||||||
tcap[t_set_a_background].string = \
|
tcap[t_set_a_background].string = \
|
||||||
const_cast<char*>("\033[4%p1%{8}%m%d%?%p1%{7}%>%t;5%e;25%;m");
|
const_cast<char*>("\033[4%p1%{8}%m%d%?%p1%{7}%>%t;5%e;25%;m");
|
||||||
}
|
}
|
||||||
if ( tera_terminal && color256 )
|
else if ( tera_terminal && color256 )
|
||||||
{
|
{
|
||||||
tcap[t_set_a_foreground].string = \
|
tcap[t_set_a_foreground].string = \
|
||||||
const_cast<char*>("\033[38;5;%p1%dm");
|
const_cast<char*>("\033[38;5;%p1%dm");
|
||||||
tcap[t_set_a_background].string = \
|
tcap[t_set_a_background].string = \
|
||||||
const_cast<char*>("\033[48;5;%p1%dm");
|
const_cast<char*>("\033[48;5;%p1%dm");
|
||||||
}
|
}
|
||||||
if ( putty_terminal )
|
else if ( putty_terminal )
|
||||||
{
|
{
|
||||||
tcap[t_set_a_foreground].string = \
|
tcap[t_set_a_foreground].string = \
|
||||||
const_cast<char*>("\033[%?%p1%{8}%<"
|
const_cast<char*>("\033[%?%p1%{8}%<"
|
||||||
|
@ -596,13 +596,25 @@ void FTerm::init_termcaps()
|
||||||
"%t10%p1%{8}%-%d"
|
"%t10%p1%{8}%-%d"
|
||||||
"%e48;5;%p1%d%;m");
|
"%e48;5;%p1%d%;m");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// fallback if "AF" is not found
|
||||||
if ( ! tcap[t_set_a_foreground].string )
|
if ( ! tcap[t_set_a_foreground].string )
|
||||||
tcap[t_set_a_foreground].string = \
|
tcap[t_set_a_foreground].string = \
|
||||||
const_cast<char*>("\033[3%p1%dm");
|
const_cast<char*>("\033[3%p1%dm");
|
||||||
|
|
||||||
|
// fallback if "AB" is not found
|
||||||
if ( ! tcap[t_set_a_background].string )
|
if ( ! tcap[t_set_a_background].string )
|
||||||
tcap[t_set_a_background].string = \
|
tcap[t_set_a_background].string = \
|
||||||
const_cast<char*>("\033[4%p1%dm");
|
const_cast<char*>("\033[4%p1%dm");
|
||||||
|
|
||||||
|
// fallback if "Ic" is not found
|
||||||
|
if ( ! tcap[t_initialize_color].string )
|
||||||
|
tcap[t_initialize_color].string = \
|
||||||
|
const_cast<char*>("\033]P%p1%x"
|
||||||
|
"%p2%{255}%*%{1000}%/%02x"
|
||||||
|
"%p3%{255}%*%{1000}%/%02x"
|
||||||
|
"%p4%{255}%*%{1000}%/%02x");
|
||||||
|
|
||||||
// fallback if "ti" is not found
|
// fallback if "ti" is not found
|
||||||
if ( ! tcap[t_enter_ca_mode].string )
|
if ( ! tcap[t_enter_ca_mode].string )
|
||||||
tcap[t_enter_ca_mode].string = \
|
tcap[t_enter_ca_mode].string = \
|
||||||
|
@ -1089,6 +1101,9 @@ void FTerm::init()
|
||||||
else
|
else
|
||||||
cygwin_terminal = false;
|
cygwin_terminal = false;
|
||||||
|
|
||||||
|
if ( strncmp(termtype, "rxvt-cygwin-native", 18) == 0 )
|
||||||
|
new_termtype = const_cast<char*>("rxvt-16color");
|
||||||
|
|
||||||
if ( (s1 && strncmp(s1, "gnome-terminal", 14) == 0) || s2 )
|
if ( (s1 && strncmp(s1, "gnome-terminal", 14) == 0) || s2 )
|
||||||
{
|
{
|
||||||
if ( color256 )
|
if ( color256 )
|
||||||
|
@ -1103,8 +1118,8 @@ void FTerm::init()
|
||||||
// terminal detection
|
// terminal detection
|
||||||
setRawMode();
|
setRawMode();
|
||||||
|
|
||||||
|
// send ENQ and read the answerback message
|
||||||
AnswerBack = new FString(getAnswerbackMsg());
|
AnswerBack = new FString(getAnswerbackMsg());
|
||||||
|
|
||||||
if ( AnswerBack && *AnswerBack == FString("PuTTY") )
|
if ( AnswerBack && *AnswerBack == FString("PuTTY") )
|
||||||
{
|
{
|
||||||
putty_terminal = true;
|
putty_terminal = true;
|
||||||
|
@ -1119,7 +1134,8 @@ void FTerm::init()
|
||||||
if ( cygwin_terminal )
|
if ( cygwin_terminal )
|
||||||
putchar(0x8); // cygwin needs a backspace to delete the '♣' char
|
putchar(0x8); // cygwin needs a backspace to delete the '♣' char
|
||||||
|
|
||||||
Sec_DA = new FString(getSecDA()); // get Secondary DA
|
// secondary device attributes (SEC_DA)
|
||||||
|
Sec_DA = new FString(getSecDA());
|
||||||
if ( Sec_DA->getLength() > 5 )
|
if ( Sec_DA->getLength() > 5 )
|
||||||
{
|
{
|
||||||
FString temp = Sec_DA->right(Sec_DA->getLength() - 3);
|
FString temp = Sec_DA->right(Sec_DA->getLength() - 3);
|
||||||
|
@ -1130,6 +1146,8 @@ void FTerm::init()
|
||||||
{
|
{
|
||||||
FString* Sec_DA_components = &Sec_DA_split[0];
|
FString* Sec_DA_components = &Sec_DA_split[0];
|
||||||
|
|
||||||
|
if ( ! Sec_DA_components[0].isEmpty() )
|
||||||
|
{
|
||||||
switch ( Sec_DA_components[0].toInt() )
|
switch ( Sec_DA_components[0].toInt() )
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
|
@ -1199,6 +1217,7 @@ void FTerm::init()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// end of terminal detection
|
// end of terminal detection
|
||||||
|
|
||||||
if ( strncmp(termtype, const_cast<char*>("xterm"), 5) == 0
|
if ( strncmp(termtype, const_cast<char*>("xterm"), 5) == 0
|
||||||
|
@ -1220,7 +1239,7 @@ void FTerm::init()
|
||||||
if ( new_termtype )
|
if ( new_termtype )
|
||||||
{
|
{
|
||||||
setenv(const_cast<char*>("TERM"), new_termtype, 1);
|
setenv(const_cast<char*>("TERM"), new_termtype, 1);
|
||||||
strncpy (termtype, new_termtype, strlen(new_termtype));
|
strncpy (termtype, new_termtype, strlen(new_termtype)+1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initializes variables for the current terminal
|
// Initializes variables for the current terminal
|
||||||
|
@ -1307,7 +1326,6 @@ void FTerm::init()
|
||||||
|
|
||||||
if ( linux_terminal
|
if ( linux_terminal
|
||||||
|| cygwin_terminal
|
|| cygwin_terminal
|
||||||
|| tera_terminal
|
|
||||||
|| NewFont
|
|| NewFont
|
||||||
|| (putty_terminal && ! utf8_state) )
|
|| (putty_terminal && ! utf8_state) )
|
||||||
{
|
{
|
||||||
|
@ -1372,8 +1390,9 @@ void FTerm::init()
|
||||||
setXTermMouseForeground ("rgb:0000/0000/0000");
|
setXTermMouseForeground ("rgb:0000/0000/0000");
|
||||||
if ( ! gnome_terminal )
|
if ( ! gnome_terminal )
|
||||||
setXTermCursor("rgb:ffff/ffff/ffff");
|
setXTermCursor("rgb:ffff/ffff/ffff");
|
||||||
if ( ! mintty_terminal )
|
if ( ! gnome_terminal && ! mintty_terminal )
|
||||||
{
|
{
|
||||||
|
// gnome-terminal and mintty can't reset these settings
|
||||||
setXTermBackground("rgb:8080/a4a4/ecec");
|
setXTermBackground("rgb:8080/a4a4/ecec");
|
||||||
setXTermForeground("rgb:0000/0000/0000");
|
setXTermForeground("rgb:0000/0000/0000");
|
||||||
setXTermHighlightBackground("rgb:b1b1/b1b1/b1b1");
|
setXTermHighlightBackground("rgb:b1b1/b1b1/b1b1");
|
||||||
|
@ -2838,7 +2857,7 @@ void FTerm::setPalette (int index, int r, int g, int b)
|
||||||
}
|
}
|
||||||
else if ( linux_terminal )
|
else if ( linux_terminal )
|
||||||
{
|
{
|
||||||
::printf ("\033]P%x%.2x%.2x%.2x", index, r, g, b);
|
//::printf ("\033]P%x%.2x%.2x%.2x", index, r, g, b);
|
||||||
|
|
||||||
/* // direct vga-register set
|
/* // direct vga-register set
|
||||||
if ( r>=0 && r<256
|
if ( r>=0 && r<256
|
||||||
|
@ -2851,26 +2870,6 @@ void FTerm::setPalette (int index, int r, int g, int b)
|
||||||
}
|
}
|
||||||
ioctl (0, PIO_CMAP, &map); */
|
ioctl (0, PIO_CMAP, &map); */
|
||||||
}
|
}
|
||||||
else if ( xterm || mintty_terminal || rxvt_terminal )
|
|
||||||
{
|
|
||||||
::printf ("\033]4;%d;#%2.2x%2.2x%2.2x\033\\", index, r, g, b);
|
|
||||||
switch (index)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
::printf ("\033]11;#%2.2x%2.2x%2.2x\033\\", r, g, b);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 7:
|
|
||||||
::printf ("\033]10;#%2.2x%2.2x%2.2x\033\\", r, g, b);
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
::printf ("\033]P%x%.2x%.2x%.2x", index, r, g, b);
|
|
||||||
}
|
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3510,7 +3509,7 @@ FString FTerm::getSecDA()
|
||||||
FD_ZERO(&ifds);
|
FD_ZERO(&ifds);
|
||||||
FD_SET(stdin_no, &ifds);
|
FD_SET(stdin_no, &ifds);
|
||||||
tv.tv_sec = 0;
|
tv.tv_sec = 0;
|
||||||
tv.tv_usec = 150000; // 150 ms
|
tv.tv_usec = 550000; // 150 ms
|
||||||
|
|
||||||
// get the secondary device attributes
|
// get the secondary device attributes
|
||||||
putchar(0x1b); // ESC
|
putchar(0x1b); // ESC
|
||||||
|
@ -3518,6 +3517,7 @@ FString FTerm::getSecDA()
|
||||||
putchar(0x3e); // >
|
putchar(0x3e); // >
|
||||||
putchar(0x63); // c
|
putchar(0x63); // c
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
usleep(150000); // min. wait time 150 ms (need for mintty)
|
||||||
|
|
||||||
// read the answer
|
// read the answer
|
||||||
if ( select (stdin_no+1, &ifds, 0, 0, &tv) > 0 )
|
if ( select (stdin_no+1, &ifds, 0, 0, &tv) > 0 )
|
||||||
|
|
|
@ -289,6 +289,7 @@ class FTerm
|
||||||
static bool hasASCII();
|
static bool hasASCII();
|
||||||
static bool isMonochron();
|
static bool isMonochron();
|
||||||
static bool isCygwinTerminal();
|
static bool isCygwinTerminal();
|
||||||
|
static bool isTeraTerm();
|
||||||
static bool isUrxvtTerminal();
|
static bool isUrxvtTerminal();
|
||||||
static bool setVGAFont();
|
static bool setVGAFont();
|
||||||
static bool setNewFont();
|
static bool setNewFont();
|
||||||
|
@ -475,6 +476,10 @@ inline bool FTerm::isMonochron()
|
||||||
inline bool FTerm::isCygwinTerminal()
|
inline bool FTerm::isCygwinTerminal()
|
||||||
{ return cygwin_terminal; }
|
{ return cygwin_terminal; }
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
inline bool FTerm::isTeraTerm()
|
||||||
|
{ return tera_terminal; }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline bool FTerm::isUrxvtTerminal()
|
inline bool FTerm::isUrxvtTerminal()
|
||||||
{ return urxvt_terminal; }
|
{ return urxvt_terminal; }
|
||||||
|
|
|
@ -1838,7 +1838,7 @@ void FWidget::drawShadow()
|
||||||
|
|
||||||
trans_shadow = bool((flags & TRANS_SHADOW) != 0);
|
trans_shadow = bool((flags & TRANS_SHADOW) != 0);
|
||||||
|
|
||||||
if ( (Encoding == fc::VT100 && ! trans_shadow)
|
if ( (Encoding == fc::VT100 && ! trans_shadow && ! isTeraTerm() )
|
||||||
|| (Encoding == fc::ASCII && ! trans_shadow)
|
|| (Encoding == fc::ASCII && ! trans_shadow)
|
||||||
|| monochron )
|
|| monochron )
|
||||||
{
|
{
|
||||||
|
@ -1909,26 +1909,39 @@ void FWidget::drawShadow()
|
||||||
{
|
{
|
||||||
if ( x2 < xmax )
|
if ( x2 < xmax )
|
||||||
{
|
{
|
||||||
|
uInt block;
|
||||||
gotoxy (x2+1, y1);
|
gotoxy (x2+1, y1);
|
||||||
ch = getCoveredCharacter (x2+1, y1, this);
|
ch = getCoveredCharacter (x2+1, y1, this);
|
||||||
setColor (wc.shadow_fg, ch.bg_color);
|
setColor (wc.shadow_fg, ch.bg_color);
|
||||||
|
|
||||||
|
if ( isTeraTerm() )
|
||||||
|
{
|
||||||
|
block = 0xdb; // █
|
||||||
|
print (0xdc); // ▄
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
block = fc::FullBlock; // █
|
||||||
print (fc::LowerHalfBlock); // ▄
|
print (fc::LowerHalfBlock); // ▄
|
||||||
|
}
|
||||||
|
|
||||||
for (int i=1; i < height && y1+i <= ymax; i++)
|
for (int i=1; i < height && y1+i <= ymax; i++)
|
||||||
{
|
{
|
||||||
gotoxy (x2+1, y1+i);
|
gotoxy (x2+1, y1+i);
|
||||||
print (fc::FullBlock); // █
|
print (block); // █
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( y2 < ymax )
|
if ( y2 < ymax )
|
||||||
{
|
{
|
||||||
gotoxy (x1+1, y2+1);
|
gotoxy (x1+1, y2+1);
|
||||||
|
|
||||||
for (int i=1; i <= width && x1+i <= xmax; i++)
|
for (int i=1; i <= width && x1+i <= xmax; i++)
|
||||||
{
|
{
|
||||||
ch = getCoveredCharacter (x1+i, y2+1, this);
|
ch = getCoveredCharacter (x1+i, y2+1, this);
|
||||||
setColor(wc.shadow_fg, ch.bg_color);
|
setColor(wc.shadow_fg, ch.bg_color);
|
||||||
|
if ( isTeraTerm() )
|
||||||
|
print (0xdf); // ▀
|
||||||
|
else
|
||||||
print (fc::UpperHalfBlock); // ▀
|
print (fc::UpperHalfBlock); // ▀
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue