2017-11-04 07:03:53 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* fterm.h - Base class for terminal detection and control *
|
|
|
|
* *
|
|
|
|
* This file is part of the Final Cut widget toolkit *
|
|
|
|
* *
|
2018-01-02 20:38:45 +01:00
|
|
|
* Copyright 2012-2018 Markus Gans *
|
2017-11-04 07:03:53 +01:00
|
|
|
* *
|
|
|
|
* 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/>. *
|
|
|
|
***********************************************************************/
|
2017-10-02 07:32:33 +02:00
|
|
|
|
|
|
|
/* Base class
|
|
|
|
* ══════════
|
|
|
|
*
|
|
|
|
* ▕▔▔▔▔▔▔▔▏1 1▕▔▔▔▔▔▔▔▔▔▔▔▏
|
|
|
|
* ▕ FTerm ▏-┬- - - -▕ FOptiMove ▏
|
|
|
|
* ▕▁▁▁▁▁▁▁▏ : ▕▁▁▁▁▁▁▁▁▁▁▁▏
|
|
|
|
* :
|
|
|
|
* : 1▕▔▔▔▔▔▔▔▔▔▔▔▏
|
|
|
|
* :- - - -▕ FOptiAttr ▏
|
|
|
|
* : ▕▁▁▁▁▁▁▁▁▁▁▁▏
|
|
|
|
* :
|
|
|
|
* : *▕▔▔▔▔▔▔▔▔▔▏
|
|
|
|
* :- - - -▕ FString ▏
|
|
|
|
* : ▕▁▁▁▁▁▁▁▁▁▏
|
|
|
|
* :
|
|
|
|
* : *▕▔▔▔▔▔▔▔▔▏
|
|
|
|
* :- - - -▕ FPoint ▏
|
|
|
|
* : ▕▁▁▁▁▁▁▁▁▏
|
|
|
|
* :
|
|
|
|
* : *▕▔▔▔▔▔▔▔▏
|
|
|
|
* └- - - -▕ FRect ▏
|
|
|
|
* ▕▁▁▁▁▁▁▁▏
|
|
|
|
*/
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2017-04-09 20:08:53 +02:00
|
|
|
#ifndef FTERM_H
|
|
|
|
#define FTERM_H
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2017-10-31 00:41:59 +01:00
|
|
|
#if !defined (USE_FINAL_H) && !defined (COMPILE_FINAL_CUT)
|
|
|
|
#error "Only <final/final.h> can be included directly."
|
|
|
|
#endif
|
|
|
|
|
2017-09-17 21:32:46 +02:00
|
|
|
#include "final/fconfig.h"
|
2015-08-22 18:53:52 +02:00
|
|
|
|
2017-03-26 20:40:04 +02:00
|
|
|
#if defined(__linux__)
|
2017-09-11 03:06:02 +02:00
|
|
|
#include <linux/fb.h> // Linux framebuffer console
|
2017-11-22 23:56:21 +01:00
|
|
|
|
|
|
|
#if defined(__x86_64__) || defined(__i386) || defined(__arm__)
|
|
|
|
#include <sys/io.h> // <asm/io.h> is deprecated
|
|
|
|
#endif
|
|
|
|
|
2017-03-26 20:40:04 +02:00
|
|
|
#include <sys/kd.h>
|
|
|
|
#endif
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2017-04-09 20:08:53 +02:00
|
|
|
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
2017-04-06 01:31:21 +02:00
|
|
|
#include <sys/consio.h>
|
2017-03-28 08:50:37 +02:00
|
|
|
#include <sys/kbio.h>
|
|
|
|
#endif
|
|
|
|
|
2017-04-14 23:55:44 +02:00
|
|
|
#if defined(__NetBSD__) || defined(__OpenBSD__)
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include <dev/wscons/wsconsio.h>
|
|
|
|
#endif
|
|
|
|
|
2015-08-09 23:39:12 +02:00
|
|
|
#include <sys/ioctl.h>
|
2016-10-14 13:02:35 +02:00
|
|
|
#include <sys/stat.h>
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <langinfo.h>
|
2018-01-14 21:21:08 +01:00
|
|
|
|
2017-12-17 01:06:53 +01:00
|
|
|
#if defined(__sun) && defined(__SVR4)
|
|
|
|
#include <termio.h>
|
|
|
|
typedef struct termio SGTTY;
|
|
|
|
typedef struct termios SGTTYS;
|
|
|
|
|
|
|
|
#ifdef _LP64
|
|
|
|
typedef unsigned int chtype;
|
|
|
|
#else
|
|
|
|
typedef unsigned long chtype;
|
|
|
|
#endif
|
|
|
|
|
2018-01-22 19:47:20 +01:00
|
|
|
#include <term.h> // termcap
|
2017-12-17 01:06:53 +01:00
|
|
|
#else
|
2018-01-22 19:47:20 +01:00
|
|
|
#include <term.h> // termcap
|
2017-12-17 01:06:53 +01:00
|
|
|
#endif
|
|
|
|
|
2018-01-14 21:21:08 +01:00
|
|
|
#ifdef F_HAVE_LIBGPM
|
|
|
|
#undef buttons // from term.h
|
|
|
|
#endif
|
|
|
|
|
2017-12-14 00:35:10 +01:00
|
|
|
#if F_HAVE_GETTTYNAM && F_HAVE_TTYENT_H
|
|
|
|
#include <ttyent.h>
|
|
|
|
#endif
|
|
|
|
|
2017-04-09 20:08:53 +02:00
|
|
|
#include <clocale>
|
2015-05-23 13:35:12 +02:00
|
|
|
#include <cmath>
|
|
|
|
#include <csignal>
|
|
|
|
#include <map>
|
|
|
|
#include <queue>
|
2017-09-11 03:06:02 +02:00
|
|
|
#include <string>
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2017-09-17 21:32:46 +02:00
|
|
|
#include "final/fc.h"
|
2018-01-24 23:02:45 +01:00
|
|
|
#include "final/fcolorpalette.h"
|
2018-01-14 21:21:08 +01:00
|
|
|
#include "final/fmouse.h"
|
2017-09-17 21:32:46 +02:00
|
|
|
#include "final/fobject.h"
|
|
|
|
#include "final/foptiattr.h"
|
|
|
|
#include "final/foptimove.h"
|
|
|
|
#include "final/fpoint.h"
|
|
|
|
#include "final/frect.h"
|
|
|
|
#include "final/fstring.h"
|
|
|
|
#include "final/ftermcap.h"
|
2018-05-02 12:31:21 +02:00
|
|
|
#include "final/ftermcapquirks.h"
|
|
|
|
#include "final/ftermdetection.h"
|
|
|
|
#include "final/ftermios.h"
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// class FTerm
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
#pragma pack(push)
|
|
|
|
#pragma pack(1)
|
|
|
|
|
|
|
|
class FTerm
|
|
|
|
{
|
2017-09-11 03:06:02 +02:00
|
|
|
public:
|
|
|
|
// Typedefs
|
|
|
|
typedef FOptiAttr::char_data char_data;
|
|
|
|
|
2017-12-02 18:52:51 +01:00
|
|
|
#if defined(__linux__)
|
2017-09-11 03:06:02 +02:00
|
|
|
static struct modifier_key // bit field
|
|
|
|
{
|
|
|
|
uChar shift : 1; // 0..1
|
|
|
|
uChar alt_gr : 1; // 0..1
|
|
|
|
uChar ctrl : 1; // 0..1
|
|
|
|
uChar alt : 1; // 0..1
|
|
|
|
uChar : 4; // padding bits
|
|
|
|
} mod_key;
|
2017-12-02 18:52:51 +01:00
|
|
|
#endif
|
2017-09-11 03:06:02 +02:00
|
|
|
|
|
|
|
// Constructor
|
|
|
|
explicit FTerm (bool = false);
|
|
|
|
|
|
|
|
// Destructor
|
|
|
|
virtual ~FTerm();
|
|
|
|
|
|
|
|
// Accessors
|
|
|
|
virtual const char* getClassName() const;
|
|
|
|
static termios getTTY();
|
|
|
|
static int getLineNumber();
|
|
|
|
static int getColumnNumber();
|
|
|
|
static const FString getKeyName (int);
|
2018-01-14 21:21:08 +01:00
|
|
|
static FMouseControl* getMouseControl();
|
2017-04-06 01:31:21 +02:00
|
|
|
|
2017-03-26 20:40:04 +02:00
|
|
|
#if defined(__linux__)
|
2017-09-11 03:06:02 +02:00
|
|
|
static modifier_key& getLinuxModifierKey();
|
2017-03-26 20:40:04 +02:00
|
|
|
#endif
|
2017-04-06 01:31:21 +02:00
|
|
|
|
2017-09-11 03:06:02 +02:00
|
|
|
static char* getTermType();
|
2018-02-11 23:41:23 +01:00
|
|
|
static char* getTermFileName();
|
2017-09-11 03:06:02 +02:00
|
|
|
static int getTabstop();
|
|
|
|
static int getMaxColor();
|
2017-04-06 01:31:21 +02:00
|
|
|
|
|
|
|
#if defined(__linux__)
|
2017-09-11 03:06:02 +02:00
|
|
|
static fc::linuxConsoleCursorStyle getLinuxConsoleCursorStyle();
|
2017-04-06 01:31:21 +02:00
|
|
|
#endif
|
|
|
|
|
2017-04-09 20:08:53 +02:00
|
|
|
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
2017-09-11 03:06:02 +02:00
|
|
|
static fc::freebsdConsoleCursorStyle getFreeBSDConsoleCursorStyle();
|
2017-04-06 01:31:21 +02:00
|
|
|
#endif
|
2016-11-02 00:37:58 +01:00
|
|
|
|
2017-03-26 20:40:04 +02:00
|
|
|
#if DEBUG
|
2017-09-11 03:06:02 +02:00
|
|
|
static const FString& getAnswerbackString();
|
|
|
|
static const FString& getSecDAString();
|
2018-05-02 12:31:21 +02:00
|
|
|
static const char* getTermType_256color();
|
|
|
|
static const char* getTermType_Answerback();
|
|
|
|
static const char* getTermType_SecDA();
|
|
|
|
static int getFramebufferBpp();
|
2017-03-26 20:40:04 +02:00
|
|
|
#endif
|
|
|
|
|
2017-09-11 03:06:02 +02:00
|
|
|
// Inquiries
|
2018-01-03 08:42:10 +01:00
|
|
|
static bool isKeypressTimeout (timeval*);
|
2017-09-11 03:06:02 +02:00
|
|
|
static bool isNormal (char_data*&);
|
|
|
|
static bool isRaw();
|
|
|
|
static bool hasPCcharset();
|
|
|
|
static bool hasUTF8();
|
|
|
|
static bool hasVT100();
|
|
|
|
static bool hasASCII();
|
|
|
|
static bool isMonochron();
|
|
|
|
static bool isXTerminal();
|
|
|
|
static bool isAnsiTerminal();
|
|
|
|
static bool isRxvtTerminal();
|
|
|
|
static bool isUrxvtTerminal();
|
|
|
|
static bool isMltermTerminal();
|
|
|
|
static bool isPuttyTerminal();
|
|
|
|
static bool isKdeTerminal();
|
|
|
|
static bool isGnomeTerminal();
|
|
|
|
static bool isKtermTerminal();
|
|
|
|
static bool isTeraTerm();
|
2017-12-14 00:35:10 +01:00
|
|
|
static bool isSunTerminal();
|
2017-09-11 03:06:02 +02:00
|
|
|
static bool isCygwinTerminal();
|
|
|
|
static bool isMinttyTerm();
|
|
|
|
static bool isLinuxTerm();
|
2018-05-02 12:31:21 +02:00
|
|
|
static bool isFreeBSDTerm();
|
2018-04-19 01:55:17 +02:00
|
|
|
static bool isNetBSDTerm();
|
|
|
|
static bool isOpenBSDTerm();
|
2017-09-11 03:06:02 +02:00
|
|
|
static bool isScreenTerm();
|
|
|
|
static bool isTmuxTerm();
|
|
|
|
static bool isInputDataPending();
|
|
|
|
static bool isNewFont();
|
|
|
|
static bool isUTF8();
|
|
|
|
|
|
|
|
// Mutators
|
2018-05-02 12:31:21 +02:00
|
|
|
static void setTermType (char[]);
|
2017-09-11 03:06:02 +02:00
|
|
|
static bool setCursorOptimisation (bool);
|
|
|
|
static void setXTermDefaultColors (bool);
|
2017-04-06 01:31:21 +02:00
|
|
|
|
|
|
|
#if defined(__linux__)
|
2017-09-11 03:06:02 +02:00
|
|
|
static void setLinuxConsoleCursorStyle \
|
2017-11-30 02:38:55 +01:00
|
|
|
(fc::linuxConsoleCursorStyle, bool);
|
2017-04-06 01:31:21 +02:00
|
|
|
#endif
|
|
|
|
|
2017-04-09 20:08:53 +02:00
|
|
|
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
2017-09-11 03:06:02 +02:00
|
|
|
static void setFreeBSDConsoleCursorStyle \
|
2017-11-30 02:38:55 +01:00
|
|
|
(fc::freebsdConsoleCursorStyle, bool);
|
2017-04-06 01:31:21 +02:00
|
|
|
#endif
|
|
|
|
|
2018-01-03 08:42:10 +01:00
|
|
|
static void setKeypressTimeout (const long);
|
|
|
|
static void setDblclickInterval (const long);
|
2017-09-11 03:06:02 +02:00
|
|
|
static void disableAltScreen();
|
|
|
|
static bool setUTF8 (bool);
|
|
|
|
static bool setUTF8();
|
|
|
|
static bool unsetUTF8();
|
|
|
|
static bool setNonBlockingInput (bool);
|
|
|
|
static bool setNonBlockingInput();
|
|
|
|
static bool unsetNonBlockingInput();
|
|
|
|
|
|
|
|
// Methods
|
|
|
|
static int parseKeyString (char[], int, timeval*);
|
|
|
|
static bool& unprocessedInput();
|
|
|
|
static bool setVGAFont();
|
|
|
|
static bool setNewFont();
|
|
|
|
static bool setOldFont();
|
|
|
|
static char* moveCursor (int, int, int, int);
|
|
|
|
static void printMoveDurations();
|
|
|
|
static char* enableCursor();
|
|
|
|
static char* disableCursor();
|
|
|
|
static void detectTermSize();
|
|
|
|
static void setTermSize (int, int);
|
|
|
|
static void setKDECursor (fc::kdeKonsoleCursorShape);
|
|
|
|
static const FString* getXTermFont();
|
|
|
|
static const FString* getXTermTitle();
|
|
|
|
static void setXTermCursorStyle (fc::xtermCursorStyle);
|
|
|
|
static void setXTermTitle (const FString&);
|
|
|
|
static void setXTermForeground (const FString&);
|
|
|
|
static void setXTermBackground (const FString&);
|
|
|
|
static void setXTermCursorColor (const FString&);
|
|
|
|
static void setXTermMouseForeground (const FString&);
|
|
|
|
static void setXTermMouseBackground (const FString&);
|
|
|
|
static void setXTermHighlightBackground (const FString&);
|
|
|
|
static void setXTermDefaults();
|
|
|
|
static void resetXTermColors();
|
|
|
|
static void resetXTermForeground();
|
|
|
|
static void resetXTermBackground();
|
|
|
|
static void resetXTermCursorColor();
|
|
|
|
static void resetXTermMouseForeground();
|
|
|
|
static void resetXTermMouseBackground();
|
|
|
|
static void resetXTermHighlightBackground();
|
|
|
|
static void resetXTermDefaults();
|
|
|
|
static void saveColorMap();
|
|
|
|
static void resetColorMap();
|
|
|
|
static void setPalette (short, int, int, int);
|
|
|
|
static void setBeep (int, int);
|
|
|
|
static void resetBeep();
|
|
|
|
static void beep();
|
|
|
|
|
2017-11-18 02:34:41 +01:00
|
|
|
static void setEncoding (fc::encoding);
|
|
|
|
static fc::encoding getEncoding();
|
|
|
|
static std::string getEncodingString();
|
2017-09-11 03:06:02 +02:00
|
|
|
|
|
|
|
static bool scrollTermForward();
|
|
|
|
static bool scrollTermReverse();
|
|
|
|
|
|
|
|
// function pointer -> static function
|
|
|
|
static int (*Fputchar)(int);
|
|
|
|
|
2017-12-25 21:17:08 +01:00
|
|
|
static void putstringf (const char[], ...)
|
2017-09-11 03:06:02 +02:00
|
|
|
#if defined(__clang__)
|
|
|
|
__attribute__((__format__ (__printf__, 1, 2)))
|
|
|
|
#elif defined(__GNUC__)
|
|
|
|
__attribute__ ((format (printf, 1, 2)))
|
|
|
|
#endif
|
|
|
|
;
|
2017-12-25 21:17:08 +01:00
|
|
|
static void putstring (const char[], int = 1);
|
2017-12-17 01:06:53 +01:00
|
|
|
|
|
|
|
#if defined(__sun) && defined(__SVR4)
|
|
|
|
static int putchar_ASCII (register char);
|
|
|
|
#endif
|
|
|
|
|
2017-09-11 03:06:02 +02:00
|
|
|
static int putchar_ASCII (register int);
|
|
|
|
static int putchar_UTF8 (register int);
|
|
|
|
static int UTF8decode (const char[]);
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2017-03-26 20:40:04 +02:00
|
|
|
#if DEBUG
|
2017-11-24 00:28:25 +01:00
|
|
|
static int framebuffer_bpp;
|
2017-03-26 20:40:04 +02:00
|
|
|
#endif
|
|
|
|
|
2017-09-11 03:06:02 +02:00
|
|
|
protected:
|
|
|
|
// Methods
|
2017-03-26 20:40:04 +02:00
|
|
|
#if defined(__linux__)
|
2017-09-11 03:06:02 +02:00
|
|
|
static void initLinuxConsoleCharMap();
|
2017-03-26 20:40:04 +02:00
|
|
|
#endif
|
2017-04-02 13:30:23 +02:00
|
|
|
|
2017-04-09 20:08:53 +02:00
|
|
|
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
2017-09-11 03:06:02 +02:00
|
|
|
static void initFreeBSDConsoleCharMap();
|
2017-04-02 21:32:48 +02:00
|
|
|
#endif
|
2017-04-14 23:55:44 +02:00
|
|
|
|
2017-09-11 03:06:02 +02:00
|
|
|
static bool charEncodable (uInt);
|
|
|
|
static uInt charEncode (uInt);
|
|
|
|
static uInt charEncode (uInt, fc::encoding);
|
|
|
|
static char* changeAttribute ( char_data*&
|
|
|
|
, char_data*& );
|
|
|
|
static bool hasChangedTermSize();
|
|
|
|
static void changeTermSizeFinished();
|
|
|
|
static void xtermMetaSendsESC (bool);
|
2017-12-10 15:36:02 +01:00
|
|
|
static void exitWithMessage (std::string)
|
|
|
|
#if defined(__clang__) || defined(__GNUC__)
|
|
|
|
__attribute__((noreturn))
|
|
|
|
#endif
|
|
|
|
;
|
2017-09-11 03:06:02 +02:00
|
|
|
// Data Members
|
|
|
|
static int erase_ch_length;
|
|
|
|
static int repeat_char_length;
|
|
|
|
static int clr_bol_length;
|
|
|
|
static int clr_eol_length;
|
|
|
|
static int cursor_addres_lengths;
|
|
|
|
static bool NewFont;
|
|
|
|
static bool VGAFont;
|
|
|
|
static bool no_shadow_character;
|
|
|
|
static bool no_half_block_character;
|
|
|
|
static bool cursor_optimisation;
|
|
|
|
static bool xterm_default_colors;
|
|
|
|
static bool use_alternate_screen;
|
2017-11-18 02:34:41 +01:00
|
|
|
static fc::encoding term_encoding;
|
2017-09-11 03:06:02 +02:00
|
|
|
static char exit_message[8192];
|
|
|
|
|
2017-11-18 02:34:41 +01:00
|
|
|
static struct initializationValues
|
|
|
|
{
|
|
|
|
public:
|
2017-12-10 15:36:02 +01:00
|
|
|
void setDefault()
|
|
|
|
{
|
|
|
|
terminal_detection = true;
|
|
|
|
cursor_optimisation = true;
|
|
|
|
color_change = true;
|
|
|
|
vgafont = false;
|
|
|
|
newfont = false;
|
|
|
|
encoding = fc::UNKNOWN;
|
|
|
|
}
|
2017-11-18 02:34:41 +01:00
|
|
|
|
|
|
|
uInt8 terminal_detection : 1;
|
|
|
|
uInt8 cursor_optimisation : 1;
|
|
|
|
uInt8 color_change : 1;
|
|
|
|
uInt8 vgafont : 1;
|
|
|
|
uInt8 newfont : 1;
|
|
|
|
uInt8 : 3; // padding bits
|
|
|
|
fc::encoding encoding;
|
|
|
|
} init_values;
|
|
|
|
|
2017-09-11 03:06:02 +02:00
|
|
|
private:
|
|
|
|
// Typedefs
|
|
|
|
typedef FTermcap::tcap_map termcap_map;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
uChar red;
|
|
|
|
uChar green;
|
|
|
|
uChar blue;
|
|
|
|
} dacreg;
|
|
|
|
|
|
|
|
// Constants
|
|
|
|
static const int NEED_MORE_DATA = -1; // parseKeyString return value
|
|
|
|
|
|
|
|
// Disable copy constructor
|
|
|
|
FTerm (const FTerm&);
|
|
|
|
// Disable assignment operator (=)
|
|
|
|
FTerm& operator = (const FTerm&);
|
|
|
|
|
2017-03-28 08:50:37 +02:00
|
|
|
#if defined(__linux__)
|
2017-09-11 03:06:02 +02:00
|
|
|
static int isLinuxConsole();
|
2017-03-28 08:50:37 +02:00
|
|
|
#endif
|
2017-04-02 13:30:23 +02:00
|
|
|
|
2017-04-09 20:08:53 +02:00
|
|
|
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
2017-09-11 03:06:02 +02:00
|
|
|
static bool isFreeBSDConsole();
|
2017-04-14 23:55:44 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(__NetBSD__) || defined(__OpenBSD__)
|
2017-09-11 03:06:02 +02:00
|
|
|
static bool isWSConsConsole();
|
2017-04-02 13:30:23 +02:00
|
|
|
#endif
|
2016-11-05 23:12:05 +01:00
|
|
|
|
2017-09-11 03:06:02 +02:00
|
|
|
// Methods
|
2017-03-28 08:50:37 +02:00
|
|
|
#if defined(__linux__)
|
2017-11-22 23:56:21 +01:00
|
|
|
#if defined(__x86_64__) || defined(__i386) || defined(__arm__)
|
2017-09-11 03:06:02 +02:00
|
|
|
static uInt16 getInputStatusRegisterOne();
|
|
|
|
static uChar readAttributeController (uChar);
|
|
|
|
static void writeAttributeController (uChar, uChar);
|
|
|
|
static uChar getAttributeMode();
|
|
|
|
static void setAttributeMode (uChar);
|
|
|
|
static int setBlinkAsIntensity (bool);
|
2017-11-22 23:56:21 +01:00
|
|
|
#endif
|
2017-09-11 03:06:02 +02:00
|
|
|
static int getFramebuffer_bpp();
|
2017-03-26 20:40:04 +02:00
|
|
|
#endif
|
2017-03-28 08:50:37 +02:00
|
|
|
|
2017-09-11 03:06:02 +02:00
|
|
|
static int openConsole();
|
|
|
|
static int closeConsole();
|
2017-03-28 08:50:37 +02:00
|
|
|
|
2017-03-26 20:40:04 +02:00
|
|
|
#if defined(__linux__)
|
2017-09-11 03:06:02 +02:00
|
|
|
static int getScreenFont();
|
2017-12-25 21:17:08 +01:00
|
|
|
static int setScreenFont ( uChar[], uInt, uInt, uInt
|
2017-09-11 03:06:02 +02:00
|
|
|
, bool = false );
|
|
|
|
static int setUnicodeMap (struct unimapdesc*);
|
|
|
|
static int getUnicodeMap ();
|
|
|
|
static void initLinuxConsole();
|
2017-04-02 13:30:23 +02:00
|
|
|
#endif
|
|
|
|
|
2017-04-09 20:08:53 +02:00
|
|
|
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
2017-09-11 03:06:02 +02:00
|
|
|
static bool saveFreeBSDAltKey();
|
|
|
|
static bool setFreeBSDAltKey (uInt);
|
|
|
|
static bool setFreeBSDAlt2Meta();
|
|
|
|
static bool resetFreeBSDAlt2Meta();
|
|
|
|
static void initFreeBSDConsole();
|
2017-03-26 20:40:04 +02:00
|
|
|
#endif
|
2017-03-28 08:50:37 +02:00
|
|
|
|
2017-04-14 23:55:44 +02:00
|
|
|
#if defined(__NetBSD__) || defined(__OpenBSD__)
|
2017-09-11 03:06:02 +02:00
|
|
|
static bool saveWSConsEncoding();
|
|
|
|
static bool setWSConsEncoding (kbd_t);
|
|
|
|
static bool setWSConsMetaEsc();
|
|
|
|
static bool resetWSConsEncoding();
|
|
|
|
static void initWSConsConsole();
|
2017-04-14 23:55:44 +02:00
|
|
|
#endif
|
|
|
|
|
2017-11-18 02:34:41 +01:00
|
|
|
static void init_global_values();
|
2017-09-11 03:06:02 +02:00
|
|
|
static void oscPrefix();
|
|
|
|
static void oscPostfix();
|
|
|
|
static void init_alt_charset();
|
|
|
|
static void init_pc_charset();
|
2017-11-18 02:34:41 +01:00
|
|
|
static void init_cygwin_charmap();
|
|
|
|
static void init_teraterm_charmap();
|
2018-05-02 12:31:21 +02:00
|
|
|
static void init_fixed_max_color();
|
|
|
|
static void init_termcap();
|
|
|
|
static void init_termcap_error (int);
|
|
|
|
static void init_termcap_variables(char*&);
|
|
|
|
static void init_termcap_booleans();
|
|
|
|
static void init_termcap_numerics();
|
|
|
|
static void init_termcap_strings (char*&);
|
|
|
|
static void init_termcap_keys (char*&);
|
2017-11-18 21:03:02 +01:00
|
|
|
static void init_OptiMove();
|
|
|
|
static void init_OptiAttr();
|
2017-11-26 19:00:04 +01:00
|
|
|
static void init_font();
|
2017-11-18 02:34:41 +01:00
|
|
|
static void init_locale();
|
2017-09-11 03:06:02 +02:00
|
|
|
static void init_encoding();
|
2018-02-19 23:02:54 +01:00
|
|
|
static void init_encoding_set();
|
|
|
|
static void init_term_encoding();
|
|
|
|
static void init_individual_term_encoding();
|
|
|
|
static bool init_force_vt100_encoding();
|
|
|
|
static void init_utf8_without_alt_charset();
|
|
|
|
static void init_tab_quirks();
|
2017-11-18 02:34:41 +01:00
|
|
|
static void redefineColorPalette();
|
|
|
|
static void restoreColorPalette();
|
2017-11-26 19:00:04 +01:00
|
|
|
static void enableMouse();
|
|
|
|
static void disableMouse();
|
2018-02-04 19:42:30 +01:00
|
|
|
static void useAlternateScreenBuffer();
|
|
|
|
static void useNormalScreenBuffer();
|
2017-11-26 19:00:04 +01:00
|
|
|
static void captureXTermFontAndTitle();
|
2017-12-21 00:45:04 +01:00
|
|
|
void allocationValues();
|
|
|
|
void deallocationValues();
|
2017-09-11 03:06:02 +02:00
|
|
|
void init();
|
2018-02-04 19:42:30 +01:00
|
|
|
void initOSspecifics();
|
2017-09-11 03:06:02 +02:00
|
|
|
void finish();
|
2018-02-04 19:42:30 +01:00
|
|
|
void finishOSspecifics1();
|
|
|
|
void finishOSspecifics2();
|
2017-09-11 03:06:02 +02:00
|
|
|
static uInt cp437_to_unicode (uChar);
|
2018-01-03 08:42:10 +01:00
|
|
|
static int getMouseProtocolKey (char[]);
|
|
|
|
static int getTermcapKey (char[], int);
|
|
|
|
static int getMetaKey (char[], int, timeval*);
|
|
|
|
static int getSingleKey (char[], int);
|
2017-11-18 02:34:41 +01:00
|
|
|
static void setSignalHandler();
|
|
|
|
static void resetSignalHandler();
|
2017-09-11 03:06:02 +02:00
|
|
|
static void signal_handler (int);
|
|
|
|
|
|
|
|
// Data Members
|
|
|
|
static std::map <uChar,uChar>* vt100_alt_char;
|
|
|
|
static std::map <std::string,fc::encoding>* encoding_set;
|
|
|
|
static FTermcap::tcap_map* tcap;
|
|
|
|
|
|
|
|
static bool input_data_pending;
|
|
|
|
static bool non_blocking_stdin;
|
|
|
|
static bool pc_charset_console;
|
|
|
|
static bool utf8_input;
|
|
|
|
static bool utf8_state;
|
|
|
|
static bool utf8_console;
|
|
|
|
static bool utf8_linux_terminal;
|
|
|
|
static bool force_vt100;
|
|
|
|
static bool vt100_console;
|
|
|
|
static bool ascii_console;
|
|
|
|
static bool color256;
|
|
|
|
static bool monochron;
|
|
|
|
static char termtype[256];
|
2018-02-11 23:41:23 +01:00
|
|
|
static char termfilename[256];
|
2017-09-11 03:06:02 +02:00
|
|
|
static char* locale_name;
|
|
|
|
static char* locale_xterm;
|
2018-05-02 12:31:21 +02:00
|
|
|
static FRect* term; // current terminal geometry
|
2017-09-11 03:06:02 +02:00
|
|
|
|
|
|
|
static int stdin_status_flags;
|
|
|
|
static int fd_tty;
|
|
|
|
static uInt baudrate;
|
2018-01-03 08:42:10 +01:00
|
|
|
static long key_timeout;
|
2017-09-11 03:06:02 +02:00
|
|
|
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;
|
2017-04-14 23:55:44 +02:00
|
|
|
|
|
|
|
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
2017-09-11 03:06:02 +02:00
|
|
|
static uInt bsd_alt_keymap;
|
2017-04-14 23:55:44 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(__NetBSD__) || defined(__OpenBSD__)
|
2017-09-11 03:06:02 +02:00
|
|
|
static kbd_t wscons_keyboard_encoding;
|
2017-04-14 23:55:44 +02:00
|
|
|
#endif
|
2016-11-02 00:37:58 +01:00
|
|
|
|
2018-05-02 12:31:21 +02:00
|
|
|
static FOptiMove* opti_move;
|
|
|
|
static FOptiAttr* opti_attr;
|
|
|
|
static FTermDetection* term_detection;
|
|
|
|
static FMouseControl* mouse;
|
|
|
|
static const FString* xterm_font;
|
|
|
|
static const FString* xterm_title;
|
2018-04-19 01:55:17 +02:00
|
|
|
|
2018-01-02 20:38:45 +01:00
|
|
|
static struct colorEnv
|
|
|
|
{
|
2018-01-03 08:42:10 +01:00
|
|
|
void setDefault()
|
|
|
|
{
|
|
|
|
string1 = 0;
|
|
|
|
string2 = 0;
|
|
|
|
string3 = 0;
|
|
|
|
string4 = 0;
|
|
|
|
string5 = 0;
|
|
|
|
string6 = 0;
|
|
|
|
}
|
|
|
|
|
2018-01-02 20:38:45 +01:00
|
|
|
char* string1;
|
|
|
|
char* string2;
|
|
|
|
char* string3;
|
|
|
|
char* string4;
|
|
|
|
char* string5;
|
|
|
|
char* string6;
|
|
|
|
} color_env;
|
|
|
|
|
|
|
|
static struct secondaryDA
|
|
|
|
{
|
2018-01-03 08:42:10 +01:00
|
|
|
void setDefault()
|
|
|
|
{
|
|
|
|
terminal_id_type = -1;
|
|
|
|
terminal_id_version = -1;
|
|
|
|
terminal_id_hardware = -1;
|
|
|
|
}
|
2018-01-02 20:38:45 +01:00
|
|
|
|
|
|
|
int terminal_id_type;
|
|
|
|
int terminal_id_version;
|
|
|
|
int terminal_id_hardware;
|
|
|
|
} secondary_da;
|
|
|
|
|
2017-09-11 03:06:02 +02:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
dacreg d[16];
|
|
|
|
} color_map;
|
2018-05-02 12:31:21 +02:00
|
|
|
|
|
|
|
friend class FTermDetection;
|
2016-11-02 00:37:58 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#pragma pack(pop)
|
2015-10-17 19:40:43 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
// FTerm inline functions
|
2015-05-23 13:35:12 +02:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline const char* FTerm::getClassName() const
|
|
|
|
{ return "FTerm"; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline char* FTerm::getTermType()
|
|
|
|
{ return termtype; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2018-02-11 23:41:23 +01:00
|
|
|
inline char* FTerm::getTermFileName()
|
|
|
|
{ return termfilename; }
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-10-13 02:16:51 +02:00
|
|
|
//----------------------------------------------------------------------
|
2017-03-26 20:40:04 +02:00
|
|
|
inline int FTerm::getTabstop()
|
2016-10-13 02:16:51 +02:00
|
|
|
{ return FTermcap::tabstop; }
|
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline int FTerm::getMaxColor()
|
|
|
|
{ return FTermcap::max_color; }
|
|
|
|
|
2017-03-26 20:40:04 +02:00
|
|
|
#if DEBUG
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline const FString& FTerm::getAnswerbackString()
|
2018-05-02 12:31:21 +02:00
|
|
|
{ return term_detection->getAnswerbackString(); }
|
2017-03-26 20:40:04 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline const FString& FTerm::getSecDAString()
|
2018-05-02 12:31:21 +02:00
|
|
|
{ return term_detection->getSecDAString(); }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline const char* FTerm::getTermType_256color()
|
|
|
|
{ return term_detection->getTermType_256color(); }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline const char* FTerm::getTermType_Answerback()
|
|
|
|
{ return term_detection->getTermType_Answerback(); }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline const char* FTerm::getTermType_SecDA()
|
|
|
|
{ return term_detection->getTermType_SecDA(); }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline int FTerm::getFramebufferBpp()
|
|
|
|
{ return framebuffer_bpp; }
|
2017-03-26 20:40:04 +02:00
|
|
|
#endif
|
|
|
|
|
2018-01-03 08:42:10 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FTerm::isKeypressTimeout (timeval* time)
|
2018-01-14 21:21:08 +01:00
|
|
|
{ return FObject::isTimeout (time, key_timeout); }
|
2018-01-03 08:42:10 +01:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FTerm::hasPCcharset()
|
|
|
|
{ return pc_charset_console; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FTerm::hasUTF8()
|
|
|
|
{ return utf8_console; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FTerm::hasVT100()
|
|
|
|
{ return vt100_console; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FTerm::hasASCII()
|
|
|
|
{ return ascii_console; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FTerm::isMonochron()
|
|
|
|
{ return monochron; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2016-10-09 02:06:06 +02:00
|
|
|
inline bool FTerm::isXTerminal()
|
2018-05-02 12:31:21 +02:00
|
|
|
{ return term_detection->isXTerminal(); }
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-11-27 00:41:34 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FTerm::isAnsiTerminal()
|
2018-05-02 12:31:21 +02:00
|
|
|
{ return term_detection->isAnsiTerminal(); }
|
2016-11-27 00:41:34 +01:00
|
|
|
|
2015-10-06 05:09:18 +02:00
|
|
|
//----------------------------------------------------------------------
|
2016-10-09 02:06:06 +02:00
|
|
|
inline bool FTerm::isRxvtTerminal()
|
2018-05-02 12:31:21 +02:00
|
|
|
{ return term_detection->isRxvtTerminal(); }
|
2015-10-06 05:09:18 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FTerm::isUrxvtTerminal()
|
2018-05-02 12:31:21 +02:00
|
|
|
{ return term_detection->isUrxvtTerminal(); }
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-10-09 02:06:06 +02:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FTerm::isMltermTerminal()
|
2018-05-02 12:31:21 +02:00
|
|
|
{ return term_detection->isMltermTerminal(); }
|
2016-10-09 02:06:06 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FTerm::isPuttyTerminal()
|
2018-05-02 12:31:21 +02:00
|
|
|
{ return term_detection->isPuttyTerminal(); }
|
2016-10-09 02:06:06 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FTerm::isKdeTerminal()
|
2018-05-02 12:31:21 +02:00
|
|
|
{ return term_detection->isKdeTerminal(); }
|
2016-10-09 02:06:06 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FTerm::isGnomeTerminal()
|
2018-05-02 12:31:21 +02:00
|
|
|
{ return term_detection->isGnomeTerminal(); }
|
2016-10-09 02:06:06 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FTerm::isKtermTerminal()
|
2018-05-02 12:31:21 +02:00
|
|
|
{ return term_detection->isKtermTerminal(); }
|
2016-10-09 02:06:06 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FTerm::isTeraTerm()
|
2018-05-02 12:31:21 +02:00
|
|
|
{ return term_detection->isTeraTerm(); }
|
2016-10-09 02:06:06 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2017-12-14 00:35:10 +01:00
|
|
|
inline bool FTerm::isSunTerminal()
|
2018-05-02 12:31:21 +02:00
|
|
|
{ return term_detection->isSunTerminal(); }
|
2017-12-14 00:35:10 +01:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2016-10-09 02:06:06 +02:00
|
|
|
inline bool FTerm::isCygwinTerminal()
|
2018-05-02 12:31:21 +02:00
|
|
|
{ return term_detection->isCygwinTerminal(); }
|
2016-10-09 02:06:06 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FTerm::isMinttyTerm()
|
2018-05-02 12:31:21 +02:00
|
|
|
{ return term_detection->isMinttyTerm(); }
|
2016-10-09 02:06:06 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FTerm::isLinuxTerm()
|
2018-05-02 12:31:21 +02:00
|
|
|
{ return term_detection->isLinuxTerm(); }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FTerm::isFreeBSDTerm()
|
|
|
|
{ return term_detection->isFreeBSDTerm(); }
|
2018-04-19 01:55:17 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FTerm::isNetBSDTerm()
|
2018-05-02 12:31:21 +02:00
|
|
|
{ return term_detection->isNetBSDTerm(); }
|
2018-04-19 01:55:17 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FTerm::isOpenBSDTerm()
|
2018-05-02 12:31:21 +02:00
|
|
|
{ return term_detection->isOpenBSDTerm(); }
|
2016-10-09 02:06:06 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FTerm::isScreenTerm()
|
2018-05-02 12:31:21 +02:00
|
|
|
{ return term_detection->isScreenTerm(); }
|
2016-10-09 02:06:06 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FTerm::isTmuxTerm()
|
2018-05-02 12:31:21 +02:00
|
|
|
{ return term_detection->isTmuxTerm(); }
|
2016-10-09 02:06:06 +02:00
|
|
|
|
2016-10-13 02:16:51 +02:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FTerm::isInputDataPending()
|
|
|
|
{ return input_data_pending; }
|
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FTerm::isNewFont()
|
|
|
|
{ return NewFont; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FTerm::isUTF8()
|
|
|
|
{ return utf8_state; }
|
|
|
|
|
2015-12-21 18:37:20 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FTerm::setCursorOptimisation (bool on)
|
2017-09-17 21:32:46 +02:00
|
|
|
{ return cursor_optimisation = ( on ) ? true : false; }
|
2015-12-21 18:37:20 +01:00
|
|
|
|
2016-11-06 16:36:21 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline void FTerm::setXTermDefaultColors (bool on)
|
|
|
|
{ xterm_default_colors = on; }
|
|
|
|
|
2018-01-03 08:42:10 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline void FTerm::setKeypressTimeout (const long timeout)
|
|
|
|
{ key_timeout = timeout; }
|
|
|
|
|
2017-03-26 20:40:04 +02:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline void FTerm::disableAltScreen()
|
|
|
|
{ use_alternate_screen = false; }
|
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FTerm::setUTF8()
|
|
|
|
{ return setUTF8(true); }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FTerm::unsetUTF8()
|
|
|
|
{ return setUTF8(false); }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2016-11-02 00:37:58 +01:00
|
|
|
inline bool FTerm::setNonBlockingInput()
|
|
|
|
{ return setNonBlockingInput(true); }
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2016-11-02 00:37:58 +01:00
|
|
|
inline bool FTerm::unsetNonBlockingInput()
|
|
|
|
{ return setNonBlockingInput(false); }
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2016-11-02 00:37:58 +01:00
|
|
|
inline bool FTerm::hasChangedTermSize()
|
|
|
|
{ return resize_term; }
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2016-11-02 00:37:58 +01:00
|
|
|
inline void FTerm::changeTermSizeFinished()
|
|
|
|
{ resize_term = false; }
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
|
2017-04-09 20:08:53 +02:00
|
|
|
#endif // FTERM_H
|