From 43c88c9bbc14cb29792d2b3a7341be1ec4687bc2 Mon Sep 17 00:00:00 2001 From: nadrad Date: Wed, 4 Mar 2026 11:30:00 +0100 Subject: [PATCH] moving viewport with ctrl+arrows --- h-m-m | 49 +++++++++++++++++++++++++++++++++++++++++++------ readme.md | 8 ++++++++ 2 files changed, 51 insertions(+), 6 deletions(-) diff --git a/h-m-m b/h-m-m index 4d20654..43dc1e3 100755 --- a/h-m-m +++ b/h-m-m @@ -241,14 +241,17 @@ const special_keys = 'arr_up' => "\033\133\101", 'arr_left' => "\033\133\104", - 'alt_arr_up' => "\033\133\061\073\063\101", - 'alt_arr_down' => "\033\133\061\073\063\102", + 'alt_arr_up' => "\033\133\061\073\063\101", + 'ctrl_arr_up' => "\033\133\061\073\065\101", - 'meta_arr_left' => "\033\033\133\104", + 'alt_arr_down' => "\033\133\061\073\063\102", + 'ctrl_arr_down' => "\033\133\061\073\065\102", + + 'meta_arr_left' => "\033\033\133\104", 'ctrl_arr_left' => "\033\133\061\073\065\104", 'shift_arr_left' => "\033\133\061\073\062\104", - 'meta_arr_right'=> "\033\033\133\103", + 'meta_arr_right' => "\033\033\133\103", 'ctrl_arr_right' => "\033\133\061\073\065\103", 'shift_arr_right' => "\033\133\061\073\062\103", @@ -318,17 +321,21 @@ $keybindings['G'] = 'go_to_bottom'; $keybindings['h'] = 'go_left'; $keybindings['H'] = 'toggle_hide'; $keybindings[special_keys['ctrl_h']] = 'toggle_show_hidden'; +$keybindings[special_keys['ctrl_arr_left']] = 'move_viewport_right'; $keybindings['i'] = 'edit_node_append'; $keybindings['I'] = 'edit_node_replace'; $keybindings['j'] = 'go_down'; $keybindings['J'] = 'move_node_down'; +$keybindings[special_keys['ctrl_arr_down']] = 'move_viewport_up'; $keybindings['k'] = 'go_up'; $keybindings['K'] = 'move_node_up'; +$keybindings[special_keys['ctrl_arr_up']] = 'move_viewport_down'; $keybindings['l'] = 'go_right'; +$keybindings[special_keys['ctrl_arr_right']] = 'move_viewport_left'; $keybindings['m'] = 'go_to_root'; $keybindings['~'] = 'go_to_root'; @@ -2664,7 +2671,7 @@ function quit_with_debug() // }}} -// {{{ move_window +// {{{ move_window / viewport function move_window(&$mm) { @@ -2682,6 +2689,37 @@ function move_window(&$mm) $mm['viewport_top'] = max( $mm['viewport_top'], $y2 - $mm['terminal_height']); } +function move_viewport_down() +{ + global $mm; + $mm['viewport_top']++; + build_map($mm); + display($mm); +} + +function move_viewport_up() +{ + global $mm; + $mm['viewport_top']--; + build_map($mm); + display($mm); +} + +function move_viewport_left() +{ + global $mm; + $mm['viewport_left']++; + build_map($mm); + display($mm); +} + +function move_viewport_right() +{ + global $mm; + $mm['viewport_left']=max(0,$mm['viewport_left']-1); + build_map($mm); + display($mm); +} // }}} // {{{ changes @@ -3582,7 +3620,6 @@ function display(&$mm, $force_center = false) echo reset_page.reset_color.$output; - // showing the logo :) if ($mm['show_logo']) diff --git a/readme.md b/readme.md index 6219d06..fe05f67 100644 --- a/readme.md +++ b/readme.md @@ -48,6 +48,10 @@ Relative navigating and moving: Adjusting the view: +* `ctrl+up` - moves the viewpoint up +* `ctrl+down` - moves the viewpoint down +* `ctrl+left` - moves the viewpoint left +* `ctrl+right` - moves the viewpoint right * `c` - centers the active node on the screen * `C` - locks/unlocks active nodes on the center * `~` or `m` - activate the root element @@ -212,6 +216,10 @@ You can also change key bindings with a `bind x = command` syntax. The following bind arr_left = go_left bind alt_arr_up = add_star bind alt_arr_down = remove_star + bind ctrl_arr_up = move_viewport_down + bind ctrl_arr_down = move_viewport_up + bind ctrl_arr_left = move_viewport_right + bind ctrl_arr_right = move_viewport_left bind 1 = collapse_level_1 bind 2 = collapse_level_2 bind 3 = collapse_level_3