From e03638a69263aad85e1fffad0096b66254b66af2 Mon Sep 17 00:00:00 2001 From: Daniel Fichtinger Date: Mon, 12 May 2025 03:31:08 -0400 Subject: [PATCH] AutoYADM commit: 2025-05-12 03:31:08 --- .config/kak/autoload/nav.kak | 26 ++++---------------------- .config/kak/scripts/nav.py | 12 +++++++++--- 2 files changed, 13 insertions(+), 25 deletions(-) diff --git a/.config/kak/autoload/nav.kak b/.config/kak/autoload/nav.kak index 15160dc1..5e6bdc1a 100644 --- a/.config/kak/autoload/nav.kak +++ b/.config/kak/autoload/nav.kak @@ -1,25 +1,7 @@ -# 1. Find actual visual column width of content area -# 2. Parse current cursor position and buffer line content -# 3. Split the logical line into chunks based on wrap width -# 4. Move cursor to the same column offset on the wrapped line - +# arg is either "up" or "down" define-command visual-vertical -params 1 %{ - execute-keys %sh{ - line="$kak_cursor_line" - col="$kak_cursor_column" - width="$kak_window_width" - count="$kak_buf_line_count" - path="$kak_buffile" - session="$kak_session" - distance=$($kak_config/scripts/nav.py "$session" "$line" "$col" "$width" "$count" "$path" "$1") + execute-keys %sh{ + distance=$($kak_config/scripts/nav.py "$kak_session" "$kak_cursor_line" "$kak_cursor_column" "$kak_window_width" "$kak_buf_line_count" "$kak_buffile" "$1") echo "$distance" - # TODO: figure out how to jump to this column? - } %sh{ - if [ "$1" = "up" ]; then - echo h - else - echo l - fi - } + } } - diff --git a/.config/kak/scripts/nav.py b/.config/kak/scripts/nav.py index 3c47315e..9c9b9609 100755 --- a/.config/kak/scripts/nav.py +++ b/.config/kak/scripts/nav.py @@ -1,7 +1,9 @@ #!/usr/bin/env python +# TODO: works great when going down, however there are problem +# with going UP if the line above is also wrapped + import sys -# import subprocess session_id = sys.argv[1] line_n = int(sys.argv[2]) @@ -28,6 +30,10 @@ if 0 <= new_visual_row < len(chunks): new_col = min(visual_col, len(target_chunk) - 1) new_abs_col = new_visual_row * wrap_width + new_col diff = abs(new_abs_col - col) - print(diff) - # _ = subprocess.run(args=["kak", "-c"]) + key = "h" if direction == "up" else "l" + print(f"{diff}{key}") +else: + print( + "j" if direction == "down" else "k" + )