Source File
term.go
Belonging Package
github.com/reeflective/readline/internal/term
package termimport ()// termFile is the file descriptor used for all low-level terminal queries (size,// cursor position) and escape sequences. We deliberately use stderr rather than// stdout: stdout is the stream most likely to be redirected (e.g. `app | other`),// whereas stderr usually stays attached to the controlling terminal, giving a// reliable terminal size even when the program's output is piped.var termFile = os.Stderr// fallback terminal width when we can't get it through query.var defaultTermWidth = 80// GetWidth returns the width of the terminal or 80 if it cannot be established.func () ( int) {var error:= int(termFile.Fd()), _, = GetSize()if != nil || == 0 {= defaultTermWidth}return}// GetLength returns the length of the terminal// (Y length), or 80 if it cannot be established.func () int {:= int(termFile.Fd()), , := GetSize()if != nil || == 0 {return defaultTermWidth}return}func printf( string, ...interface{}) {WriteString(fmt.Sprintf(, ...))}// EnableBracketedPaste enables bracketed paste mode.func () {WriteString(BracketedPasteStart)}// DisableBracketedPaste disables bracketed paste mode.func () {WriteString(BracketedPasteEnd)}
![]() |
The pages are generated with Golds v0.8.7. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |