Lines Matching refs:w
77 w := &writerImpl{
84 w.smartTerminal = isTerminal(stdio.Stdout())
86 w.stripEscapes = !w.smartTerminal
88 return w
104 func (w *writerImpl) isSmartTerminal() bool {
105 return w.smartTerminal
108 func (w *writerImpl) requestLine() {
109 if !w.haveBlankLine {
110 fmt.Fprintln(w.stdio.Stdout())
111 w.haveBlankLine = true
115 func (w *writerImpl) Print(str string) {
116 if w.stripEscapes {
120 w.lock.Lock()
121 defer w.lock.Unlock()
122 w.print(str)
125 func (w *writerImpl) print(str string) {
126 if !w.haveBlankLine {
127 fmt.Fprint(w.stdio.Stdout(), "\r", "\x1b[K")
128 w.haveBlankLine = true
130 fmt.Fprint(w.stdio.Stdout(), str)
132 fmt.Fprint(w.stdio.Stdout(), "\n")
136 func (w *writerImpl) StatusLine(str string) {
137 w.lock.Lock()
138 defer w.lock.Unlock()
140 w.statusLine(str)
143 func (w *writerImpl) statusLine(str string) {
144 if !w.smartTerminal {
145 fmt.Fprintln(w.stdio.Stdout(), str)
160 if max, ok := termWidth(w.stdio.Stdout()); ok {
170 fmt.Fprint(w.stdio.Stdout(), "\r", str, "\x1b[K")
171 w.haveBlankLine = false
174 func (w *writerImpl) StatusAndMessage(status, msg string) {
175 if w.stripEscapes {
179 w.lock.Lock()
180 defer w.lock.Unlock()
182 w.statusLine(status)
183 w.requestLine()
184 w.print(msg)
187 func (w *writerImpl) Finish() {
188 w.lock.Lock()
189 defer w.lock.Unlock()
191 w.requestLine()
194 func (w *writerImpl) Write(p []byte) (n int, err error) {
195 w.Print(string(p))