mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-26 15:57:56 +01:00
Merge pull request #532 from tig/text_scenario
demos text-based controls to show TAB behavior
This commit is contained in:
@@ -23,7 +23,7 @@ namespace UICatalog {
|
||||
const string rule = "|123456789";
|
||||
var horizontalRuler = new Label ("") {
|
||||
X = 0,
|
||||
Y = 0,
|
||||
Y = 0,
|
||||
Width = Dim.Fill (1), // BUGBUG: I don't think this should be needed; DimFill() should respect container's frame. X does.
|
||||
ColorScheme = Colors.Error
|
||||
};
|
||||
|
||||
@@ -14,6 +14,10 @@ namespace UICatalog {
|
||||
|
||||
public override void Setup ()
|
||||
{
|
||||
Win.Title = this.GetName() + "-" + _fileName ?? "Untitled";
|
||||
Win.Y = 1;
|
||||
Top.LayoutSubviews ();
|
||||
|
||||
var menu = new MenuBar (new MenuBarItem [] {
|
||||
new MenuBarItem ("_File", new MenuItem [] {
|
||||
new MenuItem ("_New", "", () => New()),
|
||||
@@ -40,28 +44,20 @@ namespace UICatalog {
|
||||
|
||||
CreateDemoFile (_fileName);
|
||||
|
||||
Win = new Window (_fileName ?? "Untitled") {
|
||||
X = 0,
|
||||
Y = 1,
|
||||
Width = Dim.Fill (),
|
||||
Height = Dim.Fill ()
|
||||
};
|
||||
Top.Add (Win);
|
||||
|
||||
_hexView = new HexView (LoadFile()) {
|
||||
X = 0,
|
||||
Y = 0,
|
||||
Width = Dim.Fill (),
|
||||
Height = Dim.Fill (),
|
||||
};
|
||||
|
||||
|
||||
_hexView.CanFocus = true;
|
||||
Win.Add (_hexView);
|
||||
}
|
||||
|
||||
private void New ()
|
||||
{
|
||||
Win.Title = _fileName = "Untitled";
|
||||
_fileName = null;
|
||||
Win.Title = this.GetName () + "-" + _fileName ?? "Untitled";
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
@@ -75,7 +71,7 @@ namespace UICatalog {
|
||||
if (_fileName != null) {
|
||||
var bin = System.IO.File.ReadAllBytes (_fileName);
|
||||
stream = new MemoryStream (bin);
|
||||
Win.Title = _fileName;
|
||||
Win.Title = this.GetName () + "-" + _fileName;
|
||||
_saved = true;
|
||||
}
|
||||
return stream;
|
||||
|
||||
59
UICatalog/Scenarios/Text.cs
Normal file
59
UICatalog/Scenarios/Text.cs
Normal file
@@ -0,0 +1,59 @@
|
||||
using System.Text;
|
||||
using Terminal.Gui;
|
||||
|
||||
namespace UICatalog {
|
||||
[ScenarioMetadata (Name: "Text Input Controls", Description: "Tests all text input controls")]
|
||||
[ScenarioCategory ("Controls")]
|
||||
[ScenarioCategory ("Bug Repro")]
|
||||
class Text : Scenario {
|
||||
public override void Setup ()
|
||||
{
|
||||
var s = "This is a test intended to show how TAB key works (or doesn't) across text fields.";
|
||||
Win.Add (new TextField (s) {
|
||||
X = 5,
|
||||
Y = 1,
|
||||
Width = Dim.Percent (80),
|
||||
ColorScheme = Colors.Dialog
|
||||
});
|
||||
|
||||
var textView = new TextView () {
|
||||
X = 5,
|
||||
Y = 3,
|
||||
Width = Dim.Percent (80),
|
||||
Height = Dim.Percent (40),
|
||||
ColorScheme = Colors.Dialog
|
||||
};
|
||||
textView.Text = s;
|
||||
Win.Add (textView);
|
||||
|
||||
// BUGBUG: 531 - TAB doesn't go to next control from HexView
|
||||
var hexView = new HexView (new System.IO.MemoryStream(Encoding.ASCII.GetBytes (s))) {
|
||||
X = 5,
|
||||
Y = Pos.Bottom(textView) + 1,
|
||||
Width = Dim.Percent(80),
|
||||
Height = Dim.Percent(40),
|
||||
ColorScheme = Colors.Dialog
|
||||
};
|
||||
Win.Add (hexView);
|
||||
|
||||
var dateField = new DateField (System.DateTime.Now) {
|
||||
X = 5,
|
||||
Y = Pos.Bottom (hexView) + 1,
|
||||
Width = Dim.Percent (40),
|
||||
ColorScheme = Colors.Dialog,
|
||||
IsShortFormat = false
|
||||
};
|
||||
Win.Add (dateField);
|
||||
|
||||
var timeField = new TimeField (System.DateTime.Now) {
|
||||
X = Pos.Right(dateField) + 5,
|
||||
Y = Pos.Bottom (hexView) + 1,
|
||||
Width = Dim.Percent (40),
|
||||
ColorScheme = Colors.Dialog,
|
||||
IsShortFormat = false
|
||||
};
|
||||
Win.Add (timeField);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user