From 133a45c109da5310add55824db21af5239951f93 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 10 Apr 2024 23:30:40 +0200 Subject: Adding upstream version 3.8.1. Signed-off-by: Daniel Baumann --- contrib/replxx/src/terminal.hxx | 94 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 contrib/replxx/src/terminal.hxx (limited to 'contrib/replxx/src/terminal.hxx') diff --git a/contrib/replxx/src/terminal.hxx b/contrib/replxx/src/terminal.hxx new file mode 100644 index 0000000..e6a2578 --- /dev/null +++ b/contrib/replxx/src/terminal.hxx @@ -0,0 +1,94 @@ +#ifndef REPLXX_IO_HXX_INCLUDED +#define REPLXX_IO_HXX_INCLUDED 1 + +#include + +#ifdef _WIN32 +#include +#include +#else +#include +#endif + +#include "utf8string.hxx" + +namespace replxx { + +class Terminal { +public: + enum class EVENT_TYPE { + KEY_PRESS, + MESSAGE, + TIMEOUT, + RESIZE + }; +private: +#ifdef _WIN32 + HANDLE _consoleOut; + HANDLE _consoleIn; + DWORD _origOutMode; + DWORD _origInMode; + bool _autoEscape; + WORD _oldDisplayAttribute; + UINT const _inputCodePage; + UINT const _outputCodePage; + HANDLE _interrupt; + typedef std::deque events_t; + events_t _events; + std::vector _empty; +#else + struct termios _origTermios; /* in order to restore at exit */ + int _interrupt[2]; +#endif + bool _rawMode; /* for destructor to check if restore is needed */ + Utf8String _utf8; +public: + enum class CLEAR_SCREEN { + WHOLE, + TO_END + }; +public: + Terminal( void ); + ~Terminal( void ); + void write32( char32_t const*, int ); + void write8( char const*, int ); + int get_screen_columns(void); + int get_screen_rows(void); + void enable_bracketed_paste( void ); + void disable_bracketed_paste( void ); + int enable_raw_mode(void); + void disable_raw_mode(void); + char32_t read_char(void); + void clear_screen( CLEAR_SCREEN ); + EVENT_TYPE wait_for_input( int long = 0 ); + void notify_event( EVENT_TYPE ); + void jump_cursor( int, int ); + void set_cursor_visible( bool ); +#ifndef _WIN32 + int read_verbatim( char32_t*, int ); + int install_window_change_handler( void ); +#endif +private: + void enable_out( void ); + void disable_out( void ); +private: + Terminal( Terminal const& ) = delete; + Terminal& operator = ( Terminal const& ) = delete; + Terminal( Terminal&& ) = delete; + Terminal& operator = ( Terminal&& ) = delete; +}; + +void beep(); +char32_t read_unicode_character(void); + +namespace tty { + +extern bool in; +extern bool out; + +} + +} + +#endif + -- cgit v1.2.3