Skip to content

Commit 5863d38

Browse files
committed
Merge branch 'v2_develop' of tig:tig/Terminal.Gui into v2_develop
2 parents 1c04acf + d3f4c42 commit 5863d38

File tree

19 files changed

+3304
-2676
lines changed

19 files changed

+3304
-2676
lines changed

.editorconfig

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1881,8 +1881,3 @@ tab_width = 4
18811881
indent_style = space
18821882
indent_size = 2
18831883
tab_width = 2
1884-
1885-
[*.{appxmanifest,axaml,axml,build,config,cs,csproj,dbml,discomap,dtd,jsproj,lsproj,njsproj,nuspec,paml,proj,props,resw,resx,StyleCop,targets,tasks,vb,vbproj,xaml,xamlx,xml,xoml,xsd}]
1886-
indent_style = space
1887-
indent_size = 4
1888-
tab_width = 4

Examples/UICatalog/Scenarios/Editor.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,8 @@ public override void Main ()
201201
CreateAutocomplete (),
202202
CreateAllowsTabChecked (),
203203
CreateReadOnlyChecked (),
204+
CreateUseSameRuneTypeForWords (),
205+
CreateSelectWordOnlyOnDoubleClick (),
204206
new MenuItem (
205207
"Colors",
206208
"",
@@ -776,6 +778,26 @@ private MenuItem [] CreateKeepChecked ()
776778
return new [] { item };
777779
}
778780

781+
private MenuItem CreateSelectWordOnlyOnDoubleClick ()
782+
{
783+
var item = new MenuItem { Title = "SelectWordOnlyOnDoubleClick" };
784+
item.CheckType |= MenuItemCheckStyle.Checked;
785+
item.Checked = _textView.SelectWordOnlyOnDoubleClick;
786+
item.Action += () => _textView.SelectWordOnlyOnDoubleClick = (bool)(item.Checked = !item.Checked);
787+
788+
return item;
789+
}
790+
791+
private MenuItem CreateUseSameRuneTypeForWords ()
792+
{
793+
var item = new MenuItem { Title = "UseSameRuneTypeForWords" };
794+
item.CheckType |= MenuItemCheckStyle.Checked;
795+
item.Checked = _textView.UseSameRuneTypeForWords;
796+
item.Action += () => _textView.UseSameRuneTypeForWords = (bool)(item.Checked = !item.Checked);
797+
798+
return item;
799+
}
800+
779801
private MenuItem CreateReadOnlyChecked ()
780802
{
781803
var item = new MenuItem { Title = "Read Only" };

Terminal.Gui/App/IPopover.cs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,26 @@ namespace Terminal.Gui.App;
2626
/// </list>
2727
/// </para>
2828
/// <para>
29-
/// To implement a custom popover, inherit from <see cref="PopoverBaseImpl"/> or implement this interface directly.
29+
/// <b>Focus and Input:</b><br/>
30+
/// When visible, a popover receives focus and input events. If the user clicks outside the popover (and not on a
31+
/// subview),
32+
/// presses <see cref="Application.QuitKey"/>, or another popover is shown, the popover will be hidden
33+
/// automatically.
34+
/// </para>
35+
/// <para>
36+
/// <b>Layout:</b><br/>
37+
/// When the popover becomes visible, it is automatically laid out to fill the screen by default. You can override
38+
/// this behavior
39+
/// by setting <see cref="View.Width"/> and <see cref="View.Height"/> in your derived class.
40+
/// </para>
41+
/// <para>
42+
/// <b>Mouse:</b><br/>
43+
/// Popovers are transparent to mouse events (see <see cref="ViewportSettingsFlags.TransparentMouse"/>),
44+
/// meaning mouse events in a popover that are not also within a subview of the popover will not be captured.
45+
/// </para>
46+
/// <para>
47+
/// <b>Custom Popovers:</b><br/>
48+
/// To create a custom popover, inherit from <see cref="PopoverBaseImpl"/> and add your own content and logic.
3049
/// </para>
3150
/// </remarks>
3251
public interface IPopover

Terminal.Gui/App/PopoverBaseImpl.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ namespace Terminal.Gui.App;
2626
/// by setting <see cref="View.Width"/> and <see cref="View.Height"/> in your derived class.
2727
/// </para>
2828
/// <para>
29+
/// <b>Mouse:</b><br/>
30+
/// Popovers are transparent to mouse events (see <see cref="ViewportSettingsFlags.TransparentMouse"/>),
31+
/// meaning mouse events in a popover that are not also within a subview of the popover will not be captured.
32+
/// </para>
33+
/// <para>
2934
/// <b>Custom Popovers:</b><br/>
3035
/// To create a custom popover, inherit from <see cref="PopoverBaseImpl"/> and add your own content and logic.
3136
/// </para>

Terminal.Gui/Drivers/NetDriver/NetDriver.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
// NetDriver.cs: The System.Console-based .NET driver, works on Windows and Unix, but is not particularly efficient.
44
//
55

6-
using System.Collections.Concurrent;
7-
using System.Diagnostics;
8-
using System.Diagnostics.CodeAnalysis;
96
using System.Runtime.InteropServices;
107
using static Terminal.Gui.Drivers.NetEvents;
118

@@ -232,6 +229,8 @@ void WriteToConsole (StringBuilder output, ref int lastCol, int row, ref int out
232229
/// <inheritdoc />
233230
public override MainLoop Init ()
234231
{
232+
Console.OutputEncoding = Encoding.UTF8;
233+
235234
PlatformID p = Environment.OSVersion.Platform;
236235

237236
if (p == PlatformID.Win32NT || p == PlatformID.Win32S || p == PlatformID.Win32Windows)

Terminal.Gui/Drivers/V2/NetOutput.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ public NetOutput ()
2222
{
2323
Logging.Logger.LogInformation ($"Creating {nameof (NetOutput)}");
2424

25+
Console.OutputEncoding = Encoding.UTF8;
26+
2527
PlatformID p = Environment.OSVersion.Platform;
2628

2729
if (p == PlatformID.Win32NT || p == PlatformID.Win32S || p == PlatformID.Win32Windows)

Terminal.Gui/Resources/config.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -511,8 +511,8 @@
511511
"Style": "None"
512512
},
513513
"Editable": {
514-
"Foreground": "Goldenrod",
515-
"Background": "WhiteSmoke",
514+
"Foreground": "Black",
515+
"Background": "LemonChiffon",
516516
"Style": "None"
517517
},
518518
"ReadOnly": {
@@ -565,8 +565,8 @@
565565
"Style": "None"
566566
},
567567
"Editable": {
568-
"Foreground": "Goldenrod",
569-
"Background": "WhiteSmoke",
568+
"Foreground": "Black",
569+
"Background": "LemonChiffon",
570570
"Style": "None"
571571
},
572572
"ReadOnly": {
@@ -669,7 +669,7 @@
669669
},
670670
"Highlight": {
671671
"Foreground": "Black",
672-
"Background": "LightGray",
672+
"Background": "LemonChiffon",
673673
"Style": "None"
674674
},
675675
"Editable": {
@@ -727,7 +727,7 @@
727727
"Style": "None"
728728
},
729729
"Editable": {
730-
"Foreground": "Goldenrod",
730+
"Foreground": "Black",
731731
"Background": "WhiteSmoke",
732732
"Style": "None"
733733
},

Terminal.Gui/ViewBase/View.Layout.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1166,7 +1166,7 @@ out int ny
11661166

11671167
result.AddRange (GetViewsUnderLocation (visiblePopover, screenLocation, excludeViewportSettingsFlags));
11681168

1169-
if (result.Count > 1)
1169+
if (result.Count > 0)
11701170
{
11711171
return result;
11721172
}

Terminal.Gui/ViewBase/ViewportSettingsFlags.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,9 @@ public enum ViewportSettingsFlags
153153
/// </summary>
154154
Transparent = 0b_0001_0000_0000,
155155

156-
// BUGBUG: The API docs here are wrong: If a TransparentMouse View has subviews, those subviews WILL get mouse events.
157-
// BUGBUG: That's an important feature that enables Popovers to work.
158156
/// <summary>
159-
/// If set the View will be transparent to mouse events: Any mouse event that occurs over the View (and it's SubViews) will be passed to the
160-
/// Views below it.
157+
/// If set the View will be transparent to mouse events: Specifically, any mouse event that occurs over the View that is NOT occupied by a SubView
158+
/// will not be captured by the View.
161159
/// <para>
162160
/// Combine this with <see cref="Transparent"/> to get a view that is both visually transparent and transparent to the mouse.
163161
/// </para>

Terminal.Gui/Views/Autocomplete/PopupAutocomplete.cs

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ public abstract partial class PopupAutocomplete : AutocompleteBase
1111
private bool _closed;
1212
private Scheme _scheme;
1313
private View _hostControl;
14-
private View _top; // The _hostControl's SuperView
15-
private View _popup;
14+
private View _top; // The _hostControl's SuperView
15+
internal View _popup;
1616
private int _toRenderLength;
1717

1818
/// <summary>Creates a new instance of the <see cref="PopupAutocomplete"/> class.</summary>
@@ -70,6 +70,7 @@ public override View HostControl
7070
{
7171
_top.Initialized += _top_Initialized;
7272
}
73+
7374
_top.Removed += _top_Removed;
7475
}
7576
}
@@ -268,7 +269,11 @@ public override void RenderOverlay (Point renderAt)
268269
else if (!Visible || HostControl?.HasFocus == false || Suggestions.Count == 0)
269270
{
270271
LastPopupPos = null;
271-
Visible = false;
272+
273+
if (Visible)
274+
{
275+
Close ();
276+
}
272277

273278
if (Suggestions.Count == 0)
274279
{
@@ -372,16 +377,16 @@ public override void RenderOverlay (Point renderAt)
372377
if (PopupInsideContainer)
373378
{
374379
_popup.Frame = new (
375-
new (HostControl.Frame.X + renderAt.X, HostControl.Frame.Y + renderAt.Y),
376-
new (width, height)
377-
);
380+
new (HostControl.Frame.X + renderAt.X, HostControl.Frame.Y + renderAt.Y),
381+
new (width, height)
382+
);
378383
}
379384
else
380385
{
381386
_popup.Frame = new (
382-
renderAt with { X = HostControl.Frame.X + renderAt.X },
383-
new (width, height)
384-
);
387+
renderAt with { X = HostControl.Frame.X + renderAt.X },
388+
new (width, height)
389+
);
385390
}
386391

387392
_popup.Move (0, 0);
@@ -419,6 +424,7 @@ protected void Close ()
419424
ClearSuggestions ();
420425
Visible = false;
421426
_closed = true;
427+
422428
//RemovePopupFromTop ();
423429
_popup.Visible = false;
424430
HostControl?.SetNeedsDraw ();
@@ -561,7 +567,6 @@ private void RemovePopupFromTop ()
561567
_top?.Remove (_popup);
562568
_popup.Dispose ();
563569
_popup = null;
564-
565570
}
566571
}
567572

@@ -571,6 +576,7 @@ private void _top_Initialized (object sender, EventArgs e)
571576
{
572577
_top = sender as View;
573578
}
579+
574580
AddPopupToTop ();
575581
}
576582

0 commit comments

Comments
 (0)