doing 2.0.19 → 2.0.23
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +15 -0
- data/Gemfile.lock +15 -5
- data/README.md +1 -1
- data/bin/doing +2 -18
- data/doing.gemspec +5 -4
- data/doing.rdoc +2 -2
- data/generate_completions.sh +3 -3
- data/lib/doing/cli_status.rb +6 -2
- data/lib/doing/completion/bash_completion.rb +185 -0
- data/lib/doing/completion/fish_completion.rb +175 -0
- data/lib/doing/completion/string.rb +17 -0
- data/lib/doing/completion/zsh_completion.rb +140 -0
- data/lib/doing/completion.rb +39 -0
- data/lib/doing/version.rb +1 -1
- data/lib/doing/wwid.rb +19 -5
- data/lib/doing.rb +1 -1
- data/lib/helpers/fzf/.goreleaser.yml +119 -0
- data/lib/helpers/fzf/.rubocop.yml +28 -0
- data/lib/helpers/fzf/ADVANCED.md +565 -0
- data/lib/helpers/fzf/BUILD.md +49 -0
- data/lib/helpers/fzf/CHANGELOG.md +1193 -0
- data/lib/helpers/fzf/Dockerfile +11 -0
- data/lib/helpers/fzf/LICENSE +21 -0
- data/lib/helpers/fzf/Makefile +166 -0
- data/lib/helpers/fzf/README-VIM.md +486 -0
- data/lib/helpers/fzf/README.md +712 -0
- data/lib/helpers/fzf/bin/fzf-tmux +233 -0
- data/lib/helpers/fzf/doc/fzf.txt +512 -0
- data/lib/helpers/fzf/go.mod +17 -0
- data/lib/helpers/fzf/go.sum +31 -0
- data/lib/helpers/fzf/install +382 -0
- data/lib/helpers/fzf/install.ps1 +65 -0
- data/lib/helpers/fzf/main.go +14 -0
- data/lib/helpers/fzf/man/man1/fzf-tmux.1 +68 -0
- data/lib/helpers/fzf/man/man1/fzf.1 +1001 -0
- data/lib/helpers/fzf/plugin/fzf.vim +1048 -0
- data/lib/helpers/fzf/shell/completion.bash +381 -0
- data/lib/helpers/fzf/shell/completion.zsh +329 -0
- data/lib/helpers/fzf/shell/key-bindings.bash +96 -0
- data/lib/helpers/fzf/shell/key-bindings.fish +172 -0
- data/lib/helpers/fzf/shell/key-bindings.zsh +114 -0
- data/lib/helpers/fzf/src/LICENSE +21 -0
- data/lib/helpers/fzf/src/algo/algo.go +884 -0
- data/lib/helpers/fzf/src/algo/algo_test.go +197 -0
- data/lib/helpers/fzf/src/algo/normalize.go +492 -0
- data/lib/helpers/fzf/src/ansi.go +409 -0
- data/lib/helpers/fzf/src/ansi_test.go +427 -0
- data/lib/helpers/fzf/src/cache.go +81 -0
- data/lib/helpers/fzf/src/cache_test.go +39 -0
- data/lib/helpers/fzf/src/chunklist.go +89 -0
- data/lib/helpers/fzf/src/chunklist_test.go +80 -0
- data/lib/helpers/fzf/src/constants.go +85 -0
- data/lib/helpers/fzf/src/core.go +351 -0
- data/lib/helpers/fzf/src/history.go +96 -0
- data/lib/helpers/fzf/src/history_test.go +68 -0
- data/lib/helpers/fzf/src/item.go +44 -0
- data/lib/helpers/fzf/src/item_test.go +23 -0
- data/lib/helpers/fzf/src/matcher.go +235 -0
- data/lib/helpers/fzf/src/merger.go +120 -0
- data/lib/helpers/fzf/src/merger_test.go +88 -0
- data/lib/helpers/fzf/src/options.go +1691 -0
- data/lib/helpers/fzf/src/options_test.go +457 -0
- data/lib/helpers/fzf/src/pattern.go +425 -0
- data/lib/helpers/fzf/src/pattern_test.go +209 -0
- data/lib/helpers/fzf/src/protector/protector.go +8 -0
- data/lib/helpers/fzf/src/protector/protector_openbsd.go +10 -0
- data/lib/helpers/fzf/src/reader.go +201 -0
- data/lib/helpers/fzf/src/reader_test.go +63 -0
- data/lib/helpers/fzf/src/result.go +243 -0
- data/lib/helpers/fzf/src/result_others.go +16 -0
- data/lib/helpers/fzf/src/result_test.go +159 -0
- data/lib/helpers/fzf/src/result_x86.go +16 -0
- data/lib/helpers/fzf/src/terminal.go +2832 -0
- data/lib/helpers/fzf/src/terminal_test.go +638 -0
- data/lib/helpers/fzf/src/terminal_unix.go +26 -0
- data/lib/helpers/fzf/src/terminal_windows.go +45 -0
- data/lib/helpers/fzf/src/tokenizer.go +253 -0
- data/lib/helpers/fzf/src/tokenizer_test.go +112 -0
- data/lib/helpers/fzf/src/tui/dummy.go +46 -0
- data/lib/helpers/fzf/src/tui/light.go +987 -0
- data/lib/helpers/fzf/src/tui/light_unix.go +110 -0
- data/lib/helpers/fzf/src/tui/light_windows.go +145 -0
- data/lib/helpers/fzf/src/tui/tcell.go +721 -0
- data/lib/helpers/fzf/src/tui/tcell_test.go +392 -0
- data/lib/helpers/fzf/src/tui/ttyname_unix.go +47 -0
- data/lib/helpers/fzf/src/tui/ttyname_windows.go +14 -0
- data/lib/helpers/fzf/src/tui/tui.go +625 -0
- data/lib/helpers/fzf/src/tui/tui_test.go +20 -0
- data/lib/helpers/fzf/src/util/atomicbool.go +34 -0
- data/lib/helpers/fzf/src/util/atomicbool_test.go +17 -0
- data/lib/helpers/fzf/src/util/chars.go +198 -0
- data/lib/helpers/fzf/src/util/chars_test.go +46 -0
- data/lib/helpers/fzf/src/util/eventbox.go +96 -0
- data/lib/helpers/fzf/src/util/eventbox_test.go +61 -0
- data/lib/helpers/fzf/src/util/slab.go +12 -0
- data/lib/helpers/fzf/src/util/util.go +138 -0
- data/lib/helpers/fzf/src/util/util_test.go +40 -0
- data/lib/helpers/fzf/src/util/util_unix.go +47 -0
- data/lib/helpers/fzf/src/util/util_windows.go +83 -0
- data/lib/helpers/fzf/test/fzf.vader +175 -0
- data/lib/helpers/fzf/test/test_go.rb +2626 -0
- data/lib/helpers/fzf/uninstall +117 -0
- data/scripts/generate_bash_completions.rb +6 -12
- data/scripts/generate_fish_completions.rb +7 -16
- data/scripts/generate_zsh_completions.rb +6 -15
- metadata +144 -9
@@ -0,0 +1,110 @@
|
|
1
|
+
// +build !windows
|
2
|
+
|
3
|
+
package tui
|
4
|
+
|
5
|
+
import (
|
6
|
+
"fmt"
|
7
|
+
"os"
|
8
|
+
"os/exec"
|
9
|
+
"strings"
|
10
|
+
"syscall"
|
11
|
+
|
12
|
+
"github.com/junegunn/fzf/src/util"
|
13
|
+
"golang.org/x/term"
|
14
|
+
)
|
15
|
+
|
16
|
+
func IsLightRendererSupported() bool {
|
17
|
+
return true
|
18
|
+
}
|
19
|
+
|
20
|
+
func (r *LightRenderer) defaultTheme() *ColorTheme {
|
21
|
+
if strings.Contains(os.Getenv("TERM"), "256") {
|
22
|
+
return Dark256
|
23
|
+
}
|
24
|
+
colors, err := exec.Command("tput", "colors").Output()
|
25
|
+
if err == nil && atoi(strings.TrimSpace(string(colors)), 16) > 16 {
|
26
|
+
return Dark256
|
27
|
+
}
|
28
|
+
return Default16
|
29
|
+
}
|
30
|
+
|
31
|
+
func (r *LightRenderer) fd() int {
|
32
|
+
return int(r.ttyin.Fd())
|
33
|
+
}
|
34
|
+
|
35
|
+
func (r *LightRenderer) initPlatform() error {
|
36
|
+
fd := r.fd()
|
37
|
+
origState, err := term.GetState(fd)
|
38
|
+
if err != nil {
|
39
|
+
return err
|
40
|
+
}
|
41
|
+
r.origState = origState
|
42
|
+
term.MakeRaw(fd)
|
43
|
+
return nil
|
44
|
+
}
|
45
|
+
|
46
|
+
func (r *LightRenderer) closePlatform() {
|
47
|
+
// NOOP
|
48
|
+
}
|
49
|
+
|
50
|
+
func openTtyIn() *os.File {
|
51
|
+
in, err := os.OpenFile(consoleDevice, syscall.O_RDONLY, 0)
|
52
|
+
if err != nil {
|
53
|
+
tty := ttyname()
|
54
|
+
if len(tty) > 0 {
|
55
|
+
if in, err := os.OpenFile(tty, syscall.O_RDONLY, 0); err == nil {
|
56
|
+
return in
|
57
|
+
}
|
58
|
+
}
|
59
|
+
fmt.Fprintln(os.Stderr, "Failed to open "+consoleDevice)
|
60
|
+
os.Exit(2)
|
61
|
+
}
|
62
|
+
return in
|
63
|
+
}
|
64
|
+
|
65
|
+
func (r *LightRenderer) setupTerminal() {
|
66
|
+
term.MakeRaw(r.fd())
|
67
|
+
}
|
68
|
+
|
69
|
+
func (r *LightRenderer) restoreTerminal() {
|
70
|
+
term.Restore(r.fd(), r.origState)
|
71
|
+
}
|
72
|
+
|
73
|
+
func (r *LightRenderer) updateTerminalSize() {
|
74
|
+
width, height, err := term.GetSize(r.fd())
|
75
|
+
|
76
|
+
if err == nil {
|
77
|
+
r.width = width
|
78
|
+
r.height = r.maxHeightFunc(height)
|
79
|
+
} else {
|
80
|
+
r.width = getEnv("COLUMNS", defaultWidth)
|
81
|
+
r.height = r.maxHeightFunc(getEnv("LINES", defaultHeight))
|
82
|
+
}
|
83
|
+
}
|
84
|
+
|
85
|
+
func (r *LightRenderer) findOffset() (row int, col int) {
|
86
|
+
r.csi("6n")
|
87
|
+
r.flush()
|
88
|
+
bytes := []byte{}
|
89
|
+
for tries := 0; tries < offsetPollTries; tries++ {
|
90
|
+
bytes = r.getBytesInternal(bytes, tries > 0)
|
91
|
+
offsets := offsetRegexp.FindSubmatch(bytes)
|
92
|
+
if len(offsets) > 3 {
|
93
|
+
// Add anything we skipped over to the input buffer
|
94
|
+
r.buffer = append(r.buffer, offsets[1]...)
|
95
|
+
return atoi(string(offsets[2]), 0) - 1, atoi(string(offsets[3]), 0) - 1
|
96
|
+
}
|
97
|
+
}
|
98
|
+
return -1, -1
|
99
|
+
}
|
100
|
+
|
101
|
+
func (r *LightRenderer) getch(nonblock bool) (int, bool) {
|
102
|
+
b := make([]byte, 1)
|
103
|
+
fd := r.fd()
|
104
|
+
util.SetNonblock(r.ttyin, nonblock)
|
105
|
+
_, err := util.Read(fd, b)
|
106
|
+
if err != nil {
|
107
|
+
return 0, false
|
108
|
+
}
|
109
|
+
return int(b[0]), true
|
110
|
+
}
|
@@ -0,0 +1,145 @@
|
|
1
|
+
//+build windows
|
2
|
+
|
3
|
+
package tui
|
4
|
+
|
5
|
+
import (
|
6
|
+
"os"
|
7
|
+
"syscall"
|
8
|
+
"time"
|
9
|
+
|
10
|
+
"github.com/junegunn/fzf/src/util"
|
11
|
+
"golang.org/x/sys/windows"
|
12
|
+
)
|
13
|
+
|
14
|
+
const (
|
15
|
+
timeoutInterval = 10
|
16
|
+
)
|
17
|
+
|
18
|
+
var (
|
19
|
+
consoleFlagsInput = uint32(windows.ENABLE_VIRTUAL_TERMINAL_INPUT | windows.ENABLE_PROCESSED_INPUT | windows.ENABLE_EXTENDED_FLAGS)
|
20
|
+
consoleFlagsOutput = uint32(windows.ENABLE_VIRTUAL_TERMINAL_PROCESSING | windows.ENABLE_PROCESSED_OUTPUT | windows.DISABLE_NEWLINE_AUTO_RETURN)
|
21
|
+
)
|
22
|
+
|
23
|
+
// IsLightRendererSupported checks to see if the Light renderer is supported
|
24
|
+
func IsLightRendererSupported() bool {
|
25
|
+
var oldState uint32
|
26
|
+
// enable vt100 emulation (https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences)
|
27
|
+
if windows.GetConsoleMode(windows.Stderr, &oldState) != nil {
|
28
|
+
return false
|
29
|
+
}
|
30
|
+
// attempt to set mode to determine if we support VT 100 codes. This will work on newer Windows 10
|
31
|
+
// version:
|
32
|
+
canSetVt100 := windows.SetConsoleMode(windows.Stderr, oldState|windows.ENABLE_VIRTUAL_TERMINAL_PROCESSING) == nil
|
33
|
+
var checkState uint32
|
34
|
+
if windows.GetConsoleMode(windows.Stderr, &checkState) != nil ||
|
35
|
+
(checkState&windows.ENABLE_VIRTUAL_TERMINAL_PROCESSING) != windows.ENABLE_VIRTUAL_TERMINAL_PROCESSING {
|
36
|
+
return false
|
37
|
+
}
|
38
|
+
windows.SetConsoleMode(windows.Stderr, oldState)
|
39
|
+
return canSetVt100
|
40
|
+
}
|
41
|
+
|
42
|
+
func (r *LightRenderer) defaultTheme() *ColorTheme {
|
43
|
+
// the getenv check is borrowed from here: https://github.com/gdamore/tcell/commit/0c473b86d82f68226a142e96cc5a34c5a29b3690#diff-b008fcd5e6934bf31bc3d33bf49f47d8R178:
|
44
|
+
if !IsLightRendererSupported() || os.Getenv("ConEmuPID") != "" || os.Getenv("TCELL_TRUECOLOR") == "disable" {
|
45
|
+
return Default16
|
46
|
+
}
|
47
|
+
return Dark256
|
48
|
+
}
|
49
|
+
|
50
|
+
func (r *LightRenderer) initPlatform() error {
|
51
|
+
//outHandle := windows.Stdout
|
52
|
+
outHandle, _ := syscall.Open("CONOUT$", syscall.O_RDWR, 0)
|
53
|
+
// enable vt100 emulation (https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences)
|
54
|
+
if err := windows.GetConsoleMode(windows.Handle(outHandle), &r.origStateOutput); err != nil {
|
55
|
+
return err
|
56
|
+
}
|
57
|
+
r.outHandle = uintptr(outHandle)
|
58
|
+
inHandle, _ := syscall.Open("CONIN$", syscall.O_RDWR, 0)
|
59
|
+
if err := windows.GetConsoleMode(windows.Handle(inHandle), &r.origStateInput); err != nil {
|
60
|
+
return err
|
61
|
+
}
|
62
|
+
r.inHandle = uintptr(inHandle)
|
63
|
+
|
64
|
+
r.setupTerminal()
|
65
|
+
|
66
|
+
// channel for non-blocking reads. Buffer to make sure
|
67
|
+
// we get the ESC sets:
|
68
|
+
r.ttyinChannel = make(chan byte, 1024)
|
69
|
+
|
70
|
+
// the following allows for non-blocking IO.
|
71
|
+
// syscall.SetNonblock() is a NOOP under Windows.
|
72
|
+
go func() {
|
73
|
+
fd := int(r.inHandle)
|
74
|
+
b := make([]byte, 1)
|
75
|
+
for {
|
76
|
+
// HACK: if run from PSReadline, something resets ConsoleMode to remove ENABLE_VIRTUAL_TERMINAL_INPUT.
|
77
|
+
_ = windows.SetConsoleMode(windows.Handle(r.inHandle), consoleFlagsInput)
|
78
|
+
|
79
|
+
_, err := util.Read(fd, b)
|
80
|
+
if err == nil {
|
81
|
+
r.ttyinChannel <- b[0]
|
82
|
+
}
|
83
|
+
}
|
84
|
+
}()
|
85
|
+
|
86
|
+
return nil
|
87
|
+
}
|
88
|
+
|
89
|
+
func (r *LightRenderer) closePlatform() {
|
90
|
+
windows.SetConsoleMode(windows.Handle(r.outHandle), r.origStateOutput)
|
91
|
+
windows.SetConsoleMode(windows.Handle(r.inHandle), r.origStateInput)
|
92
|
+
}
|
93
|
+
|
94
|
+
func openTtyIn() *os.File {
|
95
|
+
// not used
|
96
|
+
return nil
|
97
|
+
}
|
98
|
+
|
99
|
+
func (r *LightRenderer) setupTerminal() error {
|
100
|
+
if err := windows.SetConsoleMode(windows.Handle(r.outHandle), consoleFlagsOutput); err != nil {
|
101
|
+
return err
|
102
|
+
}
|
103
|
+
return windows.SetConsoleMode(windows.Handle(r.inHandle), consoleFlagsInput)
|
104
|
+
}
|
105
|
+
|
106
|
+
func (r *LightRenderer) restoreTerminal() error {
|
107
|
+
if err := windows.SetConsoleMode(windows.Handle(r.inHandle), r.origStateInput); err != nil {
|
108
|
+
return err
|
109
|
+
}
|
110
|
+
return windows.SetConsoleMode(windows.Handle(r.outHandle), r.origStateOutput)
|
111
|
+
}
|
112
|
+
|
113
|
+
func (r *LightRenderer) updateTerminalSize() {
|
114
|
+
var bufferInfo windows.ConsoleScreenBufferInfo
|
115
|
+
if err := windows.GetConsoleScreenBufferInfo(windows.Handle(r.outHandle), &bufferInfo); err != nil {
|
116
|
+
r.width = getEnv("COLUMNS", defaultWidth)
|
117
|
+
r.height = r.maxHeightFunc(getEnv("LINES", defaultHeight))
|
118
|
+
|
119
|
+
} else {
|
120
|
+
r.width = int(bufferInfo.Window.Right - bufferInfo.Window.Left)
|
121
|
+
r.height = r.maxHeightFunc(int(bufferInfo.Window.Bottom - bufferInfo.Window.Top))
|
122
|
+
}
|
123
|
+
}
|
124
|
+
|
125
|
+
func (r *LightRenderer) findOffset() (row int, col int) {
|
126
|
+
var bufferInfo windows.ConsoleScreenBufferInfo
|
127
|
+
if err := windows.GetConsoleScreenBufferInfo(windows.Handle(r.outHandle), &bufferInfo); err != nil {
|
128
|
+
return -1, -1
|
129
|
+
}
|
130
|
+
return int(bufferInfo.CursorPosition.X), int(bufferInfo.CursorPosition.Y)
|
131
|
+
}
|
132
|
+
|
133
|
+
func (r *LightRenderer) getch(nonblock bool) (int, bool) {
|
134
|
+
if nonblock {
|
135
|
+
select {
|
136
|
+
case bc := <-r.ttyinChannel:
|
137
|
+
return int(bc), true
|
138
|
+
case <-time.After(timeoutInterval * time.Millisecond):
|
139
|
+
return 0, false
|
140
|
+
}
|
141
|
+
} else {
|
142
|
+
bc := <-r.ttyinChannel
|
143
|
+
return int(bc), true
|
144
|
+
}
|
145
|
+
}
|