mirror of
https://github.com/taigrr/bubbletea.git
synced 2026-04-02 11:09:17 -07:00
* add: program.ReleaseTerminal and RestoreTerminal to re-use input & terminal * chore(examples): add altscreen toggling to exec demo * chore: put low-level altscreen stuff alongside other screen funcs * docs: edit GoDocs for ReleaseTerminal and RestoreTerminal * feat(renderer): add internal Msg renderMsg to immediately repaint * fix: repaint instantly on RestoreTerminal * fix: restore the altscreen state when restoring the terminal * feat: implement Cmd-based API for blocking *exec.Cmds * feat: allow Exec to return custom messages * feat: allow Exec to be run without a callback * fix: separate parameters for exec.Command examples * fix: error message would get printed over by prompt in exec example * fix: ignore signals while child process is running * feat: allow to execute other things besides exec.Commands (#280) * feat: allow to execute other things besides exec.Commands. * fix: lint issues * fix: renames, examples * fix: callback type should be exported * docs(exce): tiny ExecCommand doc comment correction * chore(exec): break out Cmd for clarity's sake in example * fix(exec): give the terminal a moment to catch up if exiting altscreen * docs(exec): tidy up doc comments * chore(exec): disambiguate methods for restoring the terminal state vs input Co-authored-by: Christian Rocha <christian@rocha.is> Co-authored-by: Carlos A Becker <caarlos0@gmail.com>
54 lines
1.0 KiB
Go
54 lines
1.0 KiB
Go
package tea
|
|
|
|
import (
|
|
"fmt"
|
|
"io"
|
|
|
|
te "github.com/muesli/termenv"
|
|
)
|
|
|
|
func hideCursor(w io.Writer) {
|
|
fmt.Fprintf(w, te.CSI+te.HideCursorSeq)
|
|
}
|
|
|
|
func showCursor(w io.Writer) {
|
|
fmt.Fprintf(w, te.CSI+te.ShowCursorSeq)
|
|
}
|
|
|
|
func clearLine(w io.Writer) {
|
|
fmt.Fprintf(w, te.CSI+te.EraseLineSeq, 2)
|
|
}
|
|
|
|
func cursorUp(w io.Writer) {
|
|
fmt.Fprintf(w, te.CSI+te.CursorUpSeq, 1)
|
|
}
|
|
|
|
func cursorDown(w io.Writer) {
|
|
fmt.Fprintf(w, te.CSI+te.CursorDownSeq, 1)
|
|
}
|
|
|
|
func insertLine(w io.Writer, numLines int) {
|
|
fmt.Fprintf(w, te.CSI+"%dL", numLines)
|
|
}
|
|
|
|
func moveCursor(w io.Writer, row, col int) {
|
|
fmt.Fprintf(w, te.CSI+te.CursorPositionSeq, row, col)
|
|
}
|
|
|
|
func changeScrollingRegion(w io.Writer, top, bottom int) {
|
|
fmt.Fprintf(w, te.CSI+te.ChangeScrollingRegionSeq, top, bottom)
|
|
}
|
|
|
|
func cursorBack(w io.Writer, n int) {
|
|
fmt.Fprintf(w, te.CSI+te.CursorBackSeq, n)
|
|
}
|
|
|
|
func enterAltScreen(w io.Writer) {
|
|
fmt.Fprintf(w, te.CSI+te.AltScreenSeq)
|
|
moveCursor(w, 0, 0)
|
|
}
|
|
|
|
func exitAltScreen(w io.Writer) {
|
|
fmt.Fprintf(w, te.CSI+te.ExitAltScreenSeq)
|
|
}
|