Force a UTF-8 ctype, stable buffer ids, redraw after deferred opens
- main: when the environment's locale is not UTF-8 (LANG unset, C/POSIX), switch LC_CTYPE to a UTF-8 locale so ncurses delivers and draws multibyte characters instead of dropping them. - Buffer::Id(): a process-unique id that survives moves and is fresh for copies. The terminal renderer's skip and cursor caches and the reload confirmation now key on it rather than the buffer's address, which is reused after a buffer is closed. - The reload confirmation is cancelled by any other command, like the quit confirmation. - TerminalFrontend redraws when a deferred open starts a prompt or sets a status (e.g. the swap recovery question), not only when a buffer opens. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015rcVQiiWyTzoNrsvLSaAfB
This commit is contained in:
+14
-2
@@ -1,4 +1,6 @@
|
||||
#include <cstdio>
|
||||
#include <ctime>
|
||||
#include <string>
|
||||
#include <ncurses.h>
|
||||
#include <termios.h>
|
||||
#include <unistd.h>
|
||||
@@ -106,8 +108,18 @@ TerminalFrontend::Step(Editor &ed, bool &running)
|
||||
ed.SetDimensions(static_cast<std::size_t>(r), static_cast<std::size_t>(c));
|
||||
|
||||
// Allow deferred opens (including swap recovery prompts) to run.
|
||||
if (ed.ProcessPendingOpens())
|
||||
changed = true;
|
||||
// Its return value only reports an opened buffer; a deferred open that
|
||||
// starts a prompt or sets a status must be drawn too.
|
||||
{
|
||||
const bool prompt_before = ed.PromptActive();
|
||||
const std::string status_before = ed.Status();
|
||||
const std::time_t status_time_before = ed.StatusTime();
|
||||
if (ed.ProcessPendingOpens())
|
||||
changed = true;
|
||||
if (ed.PromptActive() != prompt_before || ed.Status() != status_before ||
|
||||
ed.StatusTime() != status_time_before)
|
||||
changed = true;
|
||||
}
|
||||
|
||||
// Handle all pending input before drawing: one key per frame made a
|
||||
// pasted block take a frame (and a full redraw) per character. The first
|
||||
|
||||
Reference in New Issue
Block a user