AutoYADM commit: 2025-05-16 17:14:15

This commit is contained in:
Daniel Fichtinger 2025-05-16 17:14:15 -04:00
parent 51ccc1e607
commit b9cc8e936f
9 changed files with 78 additions and 171 deletions

View file

@ -1,18 +0,0 @@
#!/usr/bin/env perl
use strict;
use warnings;
my $Indent = 0;
my $Blank_Lines = 0;
my $Open = qr/[{\[(]$/;
my $Close = qr/^[}\])]/;
while (<>) {
s/^\h*//;
$Blank_Lines++, next if m/^$/;
my $Comment = m/^#/;
$Indent-- if m/$Close/ and not $Comment;
$Blank_Lines = 0, print "\n" if $Blank_Lines;
print "\t" x $Indent, $_;
$Indent++ if m/$Open/ and not $Comment;
}

View file

@ -1,3 +0,0 @@
#!/usr/bin/env fish
echo nav

View file

@ -1,60 +0,0 @@
#!/usr/bin/env python
# TODO: works great for moving within wrapped line,
# not quite when moving from wrapped to normal and vice versa
# 1. Detect line-wrap status of target line before deciding to do vertical jump or visual column shift
# 2. Load the target line in addition
# 3. Use the same wrap_width logic to compare visual row availability
# on the target line
# Basically, look at the target line, and figure out the logical column
# number that corresponds to the visual column number we see right now.
# ISSUE: does not work if the line has indentation
# Also TODO: once this is ironed out, re-write it in Rust for le speed
import sys
import re
session_id = sys.argv[1]
line_n = int(sys.argv[2])
col = int(sys.argv[3])
width = int(sys.argv[4])
count = int(sys.argv[5])
path = sys.argv[6]
direction = sys.argv[7]
digits = len(str(count))
wrap_width = width - (digits + 3)
line = ""
with open(path, "r") as f:
for n, l in enumerate(f, start=1):
if n == line_n:
line = l
# match = re.match(r"^(\s*)", line)
# if match:
# indent = match.group(1)
# indent_len = len(indent)
# else:
# indent_len = 0
# content = line[indent_len:]
content = line
indent_len = 0
chunks = [content[i : i + wrap_width] for i in range(0, len(content), wrap_width)]
visual_row = col // wrap_width
visual_col = col % wrap_width
new_visual_row = visual_row + (-1 if direction == "up" else 1)
if 0 <= new_visual_row < len(chunks):
target_chunk = chunks[new_visual_row]
new_col = min(visual_col, len(target_chunk) - 1)
new_abs_col = indent_len + (new_visual_row * wrap_width + new_col)
diff = abs(new_abs_col - col)
key = "h" if direction == "up" else "l"
print(f"{diff}{key}")
else:
print("j" if direction == "down" else "k")