Compare commits

..

1 Commits

Author SHA1 Message Date
fff22c22d7 Fix bug in almostontop that truncated long prompts
Add collection of cursor line immediately after the previous command
completes and use this when calculating the number of lines required to
move the screen in order to display only the latest prompt.
2021-12-07 16:56:08 +00:00

View File

@ -132,14 +132,16 @@ fresh_line_one() {
# Executed before each prompt. # Executed before each prompt.
fresh_almostontop_precmd() { fresh_almostontop_precmd() {
# TODO: store the cursor position for use in fresh_almostontop_preexec
# CSI ESC[6n gets the cursor position in the form ESC[<row>;<column>R # CSI ESC[6n gets the cursor position in the form ESC[<row>;<column>R
printf "\033[6n" printf "\033[6n"
# Discard prefix delimited by [ # Discard prefix delimited by [
read -s -d [ read -s -d [
# Store the <row> delimited by ; in row_before # Store the <row> delimited by ; in fresh_precmd_row
read -s -d \; row_before read -s -d \; fresh_precmd_row
# Discard suffix delimted by R otherwise it is output to the tty # Discard suffix delimted by R otherwise it is output to the tty
read -s -d R read -s -d R
# printf "$fresh_precmd_row\n"
} }
# Executed just after a command has been read and is about to be executed. # Executed just after a command has been read and is about to be executed.
@ -157,7 +159,7 @@ fresh_almostontop_preexec() {
let "down = $LINES - $row" let "down = $LINES - $row"
printf "\033[${down}B" printf "\033[${down}B"
# Calculate the number of lines in the prompt # Calculate the number of lines in the prompt
let "prompt_lines = ($row - $row_before) + 2" let "prompt_lines = ($row - $fresh_precmd_row) + 2"
# Print new lines to push the old command out of view # Print new lines to push the old command out of view
let "new = $row - $prompt_lines" let "new = $row - $prompt_lines"
for (( i = 0; i < $new; i++ )); do for (( i = 0; i < $new; i++ )); do