feat(terminal/osc12): define cursor color through style of cell that describes the cursor position
Zig Project Action / Lint, Spell-check and test zig project (push) Failing after 1m33s

The `.default` color will reset the cursor color to the terminal's default color
This commit is contained in:
2025-11-19 18:42:13 +01:00
parent 28c733352e
commit 424740d350
13 changed files with 55 additions and 30 deletions
+13 -6
View File
@@ -519,9 +519,13 @@ pub fn Input(Model: type, Event: type, Queue: type) fn (meta.FieldEnum(Event)) t
/// Configuration for InputField's.
pub const Configuration = packed struct {
color: Color,
cursor: Color,
pub fn init(color: Color) @This() {
return .{ .color = color };
pub fn init(color: Color, cursor: Color) @This() {
return .{
.color = color,
.cursor = cursor,
};
}
};
@@ -680,10 +684,13 @@ pub fn Input(Model: type, Event: type, Queue: type) fn (meta.FieldEnum(Event)) t
break;
}
}
if (this.input.items.len < cells.len)
cells[this.input.items.len - this.cursor_offset].style.cursor = true
else
if (this.input.items.len < cells.len) {
cells[this.input.items.len - this.cursor_offset].style.cursor = true;
cells[this.input.items.len - this.cursor_offset].style.cursor_color = this.configuration.cursor;
} else {
cells[this.input.items.len - offset - this.cursor_offset].style.cursor = true;
cells[this.input.items.len - offset - this.cursor_offset].style.cursor_color = this.configuration.cursor;
}
}
};
}
@@ -1615,7 +1622,7 @@ test "input element" {
};
var queue: Queue = .{};
var input_element: Input(Model, Event, Queue)(.accept) = .init(allocator, &queue, .init(.black));
var input_element: Input(Model, Event, Queue)(.accept) = .init(allocator, &queue, .init(.black, .default));
defer input_element.deinit();
const input_container: Container(Model, Event) = try .init(allocator, .{