example program to test video attributes
This commit is contained in:
parent
6b789b16a0
commit
4a697e7c9a
|
@ -29,6 +29,7 @@ test/string-operations
|
||||||
test/hello
|
test/hello
|
||||||
test/watch
|
test/watch
|
||||||
test/menu
|
test/menu
|
||||||
|
test/term-attributes
|
||||||
test/input-dialog
|
test/input-dialog
|
||||||
test/mandelbrot
|
test/mandelbrot
|
||||||
test/keyboard
|
test/keyboard
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
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
|
||||||
|
|
||||||
2015-12-20 Markus Gans <guru.mail@muenster.de>
|
2015-12-20 Markus Gans <guru.mail@muenster.de>
|
||||||
* Add the possibility to switch off the cursor optimization
|
* Add the possibility to switch off the cursor optimization
|
||||||
for bad ANSI-terminal implementations like HyperTerminal
|
for bad ANSI-terminal implementations like HyperTerminal
|
||||||
|
|
|
@ -13,6 +13,7 @@ noinst_PROGRAMS = \
|
||||||
mandelbrot \
|
mandelbrot \
|
||||||
calculator \
|
calculator \
|
||||||
watch \
|
watch \
|
||||||
|
term-attributes \
|
||||||
keyboard \
|
keyboard \
|
||||||
timer \
|
timer \
|
||||||
menu \
|
menu \
|
||||||
|
@ -25,7 +26,9 @@ string_operations_SOURCES = string-operations.cpp
|
||||||
mandelbrot_SOURCES = mandelbrot.cpp
|
mandelbrot_SOURCES = mandelbrot.cpp
|
||||||
calculator_SOURCES = calculator.cpp
|
calculator_SOURCES = calculator.cpp
|
||||||
watch_SOURCES = watch.cpp
|
watch_SOURCES = watch.cpp
|
||||||
|
term_attributes_SOURCES = term-attributes.cpp
|
||||||
keyboard_SOURCES = keyboard.cpp
|
keyboard_SOURCES = keyboard.cpp
|
||||||
timer_SOURCES = timer.cpp
|
timer_SOURCES = timer.cpp
|
||||||
menu_SOURCES = menu.cpp
|
menu_SOURCES = menu.cpp
|
||||||
ui_SOURCES = ui.cpp
|
ui_SOURCES = ui.cpp
|
||||||
|
|
||||||
|
|
|
@ -84,8 +84,8 @@ build_triplet = @build@
|
||||||
host_triplet = @host@
|
host_triplet = @host@
|
||||||
noinst_PROGRAMS = hello$(EXEEXT) dialog$(EXEEXT) input-dialog$(EXEEXT) \
|
noinst_PROGRAMS = hello$(EXEEXT) dialog$(EXEEXT) input-dialog$(EXEEXT) \
|
||||||
string-operations$(EXEEXT) mandelbrot$(EXEEXT) \
|
string-operations$(EXEEXT) mandelbrot$(EXEEXT) \
|
||||||
calculator$(EXEEXT) watch$(EXEEXT) keyboard$(EXEEXT) \
|
calculator$(EXEEXT) watch$(EXEEXT) term-attributes$(EXEEXT) \
|
||||||
timer$(EXEEXT) menu$(EXEEXT) ui$(EXEEXT)
|
keyboard$(EXEEXT) timer$(EXEEXT) menu$(EXEEXT) ui$(EXEEXT)
|
||||||
subdir = test
|
subdir = test
|
||||||
DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
|
DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
|
||||||
$(top_srcdir)/depcomp
|
$(top_srcdir)/depcomp
|
||||||
|
@ -129,6 +129,9 @@ menu_LDADD = $(LDADD)
|
||||||
am_string_operations_OBJECTS = string-operations.$(OBJEXT)
|
am_string_operations_OBJECTS = string-operations.$(OBJEXT)
|
||||||
string_operations_OBJECTS = $(am_string_operations_OBJECTS)
|
string_operations_OBJECTS = $(am_string_operations_OBJECTS)
|
||||||
string_operations_LDADD = $(LDADD)
|
string_operations_LDADD = $(LDADD)
|
||||||
|
am_term_attributes_OBJECTS = term-attributes.$(OBJEXT)
|
||||||
|
term_attributes_OBJECTS = $(am_term_attributes_OBJECTS)
|
||||||
|
term_attributes_LDADD = $(LDADD)
|
||||||
am_timer_OBJECTS = timer.$(OBJEXT)
|
am_timer_OBJECTS = timer.$(OBJEXT)
|
||||||
timer_OBJECTS = $(am_timer_OBJECTS)
|
timer_OBJECTS = $(am_timer_OBJECTS)
|
||||||
timer_LDADD = $(LDADD)
|
timer_LDADD = $(LDADD)
|
||||||
|
@ -175,13 +178,13 @@ am__v_CXXLD_1 =
|
||||||
SOURCES = $(calculator_SOURCES) $(dialog_SOURCES) $(hello_SOURCES) \
|
SOURCES = $(calculator_SOURCES) $(dialog_SOURCES) $(hello_SOURCES) \
|
||||||
$(input_dialog_SOURCES) $(keyboard_SOURCES) \
|
$(input_dialog_SOURCES) $(keyboard_SOURCES) \
|
||||||
$(mandelbrot_SOURCES) $(menu_SOURCES) \
|
$(mandelbrot_SOURCES) $(menu_SOURCES) \
|
||||||
$(string_operations_SOURCES) $(timer_SOURCES) $(ui_SOURCES) \
|
$(string_operations_SOURCES) $(term_attributes_SOURCES) \
|
||||||
$(watch_SOURCES)
|
$(timer_SOURCES) $(ui_SOURCES) $(watch_SOURCES)
|
||||||
DIST_SOURCES = $(calculator_SOURCES) $(dialog_SOURCES) \
|
DIST_SOURCES = $(calculator_SOURCES) $(dialog_SOURCES) \
|
||||||
$(hello_SOURCES) $(input_dialog_SOURCES) $(keyboard_SOURCES) \
|
$(hello_SOURCES) $(input_dialog_SOURCES) $(keyboard_SOURCES) \
|
||||||
$(mandelbrot_SOURCES) $(menu_SOURCES) \
|
$(mandelbrot_SOURCES) $(menu_SOURCES) \
|
||||||
$(string_operations_SOURCES) $(timer_SOURCES) $(ui_SOURCES) \
|
$(string_operations_SOURCES) $(term_attributes_SOURCES) \
|
||||||
$(watch_SOURCES)
|
$(timer_SOURCES) $(ui_SOURCES) $(watch_SOURCES)
|
||||||
am__can_run_installinfo = \
|
am__can_run_installinfo = \
|
||||||
case $$AM_UPDATE_INFO_DIR in \
|
case $$AM_UPDATE_INFO_DIR in \
|
||||||
n|no|NO) false;; \
|
n|no|NO) false;; \
|
||||||
|
@ -337,6 +340,7 @@ string_operations_SOURCES = string-operations.cpp
|
||||||
mandelbrot_SOURCES = mandelbrot.cpp
|
mandelbrot_SOURCES = mandelbrot.cpp
|
||||||
calculator_SOURCES = calculator.cpp
|
calculator_SOURCES = calculator.cpp
|
||||||
watch_SOURCES = watch.cpp
|
watch_SOURCES = watch.cpp
|
||||||
|
term_attributes_SOURCES = term-attributes.cpp
|
||||||
keyboard_SOURCES = keyboard.cpp
|
keyboard_SOURCES = keyboard.cpp
|
||||||
timer_SOURCES = timer.cpp
|
timer_SOURCES = timer.cpp
|
||||||
menu_SOURCES = menu.cpp
|
menu_SOURCES = menu.cpp
|
||||||
|
@ -417,6 +421,10 @@ string-operations$(EXEEXT): $(string_operations_OBJECTS) $(string_operations_DEP
|
||||||
@rm -f string-operations$(EXEEXT)
|
@rm -f string-operations$(EXEEXT)
|
||||||
$(AM_V_CXXLD)$(CXXLINK) $(string_operations_OBJECTS) $(string_operations_LDADD) $(LIBS)
|
$(AM_V_CXXLD)$(CXXLINK) $(string_operations_OBJECTS) $(string_operations_LDADD) $(LIBS)
|
||||||
|
|
||||||
|
term-attributes$(EXEEXT): $(term_attributes_OBJECTS) $(term_attributes_DEPENDENCIES) $(EXTRA_term_attributes_DEPENDENCIES)
|
||||||
|
@rm -f term-attributes$(EXEEXT)
|
||||||
|
$(AM_V_CXXLD)$(CXXLINK) $(term_attributes_OBJECTS) $(term_attributes_LDADD) $(LIBS)
|
||||||
|
|
||||||
timer$(EXEEXT): $(timer_OBJECTS) $(timer_DEPENDENCIES) $(EXTRA_timer_DEPENDENCIES)
|
timer$(EXEEXT): $(timer_OBJECTS) $(timer_DEPENDENCIES) $(EXTRA_timer_DEPENDENCIES)
|
||||||
@rm -f timer$(EXEEXT)
|
@rm -f timer$(EXEEXT)
|
||||||
$(AM_V_CXXLD)$(CXXLINK) $(timer_OBJECTS) $(timer_LDADD) $(LIBS)
|
$(AM_V_CXXLD)$(CXXLINK) $(timer_OBJECTS) $(timer_LDADD) $(LIBS)
|
||||||
|
@ -443,6 +451,7 @@ distclean-compile:
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mandelbrot.Po@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mandelbrot.Po@am__quote@
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/menu.Po@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/menu.Po@am__quote@
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/string-operations.Po@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/string-operations.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/term-attributes.Po@am__quote@
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/timer.Po@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/timer.Po@am__quote@
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ui.Po@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ui.Po@am__quote@
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/watch.Po@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/watch.Po@am__quote@
|
||||||
|
|
|
@ -0,0 +1,227 @@
|
||||||
|
// File: term-attributes.cpp
|
||||||
|
|
||||||
|
#include "fapp.h"
|
||||||
|
#include "fdialog.h"
|
||||||
|
#include "fmessagebox.h"
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
// class AttribDlg
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
|
||||||
|
#pragma pack(push)
|
||||||
|
#pragma pack(1)
|
||||||
|
|
||||||
|
class AttribDlg : public FDialog
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
void adjustSize();
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit AttribDlg (FWidget* = 0); // constructor
|
||||||
|
~AttribDlg(); // destructor
|
||||||
|
void onAccel (FAccelEvent*);
|
||||||
|
void onClose (FCloseEvent*);
|
||||||
|
};
|
||||||
|
#pragma pack(pop)
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
AttribDlg::AttribDlg (FWidget* parent)
|
||||||
|
: FDialog(parent)
|
||||||
|
{
|
||||||
|
setText ("A terminal attributes test");
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
AttribDlg::~AttribDlg()
|
||||||
|
{ }
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
void AttribDlg::onAccel (FAccelEvent* ev)
|
||||||
|
{
|
||||||
|
close();
|
||||||
|
ev->accept();
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
void AttribDlg::onClose (FCloseEvent* ev)
|
||||||
|
{
|
||||||
|
int ret = FMessageBox::info ( this, "Quit"
|
||||||
|
, "Do you really want\n"
|
||||||
|
"to quit the program ?"
|
||||||
|
, FMessageBox::Yes
|
||||||
|
, FMessageBox::No );
|
||||||
|
if ( ret == FMessageBox::Yes )
|
||||||
|
ev->accept();
|
||||||
|
else
|
||||||
|
ev->ignore();
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
void AttribDlg::adjustSize()
|
||||||
|
{
|
||||||
|
int h = parentWidget()->getHeight() - 2;
|
||||||
|
int x = ((parentWidget()->getWidth() - getWidth()) / 2 );
|
||||||
|
setGeometry(x, 2, 62, h, false);
|
||||||
|
FDialog::adjustSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
// class AttribDemo
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
|
||||||
|
#pragma pack(push)
|
||||||
|
#pragma pack(1)
|
||||||
|
|
||||||
|
class AttribDemo : public FWidget
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
int colors;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void printColorLine();
|
||||||
|
void draw();
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit AttribDemo (FWidget* parent = 0) // constructor
|
||||||
|
: FWidget(parent)
|
||||||
|
, colors(getMaxColor())
|
||||||
|
{
|
||||||
|
if ( isMonochron() )
|
||||||
|
colors = 1;
|
||||||
|
else if ( colors > 16 )
|
||||||
|
colors = 16;
|
||||||
|
}
|
||||||
|
|
||||||
|
~AttribDemo() // destructor
|
||||||
|
{ }
|
||||||
|
};
|
||||||
|
#pragma pack(pop)
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
void AttribDemo::printColorLine()
|
||||||
|
{
|
||||||
|
int bg = getTermBackgroundColor();
|
||||||
|
for (int color=0; color < colors; color++)
|
||||||
|
{
|
||||||
|
setColor(color, bg);
|
||||||
|
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);
|
||||||
|
|
||||||
|
gotoxy ( xpos + xmin - 1,
|
||||||
|
ypos + ymin - 1 + y );
|
||||||
|
|
||||||
|
switch (y - (color_loop*7))
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
print(" Dim: ");
|
||||||
|
setDim();
|
||||||
|
printColorLine();
|
||||||
|
unsetDim();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
print(" Normal: ");
|
||||||
|
printColorLine();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 2:
|
||||||
|
print(" Bold: ");
|
||||||
|
setBold();
|
||||||
|
printColorLine();
|
||||||
|
unsetBold();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 3:
|
||||||
|
print(" Bold+Dim: ");
|
||||||
|
setBold();
|
||||||
|
setDim();
|
||||||
|
printColorLine();
|
||||||
|
unsetDim();
|
||||||
|
unsetBold();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 4:
|
||||||
|
print(" Italic: ");
|
||||||
|
setItalic();
|
||||||
|
printColorLine();
|
||||||
|
unsetItalic();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 5:
|
||||||
|
print(" Underline: ");
|
||||||
|
setUnderline();
|
||||||
|
printColorLine();
|
||||||
|
unsetUnderline();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 6:
|
||||||
|
print(" Reverse: ");
|
||||||
|
setReverse();
|
||||||
|
printColorLine();
|
||||||
|
unsetReverse();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
color_loop++;
|
||||||
|
++iter;
|
||||||
|
}
|
||||||
|
|
||||||
|
setUpdateVTerm(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
// main part
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
int main (int argc, char* argv[])
|
||||||
|
{
|
||||||
|
// Create the application object
|
||||||
|
FApplication app (argc, argv);
|
||||||
|
|
||||||
|
// Create a dialog box object.
|
||||||
|
// This object will be automatically deleted by
|
||||||
|
// the parent object "app" (FObject destructor).
|
||||||
|
AttribDlg* dialog = new AttribDlg(&app);
|
||||||
|
|
||||||
|
dialog->setGeometry (6, 2, 62, 22);
|
||||||
|
dialog->addAccelerator('q'); // press 'q' to quit
|
||||||
|
dialog->setShadow();
|
||||||
|
|
||||||
|
AttribDemo* demo = new AttribDemo(dialog);
|
||||||
|
demo->ignorePadding(false);
|
||||||
|
demo->setGeometry (1,1,63,20);
|
||||||
|
|
||||||
|
app.setMainWidget(dialog);
|
||||||
|
dialog->show();
|
||||||
|
|
||||||
|
return app.exec();
|
||||||
|
}
|
Loading…
Reference in New Issue