C-l and C-k l repaint the whole terminal
C-l only cleared the status line and C-k l asked for nothing, and the terminal frame then sent only what ncurses believed had changed, so output another program wrote to the terminal stayed on screen. Both now request a full redraw, which the terminal honors with clearok(curscr); the GUI repaints every frame already. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1495,6 +1495,8 @@ cmd_quit_now(CommandContext &ctx)
|
||||
static bool
|
||||
cmd_refresh(CommandContext &ctx)
|
||||
{
|
||||
// C-l: repaint the whole screen, whatever else this cancels.
|
||||
ctx.editor.RequestFullRedraw();
|
||||
// C-g is mapped to Refresh and acts as a general cancel key.
|
||||
// Cancel visual-line (multicursor) mode if active.
|
||||
if (Buffer *buf = ctx.editor.CurrentBuffer()) {
|
||||
@@ -5316,6 +5318,7 @@ cmd_reload_buffer(CommandContext &ctx)
|
||||
}
|
||||
ctx.editor.SetStatus(std::string("Reloaded ") + filename);
|
||||
ensure_cursor_visible(ctx.editor, *buf);
|
||||
ctx.editor.RequestFullRedraw();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -202,6 +202,24 @@ public:
|
||||
}
|
||||
|
||||
|
||||
// Ask the frontend to repaint the whole screen on its next draw (C-l,
|
||||
// reload). The terminal otherwise sends only what ncurses believes
|
||||
// changed, so output another program wrote to the terminal would stay.
|
||||
void RequestFullRedraw()
|
||||
{
|
||||
full_redraw_requested_ = true;
|
||||
}
|
||||
|
||||
|
||||
// Returns whether a full redraw was requested, and clears the request.
|
||||
bool ConsumeFullRedraw()
|
||||
{
|
||||
const bool on = full_redraw_requested_;
|
||||
full_redraw_requested_ = false;
|
||||
return on;
|
||||
}
|
||||
|
||||
|
||||
void SetQuitConfirmPending(bool on)
|
||||
{
|
||||
quit_confirm_pending_ = on;
|
||||
@@ -630,6 +648,7 @@ private:
|
||||
// Quit state
|
||||
bool quit_requested_ = false;
|
||||
bool new_window_requested_ = false;
|
||||
bool full_redraw_requested_ = false;
|
||||
bool quit_confirm_pending_ = false;
|
||||
bool close_confirm_pending_ = false; // awaiting y/N to save-before-close
|
||||
bool close_after_save_ = false; // if true, close buffer after successful Save/SaveAs
|
||||
|
||||
+3
-1
@@ -585,7 +585,9 @@ GUIFrontend::Step(Editor &ed, bool &running)
|
||||
}
|
||||
}
|
||||
|
||||
// Draw
|
||||
// Draw. Every frame repaints the whole window, so a full-redraw
|
||||
// request (C-l, reload) needs nothing more than clearing.
|
||||
(void) wed.ConsumeFullRedraw();
|
||||
ws.renderer.Draw(wed);
|
||||
|
||||
// Render
|
||||
|
||||
@@ -138,6 +138,12 @@ TerminalFrontend::Step(Editor &ed, bool &running)
|
||||
if (handled > 0)
|
||||
timeout(16);
|
||||
|
||||
// C-l or a reload: make the next refresh repaint every cell.
|
||||
if (ed.ConsumeFullRedraw()) {
|
||||
clearok(curscr, TRUE);
|
||||
changed = true;
|
||||
}
|
||||
|
||||
if (ed.QuitRequested()) {
|
||||
running = false;
|
||||
}
|
||||
|
||||
@@ -2406,3 +2406,26 @@ TEST(Audit_B7_SanitizeSpans_WholeCharacters)
|
||||
ASSERT_TRUE(out[3].kind == TokenKind::Error);
|
||||
ASSERT_TRUE(out[4].kind == TokenKind::Error); // the earlier-starting span wins
|
||||
}
|
||||
|
||||
|
||||
// C-l and C-k l ask the frontend for a full repaint: the terminal must
|
||||
// repaint every cell, not only what ncurses believes changed, so output
|
||||
// another program wrote to the terminal is cleared.
|
||||
TEST(Redraw_RefreshAndReloadRequestFullRedraw)
|
||||
{
|
||||
TempDir d("redraw");
|
||||
const std::string file = (d.path / "r.txt").string();
|
||||
std::ofstream(file) << "disk\n";
|
||||
TestHarness h;
|
||||
Editor &ed = h.EditorRef();
|
||||
std::string err;
|
||||
ASSERT_TRUE(ed.OpenFile(file, err));
|
||||
ASSERT_TRUE(!ed.ConsumeFullRedraw());
|
||||
|
||||
ASSERT_TRUE(h.Exec(CommandId::Refresh));
|
||||
ASSERT_TRUE(ed.ConsumeFullRedraw());
|
||||
ASSERT_TRUE(!ed.ConsumeFullRedraw()); // consumed
|
||||
|
||||
ASSERT_TRUE(h.Exec(CommandId::ReloadBuffer));
|
||||
ASSERT_TRUE(ed.ConsumeFullRedraw());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user