Skip to content

Commit

Permalink
🐛 fix cursor on fsfs
Browse files Browse the repository at this point in the history
  • Loading branch information
jcaillon committed Nov 8, 2024
1 parent 7d870c5 commit ab51a9e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
1 change: 1 addition & 0 deletions docs/content/docs/800.roadmap/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ This page lists the features that I would like to implement in Valet. They come
- Betters checks in self build!
- A command can declare dependencies to auto check if some tools are installed before running the command.
- add valet in brew
- add man page for valet
- For argument and option autocompletion, accept any multiline string that will be eval and that should set RETURNED_ARRAY with the list of possible completion.
- allow to do that: `eval "$(valet self uninstall)"` to clean everything up
- functions:
Expand Down
16 changes: 11 additions & 5 deletions valet.d/lib-fsfs
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,10 @@ function fsfsInitialize() {

# contains the current search st+ring of the user
FSFS_SEARCH_STRING=""
FSFS_PROMPT=""

# switched to true when the user wants to close the session
FSFS_CLOSE_INTERACTIVE_SESSION=false
FSFS_SEARCH_STRING=""

# set up colors
if [[ ${VALET_CONFIG_ENABLE_COLORS:-} == "true" ]]; then
Expand Down Expand Up @@ -381,6 +381,9 @@ function drawLeftPane() {
toPrint+="${AC__CURSOR_MOVE__}${line};${FSFS_LEFT_PANE_WIDTH}${__AC__TO}${AC__ERASE_CHARS_LEFT}"
done

# reposition the cursor
toPrint+="${AC__CURSOR_MOVE__}$((FSFS_LEFT_PANE_FIRST_LINE));$((3 + ${#FSFS_PROMPT}))${__AC__TO}${AC__CURSOR_SHOW}"

printf '%s' "${toPrint}"
}

Expand Down Expand Up @@ -473,19 +476,22 @@ function drawRightPane() {
toPrint+="${AC__CURSOR_MOVE__}$((FSFS_RIGHT_PANE_FIRST_CONTENT_LINE + FSFS_RIGHT_PANE_LINES / 2));$((FSFS_LEFT_PANE_WIDTH + 2 + FSFS_RIGHT_PANE_WIDTH / 2 - ${#loadingMessage} / 2))${__AC__TO}${loadingMessage}"
fi

# reposition the cursor
toPrint+="${AC__CURSOR_MOVE__}$((FSFS_LEFT_PANE_FIRST_LINE));$((3 + ${#FSFS_PROMPT}))${__AC__TO}${AC__CURSOR_SHOW}"

printf '%s' "${toPrint}"
}

# Draw the prompt line
function drawPrompt() {
# check if we need to shorten the prompt
local prompt="${FSFS_SEARCH_STRING}"
FSFS_PROMPT="${FSFS_SEARCH_STRING}"
if ((${#FSFS_SEARCH_STRING} > FSFS_LEFT_PANE_WIDTH - 4)); then
prompt="${FSFS_SEARCH_STRING:$((${#FSFS_SEARCH_STRING} - (FSFS_LEFT_PANE_WIDTH - 4) + 1))}"
FSFS_PROMPT="${FSFS_SEARCH_STRING:$((${#FSFS_SEARCH_STRING} - (FSFS_LEFT_PANE_WIDTH - 4) + 1))}"
else
prompt="${FSFS_SEARCH_STRING}"
FSFS_PROMPT="${FSFS_SEARCH_STRING}"
fi
printf '%s' "${AC__CURSOR_HIDE}${AC__CURSOR_MOVE__}$((FSFS_LEFT_PANE_FIRST_LINE));$((FSFS_LEFT_PANE_WIDTH))${__AC__TO}${AC__ERASE_CHARS_LEFT}"$'\r'"${FSFS_COLOR_STATIC}> ${FSFS_COLOR_RESET_TEXT}${FSFS_COLOR_FOCUS}${prompt}${AC__CURSOR_SHOW}"
printf '%s' "${AC__CURSOR_HIDE}${AC__CURSOR_MOVE__}$((FSFS_LEFT_PANE_FIRST_LINE));$((FSFS_LEFT_PANE_WIDTH))${__AC__TO}${AC__ERASE_CHARS_LEFT}"$'\r'"${FSFS_COLOR_STATIC}> ${FSFS_COLOR_RESET_TEXT}${FSFS_COLOR_FOCUS}${FSFS_PROMPT}${AC__CURSOR_SHOW}"
}

# Returns the index of the item in the original array (if any, or -1).
Expand Down
2 changes: 1 addition & 1 deletion valet.d/lib-interactive
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ function interactive::displayQuestion() {
# ┌─────┐
# │ No. ├──░
# └─────┘
# ```)
# ```
#
# - $1: **answer** _as string_:
# the answer to display
Expand Down

0 comments on commit ab51a9e

Please sign in to comment.