Small updates

This commit is contained in:
miguel
2018-03-30 22:09:13 -04:00
parent 30602b1f46
commit e7876fb5b0
3 changed files with 31 additions and 12 deletions

View File

@@ -29,9 +29,11 @@ namespace Terminal.Gui {
{
ColorScheme = Colors.Dialog;
foreach (var b in buttons) {
this.buttons.Add (b);
Add (b);
if (buttons != null) {
foreach (var b in buttons) {
this.buttons.Add (b);
Add (b);
}
}
}

View File

@@ -8,11 +8,18 @@ using NStack;
namespace Terminal.Gui {
public class FileDialog : Dialog {
Button prompt;
Label nameFieldLabel, message;
Button prompt, cancel;
Label nameFieldLabel, message, dirLabel;
TextField dir;
public FileDialog (ustring title, ustring prompt, ustring nameFieldLabel, ustring message) : base (title, Driver.Cols - 20, Driver.Rows - 6, null)
{
dirLabel = new Label (2, 1, "Directory");
Add (dirLabel);
this.cancel = new Button ("Cancel");
AddButton (cancel);
this.prompt = new Button (prompt);
AddButton (this.prompt);

24
demo.cs
View File

@@ -8,18 +8,18 @@ static class Demo {
{
}
public override void Redraw(Rect region)
public override void Redraw (Rect region)
{
Driver.SetAttribute (ColorScheme.Focus);
for (int y = 0; y < 10; y++) {
Move (0, y);
for (int x = 0; x < 10; x++) {
Driver.AddRune ((Rune)('0' + (x+y)%10));
Driver.AddRune ((Rune)('0' + (x + y) % 10));
}
}
}
}
@@ -28,7 +28,7 @@ static class Demo {
{
}
public override void Redraw(Rect region)
public override void Redraw (Rect region)
{
Driver.SetAttribute (ColorScheme.Focus);
var f = Frame;
@@ -50,7 +50,7 @@ static class Demo {
}
Driver.AddRune (r);
}
}
}
}
}
@@ -173,6 +173,16 @@ static class Demo {
MessageBox.ErrorQuery (50, 5, "Error", "There is nothing to close", "Ok");
}
// Watch what happens when I try to introduce a newline after the first open brace
// it introduces a new brace instead, and does not indent. Then watch me fight
// the editor as more oddities happen.
public static void Open ()
{
var d = new OpenDialog ("Open", "Open a file");
Application.Run (d);
}
public static Label ml;
static void Main ()
{
@@ -187,7 +197,7 @@ static class Demo {
new MenuBarItem ("_File", new MenuItem [] {
new MenuItem ("Text Editor Demo", "", () => { Editor (top); }),
new MenuItem ("_New", "Creates new file", NewFile),
new MenuItem ("_Open", "", null),
new MenuItem ("_Open", "", Open),
new MenuItem ("_Close", "", () => Close ()),
new MenuItem ("_Quit", "", () => { if (Quit ()) top.Running = false; })
}),