colors, ../ och -a
This commit is contained in:
@@ -28,3 +28,7 @@
|
|||||||
- Cursor can now move to the empty line immediately below the last object.
|
- Cursor can now move to the empty line immediately below the last object.
|
||||||
- `Ctrl+K K` now behaves like joe: the block end is the row immediately above the cursor.
|
- `Ctrl+K K` now behaves like joe: the block end is the row immediately above the cursor.
|
||||||
- On the bottom empty line, `Ctrl+K K` therefore selects through the last object.
|
- On the bottom empty line, `Ctrl+K K` therefore selects through the last object.
|
||||||
|
|
||||||
|
## v2 update
|
||||||
|
- The bottom empty row now visibly shows the cursor.
|
||||||
|
- When TUI exits normally, the shell integration changes the parent Bash shell to the directory where TUI was closed.
|
||||||
|
|||||||
@@ -44,19 +44,31 @@ tui() {
|
|||||||
fi
|
fi
|
||||||
rc=$?
|
rc=$?
|
||||||
|
|
||||||
|
tui_cwd="$(<"$cwd_file")"
|
||||||
|
|
||||||
|
if [[ -z "$tui_cwd" || ! -d "$tui_cwd" ]]; then
|
||||||
if (( rc != 42 )); then
|
if (( rc != 42 )); then
|
||||||
rm -f "$command_file" "$cwd_file"
|
rm -f "$command_file" "$cwd_file"
|
||||||
return "$rc"
|
return "$rc"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
tui_cwd="$(<"$cwd_file")"
|
|
||||||
|
|
||||||
if [[ -z "$tui_cwd" || ! -d "$tui_cwd" ]]; then
|
|
||||||
echo "tui: invalid TUI working directory" >&2
|
echo "tui: invalid TUI working directory" >&2
|
||||||
rm -f "$command_file" "$cwd_file"
|
rm -f "$command_file" "$cwd_file"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# A normal TUI exit means the user wants to leave TUI. Change the
|
||||||
|
# parent Bash shell to the directory where TUI was actually closed.
|
||||||
|
if (( rc != 42 )); then
|
||||||
|
if (( rc == 0 )); then
|
||||||
|
cd "$tui_cwd" || {
|
||||||
|
rm -f "$command_file" "$cwd_file"
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
fi
|
||||||
|
rm -f "$command_file" "$cwd_file"
|
||||||
|
return "$rc"
|
||||||
|
fi
|
||||||
|
|
||||||
# Execute all commands belonging to one TUI action before starting
|
# Execute all commands belonging to one TUI action before starting
|
||||||
# TUI again. Each command remains a normal Bash command and gets its
|
# TUI again. Each command remains a normal Bash command and gets its
|
||||||
# own history entry. If a command fails, stop the action and pause so
|
# own history entry. If a command fails, stop the action and pause so
|
||||||
|
|||||||
17
tui/tui.py
17
tui/tui.py
@@ -443,6 +443,8 @@ def draw(stdscr, browser, status=""):
|
|||||||
text = entry.name + ("/" if entry.is_dir() else "")
|
text = entry.name + ("/" if entry.is_dir() else "")
|
||||||
else:
|
else:
|
||||||
# One empty line after the final object, matching the cursor range.
|
# One empty line after the final object, matching the cursor range.
|
||||||
|
# A literal space is needed here: curses does not draw attributes
|
||||||
|
# for an empty string, so the cursor would otherwise be invisible.
|
||||||
entry = None
|
entry = None
|
||||||
is_marked = False
|
is_marked = False
|
||||||
attrs = curses.A_NORMAL
|
attrs = curses.A_NORMAL
|
||||||
@@ -502,6 +504,18 @@ def run(stdscr, start_dir=".", show_all=False):
|
|||||||
|
|
||||||
status = ""
|
status = ""
|
||||||
|
|
||||||
|
def save_cwd():
|
||||||
|
cwd_file = os.environ.get("TUI_CWD_FILE")
|
||||||
|
if cwd_file:
|
||||||
|
try:
|
||||||
|
Path(cwd_file).write_text(str(browser.path), encoding="utf-8")
|
||||||
|
except OSError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
# Always leave the shell wrapper with the directory in which TUI was
|
||||||
|
# actually closed, not merely the directory of the last action.
|
||||||
|
save_cwd()
|
||||||
|
|
||||||
def configured_action(key):
|
def configured_action(key):
|
||||||
if key == curses.KEY_UP:
|
if key == curses.KEY_UP:
|
||||||
return browser.resolve_key_action(["up"], browser.selected())
|
return browser.resolve_key_action(["up"], browser.selected())
|
||||||
@@ -522,6 +536,7 @@ def run(stdscr, start_dir=".", show_all=False):
|
|||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
try:
|
||||||
while True:
|
while True:
|
||||||
draw(stdscr, browser, status)
|
draw(stdscr, browser, status)
|
||||||
status = ""
|
status = ""
|
||||||
@@ -578,6 +593,8 @@ def run(stdscr, start_dir=".", show_all=False):
|
|||||||
return SHELL_HANDOFF
|
return SHELL_HANDOFF
|
||||||
if result is False:
|
if result is False:
|
||||||
return
|
return
|
||||||
|
finally:
|
||||||
|
save_cwd()
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|||||||
Reference in New Issue
Block a user