Move FreeBSD, NetBSD and OpenBSD functions to separate classes
This commit is contained in:
parent
b05873babb
commit
0927e4e1fb
|
@ -1,3 +1,6 @@
|
|||
2017-05-27 Markus Gans <guru.mail@muenster.de>
|
||||
* Move FreeBSD, NetBSD and OpenBSD functions to separate classes
|
||||
|
||||
2017-05-20 Markus Gans <guru.mail@muenster.de>
|
||||
* Methods outsourcing from FTerm to FTermXTerminal
|
||||
|
||||
|
|
14
README.md
14
README.md
|
@ -117,13 +117,13 @@ printf(...)
|
|||
Class digramm
|
||||
-------------
|
||||
<pre style="line-height: 1 !important;">
|
||||
┌───────────┐
|
||||
┌────┤ FKeyEvent │
|
||||
│ └───────────┘
|
||||
│ ┌─────────────┐
|
||||
├────┤ FMouseEvent │
|
||||
│ └─────────────┘
|
||||
1┌────────────────┐ │ ┌─────────────┐
|
||||
1┌──────────────┐ ┌───────────┐
|
||||
┌-----------┤ FTermFreeBSD │ ┌────┤ FKeyEvent │
|
||||
: └──────────────┘ │ └───────────┘
|
||||
: 1┌──────────────┐ │ ┌─────────────┐
|
||||
┌-----------┤ FTermOpenBSD │ ├────┤ FMouseEvent │
|
||||
: └──────────────┘ │ └─────────────┘
|
||||
: 1┌────────────────┐ │ ┌─────────────┐
|
||||
┌-----------┤ FTermDetection │ ├────┤ FWheelEvent │
|
||||
: └────────────────┘ │ └─────────────┘
|
||||
: 1┌────────────────┐ │ ┌─────────────┐
|
||||
|
|
|
@ -2,13 +2,13 @@
|
|||
Class digramm
|
||||
══════════════════════════════════════════════════════════════════════════════
|
||||
|
||||
┌───────────┐
|
||||
┌────┤ FKeyEvent │
|
||||
│ └───────────┘
|
||||
│ ┌─────────────┐
|
||||
├────┤ FMouseEvent │
|
||||
│ └─────────────┘
|
||||
1┌────────────────┐ │ ┌─────────────┐
|
||||
1┌──────────────┐ ┌───────────┐
|
||||
┌-----------┤ FTermFreeBSD │ ┌────┤ FKeyEvent │
|
||||
: └──────────────┘ │ └───────────┘
|
||||
: 1┌──────────────┐ │ ┌─────────────┐
|
||||
┌-----------┤ FTermOpenBSD │ ├────┤ FMouseEvent │
|
||||
: └──────────────┘ │ └─────────────┘
|
||||
: 1┌────────────────┐ │ ┌─────────────┐
|
||||
┌-----------┤ FTermDetection │ ├────┤ FWheelEvent │
|
||||
: └────────────────┘ │ └─────────────┘
|
||||
: 1┌────────────────┐ │ ┌─────────────┐
|
||||
|
|
|
@ -26,26 +26,26 @@
|
|||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// class fClassName
|
||||
// class FClassName
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
// constructors and destructor
|
||||
//----------------------------------------------------------------------
|
||||
fClassName::fClassName()
|
||||
FClassName::FClassName()
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
fClassName::~fClassName() // destructor
|
||||
FClassName::~FClassName() // destructor
|
||||
{ }
|
||||
|
||||
// public methods of fClassName
|
||||
// public methods of FClassName
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
|
||||
// protected methods of fClassName
|
||||
// protected methods of FClassName
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
|
||||
// private methods of fClassName
|
||||
// private methods of FClassName
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
* ════════════════
|
||||
*
|
||||
* ▕▔▔▔▔▔▔▔▔▔▔▔▔▏
|
||||
* ▕ fClassName ▏
|
||||
* ▕ FClassName ▏
|
||||
* ▕▁▁▁▁▁▁▁▁▁▁▁▁▏
|
||||
*/
|
||||
|
||||
|
@ -39,13 +39,13 @@
|
|||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// class fClassName
|
||||
// class FClassName
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
#pragma pack(push)
|
||||
#pragma pack(1)
|
||||
|
||||
class fClassName
|
||||
class FClassName
|
||||
{
|
||||
public:
|
||||
// Using-declaration
|
||||
|
@ -55,15 +55,17 @@ class fClassName
|
|||
// Constants
|
||||
|
||||
// Constructors
|
||||
fClassName();
|
||||
FClassName();
|
||||
|
||||
// Destructor
|
||||
~fClassName();
|
||||
~FClassName();
|
||||
|
||||
// Overloaded operators
|
||||
|
||||
// Accessors
|
||||
|
||||
// Mutators
|
||||
|
||||
// Inquiries
|
||||
|
||||
// Methods
|
||||
|
@ -97,10 +99,10 @@ class fClassName
|
|||
// Constants
|
||||
|
||||
// Disable copy constructor
|
||||
fClassName (const fClassName&);
|
||||
FClassName (const FClassName&);
|
||||
|
||||
// Disable assignment operator (=)
|
||||
fClassName& operator = (const fClassName&);
|
||||
FClassName& operator = (const FClassName&);
|
||||
|
||||
// Accessors
|
||||
|
||||
|
@ -119,7 +121,7 @@ class fClassName
|
|||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
// fClassName inline functions
|
||||
// FClassName inline functions
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* *
|
||||
* This file is part of the Final Cut widget toolkit *
|
||||
* *
|
||||
* Copyright 2015-2017 Markus Gans *
|
||||
* Copyright 2015-2018 Markus Gans *
|
||||
* *
|
||||
* The Final Cut is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Lesser General Public License *
|
||||
|
@ -27,6 +27,9 @@
|
|||
#error "Only <final/final.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include "final/fc.h"
|
||||
#include "final/ftypes.h"
|
||||
|
||||
namespace fc
|
||||
{
|
||||
|
||||
|
|
|
@ -87,16 +87,6 @@
|
|||
#include <sys/kd.h>
|
||||
#endif
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
||||
#include <sys/consio.h>
|
||||
#include <sys/kbio.h>
|
||||
#endif
|
||||
|
||||
#if defined(__NetBSD__) || defined(__OpenBSD__)
|
||||
#include <sys/time.h>
|
||||
#include <dev/wscons/wsconsio.h>
|
||||
#endif
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
|
@ -146,6 +136,15 @@
|
|||
#include "final/ftermcap.h"
|
||||
#include "final/ftermcapquirks.h"
|
||||
#include "final/ftermdetection.h"
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
||||
#include "final/ftermfreebsd.h"
|
||||
#endif
|
||||
|
||||
#if defined(__NetBSD__) || defined(__OpenBSD__)
|
||||
#include "final/ftermopenbsd.h"
|
||||
#endif
|
||||
|
||||
#include "final/ftermios.h"
|
||||
#include "final/ftermxterminal.h"
|
||||
|
||||
|
@ -201,10 +200,6 @@ class FTerm
|
|||
static fc::linuxConsoleCursorStyle getLinuxConsoleCursorStyle();
|
||||
#endif
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
||||
static fc::freebsdConsoleCursorStyle getFreeBSDConsoleCursorStyle();
|
||||
#endif
|
||||
|
||||
#if DEBUG
|
||||
static const FString& getAnswerbackString();
|
||||
static const FString& getSecDAString();
|
||||
|
@ -260,11 +255,6 @@ class FTerm
|
|||
(fc::linuxConsoleCursorStyle, bool);
|
||||
#endif
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
||||
static void setFreeBSDConsoleCursorStyle \
|
||||
(fc::freebsdConsoleCursorStyle, bool);
|
||||
#endif
|
||||
|
||||
static void setKeypressTimeout (const long);
|
||||
static void setDblclickInterval (const long);
|
||||
static void disableAltScreen();
|
||||
|
@ -401,14 +391,6 @@ class FTerm
|
|||
static int isLinuxConsole();
|
||||
#endif
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
||||
static bool isFreeBSDConsole();
|
||||
#endif
|
||||
|
||||
#if defined(__NetBSD__) || defined(__OpenBSD__)
|
||||
static bool isWSConsConsole();
|
||||
#endif
|
||||
|
||||
// Methods
|
||||
#if defined(__linux__)
|
||||
#if defined(__x86_64__) || defined(__i386) || defined(__arm__)
|
||||
|
@ -435,23 +417,6 @@ class FTerm
|
|||
static void initLinuxConsoleCharMap();
|
||||
#endif
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
||||
static bool saveFreeBSDAltKey();
|
||||
static bool setFreeBSDAltKey (uInt);
|
||||
static bool setFreeBSDAlt2Meta();
|
||||
static bool resetFreeBSDAlt2Meta();
|
||||
static void initFreeBSDConsole();
|
||||
static void initFreeBSDConsoleCharMap();
|
||||
#endif
|
||||
|
||||
#if defined(__NetBSD__) || defined(__OpenBSD__)
|
||||
static bool saveWSConsEncoding();
|
||||
static bool setWSConsEncoding (kbd_t);
|
||||
static bool setWSConsMetaEsc();
|
||||
static bool resetWSConsEncoding();
|
||||
static void initWSConsConsole();
|
||||
#endif
|
||||
|
||||
static void init_global_values();
|
||||
static void oscPrefix();
|
||||
static void oscPostfix();
|
||||
|
@ -525,7 +490,6 @@ class FTerm
|
|||
static bool ascii_console;
|
||||
static bool NewFont;
|
||||
static bool VGAFont;
|
||||
static bool color256;
|
||||
static bool monochron;
|
||||
static char termtype[256];
|
||||
static char termfilename[256];
|
||||
|
@ -546,22 +510,22 @@ class FTerm
|
|||
static bool resize_term;
|
||||
|
||||
static fc::linuxConsoleCursorStyle linux_console_cursor_style;
|
||||
static fc::freebsdConsoleCursorStyle freebsd_console_cursor_style;
|
||||
static struct console_font_op screen_font;
|
||||
static struct unimapdesc screen_unicode_map;
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
||||
static uInt bsd_alt_keymap;
|
||||
#endif
|
||||
|
||||
#if defined(__NetBSD__) || defined(__OpenBSD__)
|
||||
static kbd_t wscons_keyboard_encoding;
|
||||
#endif
|
||||
|
||||
static FOptiMove* opti_move;
|
||||
static FOptiAttr* opti_attr;
|
||||
static FTermDetection* term_detection;
|
||||
static FTermXTerminal* xterm;
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
||||
static FTermFreeBSD* freebsd;
|
||||
#endif
|
||||
|
||||
#if defined(__NetBSD__) || defined(__OpenBSD__)
|
||||
static FTermOpenBSD* openbsd;
|
||||
#endif
|
||||
|
||||
static FMouseControl* mouse;
|
||||
static const FString* save_xterm_font;
|
||||
static const FString* save_xterm_title;
|
||||
|
@ -604,8 +568,6 @@ class FTerm
|
|||
{
|
||||
dacreg d[16];
|
||||
} color_map;
|
||||
|
||||
friend class FTermDetection;
|
||||
};
|
||||
|
||||
#pragma pack(pop)
|
||||
|
|
|
@ -124,6 +124,7 @@ class FTermDetection
|
|||
static bool isOpenBSDTerm();
|
||||
static bool isScreenTerm();
|
||||
static bool isTmuxTerm();
|
||||
static bool canDisplay256Colors();
|
||||
static bool hasTerminalDetection();
|
||||
static bool hasSetCursorStyleSupport();
|
||||
|
||||
|
@ -274,6 +275,10 @@ inline const char* FTermDetection::getTermType_SecDA()
|
|||
{ return termtype_SecDA; }
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FTermDetection::canDisplay256Colors()
|
||||
{ return color256; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FTermDetection::hasSetCursorStyleSupport()
|
||||
{ return decscusr_support; }
|
||||
|
|
|
@ -0,0 +1,106 @@
|
|||
/***********************************************************************
|
||||
* ftermfreebsd.h - Contains the FreeBSD terminal functions *
|
||||
* *
|
||||
* This file is part of the Final Cut widget toolkit *
|
||||
* *
|
||||
* Copyright 2018 Markus Gans *
|
||||
* *
|
||||
* The Final Cut is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Lesser General Public License *
|
||||
* as published by the Free Software Foundation; either version 3 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* The Final Cut is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Lesser General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this program. If not, see *
|
||||
* <http://www.gnu.org/licenses/>. *
|
||||
***********************************************************************/
|
||||
|
||||
/* Standalone class
|
||||
* ════════════════
|
||||
*
|
||||
* ▕▔▔▔▔▔▔▔▔▔▔▔▔▔▔▏
|
||||
* ▕ FTermFreeBSD ▏
|
||||
* ▕▁▁▁▁▁▁▁▁▁▁▁▁▁▁▏
|
||||
*/
|
||||
|
||||
#ifndef FTERMFREEBSD_H
|
||||
#define FTERMFREEBSD_H
|
||||
|
||||
#if !defined (USE_FINAL_H) && !defined (COMPILE_FINAL_CUT)
|
||||
#error "Only <final/final.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include "final/fc.h"
|
||||
#include "final/ftypes.h"
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
||||
#undef mouse_info // consio.h
|
||||
#undef buttons // consio.h
|
||||
|
||||
#include <sys/consio.h>
|
||||
#include <sys/kbio.h>
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// class FTermFreeBSD
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
#pragma pack(push)
|
||||
#pragma pack(1)
|
||||
|
||||
class FTermFreeBSD
|
||||
{
|
||||
public:
|
||||
// Typedef
|
||||
typedef fc::freebsdConsoleCursorStyle CursorStyle;
|
||||
|
||||
// Constructors
|
||||
FTermFreeBSD();
|
||||
|
||||
// Destructor
|
||||
~FTermFreeBSD();
|
||||
|
||||
// Overloaded operators
|
||||
|
||||
// Accessors
|
||||
static CursorStyle getCursorStyle();
|
||||
|
||||
// Inquiry
|
||||
static bool isFreeBSDConsole();
|
||||
|
||||
// Mutators
|
||||
static void setCursorStyle (CursorStyle, bool);
|
||||
// Methods
|
||||
static void init();
|
||||
static void initCharMap();
|
||||
static void finish();
|
||||
static void restoreCursorStyle();
|
||||
|
||||
private:
|
||||
// Disable copy constructor
|
||||
FTermFreeBSD (const FTermFreeBSD&);
|
||||
|
||||
// Disable assignment operator (=)
|
||||
FTermFreeBSD& operator = (const FTermFreeBSD&);
|
||||
|
||||
// Methods
|
||||
static bool saveFreeBSDAltKey();
|
||||
static bool setFreeBSDAltKey (uInt);
|
||||
static bool setFreeBSDAlt2Meta();
|
||||
static bool resetFreeBSDAlt2Meta();
|
||||
|
||||
// Data Members
|
||||
static uInt bsd_alt_keymap;
|
||||
static CursorStyle cursor_style;
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
|
||||
#endif // FTERMFREEBSD_H
|
||||
|
||||
|
|
@ -0,0 +1,100 @@
|
|||
/***********************************************************************
|
||||
* ftermopenbsd.h - Contains the NetBSD/OpenBSD terminal functions *
|
||||
* *
|
||||
* This file is part of the Final Cut widget toolkit *
|
||||
* *
|
||||
* Copyright 2018 Markus Gans *
|
||||
* *
|
||||
* The Final Cut is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Lesser General Public License *
|
||||
* as published by the Free Software Foundation; either version 3 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* The Final Cut is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Lesser General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this program. If not, see *
|
||||
* <http://www.gnu.org/licenses/>. *
|
||||
***********************************************************************/
|
||||
|
||||
/* Standalone class
|
||||
* ════════════════
|
||||
*
|
||||
* ▕▔▔▔▔▔▔▔▔▔▔▔▔▔▔▏
|
||||
* ▕ FTermOpenBSD ▏
|
||||
* ▕▁▁▁▁▁▁▁▁▁▁▁▁▁▁▏
|
||||
*/
|
||||
|
||||
#ifndef FTERMOPENBSD_H
|
||||
#define FTERMOPENBSD_H
|
||||
|
||||
#if !defined (USE_FINAL_H) && !defined (COMPILE_FINAL_CUT)
|
||||
#error "Only <final/final.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#if defined(__NetBSD__) || defined(__OpenBSD__)
|
||||
#include <sys/time.h>
|
||||
#include <dev/wscons/wsconsio.h>
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// class FTermOpenBSD
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
#pragma pack(push)
|
||||
#pragma pack(1)
|
||||
|
||||
class FTermOpenBSD
|
||||
{
|
||||
public:
|
||||
// Constructors
|
||||
FTermOpenBSD();
|
||||
|
||||
// Destructor
|
||||
~FTermOpenBSD();
|
||||
|
||||
// Overloaded operators
|
||||
|
||||
// Accessors
|
||||
|
||||
// Mutators
|
||||
|
||||
// Inquiries
|
||||
static bool isWSConsConsole();
|
||||
|
||||
// Methods
|
||||
static void init();
|
||||
static void finish();
|
||||
|
||||
private:
|
||||
// Disable copy constructor
|
||||
FTermOpenBSD (const FTermOpenBSD&);
|
||||
|
||||
// Disable assignment operator (=)
|
||||
FTermOpenBSD& operator = (const FTermOpenBSD&);
|
||||
|
||||
#if defined(__NetBSD__) || defined(__OpenBSD__)
|
||||
// Methods
|
||||
static bool saveWSConsEncoding();
|
||||
static bool setWSConsEncoding (kbd_t);
|
||||
static bool setWSConsMetaEsc();
|
||||
static bool resetWSConsEncoding();
|
||||
|
||||
// Data Members
|
||||
static kbd_t wscons_keyboard_encoding;
|
||||
#endif
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
// FTermOpenBSD inline functions
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
|
||||
#endif // FTERMOPENBSD_H
|
||||
|
||||
|
|
@ -42,6 +42,8 @@ libfinal_la_SOURCES = \
|
|||
fstatusbar.cpp \
|
||||
ftermcapquirks.cpp \
|
||||
ftermxterminal.cpp \
|
||||
ftermfreebsd.cpp \
|
||||
ftermopenbsd.cpp \
|
||||
ftermdetection.cpp \
|
||||
ftermios.cpp \
|
||||
fterm.cpp \
|
||||
|
@ -106,6 +108,8 @@ finalcutinclude_HEADERS = \
|
|||
../include/final/ftermcap.h \
|
||||
../include/final/ftermcapquirks.h \
|
||||
../include/final/ftermxterminal.h \
|
||||
../include/final/ftermfreebsd.h \
|
||||
../include/final/ftermopenbsd.h \
|
||||
../include/final/ftermdetection.h \
|
||||
../include/final/ftermios.h \
|
||||
../include/final/fterm.h \
|
||||
|
|
|
@ -48,6 +48,8 @@ INCLUDE_HEADERS = \
|
|||
ftermdetection.h \
|
||||
ftermcapquirks.h \
|
||||
ftermxterminal.h \
|
||||
ftermfreebsd.h \
|
||||
ftermopenbsd.h \
|
||||
fvterm.h \
|
||||
ftextview.h \
|
||||
ftogglebutton.h \
|
||||
|
@ -103,6 +105,8 @@ OBJS = \
|
|||
ftermdetection.o \
|
||||
ftermcapquirks.o \
|
||||
ftermxterminal.o \
|
||||
ftermfreebsd.o \
|
||||
ftermopenbsd.o \
|
||||
fvterm.o \
|
||||
fevent.o \
|
||||
foptiattr.o \
|
||||
|
|
|
@ -48,6 +48,8 @@ INCLUDE_HEADERS = \
|
|||
ftermdetection.h \
|
||||
ftermcapquirks.h \
|
||||
ftermxterminal.h \
|
||||
ftermfreebsd.h \
|
||||
ftermopenbsd.h \
|
||||
fvterm.h \
|
||||
ftextview.h \
|
||||
ftogglebutton.h \
|
||||
|
@ -103,6 +105,8 @@ OBJS = \
|
|||
ftermdetection.o \
|
||||
ftermcapquirks.o \
|
||||
ftermxterminal.o \
|
||||
ftermfreebsd.o \
|
||||
ftermopenbsd.o \
|
||||
fvterm.o \
|
||||
fevent.o \
|
||||
foptiattr.o \
|
||||
|
|
|
@ -137,9 +137,10 @@ am_libfinal_la_OBJECTS = fstring.lo fpoint.lo frect.lo fscrollbar.lo \
|
|||
fcheckmenuitem.lo fmenulist.lo fdialog.lo fscrollview.lo \
|
||||
fwindow.lo fmessagebox.lo ftooltip.lo ffiledialog.lo \
|
||||
ftextview.lo fstatusbar.lo ftermcapquirks.lo ftermxterminal.lo \
|
||||
ftermdetection.lo ftermios.lo fterm.lo fvterm.lo fevent.lo \
|
||||
foptiattr.lo foptimove.lo ftermbuffer.lo fapplication.lo \
|
||||
fcolorpalette.lo fwidgetcolors.lo fwidget.lo fobject.lo
|
||||
ftermfreebsd.lo ftermopenbsd.lo ftermdetection.lo ftermios.lo \
|
||||
fterm.lo fvterm.lo fevent.lo foptiattr.lo foptimove.lo \
|
||||
ftermbuffer.lo fapplication.lo fcolorpalette.lo \
|
||||
fwidgetcolors.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@)
|
||||
|
@ -415,6 +416,8 @@ libfinal_la_SOURCES = \
|
|||
fstatusbar.cpp \
|
||||
ftermcapquirks.cpp \
|
||||
ftermxterminal.cpp \
|
||||
ftermfreebsd.cpp \
|
||||
ftermopenbsd.cpp \
|
||||
ftermdetection.cpp \
|
||||
ftermios.cpp \
|
||||
fterm.cpp \
|
||||
|
@ -477,6 +480,8 @@ finalcutinclude_HEADERS = \
|
|||
../include/final/ftermcap.h \
|
||||
../include/final/ftermcapquirks.h \
|
||||
../include/final/ftermxterminal.h \
|
||||
../include/final/ftermfreebsd.h \
|
||||
../include/final/ftermopenbsd.h \
|
||||
../include/final/ftermdetection.h \
|
||||
../include/final/ftermios.h \
|
||||
../include/final/fterm.h \
|
||||
|
@ -604,7 +609,9 @@ distclean-compile:
|
|||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ftermbuffer.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ftermcapquirks.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ftermdetection.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ftermfreebsd.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ftermios.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ftermopenbsd.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ftermxterminal.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ftextview.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ftogglebutton.Plo@am__quote@
|
||||
|
|
|
@ -139,6 +139,9 @@ FString::FString (const FString& s) // copy constructor
|
|||
, bufsize(0)
|
||||
, c_string(0)
|
||||
{
|
||||
if ( ! &s )
|
||||
return;
|
||||
|
||||
if ( s.isNull() )
|
||||
return;
|
||||
else
|
||||
|
@ -152,6 +155,9 @@ FString::FString (const std::wstring& s)
|
|||
, bufsize(0)
|
||||
, c_string(0)
|
||||
{
|
||||
if ( ! &s )
|
||||
return;
|
||||
|
||||
if ( s.empty() )
|
||||
_assign (L"");
|
||||
else
|
||||
|
@ -184,6 +190,9 @@ FString::FString (const std::string& s)
|
|||
, bufsize(0)
|
||||
, c_string(0)
|
||||
{
|
||||
if ( ! &s )
|
||||
return;
|
||||
|
||||
if ( s.empty() )
|
||||
{
|
||||
_assign(L"");
|
||||
|
|
240
src/fterm.cpp
240
src/fterm.cpp
|
@ -56,10 +56,8 @@ uInt FTerm::cursor_address_lengths;
|
|||
uInt FTerm::baudrate;
|
||||
long FTerm::key_timeout;
|
||||
bool FTerm::resize_term;
|
||||
|
||||
bool FTerm::input_data_pending;
|
||||
bool FTerm::non_blocking_stdin;
|
||||
bool FTerm::color256;
|
||||
bool FTerm::monochron;
|
||||
bool FTerm::pc_charset_console;
|
||||
bool FTerm::utf8_input;
|
||||
|
@ -112,7 +110,6 @@ FTerm::colorEnv FTerm::color_env;
|
|||
FTerm::secondaryDA FTerm::secondary_da;
|
||||
FTerm::initializationValues FTerm::init_values;
|
||||
fc::linuxConsoleCursorStyle FTerm::linux_console_cursor_style;
|
||||
fc::freebsdConsoleCursorStyle FTerm::freebsd_console_cursor_style;
|
||||
|
||||
#if defined(__linux__)
|
||||
FTerm::modifier_key FTerm::mod_key;
|
||||
|
@ -121,11 +118,11 @@ fc::freebsdConsoleCursorStyle FTerm::freebsd_console_cursor_style;
|
|||
#endif
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
||||
uInt FTerm::bsd_alt_keymap = 0;
|
||||
FTermFreeBSD* FTerm::freebsd = 0;
|
||||
#endif
|
||||
|
||||
#if defined(__NetBSD__) || defined(__OpenBSD__)
|
||||
kbd_t FTerm::wscons_keyboard_encoding = 0;
|
||||
FTermOpenBSD* FTerm::openbsd = 0;
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -151,7 +148,7 @@ FTerm::FTerm (bool disable_alt_screen)
|
|||
FTerm::~FTerm() // destructor
|
||||
{
|
||||
if ( init_term_object == this )
|
||||
finish();
|
||||
finish(); // Resetting console settings
|
||||
}
|
||||
|
||||
|
||||
|
@ -233,14 +230,6 @@ fc::linuxConsoleCursorStyle FTerm::getLinuxConsoleCursorStyle()
|
|||
}
|
||||
#endif
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
||||
//----------------------------------------------------------------------
|
||||
fc::freebsdConsoleCursorStyle FTerm::getFreeBSDConsoleCursorStyle()
|
||||
{
|
||||
return freebsd_console_cursor_style;
|
||||
}
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FTerm::isNormal (char_data*& ch)
|
||||
{
|
||||
|
@ -295,25 +284,6 @@ char* FTerm::setLinuxConsoleCursorStyle ( fc::linuxConsoleCursorStyle style
|
|||
}
|
||||
#endif
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
||||
//----------------------------------------------------------------------
|
||||
void FTerm::setFreeBSDConsoleCursorStyle ( fc::freebsdConsoleCursorStyle style
|
||||
, bool hidden )
|
||||
{
|
||||
// Set cursor style in a BSD console
|
||||
|
||||
if ( ! isFreeBSDConsole() )
|
||||
return;
|
||||
|
||||
freebsd_console_cursor_style = style;
|
||||
|
||||
if ( hidden )
|
||||
return;
|
||||
|
||||
ioctl(0, CONS_CURSORTYPE, &style);
|
||||
}
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FTerm::setDblclickInterval (const long timeout)
|
||||
{
|
||||
|
@ -608,7 +578,8 @@ bool FTerm::setOldFont()
|
|||
//----------------------------------------------------------------------
|
||||
char* FTerm::moveCursor (int xold, int yold, int xnew, int ynew)
|
||||
{
|
||||
// returns the cursor move string
|
||||
// Returns the cursor move string
|
||||
|
||||
if ( cursor_optimisation )
|
||||
return opti_move->moveCursor (xold, yold, xnew, ynew);
|
||||
else
|
||||
|
@ -652,6 +623,8 @@ void FTerm::printMoveDurations()
|
|||
//----------------------------------------------------------------------
|
||||
char* FTerm::enableCursor()
|
||||
{
|
||||
// Returns the cursor enable string
|
||||
|
||||
static const std::size_t SIZE = 32;
|
||||
static char enable_str[SIZE] = { };
|
||||
char*& vs = TCAP(fc::t_cursor_visible);
|
||||
|
@ -665,6 +638,7 @@ char* FTerm::enableCursor()
|
|||
#if defined(__linux__)
|
||||
if ( isLinuxTerm() )
|
||||
{
|
||||
// Restore the last used Linux console cursor style
|
||||
char* lcur;
|
||||
lcur = setLinuxConsoleCursorStyle (getLinuxConsoleCursorStyle(), false);
|
||||
std::strncat (enable_str, lcur, SIZE - std::strlen(enable_str) - 1);
|
||||
|
@ -672,7 +646,8 @@ char* FTerm::enableCursor()
|
|||
#endif
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
||||
setFreeBSDConsoleCursorStyle (getFreeBSDConsoleCursorStyle(), false);
|
||||
// Restore the last used FreeBSD console cursor style
|
||||
freebsd->restoreCursorStyle();
|
||||
#endif
|
||||
|
||||
return enable_str;
|
||||
|
@ -681,6 +656,8 @@ char* FTerm::enableCursor()
|
|||
//----------------------------------------------------------------------
|
||||
char* FTerm::disableCursor()
|
||||
{
|
||||
// Returns the cursor disable string
|
||||
|
||||
char*& vi = TCAP(fc::t_cursor_invisible);
|
||||
|
||||
if ( vi )
|
||||
|
@ -692,6 +669,8 @@ char* FTerm::disableCursor()
|
|||
//----------------------------------------------------------------------
|
||||
void FTerm::detectTermSize()
|
||||
{
|
||||
// Detect the terminal width and height
|
||||
|
||||
struct winsize win_size;
|
||||
bool close_after_detect = false;
|
||||
int ret;
|
||||
|
@ -1114,7 +1093,7 @@ void FTerm::initScreenSettings()
|
|||
#endif
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
||||
initFreeBSDConsoleCharMap();
|
||||
freebsd->initCharMap();
|
||||
#endif
|
||||
|
||||
// set xterm underline cursor
|
||||
|
@ -1187,6 +1166,8 @@ void FTerm::exitWithMessage (std::string message)
|
|||
#if defined(__linux__)
|
||||
int FTerm::isLinuxConsole()
|
||||
{
|
||||
// Check if it's a Linux console
|
||||
|
||||
char arg = 0;
|
||||
// get keyboard type an compare
|
||||
return ( isatty (fd_tty)
|
||||
|
@ -1195,32 +1176,6 @@ int FTerm::isLinuxConsole()
|
|||
}
|
||||
#endif
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
||||
//----------------------------------------------------------------------
|
||||
bool FTerm::isFreeBSDConsole()
|
||||
{
|
||||
keymap_t keymap;
|
||||
|
||||
if ( ioctl(0, GIO_KEYMAP, &keymap) == 0 )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
#if defined(__NetBSD__) || defined(__OpenBSD__)
|
||||
bool FTerm::isWSConsConsole()
|
||||
{
|
||||
static kbd_t kbdencoding;
|
||||
|
||||
if ( ioctl(0, WSKBDIO_GETENCODING, &kbdencoding) == 0 )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(__linux__)
|
||||
#if defined(__x86_64__) || defined(__i386) || defined(__arm__)
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -1696,143 +1651,6 @@ void FTerm::initLinuxConsoleCharMap()
|
|||
}
|
||||
#endif
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
||||
//----------------------------------------------------------------------
|
||||
bool FTerm::saveFreeBSDAltKey()
|
||||
{
|
||||
static const int left_alt = 0x38;
|
||||
int ret;
|
||||
keymap_t keymap;
|
||||
|
||||
ret = ioctl(0, GIO_KEYMAP, &keymap);
|
||||
|
||||
if ( ret < 0 )
|
||||
return false;
|
||||
|
||||
// save current mapping
|
||||
bsd_alt_keymap = keymap.key[left_alt].map[0];
|
||||
return true;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FTerm::setFreeBSDAltKey (uInt key)
|
||||
{
|
||||
static const int left_alt = 0x38;
|
||||
int ret;
|
||||
keymap_t keymap;
|
||||
|
||||
ret = ioctl(0, GIO_KEYMAP, &keymap);
|
||||
|
||||
if ( ret < 0 )
|
||||
return false;
|
||||
|
||||
// map to meta key
|
||||
keymap.key[left_alt].map[0] = key;
|
||||
|
||||
if ( (keymap.n_keys > 0) && (ioctl(0, PIO_KEYMAP, &keymap) < 0) )
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FTerm::setFreeBSDAlt2Meta()
|
||||
{
|
||||
return setFreeBSDAltKey (META);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FTerm::resetFreeBSDAlt2Meta()
|
||||
{
|
||||
return setFreeBSDAltKey (bsd_alt_keymap);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FTerm::initFreeBSDConsole()
|
||||
{
|
||||
// initialize BSD console
|
||||
|
||||
if ( isFreeBSDConsole() )
|
||||
{
|
||||
// save current left alt key mapping
|
||||
saveFreeBSDAltKey();
|
||||
|
||||
// map meta key to left alt key
|
||||
setFreeBSDAlt2Meta();
|
||||
|
||||
// Initialize FreeBSD console cursor
|
||||
setFreeBSDConsoleCursorStyle (fc::destructive_cursor, true);
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FTerm::initFreeBSDConsoleCharMap()
|
||||
{
|
||||
// A FreeBSD console can't show ASCII codes from 0x00 to 0x1b
|
||||
|
||||
if ( ! isFreeBSDConsole() )
|
||||
return;
|
||||
|
||||
for (int i = 0; i <= fc::lastCharItem; i++ )
|
||||
if ( fc::character[i][fc::PC] < 0x1c )
|
||||
fc::character[i][fc::PC] = fc::character[i][fc::ASCII];
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(__NetBSD__) || defined(__OpenBSD__)
|
||||
//----------------------------------------------------------------------
|
||||
bool FTerm::saveWSConsEncoding()
|
||||
{
|
||||
static kbd_t k_encoding;
|
||||
int ret = ioctl(0, WSKBDIO_GETENCODING, &k_encoding);
|
||||
|
||||
if ( ret < 0 )
|
||||
return false;
|
||||
|
||||
// save current encoding
|
||||
wscons_keyboard_encoding = k_encoding;
|
||||
return true;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FTerm::setWSConsEncoding (kbd_t k_encoding)
|
||||
{
|
||||
if ( ioctl(0, WSKBDIO_SETENCODING, &k_encoding) < 0 )
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FTerm::setWSConsMetaEsc()
|
||||
{
|
||||
static const kbd_t meta_esc = 0x20; // generate ESC prefix on ALT-key
|
||||
|
||||
return setWSConsEncoding (wscons_keyboard_encoding | meta_esc);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FTerm::resetWSConsEncoding()
|
||||
{
|
||||
return setWSConsEncoding (wscons_keyboard_encoding);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FTerm::initWSConsConsole()
|
||||
{
|
||||
// initialize wscons console
|
||||
|
||||
if ( isWSConsConsole() )
|
||||
{
|
||||
// save current left alt key mapping
|
||||
saveWSConsEncoding();
|
||||
|
||||
// alt key generate ESC prefix
|
||||
setWSConsMetaEsc();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FTerm::init_global_values()
|
||||
{
|
||||
|
@ -2072,6 +1890,7 @@ void FTerm::init_termcap()
|
|||
static char string_buf[2048];
|
||||
char* buffer = string_buf;
|
||||
int status = uninitialized;
|
||||
bool color256 = term_detection->canDisplay256Colors();
|
||||
|
||||
// share the terminal capabilities
|
||||
FTermcap().setTermcapMap(tcap);
|
||||
|
@ -2631,7 +2450,7 @@ void FTerm::setInsertCursorStyle()
|
|||
#endif
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
||||
setFreeBSDConsoleCursorStyle (fc::destructive_cursor, isCursorHidden());
|
||||
freebsd->setCursorStyle (fc::destructive_cursor, isCursorHidden());
|
||||
#endif
|
||||
|
||||
if ( isUrxvtTerminal() )
|
||||
|
@ -2649,7 +2468,7 @@ void FTerm::setOverwriteCursorStyle()
|
|||
#endif
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
||||
setFreeBSDConsoleCursorStyle (fc::normal_cursor, isCursorHidden());
|
||||
freebsd->setCursorStyle (fc::normal_cursor, isCursorHidden());
|
||||
#endif
|
||||
|
||||
if ( isUrxvtTerminal() )
|
||||
|
@ -2741,6 +2560,11 @@ inline void FTerm::allocationValues()
|
|||
opti_attr = new FOptiAttr();
|
||||
term_detection = new FTermDetection();
|
||||
xterm = new FTermXTerminal();
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
||||
freebsd = new FTermFreeBSD();
|
||||
#endif
|
||||
|
||||
mouse = new FMouseControl();
|
||||
term = new FRect(0, 0, 0, 0);
|
||||
vt100_alt_char = new std::map<uChar, uChar>;
|
||||
|
@ -2774,6 +2598,11 @@ inline void FTerm::deallocationValues()
|
|||
if ( mouse )
|
||||
delete mouse;
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
||||
if ( freebsd )
|
||||
delete freebsd;
|
||||
#endif
|
||||
|
||||
if ( xterm )
|
||||
delete xterm;
|
||||
|
||||
|
@ -2918,12 +2747,12 @@ void FTerm::initOSspecifics()
|
|||
|
||||
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
||||
// Initialize BSD console
|
||||
initFreeBSDConsole();
|
||||
freebsd->init();
|
||||
#endif
|
||||
|
||||
#if defined(__NetBSD__) || defined(__OpenBSD__)
|
||||
// Initialize wscons console
|
||||
initWSConsConsole();
|
||||
openbsd->init();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -3011,12 +2840,11 @@ void FTerm::finishOSspecifics1()
|
|||
#endif
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
||||
resetFreeBSDAlt2Meta();
|
||||
setFreeBSDConsoleCursorStyle (fc::normal_cursor, false);
|
||||
freebsd->finish();
|
||||
#endif
|
||||
|
||||
#if defined(__NetBSD__) || defined(__OpenBSD__)
|
||||
resetWSConsEncoding();
|
||||
openbsd->finish();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -764,7 +764,7 @@ inline char* FTermDetection::secDA_Analysis_0 (char current_termtype[])
|
|||
terminal_type.putty = true; // PuTTY
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
||||
if ( FTerm::isFreeBSDConsole() )
|
||||
if ( FTermFreeBSD::isFreeBSDConsole() )
|
||||
terminal_type.freebsd_con = true;
|
||||
#endif
|
||||
|
||||
|
@ -803,7 +803,8 @@ inline char* FTermDetection::secDA_Analysis_24 (char current_termtype[])
|
|||
|
||||
#if defined(__NetBSD__) || defined(__OpenBSD__)
|
||||
|
||||
if ( secondary_da.terminal_id_version == 20 && FTerm::isWSConsConsole() )
|
||||
if ( secondary_da.terminal_id_version == 20
|
||||
&& FTermOpenBSD::isWSConsConsole() )
|
||||
{
|
||||
// NetBSD/OpenBSD workstation console
|
||||
if ( std::strncmp(termtype, C_STR("wsvt25"), 6) == 0 )
|
||||
|
|
|
@ -0,0 +1,193 @@
|
|||
/***********************************************************************
|
||||
* ftermfreebsd.cpp - Contains the FreeBSD terminal functions *
|
||||
* *
|
||||
* This file is part of the Final Cut widget toolkit *
|
||||
* *
|
||||
* Copyright 2018 Markus Gans *
|
||||
* *
|
||||
* The Final Cut is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Lesser General Public License *
|
||||
* as published by the Free Software Foundation; either version 3 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* The Final Cut is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Lesser General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this program. If not, see *
|
||||
* <http://www.gnu.org/licenses/>. *
|
||||
***********************************************************************/
|
||||
|
||||
#include "final/fcharmap.h"
|
||||
#include "final/ftermfreebsd.h"
|
||||
|
||||
// static class attributes
|
||||
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
||||
uInt FTermFreeBSD::bsd_alt_keymap = 0;
|
||||
FTermFreeBSD::CursorStyle FTermFreeBSD::cursor_style;
|
||||
#endif
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// class FTermFreeBSD
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
// constructors and destructor
|
||||
//----------------------------------------------------------------------
|
||||
FTermFreeBSD::FTermFreeBSD()
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FTermFreeBSD::~FTermFreeBSD() // destructor
|
||||
{ }
|
||||
|
||||
// public methods of FTermFreeBSD
|
||||
//----------------------------------------------------------------------
|
||||
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
||||
FTermFreeBSD::CursorStyle FTermFreeBSD::getCursorStyle()
|
||||
{
|
||||
return cursor_style;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FTermFreeBSD::setCursorStyle (CursorStyle style, bool hidden)
|
||||
{
|
||||
// Set cursor style in a BSD console
|
||||
|
||||
if ( ! isFreeBSDConsole() )
|
||||
return;
|
||||
|
||||
cursor_style = style;
|
||||
|
||||
if ( hidden )
|
||||
return;
|
||||
|
||||
ioctl(0, CONS_CURSORTYPE, &style);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FTermFreeBSD::isFreeBSDConsole()
|
||||
{
|
||||
// Check if it's a FreeBSD console
|
||||
|
||||
keymap_t keymap;
|
||||
|
||||
if ( ioctl(0, GIO_KEYMAP, &keymap) == 0 )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FTermFreeBSD::init()
|
||||
{
|
||||
// initialize BSD console
|
||||
|
||||
if ( ! isFreeBSDConsole() )
|
||||
return;
|
||||
|
||||
// save current left alt key mapping
|
||||
saveFreeBSDAltKey();
|
||||
|
||||
// map meta key to left alt key
|
||||
setFreeBSDAlt2Meta();
|
||||
|
||||
// Initialize FreeBSD console cursor
|
||||
setCursorStyle (fc::destructive_cursor, true);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FTermFreeBSD::initCharMap()
|
||||
{
|
||||
// A FreeBSD console can't show ASCII codes from 0x00 to 0x1b
|
||||
|
||||
if ( ! isFreeBSDConsole() )
|
||||
return;
|
||||
|
||||
for (int i = 0; i <= fc::lastCharItem; i++)
|
||||
if ( fc::character[i][fc::PC] < 0x1c )
|
||||
fc::character[i][fc::PC] = fc::character[i][fc::ASCII];
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FTermFreeBSD::finish()
|
||||
{
|
||||
// Resetting the FreeBSD console settings
|
||||
|
||||
if ( ! isFreeBSDConsole() )
|
||||
return;
|
||||
|
||||
resetFreeBSDAlt2Meta();
|
||||
setCursorStyle (fc::normal_cursor, false);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FTermFreeBSD::restoreCursorStyle()
|
||||
{
|
||||
// Reset to the last used FreeBSD console cursor style
|
||||
|
||||
setCursorStyle (getCursorStyle(), false);
|
||||
}
|
||||
|
||||
// private methods of FTermFreeBSD
|
||||
//----------------------------------------------------------------------
|
||||
bool FTermFreeBSD::saveFreeBSDAltKey()
|
||||
{
|
||||
// Saving the current mapping for the alt key
|
||||
|
||||
static const int left_alt = 0x38;
|
||||
int ret;
|
||||
keymap_t keymap;
|
||||
|
||||
ret = ioctl(0, GIO_KEYMAP, &keymap);
|
||||
|
||||
if ( ret < 0 )
|
||||
return false;
|
||||
|
||||
// save current mapping
|
||||
bsd_alt_keymap = keymap.key[left_alt].map[0];
|
||||
return true;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FTermFreeBSD::setFreeBSDAltKey (uInt key)
|
||||
{
|
||||
// Remapping the alt key
|
||||
|
||||
static const int left_alt = 0x38;
|
||||
int ret;
|
||||
keymap_t keymap;
|
||||
|
||||
ret = ioctl(0, GIO_KEYMAP, &keymap);
|
||||
|
||||
if ( ret < 0 )
|
||||
return false;
|
||||
|
||||
// map to meta key
|
||||
keymap.key[left_alt].map[0] = key;
|
||||
|
||||
if ( (keymap.n_keys > 0) && (ioctl(0, PIO_KEYMAP, &keymap) < 0) )
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FTermFreeBSD::setFreeBSDAlt2Meta()
|
||||
{
|
||||
// Use the meta key when pressing the Alt key
|
||||
|
||||
return setFreeBSDAltKey (META);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FTermFreeBSD::resetFreeBSDAlt2Meta()
|
||||
{
|
||||
// Restore the alt key mapping
|
||||
|
||||
return setFreeBSDAltKey (bsd_alt_keymap);
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,121 @@
|
|||
/***********************************************************************
|
||||
* ftermopenbsd.cpp - Contains the NetBSD/OpenBSD terminal functions *
|
||||
* *
|
||||
* This file is part of the Final Cut widget toolkit *
|
||||
* *
|
||||
* Copyright 2018 Markus Gans *
|
||||
* *
|
||||
* The Final Cut is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Lesser General Public License *
|
||||
* as published by the Free Software Foundation; either version 3 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* The Final Cut is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Lesser General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this program. If not, see *
|
||||
* <http://www.gnu.org/licenses/>. *
|
||||
***********************************************************************/
|
||||
|
||||
#include "final/ftermopenbsd.h"
|
||||
|
||||
// static class attributes
|
||||
#if defined(__NetBSD__) || defined(__OpenBSD__)
|
||||
kbd_t FTermOpenBSD::wscons_keyboard_encoding = 0;
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// class FTermOpenBSD
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
// constructors and destructor
|
||||
//----------------------------------------------------------------------
|
||||
FTermOpenBSD::FTermOpenBSD()
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FTermOpenBSD::~FTermOpenBSD() // destructor
|
||||
{ }
|
||||
|
||||
// public methods of FTermOpenBSD
|
||||
//----------------------------------------------------------------------
|
||||
#if defined(__NetBSD__) || defined(__OpenBSD__)
|
||||
bool FTermOpenBSD::isWSConsConsole()
|
||||
{
|
||||
// Check if it's a NetBSD/OpenBSD console
|
||||
|
||||
static kbd_t kbdencoding;
|
||||
|
||||
if ( ioctl(0, WSKBDIO_GETENCODING, &kbdencoding) == 0 )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FTermOpenBSD::init()
|
||||
{
|
||||
// initialize wscons console
|
||||
|
||||
if ( ! isWSConsConsole() )
|
||||
return;
|
||||
|
||||
// save current left alt key mapping
|
||||
saveWSConsEncoding();
|
||||
|
||||
// alt key generate ESC prefix
|
||||
setWSConsMetaEsc();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FTermOpenBSD::finish()
|
||||
{
|
||||
if ( ! isWSConsConsole() )
|
||||
return;
|
||||
|
||||
resetWSConsEncoding();
|
||||
}
|
||||
|
||||
|
||||
// private methods of FTermOpenBSD
|
||||
//----------------------------------------------------------------------
|
||||
bool FTermOpenBSD::saveWSConsEncoding()
|
||||
{
|
||||
static kbd_t k_encoding;
|
||||
int ret = ioctl(0, WSKBDIO_GETENCODING, &k_encoding);
|
||||
|
||||
if ( ret < 0 )
|
||||
return false;
|
||||
|
||||
// save current encoding
|
||||
wscons_keyboard_encoding = k_encoding;
|
||||
return true;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FTermOpenBSD::setWSConsEncoding (kbd_t k_encoding)
|
||||
{
|
||||
if ( ioctl(0, WSKBDIO_SETENCODING, &k_encoding) < 0 )
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FTermOpenBSD::setWSConsMetaEsc()
|
||||
{
|
||||
static const kbd_t meta_esc = 0x20; // generate ESC prefix on ALT-key
|
||||
|
||||
return setWSConsEncoding (wscons_keyboard_encoding | meta_esc);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FTermOpenBSD::resetWSConsEncoding()
|
||||
{
|
||||
return setWSConsEncoding (wscons_keyboard_encoding);
|
||||
}
|
||||
|
||||
#endif
|
|
@ -21,6 +21,7 @@
|
|||
***********************************************************************/
|
||||
|
||||
#include "final/fterm.h"
|
||||
#include "final/ftermfreebsd.h"
|
||||
#include "final/ftermxterminal.h"
|
||||
|
||||
// static class attributes
|
||||
|
@ -355,7 +356,7 @@ void FTermXTerminal::setXTermCursorStyle()
|
|||
// Set the xterm cursor style
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
||||
if ( FTerm::isFreeBSDConsole() )
|
||||
if ( FTermFreeBSD::isFreeBSDConsole() )
|
||||
return;
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1755,7 +1755,10 @@ void FVTerm::clearArea (term_area* area, int fillchar)
|
|||
nc.code = fillchar;
|
||||
|
||||
if ( ! (area && area->text) )
|
||||
{
|
||||
clearTerm (fillchar);
|
||||
return;
|
||||
}
|
||||
|
||||
w = uInt(area->width + area->right_shadow);
|
||||
|
||||
|
|
|
@ -210,6 +210,18 @@ void FStringTest::noArgumentTest()
|
|||
|
||||
empty.clear();
|
||||
CPPUNIT_ASSERT ( empty.isNull() );
|
||||
|
||||
const std::string* str1 = 0;
|
||||
FString s1(*str1);
|
||||
CPPUNIT_ASSERT ( s1.isEmpty() );
|
||||
CPPUNIT_ASSERT ( s1.isNull() );
|
||||
CPPUNIT_ASSERT ( ! s1 );
|
||||
|
||||
const FString* str2 = 0;
|
||||
FString s2(*str2);
|
||||
CPPUNIT_ASSERT ( s2.isEmpty() );
|
||||
CPPUNIT_ASSERT ( s2.isNull() );
|
||||
CPPUNIT_ASSERT ( ! s2 );
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in New Issue