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
Provenance
- Commit
31b433c- Tree
c1e1801- Author
Ayman Bagabas <ayman.bagabas@gmail.com>- Committer
Ayman Bagabas <ayman.bagabas@gmail.com>- Parent
8578234
1 file changed+28 added−28 removed
modified:standard_renderer.go+28 added-28 removed
170 unmodified lines171 buf := &bytes.Buffer{}172 173 // 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 lines216 217 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 lines274 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 }282 283 _, _ = r.out.Write(buf.Bytes())284 r.lastRender = r.buf.String()40 unmodified lines325 r.mtx.Lock()326 defer r.mtx.Unlock()327 328 r.execute(ansi.EraseEntireScreen)329- r.execute(ansi.HomeCursorPosition)329+ r.execute(ansi.CursorHomePosition)330 331 r.repaint()332 }333 12 unmodified lines346 return347 }348 349 r.altScreenActive = true350- r.execute(ansi.EnableAltScreenBuffer)350+ r.execute(ansi.SetAltScreenSaveCursorMode)351 352 // 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)360 361 // 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 lines381 return382 }383 384 r.altScreenActive = false385- r.execute(ansi.DisableAltScreenBuffer)385+ r.execute(ansi.ResetAltScreenSaveCursorMode)386 387 // 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 lines415 func (r *standardRenderer) enableMouseCellMotion() {416 r.mtx.Lock()417 defer r.mtx.Unlock()418 419- r.execute(ansi.EnableMouseCellMotion)419+ r.execute(ansi.SetButtonEventMouseMode)420 }421 422 func (r *standardRenderer) disableMouseCellMotion() {423 r.mtx.Lock()424 defer r.mtx.Unlock()425 426- r.execute(ansi.DisableMouseCellMotion)426+ r.execute(ansi.ResetButtonEventMouseMode)427 }428 429 func (r *standardRenderer) enableMouseAllMotion() {430 r.mtx.Lock()431 defer r.mtx.Unlock()432 433- r.execute(ansi.EnableMouseAllMotion)433+ r.execute(ansi.SetAnyEventMouseMode)434 }435 436 func (r *standardRenderer) disableMouseAllMotion() {437 r.mtx.Lock()438 defer r.mtx.Unlock()439 440- r.execute(ansi.DisableMouseAllMotion)440+ r.execute(ansi.ResetAnyEventMouseMode)441 }442 443 func (r *standardRenderer) enableMouseSGRMode() {444 r.mtx.Lock()445 defer r.mtx.Unlock()446 447- r.execute(ansi.EnableMouseSgrExt)447+ r.execute(ansi.SetSgrExtMouseMode)448 }449 450 func (r *standardRenderer) disableMouseSGRMode() {451 r.mtx.Lock()452 defer r.mtx.Unlock()453 454- r.execute(ansi.DisableMouseSgrExt)454+ r.execute(ansi.ResetSgrExtMouseMode)455 }456 457 func (r *standardRenderer) enableBracketedPaste() {458 r.mtx.Lock()459 defer r.mtx.Unlock()460 461- r.execute(ansi.EnableBracketedPaste)461+ r.execute(ansi.SetBracketedPasteMode)462 r.bpActive = true463 }464 465 func (r *standardRenderer) disableBracketedPaste() {466 r.mtx.Lock()467 defer r.mtx.Unlock()468 469- r.execute(ansi.DisableBracketedPaste)469+ r.execute(ansi.ResetBracketedPasteMode)470 r.bpActive = false471 }472 473 func (r *standardRenderer) bracketedPasteActive() bool {6 unmodified lines480 func (r *standardRenderer) enableReportFocus() {481 r.mtx.Lock()482 defer r.mtx.Unlock()483 484- r.execute(ansi.EnableReportFocus)484+ r.execute(ansi.SetFocusEventMode)485 r.reportingFocus = true486 }487 488 func (r *standardRenderer) disableReportFocus() {489 r.mtx.Lock()490 defer r.mtx.Unlock()491 492- r.execute(ansi.DisableReportFocus)492+ r.execute(ansi.ResetFocusEventMode)493 r.reportingFocus = false494 }495 496 func (r *standardRenderer) reportFocus() bool {33 unmodified lines530 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 lines571 defer r.mtx.Unlock()572 573 buf := &bytes.Buffer{}574 575- 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))580 581 // 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()))583 584 _, _ = r.out.Write(buf.Bytes())585 }586 14 unmodified lines601 defer r.mtx.Unlock()602 603 buf := &bytes.Buffer{}604 605- 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))609 610 // 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()))612 613 _, _ = r.out.Write(buf.Bytes())614 }615 171 unmodified lines