diff options
| author | Teddy Wing | 2021-08-24 20:34:12 +0200 |
|---|---|---|
| committer | Teddy Wing | 2021-08-24 20:38:32 +0200 |
| commit | 067086adff7134f970a141269856f65ef195f2db (patch) | |
| tree | 559cec0388afffb92b53dc123b76d9c21d6d149e | |
| parent | d5b6179e47d71ab5ce151fe1af9a5288bab418df (diff) | |
| download | readline-incdec-067086adff7134f970a141269856f65ef195f2db.tar.bz2 | |
incdec: Add comments to describe Bash functions
| -rw-r--r-- | incdec | 5 | ||||
| -rw-r--r-- | incdec.m4.bash | 5 |
2 files changed, 10 insertions, 0 deletions
@@ -1,3 +1,4 @@ +# Increment or decrement a number on the current line. function __readline_incdec { local increment_by="$1" local backward="$2" @@ -56,6 +57,7 @@ print $output; READLINE_LINE="$line" } +# Increment the nearest number to the left of point by 1. function __readline_incdec_increment { local old_line_length="${#READLINE_LINE}" @@ -63,11 +65,13 @@ function __readline_incdec_increment { local new_line_length="${#READLINE_LINE}" + # If a negative sign was removed, keep point where it was. if [ "$old_line_length" -gt "$new_line_length" ]; then READLINE_POINT="$(($READLINE_POINT - 1))" fi } +# Decrement the nearest number to the left of point by 1. function __readline_incdec_decrement { local old_line_length="${#READLINE_LINE}" @@ -75,6 +79,7 @@ function __readline_incdec_decrement { local new_line_length="${#READLINE_LINE}" + # If a negative sign was added, keep point where it was. if [ "$old_line_length" -lt "$new_line_length" ]; then READLINE_POINT="$(($READLINE_POINT + 1))" fi diff --git a/incdec.m4.bash b/incdec.m4.bash index 45fac7c..0ec0f51 100644 --- a/incdec.m4.bash +++ b/incdec.m4.bash @@ -1,3 +1,4 @@ +# Increment or decrement a number on the current line. function __readline_incdec { local increment_by="$1" local backward="$2" @@ -15,6 +16,7 @@ INCLUDE_INCDEC_PL READLINE_LINE="$line" } +# Increment the nearest number to the left of point by 1. function __readline_incdec_increment { local old_line_length="${#READLINE_LINE}" @@ -22,11 +24,13 @@ function __readline_incdec_increment { local new_line_length="${#READLINE_LINE}" + # If a negative sign was removed, keep point where it was. if [ "$old_line_length" -gt "$new_line_length" ]; then READLINE_POINT="$(($READLINE_POINT - 1))" fi } +# Decrement the nearest number to the left of point by 1. function __readline_incdec_decrement { local old_line_length="${#READLINE_LINE}" @@ -34,6 +38,7 @@ function __readline_incdec_decrement { local new_line_length="${#READLINE_LINE}" + # If a negative sign was added, keep point where it was. if [ "$old_line_length" -lt "$new_line_length" ]; then READLINE_POINT="$(($READLINE_POINT + 1))" fi |
