optionally show help menu for input actions
parent
2a4e85c868
commit
91a44aa884
|
@ -208,13 +208,14 @@ EditorAction :: proc(state: ^State, user_data: rawptr);
|
||||||
InputActions :: struct {
|
InputActions :: struct {
|
||||||
key_actions: map[Key]Action,
|
key_actions: map[Key]Action,
|
||||||
ctrl_key_actions: map[Key]Action,
|
ctrl_key_actions: map[Key]Action,
|
||||||
|
show_help: bool,
|
||||||
}
|
}
|
||||||
Action :: struct {
|
Action :: struct {
|
||||||
action: InputGroup,
|
action: InputGroup,
|
||||||
description: string,
|
description: string,
|
||||||
}
|
}
|
||||||
|
|
||||||
new_input_map :: proc(allocator := context.allocator) -> InputMap {
|
new_input_map :: proc(show_help: bool = false, allocator := context.allocator) -> InputMap {
|
||||||
context.allocator = allocator
|
context.allocator = allocator
|
||||||
|
|
||||||
input_map := InputMap {
|
input_map := InputMap {
|
||||||
|
@ -228,15 +229,19 @@ new_input_map :: proc(allocator := context.allocator) -> InputMap {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
normal_actions := &input_map.mode[.Normal]
|
||||||
|
normal_actions.show_help = show_help
|
||||||
|
|
||||||
return input_map;
|
return input_map;
|
||||||
}
|
}
|
||||||
|
|
||||||
new_input_actions :: proc(allocator := context.allocator) -> InputActions {
|
new_input_actions :: proc(show_help: bool = false, allocator := context.allocator) -> InputActions {
|
||||||
context.allocator = allocator
|
context.allocator = allocator
|
||||||
|
|
||||||
input_actions := InputActions {
|
input_actions := InputActions {
|
||||||
key_actions = make(map[Key]Action),
|
key_actions = make(map[Key]Action),
|
||||||
ctrl_key_actions = make(map[Key]Action),
|
ctrl_key_actions = make(map[Key]Action),
|
||||||
|
show_help = show_help,
|
||||||
}
|
}
|
||||||
|
|
||||||
return input_actions;
|
return input_actions;
|
||||||
|
|
|
@ -100,8 +100,7 @@ draw :: proc(state: ^State) {
|
||||||
ui.compute_layout(new_ui)
|
ui.compute_layout(new_ui)
|
||||||
ui.draw(new_ui, state)
|
ui.draw(new_ui, state)
|
||||||
|
|
||||||
// TODO: figure out when to not show the input help menu
|
if state.mode != .Insert && state.current_input_map.show_help {
|
||||||
if false && state.mode != .Insert { // && state.current_input_map != &state.input_map.mode[state.mode] {
|
|
||||||
longest_description := 0;
|
longest_description := 0;
|
||||||
for key, action in state.current_input_map.key_actions {
|
for key, action in state.current_input_map.key_actions {
|
||||||
if len(action.description) > longest_description {
|
if len(action.description) > longest_description {
|
||||||
|
|
|
@ -46,13 +46,14 @@ make_file_buffer_panel :: proc(file_path: string, line: int = 0, col: int = 0) -
|
||||||
panel_state.buffer = buffer
|
panel_state.buffer = buffer
|
||||||
}
|
}
|
||||||
|
|
||||||
leader_actions := core.new_input_actions()
|
leader_actions := core.new_input_actions(show_help = true)
|
||||||
register_default_leader_actions(&leader_actions);
|
register_default_leader_actions(&leader_actions);
|
||||||
file_buffer_leader_actions(&leader_actions);
|
file_buffer_leader_actions(&leader_actions);
|
||||||
core.register_key_action(&panel.input_map.mode[.Normal], .SPACE, leader_actions, "leader commands");
|
core.register_key_action(&panel.input_map.mode[.Normal], .SPACE, leader_actions, "leader commands");
|
||||||
|
|
||||||
core.register_ctrl_key_action(&panel.input_map.mode[.Normal], .W, core.new_input_actions(), "Panel Navigation")
|
panel_actions := core.new_input_actions(show_help = true)
|
||||||
register_default_panel_actions(&(&panel.input_map.mode[.Normal].ctrl_key_actions[.W]).action.(core.InputActions))
|
register_default_panel_actions(&panel_actions)
|
||||||
|
core.register_ctrl_key_action(&panel.input_map.mode[.Normal], .W, panel_actions, "Panel Navigation")
|
||||||
|
|
||||||
file_buffer_input_actions(&panel.input_map.mode[.Normal]);
|
file_buffer_input_actions(&panel.input_map.mode[.Normal]);
|
||||||
file_buffer_visual_actions(&panel.input_map.mode[.Visual]);
|
file_buffer_visual_actions(&panel.input_map.mode[.Visual]);
|
||||||
|
|
|
@ -66,12 +66,13 @@ make_grep_panel :: proc() -> core.Panel {
|
||||||
}
|
}
|
||||||
mem.arena_init(&panel_state.query_arena, arena_bytes)
|
mem.arena_init(&panel_state.query_arena, arena_bytes)
|
||||||
|
|
||||||
panel.input_map = core.new_input_map()
|
panel.input_map = core.new_input_map(show_help = true)
|
||||||
panel_state.glyphs = core.make_glyph_buffer(256,256)
|
panel_state.glyphs = core.make_glyph_buffer(256,256)
|
||||||
panel_state.buffer = core.new_virtual_file_buffer()
|
panel_state.buffer = core.new_virtual_file_buffer()
|
||||||
|
|
||||||
core.register_ctrl_key_action(&panel.input_map.mode[.Normal], .W, core.new_input_actions(), "Panel Navigation")
|
panel_actions := core.new_input_actions(show_help = true)
|
||||||
register_default_panel_actions(&(&panel.input_map.mode[.Normal].ctrl_key_actions[.W]).action.(core.InputActions))
|
register_default_panel_actions(&panel_actions)
|
||||||
|
core.register_ctrl_key_action(&panel.input_map.mode[.Normal], .W, panel_actions, "Panel Navigation")
|
||||||
|
|
||||||
core.register_key_action(&panel.input_map.mode[.Normal], .ENTER, proc(state: ^core.State, user_data: rawptr) {
|
core.register_key_action(&panel.input_map.mode[.Normal], .ENTER, proc(state: ^core.State, user_data: rawptr) {
|
||||||
this_panel := transmute(^core.Panel)user_data
|
this_panel := transmute(^core.Panel)user_data
|
||||||
|
|
Loading…
Reference in New Issue