-
Notifications
You must be signed in to change notification settings - Fork 685
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Fixes #2865. Unknown character sequence while resizing terminal. * Added USE_IOCTL definition for toggle. * Explaining that is a CSI (Esc[) = 27;91. --------- Co-authored-by: Tig <tig@users.noreply.github.com>
- Loading branch information
Showing
4 changed files
with
218 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
#pragma warning disable format | ||
|
||
#pragma warning restore format | ||
using System; | ||
using System.Collections.Generic; | ||
using Terminal.Gui; | ||
|
||
namespace UICatalog.Scenarios { | ||
[ScenarioMetadata (Name: "MainLoopTimeouts", Description: "MainLoop Timeouts")] | ||
[ScenarioCategory ("Tests")] | ||
public class MainLoopTimeouts : Scenario { | ||
static readonly List<string> GlobalList = new () { "1" }; | ||
static readonly ListView GlobalListView = new () { Width = Dim.Fill (), Height = Dim.Fill () }; | ||
|
||
static Label CounterLabel; | ||
static Label BlinkingLabel; | ||
|
||
static int Counter = 0; | ||
|
||
static object _listToken = null; | ||
static object _blinkToken = null; | ||
static object _countToken = null; | ||
|
||
public override void Init (ColorScheme colorScheme) | ||
{ | ||
Application.Init (); | ||
|
||
var startButton = new Button ("Start"); | ||
var stopButton = new Button ("Stop") { Y = 1 }; | ||
var container = new View () { X = Pos.Center (), Y = Pos.Center (), Width = 8, Height = 8, ColorScheme = Colors.Error }; | ||
|
||
CounterLabel = new Label ("0") { X = Pos.X (container), Y = Pos.Y (container) - 2 }; | ||
BlinkingLabel = new Label ("Blink") { X = Pos.X (container), Y = Pos.Bottom (container) + 1 }; | ||
|
||
startButton.Clicked += Start; | ||
stopButton.Clicked += Stop; | ||
|
||
GlobalListView.SetSource (GlobalList); | ||
container.Add (GlobalListView); | ||
|
||
Application.Top.Add (container, CounterLabel, BlinkingLabel); | ||
Application.Top.Add (startButton, stopButton); | ||
Application.Run (); | ||
Application.Shutdown (); | ||
} | ||
|
||
public override void Run () | ||
{ | ||
} | ||
|
||
private static void Start () | ||
{ | ||
_listToken = Application.MainLoop.AddTimeout (TimeSpan.FromMilliseconds (100), Add); | ||
_blinkToken = Application.MainLoop.AddTimeout (TimeSpan.FromMilliseconds (1000), Blink); | ||
_countToken = Application.MainLoop.AddTimeout (TimeSpan.FromMilliseconds (1000), Count); | ||
} | ||
|
||
private static void Stop () | ||
{ | ||
Application.MainLoop.RemoveTimeout (_listToken); | ||
Application.MainLoop.RemoveTimeout (_blinkToken); | ||
Application.MainLoop.RemoveTimeout (_countToken); | ||
} | ||
|
||
private static bool Add (MainLoop mainLoop) | ||
{ | ||
Application.MainLoop.Invoke (() => { | ||
GlobalList.Add (new Random ().Next (100).ToString ()); | ||
GlobalListView.MoveDown (); | ||
}); | ||
|
||
return true; | ||
} | ||
|
||
private static bool Blink (MainLoop mainLoop) | ||
{ | ||
Application.MainLoop.Invoke (() => { | ||
if (BlinkingLabel.Visible) { | ||
BlinkingLabel.Visible = false; | ||
System.Diagnostics.Debug.WriteLine (BlinkingLabel.Visible); | ||
} else { | ||
BlinkingLabel.Visible = true; | ||
System.Diagnostics.Debug.WriteLine (BlinkingLabel.Visible); | ||
} | ||
}); | ||
|
||
return true; | ||
} | ||
|
||
private static bool Count (MainLoop mainLoop) | ||
{ | ||
Application.MainLoop.Invoke (() => { | ||
Counter++; | ||
CounterLabel.Text = Counter.ToString (); | ||
}); | ||
|
||
return true; | ||
} | ||
} | ||
} |