2016-05-02 21:15:29 +02:00
|
|
|
#!/usr/bin/env bash
|
2016-04-30 02:42:56 +02:00
|
|
|
|
|
|
|
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
2016-05-08 17:06:02 +02:00
|
|
|
source $CURRENT_DIR/utils.sh
|
2016-05-06 00:25:54 +02:00
|
|
|
|
2016-05-08 17:06:02 +02:00
|
|
|
match_lookup_table=$(fingers_tmp)
|
2016-10-10 23:49:34 +02:00
|
|
|
pane_output_temp=$(fingers_tmp)
|
|
|
|
flushed_input=0
|
2016-05-03 09:05:05 +02:00
|
|
|
|
2016-12-03 19:17:58 +01:00
|
|
|
# exporting them so they can be properly deleted at fingers.sh handle_exit trap
|
|
|
|
export match_lookup_table
|
|
|
|
export pane_output_temp
|
|
|
|
|
2016-04-30 02:42:56 +02:00
|
|
|
function lookup_match() {
|
|
|
|
local input=$1
|
2018-02-27 21:25:44 +01:00
|
|
|
|
|
|
|
input="$(echo "$input" | tr "A-Z" "a-z")"
|
|
|
|
echo "$(cat $match_lookup_table | grep -i "^$input:" | sed "s/^$input://" | head -n 1)"
|
2016-05-23 07:59:10 +02:00
|
|
|
}
|
2016-04-30 02:42:56 +02:00
|
|
|
|
2016-10-10 23:49:34 +02:00
|
|
|
function get_stdin() {
|
|
|
|
if [[ $(cat $pane_output_temp | wc -l) -gt 0 ]]; then
|
|
|
|
cat $pane_output_temp
|
|
|
|
else
|
|
|
|
flushed_input="1"
|
|
|
|
tee $pane_output_temp
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function show_hints() {
|
|
|
|
local fingers_pane_id=$1
|
2016-10-17 21:44:28 +02:00
|
|
|
local compact_hints=$2
|
2016-10-10 23:49:34 +02:00
|
|
|
|
2019-01-14 08:41:21 +01:00
|
|
|
FINGERS_ALPHABET_DIR="$CURRENT_DIR/../alphabets/$FINGERS_KEYBOARD_LAYOUT/"
|
|
|
|
|
2016-10-10 23:49:34 +02:00
|
|
|
clear_screen "$fingers_pane_id"
|
2019-01-14 08:41:21 +01:00
|
|
|
get_stdin | FINGERS_COMPACT_HINTS="$compact_hints" FINGERS_ALPHABET_DIR="$FINGERS_ALPHABET_DIR" gawk -f $CURRENT_DIR/hinter.awk 3> $match_lookup_table
|
2016-10-10 23:49:34 +02:00
|
|
|
}
|
|
|
|
|
2016-05-08 17:06:02 +02:00
|
|
|
function show_hints_and_swap() {
|
|
|
|
current_pane_id=$1
|
|
|
|
fingers_pane_id=$2
|
2016-10-17 22:28:24 +02:00
|
|
|
compact_state=$3
|
2018-01-29 23:03:41 +01:00
|
|
|
show_hints "$fingers_pane_id" "$compact_state"
|
2017-05-01 10:16:52 +02:00
|
|
|
tmux swap-pane -s "$current_pane_id" -t "$fingers_pane_id"
|
2016-04-30 02:42:56 +02:00
|
|
|
}
|