Terminal loop, virtual buffers, yank bound

- 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
This commit is contained in:
Claude
2026-09-24 09:16:04 -07:00
committed by Kyle Isom
parent 1005f5dbe8
commit 61a7338f88
10 changed files with 184 additions and 18 deletions
+7
View File
@@ -322,6 +322,7 @@ Buffer::Buffer(const Buffer &other)
rows_cache_dirty_ = other.rows_cache_dirty_;
filename_ = other.filename_;
is_file_backed_ = other.is_file_backed_;
is_virtual_ = other.is_virtual_;
dirty_ = other.dirty_;
read_only_ = other.read_only_;
mark_set_ = other.mark_set_;
@@ -375,6 +376,7 @@ Buffer::operator=(const Buffer &other)
rows_cache_dirty_ = other.rows_cache_dirty_;
filename_ = other.filename_;
is_file_backed_ = other.is_file_backed_;
is_virtual_ = other.is_virtual_;
dirty_ = other.dirty_;
read_only_ = other.read_only_;
mark_set_ = other.mark_set_;
@@ -420,6 +422,7 @@ Buffer::Buffer(Buffer &&other) noexcept
rows_(std::move(other.rows_)),
filename_(std::move(other.filename_)),
is_file_backed_(other.is_file_backed_),
is_virtual_(other.is_virtual_),
dirty_(other.dirty_),
read_only_(other.read_only_),
mark_set_(other.mark_set_),
@@ -470,6 +473,7 @@ Buffer::operator=(Buffer &&other) noexcept
rows_ = std::move(other.rows_);
filename_ = std::move(other.filename_);
is_file_backed_ = other.is_file_backed_;
is_virtual_ = other.is_virtual_;
dirty_ = other.dirty_;
read_only_ = other.read_only_;
mark_set_ = other.mark_set_;
@@ -548,6 +552,7 @@ Buffer::OpenFromFile(const std::string &path, std::string &err)
nrows_ = 0;
filename_ = norm;
is_file_backed_ = false;
is_virtual_ = false;
dirty_ = false;
// Reset cursor/viewport state
@@ -620,6 +625,7 @@ Buffer::OpenFromFile(const std::string &path, std::string &err)
nrows_ = 0; // not used under PieceTable
filename_ = norm;
is_file_backed_ = true;
is_virtual_ = false;
dirty_ = false;
RefreshOnDiskIdentity();
@@ -702,6 +708,7 @@ Buffer::SaveAs(const std::string &path, std::string &err)
filename_ = out_path;
is_file_backed_ = true;
is_virtual_ = false;
dirty_ = false;
RefreshOnDiskIdentity();
return true;