aboutsummaryrefslogtreecommitdiffstats
path: root/incdec
diff options
context:
space:
mode:
authorTeddy Wing2021-08-24 20:17:46 +0200
committerTeddy Wing2021-08-24 20:29:58 +0200
commitd5b6179e47d71ab5ce151fe1af9a5288bab418df (patch)
treef4669eb5e493deb7396f222500b2abc953fc47a6 /incdec
parentd704b029c93adec24c3d2556974e8947b15ad2a0 (diff)
downloadreadline-incdec-d5b6179e47d71ab5ce151fe1af9a5288bab418df.tar.bz2
incdec: Remove old code
Now that we have this working, remove the old functions, binding definitions, and TODOs. All TODOs here are handled. The old Bash functions and bindings were for a Bash-only implementation. The point-moving code in `__readline_incdec_decrement` wasn't applicable to decrementing numbers.
Diffstat (limited to 'incdec')
-rw-r--r--incdec67
1 files changed, 0 insertions, 67 deletions
diff --git a/incdec b/incdec
index e898165..85336fc 100644
--- a/incdec
+++ b/incdec
@@ -1,61 +1,7 @@
-function incdec {
- local EX_DATAERR=65
-
- # Portion of the line from point to the end of the line.
- local line_part="${READLINE_LINE:$READLINE_POINT}"
-
- # Number to increment.
- local number=
-
- # If the line part doesn't contain a number, exit.
- # if ! [[ "$line_part" =~ [^0-9]*([0-9]+)[^0-9]* ]]; then
- # return $EX_DATAERR
- # fi
-
- number=${BASH_REMATCH[1]}
-
- # echo "${READLINE_LINE}"
- # echo "${BASH_REMATCH[0]}"
- # echo "$(($number + 1))"
-
- incremented_line="$(echo "$line_part" | perl -pe 's/(\d+)/$1+1/e')"
-
- # echo "${READLINE_LINE:0:$READLINE_POINT}$incremented_line"
- READLINE_LINE="${READLINE_LINE:0:$READLINE_POINT}$incremented_line"
- # echo 'this is a test'
-}
-
-function __readline_incdec_incdec2 {
- # echo "!!"
- echo !#
-}
-
-# function __readline_incdec_perl {
-# perl
-# }
-
-# bind -x '"\C-xa+":incdec'
-# bind '"\C-xa+": "\C-e$(incdec)\e\C-e"'
-# bind '"\C-xa+": "\C-e`incdec`"'
-# bind '"\C-xaa":\C-xa+'
-
-function __readline_incdec_save_readline_point {
- __readline_incdec_readline_point="$READLINE_POINT"
-}
-
-bind -x '"\C-xasrp": __readline_incdec_save_readline_point'
-
-# bind '"\C-xaa": \C-xasrp\C-c$(__readline_incdec_incdec2)\e\C-e'
-# bind '"\C-xaa": \C-xasrp'
-# bind '"\C-xaa": __readline_incdec_incdec2'
-
function __readline_incdec {
local increment_by="$1"
local backward="$2"
- # local incdec =
- # print "$line, ${"increment-by"}, ${"point-position"}, $backward";
-
line=$(perl -s -e '
sub incdec {
my ($line, $increment_by, $point_position, $is_backward) = @_;
@@ -107,13 +53,7 @@ print $output;
-backward="$backward"
)
- # echo "$line"
-
READLINE_LINE="$line"
-
- # TODO: If point was at the end, put it at the end again. The length of he line may have changed.
-
- # TODO 2021.08.22: If new READLINE_LINE is longer, move point to the right. If shorter, move it to the left.
}
function __readline_incdec_increment {
@@ -137,15 +77,8 @@ function __readline_incdec_decrement {
if [ "$old_line_length" -lt "$new_line_length" ]; then
READLINE_POINT="$(($READLINE_POINT + 1))"
- # elif [ "$old_line_length" -gt "$new_line_length" ]; then
- # READLINE_POINT="$(($READLINE_POINT - 1))"
fi
}
bind -x '"\C-x-": __readline_incdec_decrement'
bind -x '"\C-x+": __readline_incdec_increment'
-
-
-# 2021.01.15: Idea: Maybe try using $EDITOR
-
-# 2021.08.20: Idea: If point is at start, use forward matching, if point is at end, use backward matching