Skip to content

Commit 82bab39

Browse files
authored
Merge branch 'gui-cs:v2_develop' into v2_develop
2 parents 208461f + 9d7ac35 commit 82bab39

File tree

6 files changed

+11
-114
lines changed

6 files changed

+11
-114
lines changed

README.md

Lines changed: 1 addition & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -49,91 +49,7 @@ The team is looking forward to seeing new amazing projects made by the community
4949

5050
The following example shows a basic Terminal.Gui application in C#:
5151

52-
```csharp
53-
// This is a simple example application. For the full range of functionality
54-
// see the UICatalog project
55-
56-
// A simple Terminal.Gui example in C# - using C# 9.0 Top-level statements
57-
58-
using System;
59-
using Terminal.Gui;
60-
61-
Application.Run<ExampleWindow> ().Dispose ();
62-
63-
// Before the application exits, reset Terminal.Gui for clean shutdown
64-
Application.Shutdown ();
65-
66-
// To see this output on the screen it must be done after shutdown,
67-
// which restores the previous screen.
68-
Console.WriteLine ($@"Username: {ExampleWindow.UserName}");
69-
70-
// Defines a top-level window with border and title
71-
public class ExampleWindow : Window
72-
{
73-
public static string UserName;
74-
75-
public ExampleWindow ()
76-
{
77-
Title = $"Example App ({Application.QuitKey} to quit)";
78-
79-
// Create input components and labels
80-
var usernameLabel = new Label { Text = "Username:" };
81-
82-
var userNameText = new TextField
83-
{
84-
// Position text field adjacent to the label
85-
X = Pos.Right (usernameLabel) + 1,
86-
87-
// Fill remaining horizontal space
88-
Width = Dim.Fill ()
89-
};
90-
91-
var passwordLabel = new Label
92-
{
93-
Text = "Password:", X = Pos.Left (usernameLabel), Y = Pos.Bottom (usernameLabel) + 1
94-
};
95-
96-
var passwordText = new TextField
97-
{
98-
Secret = true,
99-
100-
// align with the text box above
101-
X = Pos.Left (userNameText),
102-
Y = Pos.Top (passwordLabel),
103-
Width = Dim.Fill ()
104-
};
105-
106-
// Create login button
107-
var btnLogin = new Button
108-
{
109-
Text = "Login",
110-
Y = Pos.Bottom (passwordLabel) + 1,
111-
112-
// center the login button horizontally
113-
X = Pos.Center (),
114-
IsDefault = true
115-
};
116-
117-
// When login button is clicked display a message popup
118-
btnLogin.Accept += (s, e) =>
119-
{
120-
if (userNameText.Text == "admin" && passwordText.Text == "password")
121-
{
122-
MessageBox.Query ("Logging In", "Login Successful", "Ok");
123-
UserName = userNameText.Text;
124-
Application.RequestStop ();
125-
}
126-
else
127-
{
128-
MessageBox.ErrorQuery ("Logging In", "Incorrect username or password", "Ok");
129-
}
130-
};
131-
132-
// Add the views to the Window
133-
Add (usernameLabel, userNameText, passwordLabel, passwordText, btnLogin);
134-
}
135-
}
136-
```
52+
[!code-csharp[](./Example/Example.cs)]
13753

13854
When run the application looks as follows:
13955

docfx/docs/arrangement.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Terminal.Gui provides a feature of Layout known as **Arrangement**, which contro
55

66
* **Arrangement** - Describes the feature of [Layout](layout.md) which controls how the user can use the mouse and keyboard to arrange views and enables either **Tiled** or **Overlapped** layouts.
77

8-
* **Arrange Mode** - When a user presses `Ctrl+F5` (configurable via the @Terminal.Gui.Application.ArrangeKey) the application goes into **Arrange Mode**. In this mode, indicators are displayed on an arrangeable view indicating which aspect of the View can be arranged. If @Terminal.Gui.ViewArrangement.Movable, a `` will be displayed in the top-left corner of the @Terminal.Gui.View.Border. If @Terminal.Gui.ViewArrangement.Resizable , pressing `Tab` (or `Shift+Tab`) will cycle to an an indictor in the bottom-right corner of the Border. The up/down/left/right cursor keys will act appropriately. `Esc`, `Ctrl+F5` or clicking outside of the Border will exit Arrange Mode.
8+
* **Arrange Mode** - The Arrange Modes are set via @Terminal.Gui.View.ViewArrangement. When a user presses `Ctrl+F5` (configurable via the @Terminal.Gui.Application.ArrangeKey) the application goes into **Arrange Mode**. In this mode, indicators are displayed on an arrangeable view indicating which aspect of the View can be arranged. If @Terminal.Gui.ViewArrangement.Movable, a `` will be displayed in the top-left corner of the @Terminal.Gui.View.Border. If @Terminal.Gui.ViewArrangement.Resizable , pressing `Tab` (or `Shift+Tab`) will cycle to an an indictor in the bottom-right corner of the Border. The up/down/left/right cursor keys will act appropriately. `Esc`, `Ctrl+F5` or clicking outside of the Border will exit Arrange Mode.
99

1010
* **Modal** - A modal view is one that is run as an "application" via @Terminal.Gui.Application.Run(System.Func{System.Exception,System.Boolean},Terminal.Gui.ConsoleDriver) where `Modal == true`. `Dialog`, `Messagebox`, and `Wizard` are the prototypical examples. When run this way, there IS a `z-order` but it is highly-constrained: the modal view has a z-order of 1 and everything else is at 0.
1111

docfx/docs/index.md

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ var button = new Button () {
9191
Width = Dim.Fill (),
9292
Height = Dim.Fill () - 1
9393
};
94-
button.Clicked += () => {
94+
button.Accepting += () => {
9595
MessageBox.Query (50, 5, "Hi", "Hello World! This is a message box", "Ok");
9696
};
9797

@@ -143,26 +143,7 @@ Views can either be Modal or Non-modal. Modal views take over all user input unt
143143
To run any View (but especially Dialogs, Windows, or Toplevels) modally, invoke the `Application.Run` method on a Toplevel. Use the `Application.RequestStop()` method to terminate the modal execution.
144144

145145
```csharp
146-
bool okpressed = false;
147-
var ok = new Button(3, 14, "Ok") {
148-
Clicked = () => { Application.RequestStop (); okpressed = true; }
149-
};
150-
var cancel = new Button(10, 14, "Cancel") {
151-
Clicked = () => Application.RequestStop ()
152-
};
153-
var dialog = new Dialog ("Login", 60, 18, ok, cancel);
154146

155-
var entry = new TextField () {
156-
X = 1,
157-
Y = 1,
158-
Width = Dim.Fill (),
159-
Height = 1
160-
};
161-
dialog.Add (entry);
162-
Application.Run (dialog);
163-
if (okpressed)
164-
Console.WriteLine ("The user entered: " + entry.Text);
165-
dialog.Dispose ();
166147
```
167148

168149
There is no return value from running modally, so the modal view must have a mechanism to indicate the reason the modal was closed. In the case above, the `okpressed` value is set to true if the user pressed or selected the `Ok` button.

docfx/docs/layout.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ To enable scrolling call `View.SetContentSize()` and then set `Viewport.Location
8282

8383
See the [Scrolling Deep Dive](scrolling.md) for details on how to enable scrolling.
8484

85-
The `View.ViewportSettings` property controls how the Viewport is constrained. By default, the `ViewportSettings` is set to `ViewportSettings.None`. To enable the viewport to be moved up-and-to-the-left of the content, use `ViewportSettings.AllowNegativeX` and or `ViewportSettings.AllowNegativeY`.
85+
The @Terminal.Gui.View.ViewportSettings property controls how the Viewport is constrained. By default, the `ViewportSettings` is set to `ViewportSettings.None`. To enable the viewport to be moved up-and-to-the-left of the content, use `ViewportSettings.AllowNegativeX` and or `ViewportSettings.AllowNegativeY`.
8686

8787
The default `ViewportSettings` also constrains the Viewport to the size of the content, ensuring the right-most column or bottom-most row of the content will always be visible (in v1 the equivalent concept was `ScrollBarView.AlwaysKeepContentInViewport`). To allow the Viewport to be smaller than the content, set `ViewportSettings.AllowXGreaterThanContentWidth` and/or `ViewportSettings.AllowXGreaterThanContentHeight`.
8888

docfx/docs/scrolling.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,13 @@ These Scenarios illustrate Terminal.Gui scrolling:
4040

4141
## [Viewport Settings](~/api/Terminal.Gui.ViewportSettings.yml)
4242

43-
Use [View.ViewportSettings](~/api/Terminal.Gui.View.ViewportSettings.yml) to adjust the behavior of scrolling.
43+
Use @Terminal.Gui.ViewporSettings to adjust the behavior of scrolling.
4444

45-
* [AllowNegativeX/Y](~/api/Terminal.Gui.ViewportSettings.AllowNegativeXyml) - If set, Viewport.Size can be set to negative coordinates enabling scrolling beyond the top-left of the content area.
45+
* `AllowNegativeX/Y` - If set, Viewport.Size can be set to negative coordinates enabling scrolling beyond the top-left of the content area.
4646

47-
* [AllowX/YGreaterThanContentWidth](~/api/Terminal.Gui.ViewportSettings.AllowXGreaterThanContentWidth) - If set, Viewport.Size can be set values greater than GetContentSize() enabling scrolling beyond the bottom-right of the Content Area. When not set, `Viewport.X/Y` are constrained to the dimension of the content area - 1. This means the last column of the content will remain visible even if there is an attempt to scroll the Viewport past the last column. The practical effect of this is that the last column/row of the content will always be visible.
47+
* `AllowX/YGreaterThanContentWidth` - If set, Viewport.Size can be set values greater than GetContentSize() enabling scrolling beyond the bottom-right of the Content Area. When not set, `Viewport.X/Y` are constrained to the dimension of the content area - 1. This means the last column of the content will remain visible even if there is an attempt to scroll the Viewport past the last column. The practical effect of this is that the last column/row of the content will always be visible.
4848

49-
* [ClipContentOnly](~/api/Terminal.Gui.ViewportSettings.ClipContentOnly) - By default, clipping is applied to [Viewport](~/api/Terminal.Gui.View.Viewport.yml). Setting this flag will cause clipping to be applied to the visible content area.
49+
* `ClipContentOnly` - By default, clipping is applied to [Viewport](~/api/Terminal.Gui.View.Viewport.yml). Setting this flag will cause clipping to be applied to the visible content area.
5050

51-
* [ClearContentOnly](~/api/Terminal.Gui.ViewportSettings.ClearContentOnly) - If set [View.Clear()](~/api/Terminal.Gui.View.Clear.yml) will clear only the portion of the content area that is visible within the Viewport. This is useful for views that have a content area larger than the Viewport and want the area outside the content to be visually distinct.
52-
53-
* [EnableHorizontal/VerticalScrollBar](~/api/Terminal.Gui.ViewportSettings.EnableHorizontalScrollBar) - If set, the scroll bar will be enabled and automatically made visible when the corresponding dimension of [View.Viewport](~/api/Terminal.Gui.View.Viewport.yml) is smaller than the dimension of [View.GetContentSize()](~/api/Terminal.Gui.View.GetContentSize.yml).
51+
* `ClearContentOnly`- If set [View.Clear()](~/api/Terminal.Gui.View.Clear.yml) will clear only the portion of the content area that is visible within the Viewport. This is useful for views that have a content area larger than the Viewport and want the area outside the content to be visually distinct.
5452

docfx/docs/toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
href: arrangement.md
1717
- name: Navigation
1818
href: navigation.md
19+
- name: Scrolling
20+
href: scrolling.md
1921
- name: Keyboard
2022
href: keyboard.md
2123
- name: Mouse

0 commit comments

Comments
 (0)