New class FOptiAttr to control video attributes and colors

This commit is contained in:
Markus Gans 2016-01-08 01:00:05 +01:00
parent 4a697e7c9a
commit 49629a995a
47 changed files with 2922 additions and 1220 deletions

View File

@ -1,3 +1,7 @@
2016-01-07 Markus Gans <guru.mail@muenster.de>
* Add the new class FOptiAttr to control video attributes and colors
for output on terminals
2015-12-23 Markus Gans <guru.mail@muenster.de>
* Add video attribute support for dim (half-bright) and italic
* An example program to test video attributes on your terminal

View File

@ -150,13 +150,16 @@ Class digramm
│ :1:1 │ └───────────────┘ │ └───────────┘ :
┌───────┐ │ : : │ ┌──────────────┐ │ ┌─────────┐1 :
│ FTerm │◄─┘ : : ├────┤ FProgressbar │ └──┤ FSwitch ├-------:
└──┬─┬──┘ : : │ └──────────────┘ └─────────┘ :
:1:1 : : │ ┌────────────┐ : *┌─────────┐
: └----------: : ├────┤ FScrollbar │ ├---┤ FString │
:1 : : │ └────────────┘ : └─────────┘
┌────┴──────┐ : : │ ┌───────────┐1 :
│ FOptiMove │ : : ├────┤ FTextView ├---------------------------:
└───────────┘ : : │ └───────────┘ :
└┬─┬─┬──┘ : : │ └──────────────┘ └─────────┘ :
: :1:1 : : │ ┌────────────┐ : *┌─────────┐
: : └----------: : ├────┤ FScrollbar │ ├---┤ FString │
: :1 : : │ └────────────┘ : └─────────┘
:┌┴──────────┐ : : │ ┌───────────┐1 :
:│ FOptiAttr │ : : ├────┤ FTextView ├---------------------------:
:└───────────┘ : : │ └───────────┘ :
┌┴──────────┐ : : │ ┌──────────┐1 *┌──────────────┐1 :
│ FOptiMove │ : : ├────┤ FListBox ├-------┤ FListBoxItem ├-----:
└───────────┘ : : │ └──────────┘ └──────────────┘ :
: : │ ┌──────────┐1 *┌──────────────┐1 :
: : ├────┤ FListBox ├-------┤ FListBoxItem ├-----:
: : │ └──────────┘ └──────────────┘ :

View File

@ -4,11 +4,7 @@ Bugs
Improvements
~~~~~~~~~~~~
- 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
~~~~~~~~~~~~~~~~

View File

@ -53,16 +53,16 @@
│ :1:1 │ └───────────────┘ │ └───────────┘ :
┌───────┐ │ : : │ ┌──────────────┐ │ ┌─────────┐1 :
│ FTerm │◄─┘ : : ├────┤ FProgressbar │ └──┤ FSwitch ├-------:
─┬─┬──┘ : : │ └──────────────┘ └─────────┘ :
:1:1 : : │ ┌────────────┐ : *┌─────────┐
: └----------: : ├────┤ FScrollbar │ ├---┤ FString │
:1 : : │ └────────────┘ : └─────────┘
┌──────────┐ : : │ ┌───────────┐1 :
│ FOptiMove │ : : ├────┤ FTextView ├---------------------------:
└───────────┘ : : │ └───────────┘ :
: : │ ┌──────────┐1 *┌──────────────┐1 :
: : ├────┤ FListBox ├-------┤ FListBoxItem ├-----:
: : │ └──────────┘ └──────────────┘ :
─┬─┬──┘ : : │ └──────────────┘ └─────────┘ :
: :1:1 : : │ ┌────────────┐ : *┌─────────┐
: : └----------: : ├────┤ FScrollbar │ ├---┤ FString │
: :1 : : │ └────────────┘ : └─────────┘
:──────────┐ : : │ ┌───────────┐1 :
:│ FOptiAttr │ : : ├────┤ FTextView ├---------------------------:
:└───────────┘ : : │ └───────────┘ :
┌┴──────────┐ : : │ ┌──────────┐1 *┌──────────────┐1 :
│ FOptiMove │ : : ├────┤ FListBox ├-------┤ FListBoxItem ├-----:
└───────────┘ : : │ └──────────┘ └──────────────┘ :
: : │ ┌────────────┐1 *┌────────────┐1 :
: : ├────┤ FStatusBar ├-----┤ FStatusKey ├-------:
: : │ └────┬───────┘ └────────────┘ :

View File

@ -1,7 +1,7 @@
#
# spec file for package finalcut
#
# Copyright (c) 2015 by Markus Gans
# Copyright (c) 2016 by Markus Gans
#
Name: finalcut

View File

@ -37,6 +37,7 @@ libfinal_la_SOURCES = \
fstatusbar.cpp \
fterm.cpp \
fevent.cpp \
foptiattr.cpp \
foptimove.cpp \
fapp.cpp \
fwidget.cpp \
@ -71,8 +72,9 @@ finalcutinclude_HEADERS = \
fmenulist.h \
fmessagebox.h \
fobject.h \
foptimove.h \
fpoint.h \
foptiattr.h \
foptimove.h \
fprogressbar.h \
fradiobutton.h \
frect.h \

View File

@ -26,6 +26,7 @@ INCLUDE_HEADERS = \
fcheckmenuitem.h \
fmessagebox.h \
fobject.h \
foptiattr.h \
foptimove.h \
fpoint.h \
fprogressbar.h \
@ -79,6 +80,7 @@ OBJS = \
fstatusbar.o \
fterm.o \
fevent.o \
foptiattr.o \
foptimove.o \
fapp.o \
fwidget.o \

View File

@ -26,6 +26,7 @@ INCLUDE_HEADERS = \
fcheckmenuitem.h \
fmessagebox.h \
fobject.h \
foptiattr.h \
foptimove.h \
fpoint.h \
fprogressbar.h \
@ -79,6 +80,7 @@ OBJS = \
fstatusbar.o \
fterm.o \
fevent.o \
foptiattr.o \
foptimove.o \
fapp.o \
fwidget.o \

View File

@ -134,8 +134,8 @@ am_libfinal_la_OBJECTS = fstring.lo fpoint.lo frect.lo fscrollbar.lo \
flabel.lo flistbox.lo fmenu.lo fmenubar.lo fmenuitem.lo \
fradiomenuitem.lo fcheckmenuitem.lo fmenulist.lo fdialog.lo \
fwindow.lo fmessagebox.lo ffiledialog.lo ftextview.lo \
fstatusbar.lo fterm.lo fevent.lo foptimove.lo fapp.lo \
fwidget.lo fobject.lo
fstatusbar.lo fterm.lo fevent.lo foptiattr.lo foptimove.lo \
fapp.lo fwidget.lo fobject.lo
libfinal_la_OBJECTS = $(am_libfinal_la_OBJECTS)
AM_V_lt = $(am__v_lt_@AM_V@)
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
@ -401,6 +401,7 @@ libfinal_la_SOURCES = \
fstatusbar.cpp \
fterm.cpp \
fevent.cpp \
foptiattr.cpp \
foptimove.cpp \
fapp.cpp \
fwidget.cpp \
@ -433,8 +434,9 @@ finalcutinclude_HEADERS = \
fmenulist.h \
fmessagebox.h \
fobject.h \
foptimove.h \
fpoint.h \
foptiattr.h \
foptimove.h \
fprogressbar.h \
fradiobutton.h \
frect.h \
@ -544,6 +546,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fmenulist.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fmessagebox.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fobject.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/foptiattr.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/foptimove.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fpoint.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fprogressbar.Plo@am__quote@

View File

@ -396,53 +396,53 @@ void FButton::processClick()
// public methods of FButton
//----------------------------------------------------------------------
void FButton::setForegroundColor (int color)
void FButton::setForegroundColor (short color)
{
FWidget::setForegroundColor(color);
updateButtonColor();
}
//----------------------------------------------------------------------
void FButton::setBackgroundColor (int color)
void FButton::setBackgroundColor (short color)
{
FWidget::setBackgroundColor(color);
updateButtonColor();
}
//----------------------------------------------------------------------
void FButton::setHotkeyForegroundColor (int color)
void FButton::setHotkeyForegroundColor (short color)
{
if ( color >> 8 == 0 ) // valid colors 0..254
if ( color == -1 || color >> 8 == 0 ) // valid colors -1..254
button_hotkey_fg = color;
}
void FButton::setFocusForegroundColor (int color)
void FButton::setFocusForegroundColor (short color)
{
if ( color >> 8 == 0 ) // valid colors 0..254
if ( color == -1 || color >> 8 == 0 ) // valid colors -1..254
button_focus_fg = color;
updateButtonColor();
}
//----------------------------------------------------------------------
void FButton::setFocusBackgroundColor (int color)
void FButton::setFocusBackgroundColor (short color)
{
if ( color >> 8 == 0 ) // valid colors 0..254
if ( color == -1 || color >> 8 == 0 ) // valid colors -1..254
button_focus_bg = color;
updateButtonColor();
}
//----------------------------------------------------------------------
void FButton::setInactiveForegroundColor (int color)
void FButton::setInactiveForegroundColor (short color)
{
if ( color >> 8 == 0 ) // valid colors 0..254
if ( color == -1 || color >> 8 == 0 ) // valid colors -1..254
button_inactive_fg = color;
updateButtonColor();
}
//----------------------------------------------------------------------
void FButton::setInactiveBackgroundColor (int color)
void FButton::setInactiveBackgroundColor (short color)
{
if ( color >> 8 == 0 ) // valid colors 0..254
if ( color == -1 || color >> 8 == 0 ) // valid colors -1..254
button_inactive_bg = color;
updateButtonColor();
}
@ -450,7 +450,8 @@ void FButton::setInactiveBackgroundColor (int color)
//----------------------------------------------------------------------
void FButton::hide()
{
int fg, bg, s, f, size;
int s, f, size;
short fg, bg;
char* blank;
FWidget::hide();

View File

@ -40,13 +40,13 @@ class FButton : public FWidget
bool button_down;
bool click_animation;
int click_time;
int button_fg;
int button_bg;
int button_hotkey_fg;
int button_focus_fg;
int button_focus_bg;
int button_inactive_fg;
int button_inactive_bg;
short button_fg;
short button_bg;
short button_hotkey_fg;
short button_focus_fg;
short button_focus_bg;
short button_inactive_fg;
short button_inactive_bg;
private:
FButton (const FButton&);
@ -66,13 +66,13 @@ class FButton : public FWidget
virtual ~FButton(); // destructor
const char* getClassName() const;
void setForegroundColor (int);
void setBackgroundColor (int);
void setHotkeyForegroundColor (int);
void setFocusForegroundColor (int);
void setFocusBackgroundColor (int);
void setInactiveForegroundColor (int);
void setInactiveBackgroundColor (int);
void setForegroundColor (short);
void setBackgroundColor (short);
void setHotkeyForegroundColor (short);
void setFocusForegroundColor (short);
void setFocusBackgroundColor (short);
void setInactiveForegroundColor (short);
void setInactiveBackgroundColor (short);
void hide();
void onKeyPress (FKeyEvent*);

View File

@ -263,7 +263,8 @@ void FButtonGroup::drawLabel()
//----------------------------------------------------------------------
void FButtonGroup::hide()
{
int fg, bg, size;
int size;
short fg, bg;
char* blank;
FWidget::hide();
if ( ! buttonlist.empty() )

View File

@ -10,26 +10,17 @@ static uInt character[][fc::NUM_OF_ENCODINGS] =
// | | .--------- PC (IBM-437)
// | | | .---- ASCII (7-Bit)
// | | | |
{0x00f6,0xf6, 0x94, 'o'}, // ö - o-umlaut
{0x00e4,0xe4, 0x84, 'a'}, // ä - a-umlaut
{0x00fc,0xfc, 0x81, 'u'}, // ü - u-umlaut
{0x00d6,0xd6, 0x99, 'O'}, // Ö - O-umlaut
{0x00c4,0xc4, 0x8e, 'A'}, // Ä - A-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
{0x20ac, 'E', 0xee, 'E'}, // € - Euro
{0x20ac, 0, 0xee, 'E'}, // € - Euro
{0x00a3, '}', 0x9c, 'P'}, // £ - Pound
{0x03c0, '{', 0xe3, 'n'}, // π - Pi
{0x207F, 'I', 0xfc, ' '}, // ⁿ - SuperscriptLatinSmallLetterN
{0x2265, 'z', 0xf2, '>'}, // ≥ - GreaterThanOrEqualTo
{0x2264, 'y', 0xf3, '<'}, // ≤ - LessThanOrEqualTo
{0x2260, '|', 0xd8, '!'}, // ≠ - NotEqualTo
{0x2260, 0, 0xd8, '#'}, // ≠ - NotEqualTo
{0x00b1, 'g', 0xf1, '#'}, // ± - PlusMinus
{0x00f7, '/', 0xf6, '/'}, // ÷ - Division sign
{0x00d7, 'x', 'x', 'x'}, // × - Multiplication sign
{0x02e3, '~', 0xfc, '~'}, // ˣ - Modifier letter small x
{0x00d7, 0, 'x', 'x'}, // × - Multiplication sign
{0x02e3, '~', 0xfc, '`'}, // ˣ - Modifier letter small x
{0x00b0, 'f', 0xb0, 'o'}, // ° - Degree
{0x2022, '`', 0x04, '*'}, // • - Bullet
{0x00b7, '`', 0xfa, '.'}, // · - small Bullet

View File

@ -53,8 +53,10 @@ void FCheckBox::drawCheckButton()
{
if ( ! isVisible() )
return;
gotoxy (xpos+xmin-1, ypos+ymin-1);
setColor (foregroundColor, backgroundColor);
if ( isMonochron() )
{
if ( hasFocus() )
@ -69,9 +71,6 @@ void FCheckBox::drawCheckButton()
else
{
print ('[');
if ( isTeraTerm() )
print ('x');
else
print (fc::Times); // Times ×
print (']');
}

View File

@ -137,7 +137,7 @@ void FDialog::drawBorder()
if ( isNewFont() )
{
int fg;
short fg;
if ( ! isRootWidget() )
fg = parentWidget()->getForegroundColor();
else
@ -269,7 +269,7 @@ void FDialog::drawDialogShadow()
if ( isNewFont() && ((flags & SCROLLABLE) == 0) )
{
FTerm::char_data ch;
FOptiAttr::char_data ch;
// left of the shadow ▀▀
gotoxy (xpos+xmin-1, ypos+ymin-1+height);
for (int x=0; x <= 1; x++)
@ -288,7 +288,7 @@ void FDialog::drawDialogShadow()
drawShadow();
FTerm::char_data ch;
FOptiAttr::char_data ch;
ch = getCoveredCharacter (xpos+xmin-1, ypos+ymin-1+height, this);
// left of the shadow ▀▀
gotoxy (xpos+xmin-1, ypos+ymin-1+height);
@ -305,16 +305,34 @@ void FDialog::drawDialogShadow()
if ( ch.bold )
setBold();
if ( ch.reverse )
setReverse();
if ( ch.dim )
setDim();
if ( ch.italic )
setItalic();
if ( ch.underline )
setUnderline();
if ( ch.blink )
setBlink();
if ( ch.reverse )
setReverse();
if ( ch.standout )
setStandout();
if ( ch.invisible )
setInvisible();
if ( ch.protect )
setProtected();
if ( ch.crossed_out )
setCrossedOut();
if ( ch.dbl_underline )
setDoubleUnderline();
if ( ch.alt_charset )
setAltCharset (true);
if ( ch.pc_charset )
setPCcharset (true);
print (ch.code);
unsetUnderline();
unsetReverse();
unsetBold();
setNormal();
}
}
}

View File

@ -570,6 +570,7 @@ class fc
// console color names
enum colornames
{
Default = -1,
Black = 0,
Blue = 1,
Green = 2,

View File

@ -200,16 +200,6 @@ char* FFileDialog::getHomeDir()
}
}
//----------------------------------------------------------------------
void FFileDialog::draw()
{
FDialog::draw();
if ( Encoding == fc::VT100 )
unsetVT100altChar();
}
//----------------------------------------------------------------------
inline bool FFileDialog::pattern_match ( const char* pattern
, const char* fname )

View File

@ -95,7 +95,6 @@ class FFileDialog : public FDialog
private:
void init();
static char* getHomeDir();
virtual void draw();
inline bool pattern_match (const char*, const char*);
void clear();
int numOfDirs();

View File

@ -79,6 +79,7 @@ static keymap Fkey[] =
{ fc::Fkey_create , 0, "@6" }, // create key
{ fc::Fkey_end , 0, "@7" }, // end key
{ fc::Fkey_end , 0, "@7x"}, // end key
{ fc::Fkey_end , 0, "@7X"}, // end key
{ fc::Fkey_enter , 0, "@8" }, // enter/send key
{ fc::Fkey_exit , 0, "@9" }, // exit key
{ fc::Fkey_find , 0, "@0" }, // find key
@ -424,6 +425,7 @@ static keyname FkeyName[] =
{ fc::Fckey_g , "Ctrl+G" },
{ fc::Fkey_erase , "Backspace" }, // Ctrl+H
{ fc::Fkey_tab , "Tab" }, // Ctrl+I
{ fc::Fckey_j , "Ctrl+J" },
{ fc::Fckey_h , "Ctrl+K" },
{ fc::Fckey_l , "Ctrl+L" },
{ fc::Fkey_return , "Return" }, // Ctrl+M

View File

@ -233,9 +233,6 @@ void FLabel::draw()
if ( text.isNull() || text.isEmpty() )
return;
if ( Encoding == fc::VT100 )
unsetVT100altChar();
setUpdateVTerm(false);
if ( isMonochron() )
@ -319,7 +316,7 @@ void FLabel::draw()
//----------------------------------------------------------------------
void FLabel::hide()
{
int fg, bg;
short fg, bg;
char* blank;
FWidget::hide();

View File

@ -45,8 +45,8 @@ class FLabel : public FWidget
FString text;
int emphasis;
uInt alignment;
uChar emphasis_color;
uChar ellipsis_color;
short emphasis_color;
short ellipsis_color;
bool reverse_mode;
FWidget* accel_widget;

View File

@ -106,9 +106,6 @@ void FLineEdit::draw()
{
bool isFocus;
if ( Encoding == fc::VT100 )
unsetVT100altChar();
drawInputField();
isFocus = ((flags & FOCUS) != 0);
@ -276,7 +273,8 @@ void FLineEdit::adjustSize()
//----------------------------------------------------------------------
void FLineEdit::hide()
{
int fg, bg, s, size, lable_Length;
int s, size, lable_Length;
short fg, bg;
char* blank;
FWidget::hide();

View File

@ -187,9 +187,6 @@ void FListBox::drawLabel()
if ( text.isNull() || text.isEmpty() )
return;
if ( Encoding == fc::VT100 )
unsetVT100altChar();
txt = " " + text + " ";
length = txt.getLength();
gotoxy (xpos+xmin, ypos+ymin-1);
@ -537,7 +534,8 @@ void FListBox::setCurrentItem(int index)
//----------------------------------------------------------------------
void FListBox::hide()
{
int fg, bg, n, size;
int n, size;
short fg, bg;
char* blank;
FWidget::hide();

View File

@ -754,8 +754,10 @@ void FMenu::drawItems()
{
if ( ! iswprint(wint_t(item_text[z])) )
{
if ( ! isNewFont() && ( int(item_text[z]) < fc::NF_rev_left_arrow2
|| int(item_text[z]) > fc::NF_check_mark ) )
if ( ! isNewFont()
&& ( int(item_text[z]) < fc::NF_rev_left_arrow2
|| int(item_text[z]) > fc::NF_check_mark )
&& ! charEncodable(uInt(item_text[z])) )
{
item_text[z] = L' ';
}
@ -778,11 +780,9 @@ void FMenu::drawItems()
int len = int(maxItemWidth) - (to_char + c + 3);
if ( len > 0 )
{
FString spaces (len, wchar_t(' '));
if ( isTeraTerm() )
print (spaces + wchar_t('>'));
else // BlackRightPointingPointer ►
print (spaces + wchar_t(fc::BlackRightPointingPointer));
print (FString(len, wchar_t(' ')));
// BlackRightPointingPointer ►
print (wchar_t(fc::BlackRightPointingPointer));
to_char = int(maxItemWidth) - (c + 2);
}
}

View File

@ -835,7 +835,8 @@ void FMenuBar::onAccel (FAccelEvent* ev)
//----------------------------------------------------------------------
void FMenuBar::hide()
{
int fg, bg, screenWidth;
int screenWidth;
short fg, bg;
char* blank;
FWindow::hide();

View File

@ -218,9 +218,6 @@ void FMessageBox::draw()
{
FDialog::draw();
if ( Encoding == fc::VT100 )
unsetVT100altChar();
int head_offset = 0;
int center_x = 0;
int msg_x = int((width - int(maxLineWidth)) / 2); // center the whole block

View File

@ -69,7 +69,7 @@ class FMessageBox : public FDialog
std::vector<FString> text_split;
uInt maxLineWidth;
bool center_text;
uChar emphasis_color;
short emphasis_color;
uInt numButtons;
uInt text_num_lines;
int* button_digit[3];

View File

@ -204,7 +204,7 @@ bool FObject::delTimer (int id)
//----------------------------------------------------------------------
bool FObject::delOwnTimer()
{
FObject::TimerList::iterator iter, end;
FObject::TimerList::iterator iter;
if ( ! timer_list )
return false;

1330
src/foptiattr.cpp Normal file

File diff suppressed because it is too large Load Diff

265
src/foptiattr.h Normal file
View File

@ -0,0 +1,265 @@
// File: foptiattr.h
// Provides: class FOptiAttr
//
// Standalone class
// ════════════════
//
// ▕▔▔▔▔▔▔▔▔▔▔▔▏
// ▕ FOptiAttr ▏
// ▕▁▁▁▁▁▁▁▁▁▁▁▏
#ifndef _FOPTIATTR_H
#define _FOPTIATTR_H
#include <algorithm> // need for std::swap
#include <assert.h>
#include <term.h> // need for tparm
//----------------------------------------------------------------------
// class FOptiAttr
//----------------------------------------------------------------------
#pragma pack(push)
#pragma pack(1)
class FOptiAttr
{
private:
typedef unsigned char uChar;
enum init_reset_tests
{
no_test = 0x00,
test_ansi_reset = 0x01, // ANSI X3.64 terminal
test_adm3_reset = 0x02, // Lear Siegler ADM-3 terminal
same_like_ue = 0x04,
same_like_se = 0x08,
same_like_me = 0x10,
all_tests = 0x1f
};
typedef struct
{
char* cap;
bool caused_reset;
} capability;
capability F_enter_bold_mode;
capability F_exit_bold_mode;
capability F_enter_dim_mode;
capability F_exit_dim_mode;
capability F_enter_italics_mode;
capability F_exit_italics_mode;
capability F_enter_underline_mode;
capability F_exit_underline_mode;
capability F_enter_blink_mode;
capability F_exit_blink_mode;
capability F_enter_reverse_mode;
capability F_exit_reverse_mode;
capability F_enter_standout_mode;
capability F_exit_standout_mode;
capability F_enter_secure_mode;
capability F_exit_secure_mode;
capability F_enter_protected_mode;
capability F_exit_protected_mode;
capability F_enter_crossed_out_mode;
capability F_exit_crossed_out_mode;
capability F_enter_dbl_underline_mode;
capability F_exit_dbl_underline_mode;
capability F_set_attributes;
capability F_exit_attribute_mode;
capability F_enter_alt_charset_mode;
capability F_exit_alt_charset_mode;
capability F_enter_pc_charset_mode;
capability F_exit_pc_charset_mode;
capability F_set_a_foreground;
capability F_set_a_background;
capability F_set_foreground;
capability F_set_background;
capability F_set_color_pair;
int max_color;
int attr_without_color;
bool monochron;
bool fake_reverse;
bool cygwin_terminal;
char attr_buf[8192];
char* attr_ptr;
public:
typedef struct
{
int code; // character code
short fg_color; // foreground color
short bg_color; // background color
uChar bold : 1; // bold
uChar dim : 1; // dim
uChar italic : 1; // italic
uChar underline : 1; // underline
uChar blink : 1; // blink
uChar reverse : 1; // reverse
uChar standout : 1; // standout
uChar invisible : 1; // invisible
uChar protect : 1; // protect mode
uChar crossed_out : 1; // crossed out
uChar dbl_underline : 1; // double underline
uChar alt_charset : 1; // alternate character set (vt100)
uChar pc_charset : 1; // pc character set (CP437)
uChar : 3; // padding bits
} char_data;
private:
char_data on;
char_data off;
private:
FOptiAttr (const FOptiAttr&); // Disabled copy constructor
FOptiAttr& operator = (const FOptiAttr&); // and operator '='
bool hasColor (char_data*&);
bool colorChange (char_data*&, char_data*&);
void resetColor (char_data*&);
void prevent_no_color_video_attributes (char_data*&);
void change_color (char_data*&, char_data*&);
bool hasAttribute (char_data*&);
bool hasNoAttribute (char_data*&);
void resetAttribute (char_data*&);
void reset (char_data*&);
bool caused_reset_attributes (char*&, uChar = all_tests);
void detectSwitchOn (char_data*&, char_data*&);
void detectSwitchOff (char_data*&, char_data*&);
bool switchOn();
bool switchOff();
bool append_sequence (char*&);
bool replace_sequence (char*&);
bool setTermBold (char_data*&);
bool unsetTermBold (char_data*&);
bool setTermDim (char_data*&);
bool unsetTermDim (char_data*&);
bool setTermItalic (char_data*&);
bool unsetTermItalic (char_data*&);
bool setTermUnderline (char_data*&);
bool unsetTermUnderline (char_data*&);
bool setTermBlink (char_data*&);
bool unsetTermBlink (char_data*&);
bool setTermReverse (char_data*&);
bool unsetTermReverse (char_data*&);
bool setTermStandout (char_data*&);
bool unsetTermStandout (char_data*&);
bool setTermInvisible (char_data*&);
bool unsetTermInvisible (char_data*&);
bool setTermProtected (char_data*&);
bool unsetTermProtected (char_data*&);
bool setTermCrossedOut (char_data*&);
bool unsetTermCrossedOut (char_data*&);
bool setTermDoubleUnderline (char_data*&);
bool unsetTermDoubleUnderline (char_data*&);
bool setTermAttributes ( char_data*&
, bool, bool, bool
, bool, bool, bool
, bool, bool, bool );
bool unsetTermAttributes (char_data*&);
bool setTermAltCharset (char_data*&);
bool unsetTermAltCharset (char_data*&);
bool setTermPCcharset (char_data*&);
bool unsetTermPCcharset (char_data*&);
public:
explicit FOptiAttr(); // constructor
~FOptiAttr(); // destructor
static short vga2ansi (short);
void setMaxColor (int&);
void setNoColorVideo (int);
void setCygwinTerminal();
void set_enter_bold_mode (char*&);
void set_exit_bold_mode (char*&);
void set_enter_dim_mode (char*&);
void set_exit_dim_mode (char*&);
void set_enter_italics_mode (char*&);
void set_exit_italics_mode (char*&);
void set_enter_underline_mode (char*&);
void set_exit_underline_mode (char*&);
void set_enter_blink_mode (char*&);
void set_exit_blink_mode (char*&);
void set_enter_reverse_mode (char*&);
void set_exit_reverse_mode (char*&);
void set_enter_secure_mode (char*&);
void set_exit_secure_mode (char*&);
void set_enter_protected_mode (char*&);
void set_exit_protected_mode (char*&);
void set_enter_crossed_out_mode (char*&);
void set_exit_crossed_out_mode (char*&);
void set_enter_dbl_underline_mode (char*&);
void set_exit_dbl_underline_mode (char*&);
void set_enter_standout_mode (char*&);
void set_exit_standout_mode (char*&);
void set_set_attributes (char*&);
void set_exit_attribute_mode (char*&);
void set_enter_alt_charset_mode (char*&);
void set_exit_alt_charset_mode (char*&);
void set_enter_pc_charset_mode (char*&);
void set_exit_pc_charset_mode (char*&);
void set_a_foreground_color (char*&);
void set_a_background_color (char*&);
void set_foreground_color (char*&);
void set_background_color (char*&);
void set_term_color_pair (char*&);
void init();
char* change_attribute (char_data*&, char_data*&);
friend bool operator == (const char_data&, const char_data&);
friend bool operator != (const char_data&, const char_data&);
};
#pragma pack(pop)
// FOptiAttr inline functions
//----------------------------------------------------------------------
inline void FOptiAttr::setMaxColor (int& c)
{ max_color = c; }
//----------------------------------------------------------------------
inline void FOptiAttr::setNoColorVideo (int attr)
{ attr_without_color = attr; }
//----------------------------------------------------------------------
inline void FOptiAttr::setCygwinTerminal()
{ cygwin_terminal = true; }
//----------------------------------------------------------------------
inline bool FOptiAttr::hasNoAttribute (char_data*& attr)
{ return ! hasAttribute(attr); }
//----------------------------------------------------------------------
inline bool operator == ( const FOptiAttr::char_data& lhs,
const FOptiAttr::char_data& rhs )
{
return lhs.code == rhs.code
&& lhs.fg_color == rhs.fg_color
&& lhs.bg_color == rhs.bg_color
&& lhs.bold == rhs.bold
&& lhs.dim == rhs.dim
&& lhs.italic == rhs.italic
&& lhs.underline == rhs.underline
&& lhs.blink == rhs.blink
&& lhs.reverse == rhs.reverse
&& lhs.standout == rhs.standout
&& lhs.invisible == rhs.invisible
&& lhs.protect == rhs.protect
&& lhs.crossed_out == rhs.crossed_out
&& lhs.dbl_underline == rhs.dbl_underline
&& lhs.alt_charset == rhs.alt_charset
&& lhs.pc_charset == rhs.pc_charset;
}
//----------------------------------------------------------------------
inline bool operator != ( const FOptiAttr::char_data& lhs,
const FOptiAttr::char_data& rhs )
{ return ! ( lhs == rhs ); }
#endif // _FOPTIATTR_H

View File

@ -15,7 +15,7 @@
#define _FOPTIMOVE_H
#include <assert.h>
#include <term.h>
#include <term.h> // need for tparm
#include <cctype>
#include <cstdio> // need for printf

View File

@ -110,13 +110,13 @@ void FProgressbar::drawBar()
}
else
{
setColor(wc.progressbar_fg, wc.progressbar_bg);
setColor (wc.progressbar_fg, wc.progressbar_bg);
print (fc::LeftHalfBlock); // ▌
}
i++;
}
setColor(wc.progressbar_fg, wc.progressbar_bg);
setColor (wc.progressbar_fg, wc.progressbar_bg);
if ( getMaxColor() < 16 )
{
for (; i < BarLength; i++)
@ -154,7 +154,8 @@ void FProgressbar::draw()
//----------------------------------------------------------------------
void FProgressbar::hide()
{
int fg, bg, s, size;
int s, size;
short fg, bg;
char* blank;
FWidget::hide();

View File

@ -54,8 +54,10 @@ void FRadioButton::drawRadioButton()
{
if ( ! isVisible() )
return;
gotoxy (xpos+xmin-1, ypos+ymin-1);
setColor (foregroundColor, backgroundColor);
if ( isMonochron() )
{
if ( hasFocus() )

View File

@ -515,7 +515,8 @@ void FStatusBar::onMouseMove (FMouseEvent* ev)
//----------------------------------------------------------------------
void FStatusBar::hide()
{
int fg, bg, lastLine, screenWidth;
int lastLine, screenWidth;
short fg, bg;
char* blank;
FWindow::hide();

View File

@ -40,9 +40,10 @@ static tcap_map tcap[] =
{ 0, "Sf" }, // set_foreground -> Set foreground color #1
{ 0, "Sb" }, // set_background -> Set background color #1
{ 0, "sp" }, // set_color_pair -> Set current color pair to #1
{ 0, "sa" }, // set_attributes -> define videoattributes #1-#9 (PG9)
{ 0, "op" }, // orig_pair -> Set default pair to original value
{ 0, "oc" }, // orig_colors -> Set all color pairs to the original
{ 0, "NC" }, // no_color_video -> video attributes that cannot be used
// with colors
{ 0, "cm" }, // cursor_address -> move to row #1 columns #2
{ 0, "ch" }, // column_address -> horizontal position #1, absolute (P)
{ 0, "cv" }, // row_address -> vertical position #1 absolute (P)
@ -62,24 +63,29 @@ static tcap_map tcap[] =
{ 0, "ti" }, // enter_ca_mode -> string to start programs using cup
{ 0, "te" }, // exit_ca_mode -> strings to end programs using cup
{ 0, "eA" }, // enable_acs -> enable alternate char set
{ 0, "md" }, // enter_bold_mode -> turn on bold (extra bright) mode
{ 0, "md" }, // enter_bold_mode -> turn on bold (double-bright) mode
{ 0, "me" }, // exit_bold_mode -> turn off bold mode
{ 0, "mh" }, // enter_dim_mode -> turn on half-bright
{ 0, "me" }, // exit_dim_mode -> turn off half-bright
{ 0, "ZH" }, // enter_italics_mode -> Enter italic mode
{ 0, "ZR" }, // exit_italics_mode -> End italic mode
{ 0, "mb" }, // enter_blink_mode -> turn on blinking
{ 0, "me" }, // exit_blink_mode -> turn off blinking
{ 0, "us" }, // enter_underline_mode -> begin underline mode
{ 0, "ue" }, // exit_underline_mode -> exit underline mode
{ 0, "mb" }, // enter_blink_mode -> turn on blinking
{ 0, "me" }, // exit_blink_mode -> turn off blinking
{ 0, "mr" }, // enter_reverse_mode -> turn on reverse video mode
{ 0, "me" }, // exit_reverse_mode -> turn off reverse video mode
{ 0, "mk" }, // enter_secure_mode -> turn on blank mode (characters invisible)
{ 0, "me" }, // exit_secure_mode -> turn off blank mode (characters visible)
{ 0, "XX" }, // enter_crossed_out_mode -> turn on mark character as deleted
{ 0, "me" }, // exit_crossed_out_mode -> turn off mark character as deleted
{ 0, "so" }, // enter_standout_mode -> begin standout mode
{ 0, "se" }, // exit_standout_mode -> exit standout mode
{ 0, "mk" }, // enter_secure_mode -> turn on blank mode (characters invisible)
{ 0, "me" }, // exit_secure_mode -> turn off blank mode (characters visible)
{ 0, "mp" }, // enter_protected_mode -> turn on protected mode
{ 0, "me" }, // exit_protected_mode -> turn off protected mode
{ 0, "XX" }, // enter_crossed_out_mode -> turn on mark character as deleted
{ 0, "me" }, // exit_crossed_out_mode -> turn off mark character as deleted
{ 0, "Us" }, // enter_dbl_underline_mode -> begin double underline mode
{ 0, "Ue" }, // exit_dbl_underline_mode -> exit double underline mode
{ 0, "sa" }, // set_attributes -> define videoattributes #1-#9 (PG9)
{ 0, "me" }, // exit_attribute_mode -> turn off all attributes
{ 0, "as" }, // enter_alt_charset_mode -> start alternate character set (P)
{ 0, "ae" }, // exit_alt_charset_mode -> end alternate character set (P)
@ -103,6 +109,8 @@ static tcap_map tcap[] =
* (P*) indicates that padding may vary in proportion
* to the number of lines affected
* (#i) indicates the ith parameter.
*
* "XX", "Us" and "Ue" are unofficial and are only used here.
*/
enum termcaps
@ -124,9 +132,9 @@ enum termcaps
t_set_foreground,
t_set_background,
t_set_color_pair,
t_set_attributes,
t_orig_pair,
t_orig_colors,
t_no_color_video,
t_cursor_address,
t_column_address,
t_row_address,
@ -152,18 +160,23 @@ enum termcaps
t_exit_dim_mode,
t_enter_italics_mode,
t_exit_italics_mode,
t_enter_blink_mode,
t_exit_blink_mode,
t_enter_underline_mode,
t_exit_underline_mode,
t_enter_blink_mode,
t_exit_blink_mode,
t_enter_reverse_mode,
t_exit_reverse_mode,
t_enter_secure_mode,
t_exit_secure_mode,
t_enter_crossed_out_mode,
t_exit_crossed_out_mode,
t_enter_standout_mode,
t_exit_standout_mode,
t_enter_secure_mode,
t_exit_secure_mode,
t_enter_protected_mode,
t_exit_protected_mode,
t_enter_crossed_out_mode,
t_exit_crossed_out_mode,
t_enter_dbl_underline_mode,
t_exit_dbl_underline_mode,
t_set_attributes,
t_exit_attribute_mode,
t_enter_alt_charset_mode,
t_exit_alt_charset_mode,

File diff suppressed because it is too large Load Diff

View File

@ -8,6 +8,10 @@
// ▕ FTerm ▏-┬- - - -▕ FOptiMove ▏
// ▕▁▁▁▁▁▁▁▏ : ▕▁▁▁▁▁▁▁▁▁▁▁▏
// :
// : 1▕▔▔▔▔▔▔▔▔▔▔▔▏
// :- - - -▕ FOptiAttr ▏
// : ▕▁▁▁▁▁▁▁▁▁▁▁▏
// :
// : *▕▔▔▔▔▔▔▔▔▔▏
// :- - - -▕ FString ▏
// : ▕▁▁▁▁▁▁▁▁▁▏
@ -54,6 +58,7 @@
#include "fenum.h"
#include "fobject.h"
#include "foptiattr.h"
#include "foptimove.h"
#include "fpoint.h"
#include "frect.h"
@ -90,22 +95,14 @@ class FTerm
static std::map <uChar,uChar>* vt100_alt_char;
static std::map <std::string,fc::encoding>* encoding_set;
static bool term_bold;
static bool term_dim;
static bool term_italic;
static bool term_reverse;
static bool term_underline;
static bool hiddenCursor;
static bool mouse_support;
static bool vt100_state;
static bool ignore_vt100_state;
static bool raw_mode;
static bool input_data_pending;
static bool terminal_update_pending;
static bool force_terminal_update;
static bool non_blocking_stdin;
static bool gpm_mouse_enabled;
static bool pc_charset_state;
static bool pc_charset_console;
static bool utf8_input;
static bool utf8_state;
@ -132,7 +129,6 @@ class FTerm
static bool tmux_terminal;
static bool terminal_updates;
static bool vterm_updates;
static bool exit_underline_caused_reset;
static bool background_color_erase;
static bool automatic_left_margin;
static bool automatic_right_margin;
@ -151,25 +147,27 @@ class FTerm
static int max_color;
static int fd_tty;
static uInt baudrate;
static int fg_color;
static int bg_color;
static int fg_term_color;
static int bg_term_color;
static int x_term_pos;
static int y_term_pos;
static bool resize_term;
static struct termios term_init;
static FOptiAttr::char_data term_attribute;
static FOptiAttr::char_data next_attribute;
static fc::console_cursor_style consoleCursorStyle;
static struct console_font_op screenFont;
static struct unimapdesc screenUnicodeMap;
static FOptiMove* opti;
static FOptiMove* opti_move;
static FOptiAttr* opti_attr;
static const FString* xterm_font;
static const FString* xterm_title;
static const FString* AnswerBack;
static const FString* Sec_DA;
typedef FOptiAttr::char_data char_data;
typedef struct
{
uChar red;
@ -183,15 +181,11 @@ class FTerm
} map;
protected:
static bool bold;
static bool dim;
static bool italic;
static bool reverse;
static bool underline;
static bool NewFont;
static bool VGAFont;
static bool cursor_optimisation;
static uInt tabstop;
static uInt attr_without_color;
static fc::encoding Encoding;
typedef struct
@ -200,19 +194,6 @@ class FTerm
uInt xmax;
} line_changes;
typedef struct
{
int code; // character code
uChar fg_color; // foreground color
uChar bg_color; // background color
uChar bold : 1; // bold
uChar dim : 1; // dim
uChar italic : 1; // italic
uChar reverse : 1; // reverse
uChar underline : 1; // underline
uChar : 3; // padding bits
} char_data;
typedef struct
{
int width;
@ -254,17 +235,20 @@ class FTerm
static char* parseAnswerbackMsg (char*&);
static char* parseSecDA (char*&);
static void init_termcaps();
static void init_vt100altChar();
static void init_alt_charset();
static void init_pc_charset();
static void init_encoding();
void init();
void finish();
static uInt charEncode (uInt);
static uInt charEncode (uInt, fc::encoding);
static uInt cp437_to_unicode (uChar);
static void signal_handler (int);
friend class FWidget;
friend class FApplication;
protected:
static bool charEncodable (uInt);
void createArea (FTerm::term_area*&); // reference to pointer
void resizeArea (FTerm::term_area*);
void restoreVTerm (const FRect&);
@ -336,12 +320,9 @@ class FTerm
static void resetXTermHighlightBackground();
static void saveColorMap();
static void resetColorMap();
static void setPalette (int, int, int, int);
static int vga2ansi (int);
void setColor (int, int);
static void setTermColor (int, int);
static int getTermForegroundColor();
static int getTermBackgroundColor();
static void setPalette (short, int, int, int);
static short getTermForegroundColor();
static short getTermBackgroundColor();
static int getMaxColor();
static void xtermMouse (bool);
static void enableXTermMouse();
@ -358,12 +339,6 @@ class FTerm
static void resetBeep();
static void beep();
static bool setTermBold (bool);
static bool setTermDim (bool);
static bool setTermItalic (bool);
static bool setTermReverse (bool);
static bool setTermUnderline (bool);
static bool hideCursor (bool);
static bool hideCursor();
static bool showCursor();
@ -373,20 +348,10 @@ class FTerm
static void setEncoding (std::string);
static std::string getEncoding();
static bool setPCcharset (bool);
static bool setPCcharset();
static bool unsetPCcharset();
static bool isPCcharset();
static bool setNonBlockingInput (bool);
static bool setNonBlockingInput();
static bool unsetNonBlockingInput();
static bool setVT100altChar (bool);
static bool setVT100altChar();
static bool unsetVT100altChar();
static bool isVT100altChar();
static bool setUTF8 (bool);
static bool setUTF8();
static bool unsetUTF8();
@ -421,6 +386,8 @@ class FTerm
int print (FTerm::term_area*, FString&);
int print (int);
int print (FTerm::term_area*, int);
static void newFontChanges (char_data*&);
static void charsetChanges (char_data*&);
static void appendCharacter (char_data*&);
static void appendAttributes (char_data*&);
static int appendLowerRight (char_data*&);
@ -438,8 +405,6 @@ class FTerm
;
static void putstring (const char*, int = 1);
static int putchar_ASCII (register int);
static int putchar_VT100 (register int);
static int putchar_PC (register int);
static int putchar_UTF8 (register int);
static int UTF8decode (char*);
};
@ -553,12 +518,12 @@ inline bool FTerm::isRaw()
{ return raw_mode; }
//----------------------------------------------------------------------
inline int FTerm::getTermForegroundColor()
{ return fg_color; }
inline short FTerm::getTermForegroundColor()
{ return next_attribute.fg_color; }
//----------------------------------------------------------------------
inline int FTerm::getTermBackgroundColor()
{ return bg_color; }
inline short FTerm::getTermBackgroundColor()
{ return next_attribute.bg_color; }
//----------------------------------------------------------------------
inline int FTerm::getMaxColor()
@ -592,18 +557,6 @@ inline bool FTerm::hideCursor()
inline bool FTerm::showCursor()
{ return hideCursor(false); }
//----------------------------------------------------------------------
inline bool FTerm::setPCcharset()
{ return setPCcharset(true); }
//----------------------------------------------------------------------
inline bool FTerm::unsetPCcharset()
{ return setPCcharset(false); }
//----------------------------------------------------------------------
inline bool FTerm::isPCcharset()
{ return pc_charset_state; }
//----------------------------------------------------------------------
inline bool FTerm::setNonBlockingInput()
{ return setNonBlockingInput(true); }
@ -612,18 +565,6 @@ inline bool FTerm::setNonBlockingInput()
inline bool FTerm::unsetNonBlockingInput()
{ return setNonBlockingInput(false); }
//----------------------------------------------------------------------
inline bool FTerm::setVT100altChar()
{ return setVT100altChar(true); }
//----------------------------------------------------------------------
inline bool FTerm::unsetVT100altChar()
{ return setVT100altChar(false); }
//----------------------------------------------------------------------
inline bool FTerm::isVT100altChar()
{ return vt100_state; }
//----------------------------------------------------------------------
inline bool FTerm::setUTF8()
{ return setUTF8(true); }

View File

@ -126,10 +126,20 @@ void FTextView::drawText()
uInt len = line.getLength();
for (i=0; i < len; i++)
if ( wcwidth(line_str[i]) == 1 ) // only 1 column per character
print (line_str[i]);
{
wchar_t ch = line_str[i];
bool utf8 = (Encoding == fc::UTF8) ? true : false;
// only printable and 1 column per character
if ( ( (utf8 && iswprint(wint_t(ch)))
|| (!utf8 && ch < 256 && isprint(ch)) )
&& wcwidth(ch) == 1 )
{
print (ch);
}
else
print ('.');
}
for (; i < uInt(width - nf_offset - 2); i++)
print (' ');
}
@ -180,7 +190,8 @@ void FTextView::adjustSize()
//----------------------------------------------------------------------
void FTextView::hide()
{
int fg, bg, n, size;
int n, size;
short fg, bg;
char* blank;
FWidget::hide();

View File

@ -226,9 +226,9 @@ void FToggleButton::drawLabel()
setReverse(true);
if ( isEnabled() )
setColor(wc.label_fg, wc.label_bg);
setColor (wc.label_fg, wc.label_bg);
else
setColor(wc.label_inactive_fg, wc.label_inactive_bg);
setColor (wc.label_inactive_fg, wc.label_inactive_bg);
for (int z=0; z < int(length); z++)
{
@ -346,7 +346,8 @@ void FToggleButton::onKeyPress (FKeyEvent* ev)
//----------------------------------------------------------------------
void FToggleButton::hide()
{
int fg, bg, size;
int size;
short fg, bg;
char* blank;
FWidget::hide();

View File

@ -1134,13 +1134,23 @@ void FWidget::redraw()
if ( isRootWidget() )
{
// draw windows
char_data default_char;
FOptiAttr::char_data default_char;
default_char.code = ' ';
default_char.fg_color = fc::Black;
default_char.bg_color = fc::Black;
default_char.bold = 0;
default_char.reverse = 0;
default_char.dim = 0;
default_char.italic = 0;
default_char.underline = 0;
default_char.blink = 0;
default_char.reverse = 0;
default_char.standout = 0;
default_char.invisible = 0;
default_char.protect = 0;
default_char.crossed_out = 0;
default_char.dbl_underline = 0;
default_char.alt_charset = 0;
default_char.pc_charset = 0;
if ( window_list && ! window_list->empty() )
{
@ -1451,6 +1461,14 @@ bool FWidget::setFocus(bool on)
return focus = (on) ? true : false;
}
//----------------------------------------------------------------------
void FWidget::setColor (register short fg, register short bg)
{
// Changes colors
next_attribute.fg_color = fg;
next_attribute.bg_color = bg;
}
//----------------------------------------------------------------------
void FWidget::setX (int x, bool adjust)
{
@ -1739,14 +1757,24 @@ void FWidget::clrscr()
{
term_area* area;
FWindow* area_widget;
char_data default_char;
FOptiAttr::char_data default_char;
default_char.code = ' ';
default_char.fg_color = uChar(fg_color);
default_char.bg_color = uChar(bg_color);
default_char.bold = bold;
default_char.reverse = reverse;
default_char.underline = underline;
default_char.fg_color = next_attribute.fg_color;
default_char.bg_color = next_attribute.bg_color;
default_char.bold = next_attribute.bold;
default_char.dim = next_attribute.dim;
default_char.italic = next_attribute.italic;
default_char.underline = next_attribute.underline;
default_char.blink = next_attribute.blink;
default_char.reverse = next_attribute.reverse;
default_char.standout = next_attribute.standout;
default_char.invisible = next_attribute.invisible;
default_char.protect = next_attribute.protect;
default_char.crossed_out = next_attribute.crossed_out;
default_char.dbl_underline = next_attribute.dbl_underline;
default_char.alt_charset = next_attribute.alt_charset;
default_char.pc_charset = next_attribute.pc_charset;
area_widget = FWindow::getWindowWidget(this);
@ -1782,7 +1810,7 @@ void FWidget::clrscr()
//----------------------------------------------------------------------
void FWidget::drawShadow()
{
FTerm::char_data ch;
FOptiAttr::char_data ch;
int x1, x2, y1, y2;
bool trans_shadow = ((flags & TRANS_SHADOW) != 0);
@ -1812,18 +1840,37 @@ void FWidget::drawShadow()
{
ch = getCoveredCharacter (x2+x, y1, this);
setColor (ch.fg_color, ch.bg_color);
if ( ch.reverse )
setReverse(true);
if ( ch.bold )
setBold(true);
setBold (true);
if ( ch.dim )
setDim (true);
if ( ch.italic )
setItalic (true);
if ( ch.underline )
setUnderline(true);
setUnderline (true);
if ( ch.blink )
setBlink (true);
if ( ch.reverse )
setReverse (true);
if ( ch.standout )
setStandout (true);
if ( ch.invisible )
setInvisible (true);
if ( ch.protect )
setProtected (true);
if ( ch.crossed_out )
setCrossedOut (true);
if ( ch.dbl_underline )
setDoubleUnderline (true);
if ( ch.alt_charset )
setAltCharset (true);
if ( ch.pc_charset )
setPCcharset (true);
print (ch.code);
setReverse(false);
setBold(false);
setUnderline(false);
setNormal();
}
setColor (wc.shadow_bg, wc.shadow_fg);
@ -1852,18 +1899,37 @@ void FWidget::drawShadow()
{
ch = getCoveredCharacter (x1+x, y2+1, this);
setColor (ch.fg_color, ch.bg_color);
if ( ch.reverse )
setReverse(true);
if ( ch.bold )
setBold(true);
setBold (true);
if ( ch.dim )
setDim (true);
if ( ch.italic )
setItalic (true);
if ( ch.underline )
setUnderline(true);
setUnderline (true);
if ( ch.blink )
setBlink (true);
if ( ch.reverse )
setReverse (true);
if ( ch.standout )
setStandout (true);
if ( ch.invisible )
setInvisible (true);
if ( ch.protect )
setProtected (true);
if ( ch.crossed_out )
setCrossedOut (true);
if ( ch.dbl_underline )
setDoubleUnderline (true);
if ( ch.alt_charset )
setAltCharset (true);
if ( ch.pc_charset )
setPCcharset (true);
print (ch.code);
setReverse(false);
setBold(false);
setUnderline(false);
setNormal();
}
setColor (wc.shadow_bg, wc.shadow_fg);
@ -1916,7 +1982,7 @@ void FWidget::drawShadow()
for (int i=1; i <= width && x1+i <= xmax; i++)
{
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
@ -1929,7 +1995,7 @@ void FWidget::drawShadow()
//----------------------------------------------------------------------
void FWidget::clearShadow()
{
FTerm::char_data ch;
FOptiAttr::char_data ch;
int x1, x2, y1, y2;
if ( isMonochron() )

View File

@ -141,85 +141,85 @@ class FWidget : public FObject, public FTerm
static struct widget_colors
{
uChar term_fg;
uChar term_bg;
uChar list_fg;
uChar list_bg;
uChar selected_list_fg;
uChar selected_list_bg;
uChar current_element_focus_fg;
uChar current_element_focus_bg;
uChar current_element_fg;
uChar current_element_bg;
uChar current_inc_search_element_fg;
uChar selected_current_element_focus_fg;
uChar selected_current_element_focus_bg;
uChar selected_current_element_fg;
uChar selected_current_element_bg;
uChar label_fg;
uChar label_bg;
uChar label_inactive_fg;
uChar label_inactive_bg;
uChar label_hotkey_fg;
uChar label_hotkey_bg;
uChar label_emphasis_fg;
uChar label_ellipsis_fg;
uChar inputfield_active_focus_fg;
uChar inputfield_active_focus_bg;
uChar inputfield_active_fg;
uChar inputfield_active_bg;
uChar inputfield_inactive_fg;
uChar inputfield_inactive_bg;
uChar dialog_fg;
uChar dialog_emphasis_fg;
uChar dialog_bg;
uChar error_box_fg;
uChar error_box_emphasis_fg;
uChar error_box_bg;
uChar shadow_fg;
uChar shadow_bg;
uChar toggle_button_active_focus_fg;
uChar toggle_button_active_focus_bg;
uChar toggle_button_active_fg;
uChar toggle_button_active_bg;
uChar toggle_button_inactive_fg;
uChar toggle_button_inactive_bg;
uChar button_active_focus_fg;
uChar button_active_focus_bg;
uChar button_active_fg;
uChar button_active_bg;
uChar button_inactive_fg;
uChar button_inactive_bg;
uChar button_hotkey_fg;
uChar titlebar_active_fg;
uChar titlebar_active_bg;
uChar titlebar_inactive_fg;
uChar titlebar_inactive_bg;
uChar titlebar_button_fg;
uChar titlebar_button_bg;
uChar menu_active_focus_fg;
uChar menu_active_focus_bg;
uChar menu_active_fg;
uChar menu_active_bg;
uChar menu_inactive_fg;
uChar menu_inactive_bg;
uChar menu_hotkey_fg;
uChar menu_hotkey_bg;
uChar statusbar_fg;
uChar statusbar_bg;
uChar statusbar_hotkey_fg;
uChar statusbar_hotkey_bg;
uChar statusbar_separator_fg;
uChar statusbar_active_fg;
uChar statusbar_active_bg;
uChar statusbar_active_hotkey_fg;
uChar statusbar_active_hotkey_bg;
uChar scrollbar_fg;
uChar scrollbar_bg;
uChar scrollbar_button_fg;
uChar scrollbar_button_bg;
uChar progressbar_fg;
uChar progressbar_bg;
short term_fg;
short term_bg;
short list_fg;
short list_bg;
short selected_list_fg;
short selected_list_bg;
short current_element_focus_fg;
short current_element_focus_bg;
short current_element_fg;
short current_element_bg;
short current_inc_search_element_fg;
short selected_current_element_focus_fg;
short selected_current_element_focus_bg;
short selected_current_element_fg;
short selected_current_element_bg;
short label_fg;
short label_bg;
short label_inactive_fg;
short label_inactive_bg;
short label_hotkey_fg;
short label_hotkey_bg;
short label_emphasis_fg;
short label_ellipsis_fg;
short inputfield_active_focus_fg;
short inputfield_active_focus_bg;
short inputfield_active_fg;
short inputfield_active_bg;
short inputfield_inactive_fg;
short inputfield_inactive_bg;
short dialog_fg;
short dialog_emphasis_fg;
short dialog_bg;
short error_box_fg;
short error_box_emphasis_fg;
short error_box_bg;
short shadow_fg;
short shadow_bg;
short toggle_button_active_focus_fg;
short toggle_button_active_focus_bg;
short toggle_button_active_fg;
short toggle_button_active_bg;
short toggle_button_inactive_fg;
short toggle_button_inactive_bg;
short button_active_focus_fg;
short button_active_focus_bg;
short button_active_fg;
short button_active_bg;
short button_inactive_fg;
short button_inactive_bg;
short button_hotkey_fg;
short titlebar_active_fg;
short titlebar_active_bg;
short titlebar_inactive_fg;
short titlebar_inactive_bg;
short titlebar_button_fg;
short titlebar_button_bg;
short menu_active_focus_fg;
short menu_active_focus_bg;
short menu_active_fg;
short menu_active_bg;
short menu_inactive_fg;
short menu_inactive_bg;
short menu_hotkey_fg;
short menu_hotkey_bg;
short statusbar_fg;
short statusbar_bg;
short statusbar_hotkey_fg;
short statusbar_hotkey_bg;
short statusbar_separator_fg;
short statusbar_active_fg;
short statusbar_active_bg;
short statusbar_active_hotkey_fg;
short statusbar_active_hotkey_bg;
short scrollbar_fg;
short scrollbar_bg;
short scrollbar_button_fg;
short scrollbar_button_bg;
short progressbar_fg;
short progressbar_bg;
} wc;
// widget_colors wc;
@ -258,8 +258,8 @@ class FWidget : public FObject, public FTerm
bool ignore_padding;
bool window_object;
int flags;
int foregroundColor;
int backgroundColor;
short foregroundColor;
short backgroundColor;
static uInt modal_dialogs;
private:
@ -396,8 +396,8 @@ class FWidget : public FObject, public FTerm
bool ignorePadding();
bool acceptPadding();
int getForegroundColor() const;
int getBackgroundColor() const;
short getForegroundColor() const;
short getBackgroundColor() const;
int getX() const;
int getY() const;
const FPoint getPos() const;
@ -418,8 +418,9 @@ class FWidget : public FObject, public FTerm
const FRect& getGeometryGlobal() const;
const FRect& getGeometryGlobalShadow() const;
FPoint globalToLocalPos (const FPoint&);
void setForegroundColor (int);
void setBackgroundColor (int);
void setForegroundColor (short);
void setBackgroundColor (short);
void setColor (short, short);
void setX (int, bool = true);
void setY (int, bool = true);
virtual void setPos (const FPoint&, bool = true);
@ -448,6 +449,8 @@ class FWidget : public FObject, public FTerm
static void gotoxy (register int, register int);
void clrscr();
static void setNormal();
static bool setBold (register bool);
static bool setBold();
static bool unsetBold();
@ -463,15 +466,55 @@ class FWidget : public FObject, public FTerm
static bool unsetItalic();
static bool isItalic();
static bool setUnderline (register bool);
static bool setUnderline();
static bool unsetUnderline();
static bool isUnderline();
static bool setBlink (register bool);
static bool setBlink();
static bool unsetBlink();
static bool isBlink();
static bool setReverse (register bool);
static bool setReverse();
static bool unsetReverse();
static bool isReverse();
static bool setUnderline (register bool);
static bool setUnderline();
static bool unsetUnderline();
static bool isUnderline();
static bool setStandout (register bool);
static bool setStandout();
static bool unsetStandout();
static bool isStandout();
static bool setInvisible (register bool);
static bool setInvisible();
static bool unsetInvisible();
static bool isInvisible();
static bool setProtected (register bool);
static bool setProtected();
static bool unsetProtected();
static bool isProtected();
static bool setCrossedOut (register bool);
static bool setCrossedOut();
static bool unsetCrossedOut();
static bool isCrossedOut();
static bool setDoubleUnderline (register bool);
static bool setDoubleUnderline();
static bool unsetDoubleUnderline();
static bool isDoubleUnderline();
static bool setAltCharset (register bool);
static bool setAltCharset();
static bool unsetAltCharset();
static bool isAltCharset();
static bool setPCcharset (register bool);
static bool setPCcharset();
static bool unsetPCcharset();
static bool isPCcharset();
void drawShadow();
void clearShadow();
@ -601,11 +644,11 @@ inline void FWidget::unsetFocusable()
{ focusable = false; }
//----------------------------------------------------------------------
inline int FWidget::getForegroundColor() const
inline short FWidget::getForegroundColor() const
{ return foregroundColor; }
//----------------------------------------------------------------------
inline int FWidget::getBackgroundColor() const
inline short FWidget::getBackgroundColor() const
{ return backgroundColor; }
//----------------------------------------------------------------------
@ -640,16 +683,16 @@ inline FPoint FWidget::globalToLocalPos (const FPoint& gPos)
}
//----------------------------------------------------------------------
inline void FWidget::setForegroundColor (int color)
inline void FWidget::setForegroundColor (short color)
{
if ( color >> 8 == 0 ) // valid colors 0..254
if ( color == -1 || color >> 8 == 0 ) // valid colors -1..254
foregroundColor = color;
}
//----------------------------------------------------------------------
inline void FWidget::setBackgroundColor (int color)
inline void FWidget::setBackgroundColor (short color)
{
if ( color >> 8 == 0 ) // valid colors 0..254
if ( color == -1 || color >> 8 == 0 ) // valid colors -1..254
backgroundColor = color;
}
@ -747,9 +790,30 @@ inline void FWidget::gotoxy (const FPoint& pos)
inline void FWidget::gotoxy (register int x, register int y)
{ cursor->setPoint(x,y); }
//----------------------------------------------------------------------
inline void FWidget::setNormal()
{
next_attribute.bold = \
next_attribute.dim = \
next_attribute.italic = \
next_attribute.underline = \
next_attribute.blink = \
next_attribute.reverse = \
next_attribute.standout = \
next_attribute.invisible = \
next_attribute.protect = \
next_attribute.crossed_out = \
next_attribute.dbl_underline = \
next_attribute.alt_charset = \
next_attribute.pc_charset = false;
next_attribute.fg_color = -1;
next_attribute.bg_color = -1;
}
//----------------------------------------------------------------------
inline bool FWidget::setBold (register bool on)
{ return (bold = on); }
{ return (next_attribute.bold = on); }
//----------------------------------------------------------------------
inline bool FWidget::setBold()
@ -761,11 +825,11 @@ inline bool FWidget::unsetBold()
//----------------------------------------------------------------------
inline bool FWidget::isBold()
{ return bold; }
{ return next_attribute.bold; }
//----------------------------------------------------------------------
inline bool FWidget::setDim (register bool on)
{ return (dim = on); }
{ return (next_attribute.dim = on); }
//----------------------------------------------------------------------
inline bool FWidget::setDim()
@ -777,11 +841,11 @@ inline bool FWidget::unsetDim()
//----------------------------------------------------------------------
inline bool FWidget::isDim()
{ return dim; }
{ return next_attribute.dim; }
//----------------------------------------------------------------------
inline bool FWidget::setItalic (register bool on)
{ return (italic = on); }
{ return (next_attribute.italic = on); }
//----------------------------------------------------------------------
inline bool FWidget::setItalic()
@ -793,27 +857,11 @@ inline bool FWidget::unsetItalic()
//----------------------------------------------------------------------
inline bool FWidget::isItalic()
{ return italic; }
//----------------------------------------------------------------------
inline bool FWidget::setReverse (register bool on)
{ return (reverse = on); }
//----------------------------------------------------------------------
inline bool FWidget::setReverse()
{ return setReverse(true); }
//----------------------------------------------------------------------
inline bool FWidget::unsetReverse()
{ return setReverse(false); }
//----------------------------------------------------------------------
inline bool FWidget::isReverse()
{ return reverse; }
{ return next_attribute.italic; }
//----------------------------------------------------------------------
inline bool FWidget::setUnderline (register bool on)
{ return (underline = on); }
{ return (next_attribute.underline = on); }
//----------------------------------------------------------------------
inline bool FWidget::setUnderline()
@ -825,7 +873,151 @@ inline bool FWidget::unsetUnderline()
//----------------------------------------------------------------------
inline bool FWidget::isUnderline()
{ return underline; }
{ return next_attribute.underline; }
//----------------------------------------------------------------------
inline bool FWidget::setBlink (register bool on)
{ return (next_attribute.blink = on); }
//----------------------------------------------------------------------
inline bool FWidget::setBlink()
{ return setBlink(true); }
//----------------------------------------------------------------------
inline bool FWidget::unsetBlink()
{ return setBlink(false); }
//----------------------------------------------------------------------
inline bool FWidget::isBlink()
{ return next_attribute.blink; }
//----------------------------------------------------------------------
inline bool FWidget::setReverse (register bool on)
{ return (next_attribute.reverse = on); }
//----------------------------------------------------------------------
inline bool FWidget::setReverse()
{ return setReverse(true); }
//----------------------------------------------------------------------
inline bool FWidget::unsetReverse()
{ return setReverse(false); }
//----------------------------------------------------------------------
inline bool FWidget::isReverse()
{ return next_attribute.reverse; }
//----------------------------------------------------------------------
inline bool FWidget::setStandout (register bool on)
{ return (next_attribute.standout = on); }
//----------------------------------------------------------------------
inline bool FWidget::setStandout()
{ return setStandout(true); }
//----------------------------------------------------------------------
inline bool FWidget::unsetStandout()
{ return setStandout(false); }
//----------------------------------------------------------------------
inline bool FWidget::isStandout()
{ return next_attribute.standout; }
//----------------------------------------------------------------------
inline bool FWidget::setInvisible (register bool on)
{ return (next_attribute.invisible = on); }
//----------------------------------------------------------------------
inline bool FWidget::setInvisible()
{ return setInvisible(true); }
//----------------------------------------------------------------------
inline bool FWidget::unsetInvisible()
{ return setInvisible(false); }
//----------------------------------------------------------------------
inline bool FWidget::isInvisible()
{ return next_attribute.invisible; }
//----------------------------------------------------------------------
inline bool FWidget::setProtected (register bool on)
{ return (next_attribute.protect = on); }
//----------------------------------------------------------------------
inline bool FWidget::setProtected()
{ return setProtected(true); }
//----------------------------------------------------------------------
inline bool FWidget::unsetProtected()
{ return setProtected(false); }
//----------------------------------------------------------------------
inline bool FWidget::isProtected()
{ return next_attribute.protect; }
//----------------------------------------------------------------------
inline bool FWidget::setCrossedOut (register bool on)
{ return (next_attribute.crossed_out = on); }
//----------------------------------------------------------------------
inline bool FWidget::setCrossedOut()
{ return setCrossedOut(true); }
//----------------------------------------------------------------------
inline bool FWidget::unsetCrossedOut()
{ return setCrossedOut(false); }
//----------------------------------------------------------------------
inline bool FWidget::isCrossedOut()
{ return next_attribute.crossed_out; }
//----------------------------------------------------------------------
inline bool FWidget::setDoubleUnderline (register bool on)
{ return (next_attribute.dbl_underline = on); }
//----------------------------------------------------------------------
inline bool FWidget::setDoubleUnderline()
{ return setDoubleUnderline(true); }
//----------------------------------------------------------------------
inline bool FWidget::unsetDoubleUnderline()
{ return setDoubleUnderline(false); }
//----------------------------------------------------------------------
inline bool FWidget::isDoubleUnderline()
{ return next_attribute.dbl_underline; }
//----------------------------------------------------------------------
inline bool FWidget::setAltCharset (register bool on)
{ return (next_attribute.alt_charset = on); }
//----------------------------------------------------------------------
inline bool FWidget::setAltCharset()
{ return setAltCharset(true); }
//----------------------------------------------------------------------
inline bool FWidget::unsetAltCharset()
{ return setAltCharset(false); }
//----------------------------------------------------------------------
inline bool FWidget::isAltCharset()
{ return next_attribute.alt_charset; }
//----------------------------------------------------------------------
inline bool FWidget::setPCcharset (register bool on)
{ return (next_attribute.pc_charset = on); }
//----------------------------------------------------------------------
inline bool FWidget::setPCcharset()
{ return setPCcharset(true); }
//----------------------------------------------------------------------
inline bool FWidget::unsetPCcharset()
{ return setPCcharset(false); }
//----------------------------------------------------------------------
inline bool FWidget::isPCcharset()
{ return next_attribute.pc_charset; }
//----------------------------------------------------------------------
inline void FWidget::unsetDoubleFlatLine(int side)

View File

@ -13,15 +13,17 @@ class keyboard : public FWidget
protected:
void onKeyPress (FKeyEvent*);
void onAccel (FAccelEvent*);
void draw();
};
//----------------------------------------------------------------------
keyboard::keyboard (FWidget* parent)
: FWidget(parent)
{
setColor(fc::LightGray, fc::Black);
clrscr();
updateTerminal();
resetXTermForeground();
resetXTermBackground();
wc.term_fg = -1;
wc.term_bg = -1;
}
//----------------------------------------------------------------------
@ -38,6 +40,18 @@ void keyboard::onAccel (FAccelEvent* ev)
ev->accept();
}
//----------------------------------------------------------------------
void keyboard::draw()
{
setNormal();
setColor(-1,-1);
clrscr();
gotoxy (1,1);
print ("---------------\n");
print ("Press Q to quit\n");
print ("---------------\n");
setCursorPos (1,5);
}
//----------------------------------------------------------------------
// main part
@ -45,14 +59,9 @@ void keyboard::onAccel (FAccelEvent* ev)
int main (int argc, char* argv[])
{
FApplication app(argc, argv);
keyboard t(&app);
t.addAccelerator('q');
app.setMainWidget(&t);
t.show();
t.setTermXY(0,0);
t.flush_out();
::printf("---------------\n\r");
::printf("Press Q to quit\n\r");
::printf("---------------\n\r\n");
keyboard key(&app);
key.addAccelerator('q');
app.setMainWidget(&key);
key.show();
return app.exec();
}

View File

@ -46,9 +46,6 @@ void Mandelbrot::draw()
FDialog::draw();
if ( Encoding == fc::VT100 )
unsetVT100altChar();
x_min = -2.20;
x_max = 1.00;
y_min = -1.05;

View File

@ -196,7 +196,7 @@ void Menu::defaultCallback (FMenuList* mb)
{
for (uInt i=1; i <= mb->count(); i++)
{
FMenuItem* item = mb->item(i);
FMenuItem* item = mb->item(int(i));
if ( item
&& item->isEnabled()

View File

@ -1,6 +1,7 @@
// File: term-attributes.cpp
#include "fapp.h"
#include "fbutton.h"
#include "fdialog.h"
#include "fmessagebox.h"
@ -14,6 +15,15 @@
class AttribDlg : public FDialog
{
private:
FButton* next_button;
FButton* back_button;
public:
short bgcolor;
private:
AttribDlg (const AttribDlg&); // Disabled copy constructor
AttribDlg& operator = (const AttribDlg&); // and operator '='
void adjustSize();
public:
@ -21,14 +31,44 @@ class AttribDlg : public FDialog
~AttribDlg(); // destructor
void onAccel (FAccelEvent*);
void onClose (FCloseEvent*);
void cb_next (FWidget*, void*);
void cb_back (FWidget*, void*);
};
#pragma pack(pop)
//----------------------------------------------------------------------
AttribDlg::AttribDlg (FWidget* parent)
: FDialog(parent)
, next_button()
, back_button()
, bgcolor(wc.label_bg)
{
setText ("A terminal attributes test");
resetXTermForeground();
resetXTermBackground();
setText ( "A terminal attributes test ("
+ FString(getTermType())
+ ")");
next_button = new FButton("&Next >", this);
next_button->setGeometry(getWidth()-13, getHeight()-4, 10, 1);
next_button->setShadow();
next_button->addAccelerator(fc::Fkey_right);
back_button = new FButton("< &Back", this);
back_button->setGeometry(getWidth()-25, getHeight()-4, 10, 1);
back_button->setShadow();
back_button->addAccelerator(fc::Fkey_left);
// Add function callbacks
next_button->addCallback
(
"clicked",
_METHOD_CALLBACK (this, &AttribDlg::cb_next)
);
back_button->addCallback
(
"clicked",
_METHOD_CALLBACK (this, &AttribDlg::cb_back)
);
}
//----------------------------------------------------------------------
@ -56,12 +96,37 @@ void AttribDlg::onClose (FCloseEvent* ev)
ev->ignore();
}
//----------------------------------------------------------------------
void AttribDlg::cb_next (FWidget*, void*)
{
if ( isMonochron() )
return;
bgcolor++;
if ( bgcolor >= getMaxColor() )
bgcolor = -1;
redraw();
}
//----------------------------------------------------------------------
void AttribDlg::cb_back (FWidget*, void*)
{
if ( isMonochron() )
return;
bgcolor--;
if ( bgcolor < -1 )
bgcolor = short(getMaxColor() - 1);
redraw();
}
//----------------------------------------------------------------------
void AttribDlg::adjustSize()
{
int h = parentWidget()->getHeight() - 2;
int x = ((parentWidget()->getWidth() - getWidth()) / 2 );
setGeometry(x, 2, 62, h, false);
int y = ((parentWidget()->getHeight() - getHeight()) / 2 ) + 1;
setGeometry(x, y, 69, 21, false);
next_button->setGeometry(getWidth()-13, getHeight()-4, 10, 1, false);
back_button->setGeometry(getWidth()-25, getHeight()-4, 10, 1, false);
FDialog::adjustSize();
}
@ -80,67 +145,84 @@ class AttribDemo : public FWidget
private:
void printColorLine();
void printAltCharset();
void draw();
public:
explicit AttribDemo (FWidget* parent = 0) // constructor
: FWidget(parent)
, colors(getMaxColor())
{
if ( isMonochron() )
colors = 1;
else if ( colors > 16 )
colors = 16;
}
explicit AttribDemo (FWidget* = 0); // constructor
~AttribDemo() // destructor
{ }
};
#pragma pack(pop)
//----------------------------------------------------------------------
AttribDemo::AttribDemo (FWidget* parent)
: FWidget(parent)
, colors(getMaxColor())
{
if ( isMonochron() )
colors = 1;
else if ( colors > 16 )
colors = 16;
unsetFocusable();
}
//----------------------------------------------------------------------
void AttribDemo::printColorLine()
{
int bg = getTermBackgroundColor();
for (int color=0; color < colors; color++)
AttribDlg* parent = static_cast<AttribDlg*>(getParent());
for (short color=0; color < colors; color++)
{
setColor(color, bg);
setColor (color, parent->bgcolor);
print (" # ");
}
}
//----------------------------------------------------------------------
void AttribDemo::printAltCharset()
{
AttribDlg* parent = static_cast<AttribDlg*>(getParent());
if ( ! isMonochron() )
setColor (wc.label_fg, wc.label_bg);
gotoxy (xpos + xmin - 1, ypos + ymin - 1);
print("alternate charset: ");
if ( parent->bgcolor == -1 )
{
setColor (-1,-1);
}
else
{
if ( parent->bgcolor == 0 || parent->bgcolor == 16 )
setColor (fc::White, parent->bgcolor);
else
setColor (fc::Black, parent->bgcolor);
}
setAltCharset();
print("`abcdefghijklmnopqrstuvwxyz{|}~");
unsetAltCharset();
print(" ");
}
//----------------------------------------------------------------------
void AttribDemo::draw()
{
setUpdateVTerm(false);
int color_loop = 0;
std::vector<int> background;
std::vector<int>::iterator iter;
background.push_back(fc::White);
background.push_back(fc::Black);
background.push_back(-1);
iter = background.begin();
while ( iter != background.end() )
{
for (int y=color_loop*7; y < parentWidget()->getHeight()-3; y++)
{
if ( *iter == -1 )
break;
else if ( *iter == fc::Black )
{
if ( colors < 16 )
setColor(fc::LightGray, fc::Black);
else
setColor(fc::White, fc::Black);
}
else
setColor(fc::Black, *iter);
// test alternate character set
printAltCharset();
for (int y=0; y < parentWidget()->getHeight()-7; y++)
{
gotoxy ( xpos + xmin - 1,
ypos + ymin - 1 + y );
ypos + ymin + y );
switch (y - (color_loop*7))
if ( ! isMonochron() )
setColor (wc.label_fg, wc.label_bg);
switch (y)
{
case 0:
print(" Dim: ");
@ -151,6 +233,7 @@ void AttribDemo::draw()
case 1:
print(" Normal: ");
setNormal();
printColorLine();
break;
@ -185,16 +268,63 @@ void AttribDemo::draw()
break;
case 6:
print(" Double underline: ");
setDoubleUnderline();
printColorLine();
unsetDoubleUnderline();
break;
case 7:
print(" Crossed-out: ");
setCrossedOut();
printColorLine();
unsetCrossedOut();
break;
case 8:
print(" Blink: ");
setBlink();
printColorLine();
unsetBlink();
break;
case 9:
print(" Reverse: ");
setReverse();
printColorLine();
unsetReverse();
break;
case 10:
print(" Standout: ");
setStandout();
printColorLine();
unsetStandout();
break;
case 11:
print(" Invisible: ");
setInvisible();
printColorLine();
unsetInvisible();
break;
case 12:
print(" Protected: ");
setProtected();
printColorLine();
unsetProtected();
break;
}
}
color_loop++;
++iter;
}
if ( ! isMonochron() )
setColor(wc.label_fg, wc.label_bg);
gotoxy (xpos + xmin - 1, ypos + ymin + 13);
printf ( " Background color: %d ",
static_cast<AttribDlg*>(getParent())->bgcolor );
gotoxy (xpos + xmin + 14, ypos + ymin + 15);
print ("Change background color ->");
setUpdateVTerm(true);
}
@ -212,13 +342,12 @@ int main (int argc, char* argv[])
// the parent object "app" (FObject destructor).
AttribDlg* dialog = new AttribDlg(&app);
dialog->setGeometry (6, 2, 62, 22);
dialog->setGeometry (6, 2, 69, 21);
dialog->addAccelerator('q'); // press 'q' to quit
dialog->setShadow();
AttribDemo* demo = new AttribDemo(dialog);
demo->ignorePadding(false);
demo->setGeometry (1,1,63,20);
demo->setGeometry (1,1,67,19);
app.setMainWidget(dialog);
dialog->show();

View File

@ -13,6 +13,7 @@ class timer : public FWidget
protected:
void onTimer (FTimerEvent*);
void onAccel (FAccelEvent*);
void draw();
};
//----------------------------------------------------------------------
@ -25,9 +26,10 @@ timer::timer (FWidget* parent)
delTimer (id);
addTimer (250); // 250-millisecond timer
setColor(fc::LightGray, fc::Black);
clrscr();
updateTerminal();
resetXTermForeground();
resetXTermBackground();
wc.term_fg = -1;
wc.term_bg = -1;
}
//----------------------------------------------------------------------
@ -43,6 +45,19 @@ void timer::onAccel (FAccelEvent* ev)
ev->accept();
}
//----------------------------------------------------------------------
void timer::draw()
{
setNormal();
setColor(-1,-1);
clrscr();
gotoxy (1,1);
print ("---------------\n");
print ("Press Q to quit\n");
print ("---------------\n");
setCursorPos (1,4);
}
//----------------------------------------------------------------------
// main part
@ -54,10 +69,5 @@ int main (int argc, char* argv[])
t.addAccelerator('q');
app.setMainWidget(&t);
t.show();
t.setTermXY(0,0);
t.flush_out();
::printf("---------------\n\r");
::printf("Press Q to quit\n\r");
::printf("---------------\n\r\n");
return app.exec();
}

View File

@ -564,7 +564,7 @@ void MyDialog::cb_about (FWidget*, void*)
FMessageBox info ( "About"
, line + L" The Final Cut " + line + "\n\n"
L"Version " + libver + "\n\n"
L"(c) 2015 by Markus Gans"
L"(c) 2016 by Markus Gans"
, FMessageBox::Ok, 0, 0, this );
info.setCenterText();
info.show();
@ -797,7 +797,7 @@ void MyDialog::adjustSize()
int main (int argc, char* argv[])
{
FString ver = F_VERSION; // library version
FString title = "The FINAL CUT " + ver + " (C) 2015 by Markus Gans";
FString title = "The FINAL CUT " + ver + " (C) 2016 by Markus Gans";
if ( argv[1] && ( strcmp(argv[1], "--help") == 0
|| strcmp(argv[1], "-h") == 0 ) )