Use fputs and fflush in ncurses_ui direct stdout access to respect buffering

Ncurses will write using the FILE* interface, using the fd based one is error
prone.

Fixes #703
This commit is contained in:
Maxime Coste 2016-06-20 20:56:38 +01:00
parent 91bf0d4622
commit 2edea2e0f6

View File

@ -413,7 +413,8 @@ void NCursesUI::draw_status(const DisplayLine& status_line,
for (auto& atom : mode_line) for (auto& atom : mode_line)
title += atom.content(); title += atom.content();
title += " - Kakoune\007"; title += " - Kakoune\007";
write_stdout(title); fputs(stdout, title.c_str());
fflush(stdout);
} }
m_dirty = true; m_dirty = true;
@ -446,7 +447,7 @@ void NCursesUI::check_resize(bool force)
m_dimensions = CharCoord{ws.ws_row-1, ws.ws_col}; m_dimensions = CharCoord{ws.ws_row-1, ws.ws_col};
if (char* csr = tigetstr((char*)"csr")) if (char* csr = tigetstr((char*)"csr"))
putp(csr); putp(tiparm(csr, 0, ws.ws_row));
if (menu) if (menu)
{ {
@ -937,16 +938,17 @@ void NCursesUI::enable_mouse(bool enabled)
mousemask(ALL_MOUSE_EVENTS | REPORT_MOUSE_POSITION, nullptr); mousemask(ALL_MOUSE_EVENTS | REPORT_MOUSE_POSITION, nullptr);
mouseinterval(0); mouseinterval(0);
// force enable report mouse position // force enable report mouse position
puts("\033[?1002h"); fputs(stdout, "\033[?1002h");
// force enable report focus events // force enable report focus events
puts("\033[?1004h"); fputs(stdout, "\033[?1004h");
} }
else else
{ {
mousemask(0, nullptr); mousemask(0, nullptr);
puts("\033[?1004l"); fputs(stdout, "\033[?1004l");
puts("\033[?1002l"); fputs(stdout, "\033[?1002l");
} }
fflush(stdout);
} }
void NCursesUI::set_ui_options(const Options& options) void NCursesUI::set_ui_options(const Options& options)