Skip to content

Commit 1707d09

Browse files
BDisptig
andcommitted
Fixes gui-cs#4236. CursesDriver erase the previous text under the cursor when moving if Force16Colors is true (gui-cs#4237)
* Fixes gui-cs#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 <tig@users.noreply.github.com>
1 parent 65b4402 commit 1707d09

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
@@ -540,6 +540,8 @@ public override bool GetCursorVisibility (out CursorVisibility visibility)
540540
return true;
541541
}
542542

543+
private EscSeqUtils.DECSCUSR_Style? _currentDecscusrStyle;
544+
543545
/// <inheritdoc/>
544546
public override bool SetCursorVisibility (CursorVisibility visibility)
545547
{
@@ -551,17 +553,19 @@ public override bool SetCursorVisibility (CursorVisibility visibility)
551553
if (!RunningUnitTests)
552554
{
553555
Curses.curs_set (((int)visibility >> 16) & 0x000000FF);
556+
Curses.leaveok (_window!.Handle, !Force16Colors);
554557
}
555558

556559
if (visibility != CursorVisibility.Invisible)
557560
{
558-
_mainLoopDriver?.WriteRaw (
559-
EscSeqUtils.CSI_SetCursorStyle (
560-
(EscSeqUtils.DECSCUSR_Style)
561-
(((int)visibility >> 24)
562-
& 0xFF)
563-
)
564-
);
561+
if (_currentDecscusrStyle is null || _currentDecscusrStyle != (EscSeqUtils.DECSCUSR_Style)(((int)visibility >> 24) & 0xFF))
562+
{
563+
_currentDecscusrStyle = (EscSeqUtils.DECSCUSR_Style)(((int)visibility >> 24) & 0xFF);
564+
565+
_mainLoopDriver?.WriteRaw (
566+
EscSeqUtils.CSI_SetCursorStyle ((EscSeqUtils.DECSCUSR_Style)_currentDecscusrStyle)
567+
);
568+
}
565569
}
566570

567571
_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)