Small cleanups in terminal ui
This commit is contained in:
parent
44deaeb4eb
commit
76e5d11c8b
|
@ -18,19 +18,12 @@
|
|||
#include <unistd.h>
|
||||
#include <strings.h>
|
||||
|
||||
constexpr char control(char c) { return c & 037; }
|
||||
|
||||
namespace Kakoune
|
||||
{
|
||||
|
||||
using std::min;
|
||||
using std::max;
|
||||
|
||||
static void set_cursor_pos(DisplayCoord coord)
|
||||
{
|
||||
printf("\033[%d;%dH", (int)coord.line + 1, (int)coord.column + 1);
|
||||
}
|
||||
|
||||
void TerminalUI::Window::create(const DisplayCoord& p, const DisplayCoord& s)
|
||||
{
|
||||
pos = p;
|
||||
|
@ -456,6 +449,10 @@ void TerminalUI::redraw(bool force)
|
|||
m_info.blit(m_screen);
|
||||
|
||||
m_screen.output(force);
|
||||
|
||||
auto set_cursor_pos = [](DisplayCoord c) {
|
||||
printf("\033[%d;%dH", (int)c.line + 1, (int)c.column + 1);
|
||||
};
|
||||
if (m_cursor.mode == CursorMode::Prompt)
|
||||
set_cursor_pos({m_status_on_top ? 0 : m_dimensions.line, m_cursor.coord.column});
|
||||
else
|
||||
|
@ -625,13 +622,14 @@ Optional<Key> TerminalUI::get_next_key()
|
|||
if (not c)
|
||||
return {};
|
||||
|
||||
const cc_t erase = m_original_termios.c_cc[VERASE];
|
||||
auto convert = [erase](Codepoint c) -> Codepoint {
|
||||
static constexpr auto control = [](char c) { return c & 037; };
|
||||
|
||||
auto convert = [this](Codepoint c) -> Codepoint {
|
||||
if (c == control('m') or c == control('j'))
|
||||
return Key::Return;
|
||||
if (c == control('i'))
|
||||
return Key::Tab;
|
||||
if (c == erase)
|
||||
if (c == m_original_termios.c_cc[VERASE])
|
||||
return Key::Backspace;
|
||||
if (c == 127) // when it's not backspace
|
||||
return Key::Delete;
|
||||
|
|
Loading…
Reference in New Issue
Block a user