fix(wrapper): up/down arrow hide menu
This commit is contained in:
+21
-18
@@ -199,38 +199,41 @@ func runWrapper() {
|
|||||||
|
|
||||||
if b == '\033' {
|
if b == '\033' {
|
||||||
// handle escape sequences like arrow keys and functional shortcuts
|
// handle escape sequences like arrow keys and functional shortcuts
|
||||||
if i+2 < n && inputSlice[i+1] == '[' && inputSlice[i+2] == 'Z' {
|
if i+2 < n && (inputSlice[i+1] == '[' || inputSlice[i+1] == 'O') {
|
||||||
// shift tab: hide/unhide menu dropdown
|
// shift tab: hide/unhide menu dropdown
|
||||||
intercepted = true
|
if inputSlice[i+1] == '[' && inputSlice[i+2] == 'Z' {
|
||||||
suggestionsEnabled = !suggestionsEnabled
|
intercepted = true
|
||||||
if !suggestionsEnabled {
|
suggestionsEnabled = !suggestionsEnabled
|
||||||
os.Stdout.Write([]byte(overlay.ClearAndDisable()))
|
if !suggestionsEnabled {
|
||||||
} else {
|
os.Stdout.Write([]byte(overlay.ClearAndDisable()))
|
||||||
shouldOverlayDraw = true
|
} else {
|
||||||
|
shouldOverlayDraw = true
|
||||||
|
}
|
||||||
|
i += 2
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
i += 2
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
ptmx.Write([]byte{b})
|
if overlay.Visible && (inputSlice[i+2] == 'A' || inputSlice[i+2] == 'B') {
|
||||||
if i+2 < n && inputSlice[i+1] == '[' {
|
intercepted = true
|
||||||
if overlay.Visible {
|
if inputSlice[i+2] == 'A' { // up arrow
|
||||||
switch inputSlice[i+2] {
|
|
||||||
case 'A': // up arrow
|
|
||||||
overlay.Cursor--
|
overlay.Cursor--
|
||||||
if overlay.Cursor < 0 {
|
if overlay.Cursor < 0 {
|
||||||
overlay.Cursor = 0
|
overlay.Cursor = 0
|
||||||
}
|
}
|
||||||
os.Stdout.Write([]byte(overlay.Render()))
|
} else { // down arrow
|
||||||
case 'B': // down arrow
|
|
||||||
overlay.Cursor++
|
overlay.Cursor++
|
||||||
if overlay.Cursor >= len(overlay.Items) {
|
if overlay.Cursor >= len(overlay.Items) {
|
||||||
overlay.Cursor = len(overlay.Items) - 1
|
overlay.Cursor = len(overlay.Items) - 1
|
||||||
}
|
}
|
||||||
os.Stdout.Write([]byte(overlay.Render()))
|
|
||||||
}
|
}
|
||||||
|
os.Stdout.Write([]byte(overlay.Render()))
|
||||||
|
i += 2
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// forward escape sequence to pty if not intercepted
|
||||||
|
ptmx.Write([]byte{b})
|
||||||
// skip remaining bytes of the escape sequence to avoid misinterpretation
|
// skip remaining bytes of the escape sequence to avoid misinterpretation
|
||||||
for j := i + 1; j < n; j++ {
|
for j := i + 1; j < n; j++ {
|
||||||
char := inputSlice[j]
|
char := inputSlice[j]
|
||||||
|
|||||||
Reference in New Issue
Block a user