-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Redisplay interface on terminal resize events
- Not implemented on Windows, because there is a weird behavior that makes it too unstable to be used.
- Loading branch information
Showing
6 changed files
with
164 additions
and
22 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
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,31 @@ | ||
//go:build unix | ||
// +build unix | ||
|
||
package display | ||
|
||
import ( | ||
"os" | ||
"os/signal" | ||
"syscall" | ||
) | ||
|
||
// WatchResize redisplays the interface on terminal resize events. | ||
func WatchResize(eng *Engine) chan<- bool { | ||
done := make(chan bool, 1) | ||
|
||
resizeChannel := make(chan os.Signal) | ||
signal.Notify(resizeChannel, syscall.SIGWINCH) | ||
|
||
go func() { | ||
for { | ||
select { | ||
case <-resizeChannel: | ||
eng.Refresh() | ||
case <-done: | ||
return | ||
} | ||
} | ||
}() | ||
|
||
return done | ||
} |
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,46 @@ | ||
//go:build windows | ||
// +build windows | ||
|
||
package display | ||
|
||
// WatchResize redisplays the interface on terminal resize events on Windows. | ||
// Currently not implemented, see related issue in repo: too buggy right now. | ||
func WatchResize(eng *Engine) chan<- bool { | ||
return make(chan<- bool) | ||
// resizeChannel := core.GetTerminalResize(eng.keys) | ||
|
||
// for { | ||
// select { | ||
// case <-resizeChannel: | ||
// // Weird behavior on Windows: when there is no autosuggested line, | ||
// // the cursor moves at the end of the completions area, if non-empty. | ||
// // We must manually go back to the input cursor position first. | ||
// line, _ := eng.completer.Line() | ||
// if eng.completer.IsInserting() { | ||
// eng.suggested = *eng.line | ||
// } else { | ||
// eng.suggested = eng.histories.Suggest(eng.line) | ||
// } | ||
// | ||
// if eng.suggested.Len() <= line.Len() { | ||
// fmt.Println(term.HideCursor) | ||
// | ||
// compRows := completion.Coordinates(eng.completer) | ||
// if compRows <= eng.AvailableHelperLines() { | ||
// compRows++ | ||
// } | ||
// | ||
// term.MoveCursorBackwards(term.GetWidth()) | ||
// term.MoveCursorUp(compRows) | ||
// term.MoveCursorUp(ui.CoordinatesHint(eng.hint)) | ||
// eng.cursorHintToLineStart() | ||
// eng.lineStartToCursorPos() | ||
// fmt.Println(term.ShowCursor) | ||
// } | ||
// | ||
// eng.Refresh() | ||
// case <-done: | ||
// return | ||
// } | ||
// } | ||
} |
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