From d9c03fc0b071927ca4dedb3082f2570142b6863c Mon Sep 17 00:00:00 2001 From: Christian Rocha Date: Tue, 16 Jun 2020 16:10:34 -0400 Subject: [PATCH] Add cursor positioning functions to viewport renderder --- viewport/renderer.go | 8 ++++++++ viewport/viewport.go | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/viewport/renderer.go b/viewport/renderer.go index 2f1a9e6..8168225 100644 --- a/viewport/renderer.go +++ b/viewport/renderer.go @@ -95,3 +95,11 @@ func clearLine(w io.Writer) { func insertLine(w io.Writer, numLines int) { fmt.Fprintf(w, te.CSI+"%dL", numLines) } + +func saveCursorPosition(w io.Writer) { + fmt.Fprint(w, te.CSI+"s") +} + +func restoreCursorPosition(w io.Writer) { + fmt.Fprint(w, te.CSI+"u") +} diff --git a/viewport/viewport.go b/viewport/viewport.go index d69a296..38511d1 100644 --- a/viewport/viewport.go +++ b/viewport/viewport.go @@ -21,8 +21,8 @@ type Model struct { // It's used in high performance rendering. Y int - // UseInternalRenderer specifies whether or not to use the pager's internal, - // high performance renderer to paint the screen. + // UseInternalRenderer specifies whether or not to use the pager's + // internal, high performance renderer to paint the screen. UseInternalRenderer bool lines []string