Better support for monochrom terminals

This commit is contained in:
Markus Gans 2015-10-11 21:56:16 +02:00
parent a41727c4fc
commit 70f5b545a5
21 changed files with 225 additions and 71 deletions

View File

@ -1,5 +1,6 @@
2015-10-11 Markus Gans <guru.mail@muenster.de>
* Improve attribute setting for bold, reverse and underline output
* Better support for monochrom terminals
2015-10-10 Markus Gans <guru.mail@muenster.de>
* Deactivate a key from the status bar automatically

View File

@ -2,7 +2,6 @@ Bugs
~~~~
-
Improvements
~~~~~~~~~~~~
- Use only termpap variables for FTerm::hideCursor()
@ -11,10 +10,10 @@ Improvements
-> implement t_exit_reverse_mode with "\E[27m"
- New behavior in FTerm::appendAttributes(...)
- 1st: reset don't needed attributes (bold, reverse and underline)
use 'sgr' for this, to do this in one step => 3rd is don't need
- 2nd: set the foreground and background color
- 3rd: set new attributes (bold, reverse and underline)
Missing Features
~~~~~~~~~~~~~~~~
- application menu

View File

@ -145,7 +145,7 @@ void FButton::draw()
hotkey_offset = 0;
space = int(' ');
if ( isMonochron() )
if ( isMonochron() || getMaxColor() < 16 )
ButtonText = new wchar_t[length+3];
else
ButtonText = new wchar_t[length+1];
@ -162,6 +162,8 @@ void FButton::draw()
is_NoUnderline = ((flags & NO_UNDERLINE) != 0);
setUpdateVTerm(false);
if ( isMonochron() )
setReverse(true);
if ( button_down && click_animation )
{
// noshadow + indent one character to the right
@ -214,7 +216,7 @@ void FButton::draw()
margin = 0;
if ( isMonochron() && (is_Active || is_Focus) )
setReverse(true);
setReverse(false);
if ( is_Flat )
{
@ -257,11 +259,11 @@ void FButton::draw()
for (int y=1; y <= height; y++)
{
if ( isMonochron() )
setReverse(false);
setReverse(true);
gotoxy (xpos+xmin-1+width, ypos+ymin-2+y);
print (' '); // clear right
if ( isMonochron() )
setReverse(true);
setReverse(false);
}
}
@ -333,7 +335,7 @@ void FButton::draw()
}
if ( isMonochron() )
setReverse(false);
setReverse(true);
if ( is_NonFlatShadow && ! button_down )
{
@ -343,6 +345,9 @@ void FButton::draw()
drawShadow();
}
if ( isMonochron() )
setReverse(false);
setUpdateVTerm(true);
delete[] ButtonText;

View File

@ -134,10 +134,14 @@ void FButtonGroup::directFocus()
void FButtonGroup::draw()
{
setUpdateVTerm(false);
if ( isMonochron() )
setReverse(true);
setColor (foregroundColor, backgroundColor);
if ( border )
drawBorder();
drawLabel();
if ( isMonochron() )
setReverse(false);
setUpdateVTerm(true);
}

View File

@ -55,6 +55,13 @@ void FCheckBox::drawCheckButton()
return;
gotoxy (xpos+xmin-1, ypos+ymin-1);
setColor (foregroundColor, backgroundColor);
if ( isMonochron() )
{
if ( hasFocus() )
setReverse(false);
else
setReverse(true);
}
if ( checked )
{
if ( isNewFont() )
@ -77,4 +84,6 @@ void FCheckBox::drawCheckButton()
print (']');
}
}
if ( isMonochron() )
setReverse(false);
}

View File

@ -198,9 +198,13 @@ void FDialog::drawTitleBar()
// draw the title button
gotoxy (xpos+xmin-1, ypos+ymin-1);
setColor (wc.titlebar_button_fg, wc.titlebar_button_bg);
if ( isMonochron() )
setReverse(true);
{
if ( isActiveWindow() )
setReverse(false);
else
setReverse(true);
}
if ( isNewFont() )
{
@ -256,6 +260,7 @@ void FDialog::drawDialogShadow()
{
// transparent shadow
drawShadow();
if ( isNewFont() && ((flags & SCROLLABLE) == 0) )
{
FTerm::char_data ch;
@ -272,7 +277,11 @@ void FDialog::drawDialogShadow()
}
else
{
if ( isMonochron() )
return;
drawShadow();
FTerm::char_data ch;
ch = getCoveredCharacter (xpos+xmin-1, ypos+ymin-1+height, this);
// left of the shaddow ▀▀
@ -297,12 +306,9 @@ void FDialog::drawDialogShadow()
print (ch.code);
if ( ch.underline )
unsetUnderline();
if ( ch.reverse )
unsetReverse();
if ( ch.bold )
unsetBold();
unsetUnderline();
unsetReverse();
unsetBold();
}
}
}
@ -317,9 +323,14 @@ void FDialog::draw()
width = xmax;
height = ymax;
}
setUpdateVTerm(false);
// fill the background
setColor (foregroundColor, backgroundColor);
setUpdateVTerm(false);
if ( isMonochron() )
setReverse(true);
clrscr();
drawBorder();
drawTitleBar();
@ -329,6 +340,9 @@ void FDialog::draw()
if ( (flags & RESIZEABLE) != 0 )
{
if ( isMonochron() )
setReverse(false);
if ( maximized )
{
if ( isNewFont() )
@ -366,6 +380,8 @@ void FDialog::draw()
}
}
}
if ( isMonochron() )
setReverse(false);
setUpdateVTerm(true);
}
@ -872,6 +888,9 @@ bool FDialog::setTransparentShadow (bool on)
//----------------------------------------------------------------------
bool FDialog::setShadow (bool on)
{
if ( isMonochron() )
return false;
if ( on )
{
flags |= SHADOW;

View File

@ -232,6 +232,13 @@ void FLabel::draw()
setUpdateVTerm(false);
if ( isMonochron() )
{
setReverse(true);
if ( hasEmphasis() )
setBold(true);
}
if ( hasEmphasis() )
setColor (emphasis_color, backgroundColor);
else
@ -292,6 +299,12 @@ void FLabel::draw()
printLine (LabelText, length, hotkeypos, xoffset);
delete[] LabelText;
}
if ( isMonochron() )
{
setReverse(false);
if ( hasEmphasis() )
setBold(false);
}
setUpdateVTerm(true);
}

View File

@ -138,8 +138,12 @@ void FLineEdit::drawInputField()
gotoxy (xpos+xmin-1, ypos+ymin-1);
if ( isMonochron() )
{
setReverse(true);
print (' ');
setUnderline(true);
if ( isActiveFocus )
setReverse(false);
else
setUnderline(true);
}
else if ( isActiveFocus )
{
@ -190,7 +194,10 @@ void FLineEdit::drawInputField()
x++;
}
if ( isMonochron() )
{
setReverse(false);
setUnderline(false);
}
if ( isShadow )
drawShadow ();

View File

@ -134,6 +134,8 @@ void FListBox::draw()
setUpdateVTerm(false);
setColor (foregroundColor, backgroundColor);
if ( isMonochron() )
setReverse(true);
if ( isNewFont() )
width--;
drawBorder();
@ -151,6 +153,8 @@ void FListBox::draw()
}
}
drawLabel();
if ( isMonochron() )
setReverse(false);
setUpdateVTerm(true);
if ( VBar->isVisible() )
@ -291,10 +295,10 @@ void FListBox::drawList()
, wc.current_element_bg );
}
if ( isMonochron() )
setReverse(true);
setReverse(false);
}
else if ( isMonochron() )
setReverse(false);
setReverse(true);
// print the entry
if ( isMonochron() && isCurrentLine )

View File

@ -203,9 +203,13 @@ void FMenu::draw()
// fill the background
setColor (wc.menu_active_fg, wc.menu_active_bg);
setUpdateVTerm(false);
if ( isMonochron() )
setReverse(true);
clrscr();
drawBorder();
drawItems();
if ( isMonochron() )
setReverse(false);
//if ( (flags & SHADOW) != 0 )
// drawMenuShadow();
setUpdateVTerm(true);
@ -356,8 +360,8 @@ void FMenu::drawItems()
print (' ');
}
if ( is_Active && is_Selected )
setReverse(false);
if ( isMonochron() && is_Active && is_Selected )
setReverse(true);
delete[] item_text;
++iter;

View File

@ -134,11 +134,12 @@ void FMenuBar::drawItems()
setUpdateVTerm(false);
gotoxy (1,1);
if ( isMonochron() )
setReverse(true);
iter = itemlist.begin();
end = itemlist.end();
if ( isMonochron() )
setReverse(true);
while ( iter != end )
{
wchar_t* src;
@ -157,10 +158,10 @@ void FMenuBar::drawItems()
{
if ( is_Selected )
{
foregroundColor = wc.menu_active_focus_fg;
backgroundColor = wc.menu_active_focus_bg;
if ( isMonochron() )
setReverse(false);
foregroundColor = wc.menu_active_focus_fg;
backgroundColor = wc.menu_active_focus_bg;
}
else
{
@ -227,8 +228,8 @@ void FMenuBar::drawItems()
}
setColor (wc.menu_active_fg, wc.menu_active_bg);
if ( is_Active && is_Selected )
setReverse(false);
if ( isMonochron() && is_Active && is_Selected )
setReverse(true);
delete[] item_text;
++iter;
@ -236,6 +237,7 @@ void FMenuBar::drawItems()
for (; x <= screenWidth; x++)
print (vmenubar, ' ');
if ( isMonochron() )
setReverse(false);

View File

@ -226,6 +226,10 @@ void FMessageBox::draw()
int msg_x = int((width - int(maxLineWidth)) / 2); // center the whole block
setUpdateVTerm(false);
if ( isMonochron() )
setReverse(true);
if ( ! headline_text.isNull() )
{
setColor(emphasis_color, backgroundColor);
@ -247,6 +251,10 @@ void FMessageBox::draw()
gotoxy (xpos+xmin-1+msg_x+center_x, ypos+ymin+2+head_offset+i);
print(text_components[i]);
}
if ( isMonochron() )
setReverse(false);
setUpdateVTerm(true);
}

View File

@ -27,11 +27,15 @@ void FProgressbar::drawPercentage()
{
setColor ( parentWidget()->getForegroundColor()
, parentWidget()->getBackgroundColor() );
if ( isMonochron() )
setReverse(true);
gotoxy (xpos+xmin+width-5, ypos+ymin-2);
if ( percentage < 0 || percentage > 100 )
print ("--- %");
else
printf ("%3d %%", percentage);
if ( isMonochron() )
setReverse(false);
}
//----------------------------------------------------------------------
@ -45,9 +49,9 @@ void FProgressbar::drawBar()
{
if ( round(length) >= 1)
{
setReverse(true);
print (' ');
setReverse(false);
print (' ');
setReverse(true);
}
else
print (fc::MediumShade); // ▒
@ -83,11 +87,11 @@ void FProgressbar::drawBar()
setColor ( wc.progressbar_bg
, wc.progressbar_fg );
if ( isMonochron() )
setReverse(true);
setReverse(false);
for (; i < trunc(length); i++)
print (' ');
if ( isMonochron() )
setReverse(false);
setReverse(true);
if ( trunc(length) >= 1 && trunc(length) < BarLength )
{
@ -97,9 +101,9 @@ void FProgressbar::drawBar()
{
if ( isMonochron() )
{
setReverse(true);
print (' ');
setReverse(false);
print (' ');
setReverse(true);
}
else
print (' ');
@ -123,6 +127,8 @@ void FProgressbar::drawBar()
for (; i < BarLength; i++)
print (' ');
}
if ( isMonochron() )
setReverse(false);
updateTerminal();
flush_out();
}

View File

@ -56,6 +56,13 @@ void FRadioButton::drawRadioButton()
return;
gotoxy (xpos+xmin-1, ypos+ymin-1);
setColor (foregroundColor, backgroundColor);
if ( isMonochron() )
{
if ( hasFocus() )
setReverse(false);
else
setReverse(true);
}
if ( checked )
{
if ( isNewFont() )
@ -78,5 +85,7 @@ void FRadioButton::drawRadioButton()
print (')');
}
}
if ( isMonochron() )
setReverse(false);
}

View File

@ -550,10 +550,11 @@ void FScrollbar::setGeometry (int x, int y, int w, int h, bool adjust)
//----------------------------------------------------------------------
void FScrollbar::drawBar()
{
setUpdateVTerm(false);
if (SliderPos != currentSliderPos)
{
int z;
setUpdateVTerm(false);
if ( bar_orientation == fc::vertical )
{
setColor (wc.scrollbar_fg, wc.scrollbar_bg);
@ -569,7 +570,7 @@ void FScrollbar::drawBar()
}
setColor (wc.scrollbar_bg, wc.scrollbar_fg);
if ( isMonochron() )
setReverse(true);
setReverse(false);
for (z=1; z <= SliderLength; z++)
{
gotoxy (xpos+xmin-1, ypos+ymin-1+SliderPos+z);
@ -578,7 +579,7 @@ void FScrollbar::drawBar()
print (' ');
}
if ( isMonochron() )
setReverse(false);
setReverse(true);
setColor (wc.scrollbar_fg, wc.scrollbar_bg);
for (z=SliderPos+SliderLength+1; z <= BarLength; z++)
{
@ -612,13 +613,13 @@ void FScrollbar::drawBar()
}
setColor (wc.scrollbar_bg, wc.scrollbar_fg);
if ( isMonochron() )
setReverse(true);
setReverse(false);
z = 0;
for (; z < SliderLength; z++)
print (' ');
if ( isMonochron() )
setReverse(false);
setReverse(true);
setColor (wc.scrollbar_fg, wc.scrollbar_bg);
z = SliderPos + SliderLength + 1;
for (; z <= BarLength; z++)
@ -632,8 +633,12 @@ void FScrollbar::drawBar()
}
}
currentSliderPos = SliderPos;
if ( isMonochron() )
setReverse(false);
setUpdateVTerm(true);
}
setUpdateVTerm(true);
}
//----------------------------------------------------------------------
@ -643,9 +648,10 @@ void FScrollbar::drawButtons()
if ( isNewFont() )
{
gotoxy (xpos+xmin-1, ypos+ymin-1);
if ( bar_orientation == fc::vertical )
{
gotoxy (xpos+xmin-1, ypos+ymin-1);
print (fc::NF_rev_up_arrow1);
print (fc::NF_rev_up_arrow2);
gotoxy (xpos+xmin-1, ypos+ymin+length-2);
@ -654,7 +660,6 @@ void FScrollbar::drawButtons()
}
else // horizontal
{
gotoxy (xpos+xmin-1, ypos+ymin-1);
print (fc::NF_rev_left_arrow1);
print (fc::NF_rev_left_arrow2);
gotoxy (xpos+xmin+length-3, ypos+ymin-1);
@ -664,11 +669,13 @@ void FScrollbar::drawButtons()
}
else
{
gotoxy (xpos+xmin-1, ypos+ymin-1);
if ( isMonochron() )
setReverse(true);
if ( bar_orientation == fc::vertical )
{
gotoxy (xpos+xmin-1, ypos+ymin-1);
if ( isMonochron() )
setReverse(true);
if ( isCygwinTerminal() )
print ('^');
else
@ -678,19 +685,15 @@ void FScrollbar::drawButtons()
print ('v');
else
print (fc::BlackDownPointingTriangle); // ▼
if ( isMonochron() )
setReverse(false);
}
else // horizontal
{
gotoxy (xpos+xmin-1, ypos+ymin-1);
if ( isMonochron() )
setReverse(true);
print (fc::BlackLeftPointingPointer); // ◄
gotoxy (xpos+xmin+length-2, ypos+ymin-1);
print (fc::BlackRightPointingPointer); // ►
if ( isMonochron() )
setReverse(false);
}
if ( isMonochron() )
setReverse(false);
}
}

View File

@ -226,11 +226,12 @@ void FStatusBar::drawKeys()
setUpdateVTerm(false);
gotoxy (1, lastLine);
if ( isMonochron() )
setReverse(true);
iter = keylist.begin();
end = keylist.end();
if ( isMonochron() )
setReverse(true);
while ( iter != end )
{
int kname_len = int(getKeyName((*iter)->getKey()).getLength());
@ -620,6 +621,7 @@ void FStatusBar::drawMessage()
}
for (int i=x; i <= termWidth; i++)
print (vstatusbar, ' ');
if ( isMonochron() )
setReverse(false);

View File

@ -63,6 +63,7 @@ void FSwitch::drawCheckButton()
{
if ( isMonochron() )
setBold(true);
if ( isMonochron() || getMaxColor() < 16 )
{
wcsncpy ( on, L" <On>", 6);
@ -78,22 +79,30 @@ void FSwitch::drawCheckButton()
setColor (wc.button_hotkey_fg, wc.button_active_bg);
if ( isMonochron() )
setReverse(true);
setReverse(false);
print (on);
if ( isMonochron() )
{
setReverse(false);
setReverse(true);
setBold(false);
}
setColor (wc.button_inactive_fg, wc.button_inactive_bg);
print (off);
if ( isMonochron() )
setReverse(false);
setCursorPos ( xpos + xmin + 1 + switch_offset_pos
, ypos + ymin - 1 );
}
else
{
setColor (wc.button_inactive_fg, wc.button_inactive_bg);
if ( isMonochron() )
setReverse(true);
print (on);
if ( hasFocus() && ! button_pressed )
@ -115,13 +124,12 @@ void FSwitch::drawCheckButton()
setColor (wc.button_hotkey_fg, wc.button_active_bg);
if ( isMonochron() )
setReverse(true);
print (off);
if ( isMonochron() )
{
setReverse(false);
print (off);
if ( isMonochron() )
setBold(false);
}
setCursorPos ( xpos + xmin + 5 + switch_offset_pos
, ypos + ymin - 1 );

View File

@ -67,9 +67,12 @@ void FTextView::draw()
{
setUpdateVTerm(false);
setColor (foregroundColor, backgroundColor);
if ( isMonochron() )
setReverse(true);
if ( ! isNewFont() )
drawBorder();
if ( isMonochron() )
setReverse(false);
if ( VBar->isVisible() )
VBar->redraw();
if ( HBar->isVisible() )
@ -108,6 +111,10 @@ void FTextView::drawText()
setUpdateVTerm(false);
setColor (foregroundColor, backgroundColor);
if ( isMonochron() )
setReverse(true);
for (uInt y=start; y < end; y++)
{
gotoxy (xpos+xmin, ypos+ymin-nf_offset+int(y));
@ -125,6 +132,10 @@ void FTextView::drawText()
for (; i < uInt(width - nf_offset - 2); i++)
print (' ');
}
if ( isMonochron() )
setReverse(false);
setUpdateVTerm(true);
}

View File

@ -222,6 +222,9 @@ void FToggleButton::drawLabel()
gotoxy (xpos+xmin-1+label_offset_pos, ypos+ymin-1);
if ( isMonochron() )
setReverse(true);
if ( isEnabled() )
setColor(wc.label_fg, wc.label_bg);
else
@ -240,8 +243,12 @@ void FToggleButton::drawLabel()
setColor (wc.label_fg, wc.label_bg);
}
else
print ( LabelText[z] );
print (LabelText[z]);
}
if ( isMonochron() )
setReverse(false);
delete[] LabelText;
}
@ -423,6 +430,7 @@ bool FToggleButton::setFocus(bool on)
foregroundColor = wc.toggle_button_active_focus_fg;
backgroundColor = wc.toggle_button_active_focus_bg;
if ( isCursorInside() && (isRadioButton() || isCheckboxButton()) )
showCursor();

View File

@ -636,11 +636,6 @@ void FWidget::onAccel (FAccelEvent*)
//----------------------------------------------------------------------
void FWidget::onResize (FResizeEvent* ev)
{
if ( openConsole() == 0 )
{
getTermGeometry();
closeConsole();
}
rootObject->resize();
rootObject->redraw();
ev->accept();
@ -1226,6 +1221,8 @@ void FWidget::resize()
}
else
adjustSize();
// resize the four double-flatline-masks
double_flatline_mask.top.resize (uLong(width), false);
double_flatline_mask.right.resize (uLong(height), false);
double_flatline_mask.bottom.resize (uLong(width), false);
@ -1834,13 +1831,13 @@ void FWidget::drawShadow()
{
FTerm::char_data ch;
int x1, x2, y1, y2;
bool trans_shadow;
bool trans_shadow = ((flags & TRANS_SHADOW) != 0);
trans_shadow = bool((flags & TRANS_SHADOW) != 0);
if ( isMonochron() && ! trans_shadow )
return;
if ( (Encoding == fc::VT100 && ! trans_shadow && ! isTeraTerm() )
|| (Encoding == fc::ASCII && ! trans_shadow)
|| monochron )
|| (Encoding == fc::ASCII && ! trans_shadow) )
{
clearShadow();
return;
@ -1857,12 +1854,25 @@ void FWidget::drawShadow()
if ( x2 < xmax )
{
gotoxy (x2+1, y1);
for (int x=1; x <= 2; x++)
{
ch = getCoveredCharacter (x2+x, y1, this);
setColor (ch.fg_color, ch.bg_color);
if ( ch.reverse )
setReverse(true);
if ( ch.bold )
setBold(true);
if ( ch.underline )
setUnderline(true);
print (ch.code);
setReverse(false);
setBold(false);
setUnderline(false);
}
setColor (wc.shadow_bg, wc.shadow_fg);
for (int i=1; i < height && y1+i <= ymax; i++)
{
@ -1884,12 +1894,25 @@ void FWidget::drawShadow()
if ( y2 < ymax )
{
gotoxy (x1, y2+1);
for (int x=0; x <= 1; x++)
{
ch = getCoveredCharacter (x1+x, y2+1, this);
setColor (ch.fg_color, ch.bg_color);
if ( ch.reverse )
setReverse(true);
if ( ch.bold )
setBold(true);
if ( ch.underline )
setUnderline(true);
print (ch.code);
setReverse(false);
setBold(false);
setUnderline(false);
}
setColor (wc.shadow_bg, wc.shadow_fg);
for (int i=2; i <= width+1 && x1+i <= xmax; i++)
{
@ -1904,6 +1927,8 @@ void FWidget::drawShadow()
print (ch.code);
}
}
if ( isMonochron() )
setReverse(false);
}
else
{
@ -1954,6 +1979,9 @@ void FWidget::clearShadow()
FTerm::char_data ch;
int x1, x2, y1, y2;
if ( isMonochron() )
return;
x1 = xpos+xmin-1;
x2 = xpos+xmin-2+width;
y1 = ypos+ymin-1;

View File

@ -313,11 +313,15 @@ void Calc::drawDispay()
display = " Error ";
setColor(fc::Black, fc::LightGray);
if ( isMonochron() )
setReverse(false);
gotoxy (xpos+xmin+1, ypos+ymin+1);
print(display);
print(L' ');
setColor(wc.dialog_fg, wc.dialog_bg);
if ( isMonochron() )
setReverse(true);
if ( isNewFont() )
{
FString bottom_line(33, wchar_t(fc::NF_border_line_bottom));