diff options
author | elfmz <fenix1905@tut.by> | 2021-12-30 03:38:02 +0300 |
---|---|---|
committer | elfmz <fenix1905@tut.by> | 2021-12-30 03:38:02 +0300 |
commit | d5f1bf245e96834d44390d1723cfef3dfbb1fb02 (patch) | |
tree | a045a0288ba9ff6727b4012ca27c8f60c8544f5a /WinPort | |
parent | 6d42eb84da2c011c68ed08e15ffa7a205e36d5e3 (diff) |
TTY: dont use bold if terminal supports intensify (fix #635)
Diffstat (limited to 'WinPort')
-rw-r--r-- | WinPort/src/Backend/TTY/TTYOutput.cpp | 33 | ||||
-rw-r--r-- | WinPort/src/Backend/TTY/TTYOutput.h | 2 |
2 files changed, 31 insertions, 4 deletions
diff --git a/WinPort/src/Backend/TTY/TTYOutput.cpp b/WinPort/src/Backend/TTY/TTYOutput.cpp index 608d24e2..54cef5d2 100644 --- a/WinPort/src/Backend/TTY/TTYOutput.cpp +++ b/WinPort/src/Backend/TTY/TTYOutput.cpp @@ -2,6 +2,15 @@ #include <assert.h> #include <base64.h> #include <string> +#include <sys/ioctl.h> +#ifdef __linux__ +# include <termios.h> +# include <linux/kd.h> +# include <linux/keyboard.h> +#elif defined(__FreeBSD__) +# include <sys/ioctl.h> +# include <sys/kbio.h> +#endif #include <os_call.hpp> #include "TTYOutput.h" #include "FarTTY.h" @@ -35,8 +44,18 @@ bool TTYOutput::Attributes::operator ==(const Attributes &attr) const TTYOutput::TTYOutput(int out, bool far2l_tty) : - _out(out), _far2l_tty(far2l_tty) + _out(out), _far2l_tty(far2l_tty), _kernel_tty(false) { +#if defined(__linux__) || defined(__FreeBSD__) + unsigned long int leds = 0; + if (ioctl(out, KDGETLED, &leds) == 0) { + // running under linux 'real' TTY, such kind of terminal cannot be dropped due to lost connection etc + // also detachable session makes impossible using of ioctl(_stdin, TIOCLINUX, &state) in child (#653), + // so lets default to mortal mode in Linux/BSD TTY + _kernel_tty = true; + } +#endif + Format(ESC "7" ESC "[?47h" ESC "[?1049h"); ChangeKeypad(true); ChangeMouse(true); @@ -57,7 +76,10 @@ TTYOutput::~TTYOutput() ChangeCursor(true, true); ChangeMouse(false); ChangeKeypad(false); - Format(ESC "[0 q" ESC "[0m" ESC "[?1049l" ESC "[?47l" ESC "8" "\r\n"); + if (!_kernel_tty) { + Format(ESC "[0 q"); + } + Format(ESC "[0m" ESC "[?1049l" ESC "[?47l" ESC "8" "\r\n"); Flush(); } catch (std::exception &) { @@ -200,6 +222,9 @@ void TTYOutput::ChangeCursorHeight(unsigned int height) stk_ser.PushPOD((uint8_t)0); // zero ID means not expecting reply SendFar2lInterract(stk_ser); + } else if (_kernel_tty) { + ; // avoid printing 'q' on screen + } else if (height < 30) { Format(ESC "[3 q"); // Blink Underline @@ -268,7 +293,9 @@ void TTYOutput::WriteLine(const CHAR_INFO *ci, unsigned int cnt) || _attr.background_intensive != attr.background_intensive) ) { tmp = ESC "["; - if (_attr.foreground_intensive != attr.foreground_intensive) +// wikipedia claims that colors 90-97 are nonstandard, so in case of some +// terminal missing '90–97 Set bright foreground color' - use bold font + if (_kernel_tty && _attr.foreground_intensive != attr.foreground_intensive) tmp+= attr.foreground_intensive ? "1;" : "22;"; if (_attr.foreground != attr.foreground diff --git a/WinPort/src/Backend/TTY/TTYOutput.h b/WinPort/src/Backend/TTY/TTYOutput.h index 42e924bc..4bafcb58 100644 --- a/WinPort/src/Backend/TTY/TTYOutput.h +++ b/WinPort/src/Backend/TTY/TTYOutput.h @@ -34,7 +34,7 @@ class TTYOutput unsigned int count = 0; std::string tmp; } _same_chars; - bool _far2l_tty; + bool _far2l_tty, _kernel_tty; void WriteReally(const char *str, int len); void FinalizeSameChars(); |