Skip to content

Commit

Permalink
small stylistic changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchellh committed Aug 25, 2024
1 parent b8d4969 commit 8e2d63b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 20 deletions.
4 changes: 2 additions & 2 deletions src/terminal/kitty/color.zig
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ pub const Kind = union(enum) {
special: Special,

pub fn parse(key: []const u8) ?Kind {
if (std.meta.stringToEnum(Special, key)) |s| return Kind{ .special = s };
return Kind{ .palette = std.fmt.parseUnsigned(u8, key, 10) catch return null };
if (std.meta.stringToEnum(Special, key)) |s| return .{ .special = s };
return .{ .palette = std.fmt.parseUnsigned(u8, key, 10) catch return null };
}

pub fn format(
Expand Down
26 changes: 8 additions & 18 deletions src/termio/stream_handler.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1345,25 +1345,20 @@ pub const StreamHandler = struct {
self.terminal.color_palette.colors[palette] = v.color;
self.terminal.color_palette.mask.unset(palette);
},

.special => |special| {
const msg: renderer.Message = switch (special) {
.foreground => msg: {
self.foreground_color = v.color;
break :msg .{
.foreground_color = v.color,
};
break :msg .{ .foreground_color = v.color };
},
.background => msg: {
self.background_color = v.color;
break :msg .{
.background_color = v.color,
};
break :msg .{ .background_color = v.color };
},
.cursor => msg: {
self.cursor_color = v.color;
break :msg .{
.cursor_color = v.color,
};
break :msg .{ .cursor_color = v.color };
},
else => {
log.warn(
Expand All @@ -1385,25 +1380,20 @@ pub const StreamHandler = struct {
self.terminal.color_palette.colors[palette] = self.terminal.default_palette[palette];
self.terminal.color_palette.mask.unset(palette);
},

.special => |special| {
const msg: renderer.Message = switch (special) {
.foreground => msg: {
self.foreground_color = self.default_foreground_color;
break :msg .{
.foreground_color = self.default_foreground_color,
};
break :msg .{ .foreground_color = self.default_foreground_color };
},
.background => msg: {
self.background_color = self.default_background_color;
break :msg .{
.background_color = self.default_background_color,
};
break :msg .{ .background_color = self.default_background_color };
},
.cursor => msg: {
self.cursor_color = self.default_cursor_color;
break :msg .{
.cursor_color = self.default_cursor_color,
};
break :msg .{ .cursor_color = self.default_cursor_color };
},
else => {
log.warn(
Expand Down

0 comments on commit 8e2d63b

Please sign in to comment.