feat: add scroll_keybind_hints command

This commit is contained in:
CJ van den Berg 2025-12-01 22:13:02 +01:00
parent a296471161
commit 3012fdcd90
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
3 changed files with 20 additions and 1 deletions

View file

@ -2,6 +2,7 @@
"project": { "project": {
"press": [ "press": [
["ctrl+?", "toggle_keybind_hints"], ["ctrl+?", "toggle_keybind_hints"],
["ctrl+alt+?", "scroll_keybind_hints"],
["ctrl+alt+shift+r", "restart"], ["ctrl+alt+shift+r", "restart"],
["ctrl+e", "find_file"], ["ctrl+e", "find_file"],
["ctrl+shift+n", "create_new_file"], ["ctrl+shift+n", "create_new_file"],
@ -382,6 +383,7 @@
"overlay/palette": { "overlay/palette": {
"press": [ "press": [
["ctrl+?", "toggle_keybind_hints"], ["ctrl+?", "toggle_keybind_hints"],
["ctrl+alt+?", "scroll_keybind_hints"],
["alt+f9", "overlay_next_widget_style"], ["alt+f9", "overlay_next_widget_style"],
["alt+!", "add_task"], ["alt+!", "add_task"],
["ctrl+j", "toggle_panel"], ["ctrl+j", "toggle_panel"],
@ -445,6 +447,7 @@
"mini/numeric": { "mini/numeric": {
"press": [ "press": [
["ctrl+?", "toggle_keybind_hints"], ["ctrl+?", "toggle_keybind_hints"],
["ctrl+alt+?", "scroll_keybind_hints"],
["b", "toggle_goto_style"], ["b", "toggle_goto_style"],
["ctrl+q", "quit"], ["ctrl+q", "quit"],
["ctrl+v", "system_paste"], ["ctrl+v", "system_paste"],
@ -461,6 +464,7 @@
"mini/get_char": { "mini/get_char": {
"press": [ "press": [
["ctrl+?", "toggle_keybind_hints"], ["ctrl+?", "toggle_keybind_hints"],
["ctrl+alt+?", "scroll_keybind_hints"],
["ctrl+g", "mini_mode_cancel"], ["ctrl+g", "mini_mode_cancel"],
["ctrl+c", "mini_mode_cancel"], ["ctrl+c", "mini_mode_cancel"],
["ctrl+l", "scroll_view_center_cycle"], ["ctrl+l", "scroll_view_center_cycle"],
@ -473,6 +477,7 @@
"mini/buffer": { "mini/buffer": {
"press": [ "press": [
["ctrl+?", "toggle_keybind_hints"], ["ctrl+?", "toggle_keybind_hints"],
["ctrl+alt+?", "scroll_keybind_hints"],
["ctrl+q", "quit"], ["ctrl+q", "quit"],
["ctrl+v", "system_paste"], ["ctrl+v", "system_paste"],
["ctrl+u", "mini_mode_reset"], ["ctrl+u", "mini_mode_reset"],
@ -492,6 +497,7 @@
"mini/file_browser": { "mini/file_browser": {
"press": [ "press": [
["ctrl+?", "toggle_keybind_hints"], ["ctrl+?", "toggle_keybind_hints"],
["ctrl+alt+?", "scroll_keybind_hints"],
["ctrl+q", "quit"], ["ctrl+q", "quit"],
["ctrl+v", "system_paste"], ["ctrl+v", "system_paste"],
["ctrl+u", "mini_mode_reset"], ["ctrl+u", "mini_mode_reset"],
@ -520,6 +526,7 @@
"mini/find_in_files": { "mini/find_in_files": {
"press": [ "press": [
["ctrl+?", "toggle_keybind_hints"], ["ctrl+?", "toggle_keybind_hints"],
["ctrl+alt+?", "scroll_keybind_hints"],
["ctrl+q", "quit"], ["ctrl+q", "quit"],
["ctrl+v", "system_paste"], ["ctrl+v", "system_paste"],
["ctrl+u", "mini_mode_reset"], ["ctrl+u", "mini_mode_reset"],
@ -554,6 +561,7 @@
"mini/find": { "mini/find": {
"press": [ "press": [
["ctrl+?", "toggle_keybind_hints"], ["ctrl+?", "toggle_keybind_hints"],
["ctrl+alt+?", "scroll_keybind_hints"],
["ctrl+q", "quit"], ["ctrl+q", "quit"],
["ctrl+v", "system_paste"], ["ctrl+v", "system_paste"],
["ctrl+u", "mini_mode_reset"], ["ctrl+u", "mini_mode_reset"],

View file

@ -8,6 +8,8 @@ const Widget = @import("Widget.zig");
const widget_type: Widget.Type = .hint_window; const widget_type: Widget.Type = .hint_window;
var show_page: usize = 0;
pub fn render_current_input_mode(allocator: std.mem.Allocator, select_mode: keybind.SelectMode, theme: *const Widget.Theme) void { pub fn render_current_input_mode(allocator: std.mem.Allocator, select_mode: keybind.SelectMode, theme: *const Widget.Theme) void {
const mode = tui.input_mode() orelse return; const mode = tui.input_mode() orelse return;
const bindings = blk: { const bindings = blk: {
@ -25,9 +27,13 @@ pub fn render_current_key_event_sequence(allocator: std.mem.Allocator, select_mo
return render(bindings, theme, .no_key_event_prefix); return render(bindings, theme, .no_key_event_prefix);
} }
pub fn scroll() void {
show_page += 1;
}
const RenderMode = enum { full, no_key_event_prefix }; const RenderMode = enum { full, no_key_event_prefix };
pub fn render(bindings: []const keybind.Binding, theme: *const Widget.Theme, mode: RenderMode) void { fn render(bindings: []const keybind.Binding, theme: *const Widget.Theme, mode: RenderMode) void {
// return if something is already rendering to the top layer // return if something is already rendering to the top layer
if (tui.have_top_layer()) return; if (tui.have_top_layer()) return;
if (bindings.len == 0) return; if (bindings.len == 0) return;

View file

@ -1057,6 +1057,11 @@ const cmds = struct {
} }
pub const toggle_keybind_hints_meta: Meta = .{ .description = "Toggle keybind hints" }; pub const toggle_keybind_hints_meta: Meta = .{ .description = "Toggle keybind hints" };
pub fn scroll_keybind_hints(_: *Self, _: Ctx) Result {
@import("keyhints.zig").scroll();
}
pub const scroll_keybind_hints_meta: Meta = .{ .description = "Scroll keybind hints" };
pub fn force_color_scheme(self: *Self, ctx: Ctx) Result { pub fn force_color_scheme(self: *Self, ctx: Ctx) Result {
self.force_color_scheme(if (try ctx.args.match(.{"dark"})) self.force_color_scheme(if (try ctx.args.match(.{"dark"}))
.dark .dark