Skip to content

Commit acb035b

Browse files
fix: terminal UI and entries editor bugs
- Fix terminal_ui to use python_search binary instead of pys for loading entries - Add entries_editor script to pyproject.toml - Fix search_actions to use SystemPaths for entries_editor binary - Add custom window size for entries editor (100x40 chars) - Fix duplicate remember_window_size setting in terminal params
1 parent ae3baaf commit acb035b

5 files changed

Lines changed: 25 additions & 6 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,4 @@ term_ui = 'python_search.search.search_ui.terminal_ui:main'
6969
register_new_launch_ui = 'python_search.entry_capture.entry_inserter_gui.register_new_gui:launch_ui'
7070
google_it = 'python_search.apps.google_it:main'
7171
share_entry = 'python_search.share_entry:main'
72+
entries_editor = 'python_search.entry_capture.entries_editor:main'

python_search/apps/terminal.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@ class KittyTerminal:
1414
# these parameters are applied both to all kitty windows of pythons search
1515
# including the generic params and the python search main window
1616
GLOBAL_TERMINAL_PARAMS = (
17-
" -o remember_window_size=yes "
17+
" -o remember_window_size=no "
1818
+ " -o confirm_os_window_close=0 "
19-
+ " -o remember_window_size=n "
2019
+ " -o resize_in_steps=1 "
2120
+ " -o macos_quit_when_last_window_closed=yes "
2221
)

python_search/entry_capture/entries_editor.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,22 @@ def edit_key(self, key_expr: str):
7070
def edit_default(self):
7171
import os
7272

73+
terminal = KittyTerminal()
74+
editor_params = (
75+
f" {terminal.GLOBAL_TERMINAL_PARAMS} "
76+
f" -o initial_window_width={self.EDITOR_WIDTH} "
77+
f" -o initial_window_height={self.EDITOR_HEIGHT} "
78+
f" -o font_size={self.EDITOR_FONT_SIZE} "
79+
)
7380
os.system(
74-
f"kitty vim '{self.configuration.get_project_root() + '/entries_main.py'}'"
81+
f"{terminal.get_kitty_cmd()} {editor_params} vim '{self.configuration.get_project_root()}/entries_main.py'"
7582
)
7683

84+
# Editor-specific window settings (squared window for editing)
85+
EDITOR_WIDTH = "100c"
86+
EDITOR_HEIGHT = "40c"
87+
EDITOR_FONT_SIZE = 14
88+
7789
def _edit_file(self, file_name: str, line: Optional[int] = 30, dry_run=False):
7890
"""
7991
edit a configuration file given the name and line
@@ -82,8 +94,15 @@ def _edit_file(self, file_name: str, line: Optional[int] = 30, dry_run=False):
8294
# @ todo make this editor generic
8395

8496
terminal = KittyTerminal()
97+
# Use editor-specific window size instead of generic terminal params
98+
editor_params = (
99+
f" {terminal.GLOBAL_TERMINAL_PARAMS} "
100+
f" -o initial_window_width={self.EDITOR_WIDTH} "
101+
f" -o initial_window_height={self.EDITOR_HEIGHT} "
102+
f" -o font_size={self.EDITOR_FONT_SIZE} "
103+
)
85104
cmd: str = (
86-
f" {terminal.get_kitty_cmd()} {terminal.GENERIC_TERMINAL_PARAMS} "
105+
f" {terminal.get_kitty_cmd()} {editor_params} "
87106
f"bash -c 'cd {self.configuration.get_project_root()} && "
88107
f"{self._get_open_text_editor_command(file_name, line)}'"
89108
)

python_search/search/search_ui/search_actions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def edit_key(self, key: str, block: bool = False) -> None:
3030
key: The identifier for the entry to edit
3131
block: Whether to block execution (currently unused)
3232
"""
33-
cmd = f"/opt/miniconda3/envs/python312/bin/entries_editor " f'edit_key "{key}" &>/dev/null'
33+
cmd = SystemPaths.get_binary_full_path("entries_editor") + f' edit_key "{key}" &>/dev/null'
3434
Popen(cmd, stdout=None, stderr=None, shell=True)
3535

3636
def copy_entry_value_to_clipboard(self, entry_key: str) -> None:

python_search/search/search_ui/terminal_ui.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ def _setup_entries(self):
218218
import subprocess
219219

220220
output = subprocess.getoutput(
221-
SystemPaths.get_binary_full_path("pys") + " _entries_loader load_entries_as_json 2>/dev/null"
221+
SystemPaths.get_binary_full_path("python_search") + " _entries_loader load_entries_as_json 2>/dev/null"
222222
)
223223
# print("output", output)
224224
self.commands = json.loads(output)

0 commit comments

Comments
 (0)