compiles now under FreeBSD

This commit is contained in:
Markus Gans 2017-03-26 20:40:04 +02:00
parent ef5ca7d5f8
commit 48b2e6a816
37 changed files with 881 additions and 403 deletions

1
.gitignore vendored
View File

@ -27,6 +27,7 @@ test/calculator
test/dialog
test/string-operations
test/opti-move
test/termcap
test/hello
test/watch
test/menu

View File

@ -1,3 +1,7 @@
2017-03-26 Markus Gans <guru.mail@muenster.de>
* The Final Cut compiles now under FreeBSD
* A new test program to show the termcap variables
2017-03-19 Markus Gans <guru.mail@muenster.de>
* Add the "mouse" example to illustrate mouse programming

View File

@ -341,6 +341,7 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@

14
configure vendored
View File

@ -735,6 +735,7 @@ infodir
docdir
oldincludedir
includedir
runstatedir
localstatedir
sharedstatedir
sysconfdir
@ -820,6 +821,7 @@ datadir='${datarootdir}'
sysconfdir='${prefix}/etc'
sharedstatedir='${prefix}/com'
localstatedir='${prefix}/var'
runstatedir='${localstatedir}/run'
includedir='${prefix}/include'
oldincludedir='/usr/include'
docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
@ -1072,6 +1074,15 @@ do
| -silent | --silent | --silen | --sile | --sil)
silent=yes ;;
-runstatedir | --runstatedir | --runstatedi | --runstated \
| --runstate | --runstat | --runsta | --runst | --runs \
| --run | --ru | --r)
ac_prev=runstatedir ;;
-runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
| --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
| --run=* | --ru=* | --r=*)
runstatedir=$ac_optarg ;;
-sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
ac_prev=sbindir ;;
-sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
@ -1209,7 +1220,7 @@ fi
for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
datadir sysconfdir sharedstatedir localstatedir includedir \
oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
libdir localedir mandir
libdir localedir mandir runstatedir
do
eval ac_val=\$$ac_var
# Remove trailing slashes.
@ -1362,6 +1373,7 @@ Fine tuning of the installation directories:
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
--runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run]
--libdir=DIR object code libraries [EPREFIX/lib]
--includedir=DIR C header files [PREFIX/include]
--oldincludedir=DIR C header files for non-gcc [/usr/include]

View File

@ -258,6 +258,7 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@

View File

@ -362,6 +362,7 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@

View File

@ -33,8 +33,10 @@ FApplication::eventQueue* FApplication::event_queue = 0;
// constructors and destructor
//----------------------------------------------------------------------
FApplication::FApplication (int& _argc, char* _argv[])
: FWidget(0)
FApplication::FApplication ( int& _argc
, char* _argv[]
, bool disable_alt_screen )
: FWidget(0, disable_alt_screen)
, app_argc(_argc)
, app_argv(_argv)
, key(0)
@ -323,10 +325,10 @@ void FApplication::init()
void FApplication::setExitMessage (std::string message)
{
quit_now = true;
std::snprintf ( FTerm::exit_message
, sizeof(FTerm::exit_message)
, "%s"
, message.c_str() );
snprintf ( FTerm::exit_message
, sizeof(FTerm::exit_message)
, "%s"
, message.c_str() );
}
//----------------------------------------------------------------------
@ -548,7 +550,10 @@ void FApplication::processKeyboardEvent()
if ( key != NEED_MORE_DATA )
{
#if defined(__linux__)
key = modifierKeyCorrection (key);
#endif
switch ( key )
{
@ -704,6 +709,7 @@ void FApplication::processKeyboardEvent()
}
}
#if defined(__linux__)
//----------------------------------------------------------------------
int FApplication::modifierKeyCorrection (int& key_id)
{
@ -983,6 +989,7 @@ int FApplication::modifierKeyCorrection (int& key_id)
return key_id;
}
#endif
//----------------------------------------------------------------------
bool FApplication::processDialogSwitchAccelerator()

View File

@ -55,7 +55,7 @@ class FApplication : public FWidget
{
public:
// Constructor
FApplication (int&, char*[]);
FApplication (int&, char*[], bool = false);
// Destructor
virtual ~FApplication();
@ -129,7 +129,9 @@ class FApplication : public FWidget
bool KeyPressed();
ssize_t readKey();
void processKeyboardEvent();
#if defined(__linux__)
int modifierKeyCorrection (int& key);
#endif
bool processDialogSwitchAccelerator();
bool processAccelerator (FWidget*&);
void getX11ButtonState (int);

View File

@ -163,8 +163,8 @@ bool FButton::setFocus (bool on)
{
if ( getStatusBar() )
{
const FString msg = getStatusbarMessage();
const FString curMsg = getStatusBar()->getMessage();
const FString& msg = getStatusbarMessage();
const FString& curMsg = getStatusBar()->getMessage();
if ( curMsg != msg )
getStatusBar()->setMessage(msg);
@ -734,8 +734,8 @@ void FButton::draw()
if ( is_Focus && getStatusBar() )
{
const FString msg = getStatusbarMessage();
const FString curMsg = getStatusBar()->getMessage();
const FString& msg = getStatusbarMessage();
const FString& curMsg = getStatusBar()->getMessage();
if ( curMsg != msg )
{

View File

@ -368,7 +368,7 @@ const FString FFileDialog::fileOpenChooser ( FWidget* parent
{
path = getHomeDir();
if ( path.isEmpty() || path.isEmpty() )
if ( path.isNull() || path.isEmpty() )
path = FString("/");
}
@ -403,7 +403,7 @@ const FString FFileDialog::fileSaveChooser ( FWidget* parent
{
path = getHomeDir();
if ( path.isEmpty() || path.isEmpty() )
if ( path.isNull() || path.isEmpty() )
path = FString("/");
}

View File

@ -108,8 +108,8 @@ bool FLineEdit::setFocus (bool on)
if ( getStatusBar() )
{
const FString msg = getStatusbarMessage();
const FString curMsg = getStatusBar()->getMessage();
const FString& msg = getStatusbarMessage();
const FString& curMsg = getStatusBar()->getMessage();
if ( curMsg != msg )
getStatusBar()->setMessage(msg);
@ -153,7 +153,7 @@ bool FLineEdit::setShadow (bool on)
}
//----------------------------------------------------------------------
void FLineEdit::setText (const FString txt)
void FLineEdit::setText (const FString& txt)
{
text_offset = 0;
cursor_pos = 0;
@ -165,7 +165,7 @@ void FLineEdit::setText (const FString txt)
}
//----------------------------------------------------------------------
void FLineEdit::setLabelText (const FString ltxt)
void FLineEdit::setLabelText (const FString& ltxt)
{
label_text = ltxt;
label->setText(label_text);
@ -734,8 +734,8 @@ void FLineEdit::draw()
if ( isFocus && getStatusBar() )
{
const FString msg = getStatusbarMessage();
const FString curMsg = getStatusBar()->getMessage();
const FString& msg = getStatusbarMessage();
const FString& curMsg = getStatusBar()->getMessage();
if ( curMsg != msg )
{

View File

@ -62,8 +62,8 @@ class FLineEdit : public FWidget
int getLabelOrientation();
// Mutators
void setText (const FString);
void setLabelText (const FString);
void setText (const FString&);
void setLabelText (const FString&);
void setLabelOrientation(const label_o);
bool setEnable(bool);
bool setEnable();

View File

@ -195,8 +195,8 @@ bool FListBox::setFocus (bool on)
if ( getStatusBar() )
{
const FString msg = getStatusbarMessage();
const FString curMsg = getStatusBar()->getMessage();
const FString& msg = getStatusbarMessage();
const FString& curMsg = getStatusBar()->getMessage();
if ( curMsg != msg )
getStatusBar()->setMessage(msg);
@ -214,7 +214,7 @@ bool FListBox::setFocus (bool on)
}
//----------------------------------------------------------------------
void FListBox::setText (const FString txt)
void FListBox::setText (const FString& txt)
{
text = txt;
}
@ -261,7 +261,7 @@ void FListBox::hide()
}
//----------------------------------------------------------------------
void FListBox::insert ( const FString item
void FListBox::insert ( const FString& item
, fc::brackets_type b
, bool s
, data_ptr d )

View File

@ -139,7 +139,7 @@ class FListBox : public FWidget
bool setFocus (bool);
bool setFocus();
bool unsetFocus();
void setText (const FString);
void setText (const FString&);
// Inquiries
bool isSelected (int) const;
@ -148,7 +148,7 @@ class FListBox : public FWidget
// Methods
void hide();
void insert ( const FString
void insert ( const FString&
, fc::brackets_type = fc::NoBrackets
, bool = false
, data_ptr = 0);

View File

@ -64,7 +64,7 @@ bool FMenu::setMenuWidget (bool on)
}
//----------------------------------------------------------------------
void FMenu::setStatusbarMessage (const FString msg)
void FMenu::setStatusbarMessage (const FString& msg)
{
FWidget::setStatusbarMessage(msg);
@ -622,8 +622,8 @@ void FMenu::onMouseMove (FMouseEvent* ev)
// Mouse is over border or separator
if ( getStatusBar() )
{
const FString msg = getStatusbarMessage();
const FString curMsg = getStatusBar()->getMessage();
const FString& msg = getStatusbarMessage();
const FString& curMsg = getStatusBar()->getMessage();
if ( curMsg != msg )
{

View File

@ -73,7 +73,7 @@ class FMenu : public FWindow, public FMenuList
bool setMenuWidget (bool);
bool setMenuWidget();
bool unsetMenuWidget();
void setStatusbarMessage (const FString);
void setStatusbarMessage (const FString&);
void setMenu (FMenu*);
void setText (const FString&);

View File

@ -158,8 +158,8 @@ bool FMenuItem::setFocus (bool on)
if ( getStatusBar() )
{
const FString msg = getStatusbarMessage();
const FString curMsg = getStatusBar()->getMessage();
const FString& msg = getStatusbarMessage();
const FString& curMsg = getStatusBar()->getMessage();
if ( curMsg != msg )
getStatusBar()->setMessage(msg);
@ -754,7 +754,7 @@ void FMenuItem::createDialogList (FMenu* winmenu)
{
int n = int(std::distance(begin, iter));
// get the dialog title
const FString name = win->getText();
const FString& name = win->getText();
// create a new dialog list item
FMenuItem* win_item = new FMenuItem (name, winmenu);

View File

@ -212,7 +212,7 @@ int FMessageBox::error ( FWidget* parent
, int button2 )
{
int reply;
const FString caption = "Error message";
const FString& caption = "Error message";
FMessageBox* mbox = new FMessageBox ( caption, message
, button0, button1, button2
, parent );

View File

@ -228,6 +228,7 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@

View File

@ -383,7 +383,6 @@ void FScrollView::draw()
void FScrollView::onKeyPress (FKeyEvent* ev)
{
int key = ev->key();
bool hasChanges = false;
short& xoffset = viewport_geometry.x1_ref();
short& yoffset = viewport_geometry.y1_ref();
short xoffset_before = xoffset;
@ -457,6 +456,8 @@ void FScrollView::onKeyPress (FKeyEvent* ev)
if ( ev->isAccepted() )
{
bool hasChanges = false;
if ( isVisible() && viewport
&& (xoffset_before != xoffset || yoffset_before != yoffset) )
{
@ -690,8 +691,6 @@ void FScrollView::copy2area()
// copy viewport to area
int ax, ay, dx, dy, y_end, x_end;
char_data* vc; // viewport character
char_data* ac; // area character
if ( ! hasPrintArea() )
FVTerm::getPrintArea();
@ -711,6 +710,8 @@ void FScrollView::copy2area()
for (int y=0; y < y_end; y++) // line loop
{
char_data* vc; // viewport character
char_data* ac; // area character
int v_line_len = viewport->width;
int a_line_len = print_area->width + print_area->right_shadow;
vc = &viewport->text[(dy+y) * v_line_len + dx];
@ -734,15 +735,16 @@ void FScrollView::copy2area()
//----------------------------------------------------------------------
inline FPoint FScrollView::getViewportCursorPos()
{
int x, y;
FWidget* window = FWindow::getWindowWidget(this);
if ( window )
{
int widget_offsetX = getTermX() - window->getTermX();
int widget_offsetY = getTermY() - window->getTermY();
x = widget_offsetX + viewport->input_cursor_x - viewport_geometry.getX();
y = widget_offsetY + viewport->input_cursor_y - viewport_geometry.getY();
int x = widget_offsetX + viewport->input_cursor_x
- viewport_geometry.getX();
int y = widget_offsetY + viewport->input_cursor_y
- viewport_geometry.getY();
return FPoint(x,y);
}
else

View File

@ -517,14 +517,14 @@ FString& FString::sprintf (const char* format, ...)
buffer = buf;
va_start (args, format);
len = std::vsnprintf (buffer, sizeof(buf), format, args);
len = vsnprintf (buffer, sizeof(buf), format, args);
va_end (args);
if ( len >= int(sizeof(buf)) )
{
buffer = new char[len+1]();
va_start (args, format);
std::vsnprintf (buffer, uLong(len+1), format, args);
vsnprintf (buffer, uLong(len+1), format, args);
va_end (args);
}
@ -1999,20 +1999,24 @@ FString FString::replaceControlCodes() const
}
//----------------------------------------------------------------------
FString FString::expandTabs (uInt tabstop) const
FString FString::expandTabs (int tabstop) const
{
uLong last;
std::vector<FString> tab_split;
FString instr(string);
FString outstr;
if ( tabstop <= 0 )
return instr;
tab_split = instr.split("\t");
last = tab_split.size();
for (uInt i=0; i < last; i++)
{
uInt len = tab_split[i].getLength();
outstr += tab_split[i] + FString(tabstop - len % tabstop, L' ');
uInt tab_len = uInt(tabstop);
outstr += tab_split[i] + FString(tab_len - (len % tab_len), L' ');
}
return outstr;

View File

@ -306,7 +306,7 @@ class FString
FString replace (const char, const char);
FString replaceControlCodes() const;
FString expandTabs (uInt = 8) const;
FString expandTabs (int = 8) const;
FString removeDel() const;
FString removeBackspaces() const;

File diff suppressed because it is too large Load Diff

View File

@ -33,12 +33,14 @@
#include <gpm.h>
#endif
#include <linux/fb.h> // Linux framebuffer console
#include <linux/keyboard.h> // need for gpm keyboard modifiers
#if defined(__linux__)
#include <linux/fb.h> // Linux framebuffer console
#include <linux/keyboard.h> // need for gpm keyboard modifiers
#include <sys/io.h> // <asm/io.h> is deprecated, use <sys/io.h> instead
#include <sys/kd.h>
#endif
#include <sys/io.h> // <asm/io.h> is deprecated, use <sys/io.h> instead
#include <sys/ioctl.h>
#include <sys/kd.h>
#include <sys/stat.h>
#include <fcntl.h>
@ -99,7 +101,7 @@ class FTerm
} mod_key;
// Constructor
FTerm ();
FTerm (bool = false);
// Destructor
virtual ~FTerm();
@ -110,13 +112,20 @@ class FTerm
static int getLineNumber();
static int getColumnNumber();
static const FString getKeyName (int);
#if defined(__linux__)
static modifier_key& getModifierKey();
#endif
static char* getTermType();
static char* getTermName();
static uInt getTabstop();
static int getTabstop();
static int getMaxColor();
static fc::consoleCursorStyle getConsoleCursor();
#if DEBUG
static const FString& getAnswerbackString();
static const FString& getSecDAString();
#endif
// Inquiries
static bool isKeyTimeout (timeval*, register long);
static bool isNormal (char_data*&);
@ -156,6 +165,7 @@ class FTerm
static bool setRawMode();
static bool unsetRawMode();
static bool setCookedMode();
static void disableAltScreen();
static bool setUTF8 (bool);
static bool setUTF8();
static bool unsetUTF8();
@ -227,9 +237,17 @@ class FTerm
static int putchar_UTF8 (register int);
static int UTF8decode (const char[]);
#if DEBUG
static char termtype_256color[30];
static char termtype_Answerback[30];
static char termtype_SecDA[30];
#endif
protected:
// Methods
#if defined(__linux__)
static void init_consoleCharMap();
#endif
static bool charEncodable (uInt);
static uInt charEncode (uInt);
static uInt charEncode (uInt, fc::encoding);
@ -265,6 +283,7 @@ class FTerm
static bool no_half_block_character;
static bool cursor_optimisation;
static bool xterm_default_colors;
static bool use_alternate_screen;
static fc::encoding Encoding;
static char exit_message[8192];
@ -287,6 +306,7 @@ class FTerm
// Disable assignment operator (=)
FTerm& operator = (const FTerm&);
#if defined(__linux__)
// Inquiries
static int isConsole();
@ -298,16 +318,19 @@ class FTerm
static void setAttributeMode (uChar);
static int setBlinkAsIntensity (bool);
static int getFramebuffer_bpp();
#endif
static int openConsole();
static int closeConsole();
static void identifyTermType();
static void storeTTYsettings();
static void restoreTTYsettings();
#if defined(__linux__)
static int getScreenFont();
static int setScreenFont (uChar*, uInt, uInt, uInt, bool = false);
static int setUnicodeMap (struct unimapdesc*);
static int getUnicodeMap ();
static void init_console();
#endif
static uInt getBaudRate (const struct termios*);
static char* init_256colorTerminal();
static char* parseAnswerbackMsg (char*&);
@ -406,13 +429,23 @@ inline char* FTerm::getTermName()
{ return term_name; }
//----------------------------------------------------------------------
inline uInt FTerm::getTabstop()
inline int FTerm::getTabstop()
{ return FTermcap::tabstop; }
//----------------------------------------------------------------------
inline int FTerm::getMaxColor()
{ return FTermcap::max_color; }
#if DEBUG
//----------------------------------------------------------------------
inline const FString& FTerm::getAnswerbackString()
{ return *answer_back; }
//----------------------------------------------------------------------
inline const FString& FTerm::getSecDAString()
{ return *sec_da; }
#endif
//----------------------------------------------------------------------
inline bool FTerm::isRaw()
{ return raw_mode; }
@ -533,6 +566,10 @@ inline bool FTerm::unsetRawMode()
inline bool FTerm::setCookedMode()
{ return setRawMode(false); }
//----------------------------------------------------------------------
inline void FTerm::disableAltScreen()
{ use_alternate_screen = false; }
//----------------------------------------------------------------------
inline bool FTerm::setUTF8()
{ return setUTF8(true); }

View File

@ -38,13 +38,13 @@ class FTermcap
{ }
// Accessor
tcap_map* getTermcapMap()
static tcap_map* getTermcapMap()
{
return tcap;
}
// Mutator
void setTermcapMap (tcap_map* t)
static void setTermcapMap (tcap_map* t)
{
tcap = t;
}
@ -58,8 +58,8 @@ class FTermcap
static bool osc_support;
static bool no_utf8_acs_chars;
static int max_color;
static uInt tabstop;
static uInt attr_without_color;
static int tabstop;
static int attr_without_color;
private:
// Data Members

View File

@ -670,8 +670,8 @@ void FTextView::draw()
if ( hasFocus() && getStatusBar() )
{
const FString msg = getStatusbarMessage();
const FString curMsg = getStatusBar()->getMessage();
const FString& msg = getStatusbarMessage();
const FString& curMsg = getStatusBar()->getMessage();
if ( curMsg != msg )
{

View File

@ -146,8 +146,8 @@ bool FToggleButton::setFocus (bool on)
if ( getStatusBar() )
{
const FString msg = getStatusbarMessage();
const FString curMsg = getStatusBar()->getMessage();
const FString& msg = getStatusbarMessage();
const FString& curMsg = getStatusBar()->getMessage();
if ( curMsg != msg )
getStatusBar()->setMessage(msg);
@ -184,7 +184,7 @@ bool FToggleButton::setChecked (bool on)
}
//----------------------------------------------------------------------
void FToggleButton::setText (const FString txt)
void FToggleButton::setText (const FString& txt)
{
text = txt;
setWidth(button_width + int(text.getLength()));
@ -456,8 +456,8 @@ void FToggleButton::draw()
if ( isFocus && getStatusBar() )
{
const FString msg = getStatusbarMessage();
const FString curMsg = getStatusBar()->getMessage();
const FString& msg = getStatusbarMessage();
const FString& curMsg = getStatusBar()->getMessage();
if ( curMsg != msg )
{

View File

@ -73,7 +73,7 @@ class FToggleButton : public FWidget
bool setChecked (bool);
bool setChecked();
bool unsetChecked();
virtual void setText (const FString);
virtual void setText (const FString&);
// Inquiries
bool isChecked();

View File

@ -33,8 +33,9 @@ FVTerm::char_data FVTerm::next_attribute;
// constructors and destructor
//----------------------------------------------------------------------
FVTerm::FVTerm (FVTerm* parent)
FVTerm::FVTerm (FVTerm* parent, bool disable_alt_screen)
: FObject(parent)
, FTerm(disable_alt_screen)
, print_area(0)
, child_print_area(0)
, vwin(0)
@ -304,14 +305,14 @@ int FVTerm::printf (const char* format, ...)
buffer = buf;
va_start (args, format);
len = std::vsnprintf (buffer, sizeof(buf), format, args);
len = vsnprintf (buffer, sizeof(buf), format, args);
va_end (args);
if ( len >= int(sizeof(buf)) )
{
buffer = new char[len+1]();
va_start (args, format);
std::vsnprintf (buffer, uLong(len+1), format, args);
vsnprintf (buffer, uLong(len+1), format, args);
va_end (args);
}
@ -409,7 +410,7 @@ int FVTerm::print (term_area* area, const FString& s)
assert ( ! s.isNull() );
register int len = 0;
const wchar_t* p;
uInt tabstop = getTabstop();
uInt tabstop = uInt(getTabstop());
if ( ! area )
return -1;
@ -2102,7 +2103,10 @@ void FVTerm::finish()
// Clear the terminal
setNormal();
clearTerm();
if ( use_alternate_screen )
clearTerm();
flush_out();
if ( output_buffer )

View File

@ -126,7 +126,7 @@ class FVTerm : public FObject, public FTerm
};
// Constructor
explicit FVTerm (FVTerm* = 0);
explicit FVTerm (FVTerm* = 0, bool = false);
// Destructor
~FVTerm();

View File

@ -32,8 +32,8 @@ bool FWidget::hideable;
// constructors and destructor
//----------------------------------------------------------------------
FWidget::FWidget (FWidget* parent)
: FVTerm(parent)
FWidget::FWidget (FWidget* parent, bool disable_alt_screen)
: FVTerm(parent, disable_alt_screen)
, accelerator_list(0)
, flags(0)
, callback_objects()
@ -301,7 +301,7 @@ void FWidget::setOpenMenu (FWidget* obj)
}
//----------------------------------------------------------------------
void FWidget::setStatusbarMessage (const FString msg)
void FWidget::setStatusbarMessage (const FString& msg)
{
statusbar_message = msg;
}
@ -874,7 +874,7 @@ bool FWidget::close()
}
//----------------------------------------------------------------------
void FWidget::addCallback ( const FString cb_signal
void FWidget::addCallback ( const FString& cb_signal
, FCallback cb_handler
, data_ptr data )
{
@ -884,7 +884,7 @@ void FWidget::addCallback ( const FString cb_signal
}
//----------------------------------------------------------------------
void FWidget::addCallback ( const FString cb_signal
void FWidget::addCallback ( const FString& cb_signal
, FWidget* cb_instance
, FMemberCallback cb_handler
, data_ptr data )
@ -946,7 +946,7 @@ inline void FWidget::delCallbacks()
}
//----------------------------------------------------------------------
void FWidget::emitCallback (const FString emit_signal)
void FWidget::emitCallback (const FString& emit_signal)
{
// member function pointer
if ( ! member_callback_objects.empty() )
@ -1157,9 +1157,11 @@ void FWidget::show()
if ( ! init_desktop )
{
#if defined(__linux__)
// Important: Do not use setNewFont() or setVGAFont() after
// the console character mapping has been initialized
init_consoleCharMap();
#endif
// set xterm underline cursor
setXTermCursorStyle(fc::blinking_underline);

View File

@ -113,7 +113,7 @@ class FWidget : public FVTerm
typedef std::vector<accelerator> Accelerators;
// Constructor
explicit FWidget (FWidget* = 0);
explicit FWidget (FWidget* = 0, bool = false);
// Destructor
~FWidget();
@ -166,7 +166,7 @@ class FWidget : public FVTerm
static void setClickedWidget (FWidget*);
static void setMoveSizeWidget (FWidget*);
static void setOpenMenu (FWidget*);
virtual void setStatusbarMessage (const FString);
virtual void setStatusbarMessage (const FString&);
bool setVisible();
virtual bool setEnable (bool);
virtual bool setEnable();
@ -240,17 +240,17 @@ class FWidget : public FVTerm
int numOfFocusableChildren();
virtual bool close();
void clearStatusbarMessage();
void addCallback ( const FString
void addCallback ( const FString&
, FCallback
, data_ptr = null );
void addCallback ( const FString
void addCallback ( const FString&
, FWidget*
, FMemberCallback
, data_ptr = null );
void delCallback (FCallback);
void delCallback (FWidget*);
void delCallbacks();
void emitCallback (const FString);
void emitCallback (const FString&);
void addAccelerator (int);
virtual void addAccelerator (int, FWidget*);
void delAccelerator ();

View File

@ -11,6 +11,7 @@ noinst_PROGRAMS = \
input-dialog \
choice \
opti-move \
termcap \
string-operations \
mandelbrot \
calculator \
@ -35,6 +36,7 @@ mandelbrot_SOURCES = mandelbrot.cpp
calculator_SOURCES = calculator.cpp
watch_SOURCES = watch.cpp
term_attributes_SOURCES = term-attributes.cpp
termcap_SOURCES = termcap.cpp
transparent_SOURCES = transparent.cpp
keyboard_SOURCES = keyboard.cpp
mouse_SOURCES = mouse.cpp

View File

@ -83,11 +83,12 @@ POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
noinst_PROGRAMS = hello$(EXEEXT) dialog$(EXEEXT) input-dialog$(EXEEXT) \
choice$(EXEEXT) opti-move$(EXEEXT) string-operations$(EXEEXT) \
mandelbrot$(EXEEXT) calculator$(EXEEXT) watch$(EXEEXT) \
term-attributes$(EXEEXT) transparent$(EXEEXT) \
keyboard$(EXEEXT) mouse$(EXEEXT) timer$(EXEEXT) \
scrollview$(EXEEXT) windows$(EXEEXT) menu$(EXEEXT) ui$(EXEEXT)
choice$(EXEEXT) opti-move$(EXEEXT) termcap$(EXEEXT) \
string-operations$(EXEEXT) mandelbrot$(EXEEXT) \
calculator$(EXEEXT) watch$(EXEEXT) term-attributes$(EXEEXT) \
transparent$(EXEEXT) keyboard$(EXEEXT) mouse$(EXEEXT) \
timer$(EXEEXT) scrollview$(EXEEXT) windows$(EXEEXT) \
menu$(EXEEXT) ui$(EXEEXT)
subdir = test
DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
$(top_srcdir)/depcomp
@ -146,6 +147,9 @@ string_operations_LDADD = $(LDADD)
am_term_attributes_OBJECTS = term-attributes.$(OBJEXT)
term_attributes_OBJECTS = $(am_term_attributes_OBJECTS)
term_attributes_LDADD = $(LDADD)
am_termcap_OBJECTS = termcap.$(OBJEXT)
termcap_OBJECTS = $(am_termcap_OBJECTS)
termcap_LDADD = $(LDADD)
am_timer_OBJECTS = timer.$(OBJEXT)
timer_OBJECTS = $(am_timer_OBJECTS)
timer_LDADD = $(LDADD)
@ -200,15 +204,15 @@ SOURCES = $(calculator_SOURCES) $(choice_SOURCES) $(dialog_SOURCES) \
$(mandelbrot_SOURCES) $(menu_SOURCES) $(mouse_SOURCES) \
$(opti_move_SOURCES) $(scrollview_SOURCES) \
$(string_operations_SOURCES) $(term_attributes_SOURCES) \
$(timer_SOURCES) $(transparent_SOURCES) $(ui_SOURCES) \
$(watch_SOURCES) $(windows_SOURCES)
$(termcap_SOURCES) $(timer_SOURCES) $(transparent_SOURCES) \
$(ui_SOURCES) $(watch_SOURCES) $(windows_SOURCES)
DIST_SOURCES = $(calculator_SOURCES) $(choice_SOURCES) \
$(dialog_SOURCES) $(hello_SOURCES) $(input_dialog_SOURCES) \
$(keyboard_SOURCES) $(mandelbrot_SOURCES) $(menu_SOURCES) \
$(mouse_SOURCES) $(opti_move_SOURCES) $(scrollview_SOURCES) \
$(string_operations_SOURCES) $(term_attributes_SOURCES) \
$(timer_SOURCES) $(transparent_SOURCES) $(ui_SOURCES) \
$(watch_SOURCES) $(windows_SOURCES)
$(termcap_SOURCES) $(timer_SOURCES) $(transparent_SOURCES) \
$(ui_SOURCES) $(watch_SOURCES) $(windows_SOURCES)
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
@ -347,6 +351,7 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
@ -367,6 +372,7 @@ mandelbrot_SOURCES = mandelbrot.cpp
calculator_SOURCES = calculator.cpp
watch_SOURCES = watch.cpp
term_attributes_SOURCES = term-attributes.cpp
termcap_SOURCES = termcap.cpp
transparent_SOURCES = transparent.cpp
keyboard_SOURCES = keyboard.cpp
mouse_SOURCES = mouse.cpp
@ -471,6 +477,10 @@ term-attributes$(EXEEXT): $(term_attributes_OBJECTS) $(term_attributes_DEPENDENC
@rm -f term-attributes$(EXEEXT)
$(AM_V_CXXLD)$(CXXLINK) $(term_attributes_OBJECTS) $(term_attributes_LDADD) $(LIBS)
termcap$(EXEEXT): $(termcap_OBJECTS) $(termcap_DEPENDENCIES) $(EXTRA_termcap_DEPENDENCIES)
@rm -f termcap$(EXEEXT)
$(AM_V_CXXLD)$(CXXLINK) $(termcap_OBJECTS) $(termcap_LDADD) $(LIBS)
timer$(EXEEXT): $(timer_OBJECTS) $(timer_DEPENDENCIES) $(EXTRA_timer_DEPENDENCIES)
@rm -f timer$(EXEEXT)
$(AM_V_CXXLD)$(CXXLINK) $(timer_OBJECTS) $(timer_LDADD) $(LIBS)
@ -510,6 +520,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/scrollview.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)/termcap.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/timer.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/transparent.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ui.Po@am__quote@

View File

@ -429,7 +429,7 @@ bool Calc::isOperatorKey(int key)
void Calc::setDisplay (lDouble d)
{
char buffer[33];
std::snprintf (buffer, sizeof(buffer), "%32.11Lg", d);
snprintf (buffer, sizeof(buffer), "%32.11Lg", d);
input = buffer;
}

View File

@ -444,8 +444,6 @@ void MouseDraw::drawBrush (int x, int y, bool swap_color)
void MouseDraw::drawCanvas()
{
int ax, ay, y_end, x_end;
char_data* cc; // canvas character
char_data* wc; // window character
if ( ! hasPrintArea() )
FVTerm::getPrintArea();
@ -461,6 +459,8 @@ void MouseDraw::drawCanvas()
for (int y=0; y < y_end; y++) // line loop
{
char_data* cc; // canvas character
char_data* wc; // window character
cc = &canvas->text[y * x_end];
wc = &print_area->text[(ay+y) * w_line_len + ax];
std::memcpy (wc, cc, sizeof(char_data) * unsigned(x_end));

207
test/termcap.cpp Normal file
View File

@ -0,0 +1,207 @@
// File: opti-move.cpp
#include <iomanip>
#include "fapp.h"
#include "ftermcap.h"
#include "fvterm.h"
// global FVTerm object
static FVTerm* terminal;
// function prototype
void tcapBooleans (std::string, bool);
void tcapNumeric (std::string, int);
void termcapString (std::string, char*);
//----------------------------------------------------------------------
// functions
//----------------------------------------------------------------------
void tcapBooleans (std::string name, bool cap_bool)
{
std::cout << "FTermcap::" << name << ": ";
if ( cap_bool )
std::cout << "true\r\n";
else
std::cout << "false\r\n";
}
//----------------------------------------------------------------------
void tcapNumeric (std::string name, int cap_num)
{
std::cout << "FTermcap::" << name << ": " << cap_num << "\r\n";
}
//----------------------------------------------------------------------
void tcapString (std::string name, const char* cap_str)
{
uInt len;
std::string sequence;
std::cout << name << ": ";
if ( cap_str == 0 )
{
std::cout << "\r\n";
return;
}
len = uInt(std::strlen(cap_str));
for (uInt i=0; i < len; i++)
{
if ( cap_str[i] < 32 )
{
if ( cap_str[i] == 27 )
sequence += "\\E";
else
{
sequence += '^';
sequence += cap_str[i] + 64;
}
}
else
sequence += cap_str[i];
}
std::cout << sequence << " ";
std::cout << "\r\n";
}
//----------------------------------------------------------------------
// main part
//----------------------------------------------------------------------
int main (int argc, char* argv[])
{
bool disable_alt_screen = true;
FApplication app (argc, argv, disable_alt_screen);
terminal = new FVTerm(&app);
FTermcap::tcap_map* tcap = 0;
tcap = FTermcap::getTermcapMap();
std::cout << "--------\r\nFTermcap\r\n--------\r\n\n";
std::cout << "Terminal: " << terminal->getTermType() << "\r\n";
#if DEBUG
std::cout << "\n.------------------- debug -------------------\r\n";
std::cout << "| after init_256colorTerminal(): "
<< terminal->termtype_256color << "\r\n";
std::cout << "| after parseAnswerbackMsg(): "
<< terminal->termtype_Answerback << "\r\n";
std::cout << "| after parseSecDA(): "
<< terminal->termtype_SecDA << "\r\n";
tcapString ( "| The answerback String"
, terminal->getAnswerbackString().c_str() );
tcapString ( "| The SecDA String"
, terminal->getSecDAString().c_str() );
std::cout << "'------------------- debug -------------------\r\n";
#endif
std::cout << "\r\n[Booleans]\r\n";
tcapBooleans ( "background_color_erase"
, FTermcap::background_color_erase );
tcapBooleans ( "automatic_left_margin"
, FTermcap::automatic_left_margin );
tcapBooleans ( "automatic_right_margin"
, FTermcap::automatic_right_margin );
tcapBooleans ( "eat_nl_glitch"
, FTermcap::eat_nl_glitch );
tcapBooleans ( "ansi_default_color"
, FTermcap::ansi_default_color );
tcapBooleans ( "osc_support"
, FTermcap::osc_support );
tcapBooleans ( "no_utf8_acs_chars"
, FTermcap::no_utf8_acs_chars );
std::cout << "\r\n[Numeric]\r\n";
tcapNumeric ("max_color", FTermcap::max_color);
tcapNumeric ("tabstop", FTermcap::tabstop);
tcapNumeric ("attr_without_color", FTermcap::attr_without_color);
std::cout << "\r\n[String]\r\n";
tcapString ("t_bell", tcap[fc::t_bell].string);
tcapString ("t_erase_chars", tcap[fc::t_erase_chars].string);
tcapString ("t_clear_screen", tcap[fc::t_clear_screen].string);
tcapString ("t_clr_eos", tcap[fc::t_clr_eos].string);
tcapString ("t_clr_eol", tcap[fc::t_clr_eol].string);
tcapString ("t_clr_bol", tcap[fc::t_clr_bol].string);
tcapString ("t_cursor_home", tcap[fc::t_cursor_home].string);
tcapString ("t_cursor_to_ll", tcap[fc::t_cursor_to_ll].string);
tcapString ("t_carriage_return", tcap[fc::t_carriage_return].string);
tcapString ("t_tab", tcap[fc::t_tab].string);
tcapString ("t_back_tab", tcap[fc::t_back_tab].string);
tcapString ("t_insert_padding", tcap[fc::t_insert_padding].string);
tcapString ("t_insert_character", tcap[fc::t_insert_character].string);
tcapString ("t_parm_ich", tcap[fc::t_parm_ich].string);
tcapString ("t_repeat_char", tcap[fc::t_repeat_char].string);
tcapString ("t_initialize_color", tcap[fc::t_initialize_color].string);
tcapString ("t_initialize_pair", tcap[fc::t_initialize_pair].string);
tcapString ("t_set_a_foreground", tcap[fc::t_set_a_foreground].string);
tcapString ("t_set_a_background", tcap[fc::t_set_a_background].string);
tcapString ("t_set_foreground", tcap[fc::t_set_foreground].string);
tcapString ("t_set_background", tcap[fc::t_set_background].string);
tcapString ("t_set_color_pair", tcap[fc::t_set_color_pair].string);
tcapString ("t_orig_pair", tcap[fc::t_orig_pair].string);
tcapString ("t_orig_colors", tcap[fc::t_orig_colors].string);
tcapString ("t_no_color_video", tcap[fc::t_no_color_video].string);
tcapString ("t_cursor_address", tcap[fc::t_cursor_address].string);
tcapString ("t_column_address", tcap[fc::t_column_address].string);
tcapString ("t_row_address", tcap[fc::t_row_address].string);
tcapString ("t_cursor_visible", tcap[fc::t_cursor_visible].string);
tcapString ("t_cursor_invisible", tcap[fc::t_cursor_invisible].string);
tcapString ("t_cursor_normal", tcap[fc::t_cursor_normal].string);
tcapString ("t_cursor_up", tcap[fc::t_cursor_up].string);
tcapString ("t_cursor_down", tcap[fc::t_cursor_down].string);
tcapString ("t_cursor_left", tcap[fc::t_cursor_left].string);
tcapString ("t_cursor_right", tcap[fc::t_cursor_right].string);
tcapString ("t_parm_up_cursor", tcap[fc::t_parm_up_cursor].string);
tcapString ("t_parm_down_cursor", tcap[fc::t_parm_down_cursor].string);
tcapString ("t_parm_left_cursor", tcap[fc::t_parm_left_cursor].string);
tcapString ("t_parm_right_cursor", tcap[fc::t_parm_right_cursor].string);
tcapString ("t_save_cursor", tcap[fc::t_save_cursor].string);
tcapString ("t_restore_cursor", tcap[fc::t_restore_cursor].string);
tcapString ("t_scroll_forward", tcap[fc::t_scroll_forward].string);
tcapString ("t_scroll_reverse", tcap[fc::t_scroll_reverse].string);
tcapString ("t_enter_ca_mode", tcap[fc::t_enter_ca_mode].string);
tcapString ("t_exit_ca_mode", tcap[fc::t_exit_ca_mode].string);
tcapString ("t_enable_acs", tcap[fc::t_enable_acs].string);
tcapString ("t_enter_bold_mode", tcap[fc::t_enter_bold_mode].string);
tcapString ("t_exit_bold_mode", tcap[fc::t_exit_bold_mode].string);
tcapString ("t_enter_dim_mode", tcap[fc::t_enter_dim_mode].string);
tcapString ("t_exit_dim_mode", tcap[fc::t_exit_dim_mode].string);
tcapString ("t_enter_italics_mode", tcap[fc::t_enter_italics_mode].string);
tcapString ("t_exit_italics_mode", tcap[fc::t_exit_italics_mode].string);
tcapString ("t_enter_underline_mode", tcap[fc::t_enter_underline_mode].string);
tcapString ("t_exit_underline_mode", tcap[fc::t_exit_underline_mode].string);
tcapString ("t_enter_blink_mode", tcap[fc::t_enter_blink_mode].string);
tcapString ("t_exit_blink_mode", tcap[fc::t_exit_blink_mode].string);
tcapString ("t_enter_reverse_mode", tcap[fc::t_enter_reverse_mode].string);
tcapString ("t_exit_reverse_mode", tcap[fc::t_exit_reverse_mode].string);
tcapString ("t_enter_standout_mode", tcap[fc::t_enter_standout_mode].string);
tcapString ("t_exit_standout_mode", tcap[fc::t_exit_standout_mode].string);
tcapString ("t_enter_secure_mode", tcap[fc::t_enter_secure_mode].string);
tcapString ("t_exit_secure_mode", tcap[fc::t_exit_secure_mode].string);
tcapString ("t_enter_protected_mode", tcap[fc::t_enter_protected_mode].string);
tcapString ("t_exit_protected_mode", tcap[fc::t_exit_protected_mode].string);
tcapString ("t_enter_crossed_out_mode", tcap[fc::t_enter_crossed_out_mode].string);
tcapString ("t_exit_crossed_out_mode", tcap[fc::t_exit_crossed_out_mode].string);
tcapString ("t_enter_dbl_underline_mode", tcap[fc::t_enter_dbl_underline_mode].string);
tcapString ("t_exit_dbl_underline_mode", tcap[fc::t_exit_dbl_underline_mode].string);
tcapString ("t_set_attributes", tcap[fc::t_set_attributes].string);
tcapString ("t_exit_attribute_mode", tcap[fc::t_exit_attribute_mode].string);
tcapString ("t_enter_alt_charset_mode", tcap[fc::t_enter_alt_charset_mode].string);
tcapString ("t_exit_alt_charset_mode", tcap[fc::t_exit_alt_charset_mode].string);
tcapString ("t_enter_pc_charset_mode", tcap[fc::t_enter_pc_charset_mode].string);
tcapString ("t_exit_pc_charset_mode", tcap[fc::t_exit_pc_charset_mode].string);
tcapString ("t_enter_insert_mode", tcap[fc::t_enter_insert_mode].string);
tcapString ("t_exit_insert_mode", tcap[fc::t_exit_insert_mode].string);
tcapString ("t_enter_am_mode", tcap[fc::t_enter_am_mode].string);
tcapString ("t_exit_am_mode", tcap[fc::t_exit_am_mode].string);
tcapString ("t_acs_chars", tcap[fc::t_acs_chars].string);
tcapString ("t_keypad_xmit", tcap[fc::t_keypad_xmit].string);
tcapString ("t_keypad_local", tcap[fc::t_keypad_local].string);
tcapString ("t_key_mouse", tcap[fc::t_key_mouse].string);
}