2018-05-27 19:43:18 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* ftermfreebsd.h - Contains the FreeBSD terminal functions *
|
|
|
|
* *
|
|
|
|
* This file is part of the Final Cut widget toolkit *
|
|
|
|
* *
|
2020-04-15 23:44:08 +02:00
|
|
|
* Copyright 2018-2020 Markus Gans *
|
2018-05-27 19:43:18 +02: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/>. *
|
|
|
|
***********************************************************************/
|
|
|
|
|
|
|
|
/* Standalone class
|
|
|
|
* ════════════════
|
|
|
|
*
|
|
|
|
* ▕▔▔▔▔▔▔▔▔▔▔▔▔▔▔▏
|
|
|
|
* ▕ FTermFreeBSD ▏
|
|
|
|
* ▕▁▁▁▁▁▁▁▁▁▁▁▁▁▁▏
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef FTERMFREEBSD_H
|
|
|
|
#define FTERMFREEBSD_H
|
|
|
|
|
|
|
|
#if !defined (USE_FINAL_H) && !defined (COMPILE_FINAL_CUT)
|
|
|
|
#error "Only <final/final.h> can be included directly."
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "final/fc.h"
|
|
|
|
|
2019-07-28 23:12:01 +02:00
|
|
|
#if defined(UNIT_TEST)
|
|
|
|
#define CONS_CURSORTYPE 0x80046307
|
|
|
|
#define GIO_KEYMAP 0x20006b06
|
|
|
|
#define PIO_KEYMAP 0x20006b07
|
|
|
|
#define META 0x84 // Meta key
|
|
|
|
#define NUM_KEYS 256 // Number of keys in table
|
|
|
|
#define NUM_STATES 8 // States per key
|
|
|
|
|
|
|
|
struct keyent_t
|
|
|
|
{
|
|
|
|
int map[NUM_STATES];
|
|
|
|
int spcl;
|
|
|
|
int flgs;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct keymap_t
|
|
|
|
{
|
|
|
|
int n_keys;
|
|
|
|
struct keyent_t key[NUM_KEYS];
|
|
|
|
};
|
|
|
|
#elif defined(__FreeBSD__) || defined(__DragonFly__)
|
2018-05-27 19:43:18 +02:00
|
|
|
#undef mouse_info // consio.h
|
|
|
|
#undef buttons // consio.h
|
|
|
|
|
|
|
|
#include <sys/consio.h>
|
|
|
|
#include <sys/kbio.h>
|
|
|
|
#endif
|
|
|
|
|
2018-09-20 23:59:01 +02:00
|
|
|
namespace finalcut
|
|
|
|
{
|
|
|
|
|
2019-07-21 23:31:21 +02:00
|
|
|
// class forward declaration
|
|
|
|
class FSystem;
|
2019-08-04 23:38:47 +02:00
|
|
|
class FTermData;
|
2019-07-21 23:31:21 +02:00
|
|
|
|
2018-05-27 19:43:18 +02:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// class FTermFreeBSD
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
2019-01-04 02:18:54 +01:00
|
|
|
class FTermFreeBSD final
|
2018-05-27 19:43:18 +02:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
// Typedef
|
|
|
|
typedef fc::freebsdConsoleCursorStyle CursorStyle;
|
|
|
|
|
|
|
|
// Constructors
|
2018-12-03 03:22:36 +01:00
|
|
|
FTermFreeBSD() = default;
|
2018-12-24 18:11:16 +01:00
|
|
|
|
2018-12-09 22:04:55 +01:00
|
|
|
// Disable copy constructor
|
|
|
|
FTermFreeBSD (const FTermFreeBSD&) = delete;
|
2018-12-24 18:11:16 +01:00
|
|
|
|
2018-05-27 19:43:18 +02:00
|
|
|
// Destructor
|
2020-04-04 20:58:47 +02:00
|
|
|
~FTermFreeBSD() = default;
|
2018-05-27 19:43:18 +02:00
|
|
|
|
2020-04-15 23:44:08 +02:00
|
|
|
// Disable copy assignment operator (=)
|
2018-12-09 22:04:55 +01:00
|
|
|
FTermFreeBSD& operator = (const FTermFreeBSD&) = delete;
|
|
|
|
|
2018-05-27 19:43:18 +02:00
|
|
|
// Accessors
|
2019-10-05 23:20:07 +02:00
|
|
|
const FString getClassName() const;
|
2018-05-27 19:43:18 +02:00
|
|
|
static CursorStyle getCursorStyle();
|
|
|
|
|
|
|
|
// Inquiry
|
|
|
|
static bool isFreeBSDConsole();
|
|
|
|
|
|
|
|
// Mutators
|
2019-08-04 23:38:47 +02:00
|
|
|
static bool setCursorStyle (CursorStyle);
|
2018-06-17 23:25:32 +02:00
|
|
|
static void enableChangeCursorStyle();
|
|
|
|
static void disableChangeCursorStyle();
|
|
|
|
static void enableMetaSendsEscape();
|
|
|
|
static void disableMetaSendsEscape();
|
2019-07-28 23:12:01 +02:00
|
|
|
static void setBeep (int, int);
|
|
|
|
static void resetBeep();
|
2018-06-12 16:37:48 +02:00
|
|
|
|
2018-05-27 19:43:18 +02:00
|
|
|
// Methods
|
|
|
|
static void init();
|
2019-08-04 23:38:47 +02:00
|
|
|
static void initCharMap();
|
2018-05-27 19:43:18 +02:00
|
|
|
static void finish();
|
|
|
|
|
|
|
|
private:
|
|
|
|
// Methods
|
2020-05-16 22:24:36 +02:00
|
|
|
static void warnNotInitialized();
|
2018-05-27 19:43:18 +02:00
|
|
|
static bool saveFreeBSDAltKey();
|
|
|
|
static bool setFreeBSDAltKey (uInt);
|
|
|
|
static bool setFreeBSDAlt2Meta();
|
|
|
|
static bool resetFreeBSDAlt2Meta();
|
2019-08-04 23:38:47 +02:00
|
|
|
static bool setFreeBSDCursorStyle (CursorStyle);
|
2020-05-16 22:24:36 +02:00
|
|
|
static bool isInitialized();
|
2018-05-27 19:43:18 +02:00
|
|
|
|
2019-09-04 23:57:31 +02:00
|
|
|
// Data members
|
2018-05-27 19:43:18 +02:00
|
|
|
static uInt bsd_alt_keymap;
|
|
|
|
static CursorStyle cursor_style;
|
2018-06-17 23:25:32 +02:00
|
|
|
static bool change_cursorstyle;
|
|
|
|
static bool meta_sends_escape;
|
2019-05-17 15:48:09 +02:00
|
|
|
static FSystem* fsystem;
|
2019-08-04 23:38:47 +02:00
|
|
|
static FTermData* fterm_data;
|
2018-05-27 19:43:18 +02:00
|
|
|
};
|
2019-09-08 02:04:24 +02:00
|
|
|
|
2018-05-27 19:43:18 +02:00
|
|
|
|
2018-06-17 23:25:32 +02:00
|
|
|
// FTermFreeBSD inline functions
|
2018-08-09 00:04:00 +02:00
|
|
|
//----------------------------------------------------------------------
|
2019-10-05 23:20:07 +02:00
|
|
|
inline const FString FTermFreeBSD::getClassName() const
|
2018-08-09 00:04:00 +02:00
|
|
|
{ return "FTermFreeBSD"; }
|
|
|
|
|
2018-06-17 23:25:32 +02:00
|
|
|
//----------------------------------------------------------------------
|
2019-07-28 23:12:01 +02:00
|
|
|
#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST)
|
2018-06-17 23:25:32 +02:00
|
|
|
inline void FTermFreeBSD::enableChangeCursorStyle()
|
|
|
|
{ change_cursorstyle = true; }
|
2018-05-27 19:43:18 +02:00
|
|
|
|
2018-06-17 23:25:32 +02:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline void FTermFreeBSD::disableChangeCursorStyle()
|
|
|
|
{ change_cursorstyle = false; }
|
2018-05-27 19:43:18 +02:00
|
|
|
|
2018-06-17 23:25:32 +02:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline void FTermFreeBSD::enableMetaSendsEscape()
|
|
|
|
{ meta_sends_escape = true; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline void FTermFreeBSD::disableMetaSendsEscape()
|
|
|
|
{ meta_sends_escape = false; }
|
2020-05-16 22:24:36 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FTermFreeBSD::isInitialized()
|
|
|
|
{ return bool(fsystem && fterm_data); }
|
2019-07-28 23:12:01 +02:00
|
|
|
#endif // defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST)
|
2018-05-27 19:43:18 +02:00
|
|
|
|
2018-09-20 23:59:01 +02:00
|
|
|
} // namespace finalcut
|
|
|
|
|
2018-06-17 23:25:32 +02:00
|
|
|
#endif // FTERMFREEBSD_H
|