summaryrefslogtreecommitdiff
path: root/core/Core.zig
diff options
context:
space:
mode:
Diffstat (limited to 'core/Core.zig')
-rw-r--r--core/Core.zig37
1 files changed, 33 insertions, 4 deletions
diff --git a/core/Core.zig b/core/Core.zig
index 96fd547e..2c04cc64 100644
--- a/core/Core.zig
+++ b/core/Core.zig
@@ -153,7 +153,13 @@ pub const View = struct {
/// Whether the host window has the keyboard (Event.focus), and the pane
/// whose program was last told it has it (reportFocus).
window_focused: bool = true,
- focus_told: ?struct { id: usize, serial: u32 } = null,
+ focus_told: ?struct {
+ // A slot of the session's, looked at before it is used, as
+ // `active` is (a damaged image's indexed past the panes).
+ pub const replica = .{ .index = .{.{ "id", Pardes, "panes" }} };
+ id: usize,
+ serial: u32,
+ } = null,
hover_col: u16 = 0,
hover_row: u16 = 0,
pointer_raw_col: u16 = 0,
@@ -341,6 +347,11 @@ locations_cache: locations.Cache = .{},
tty_filter_palette: pardes.Term.FilterPalette = .{},
font_request_taken: bool = false,
custom_theme: ?Theme = null,
+/// The theme the window wears while a picker of them (or `:theme `)
+/// previews one, by index, and its chrome (colors.previewTheme); the
+/// session's own theme untouched under it.
+theme_preview: ?u16 = null,
+preview_chrome: ChromeTheme = colors.initial_chrome,
/// bodyChrome's: the theme it was worked out for, and it.
body_chrome: ?struct { theme: Theme, chrome: ChromeTheme } = null,
theme_file_path: config.Settings.Text(limits.host_path_cap) = .{},
@@ -444,6 +455,9 @@ in_head: usize = 0,
in_len: usize = 0,
registers: Registers = .{},
+/// The text prompts' histories (Prompt.zig): search and select's, the
+/// pipes', the command line's.
+prompt_history: pardes.Prompt.History = .{},
macro: Macro = .{},
/// an edited text nothing kept (a tag's shown text): see edit.retireEditText
retired_edit: ?[]u8 = null,
@@ -529,7 +543,7 @@ pub const replica = .{
"opts", "dump_out", "dump_export",
"tape",
},
- .derived = .{ "shell_rows", "diff_output", "locations_cache", "retired_panes", "tty_filter_palette", "body_chrome" },
+ .derived = .{ "shell_rows", "diff_output", "locations_cache", "retired_panes", "tty_filter_palette", "body_chrome", "theme_preview", "preview_chrome" },
// The host's handles, the state file every session of the user
// shares (and Recent read from it), this session's closed panes, and
// the files of a host with no file system of its own. (The 9P
@@ -1399,7 +1413,8 @@ fn refillPendingWrites(p: *Pardes) void {
/// may be handed to a different pane next frame.
pub fn dropPendingWrite(p: *Pardes, id: usize) void {
const pw = p.pending_write[id] orelse return;
- p.pending_write_bytes -= pw.bytes.len - pw.off;
+ // (Saturating: a damaged image's total may say less than its parts.)
+ p.pending_write_bytes -|= pw.bytes.len - pw.off;
p.gpa.free(pw.bytes);
p.pending_write[id] = null;
}
@@ -1815,6 +1830,8 @@ fn updateInner(p: *Pardes, ev: Event) void {
// Each pane's places find a frame's more on a tick, and on any other
// step the ones an edit or a scroll left unfound in the view.
for (p.panes) |slot| if (slot) |pane| pane.places.settle(p, pane, ev == .tick);
+ // Their search words and a search prompt with them (Prompt.zig).
+ pardes.Prompt.settle(p);
// Each live query pane's rows, made from what changed this step.
pardes.panes.Query.produceAll(p, ev == .tick, ev == .key);
pardes.Pick.produceAll(p, ev == .tick);
@@ -2128,12 +2145,14 @@ fn sizes(p: *const Pardes, pane: *const Pane) bool {
}
pub fn theme(p: *const Pardes) *const Theme {
+ if (p.theme_preview) |i| return &themes[i];
if (p.custom_theme) |*custom| return custom;
return &themes[p.settings.theme];
}
/// The colours of the chrome: the theme's, set as it changes.
pub fn chromeTheme(p: *const Pardes) *const ChromeTheme {
+ if (p.theme_preview != null) return &p.preview_chrome;
return &p.chrome;
}
@@ -2295,7 +2314,17 @@ pub fn appendPlacement(p: *Pardes, place: Placement) bool {
return true;
}
-pub const PendingWrite = struct { bytes: []u8, off: usize = 0 };
+pub const PendingWrite = struct {
+ /// What is written held to the bytes (walk.zig `.place`): a damaged
+ /// image's past them freed a count below zero.
+ pub const replica = .{ .place = .{.{ "off", "lastOff" }} };
+ bytes: []u8,
+ off: usize = 0,
+
+ pub fn lastOff(pw: *const PendingWrite) usize {
+ return pw.bytes.len;
+ }
+};
/// The session layouts `init` can put on screen. One name each, so choosing
/// between them reads as a choice instead of a chain of ifs over four options.