Skip to content

Commit 02d24bb

Browse files
BDisptig
andauthored
Fixes #4236. CursesDriver erase the previous text under the cursor when moving if Force16Colors is true (#4237)
* Fixes #4236. CursesDriver erase the previous text under the cursor when moving if Force16Colors is true * Still trying to fix fluent unit tests * Fix nullable issue --------- Co-authored-by: Tig <[email protected]>
1 parent da9286d commit 02d24bb

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

Terminal.Gui/Drivers/CursesDriver/CursesDriver.cs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,8 @@ public override bool GetCursorVisibility (out CursorVisibility visibility)
536536
return true;
537537
}
538538

539+
private EscSeqUtils.DECSCUSR_Style? _currentDecscusrStyle;
540+
539541
/// <inheritdoc/>
540542
public override bool SetCursorVisibility (CursorVisibility visibility)
541543
{
@@ -547,17 +549,19 @@ public override bool SetCursorVisibility (CursorVisibility visibility)
547549
if (!RunningUnitTests)
548550
{
549551
Curses.curs_set (((int)visibility >> 16) & 0x000000FF);
552+
Curses.leaveok (_window!.Handle, !Force16Colors);
550553
}
551554

552555
if (visibility != CursorVisibility.Invisible)
553556
{
554-
_mainLoopDriver?.WriteRaw (
555-
EscSeqUtils.CSI_SetCursorStyle (
556-
(EscSeqUtils.DECSCUSR_Style)
557-
(((int)visibility >> 24)
558-
& 0xFF)
559-
)
560-
);
557+
if (_currentDecscusrStyle is null || _currentDecscusrStyle != (EscSeqUtils.DECSCUSR_Style)(((int)visibility >> 24) & 0xFF))
558+
{
559+
_currentDecscusrStyle = (EscSeqUtils.DECSCUSR_Style)(((int)visibility >> 24) & 0xFF);
560+
561+
_mainLoopDriver?.WriteRaw (
562+
EscSeqUtils.CSI_SetCursorStyle ((EscSeqUtils.DECSCUSR_Style)_currentDecscusrStyle)
563+
);
564+
}
561565
}
562566

563567
_currentCursorVisibility = visibility;

Terminal.Gui/Drivers/CursesDriver/UnixMainLoop.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,7 @@ private struct Pollfd
249249

250250
private class Watch
251251
{
252-
// BUGBUG: Fix this nullable issue.
253-
public Func<MainLoop, bool> Callback;
252+
public Func<MainLoop, bool>? Callback;
254253
public Condition Condition;
255254
public int File;
256255
}

Terminal.Gui/ViewBase/ViewCollectionHelpers.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ internal static View [] Snapshot (this IEnumerable<View> source)
1010
// The list parameter might be the live `_subviews`, so freeze it under a lock
1111
lock (list)
1212
{
13-
return [.. list]; // C# 12 slice copy (= new List<View>(list).ToArray())
13+
return list.ToArray (); // It’s slightly less “fancy C# 12”, but much safer in multithreaded code
1414
}
1515
}
1616

0 commit comments

Comments
 (0)