浏览代码

Made Window resizable by default

Tig 10 月之前
父节点
当前提交
889c59c7be
共有 3 个文件被更改,包括 31 次插入19 次删除
  1. 19 17
      Terminal.Gui/Application/Application.Keyboard.cs
  2. 11 1
      Terminal.Gui/View/Adornment/Border.cs
  3. 1 1
      Terminal.Gui/Views/Window.cs

+ 19 - 17
Terminal.Gui/Application/Application.Keyboard.cs

@@ -153,7 +153,7 @@ public static partial class Application // Keyboard handling
     }
 
     /// <summary>
-    /// INTENRAL method to invoke one of the commands in <see cref="CommandImplementations"/>
+    ///     INTENRAL method to invoke one of the commands in <see cref="CommandImplementations"/>
     /// </summary>
     /// <param name="command"></param>
     /// <param name="keyEvent"></param>
@@ -172,6 +172,7 @@ public static partial class Application // Keyboard handling
         if (CommandImplementations.TryGetValue (command, out Func<CommandContext, bool?>? implementation))
         {
             var context = new CommandContext (command, keyEvent, appBinding); // Create the context here
+
             return implementation (context);
         }
 
@@ -260,7 +261,6 @@ public static partial class Application // Keyboard handling
         }
     }
 
-
     /// <summary>Gets or sets the key to activate arranging views using the keyboard.</summary>
     [SerializableConfigurationProperty (Scope = typeof (SettingsScope))]
     public static Key ArrangeKey
@@ -282,7 +282,7 @@ public static partial class Application // Keyboard handling
 
         // Things this view knows how to do
         AddCommand (
-                    Command.Quit, // TODO: IRunnable: Rename to Command.Quit to make more generic.
+                    Command.Quit,
                     static () =>
                     {
                         if (ApplicationOverlapped.OverlappedTop is { })
@@ -358,23 +358,25 @@ public static partial class Application // Keyboard handling
                     }
                    );
 
-        AddCommand (Command.Edit, static () =>
-                                  {
-                                      View? viewToArrange = Navigation?.GetFocused ();
+        AddCommand (
+                    Command.Edit,
+                    static () =>
+                    {
+                        View? viewToArrange = Navigation?.GetFocused ();
 
-                                      // Go up the superview hierarchy and find the first that is not ViewArrangement.Fixed
-                                      while (viewToArrange?.SuperView is { } && viewToArrange.Arrangement == ViewArrangement.Fixed)
-                                      {
-                                          viewToArrange = viewToArrange.SuperView;
-                                      }
+                        // Go up the superview hierarchy and find the first that is not ViewArrangement.Fixed
+                        while (viewToArrange?.SuperView is { } && viewToArrange.Arrangement == ViewArrangement.Fixed)
+                        {
+                            viewToArrange = viewToArrange.SuperView;
+                        }
 
-                                      if (viewToArrange is { })
-                                      {
-                                          return viewToArrange.Border?.Arrange ();
-                                      }
+                        if (viewToArrange is { })
+                        {
+                            return viewToArrange.Border?.Arrange ();
+                        }
 
-                                      return false;
-                                  });
+                        return false;
+                    });
 
         KeyBindings.Clear ();
 

+ 11 - 1
Terminal.Gui/View/Adornment/Border.cs

@@ -116,7 +116,7 @@ public class Border : Adornment
             LayoutStarted += OnLayoutStarted;
     }
 #endif
-        
+
     }
 
 
@@ -738,6 +738,16 @@ public class Border : Adornment
     {
         Debug.Assert (_arranging == ViewArrangement.Fixed);
 
+        if (!Parent!.Arrangement.HasFlag (ViewArrangement.Movable)
+            && !Parent!.Arrangement.HasFlag (ViewArrangement.BottomResizable)
+            && !Parent!.Arrangement.HasFlag (ViewArrangement.TopResizable)
+            && !Parent!.Arrangement.HasFlag (ViewArrangement.LeftResizable)
+            && !Parent!.Arrangement.HasFlag (ViewArrangement.RightResizable)
+            )
+        {
+            return false;
+        }
+
         CanFocus = true;
         SetFocus ();
 

+ 1 - 1
Terminal.Gui/Views/Window.cs

@@ -27,7 +27,7 @@ public class Window : Toplevel
     {
         CanFocus = true;
         TabStop = TabBehavior.TabGroup;
-        Arrangement = ViewArrangement.Movable | ViewArrangement.Overlapped;
+        Arrangement = ViewArrangement.Movable | ViewArrangement.Overlapped | ViewArrangement.Resizable;
         ColorScheme = Colors.ColorSchemes ["Base"]; // TODO: make this a theme property
         BorderStyle = DefaultBorderStyle;
         ShadowStyle = DefaultShadow;