Compare commits
2 commits
2fe12a050e
...
1d509282f7
| Author | SHA1 | Date | |
|---|---|---|---|
| 1d509282f7 | |||
| 8e4c428421 |
2 changed files with 31 additions and 4 deletions
|
|
@ -83,6 +83,8 @@ pub fn main() anyerror!void {
|
|||
.literal = "Disable :LINE and +LINE syntax",
|
||||
.scratch = "Open a scratch (temporary) buffer on start",
|
||||
.new_file = "Create a new untitled file on start",
|
||||
.dark = "Use dark color scheme",
|
||||
.light = "Use light color scheme",
|
||||
.version = "Show build version and exit",
|
||||
};
|
||||
|
||||
|
|
@ -121,6 +123,8 @@ pub fn main() anyerror!void {
|
|||
literal: bool,
|
||||
scratch: bool,
|
||||
new_file: bool,
|
||||
dark: bool,
|
||||
light: bool,
|
||||
version: bool,
|
||||
|
||||
positional: struct {
|
||||
|
|
@ -346,6 +350,11 @@ pub fn main() anyerror!void {
|
|||
try tui_proc.send(.{ "cmd", "create_scratch_buffer", .{} });
|
||||
}
|
||||
|
||||
if (args.dark)
|
||||
try tui_proc.send(.{ "cmd", "force_color_scheme", .{"dark"} })
|
||||
else if (args.light)
|
||||
try tui_proc.send(.{ "cmd", "force_color_scheme", .{"light"} });
|
||||
|
||||
if (args.exec) |exec_str| {
|
||||
var cmds = std.mem.splitScalar(u8, exec_str, ';');
|
||||
while (cmds.next()) |cmd| {
|
||||
|
|
|
|||
|
|
@ -68,6 +68,7 @@ query_cache_: *syntax.QueryCache,
|
|||
frames_rendered_: usize = 0,
|
||||
clipboard: ?[]const u8 = null,
|
||||
color_scheme: enum { dark, light } = .dark,
|
||||
color_scheme_locked: bool = false,
|
||||
|
||||
const keepalive = std.time.us_per_day * 365; // one year
|
||||
const idle_frames = 0;
|
||||
|
|
@ -786,7 +787,14 @@ fn set_theme_by_name(self: *Self, name: []const u8, action: enum { none, store }
|
|||
}
|
||||
}
|
||||
|
||||
fn force_color_scheme(self: *Self, color_scheme: @TypeOf(self.color_scheme)) void {
|
||||
self.color_scheme = color_scheme;
|
||||
self.color_scheme_locked = true;
|
||||
self.logger.print("color scheme: {s} ({s})", .{ @tagName(self.color_scheme), self.current_theme().name });
|
||||
}
|
||||
|
||||
fn set_color_scheme(self: *Self, color_scheme: @TypeOf(self.color_scheme)) void {
|
||||
if (self.color_scheme_locked) return;
|
||||
self.color_scheme = color_scheme;
|
||||
self.logger.print("color scheme: {s} ({s})", .{ @tagName(self.color_scheme), self.current_theme().name });
|
||||
}
|
||||
|
|
@ -913,18 +921,28 @@ const cmds = struct {
|
|||
}
|
||||
pub const toggle_highlight_columns_meta: Meta = .{ .description = "Toggle highlight columns" };
|
||||
|
||||
pub fn set_color_scheme(self: *Self, ctx: Ctx) Result {
|
||||
self.set_color_scheme(if (try ctx.args.match(.{"dark"}))
|
||||
pub fn force_color_scheme(self: *Self, ctx: Ctx) Result {
|
||||
self.force_color_scheme(if (try ctx.args.match(.{"dark"}))
|
||||
.dark
|
||||
else if (try ctx.args.match(.{"light"}))
|
||||
.light
|
||||
else
|
||||
.dark);
|
||||
}
|
||||
pub const set_color_scheme_meta: Meta = .{ .description = "Toggle dark/light color scheme" };
|
||||
pub const force_color_scheme_meta: Meta = .{ .arguments = &.{.string} };
|
||||
|
||||
pub fn set_color_scheme(self: *Self, ctx: Ctx) Result {
|
||||
self.force_color_scheme(if (try ctx.args.match(.{"dark"}))
|
||||
.dark
|
||||
else if (try ctx.args.match(.{"light"}))
|
||||
.light
|
||||
else
|
||||
.dark);
|
||||
}
|
||||
pub const set_color_scheme_meta: Meta = .{ .arguments = &.{.string} };
|
||||
|
||||
pub fn toggle_color_scheme(self: *Self, _: Ctx) Result {
|
||||
self.set_color_scheme(switch (self.color_scheme) {
|
||||
self.force_color_scheme(switch (self.color_scheme) {
|
||||
.dark => .light,
|
||||
.light => .dark,
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue