2018-05-02 12:31:21 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* ftermios.h - Provides access to POSIX tty I/O control *
|
|
|
|
* *
|
|
|
|
* This file is part of the Final Cut widget toolkit *
|
|
|
|
* *
|
2019-01-04 02:18:54 +01:00
|
|
|
* Copyright 2018-2019 Markus Gans *
|
2018-05-02 12:31:21 +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
|
|
|
|
* ════════════════
|
|
|
|
*
|
|
|
|
* ▕▔▔▔▔▔▔▔▔▔▔▏
|
|
|
|
* ▕ FTermios ▏
|
|
|
|
* ▕▁▁▁▁▁▁▁▁▁▁▏
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef FTERMIOS_H
|
|
|
|
#define FTERMIOS_H
|
|
|
|
|
|
|
|
#if !defined (USE_FINAL_H) && !defined (COMPILE_FINAL_CUT)
|
|
|
|
#error "Only <final/final.h> can be included directly."
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <termios.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
#include "final/ftypes.h"
|
|
|
|
|
2018-09-20 23:59:01 +02:00
|
|
|
namespace finalcut
|
|
|
|
{
|
2018-05-02 12:31:21 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// class FTermios
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
2019-01-04 02:18:54 +01:00
|
|
|
class FTermios final
|
2018-05-02 12:31:21 +02:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
// Constructors
|
|
|
|
FTermios();
|
|
|
|
|
|
|
|
// Destructor
|
2018-09-24 04:02:35 +02:00
|
|
|
virtual ~FTermios();
|
2018-05-02 12:31:21 +02:00
|
|
|
|
|
|
|
// Accessors
|
2018-08-09 00:04:00 +02:00
|
|
|
const char* getClassName() const;
|
2018-05-02 12:31:21 +02:00
|
|
|
static termios getTTY();
|
|
|
|
static int getStdIn();
|
|
|
|
static int getStdOut();
|
2018-09-14 22:42:56 +02:00
|
|
|
static int getStdErr();
|
2018-05-02 12:31:21 +02:00
|
|
|
|
|
|
|
// Inquiries
|
2018-06-12 16:37:48 +02:00
|
|
|
static bool isRaw();
|
2018-05-02 12:31:21 +02:00
|
|
|
|
|
|
|
// Methods
|
2018-06-12 16:37:48 +02:00
|
|
|
static void init();
|
|
|
|
static void setTTY (const termios&);
|
|
|
|
static void storeTTYsettings();
|
|
|
|
static void restoreTTYsettings();
|
|
|
|
static void setHardwareEcho();
|
|
|
|
static void unsetHardwareEcho();
|
|
|
|
static void setCaptureSendCharacters();
|
|
|
|
static void unsetCaptureSendCharacters();
|
|
|
|
static bool setRawMode (bool);
|
|
|
|
static bool setRawMode();
|
|
|
|
static bool unsetRawMode();
|
|
|
|
static bool setCookedMode();
|
|
|
|
static uInt getBaudRate();
|
2018-05-02 12:31:21 +02:00
|
|
|
|
|
|
|
private:
|
2019-09-04 23:57:31 +02:00
|
|
|
// Data members
|
2018-05-02 12:31:21 +02:00
|
|
|
static int stdin_no;
|
|
|
|
static int stdout_no;
|
2018-09-14 22:42:56 +02:00
|
|
|
static int stderr_no;
|
2018-05-02 12:31:21 +02:00
|
|
|
static bool raw_mode;
|
|
|
|
static struct termios term_init;
|
|
|
|
};
|
2019-09-08 02:04:24 +02:00
|
|
|
|
2018-05-02 12:31:21 +02:00
|
|
|
|
|
|
|
// FTermios inline functions
|
2018-08-09 00:04:00 +02:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline const char* FTermios::getClassName() const
|
|
|
|
{ return "FTermios"; }
|
|
|
|
|
2018-05-02 12:31:21 +02:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline int FTermios::getStdIn()
|
|
|
|
{ return stdin_no; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline int FTermios::getStdOut()
|
|
|
|
{ return stdout_no; }
|
|
|
|
|
2018-09-14 22:42:56 +02:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline int FTermios::getStdErr()
|
|
|
|
{ return stderr_no; }
|
|
|
|
|
2018-05-02 12:31:21 +02:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FTermios::isRaw()
|
|
|
|
{ return raw_mode; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FTermios::setRawMode()
|
|
|
|
{ return setRawMode(true); }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FTermios::unsetRawMode()
|
|
|
|
{ return setRawMode(false); }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FTermios::setCookedMode()
|
|
|
|
{ return setRawMode(false); }
|
|
|
|
|
2018-09-20 23:59:01 +02:00
|
|
|
} // namespace finalcut
|
2018-05-02 12:31:21 +02:00
|
|
|
|
|
|
|
#endif // FTERMIOS_H
|