Skip to content

Commit

Permalink
Merge branch 'v1_showcase' of https://github.com/En3Tho/gui.cs into v…
Browse files Browse the repository at this point in the history
…1_showcase
  • Loading branch information
En3Tho committed Oct 2, 2023
2 parents f18727c + fc9ddc2 commit c6eb6d0
Show file tree
Hide file tree
Showing 26 changed files with 342 additions and 101 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/api-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup .NET Core
uses: actions/[email protected]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
# We must fetch at least the immediate parents so that if this is
# a pull request then we can checkout the head.
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/dotnet-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,25 @@ on:

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Setup .NET Core
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0
dotnet-quality: 'ga'

- name: Install dependencies
run: |
dotnet restore
- name: Build Debug
run: dotnet build --configuration Debug --no-restore

run: |
dotnet build --configuration Debug --no-restore
- name: Test
run: |
sed -i 's/"stopOnFail": false/"stopOnFail": true/g' UnitTests/xunit.runner.json
Expand Down
15 changes: 10 additions & 5 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,29 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0 #fetch-depth is needed for GitVersion
fetch-depth: 0 # fetch-depth is needed for GitVersion

- name: Install and calculate the new version with GitVersion
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v0
with:
versionSpec: 5.x
versionSpec: '5.x'
includePrerelease: true

- name: Determine Version
uses: gittools/actions/gitversion/execute@v0
with:
useConfigFile: true
#additionalArguments: /b develop
id: gitversion # step id used as reference for output values

- name: Setup dotnet
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0

dotnet-quality: 'ga'

- name: Install dependencies
run: dotnet restore

Expand Down
6 changes: 2 additions & 4 deletions Example/Example.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@
<TargetFramework>net7.0</TargetFramework>
<!-- Version numbers are automatically updated by gitversion when a release is released -->
<!-- Do not modify these. -->
<AssemblyVersion>1.14.0.0</AssemblyVersion>
<FileVersion>1.14.0.0</FileVersion>
<Version>1.14.0</Version>
<InformationalVersion>1.14.0+Branch.v1-develop-branching-update.Sha.f47377ce8ba5a97f2f84c745eca04c336b094e96</InformationalVersion>
<FileVersion>1.0.0.0</FileVersion>
<Version>1.0.0</Version>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Terminal.Gui\Terminal.Gui.csproj" />
Expand Down
4 changes: 2 additions & 2 deletions FSharpExample/FSharpExample.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<TargetFramework>net6.0</TargetFramework>
<AssemblyVersion>1.14.0.0</AssemblyVersion>
<FileVersion>1.14.0.0</FileVersion>
<InformationalVersion>1.14.0+Branch.v1-develop-branching-update.Sha.f47377ce8ba5a97f2f84c745eca04c336b094e96</InformationalVersion>
<Version>1.14.0</Version>
<InformationalVersion>1.14.0-pre.1+Branch.develop.Sha.e0b7464669ef87b96b57f2285200e02bcf85d0e7</InformationalVersion>
<Version>1.14.0-pre0001</Version>
</PropertyGroup>
<ItemGroup>
<Compile Include="Program.fs" />
Expand Down
7 changes: 5 additions & 2 deletions GitVersion.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
mode: ContinuousDeployment
tag-prefix: '[vV]'
continuous-delivery-fallback-tag: 'pre'
continuous-delivery-fallback-tag: pre
branches:
develop:
mode: ContinuousDeployment
tag: pre
regex: develop
source-branches:
- main
pre-release-weight: 100
main:
tag: rc
increment: Patch
Expand All @@ -22,4 +26,3 @@ branches:
increment: Inherit
ignore:
sha: []
merge-message-formats: {}
6 changes: 3 additions & 3 deletions ReactiveExample/ReactiveExample.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
<TargetFramework>net7.0</TargetFramework>
<!-- Version numbers are automatically updated by gitversion when a release is released -->
<!-- Do not modify these. -->
<AssemblyVersion>1.14.0.0</AssemblyVersion>
<!--<AssemblyVersion>1.14.0.0</AssemblyVersion>
<FileVersion>1.14.0.0</FileVersion>
<Version>1.14.0</Version>
<InformationalVersion>1.14.0+Branch.v1-develop-branching-update.Sha.f47377ce8ba5a97f2f84c745eca04c336b094e96</InformationalVersion>
<Version>1.14.0-pre0001</Version>
<InformationalVersion>1.14.0-pre.1+Branch.develop.Sha.e0b7464669ef87b96b57f2285200e02bcf85d0e7</InformationalVersion>-->
</PropertyGroup>
<ItemGroup>
<PackageReference Include="ReactiveUI.Fody" Version="19.4.1" />
Expand Down
1 change: 1 addition & 0 deletions Terminal.Gui/ConsoleDrivers/CursesDriver/CursesDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ public override void Refresh ()
Curses.raw ();
Curses.noecho ();
Curses.refresh ();
ProcessWinChange ();
}

private void ProcessWinChange ()
Expand Down
17 changes: 14 additions & 3 deletions Terminal.Gui/ConsoleDrivers/CursesDriver/UnixMainLoop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ class Watch {
bool poll_dirty = true;
int [] wakeupPipes = new int [2];
static IntPtr ignore = Marshal.AllocHGlobal (1);
static IntPtr readHandle = Marshal.AllocHGlobal (1);
MainLoop mainLoop;
bool winChanged;

Expand All @@ -97,8 +96,8 @@ void IMainLoopDriver.Setup (MainLoop mainLoop)
{
this.mainLoop = mainLoop;
pipe (wakeupPipes);
AddWatch (wakeupPipes [1], Condition.PollIn, ml => {
read (wakeupPipes [1], ignore, readHandle);
AddWatch (wakeupPipes [0], Condition.PollIn, ml => {
read (wakeupPipes [1], ignore, (IntPtr)1);
return true;
});
}
Expand Down Expand Up @@ -176,6 +175,18 @@ bool CheckTimers (bool wait, out int pollTimeout)
if (mainLoop.timeouts.Count > 0) {
pollTimeout = (int)((mainLoop.timeouts.Keys [0] - now) / TimeSpan.TicksPerMillisecond);
if (pollTimeout < 0) {
// This avoids 'poll' waiting infinitely if 'pollTimeout < 0' until some action is detected
// This can occur after IMainLoopDriver.Wakeup is executed where the pollTimeout is less than 0
// and no event occurred in elapsed time when the 'poll' is start running again.
/*
The 'poll' function in the C standard library uses a signed integer as the timeout argument, where:
- A positive value specifies a timeout in milliseconds.
- A value of 0 means the poll function will return immediately, checking for events and not waiting.
- A value of -1 means the poll function will wait indefinitely until an event occurs or an error occurs.
- A negative value other than -1 typically indicates an error.
*/
pollTimeout = 0;
return true;
}
} else
Expand Down
3 changes: 2 additions & 1 deletion Terminal.Gui/Core/Application.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1053,7 +1053,8 @@ public static void End (RunState runState)
MdiTop.OnAllChildClosed ();
} else {
SetCurrentAsTop ();
Current.OnEnter (Current);
runState.Toplevel.OnLeave (Current);
Current.OnEnter (runState.Toplevel);
}
Refresh ();
}
Expand Down
32 changes: 17 additions & 15 deletions Terminal.Gui/Core/Border.cs
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ public override void Redraw (Rect bounds)
/// <inheritdoc/>
public override void OnCanFocusChanged ()
{
if (Border.Child != null) {
if (Border?.Child != null) {
Border.Child.CanFocus = CanFocus;
}
base.OnCanFocusChanged ();
Expand Down Expand Up @@ -375,8 +375,10 @@ public Thickness BorderThickness {
public Color BorderBrush {
get => borderBrush != null ? (Color)borderBrush : (Color)(-1);
set {
borderBrush = value;
OnBorderChanged ();
if (Enum.IsDefined (typeof (Color), value)) {
borderBrush = value;
OnBorderChanged ();
}
}
}

Expand All @@ -386,8 +388,10 @@ public Color BorderBrush {
public Color Background {
get => background != null ? (Color)background : (Color)(-1);
set {
background = value;
OnBorderChanged ();
if (Enum.IsDefined (typeof (Color), value)) {
background = value;
OnBorderChanged ();
}
}
}

Expand Down Expand Up @@ -445,12 +449,10 @@ public View Child {

private void Parent_Removed (View obj)
{
if (borderBrush != null)
{
if (borderBrush != null) {
BorderBrush = default;
}
if (background != null)
{
if (background != null) {
Background = default;
}
child.Removed -= Parent_Removed;
Expand Down Expand Up @@ -800,7 +802,7 @@ private void DrawParentBorder (Rect frame, bool fill = true)
SetBorderBrush (driver);

// Draw the upper BorderThickness
for (int r = frame.Y;
for (int r = Math.Max (frame.Y, 0);
r < Math.Min (frame.Y + borderThickness.Top, frame.Bottom); r++) {
for (int c = frame.X;
c < Math.Min (frame.Right, driver.Cols); c++) {
Expand All @@ -810,7 +812,7 @@ private void DrawParentBorder (Rect frame, bool fill = true)
}

// Draw the left BorderThickness
for (int r = Math.Min (frame.Y + borderThickness.Top, frame.Bottom);
for (int r = Math.Max (Math.Min (frame.Y + borderThickness.Top, frame.Bottom), 0);
r < Math.Min (frame.Bottom - borderThickness.Bottom, driver.Rows); r++) {
for (int c = frame.X;
c < Math.Min (frame.X + borderThickness.Left, frame.Right); c++) {
Expand All @@ -820,7 +822,7 @@ private void DrawParentBorder (Rect frame, bool fill = true)
}

// Draw the right BorderThickness
for (int r = Math.Min (frame.Y + borderThickness.Top, frame.Bottom);
for (int r = Math.Max (Math.Min (frame.Y + borderThickness.Top, frame.Bottom), 0);
r < Math.Min (frame.Bottom - borderThickness.Bottom, driver.Rows); r++) {
for (int c = Math.Max (frame.Right - borderThickness.Right, frame.X);
c < Math.Min (frame.Right, driver.Cols); c++) {
Expand All @@ -842,7 +844,7 @@ private void DrawParentBorder (Rect frame, bool fill = true)
SetBackground (driver);

// Draw the upper Padding
for (int r = frame.Y + borderThickness.Top;
for (int r = Math.Max (frame.Y + borderThickness.Top, 0);
r < Math.Min (frame.Y + sumThickness.Top, frame.Bottom - borderThickness.Bottom); r++) {
for (int c = frame.X + borderThickness.Left;
c < Math.Min (frame.Right - borderThickness.Right, driver.Cols); c++) {
Expand All @@ -852,7 +854,7 @@ private void DrawParentBorder (Rect frame, bool fill = true)
}

// Draw the left Padding
for (int r = frame.Y + sumThickness.Top;
for (int r = Math.Max (frame.Y + sumThickness.Top, 0);
r < Math.Min (frame.Bottom - sumThickness.Bottom, driver.Rows); r++) {
for (int c = frame.X + borderThickness.Left;
c < Math.Min (frame.X + sumThickness.Left, frame.Right - borderThickness.Right); c++) {
Expand All @@ -862,7 +864,7 @@ private void DrawParentBorder (Rect frame, bool fill = true)
}

// Draw the right Padding
for (int r = frame.Y + sumThickness.Top;
for (int r = Math.Max (frame.Y + sumThickness.Top, 0);
r < Math.Min (frame.Bottom - sumThickness.Bottom, driver.Rows); r++) {
for (int c = Math.Max (frame.Right - sumThickness.Right, frame.X + sumThickness.Left);
c < Math.Max (frame.Right - borderThickness.Right, frame.X + sumThickness.Left); c++) {
Expand Down
1 change: 1 addition & 0 deletions Terminal.Gui/Core/Toplevel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,7 @@ void FocusNearestView (IEnumerable<View> views, Direction direction)
///<inheritdoc/>
public override void Add (View view)
{
CanFocus = true;
AddMenuStatusBar (view);
base.Add (view);
}
Expand Down
3 changes: 0 additions & 3 deletions Terminal.Gui/Core/View.cs
Original file line number Diff line number Diff line change
Expand Up @@ -995,9 +995,6 @@ public virtual void Remove (View view)
view.tabIndex = -1;
SetNeedsLayout ();
SetNeedsDisplay ();
if (subviews.Count < 1) {
CanFocus = false;
}
foreach (var v in subviews) {
if (v.Frame.IntersectsWith (touched))
view.SetNeedsDisplay ();
Expand Down
3 changes: 0 additions & 3 deletions Terminal.Gui/Core/Window.cs
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,6 @@ public override void Remove (View view)
SetNeedsDisplay ();
contentView.Remove (view);

if (contentView.InternalSubviews.Count < 1) {
CanFocus = false;
}
RemoveMenuStatusBar (view);
if (view != contentView && Focused == null) {
FocusFirst ();
Expand Down
Loading

0 comments on commit c6eb6d0

Please sign in to comment.