Merge branch 'v2_develop' into v2_alt-key-on-window-with-menubar-fix_2776

This commit is contained in:
BDisp
2023-08-30 17:18:58 +01:00
committed by GitHub
8 changed files with 199 additions and 87 deletions

50
GitVersion.yml Normal file
View File

@@ -0,0 +1,50 @@
mode: ContinuousDeployment
tag-prefix: '[vV]'
continuous-delivery-fallback-tag: 'pre'
branches:
# v1_develop:
# mode: ContinuousDeployment
# tag: pre
# regex: ^v1_develop?[/-]
# is-release-branch: false
# source-branches:
# - v1
# v1:
# tag: rc
# increment: Patch
# regex: ^v2?[/-]
# is-release-branch: false
# source-branches: []
# is-mainline: true
v2_develop:
mode: ContinuousDeployment
tag: pre
regex: ^v2_develop?[/-]
is-release-branch: true
tracks-release-branches: true
is-source-branch-for: ['v2']
source-branches: []
v2:
mode: ContinuousDeployment
is-release-branch: false
tag: alpha
increment: Patch
regex: ^v2?[/-]
source-branches: ['v2_develop']
# feature:
# tag: useBranchName
# regex: ^features?[/-]
# source-branches:
# - v1
# - v1_develop
# - v2
# - v2_develop
pull-request:
tag: PullRequest.{BranchName}
increment: Inherit
ignore:
sha: []
merge-message-formats: {}

View File

@@ -103,15 +103,17 @@ class NetWinVTConsole {
static extern uint GetLastError ();
}
internal class NetEvents {
internal class NetEvents : IDisposable {
ManualResetEventSlim _inputReady = new ManualResetEventSlim (false);
ManualResetEventSlim _waitForStart = new ManualResetEventSlim (false);
ManualResetEventSlim _winChange = new ManualResetEventSlim (false);
Queue<InputResult?> _inputResultQueue = new Queue<InputResult?> ();
ConsoleDriver _consoleDriver;
volatile ConsoleKeyInfo [] _cki = null;
volatile static bool _isEscSeq;
bool _stopTasks;
ConsoleKeyInfo [] _cki;
bool _isEscSeq;
CancellationTokenSource _cancellationTokenSource;
CancellationToken _cancellationToken;
#if PROCESS_REQUEST
bool _neededProcessRequest;
#endif
@@ -120,19 +122,16 @@ internal class NetEvents {
public NetEvents (ConsoleDriver consoleDriver)
{
_consoleDriver = consoleDriver ?? throw new ArgumentNullException (nameof (consoleDriver));
_cancellationTokenSource = new CancellationTokenSource ();
_cancellationToken = _cancellationTokenSource.Token;
Task.Run (ProcessInputResultQueue);
Task.Run (CheckWindowSizeChange);
}
internal void StopTasks ()
{
_stopTasks = true;
}
public InputResult? ReadConsoleInput ()
{
while (true) {
if (_stopTasks) {
if (_cancellationToken.IsCancellationRequested) {
return null;
}
_waitForStart.Set ();
@@ -151,6 +150,24 @@ internal class NetEvents {
}
}
static ConsoleKeyInfo ReadConsoleKeyInfo (CancellationToken cancellationToken, bool intercept = true)
{
// if there is a key available, return it without waiting
// (or dispatching work to the thread queue)
if (Console.KeyAvailable) {
return Console.ReadKey (intercept);
}
while (!cancellationToken.IsCancellationRequested) {
Task.Delay (100);
if (Console.KeyAvailable) {
return Console.ReadKey (intercept);
}
}
cancellationToken.ThrowIfCancellationRequested ();
return default;
}
void ProcessInputResultQueue ()
{
while (true) {
@@ -163,9 +180,18 @@ internal class NetEvents {
ConsoleKeyInfo newConsoleKeyInfo = default;
while (true) {
ConsoleKeyInfo consoleKeyInfo = Console.ReadKey (true);
if (_cancellationToken.IsCancellationRequested) {
return;
}
ConsoleKeyInfo consoleKeyInfo;
try {
consoleKeyInfo = ReadConsoleKeyInfo (_cancellationToken, true);
} catch (OperationCanceledException) {
return;
}
if ((consoleKeyInfo.KeyChar == (char)Key.Esc && !_isEscSeq)
|| (consoleKeyInfo.KeyChar != (char)Key.Esc && _isEscSeq)) {
|| (consoleKeyInfo.KeyChar != (char)Key.Esc && _isEscSeq)) {
if (_cki == null && consoleKeyInfo.KeyChar != (char)Key.Esc && _isEscSeq) {
_cki = EscSeqUtils.ResizeArray (new ConsoleKeyInfo ((char)Key.Esc, 0,
false, false, false), _cki);
@@ -179,17 +205,16 @@ internal class NetEvents {
_isEscSeq = false;
break;
} else if (consoleKeyInfo.KeyChar == (char)Key.Esc && _isEscSeq && _cki != null) {
if (_cki != null) {
ProcessRequestResponse (ref newConsoleKeyInfo, ref key, _cki, ref mod);
_cki = null;
ProcessRequestResponse (ref newConsoleKeyInfo, ref key, _cki, ref mod);
_cki = null;
if (Console.KeyAvailable) {
_cki = EscSeqUtils.ResizeArray (consoleKeyInfo, _cki);
} else {
ProcessMapConsoleKeyInfo (consoleKeyInfo);
}
break;
} else {
_inputResultQueue.Enqueue (new InputResult {
EventType = EventType.Key,
ConsoleKeyInfo = EscSeqUtils.MapConsoleKeyInfo (consoleKeyInfo)
});
_isEscSeq = false;
ProcessMapConsoleKeyInfo (consoleKeyInfo);
break;
}
}
@@ -197,19 +222,25 @@ internal class NetEvents {
_inputReady.Set ();
}
void ProcessMapConsoleKeyInfo (ConsoleKeyInfo consoleKeyInfo)
{
_inputResultQueue.Enqueue (new InputResult {
EventType = EventType.Key,
ConsoleKeyInfo = EscSeqUtils.MapConsoleKeyInfo (consoleKeyInfo)
});
_isEscSeq = false;
}
}
void CheckWindowSizeChange ()
{
void RequestWindowSize ()
void RequestWindowSize (CancellationToken cancellationToken)
{
while (true) {
while (!cancellationToken.IsCancellationRequested) {
// Wait for a while then check if screen has changed sizes
Task.Delay (500).Wait ();
Task.Delay (500, cancellationToken);
if (_stopTasks) {
return;
}
int buffHeight, buffWidth;
if (((NetDriver)_consoleDriver).IsWinPlatform) {
buffHeight = Math.Max (Console.BufferHeight, 0);
@@ -227,15 +258,20 @@ internal class NetEvents {
return;
}
}
cancellationToken.ThrowIfCancellationRequested ();
}
while (true) {
if (_stopTasks) {
if (_cancellationToken.IsCancellationRequested) {
return;
}
_winChange.Wait ();
_winChange.Reset ();
RequestWindowSize ();
try {
RequestWindowSize (_cancellationToken);
} catch (OperationCanceledException) {
return;
}
_inputReady.Set ();
}
}
@@ -536,6 +572,23 @@ internal class NetEvents {
_inputResultQueue.Enqueue (inputResult);
}
public void Dispose ()
{
_cancellationTokenSource.Cancel ();
_cancellationTokenSource.Dispose ();
_cancellationTokenSource = null;
FlushIn ();
}
void FlushIn ()
{
// throws away any typeahead that has been typed by
// the user and has not yet been read by the program.
while (Console.KeyAvailable) {
Console.ReadKey (true);
}
}
}
internal class NetDriver : ConsoleDriver {
@@ -563,7 +616,7 @@ internal class NetDriver : ConsoleDriver {
public override void End ()
{
_mainLoop?._netEvents.StopTasks ();
_mainLoop?._netEvents.Dispose ();
if (IsWinPlatform) {
NetWinConsole?.Cleanup ();
@@ -611,7 +664,7 @@ internal class NetDriver : ConsoleDriver {
if (!RunningUnitTests) {
Console.TreatControlCAsInput = true;
Cols = Console.WindowWidth;
Rows = Console.WindowHeight;

View File

@@ -777,7 +777,7 @@ internal class WindowsDriver : ConsoleDriver {
public WindowsConsole WinConsole { get; private set; }
public override bool SupportsTrueColor => RunningUnitTests || (_isWindowsTerminal && Environment.OSVersion.Version.Build >= 14931);
public override bool SupportsTrueColor => RunningUnitTests || (Environment.OSVersion.Version.Build >= 14931);
public override bool Force16Colors {
get => base.Force16Colors;

View File

@@ -1,39 +1,61 @@
<Project Sdk="Microsoft.NET.Sdk">
<!-- =================================================================== -->
<!-- Version numbers -->
<!-- Automatically updated by gitversion (run `dotnet-gitversion /updateprojectfiles`) -->
<!-- GitVersion.xml controls settings -->
<!-- =================================================================== -->
<PropertyGroup>
<Version>2.0.0</Version>
</PropertyGroup>
<!-- =================================================================== -->
<!-- .NET Build Settings -->
<!-- =================================================================== -->
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>portable</DebugType>
<VersionSuffix></VersionSuffix>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DefineConstants>TRACE;DEBUG_IDISPOSABLE</DefineConstants>
<DebugType>portable</DebugType>
<WarningsAsErrors>CS1574<!--,CA1034--></WarningsAsErrors>
</PropertyGroup>
<PropertyGroup>
<!-- Version numbers are automatically updated by gitversion when a release is released -->
<!-- In the source tree the version will always be 2.0 for all projects. -->
<!-- Do not modify these. Do NOT commit after manually running `dotnet-gitversion /updateprojectfiles` -->
<AssemblyVersion>2.0</AssemblyVersion>
<FileVersion>2.0</FileVersion>
<Version>2.0</Version>
<InformationalVersion>2.0</InformationalVersion>
<TargetFrameworks>net7.0</TargetFrameworks>
<LangVersion>10.0</LangVersion>
<RootNamespace>Terminal.Gui</RootNamespace>
<AssemblyName>Terminal.Gui</AssemblyName>
<SuppressNETCoreSdkPreviewMessage>true</SuppressNETCoreSdkPreviewMessage>
</PropertyGroup>
<!-- =================================================================== -->
<!-- Configuration Manager -->
<!-- =================================================================== -->
<ItemGroup>
<None Remove="Resources\config.json" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Resources\config.json" />
</ItemGroup>
<!-- =================================================================== -->
<!-- Dependencies -->
<!-- =================================================================== -->
<ItemGroup>
<!-- Enable Nuget Source Link for github -->
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
<PackageReference Include="Microsoft.DotNet.PlatformAbstractions" Version="3.1.6" />
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" PrivateAssets="all" />
<PackageReference Include="System.IO.Abstractions" Version="19.2.51" />
<PackageReference Include="System.Text.Json" Version="7.0.3" />
<PackageReference Include="System.Management" Version="7.0.2" />
<PackageReference Include="Wcwidth" Version="1.0.0" />
<!-- Enable Nuget Source Link for github -->
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
<InternalsVisibleTo Include="UnitTests" />
</ItemGroup>
</ItemGroup>
<PropertyGroup>
<!-- Uncomment the RestoreSources element to have dotnet restore pull NStack from a local dir for testing -->
<!-- See https://stackoverflow.com/a/44463578/297526 -->
<!--<RestoreSources>$(RestoreSources);..\..\NStack\NStack\bin\Debug;https://api.nuget.org/v3/index.json</RestoreSources>-->
</PropertyGroup>
<!-- =================================================================== -->
<!-- API Documentation -->
<!-- =================================================================== -->
<ItemGroup>
<None Include="..\docfx\images\logo.png">
<Pack>True</Pack>
@@ -44,6 +66,9 @@
<PackagePath>\</PackagePath>
</None>
</ItemGroup>
<!-- =================================================================== -->
<!-- i18 -->
<!-- =================================================================== -->
<ItemGroup>
<Compile Update="Resources\Strings.Designer.cs">
<DesignTime>True</DesignTime>
@@ -57,17 +82,26 @@
<LastGenOutput>Strings.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<!-- =================================================================== -->
<!-- Nuget -->
<!-- =================================================================== -->
<PropertyGroup>
<TargetFrameworks>net7.0</TargetFrameworks>
<LangVersion>10.0</LangVersion>
<RootNamespace>Terminal.Gui</RootNamespace>
<AssemblyName>Terminal.Gui</AssemblyName>
<DocumentationFile>bin\Release\Terminal.Gui.xml</DocumentationFile>
<GenerateDocumentationFile Condition=" '$(Configuration)' == 'Release' ">true</GenerateDocumentationFile>
<!--<GeneratePackageOnBuild Condition=" '$(Configuration)' == 'Release' ">true</GeneratePackageOnBuild>-->
<PackageId>Terminal.Gui</PackageId>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageProjectUrl>https://github.com/gui-cs/Terminal.Gui/</PackageProjectUrl>
<PackageIcon>logo.png</PackageIcon>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageTags>csharp, terminal, c#, f#, gui, toolkit, console, tui</PackageTags>
<Description>Cross platform Terminal UI toolkit for .NET</Description>
<Owners>Miguel de Icaza, Tig Kindel</Owners>
<Summary>A toolkit for building rich console apps for .NET that works on Windows, Mac, and Linux/Unix.</Summary>
<Title>Terminal.Gui - Cross platform Terminal User Interface (TUI) toolkit for .NET</Title>
<PackageReleaseNotes>
See: https://github.com/gui-cs/Terminal.Gui/releases
</PackageReleaseNotes>
<DocumentationFile>bin\Release\Terminal.Gui.xml</DocumentationFile>
<GeneratePackageOnBuild Condition=" '$(Configuration)' == 'Debug' ">true</GeneratePackageOnBuild>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<RepositoryUrl>https://github.com/gui-cs/Terminal.Gui.git</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<IncludeSymbols>true</IncludeSymbols>
@@ -75,17 +109,10 @@
<!-- Publish the repository URL in the built .nupkg (in the NuSpec <Repository> element) -->
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<!-- Embed source files that are not tracked by the source control manager in the PDB -->
<GitRepositoryRemoteName>upstream</GitRepositoryRemoteName>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<PackageIcon>logo.png</PackageIcon>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageTags>csharp, terminal, c#, f#, gui, toolkit, console, tui</PackageTags>
<Description>Cross platform Terminal UI toolkit for .NET</Description>
<Owners>Miguel de Icaza, Charlie Kindel</Owners>
<Summary>A toolkit for building rich console apps for .NET that works on Windows, Mac, and Linux/Unix.</Summary>
<Title>Terminal.Gui - Cross platform Terminal User Interface (TUI) toolkit for .NET</Title>
<PackageReleaseNotes>
See: https://github.com/gui-cs/Terminal.Gui/releases
</PackageReleaseNotes>
<EnableSourceLink>true</EnableSourceLink>
<!--<DebugType>Embedded</DebugType>-->
<Authors>Miguel de Icaza, Tig Kindel (@tig), @BDisp</Authors>
</PropertyGroup>
<ProjectExtensions><VisualStudio><UserProperties resources_4config_1json__JsonSchema="" /></VisualStudio></ProjectExtensions>
</Project>
</Project>

View File

@@ -19,6 +19,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
CODE_OF_CONDUCT.md = CODE_OF_CONDUCT.md
CONTRIBUTING.md = CONTRIBUTING.md
.github\workflows\dotnet-core.yml = .github\workflows\dotnet-core.yml
GitVersion.yml = GitVersion.yml
global.json = global.json
.github\workflows\publish.yml = .github\workflows\publish.yml
README.md = README.md
Terminal.sln.DotSettings = Terminal.sln.DotSettings

View File

@@ -1,23 +0,0 @@
[*.cs]
indent_style = tab
indent_size = 8
tab_width = 8
csharp_new_line_before_open_brace = methods,local_functions
csharp_new_line_before_else = false
csharp_new_line_before_catch = false
csharp_new_line_before_finally = false
end_of_line = crlf
csharp_indent_case_contents = true
csharp_indent_switch_labels = false
csharp_indent_labels = flush_left
csharp_space_after_keywords_in_control_flow_statements = true
csharp_space_between_method_declaration_parameter_list_parentheses = false
csharp_space_between_method_call_parameter_list_parentheses = false
csharp_preserve_single_line_blocks = true
dotnet_style_require_accessibility_modifiers = never
csharp_style_var_when_type_is_apparent = true
csharp_prefer_braces = false
csharp_space_before_open_square_brackets = true
csharp_space_between_method_call_name_and_opening_parenthesis = true
csharp_space_between_method_declaration_name_and_open_parenthesis = true

View File

@@ -1,7 +1,10 @@
{
"profiles": {
"UICatalog": {
"commandName": "Project"
"commandName": "Project",
"environmentVariables": {
"WT_SESSION": "1"
}
},
"WSL : UICatalog": {
"commandName": "Executable",

View File

@@ -1,6 +1,6 @@
{
"sdk":{
"version":"6.0.100",
"rollForward":"latestMajor"
"version":"7.0.200",
"rollForward":"latestMinor"
}
}