-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Implement
wk widget
features (#10)
- Loading branch information
Showing
9 changed files
with
221 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
.task/ | ||
dist/ | ||
src/version.generated.json | ||
src/widget.generated.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ registries: | |
ref: v4.212.0 | ||
packages: | ||
- name: go-task/task@v3.38.0 | ||
- name: jqlang/jq@jq-1.7.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
_wk_widget() { | ||
local opts | ||
zstyle -a ':wk:*' options opts || opts=() | ||
|
||
local res='' | ||
res=$(<%= it.wk_path %> run ${=opts} 2>&1) | ||
local wk_exit=$? | ||
|
||
zle redisplay | ||
echo -n $'\x1b[?25h' >$TTY # Ensure cursor is visible | ||
|
||
case $wk_exit in | ||
0) | ||
# NOOP | ||
;; | ||
3|4) | ||
# Abort, Timeout | ||
return | ||
;; | ||
*) | ||
# 1: General errors | ||
# 2: Invalid arguments or options error | ||
# 5: No match error | ||
# 6: Key parse error | ||
# *: Unknown errors | ||
zle -M "wk: $res" | ||
return $wk_exit | ||
;; | ||
esac | ||
|
||
reply=("${(@ps:\t:)res}") | ||
|
||
if [[ "${reply[(rb:2:)eval:*]}" == 'eval:true' ]]; then | ||
BUFFER=${(e)reply[1]} | ||
else | ||
BUFFER=${reply[1]} | ||
fi | ||
CURSOR=${#BUFFER} | ||
|
||
if [[ "${reply[(rb:2:)accept:*]}" == 'accept:true' ]]; then | ||
local accept_widget | ||
zstyle -s ':wk:*' accept-widget accept_widget || accept_widget='accept-line' | ||
zle $accept_widget | ||
fi | ||
} | ||
|
||
zle -N _wk_widget | ||
<% if (typeof it.bindkey === 'string') { %> | ||
bindkey '<%= it.bindkey %>' _wk_widget | ||
<% } %> |