Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions Terminal.Gui/Drivers/CursesDriver/CursesDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,8 @@ public override bool GetCursorVisibility (out CursorVisibility visibility)
return true;
}

private EscSeqUtils.DECSCUSR_Style? _currentDecscusrStyle;

/// <inheritdoc/>
public override bool SetCursorVisibility (CursorVisibility visibility)
{
Expand All @@ -547,17 +549,19 @@ public override bool SetCursorVisibility (CursorVisibility visibility)
if (!RunningUnitTests)
{
Curses.curs_set (((int)visibility >> 16) & 0x000000FF);
Curses.leaveok (_window!.Handle, !Force16Colors);
}

if (visibility != CursorVisibility.Invisible)
{
_mainLoopDriver?.WriteRaw (
EscSeqUtils.CSI_SetCursorStyle (
(EscSeqUtils.DECSCUSR_Style)
(((int)visibility >> 24)
& 0xFF)
)
);
if (_currentDecscusrStyle is null || _currentDecscusrStyle != (EscSeqUtils.DECSCUSR_Style)(((int)visibility >> 24) & 0xFF))
{
_currentDecscusrStyle = (EscSeqUtils.DECSCUSR_Style)(((int)visibility >> 24) & 0xFF);

_mainLoopDriver?.WriteRaw (
EscSeqUtils.CSI_SetCursorStyle ((EscSeqUtils.DECSCUSR_Style)_currentDecscusrStyle)
);
}
}

_currentCursorVisibility = visibility;
Expand Down
3 changes: 1 addition & 2 deletions Terminal.Gui/Drivers/CursesDriver/UnixMainLoop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,7 @@ private struct Pollfd

private class Watch
{
// BUGBUG: Fix this nullable issue.
public Func<MainLoop, bool> Callback;
public Func<MainLoop, bool>? Callback;
public Condition Condition;
public int File;
}
Expand Down
2 changes: 1 addition & 1 deletion Terminal.Gui/ViewBase/ViewCollectionHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ internal static View [] Snapshot (this IEnumerable<View> source)
// The list parameter might be the live `_subviews`, so freeze it under a lock
lock (list)
{
return [.. list]; // C# 12 slice copy (= new List<View>(list).ToArray())
return list.ToArray (); // It’s slightly less “fancy C# 12”, but much safer in multithreaded code
}
}

Expand Down
Loading