nicer cheatsheet (#607)

This commit is contained in:
end-4
2024-06-15 21:06:30 +07:00
parent 059c8937ca
commit edbb3cb956
3 changed files with 79 additions and 56 deletions
+9 -3
View File
@@ -7,6 +7,7 @@ from typing import Dict, List
TITLE_REGEX = "#+!"
HIDE_COMMENT = "[hidden]"
MOD_SEPARATORS = ['+', ' ']
COMMENT_BIND_PATTERN = "#/#"
parser = argparse.ArgumentParser(description='Hyprland keybind reader')
parser.add_argument('--path', type=str, default="$HOME/.config/hypr/hyprland.conf", help='path to keybind file (sourcing isn\'t supported)')
@@ -56,7 +57,7 @@ def autogenerate_comment(dispatcher: str, params: str = "") -> str:
}.get(params, "null"))
case "pin":
return "Pin window"
return "Window: pin (show on all workspaces)"
case "splitratio":
return "Window split ratio {}".format(params)
@@ -124,7 +125,7 @@ def autogenerate_comment(dispatcher: str, params: str = "") -> str:
return "Window: move to workspace {}".format(params)
case "togglespecialworkspace":
return "Toggle special workspace"
return "Workspace: toggle special"
case "exec":
return "Execute: {}".format(params)
@@ -132,7 +133,7 @@ def autogenerate_comment(dispatcher: str, params: str = "") -> str:
case _:
return ""
def get_keybind_at_line(line_number):
def get_keybind_at_line(line_number, line_start = 0):
global content_lines
line = content_lines[line_number]
_, keys = line.split("=", 1)
@@ -186,6 +187,11 @@ def get_binds_recursive(current_content, scope):
reading_line += 1
current_content["children"].append(get_binds_recursive(Section([], [], section_name), heading_scope))
elif line.startswith(COMMENT_BIND_PATTERN):
keybind = get_keybind_at_line(reading_line, line_start=len(COMMENT_BIND_PATTERN))
if(keybind != None):
current_content["keybinds"].append(keybind)
elif line == "" or line.startswith("$") or line.startswith("#"): # Comment, ignore
pass