2018-06-12 16:37:48 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* ftermlinux.h - Contains the Linux 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
|
|
|
|
* ════════════════
|
|
|
|
*
|
|
|
|
* ▕▔▔▔▔▔▔▔▔▔▔▔▔▏
|
|
|
|
* ▕ FTermLinux ▏
|
|
|
|
* ▕▁▁▁▁▁▁▁▁▁▁▁▁▏
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef FTERMLINUX_H
|
|
|
|
#define FTERMLINUX_H
|
|
|
|
|
|
|
|
#if !defined (USE_FINAL_H) && !defined (COMPILE_FINAL_CUT)
|
|
|
|
#error "Only <final/final.h> can be included directly."
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(__linux__)
|
|
|
|
#include <linux/fb.h> // Linux framebuffer console
|
|
|
|
|
|
|
|
#if defined(__x86_64__) || defined(__i386) || defined(__arm__)
|
|
|
|
#include <sys/io.h> // <asm/io.h> is deprecated
|
2018-09-20 23:59:01 +02:00
|
|
|
#endif // defined(__x86_64__) || defined(__i386) || defined(__arm__)
|
2018-06-12 16:37:48 +02:00
|
|
|
|
|
|
|
#include <sys/kd.h>
|
2018-09-20 23:59:01 +02:00
|
|
|
#endif // defined(__linux__)
|
2018-06-12 16:37:48 +02:00
|
|
|
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
#include <cstdio> // need for sprintf
|
|
|
|
#include <cstring>
|
|
|
|
|
|
|
|
#include "final/fc.h"
|
|
|
|
#include "final/fcharmap.h"
|
|
|
|
#include "final/ftermdetection.h"
|
|
|
|
#include "final/ftypes.h"
|
|
|
|
|
2018-09-20 23:59:01 +02:00
|
|
|
namespace finalcut
|
|
|
|
{
|
2018-06-12 16:37:48 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// class FTermLinux
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
#pragma pack(push)
|
|
|
|
#pragma pack(1)
|
|
|
|
|
|
|
|
class FTermLinux
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
// Constructors
|
|
|
|
FTermLinux();
|
|
|
|
|
|
|
|
// Destructor
|
2018-09-24 04:02:35 +02:00
|
|
|
virtual ~FTermLinux();
|
2018-06-12 16:37:48 +02:00
|
|
|
|
|
|
|
// Accessors
|
2018-08-09 00:04:00 +02:00
|
|
|
const char* getClassName() const;
|
2018-06-12 16:37:48 +02:00
|
|
|
static fc::linuxConsoleCursorStyle getCursorStyle();
|
|
|
|
static int getFramebufferBpp();
|
|
|
|
|
|
|
|
// Mutators
|
|
|
|
static void setFTermDetection (FTermDetection*);
|
|
|
|
static char* setCursorStyle (fc::linuxConsoleCursorStyle, bool);
|
2018-11-07 22:06:58 +01:00
|
|
|
static bool setPalette (FColor, int, int, int);
|
2018-06-12 16:37:48 +02:00
|
|
|
static void setUTF8 (bool);
|
|
|
|
|
|
|
|
// Inquiries
|
|
|
|
static bool isLinuxConsole();
|
|
|
|
static bool hasShadowCharacter();
|
|
|
|
static bool hasHalfBlockCharacter();
|
|
|
|
static bool isVGAFontUsed();
|
|
|
|
static bool isNewFontUsed();
|
|
|
|
|
|
|
|
// Methods
|
|
|
|
static void init();
|
|
|
|
static void initCharMap (uInt[][fc::NUM_OF_ENCODINGS]);
|
|
|
|
static void finish();
|
|
|
|
static bool loadVGAFont();
|
|
|
|
static bool loadNewFont();
|
|
|
|
static bool loadOldFont (uInt[][fc::NUM_OF_ENCODINGS]);
|
|
|
|
static bool saveColorMap();
|
|
|
|
static bool resetColorMap();
|
|
|
|
static void setBeep (int, int);
|
|
|
|
static void resetBeep();
|
|
|
|
static char* restoreCursorStyle();
|
2018-11-21 20:07:08 +01:00
|
|
|
static FKey modifierKeyCorrection (const FKey&);
|
2018-06-12 16:37:48 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
// Typedef
|
|
|
|
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;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
uChar red;
|
|
|
|
uChar green;
|
|
|
|
uChar blue;
|
|
|
|
} rgb;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
rgb color[16];
|
|
|
|
} ColorMap;
|
|
|
|
|
|
|
|
// Disable copy constructor
|
|
|
|
FTermLinux (const FTermLinux&);
|
|
|
|
|
|
|
|
// Disable assignment operator (=)
|
|
|
|
FTermLinux& operator = (const FTermLinux&);
|
|
|
|
|
|
|
|
// Accessors
|
|
|
|
static int getFramebuffer_bpp();
|
|
|
|
static bool getScreenFont();
|
|
|
|
static bool getUnicodeMap ();
|
|
|
|
static modifier_key& getModifierKey();
|
|
|
|
|
|
|
|
// Mutators
|
|
|
|
static int setScreenFont ( uChar[], uInt, uInt, uInt
|
|
|
|
, bool = false );
|
|
|
|
static int setUnicodeMap (struct unimapdesc*);
|
|
|
|
|
|
|
|
// Methods
|
|
|
|
#if defined(__x86_64__) || defined(__i386) || defined(__arm__)
|
|
|
|
static uInt16 getInputStatusRegisterOne();
|
|
|
|
static uChar readAttributeController (uChar);
|
|
|
|
static void writeAttributeController (uChar, uChar);
|
|
|
|
static uChar getAttributeMode();
|
|
|
|
static void setAttributeMode (uChar);
|
|
|
|
static int setBlinkAsIntensity (bool);
|
2018-11-07 22:06:58 +01:00
|
|
|
static bool setVGAPalette (FColor, int, int, int);
|
2018-06-12 16:37:48 +02:00
|
|
|
static bool saveVGAPalette();
|
|
|
|
static bool resetVGAPalette();
|
2018-09-20 23:59:01 +02:00
|
|
|
#endif // defined(__x86_64__) || defined(__i386) || defined(__arm__)
|
2018-11-21 20:07:08 +01:00
|
|
|
static FKey shiftKeyCorrection (const FKey&);
|
|
|
|
static FKey ctrlKeyCorrection (const FKey&);
|
|
|
|
static FKey altKeyCorrection (const FKey&);
|
|
|
|
static FKey shiftCtrlKeyCorrection (const FKey&);
|
|
|
|
static FKey shiftAltKeyCorrection (const FKey&);
|
|
|
|
static FKey ctrlAltKeyCorrection (const FKey&);
|
|
|
|
static FKey shiftCtrlAltKeyCorrection (const FKey&);
|
2018-06-12 16:37:48 +02:00
|
|
|
|
|
|
|
// Data Members
|
|
|
|
#if defined(__linux__)
|
2018-10-01 22:27:54 +02:00
|
|
|
static bool vga_font;
|
|
|
|
static bool new_font;
|
2018-06-12 16:37:48 +02:00
|
|
|
static bool shadow_character;
|
|
|
|
static bool half_block_character;
|
|
|
|
static bool has_saved_palette;
|
|
|
|
static FTermDetection* term_detection;
|
|
|
|
static fc::linuxConsoleCursorStyle
|
|
|
|
linux_console_cursor_style;
|
|
|
|
static console_font_op screen_font;
|
|
|
|
static unimapdesc screen_unicode_map;
|
|
|
|
static ColorMap saved_color_map;
|
|
|
|
static ColorMap cmap;
|
|
|
|
static int framebuffer_bpp;
|
|
|
|
#endif // defined(__linux__)
|
|
|
|
};
|
|
|
|
#pragma pack(pop)
|
|
|
|
|
|
|
|
// FTermLinux inline functions
|
2018-08-09 00:04:00 +02:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline const char* FTermLinux::getClassName() const
|
|
|
|
{ return "FTermLinux"; }
|
|
|
|
|
2018-06-12 16:37:48 +02:00
|
|
|
//----------------------------------------------------------------------
|
2018-06-12 16:52:26 +02:00
|
|
|
#if defined(__linux__)
|
2018-06-12 16:37:48 +02:00
|
|
|
inline int FTermLinux::getFramebufferBpp()
|
|
|
|
{ return framebuffer_bpp; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline void FTermLinux::setFTermDetection (FTermDetection* td)
|
|
|
|
{ term_detection = td; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FTermLinux::hasShadowCharacter()
|
|
|
|
{ return shadow_character; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FTermLinux::hasHalfBlockCharacter()
|
|
|
|
{ return half_block_character; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FTermLinux::isVGAFontUsed()
|
2018-10-01 22:27:54 +02:00
|
|
|
{ return vga_font; }
|
2018-06-12 16:37:48 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FTermLinux::isNewFontUsed()
|
2018-10-01 22:27:54 +02:00
|
|
|
{ return new_font; }
|
2018-06-17 23:25:32 +02:00
|
|
|
#endif // defined(__linux__)
|
2018-06-12 16:37:48 +02:00
|
|
|
|
2018-09-20 23:59:01 +02:00
|
|
|
} // namespace finalcut
|
|
|
|
|
2018-06-12 16:37:48 +02:00
|
|
|
#endif // FTERMLINUX_H
|