mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-26 15:57:56 +01:00
* Fixes #2930. Console.CursorLeft-- throw an exception with NetDriver on Linux (v2). * Fix inverted parameters. * Fixes #2666. With #2659 Cursor flickers on NetDriver * Fix typo. * Using the _cachedCursorVisibility field.
This commit is contained in:
@@ -480,7 +480,7 @@ namespace Terminal.Gui {
|
||||
#endif
|
||||
resume = false;
|
||||
var runState = Begin (view);
|
||||
// If ExitRunLoopAfterFirstIteration is true then the user must dispose of the runToken
|
||||
// If EndAfterFirstIteration is true then the user must dispose of the runToken
|
||||
// by using NotifyStopRunState event.
|
||||
RunLoop (runState);
|
||||
if (!EndAfterFirstIteration) {
|
||||
@@ -668,9 +668,6 @@ namespace Terminal.Gui {
|
||||
} else if (Current.SuperView == null && Current?.Modal == true) {
|
||||
Refresh ();
|
||||
}
|
||||
if (Driver.EnsureCursorVisibility ()) {
|
||||
state.Toplevel.SetNeedsDisplay ();
|
||||
}
|
||||
}
|
||||
|
||||
firstIteration = false;
|
||||
|
||||
@@ -173,7 +173,7 @@ public static class EscSeqUtils {
|
||||
/// <param name="x"></param>
|
||||
/// <param name="y"></param>
|
||||
/// <returns></returns>
|
||||
public static string CSI_SetCursorPosition (int x, int y) => $"{CSI}{y};{x}H";
|
||||
public static string CSI_SetCursorPosition (int y, int x) => $"{CSI}{y};{x}H";
|
||||
|
||||
|
||||
//ESC [ <y> ; <x> f - HVP Horizontal Vertical Position* Cursor moves to<x>; <y> coordinate within the viewport, where <x> is the column of the<y> line
|
||||
|
||||
@@ -759,8 +759,8 @@ internal class NetDriver : ConsoleDriver {
|
||||
Attribute redrawAttr = new Attribute ();
|
||||
var lastCol = -1;
|
||||
|
||||
//GetCursorVisibility (out CursorVisibility savedVisibitity);
|
||||
//SetCursorVisibility (CursorVisibility.Invisible);
|
||||
var savedVisibitity = _cachedCursorVisibility;
|
||||
SetCursorVisibility (CursorVisibility.Invisible);
|
||||
|
||||
for (var row = top; row < rows; row++) {
|
||||
if (Console.WindowHeight < 1) {
|
||||
@@ -812,7 +812,7 @@ internal class NetDriver : ConsoleDriver {
|
||||
output.Append (rune.ToString ());
|
||||
if (rune.IsSurrogatePair () && rune.GetColumns () < 2) {
|
||||
WriteToConsole (output, ref lastCol, row, ref outputWidth);
|
||||
Console.CursorLeft--;
|
||||
SetCursorPosition (col - 1, row);
|
||||
}
|
||||
Contents [row, col].IsDirty = false;
|
||||
}
|
||||
@@ -824,7 +824,7 @@ internal class NetDriver : ConsoleDriver {
|
||||
}
|
||||
SetCursorPosition (0, 0);
|
||||
|
||||
//SetCursorVisibility (savedVisibitity);
|
||||
_cachedCursorVisibility = savedVisibitity;
|
||||
|
||||
void WriteToConsole (StringBuilder output, ref int lastCol, int row, ref int outputWidth)
|
||||
{
|
||||
@@ -888,20 +888,20 @@ internal class NetDriver : ConsoleDriver {
|
||||
#region Cursor Handling
|
||||
bool SetCursorPosition (int col, int row)
|
||||
{
|
||||
//if (IsWinPlatform) {
|
||||
// Could happens that the windows is still resizing and the col is bigger than Console.WindowWidth.
|
||||
try {
|
||||
Console.SetCursorPosition (col, row);
|
||||
if (IsWinPlatform) {
|
||||
// Could happens that the windows is still resizing and the col is bigger than Console.WindowWidth.
|
||||
try {
|
||||
Console.SetCursorPosition (col, row);
|
||||
return true;
|
||||
} catch (Exception) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
// + 1 is needed because non-Windows is based on 1 instead of 0 and
|
||||
// Console.CursorTop/CursorLeft isn't reliable.
|
||||
Console.Out.Write (EscSeqUtils.CSI_SetCursorPosition (row + 1, col + 1));
|
||||
return true;
|
||||
} catch (Exception) {
|
||||
return false;
|
||||
}
|
||||
// BUGBUG: This breaks -usc on WSL; not sure why. But commenting out fixes.
|
||||
//} else {
|
||||
// // TODO: Explain why + 1 is needed (and why we do this for non-Windows).
|
||||
// Console.Out.Write (EscSeqUtils.CSI_SetCursorPosition (row + 1, col + 1));
|
||||
// return true;
|
||||
//}
|
||||
}
|
||||
|
||||
CursorVisibility? _cachedCursorVisibility;
|
||||
@@ -926,7 +926,7 @@ internal class NetDriver : ConsoleDriver {
|
||||
{
|
||||
_cachedCursorVisibility = visibility;
|
||||
var isVisible = RunningUnitTests ? visibility == CursorVisibility.Default : Console.CursorVisible = visibility == CursorVisibility.Default;
|
||||
//Console.Out.Write (isVisible ? EscSeqUtils.CSI_ShowCursor : EscSeqUtils.CSI_HideCursor);
|
||||
Console.Out.Write (isVisible ? EscSeqUtils.CSI_ShowCursor : EscSeqUtils.CSI_HideCursor);
|
||||
return isVisible;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user