RediWM is a Wayland compositor written in Zig (OpenGL ES) that includes everything in one process
editor: fold long lines at 2 KiB so scrollbar drags stay smooth
oxydizerd942edf6e572
diff --git a/src/editor/AGENTS.md b/src/editor/AGENTS.mdindex 08b30fc..d525a92 100644--- a/src/editor/AGENTS.md+++ b/src/editor/AGENTS.md@@ -3,8 +3,9 @@* **Never give Pango more than a few lines.** One layout of 1 MiB took 46 s(cost grows faster than the line count). `view.zig` lays out one *segment*at a time (`lines.zig`: a logical line, or a piece of one folded at `fold` =- 16 KiB, cut after a nearby space) in a content-keyed cache (`Layouts`), so- edits need no invalidation. Pieces are a function of the line start alone,+ 2 KiB, cut after a nearby space) in a content-keyed cache (`Layouts`), so+ edits need no invalidation. A scrollbar drag lays out a new piece per motion:+ 16 KiB pieces stuttered at 16–38 ms, 2 KiB take about 5 ms. Pieces are a function of the line start alone,so walking up or down finds the same ones; keep `lines.zig`'s property testgreen when touching it.* **Scroll is `Document.top` (a byte offset) plus `Tab.dy` pixels into thatdiff --git a/src/editor/lines.zig b/src/editor/lines.zigindex 80bb707..8440538 100644--- a/src/editor/lines.zig+++ b/src/editor/lines.zig@@ -8,8 +8,9 @@const std = @import("std");/// Longest piece of one line, in bytes, before it is folded onto another row.-/// Laying out one paragraph this long costs a few milliseconds.-pub const fold: usize = 16 * 1024;+/// A scrollbar drag lands on unseen text at every motion, so each step lays out+/// a new piece: 16 KiB cost 16 ms median (38 ms worst), 2 KiB about 5 ms.+pub const fold: usize = 2 * 1024;/// How far before the nominal cut a space may be looked for.const soft_limit: usize = 256;