diff --git a/Terminal.Gui/ConsoleDrivers/WindowsDriver.cs b/Terminal.Gui/ConsoleDrivers/WindowsDriver.cs index 01a8fcd8e..3b30118b8 100644 --- a/Terminal.Gui/ConsoleDrivers/WindowsDriver.cs +++ b/Terminal.Gui/ConsoleDrivers/WindowsDriver.cs @@ -54,6 +54,8 @@ internal class WindowsConsole public bool WriteToConsole (Size size, ExtendedCharInfo [] charInfoBuffer, Coord bufferSize, SmallRect window, bool force16Colors) { + //Debug.WriteLine ("WriteToConsole"); + if (_screenBuffer == nint.Zero) { ReadFromConsoleOutput (size, bufferSize, ref window); @@ -1297,6 +1299,7 @@ internal class WindowsDriver : ConsoleDriver Y = (short)Rows, //Clip.Height }; + bool _dirty = false; for (var row = 0; row < Rows; row++) { if (!_dirtyLines [row]) @@ -1320,6 +1323,7 @@ internal class WindowsDriver : ConsoleDriver } _outputBuffer [position].Empty = false; + _dirty = true; if (Contents [row, col].Rune.IsBmp) { diff --git a/Terminal.Gui/View/Adornment/Border.cs b/Terminal.Gui/View/Adornment/Border.cs index 99fae34fb..082df687f 100644 --- a/Terminal.Gui/View/Adornment/Border.cs +++ b/Terminal.Gui/View/Adornment/Border.cs @@ -270,7 +270,10 @@ public class Border : Adornment } // BUGBUG: See https://github.com/gui-cs/Terminal.Gui/issues/3312 - if (!_dragPosition.HasValue && mouseEvent.Flags.HasFlag (MouseFlags.Button1Pressed)) + if (!_dragPosition.HasValue && mouseEvent.Flags.HasFlag (MouseFlags.Button1Pressed) + // HACK: Prevents Window from being draggable if it's Top + //&& Parent is Toplevel { Modal: true } + ) { Parent!.SetFocus (); diff --git a/Terminal.Gui/View/Adornment/Margin.cs b/Terminal.Gui/View/Adornment/Margin.cs index 818b19698..1f6cc8154 100644 --- a/Terminal.Gui/View/Adornment/Margin.cs +++ b/Terminal.Gui/View/Adornment/Margin.cs @@ -91,17 +91,22 @@ public class Margin : Adornment /// public override void OnDrawContent (Rectangle viewport) { + if (!NeedsDisplay) + { + return; + } + Rectangle screen = ViewportToScreen (viewport); Attribute normalAttr = GetNormalColor (); Driver?.SetAttribute (normalAttr); - // This just draws/clears the thickness, not the insides. if (ShadowStyle != ShadowStyle.None) { screen = Rectangle.Inflate (screen, -1, -1); } + // This just draws/clears the thickness, not the insides. Thickness.Draw (screen, ToString ()); if (Subviews.Count > 0) diff --git a/UICatalog/KeyBindingsDialog.cs b/UICatalog/KeyBindingsDialog.cs index 1667d0729..94aa4f91a 100644 --- a/UICatalog/KeyBindingsDialog.cs +++ b/UICatalog/KeyBindingsDialog.cs @@ -19,8 +19,8 @@ internal class KeyBindingsDialog : Dialog { Title = "Keybindings"; - Height = Dim.Percent (80); - Width = Dim.Percent (80); + //Height = Dim.Percent (80); + //Width = Dim.Percent (80); if (ViewTracker.Instance == null) { ViewTracker.Initialize (); diff --git a/UICatalog/Scenarios/ASCIICustomButton.cs b/UICatalog/Scenarios/ASCIICustomButton.cs index 3ed5f7776..04b4e0b3e 100644 --- a/UICatalog/Scenarios/ASCIICustomButton.cs +++ b/UICatalog/Scenarios/ASCIICustomButton.cs @@ -241,6 +241,8 @@ public class ASCIICustomButtonTest : Scenario { Add (titleLabel, _scrollView); } + + Y = 1; } private void Button_Initialized (object sender, EventArgs e) { diff --git a/UICatalog/Scenarios/AllViewsTester.cs b/UICatalog/Scenarios/AllViewsTester.cs index c0d64051e..026a18383 100644 --- a/UICatalog/Scenarios/AllViewsTester.cs +++ b/UICatalog/Scenarios/AllViewsTester.cs @@ -149,7 +149,7 @@ public class AllViewsTester : Scenario var label = new Label { X = 0, Y = 0, Text = "X:" }; _locationFrame.Add (label); _xRadioGroup = new () { X = 0, Y = Pos.Bottom (label), RadioLabels = radioItems }; - _xRadioGroup.SelectedItemChanged += OnXRadioGroupOnSelectedItemChanged; + _xRadioGroup.SelectedItemChanged += OnRadioGroupOnSelectedItemChanged; _xText = new () { X = Pos.Right (label) + 1, Y = 0, Width = 4, Text = $"{_xVal}" }; _xText.Accepting += (s, args) => @@ -183,7 +183,7 @@ public class AllViewsTester : Scenario }; _locationFrame.Add (_yText); _yRadioGroup = new () { X = Pos.X (label), Y = Pos.Bottom (label), RadioLabels = radioItems }; - _yRadioGroup.SelectedItemChanged += OnYRadioGroupOnSelectedItemChanged; + _yRadioGroup.SelectedItemChanged += OnRadioGroupOnSelectedItemChanged; _locationFrame.Add (_yRadioGroup); _sizeFrame = new () @@ -200,7 +200,7 @@ public class AllViewsTester : Scenario label = new () { X = 0, Y = 0, Text = "Width:" }; _sizeFrame.Add (label); _wRadioGroup = new () { X = 0, Y = Pos.Bottom (label), RadioLabels = radioItems }; - _wRadioGroup.SelectedItemChanged += OnWRadioGroupOnSelectedItemChanged; + _wRadioGroup.SelectedItemChanged += OnRadioGroupOnSelectedItemChanged; _wText = new () { X = Pos.Right (label) + 1, Y = 0, Width = 4, Text = $"{_wVal}" }; _wText.Accepting += (s, args) => @@ -260,7 +260,7 @@ public class AllViewsTester : Scenario _sizeFrame.Add (_hText); _hRadioGroup = new () { X = Pos.X (label), Y = Pos.Bottom (label), RadioLabels = radioItems }; - _hRadioGroup.SelectedItemChanged += OnHRadioGroupOnSelectedItemChanged; + _hRadioGroup.SelectedItemChanged += OnRadioGroupOnSelectedItemChanged; _sizeFrame.Add (_hRadioGroup); _settingsPane.Add (_sizeFrame); @@ -333,13 +333,7 @@ public class AllViewsTester : Scenario Application.Shutdown (); } - private void OnHRadioGroupOnSelectedItemChanged (object s, SelectedItemChangedArgs selected) { DimPosChanged (_curView); } - - private void OnWRadioGroupOnSelectedItemChanged (object s, SelectedItemChangedArgs selected) { DimPosChanged (_curView); } - - private void OnYRadioGroupOnSelectedItemChanged (object s, SelectedItemChangedArgs selected) { DimPosChanged (_curView); } - - private void OnXRadioGroupOnSelectedItemChanged (object s, SelectedItemChangedArgs selected) { DimPosChanged (_curView); } + private void OnRadioGroupOnSelectedItemChanged (object s, SelectedItemChangedArgs selected) { DimPosChanged (_curView); } // TODO: Add Command.HotKey handler (pop a message box?) private void CreateCurrentView (Type type) @@ -407,7 +401,7 @@ public class AllViewsTester : Scenario private void DimPosChanged (View view) { - if (view == null) + if (view == null || _updatingSettings) { return; } @@ -504,8 +498,10 @@ public class AllViewsTester : Scenario UpdateHostTitle (_curView); } + private bool _updatingSettings = false; private void UpdateSettings (View view) { + _updatingSettings = true; var x = view.X.ToString (); var y = view.Y.ToString (); @@ -528,27 +524,29 @@ public class AllViewsTester : Scenario _wRadioGroup.SelectedItem = _dimNames.IndexOf (_dimNames.First (s => w.Contains (s))); _hRadioGroup.SelectedItem = _dimNames.IndexOf (_dimNames.First (s => h.Contains (s))); - if (view.Width is DimAuto) + if (view.Width.Has (out _)) { _wText.Text = "Auto"; _wText.Enabled = false; } else { - _wText.Text = "100"; + _wText.Text = $"{view.Frame.Width}"; _wText.Enabled = true; } - if (view.Height is DimAuto) + if (view.Height.Has (out _)) { _hText.Text = "Auto"; _hText.Enabled = false; } else { - _hText.Text = "100"; + _hText.Text = $"{view.Frame.Height}"; _hText.Enabled = true; } + + _updatingSettings = false; } private void UpdateHostTitle (View view) { _hostPane.Title = $"_Demo of {view.GetType ().Name}"; } @@ -560,25 +558,17 @@ public class AllViewsTester : Scenario return; } - if (view.Width is not DimAuto && (view.Width is null || view.Frame.Width == 0)) + if (!view.Width!.Has (out _) || (view.Width is null || view.Frame.Width == 0)) { view.Width = Dim.Fill (); } - if (view.Height is not DimAuto && (view.Height is null || view.Frame.Height == 0)) + if (!view.Height!.Has (out _) || (view.Height is null || view.Frame.Height == 0)) { view.Height = Dim.Fill (); } - _xRadioGroup.SelectedItemChanged -= OnXRadioGroupOnSelectedItemChanged; - _yRadioGroup.SelectedItemChanged -= OnYRadioGroupOnSelectedItemChanged; - _hRadioGroup.SelectedItemChanged -= OnHRadioGroupOnSelectedItemChanged; - _wRadioGroup.SelectedItemChanged -= OnWRadioGroupOnSelectedItemChanged; UpdateSettings (view); - _xRadioGroup.SelectedItemChanged += OnXRadioGroupOnSelectedItemChanged; - _yRadioGroup.SelectedItemChanged += OnYRadioGroupOnSelectedItemChanged; - _hRadioGroup.SelectedItemChanged += OnHRadioGroupOnSelectedItemChanged; - _wRadioGroup.SelectedItemChanged += OnWRadioGroupOnSelectedItemChanged; UpdateHostTitle (view); }