Skip to content
Myr

fix: replace deprecated ansi codes

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Ayman Bagabas · committed by Ayman Bagabas · parent 8578234 · Browse files · 1 file+28 added−28 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+28 added−28 removed

  • other:+28 added−28 removed

1 file+28 added−28 removed

modified:standard_renderer.go+28 added-28 removed
170 unmodified lines
171 buf := &bytes.Buffer{}172173 // Moving to the beginning of the section, that we rendered.174 if r.altScreenActive {175 buf.WriteString(ansi.HomeCursorPosition)175 buf.WriteString(ansi.CursorHomePosition)176 } else if r.linesRendered > 1 {177 buf.WriteString(ansi.CursorUp(r.linesRendered - 1))178 }179
36 unmodified lines
216217 if _, ignore := r.ignoreLines[i]; ignore || canSkip {218 // Unless this is the last line, move the cursor down.219 if i < len(newLines)-1 {220 buf.WriteString(ansi.CursorDown1)220 buf.WriteString(ansi.CUD1)221 }222 continue223 }224
49 unmodified lines
274 if r.altScreenActive {275 // This case fixes a bug in macOS terminal. In other terminals the276 // other case seems to do the job regardless of whether or not we're277 // using the full terminal window.278 buf.WriteString(ansi.SetCursorPosition(0, len(newLines)))278 buf.WriteString(ansi.CursorPosition(0, len(newLines)))279 } else {280 buf.WriteString(ansi.CursorLeft(r.width))280 buf.WriteString(ansi.CursorBackward(r.width))281 }282283 _, _ = r.out.Write(buf.Bytes())284 r.lastRender = r.buf.String()
40 unmodified lines
325 r.mtx.Lock()326 defer r.mtx.Unlock()327328 r.execute(ansi.EraseEntireScreen)329 r.execute(ansi.HomeCursorPosition)329 r.execute(ansi.CursorHomePosition)330331 r.repaint()332}333
12 unmodified lines
346 return347 }348349 r.altScreenActive = true350 r.execute(ansi.EnableAltScreenBuffer)350 r.execute(ansi.SetAltScreenSaveCursorMode)351352 // Ensure that the terminal is cleared, even when it doesn't support353 // alt screen (or alt screen support is disabled, like GNU screen by354 // default).355 //356 // Note: we can't use r.clearScreen() here because the mutex is already357 // locked.358 r.execute(ansi.EraseEntireScreen)359 r.execute(ansi.HomeCursorPosition)359 r.execute(ansi.CursorHomePosition)360361 // cmd.exe and other terminals keep separate cursor states for the AltScreen362 // and the main buffer. We have to explicitly reset the cursor visibility363 // whenever we enter AltScreen.
17 unmodified lines
381 return382 }383384 r.altScreenActive = false385 r.execute(ansi.DisableAltScreenBuffer)385 r.execute(ansi.ResetAltScreenSaveCursorMode)386387 // cmd.exe and other terminals keep separate cursor states for the AltScreen388 // and the main buffer. We have to explicitly reset the cursor visibility389 // whenever we exit AltScreen.
25 unmodified lines
415func (r *standardRenderer) enableMouseCellMotion() {416 r.mtx.Lock()417 defer r.mtx.Unlock()418419 r.execute(ansi.EnableMouseCellMotion)419 r.execute(ansi.SetButtonEventMouseMode)420}421422func (r *standardRenderer) disableMouseCellMotion() {423 r.mtx.Lock()424 defer r.mtx.Unlock()425426 r.execute(ansi.DisableMouseCellMotion)426 r.execute(ansi.ResetButtonEventMouseMode)427}428429func (r *standardRenderer) enableMouseAllMotion() {430 r.mtx.Lock()431 defer r.mtx.Unlock()432433 r.execute(ansi.EnableMouseAllMotion)433 r.execute(ansi.SetAnyEventMouseMode)434}435436func (r *standardRenderer) disableMouseAllMotion() {437 r.mtx.Lock()438 defer r.mtx.Unlock()439440 r.execute(ansi.DisableMouseAllMotion)440 r.execute(ansi.ResetAnyEventMouseMode)441}442443func (r *standardRenderer) enableMouseSGRMode() {444 r.mtx.Lock()445 defer r.mtx.Unlock()446447 r.execute(ansi.EnableMouseSgrExt)447 r.execute(ansi.SetSgrExtMouseMode)448}449450func (r *standardRenderer) disableMouseSGRMode() {451 r.mtx.Lock()452 defer r.mtx.Unlock()453454 r.execute(ansi.DisableMouseSgrExt)454 r.execute(ansi.ResetSgrExtMouseMode)455}456457func (r *standardRenderer) enableBracketedPaste() {458 r.mtx.Lock()459 defer r.mtx.Unlock()460461 r.execute(ansi.EnableBracketedPaste)461 r.execute(ansi.SetBracketedPasteMode)462 r.bpActive = true463}464465func (r *standardRenderer) disableBracketedPaste() {466 r.mtx.Lock()467 defer r.mtx.Unlock()468469 r.execute(ansi.DisableBracketedPaste)469 r.execute(ansi.ResetBracketedPasteMode)470 r.bpActive = false471}472473func (r *standardRenderer) bracketedPasteActive() bool {
6 unmodified lines
480func (r *standardRenderer) enableReportFocus() {481 r.mtx.Lock()482 defer r.mtx.Unlock()483484 r.execute(ansi.EnableReportFocus)484 r.execute(ansi.SetFocusEventMode)485 r.reportingFocus = true486}487488func (r *standardRenderer) disableReportFocus() {489 r.mtx.Lock()490 defer r.mtx.Unlock()491492 r.execute(ansi.DisableReportFocus)492 r.execute(ansi.ResetFocusEventMode)493 r.reportingFocus = false494}495496func (r *standardRenderer) reportFocus() bool {
33 unmodified lines
530 for i := lastLinesRendered - 1; i >= 0; i-- {531 if _, exists := r.ignoreLines[i]; exists {532 buf.WriteString(ansi.EraseEntireLine)533 }534 buf.WriteString(ansi.CursorUp1)534 buf.WriteString(ansi.CUU1)535 }536 buf.WriteString(ansi.SetCursorPosition(0, lastLinesRendered)) // put cursor back536 buf.WriteString(ansi.CursorPosition(0, lastLinesRendered)) // put cursor back537 _, _ = r.out.Write(buf.Bytes())538 }539}540
30 unmodified lines
571 defer r.mtx.Unlock()572573 buf := &bytes.Buffer{}574575 buf.WriteString(ansi.SetScrollingRegion(topBoundary, bottomBoundary))576 buf.WriteString(ansi.SetCursorPosition(0, topBoundary))575 buf.WriteString(ansi.SetTopBottomMargins(topBoundary, bottomBoundary))576 buf.WriteString(ansi.CursorPosition(0, topBoundary))577 buf.WriteString(ansi.InsertLine(len(lines)))578 _, _ = buf.WriteString(strings.Join(lines, "\r\n"))579 buf.WriteString(ansi.SetScrollingRegion(0, r.height))579 buf.WriteString(ansi.SetTopBottomMargins(0, r.height))580581 // Move cursor back to where the main rendering routine expects it to be582 buf.WriteString(ansi.SetCursorPosition(0, r.lastLinesRendered()))582 buf.WriteString(ansi.CursorPosition(0, r.lastLinesRendered()))583584 _, _ = r.out.Write(buf.Bytes())585}586
14 unmodified lines
601 defer r.mtx.Unlock()602603 buf := &bytes.Buffer{}604605 buf.WriteString(ansi.SetScrollingRegion(topBoundary, bottomBoundary))606 buf.WriteString(ansi.SetCursorPosition(0, bottomBoundary))605 buf.WriteString(ansi.SetTopBottomMargins(topBoundary, bottomBoundary))606 buf.WriteString(ansi.CursorPosition(0, bottomBoundary))607 _, _ = buf.WriteString("\r\n" + strings.Join(lines, "\r\n"))608 buf.WriteString(ansi.SetScrollingRegion(0, r.height))608 buf.WriteString(ansi.SetTopBottomMargins(0, r.height))609610 // Move cursor back to where the main rendering routine expects it to be611 buf.WriteString(ansi.SetCursorPosition(0, r.lastLinesRendered()))611 buf.WriteString(ansi.CursorPosition(0, r.lastLinesRendered()))612613 _, _ = r.out.Write(buf.Bytes())614}615
171 unmodified lines