drafting multi mode
This commit is contained in:
parent
1deef23dc7
commit
1a5dc4fc10
|
@ -126,10 +126,14 @@ fingers_defaults=( \
|
||||||
|
|
||||||
[fingers-hint-position]="left" \
|
[fingers-hint-position]="left" \
|
||||||
[fingers-hint-format]="#[fg=yellow,bold]%s" \
|
[fingers-hint-format]="#[fg=yellow,bold]%s" \
|
||||||
|
[fingers-selected-hint-format]="#[fg=red,bold]%s" \
|
||||||
|
[fingers-selected-highlight-format]="#[fg=red,nobold,dim]%s" \
|
||||||
[fingers-highlight-format]="#[fg=yellow,nobold,dim]%s" \
|
[fingers-highlight-format]="#[fg=yellow,nobold,dim]%s" \
|
||||||
|
|
||||||
[fingers-hint-position-nocompact]="right" \
|
[fingers-hint-position-nocompact]="right" \
|
||||||
[fingers-hint-format-nocompact]="#[fg=yellow,bold][%s]" \
|
[fingers-hint-format-nocompact]="#[fg=yellow,bold][%s]" \
|
||||||
|
[fingers-selected-hint-format-nocompact]="#[fg=red,bold][%s]" \
|
||||||
|
[fingers-selected-highlight-format-nocompact]="#[fg=red,nobold,dim][%s]" \
|
||||||
[fingers-highlight-format-nocompact]="#[fg=yellow,nobold,dim]%s" \
|
[fingers-highlight-format-nocompact]="#[fg=yellow,nobold,dim]%s" \
|
||||||
|
|
||||||
[fingers-keyboard-layout]="qwerty" \
|
[fingers-keyboard-layout]="qwerty" \
|
||||||
|
@ -163,9 +167,14 @@ set_tmux_env 'fingers-hint-position-nocompact'
|
||||||
set_tmux_env 'fingers-hint-format-nocompact' process_format
|
set_tmux_env 'fingers-hint-format-nocompact' process_format
|
||||||
set_tmux_env 'fingers-highlight-format-nocompact' process_format
|
set_tmux_env 'fingers-highlight-format-nocompact' process_format
|
||||||
|
|
||||||
|
set_tmux_env 'fingers-selected-hint-format' process_format
|
||||||
|
set_tmux_env 'fingers-selected-highlight-format' process_format
|
||||||
|
set_tmux_env 'fingers-selected-hint-format-nocompact' process_format
|
||||||
|
set_tmux_env 'fingers-selected-highlight-format-nocompact' process_format
|
||||||
|
|
||||||
set_tmux_env 'fingers-keyboard-layout'
|
set_tmux_env 'fingers-keyboard-layout'
|
||||||
|
|
||||||
for option in fingers-{hint,highlight}-format{,-nocompact}; do
|
for option in fingers-{selected-hint,selected-highlight,hint,highlight}-format{,-nocompact}; do
|
||||||
env_name="$(envify "$option")_NOCOLOR"
|
env_name="$(envify "$option")_NOCOLOR"
|
||||||
option_value="$(read_from_config "$option")"
|
option_value="$(read_from_config "$option")"
|
||||||
default_value="${fingers_defaults[$option]}"
|
default_value="${fingers_defaults[$option]}"
|
||||||
|
|
|
@ -12,3 +12,12 @@ function current_ms() {
|
||||||
function log() {
|
function log() {
|
||||||
echo "$1" >> "$CURRENT_DIR/../fingers.log"
|
echo "$1" >> "$CURRENT_DIR/../fingers.log"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function log_array() {
|
||||||
|
declare -a arg_arr=(${!1})
|
||||||
|
|
||||||
|
for i in "${arg_arr[@]}"
|
||||||
|
do
|
||||||
|
log "> $i"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
source $CURRENT_DIR/hints.sh
|
source $CURRENT_DIR/hints.sh
|
||||||
source $CURRENT_DIR/utils.sh
|
source $CURRENT_DIR/utils.sh
|
||||||
source $CURRENT_DIR/help.sh
|
source $CURRENT_DIR/help.sh
|
||||||
|
source $CURRENT_DIR/debug.sh
|
||||||
|
|
||||||
current_pane_id=$1
|
current_pane_id=$1
|
||||||
fingers_pane_id=$2
|
fingers_pane_id=$2
|
||||||
|
@ -43,8 +44,8 @@ function hide_cursor() {
|
||||||
echo -n "$(tput civis)"
|
echo -n "$(tput civis)"
|
||||||
}
|
}
|
||||||
|
|
||||||
function copy_result() {
|
function copy_final_result() {
|
||||||
local result="${state[result]}"
|
local result="${state[final_result]}"
|
||||||
|
|
||||||
tmux set-buffer "$result"
|
tmux set-buffer "$result"
|
||||||
}
|
}
|
||||||
|
@ -115,7 +116,7 @@ function run_shell_action() {
|
||||||
local command_to_run="$1"
|
local command_to_run="$1"
|
||||||
|
|
||||||
if [[ ! -z $command_to_run ]]; then
|
if [[ ! -z $command_to_run ]]; then
|
||||||
tmux run-shell -b "printf \"$(escape_quotes "${state[result]}")\" | MODIFIER=${state[modifier]} HINT=${state[input]} $EXEC_PREFIX $command_to_run"
|
tmux run-shell -b "printf \"$(escape_quotes "${state[final_result]}")\" | MODIFIER=${state[modifier]} HINT=${state[input]} $EXEC_PREFIX $command_to_run"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,8 +176,11 @@ trap "handle_exit" EXIT
|
||||||
state[pane_was_zoomed]=$(is_pane_zoomed "$current_pane_id")
|
state[pane_was_zoomed]=$(is_pane_zoomed "$current_pane_id")
|
||||||
state[show_help]=0
|
state[show_help]=0
|
||||||
state[compact_mode]="$FINGERS_COMPACT_HINTS"
|
state[compact_mode]="$FINGERS_COMPACT_HINTS"
|
||||||
|
state[multi_mode]=0
|
||||||
state[input]=''
|
state[input]=''
|
||||||
state[modifier]=''
|
state[modifier]=''
|
||||||
|
selected_matches=()
|
||||||
|
selected_hints=()
|
||||||
|
|
||||||
hide_cursor
|
hide_cursor
|
||||||
show_hints_and_swap "$current_pane_id" "$fingers_pane_id" "$compact_state"
|
show_hints_and_swap "$current_pane_id" "$fingers_pane_id" "$compact_state"
|
||||||
|
@ -207,6 +211,9 @@ do
|
||||||
toggle-compact-mode)
|
toggle-compact-mode)
|
||||||
toggle_state "compact_mode"
|
toggle_state "compact_mode"
|
||||||
;;
|
;;
|
||||||
|
toggle-multi-mode)
|
||||||
|
toggle_state "multi_mode"
|
||||||
|
;;
|
||||||
hint:*)
|
hint:*)
|
||||||
accept_hint "$statement"
|
accept_hint "$statement"
|
||||||
;;
|
;;
|
||||||
|
@ -223,20 +230,35 @@ do
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $(did_state_change "show_help" "1 => 0") == 1 ]]; then
|
if [[ $(did_state_change "show_help" "1 => 0") == 1 ]]; then
|
||||||
show_hints "$fingers_pane_id" "${state[compact_mode]}"
|
show_hints "$fingers_pane_id" "${state[compact_mode]}" "${state[multi_mode]}" "${selected_hints[@]}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $(did_state_change "compact_mode") == 1 ]]; then
|
if [[ $(did_state_change "compact_mode") == 1 ]]; then
|
||||||
show_hints "$fingers_pane_id" "${state[compact_mode]}"
|
show_hints "$fingers_pane_id" "${state[compact_mode]}" "${state[multi_mode]}" "${selected_hints[@]}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Exiting multi mode makes an early exit
|
||||||
|
if [[ $(did_state_change "multi_mode" "1 => 0") == 1 ]]; then
|
||||||
|
state[final_result]=$(array_join " " "${selected_matches[@]}")
|
||||||
|
copy_final_result
|
||||||
|
break
|
||||||
fi
|
fi
|
||||||
|
|
||||||
input="${state[input]}"
|
input="${state[input]}"
|
||||||
|
|
||||||
state[result]=$(lookup_match "$input")
|
state[current_match]=$(lookup_match "$input")
|
||||||
|
|
||||||
if [[ -n "${state[result]}" ]]; then
|
if [[ -n "${state[current_match]}" ]]; then
|
||||||
copy_result
|
if [[ "${state[multi_mode]}" == "1" ]]; then
|
||||||
break
|
selected_matches+=(${state[current_match]})
|
||||||
|
selected_hints+=(${state[input]})
|
||||||
|
state[input]=''
|
||||||
|
show_hints "$fingers_pane_id" "${state[compact_mode]}" "${state[multi_mode]}" "${selected_hints[@]}"
|
||||||
|
else
|
||||||
|
state[final_result]="${state[current_match]}"
|
||||||
|
copy_final_result
|
||||||
|
break
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
done < <(tail -f /tmp/fingers-command-queue)
|
done < <(tail -f /tmp/fingers-command-queue)
|
||||||
|
|
||||||
|
|
|
@ -15,19 +15,37 @@ BEGIN {
|
||||||
hint_format_nocolor = ENVIRON["FINGERS_HINT_FORMAT_NOCOLOR"]
|
hint_format_nocolor = ENVIRON["FINGERS_HINT_FORMAT_NOCOLOR"]
|
||||||
highlight_format = ENVIRON["FINGERS_HIGHLIGHT_FORMAT"]
|
highlight_format = ENVIRON["FINGERS_HIGHLIGHT_FORMAT"]
|
||||||
highlight_format_nocolor = ENVIRON["FINGERS_HIGHLIGHT_FORMAT_NOCOLOR"]
|
highlight_format_nocolor = ENVIRON["FINGERS_HIGHLIGHT_FORMAT_NOCOLOR"]
|
||||||
|
selected_highlight_format = ENVIRON["FINGERS_SELECTED_HIGHLIGHT_FORMAT"]
|
||||||
|
selected_highlight_format_nocolor = ENVIRON["FINGERS_SELECTED_HIGHLIGHT_FORMAT_NOCOLOR"]
|
||||||
|
selected_hint_format = ENVIRON["FINGERS_SELECTED_HINT_FORMAT"]
|
||||||
|
selected_hint_format_nocolor = ENVIRON["FINGERS_SELECTED_HINT_FORMAT_NOCOLOR"]
|
||||||
} else {
|
} else {
|
||||||
hint_format = ENVIRON["FINGERS_HINT_FORMAT_NOCOMPACT"]
|
hint_format = ENVIRON["FINGERS_HINT_FORMAT_NOCOMPACT"]
|
||||||
highlight_format = ENVIRON["FINGERS_HIGHLIGHT_FORMAT_NOCOMPACT"]
|
highlight_format = ENVIRON["FINGERS_HIGHLIGHT_FORMAT_NOCOMPACT"]
|
||||||
hint_format_nocolor = ENVIRON["FINGERS_HINT_FORMAT_NOCOMPACT_NOCOLOR"]
|
hint_format_nocolor = ENVIRON["FINGERS_HINT_FORMAT_NOCOMPACT_NOCOLOR"]
|
||||||
highlight_format_nocolor = ENVIRON["FINGERS_HIGHLIGHT_FORMAT_NOCOMPACT_NOCOLOR"]
|
highlight_format_nocolor = ENVIRON["FINGERS_HIGHLIGHT_FORMAT_NOCOMPACT_NOCOLOR"]
|
||||||
|
selected_highlight_format = ENVIRON["FINGERS_SELECTED_HIGHLIGHT_FORMAT_NOCOMPACT"]
|
||||||
|
selected_highlight_format_nocolor = ENVIRON["FINGERS_SELECTED_HIGHLIGHT_FORMAT_NOCOMPACT_NOCOLOR"]
|
||||||
|
selected_hint_format = ENVIRON["FINGERS_SELECTED_HINT_FORMAT_NOCOMPACT"]
|
||||||
|
selected_hint_format_nocolor = ENVIRON["FINGERS_SELECTED_HINT_FORMAT_NOCOMPACT_NOCOLOR"]
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fingers_hint_position == "left")
|
if (fingers_hint_position == "left") {
|
||||||
compound_format = hint_format highlight_format
|
general_compound_format = hint_format highlight_format
|
||||||
else
|
selected_compound_format = selected_hint_format selected_highlight_format
|
||||||
compound_format = highlight_format hint_format
|
} else {
|
||||||
|
general_compound_format = highlight_format hint_format
|
||||||
|
selected_compound_format = selected_highlight_format selected_hint_format
|
||||||
|
}
|
||||||
|
|
||||||
hint_lookup = ""
|
hint_lookup = ""
|
||||||
|
|
||||||
|
split(ENVIRON["FINGERS_SELECTED_HINTS"], selected_hints_arr, ":")
|
||||||
|
|
||||||
|
for (i = 1; i <= length(selected_hints_arr); ++i) {
|
||||||
|
selected_hints_lookup[selected_hints_arr[i]] = 1
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -97,8 +115,16 @@ END {
|
||||||
hint_lookup = hint_lookup hint ":" token "\n"
|
hint_lookup = hint_lookup hint ":" token "\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (selected_hints_lookup[hint]) {
|
||||||
|
this_hint_format_nocolor = selected_hint_format_nocolor
|
||||||
|
this_compound_format = selected_compound_format
|
||||||
|
} else {
|
||||||
|
this_hint_format_nocolor = hint_format_nocolor
|
||||||
|
this_compound_format = general_compound_format
|
||||||
|
}
|
||||||
|
|
||||||
if (fingers_compact_hints) {
|
if (fingers_compact_hints) {
|
||||||
hint_len = length(sprintf(hint_format_nocolor, hint))
|
hint_len = length(sprintf(this_hint_format_nocolor, hint))
|
||||||
if (fingers_hint_position == "left")
|
if (fingers_hint_position == "left")
|
||||||
token = substr(token, hint_len + 1, length(token) - hint_len);
|
token = substr(token, hint_len + 1, length(token) - hint_len);
|
||||||
else
|
else
|
||||||
|
@ -106,9 +132,9 @@ END {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fingers_hint_position == "left")
|
if (fingers_hint_position == "left")
|
||||||
token = sprintf(compound_format, hint, token);
|
token = sprintf(this_compound_format, hint, token);
|
||||||
else
|
else
|
||||||
token = sprintf(compound_format, token, hint);
|
token = sprintf(this_compound_format, token, hint);
|
||||||
}
|
}
|
||||||
|
|
||||||
printf "%s", token
|
printf "%s", token
|
||||||
|
|
|
@ -29,12 +29,22 @@ function get_stdin() {
|
||||||
|
|
||||||
function show_hints() {
|
function show_hints() {
|
||||||
local fingers_pane_id=$1
|
local fingers_pane_id=$1
|
||||||
local compact_hints=$2
|
shift
|
||||||
|
local compact_hints=$1
|
||||||
|
shift
|
||||||
|
local multi_mode=$1
|
||||||
|
shift
|
||||||
|
declare -a selected_hints=(${@})
|
||||||
|
|
||||||
FINGERS_ALPHABET_DIR="$CURRENT_DIR/../alphabets/$FINGERS_KEYBOARD_LAYOUT/"
|
FINGERS_ALPHABET_DIR="$CURRENT_DIR/../alphabets/$FINGERS_KEYBOARD_LAYOUT/"
|
||||||
|
|
||||||
|
log "logging array begin"
|
||||||
|
log_array selected_hints[@]
|
||||||
|
log "logging array end"
|
||||||
|
log "join array: $(array_join ":" "${selected_hints[@]}")"
|
||||||
|
|
||||||
clear_screen "$fingers_pane_id"
|
clear_screen "$fingers_pane_id"
|
||||||
get_stdin | FINGERS_COMPACT_HINTS="$compact_hints" FINGERS_ALPHABET_DIR="$FINGERS_ALPHABET_DIR" gawk -f $CURRENT_DIR/hinter.awk 3> $match_lookup_table
|
get_stdin | FINGERS_SELECTED_HINTS="$(array_join ":" "${selected_hints[@]}")" FINGERS_COMPACT_HINTS="$compact_hints" FINGERS_ALPHABET_DIR="$FINGERS_ALPHABET_DIR" gawk -f $CURRENT_DIR/hinter.awk 3> $match_lookup_table
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_hints_and_swap() {
|
function show_hints_and_swap() {
|
||||||
|
|
|
@ -33,7 +33,7 @@ fingers_bind "?" "toggle-help"
|
||||||
fingers_bind "Space" "toggle-compact-mode"
|
fingers_bind "Space" "toggle-compact-mode"
|
||||||
|
|
||||||
fingers_bind "Enter" "noop"
|
fingers_bind "Enter" "noop"
|
||||||
fingers_bind "Tab" "noop"
|
fingers_bind "Tab" "toggle-multi-mode"
|
||||||
|
|
||||||
fingers_bind "Any" "noop"
|
fingers_bind "Any" "noop"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue