diff --git a/Terminal.Gui/Dialogs/Dialog.cs b/Terminal.Gui/Dialogs/Dialog.cs index d74106c55..f578f15a4 100644 --- a/Terminal.Gui/Dialogs/Dialog.cs +++ b/Terminal.Gui/Dialogs/Dialog.cs @@ -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); + } } } diff --git a/Terminal.Gui/Dialogs/FileDialog.cs b/Terminal.Gui/Dialogs/FileDialog.cs index c275fe738..8b5a95dce 100644 --- a/Terminal.Gui/Dialogs/FileDialog.cs +++ b/Terminal.Gui/Dialogs/FileDialog.cs @@ -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); diff --git a/demo.cs b/demo.cs index 33cfef9c3..a5a115b8a 100644 --- a/demo.cs +++ b/demo.cs @@ -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; }) }),