- kte refuses to start when stdin is not a terminal: piped bytes were executed as editor commands (C-k s plus a path writes a file), and after EOF the loop spun at full CPU with no way to quit. - The terminal frontend handles all pending input before drawing (a paste used to cost a frame and a full redraw per character) and redraws only after input, a resize or deferred opens, else once a second. The renderer caches, per row and buffer version, where the horizontally scrolled part of a line starts and the cursor's render column, instead of rescanning the line every frame. Idle CPU with the cursor at the end of a 20 MB line: one full core -> ~1%. - Buffers with a virtual name (+HELP+) are not journaled and saving one asks for a file name; it used to write ./+HELP+ and journal under that path. - Yank with a repeat count is capped at 256 MiB in total instead of reserving count x size bytes (C-u 1000000 C-y of a large kill). - Remove an overload clang reports as unused (-Werror on macOS). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015rcVQiiWyTzoNrsvLSaAfB
47 lines
1.0 KiB
C++
47 lines
1.0 KiB
C++
/*
|
|
* TerminalInputHandler - ncurses-based input handling for terminal mode
|
|
*/
|
|
#pragma once
|
|
#include "InputHandler.h"
|
|
|
|
|
|
class TerminalInputHandler final : public InputHandler {
|
|
public:
|
|
TerminalInputHandler();
|
|
|
|
~TerminalInputHandler() override;
|
|
|
|
|
|
void Attach(Editor *ed) override
|
|
{
|
|
ed_ = ed;
|
|
}
|
|
|
|
|
|
bool Poll(MappedInput &out) override;
|
|
|
|
// Read one key if available. Returns false when no input was read; true
|
|
// when a key was consumed (out.hasCommand says whether it produced a
|
|
// command: prefixes such as C-k or ESC do not).
|
|
bool PollKey(MappedInput &out)
|
|
{
|
|
out = {};
|
|
return decode_(out);
|
|
}
|
|
|
|
private:
|
|
bool decode_(MappedInput &out);
|
|
|
|
// ke-style prefix state
|
|
bool k_prefix_ = false; // true after C-k until next key or ESC
|
|
// Optional control qualifier inside k-prefix (e.g., user typed literal 'C' or '^')
|
|
bool k_ctrl_pending_ = false;
|
|
// Simple meta (ESC) state for ESC sequences like ESC b/f
|
|
bool esc_meta_ = false;
|
|
|
|
// Mouse drag selection state
|
|
bool mouse_selecting_ = false;
|
|
|
|
Editor *ed_ = nullptr; // attached editor for uarg handling
|
|
};
|