diff --git a/ChangeLog b/ChangeLog index 6bd23b16..d31149ed 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2017-05-27 Markus Gans + * Move FreeBSD, NetBSD and OpenBSD functions to separate classes + 2017-05-20 Markus Gans * Methods outsourcing from FTerm to FTermXTerminal diff --git a/README.md b/README.md index 2dee49ee..a8ac1fef 100644 --- a/README.md +++ b/README.md @@ -117,13 +117,13 @@ printf(...) Class digramm -------------
-                                                ┌───────────┐
-                                           ┌────┤ FKeyEvent │
-                                           │    └───────────┘
-                                           │    ┌─────────────┐
-                                           ├────┤ FMouseEvent │
-                                           │    └─────────────┘
-              1┌────────────────┐          │    ┌─────────────┐
+              1┌──────────────┐                 ┌───────────┐
+   ┌-----------┤ FTermFreeBSD │            ┌────┤ FKeyEvent │
+   :           └──────────────┘            │    └───────────┘
+   :          1┌──────────────┐            │    ┌─────────────┐
+   ┌-----------┤ FTermOpenBSD │            ├────┤ FMouseEvent │
+   :           └──────────────┘            │    └─────────────┘
+   :          1┌────────────────┐          │    ┌─────────────┐
    ┌-----------┤ FTermDetection │          ├────┤ FWheelEvent │
    :           └────────────────┘          │    └─────────────┘
    :          1┌────────────────┐          │    ┌─────────────┐
diff --git a/doc/class-diagram.txt b/doc/class-diagram.txt
index 07430abf..6792b81b 100644
--- a/doc/class-diagram.txt
+++ b/doc/class-diagram.txt
@@ -2,13 +2,13 @@
                                  Class digramm
 ══════════════════════════════════════════════════════════════════════════════
 
-                                                ┌───────────┐
-                                           ┌────┤ FKeyEvent │
-                                           │    └───────────┘
-                                           │    ┌─────────────┐
-                                           ├────┤ FMouseEvent │
-                                           │    └─────────────┘
-              1┌────────────────┐          │    ┌─────────────┐
+              1┌──────────────┐                 ┌───────────┐
+   ┌-----------┤ FTermFreeBSD │            ┌────┤ FKeyEvent │
+   :           └──────────────┘            │    └───────────┘
+   :          1┌──────────────┐            │    ┌─────────────┐
+   ┌-----------┤ FTermOpenBSD │            ├────┤ FMouseEvent │
+   :           └──────────────┘            │    └─────────────┘
+   :          1┌────────────────┐          │    ┌─────────────┐
    ┌-----------┤ FTermDetection │          ├────┤ FWheelEvent │
    :           └────────────────┘          │    └─────────────┘
    :          1┌────────────────┐          │    ┌─────────────┐
diff --git a/doc/class_template.cpp b/doc/class_template.cpp
index 99d53d1a..39de0ef7 100644
--- a/doc/class_template.cpp
+++ b/doc/class_template.cpp
@@ -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
 //----------------------------------------------------------------------
 
diff --git a/doc/class_template.h b/doc/class_template.h
index d5528f6a..7a3372a2 100644
--- a/doc/class_template.h
+++ b/doc/class_template.h
@@ -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
 //----------------------------------------------------------------------
 
 
diff --git a/include/final/fcharmap.h b/include/final/fcharmap.h
index a1f0c7ac..e863216e 100644
--- a/include/final/fcharmap.h
+++ b/include/final/fcharmap.h
@@ -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  can be included directly."
 #endif
 
+#include "final/fc.h"
+#include "final/ftypes.h"
+
 namespace fc
 {
 
diff --git a/include/final/fterm.h b/include/final/fterm.h
index f75194cb..98b9751c 100644
--- a/include/final/fterm.h
+++ b/include/final/fterm.h
@@ -87,16 +87,6 @@
   #include 
 #endif
 
-#if defined(__FreeBSD__) || defined(__DragonFly__)
-  #include 
-  #include 
-#endif
-
-#if defined(__NetBSD__) || defined(__OpenBSD__)
-  #include 
-  #include 
-#endif
-
 #include 
 #include 
 
@@ -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)
diff --git a/include/final/ftermdetection.h b/include/final/ftermdetection.h
index 4176aaf0..96c08193 100644
--- a/include/final/ftermdetection.h
+++ b/include/final/ftermdetection.h
@@ -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; }
diff --git a/include/final/ftermfreebsd.h b/include/final/ftermfreebsd.h
new file mode 100644
index 00000000..75abbbdc
--- /dev/null
+++ b/include/final/ftermfreebsd.h
@@ -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                        *
+* .                                      *
+***********************************************************************/
+
+/*  Standalone class
+ *  ════════════════
+ *
+ * ▕▔▔▔▔▔▔▔▔▔▔▔▔▔▔▏
+ * ▕ FTermFreeBSD ▏
+ * ▕▁▁▁▁▁▁▁▁▁▁▁▁▁▁▏
+ */
+
+#ifndef FTERMFREEBSD_H
+#define FTERMFREEBSD_H
+
+#if !defined (USE_FINAL_H) && !defined (COMPILE_FINAL_CUT)
+  #error "Only  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 
+  #include 
+#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
+
+
diff --git a/include/final/ftermopenbsd.h b/include/final/ftermopenbsd.h
new file mode 100644
index 00000000..12d95826
--- /dev/null
+++ b/include/final/ftermopenbsd.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                        *
+* .                                      *
+***********************************************************************/
+
+/*  Standalone class
+ *  ════════════════
+ *
+ * ▕▔▔▔▔▔▔▔▔▔▔▔▔▔▔▏
+ * ▕ FTermOpenBSD ▏
+ * ▕▁▁▁▁▁▁▁▁▁▁▁▁▁▁▏
+ */
+
+#ifndef FTERMOPENBSD_H
+#define FTERMOPENBSD_H
+
+#if !defined (USE_FINAL_H) && !defined (COMPILE_FINAL_CUT)
+  #error "Only  can be included directly."
+#endif
+
+#include 
+
+#if defined(__NetBSD__) || defined(__OpenBSD__)
+  #include 
+  #include 
+#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
+
+
diff --git a/src/Makefile.am b/src/Makefile.am
index 89bb60b3..01740c44 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -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 \
diff --git a/src/Makefile.clang b/src/Makefile.clang
index 8d85252e..a1ec792c 100644
--- a/src/Makefile.clang
+++ b/src/Makefile.clang
@@ -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 \
diff --git a/src/Makefile.gcc b/src/Makefile.gcc
index 412073ad..7e305db1 100644
--- a/src/Makefile.gcc
+++ b/src/Makefile.gcc
@@ -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 \
diff --git a/src/Makefile.in b/src/Makefile.in
index 9d2fd131..2f7f6d76 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -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@
diff --git a/src/ffiledialog.cpp b/src/ffiledialog.cpp
index ecb3af74..80b8b007 100644
--- a/src/ffiledialog.cpp
+++ b/src/ffiledialog.cpp
@@ -502,7 +502,7 @@ void FFileDialog::initCallbacks()
 inline bool FFileDialog::pattern_match ( const char* const pattern
                                        , char fname[] )
 {
-  char search[128] = {};
+  char search[128] = { };
 
   if ( show_hidden && fname[0] == '.' && fname[1] != '\0' )  // hidden files
   {
@@ -695,8 +695,8 @@ void FFileDialog::followSymLink (const char* const dir, dir_entry& entry)
   if ( ! entry.symbolic_link )
     return;  // No symbolic link
 
-  char resolved_path[MAXPATHLEN] = {};
-  char symLink[MAXPATHLEN] = {};
+  char resolved_path[MAXPATHLEN] = { };
+  char symLink[MAXPATHLEN] = { };
   struct stat sb;
 
   std::strncpy (symLink, dir, sizeof(symLink) - 1);
diff --git a/src/foptimove.cpp b/src/foptimove.cpp
index 8aac08d6..cc258b42 100644
--- a/src/foptimove.cpp
+++ b/src/foptimove.cpp
@@ -726,7 +726,7 @@ int FOptiMove::relativeMove ( char move[]
 
   if ( to_x != from_x )  // horizontal move
   {
-    char hmove[BUF_SIZE] = {};
+    char hmove[BUF_SIZE] = { };
     htime = horizontalMove (hmove, from_x, to_x);
 
     if ( htime >= LONG_DURATION )
@@ -855,7 +855,7 @@ inline void FOptiMove::rightMove ( char hmove[], int& htime
 
   if ( F_cursor_right.cap )
   {
-    char str[BUF_SIZE] = {};
+    char str[BUF_SIZE] = { };
     int htime_r = 0;
     str[0] = '\0';
 
@@ -908,7 +908,7 @@ inline void FOptiMove::leftMove ( char hmove[], int& htime
 
   if ( F_cursor_left.cap )
   {
-    char str[BUF_SIZE] = {};
+    char str[BUF_SIZE] = { };
     int htime_l = 0;
     str[0] = '\0';
 
diff --git a/src/fstring.cpp b/src/fstring.cpp
index 5d6d2fb5..03c78a01 100644
--- a/src/fstring.cpp
+++ b/src/fstring.cpp
@@ -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"");
diff --git a/src/fterm.cpp b/src/fterm.cpp
index 41a174bb..fc148d07 100644
--- a/src/fterm.cpp
+++ b/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;
@@ -76,8 +74,8 @@ bool     FTerm::half_block_character;
 bool     FTerm::cursor_optimisation;
 bool     FTerm::hidden_cursor;
 bool     FTerm::use_alternate_screen = true;
-char     FTerm::termtype[256] = {};
-char     FTerm::termfilename[256] = {};
+char     FTerm::termtype[256] = { };
+char     FTerm::termfilename[256] = { };
 #if DEBUG
 int      FTerm::framebuffer_bpp = -1;
 #endif
@@ -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__)
 //----------------------------------------------------------------------
@@ -1328,7 +1283,7 @@ int FTerm::setBlinkAsIntensity (bool on)
 #endif
 
 //----------------------------------------------------------------------
-int FTerm::getFramebuffer_bpp ()
+int FTerm::getFramebuffer_bpp()
 {
   int fd = -1;
   struct fb_var_screeninfo fb_var;
@@ -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;
@@ -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
 }
 
@@ -3159,7 +2987,7 @@ inline int FTerm::getSingleKey (char buffer[], int buf_size)
   // Look for a utf-8 character
   if ( utf8_input && (firstchar & 0xc0) == 0xc0 )
   {
-    char utf8char[4] = {};  // Init array with '\0'
+    char utf8char[4] = { };  // Init array with '\0'
 
     if ( (firstchar & 0xe0) == 0xc0 )
       len = 2;
diff --git a/src/ftermcapquirks.cpp b/src/ftermcapquirks.cpp
index b8d9f068..bc028085 100644
--- a/src/ftermcapquirks.cpp
+++ b/src/ftermcapquirks.cpp
@@ -23,7 +23,7 @@
 #include "final/ftermcapquirks.h"
 
 // static class attributes
-char                FTermcapQuirks::termtype[256]  = {};
+char                FTermcapQuirks::termtype[256]  = { };
 FTermcap::tcap_map* FTermcapQuirks::tcap           = 0;
 FTermDetection*     FTermcapQuirks::term_detection = 0;
 
diff --git a/src/ftermdetection.cpp b/src/ftermdetection.cpp
index 5b0528b7..9c0c39eb 100644
--- a/src/ftermdetection.cpp
+++ b/src/ftermdetection.cpp
@@ -28,8 +28,8 @@ FTermDetection::terminalType FTermDetection::terminal_type = \
     { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
 FTermDetection::colorEnv     FTermDetection::color_env;
 FTermDetection::secondaryDA  FTermDetection::secondary_da;
-char           FTermDetection::termtype[256] = {};
-char           FTermDetection::termfilename[256] = {};
+char           FTermDetection::termtype[256] = { };
+char           FTermDetection::termfilename[256] = { };
 bool           FTermDetection::decscusr_support;
 bool           FTermDetection::terminal_detection;
 bool           FTermDetection::color256;
@@ -38,9 +38,9 @@ const FString* FTermDetection::sec_da      = 0;
 int            FTermDetection::gnome_terminal_id;
 
 #if DEBUG
-  char FTermDetection::termtype_256color[256]   = {};
-  char FTermDetection::termtype_Answerback[256] = {};
-  char FTermDetection::termtype_SecDA[256]      = {};
+  char FTermDetection::termtype_256color[256]   = { };
+  char FTermDetection::termtype_Answerback[256] = { };
+  char FTermDetection::termtype_SecDA[256]      = { };
 #endif
 
 
@@ -469,7 +469,7 @@ const FString FTermDetection::getXTermColorName (int color)
   struct timeval tv;
   int stdin_no = FTermios::getStdIn();
 
-  char temp[512] = {};
+  char temp[512] = { };
   FTerm::putstringf (OSC "4;%d;?" BEL, color);  // get color
   std::fflush(stdout);
 
@@ -547,7 +547,7 @@ const FString FTermDetection::getAnswerbackMsg()
 
   fd_set ifds;
   struct timeval tv;
-  char temp[10] = {};
+  char temp[10] = { };
   int stdin_no = FTermios::getStdIn();
 
   std::putchar (ENQ[0]);  // Send enquiry character
@@ -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 )
diff --git a/src/ftermfreebsd.cpp b/src/ftermfreebsd.cpp
new file mode 100644
index 00000000..5b9a0019
--- /dev/null
+++ b/src/ftermfreebsd.cpp
@@ -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                        *
+* .                                      *
+***********************************************************************/
+
+#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
diff --git a/src/ftermopenbsd.cpp b/src/ftermopenbsd.cpp
new file mode 100644
index 00000000..468cde27
--- /dev/null
+++ b/src/ftermopenbsd.cpp
@@ -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                        *
+* .                                      *
+***********************************************************************/
+
+#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
diff --git a/src/ftermxterminal.cpp b/src/ftermxterminal.cpp
index 69a953b6..0656cb03 100644
--- a/src/ftermxterminal.cpp
+++ b/src/ftermxterminal.cpp
@@ -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
 
@@ -780,7 +781,7 @@ const FString* FTermXTerminal::captureXTermFont()
     // Read the terminal answer
     if ( select(stdin_no + 1, &ifds, 0, 0, &tv) > 0 )
     {
-      char temp[150] = {};
+      char temp[150] = { };
 
       if ( std::scanf("\033]50;%148[^\n]s", temp) == 1 )
       {
@@ -830,7 +831,7 @@ const FString* FTermXTerminal::captureXTermTitle()
   // read the terminal answer
   if ( select (stdin_no + 1, &ifds, 0, 0, &tv) > 0 )
   {
-    char temp[512] = {};
+    char temp[512] = { };
 
     if ( std::scanf("\033]l%509[^\n]s", temp) == 1 )
     {
diff --git a/src/fvterm.cpp b/src/fvterm.cpp
index 98fb49e5..8904c8a2 100644
--- a/src/fvterm.cpp
+++ b/src/fvterm.cpp
@@ -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);
 
diff --git a/src/test/fstring-test.cpp b/src/test/fstring-test.cpp
index 71e358ee..dda71be3 100644
--- a/src/test/fstring-test.cpp
+++ b/src/test/fstring-test.cpp
@@ -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 );
 }
 
 //----------------------------------------------------------------------