From d5ff785559b0805713eb0f2f809f761502e372d1 Mon Sep 17 00:00:00 2001 From: Zachary Yedidia Date: Thu, 26 Jan 2023 18:02:54 -0800 Subject: [PATCH] Add fakecursor option When 'fakecursor' is enabled micro will use a "fake" block to display the cursor instead of the terminal's cursor. Closes #2698 Closes #2703 --- internal/config/settings.go | 1 + internal/screen/screen.go | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/internal/config/settings.go b/internal/config/settings.go index bedec930..5c9c6ae8 100644 --- a/internal/config/settings.go +++ b/internal/config/settings.go @@ -331,6 +331,7 @@ var DefaultGlobalOnlySettings = map[string]interface{}{ "colorscheme": "default", "divchars": "|-", "divreverse": true, + "fakecursor": false, "infobar": true, "keymenu": false, "mouse": true, diff --git a/internal/screen/screen.go b/internal/screen/screen.go index 967e8617..339e69aa 100644 --- a/internal/screen/screen.go +++ b/internal/screen/screen.go @@ -79,6 +79,10 @@ func ShowFakeCursor(x, y int) { lastCursor.style = style } +func UseFake() bool { + return util.FakeCursor || config.GetGlobalOption("fakecursor").(bool) +} + // ShowFakeCursorMulti is the same as ShowFakeCursor except it does not // reset previous locations of the cursor // Fake cursors are also necessary to display multiple cursors @@ -91,7 +95,7 @@ func ShowFakeCursorMulti(x, y int) { // if enabled or using the terminal cursor otherwise // By default only the windows console will use a fake cursor func ShowCursor(x, y int) { - if util.FakeCursor { + if UseFake() { ShowFakeCursor(x, y) } else { Screen.ShowCursor(x, y) @@ -106,7 +110,7 @@ func SetContent(x, y int, mainc rune, combc []rune, style tcell.Style) { } Screen.SetContent(x, y, mainc, combc, style) - if util.FakeCursor && lastCursor.x == x && lastCursor.y == y { + if UseFake() && lastCursor.x == x && lastCursor.y == y { lastCursor.r = mainc lastCursor.style = style lastCursor.combc = combc