Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Below is an example configuration file that replicates the default settings. You
"width_mode": { "key": "w" },
"colorize": { "key": "z" },
"quit": { "key": "c", "modifiers": [ "ctrl" ] },
"full_screen": { "key": "f"},
"enter_command_mode": { "key": ":" },
"exit_command_mode": { "key": "escape" },
"execute_command": { "key": "enter" }
Expand Down Expand Up @@ -105,6 +106,7 @@ The `KeyMap` section defines keybindings for various actions.
| `width_mode` | Toggle between full-height or full-width mode |
| `colorize` | Toggle color replacement |
| `quit` | Exit the program |
| `full_screen` | Toggle full screen (i.e. hide status bar) |
| `enter_command_mode` | Enter command mode |
| `exit_command_mode` | Exit command mode |
| `execute_command` | Execute the entered command |
Expand Down
4 changes: 4 additions & 0 deletions src/Context.zig
Original file line number Diff line number Diff line change
Expand Up @@ -464,4 +464,8 @@ pub const Context = struct {
self.current_mode.command.drawCommandBar(win);
}
}

pub fn toggleFullScreen(self: *Self) void {
self.config.status_bar.enabled = !self.config.status_bar.enabled;
}
};
38 changes: 32 additions & 6 deletions src/config/Config.zig
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pub const KeyMap = struct {
width_mode: vaxis.Key = .{ .codepoint = 'w' },
colorize: vaxis.Key = .{ .codepoint = 'z' },
quit: vaxis.Key = .{ .codepoint = 'c', .mods = .{ .ctrl = true } },
full_screen: vaxis.Key = .{ .codepoint = 'f' },
enter_command_mode: vaxis.Key = .{ .codepoint = ':' },
exit_command_mode: vaxis.Key = .{ .codepoint = vaxis.Key.escape },
execute_command: vaxis.Key = .{ .codepoint = vaxis.Key.enter },
Expand All @@ -23,7 +24,10 @@ pub const KeyMap = struct {
if (val != .object) return keymap;

inline for (std.meta.fields(KeyMap)) |key| {
@field(keymap, key.name) = parseKeyBinding(val.object, key.name, allocator, @field(keymap, key.name));
@field(keymap, key.name) = parseKeyBinding(val.object, key.name, allocator, @field(
keymap,
key.name,
));
}

return keymap;
Expand All @@ -40,9 +44,27 @@ pub const FileMonitor = struct {
var file_monitor = FileMonitor{};
if (val != .object) return file_monitor;

file_monitor.enabled = parseType(bool, val.object, "enabled", allocator, file_monitor.enabled);
file_monitor.latency = parseType(f16, val.object, "latency", allocator, file_monitor.latency);
file_monitor.reload_indicator_duration = parseType(f16, val.object, "reload_indicator_duration", allocator, file_monitor.reload_indicator_duration);
file_monitor.enabled = parseType(
bool,
val.object,
"enabled",
allocator,
file_monitor.enabled,
);
file_monitor.latency = parseType(
f16,
val.object,
"latency",
allocator,
file_monitor.latency,
);
file_monitor.reload_indicator_duration = parseType(
f16,
val.object,
"reload_indicator_duration",
allocator,
file_monitor.reload_indicator_duration,
);

return file_monitor;
}
Expand Down Expand Up @@ -74,12 +96,16 @@ pub const General = struct {

if (val.object.get("white")) |white| {
if (parseRGB(white, allocator)) |rgb| {
general.white = @intCast((@as(u32, rgb[0]) << 16) | (@as(u32, rgb[1]) << 8) | @as(u32, rgb[2]));
general.white = @intCast(
(@as(u32, rgb[0]) << 16) | (@as(u32, rgb[1]) << 8) | @as(u32, rgb[2]),
);
}
}
if (val.object.get("black")) |black| {
if (parseRGB(black, allocator)) |rgb| {
general.black = @intCast((@as(u32, rgb[0]) << 16) | (@as(u32, rgb[1]) << 8) | @as(u32, rgb[2]));
general.black = @intCast(
(@as(u32, rgb[0]) << 16) | (@as(u32, rgb[1]) << 8) | @as(u32, rgb[2]),
);
}
}

Expand Down
10 changes: 10 additions & 0 deletions src/modes/ViewMode.zig
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,16 @@ pub fn handleKeyStroke(self: *Self, key: vaxis.Key, km: Config.KeyMap) !void {
}
}.action,
},
.{
.codepoint = km.full_screen.codepoint,
.mods = km.full_screen.mods,
.handler = struct {
fn action(s: *Context) void {
s.toggleFullScreen();
s.reload_page = true;
}
}.action,
},
.{
.codepoint = km.scroll_up.codepoint,
.mods = km.scroll_up.mods,
Expand Down