mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-27 08:17:53 +01:00
* Fixed key events traversal for modal dialogs The key must be propagated initially to the first chain element before evaluating if we should stop because of the handled or the Modal condition. Otherwise the modal dialog won't get any process key notification. This fixesc072e29a68* Fixes culture info of DataField from pr #250 * Fixes the rectangle drawing issue * Fixes #290 issue "Redraw issue when setting coordinates of label" * Added sub menus into menu bar with mouse and key navigation * Needed to assume color for the Disable attribute * Added Colors.Menu.Disabled to CursesDriver.cs * Mouse text selection with cut, copy and paste on text fields * Change sepChar from char to string in DateField * Adding a disabled menu item in the demo file * Adding a disabled menu item in the demo file * Fixes Button repainting issue when changing the text length to one smaller * Fixes #290 issue "Redraw issue when setting coordinates of label" * Only demonstration of issue # 308 that even though the cursor is gray on a gray background can be viewed. * Fixes issue #163 "ScrollView does not render some content" * Fixed bug in Button that caused a loop redraw calling TerminalResized * Fixes #282 "Repaint Issue" * Removed white space * Mouse features added to FileDialog including wheel support. * Forget to delete this commented method. * Changing back to MouseFlags.AllEvents in case some mouse event is not triggering. * Add documentation on ISupportInitialize/ISupportInitializeNotification (#286) * Switch netcoreapp target to netstandard2.0 (#284) Fixes #283 Instead of adding another target framework to the list, switch from netcoreapp2.0 to netstandard2.0, as ns2.0 is a subset of netcoreapp. * Added TextView.TextChanged event (#264) * Fixed key events traversal for modal dialogs (#288) The key must be propagated initially to the first chain element before evaluating if we should stop because of the handled or the Modal condition. Otherwise the modal dialog won't get any process key notification. This fixesc072e29a68* Prepare for 0.25 * Remove travis link * Revert Daniel's change00c5997daaas it prevents the solution from building on Mac * Prepare for 0.26 * Restore some files that were deleted by Daniel's commit that I had not restored * Fixed out of range exception and text redraw when navigate backward (#320) * Typo fix (#321) * Fixes issue #306 async/await hang (#312) * Fixed async/await hang * Fixed async/await hang with calling Wakeup * Moved Wake Up into lock statement * Support menu items that are null so they can be drawn as a menu separator (#304) * Fixed and Enabled Library reinitialization (#291) - Replaced static driver initialization with property getter for reference passing in Core.cs::View class, this allows the library to be reinitialized at any time. - Made the Shutdown method on Core.cs::Application class public, since there is no reason to keep it private. Applications can shutdown the library and revert the console to the initial stage by calling it. - Fixed a memory-leak on Drivers/WindowsDriver class by destroying the generated screen buffers at library shutdown by calling CloseHandle. - Minor change to Core.cs::Application.Init(Func<Toplevel>) for better initialization status tracking, via backend property instead of relying on the Top field. * Moved `ListView.ListWrapper` out of `ListView` migueldeicaza/gui.cs#313` (#315) * Resizing the MessageBox width to accommodate all message text (#299) * Fixed key events traversal for modal dialogs The key must be propagated initially to the first chain element before evaluating if we should stop because of the handled or the Modal condition. Otherwise the modal dialog won't get any process key notification. This fixesc072e29a68* Resizing the MessageBox width to accommodate all message text Co-authored-by: Adrian Alonso <adrianalonso@gmail.com> * Timefield format with bounds values (#303) * Implemented lower and upper bounds to TimeField * Passing old text to the Changed event handler * Change sepChar from char to string in TimeField * Changing comparison from ':' to sepChar.ToCharArray () [0] * extract methods on ListView to make it controlable from other controls (#310) * moveup * MoveDown * MovePageDown * MovePageUp * MarkUnmarkRow * Allowing list items selection (#302) * Prepare for 0.26 * Restore some files that were deleted by Daniel's commit that I had not restored * Fixed out of range exception and text redraw when navigate backward (#320) * Typo fix (#321) * Fixes issue #306 async/await hang (#312) * Fixed async/await hang * Fixed async/await hang with calling Wakeup * Moved Wake Up into lock statement * Support menu items that are null so they can be drawn as a menu separator (#304) * Fixed and Enabled Library reinitialization (#291) - Replaced static driver initialization with property getter for reference passing in Core.cs::View class, this allows the library to be reinitialized at any time. - Made the Shutdown method on Core.cs::Application class public, since there is no reason to keep it private. Applications can shutdown the library and revert the console to the initial stage by calling it. - Fixed a memory-leak on Drivers/WindowsDriver class by destroying the generated screen buffers at library shutdown by calling CloseHandle. - Minor change to Core.cs::Application.Init(Func<Toplevel>) for better initialization status tracking, via backend property instead of relying on the Top field. * Moved `ListView.ListWrapper` out of `ListView` migueldeicaza/gui.cs#313` (#315) * Resizing the MessageBox width to accommodate all message text (#299) * Fixed key events traversal for modal dialogs The key must be propagated initially to the first chain element before evaluating if we should stop because of the handled or the Modal condition. Otherwise the modal dialog won't get any process key notification. This fixesc072e29a68* Resizing the MessageBox width to accommodate all message text Co-authored-by: Adrian Alonso <adrianalonso@gmail.com> * Timefield format with bounds values (#303) * Implemented lower and upper bounds to TimeField * Passing old text to the Changed event handler * Change sepChar from char to string in TimeField * Changing comparison from ':' to sepChar.ToCharArray () [0] * extract methods on ListView to make it controlable from other controls (#310) * moveup * MoveDown * MovePageDown * MovePageUp * MarkUnmarkRow * Allowing list items selection (#302) * Add documentation on ISupportInitialize/ISupportInitializeNotification (#286) * Switch netcoreapp target to netstandard2.0 (#284) Fixes #283 Instead of adding another target framework to the list, switch from netcoreapp2.0 to netstandard2.0, as ns2.0 is a subset of netcoreapp. * Added TextView.TextChanged event (#264) * Fixed key events traversal for modal dialogs (#288) The key must be propagated initially to the first chain element before evaluating if we should stop because of the handled or the Modal condition. Otherwise the modal dialog won't get any process key notification. This fixesc072e29a68* Prepare for 0.25 * Remove travis link * Revert Daniel's change00c5997daaas it prevents the solution from building on Mac * Prepare for 0.26 * Restore some files that were deleted by Daniel's commit that I had not restored * Fixed out of range exception and text redraw when navigate backward (#320) * Typo fix (#321) * Fixes issue #306 async/await hang (#312) * Fixed async/await hang * Fixed async/await hang with calling Wakeup * Moved Wake Up into lock statement * Support menu items that are null so they can be drawn as a menu separator (#304) * Fixed and Enabled Library reinitialization (#291) - Replaced static driver initialization with property getter for reference passing in Core.cs::View class, this allows the library to be reinitialized at any time. - Made the Shutdown method on Core.cs::Application class public, since there is no reason to keep it private. Applications can shutdown the library and revert the console to the initial stage by calling it. - Fixed a memory-leak on Drivers/WindowsDriver class by destroying the generated screen buffers at library shutdown by calling CloseHandle. - Minor change to Core.cs::Application.Init(Func<Toplevel>) for better initialization status tracking, via backend property instead of relying on the Top field. * Moved `ListView.ListWrapper` out of `ListView` migueldeicaza/gui.cs#313` (#315) * Resizing the MessageBox width to accommodate all message text (#299) * Fixed key events traversal for modal dialogs The key must be propagated initially to the first chain element before evaluating if we should stop because of the handled or the Modal condition. Otherwise the modal dialog won't get any process key notification. This fixesc072e29a68* Resizing the MessageBox width to accommodate all message text Co-authored-by: Adrian Alonso <adrianalonso@gmail.com> * Timefield format with bounds values (#303) * Implemented lower and upper bounds to TimeField * Passing old text to the Changed event handler * Change sepChar from char to string in TimeField * Changing comparison from ':' to sepChar.ToCharArray () [0] * extract methods on ListView to make it controlable from other controls (#310) * moveup * MoveDown * MovePageDown * MovePageUp * MarkUnmarkRow * Allowing list items selection (#302) * Switch netcoreapp target to netstandard2.0 (#284) Fixes #283 Instead of adding another target framework to the list, switch from netcoreapp2.0 to netstandard2.0, as ns2.0 is a subset of netcoreapp. * Added TextView.TextChanged event (#264) * Prepare for 0.25 * Remove travis link * Revert Daniel's change00c5997daaas it prevents the solution from building on Mac * Prepare for 0.26 * Restore some files that were deleted by Daniel's commit that I had not restored * Fixed out of range exception and text redraw when navigate backward (#320) * Typo fix (#321) * Fixes issue #306 async/await hang (#312) * Fixed async/await hang * Fixed async/await hang with calling Wakeup * Moved Wake Up into lock statement * Fixed and Enabled Library reinitialization (#291) - Replaced static driver initialization with property getter for reference passing in Core.cs::View class, this allows the library to be reinitialized at any time. - Made the Shutdown method on Core.cs::Application class public, since there is no reason to keep it private. Applications can shutdown the library and revert the console to the initial stage by calling it. - Fixed a memory-leak on Drivers/WindowsDriver class by destroying the generated screen buffers at library shutdown by calling CloseHandle. - Minor change to Core.cs::Application.Init(Func<Toplevel>) for better initialization status tracking, via backend property instead of relying on the Top field. * Moved `ListView.ListWrapper` out of `ListView` migueldeicaza/gui.cs#313` (#315) * Resizing the MessageBox width to accommodate all message text (#299) * Fixed key events traversal for modal dialogs The key must be propagated initially to the first chain element before evaluating if we should stop because of the handled or the Modal condition. Otherwise the modal dialog won't get any process key notification. This fixesc072e29a68* Resizing the MessageBox width to accommodate all message text Co-authored-by: Adrian Alonso <adrianalonso@gmail.com> * Timefield format with bounds values (#303) * Implemented lower and upper bounds to TimeField * Passing old text to the Changed event handler * Change sepChar from char to string in TimeField * Changing comparison from ':' to sepChar.ToCharArray () [0] * extract methods on ListView to make it controlable from other controls (#310) * moveup * MoveDown * MovePageDown * MovePageUp * MarkUnmarkRow * Allowing list items selection (#302) * Added sub menus into menu bar with mouse and key navigation * Fetch from upstream/master * Fetch from upstream/master * Fetch from upstream/master * Fetch from upstream/master * Fetch from upstream/master * Add documentation on ISupportInitialize/ISupportInitializeNotification (#286) * Switch netcoreapp target to netstandard2.0 (#284) Fixes #283 Instead of adding another target framework to the list, switch from netcoreapp2.0 to netstandard2.0, as ns2.0 is a subset of netcoreapp. * Added TextView.TextChanged event (#264) * Fixed key events traversal for modal dialogs (#288) The key must be propagated initially to the first chain element before evaluating if we should stop because of the handled or the Modal condition. Otherwise the modal dialog won't get any process key notification. This fixesc072e29a68* Prepare for 0.25 * Remove travis link * Revert Daniel's change00c5997daaas it prevents the solution from building on Mac * Prepare for 0.26 * Restore some files that were deleted by Daniel's commit that I had not restored * Fixed out of range exception and text redraw when navigate backward (#320) * Typo fix (#321) * Fixes issue #306 async/await hang (#312) * Fixed async/await hang * Fixed async/await hang with calling Wakeup * Moved Wake Up into lock statement * Support menu items that are null so they can be drawn as a menu separator (#304) * Fixed and Enabled Library reinitialization (#291) - Replaced static driver initialization with property getter for reference passing in Core.cs::View class, this allows the library to be reinitialized at any time. - Made the Shutdown method on Core.cs::Application class public, since there is no reason to keep it private. Applications can shutdown the library and revert the console to the initial stage by calling it. - Fixed a memory-leak on Drivers/WindowsDriver class by destroying the generated screen buffers at library shutdown by calling CloseHandle. - Minor change to Core.cs::Application.Init(Func<Toplevel>) for better initialization status tracking, via backend property instead of relying on the Top field. * Moved `ListView.ListWrapper` out of `ListView` migueldeicaza/gui.cs#313` (#315) * Resizing the MessageBox width to accommodate all message text (#299) * Fixed key events traversal for modal dialogs The key must be propagated initially to the first chain element before evaluating if we should stop because of the handled or the Modal condition. Otherwise the modal dialog won't get any process key notification. This fixesc072e29a68* Resizing the MessageBox width to accommodate all message text Co-authored-by: Adrian Alonso <adrianalonso@gmail.com> * Timefield format with bounds values (#303) * Implemented lower and upper bounds to TimeField * Passing old text to the Changed event handler * Change sepChar from char to string in TimeField * Changing comparison from ':' to sepChar.ToCharArray () [0] * extract methods on ListView to make it controlable from other controls (#310) * moveup * MoveDown * MovePageDown * MovePageUp * MarkUnmarkRow * Allowing list items selection (#302) * Fetch from upstream/master * Fetch from upstream/master * Fetch from upstream/master * Add documentation on ISupportInitialize/ISupportInitializeNotification (#286) * Switch netcoreapp target to netstandard2.0 (#284) Fixes #283 Instead of adding another target framework to the list, switch from netcoreapp2.0 to netstandard2.0, as ns2.0 is a subset of netcoreapp. * Added TextView.TextChanged event (#264) * Fixed key events traversal for modal dialogs (#288) The key must be propagated initially to the first chain element before evaluating if we should stop because of the handled or the Modal condition. Otherwise the modal dialog won't get any process key notification. This fixesc072e29a68* Prepare for 0.25 * Remove travis link * Revert Daniel's change00c5997daaas it prevents the solution from building on Mac * Prepare for 0.26 * Restore some files that were deleted by Daniel's commit that I had not restored * Fixed out of range exception and text redraw when navigate backward (#320) * Typo fix (#321) * Fixes issue #306 async/await hang (#312) * Fixed async/await hang * Fixed async/await hang with calling Wakeup * Moved Wake Up into lock statement * Support menu items that are null so they can be drawn as a menu separator (#304) * Fixed and Enabled Library reinitialization (#291) - Replaced static driver initialization with property getter for reference passing in Core.cs::View class, this allows the library to be reinitialized at any time. - Made the Shutdown method on Core.cs::Application class public, since there is no reason to keep it private. Applications can shutdown the library and revert the console to the initial stage by calling it. - Fixed a memory-leak on Drivers/WindowsDriver class by destroying the generated screen buffers at library shutdown by calling CloseHandle. - Minor change to Core.cs::Application.Init(Func<Toplevel>) for better initialization status tracking, via backend property instead of relying on the Top field. * Moved `ListView.ListWrapper` out of `ListView` migueldeicaza/gui.cs#313` (#315) * Resizing the MessageBox width to accommodate all message text (#299) * Fixed key events traversal for modal dialogs The key must be propagated initially to the first chain element before evaluating if we should stop because of the handled or the Modal condition. Otherwise the modal dialog won't get any process key notification. This fixesc072e29a68* Resizing the MessageBox width to accommodate all message text Co-authored-by: Adrian Alonso <adrianalonso@gmail.com> * Timefield format with bounds values (#303) * Implemented lower and upper bounds to TimeField * Passing old text to the Changed event handler * Change sepChar from char to string in TimeField * Changing comparison from ':' to sepChar.ToCharArray () [0] * extract methods on ListView to make it controlable from other controls (#310) * moveup * MoveDown * MovePageDown * MovePageUp * MarkUnmarkRow * Allowing list items selection (#302) * Fetch from upstream/master * Switch netcoreapp target to netstandard2.0 (#284) Fixes #283 Instead of adding another target framework to the list, switch from netcoreapp2.0 to netstandard2.0, as ns2.0 is a subset of netcoreapp. * Added TextView.TextChanged event (#264) * Prepare for 0.25 * Remove travis link * Revert Daniel's change00c5997daaas it prevents the solution from building on Mac * Prepare for 0.26 * Restore some files that were deleted by Daniel's commit that I had not restored * Fixed out of range exception and text redraw when navigate backward (#320) * Typo fix (#321) * Fixes issue #306 async/await hang (#312) * Fixed async/await hang * Fixed async/await hang with calling Wakeup * Moved Wake Up into lock statement * Support menu items that are null so they can be drawn as a menu separator (#304) * Fixed and Enabled Library reinitialization (#291) - Replaced static driver initialization with property getter for reference passing in Core.cs::View class, this allows the library to be reinitialized at any time. - Made the Shutdown method on Core.cs::Application class public, since there is no reason to keep it private. Applications can shutdown the library and revert the console to the initial stage by calling it. - Fixed a memory-leak on Drivers/WindowsDriver class by destroying the generated screen buffers at library shutdown by calling CloseHandle. - Minor change to Core.cs::Application.Init(Func<Toplevel>) for better initialization status tracking, via backend property instead of relying on the Top field. * Moved `ListView.ListWrapper` out of `ListView` migueldeicaza/gui.cs#313` (#315) * Resizing the MessageBox width to accommodate all message text (#299) * Fixed key events traversal for modal dialogs The key must be propagated initially to the first chain element before evaluating if we should stop because of the handled or the Modal condition. Otherwise the modal dialog won't get any process key notification. This fixesc072e29a68* Resizing the MessageBox width to accommodate all message text Co-authored-by: Adrian Alonso <adrianalonso@gmail.com> * Timefield format with bounds values (#303) * Implemented lower and upper bounds to TimeField * Passing old text to the Changed event handler * Change sepChar from char to string in TimeField * Changing comparison from ':' to sepChar.ToCharArray () [0] * extract methods on ListView to make it controlable from other controls (#310) * moveup * MoveDown * MovePageDown * MovePageUp * MarkUnmarkRow * Allowing list items selection (#302) * Fetch from upstream/master * Fixes #342 and improves color change interaction. Usage: Colors.Base.Normal = new Terminal.Gui.Attribute (Color.Green, Color.Black); * Inserted new line at the end of file . Changed method name to SetAttribute in the ColorScheme class. * Prepare for 0.70 * Prepare for 0.70 * Prepare for 0.70 * Prepare for 0.70 * Prepare for 0.70 * Prepare for 0.70 * Prepare for 0.70 * Prepare for 0.70 * Timefield format with bounds values (#303) * Implemented lower and upper bounds to TimeField * Passing old text to the Changed event handler * Change sepChar from char to string in TimeField * Changing comparison from ':' to sepChar.ToCharArray () [0] * Prepare for 0.70 * Removed duplicated Attribute Disabled property * Fixed some bugs with the mouse event and text selection, copy, cut and paste. There is still a random failure in the mouse events that lock on button released and only trigger button clicked after moving the mouse. * Failure behavior solved. It was a threading safe issue. Driver.Wakeup () moved to the Post method on MainLoopSyncContext class solved it. * Changed the default for RightmostButtonPressed to Button4 and enabled clicked-drag * Added support for Button Triple Clicked too. FileDialog changed to deal with ButtonClicked. * Fixed a bug with the timer when dragging. * Fixes #343 - Added AllowsMultipleSelection to the ListView * Fixes #346 issue with enhancers characters, but it only could be apply after the pull requests at NStack are merged because of the Rune.ColumnWidth error. * Fixes code format. * Enabled Button Pressed with ReportMousePosition simultaneously. * Dragging is already working. TODO: optimize, only SetNeedsDisplay on the before/after regions. * Fixes the extra characters that remains in case the new text length is smaller than the older. * Fixes #349 TextField user typed input no longer fires Changed event. * Includes ControlKeyState for all the buttons events. * Added SetSourceAsync to ListView * Menu enhancement that works well, even if the top level has no other views. Working in further feature that if clicked outside of the menu it will closed. * Some more features in mouse and in core. * Added more mouse events flags, drag features, toplevel color and more... * Remove unnecessary SetNeedsDisplay. * Fixes a bug in the label * Added StatusBar from pr #201 with a little change. * Added features to TextField like mouse selection with copy, cut and paste shortcut keys. Now it's possible to use the combination of the Alt+Control+delta keys. It also be possible use special characters like €. * Simplifying the menu with better performance. * Private keyword dropped in all files and added some documentation. * Changed demo to reflect the added and changes features. * Added csproj and config files to verify if it won't trigger errors from Travis. * Demo with the StatusBar. * Patch for position of the StatusBar * Removed unnecessary nugget packages. * It looks like packages.config files are obsolete. Travis verification test. * Update Designer.csproj Use Stack 0.14 * Use NStack 0.14 * Use NStack 0.14 * Use NStack 0.14 * Use NStack 0.14 * Changed the NStack.Core and System.ValueTuple versions. * Added System.ValueTuple to Example project. * Remove System.ValueTuple and added NETStandard.Library to Example project. * Try to restore the nuget packages. * Revert "Try to restore the nuget packages." This reverts commit3957e022c3. * Added NETStandard.Library ti the root packages.config * Upgrade to "Microsoft.NETCore.Platforms" version=" 2.0.1" * Added <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> * Targeting framework 472. * Removed "System.ValueTuple" Version="4.5.0" from Terminal.Gui project. * More cleaning to the projects. * I guess you don't need this. Co-authored-by: Adrian Alonso <adrianalonso@gmail.com> Co-authored-by: Daniel Cazzulino <daniel@cazzulino.com> Co-authored-by: Marius Ungureanu <teromario@yahoo.com> Co-authored-by: miguel <miguel.de.icaza@gmail.com> Co-authored-by: Miguel de Icaza <miguel@gnome.org> Co-authored-by: imaras <imaras@net.hr> Co-authored-by: Kasper B. Graversen <kbilsted@users.noreply.github.com> Co-authored-by: Fabian R <kderazorback@me.com> Co-authored-by: Timothy <timothyparez@gmail.com>
522 lines
13 KiB
C#
522 lines
13 KiB
C#
using Terminal.Gui;
|
|
using System;
|
|
using Mono.Terminal;
|
|
using System.Collections.Generic;
|
|
using System.Diagnostics;
|
|
using System.Globalization;
|
|
using System.Reflection;
|
|
using NStack;
|
|
|
|
static class Demo {
|
|
//class Box10x : View, IScrollView {
|
|
class Box10x : View {
|
|
int w = 40;
|
|
int h = 50;
|
|
|
|
public bool WantCursorPosition { get; set; } = false;
|
|
|
|
public Box10x (int x, int y) : base (new Rect (x, y, 20, 10))
|
|
{
|
|
}
|
|
|
|
public Size GetContentSize ()
|
|
{
|
|
return new Size (w, h);
|
|
}
|
|
|
|
public void SetCursorPosition (Point pos)
|
|
{
|
|
throw new NotImplementedException ();
|
|
}
|
|
|
|
public override void Redraw (Rect region)
|
|
{
|
|
//Point pos = new Point (region.X, region.Y);
|
|
Driver.SetAttribute (ColorScheme.Focus);
|
|
|
|
for (int y = 0; y < h; y++) {
|
|
Move (0, y);
|
|
Driver.AddStr (y.ToString ());
|
|
for (int x = 0; x < w - y.ToString ().Length; x++) {
|
|
//Driver.AddRune ((Rune)('0' + (x + y) % 10));
|
|
if (y.ToString ().Length < w)
|
|
Driver.AddStr (" ");
|
|
}
|
|
}
|
|
//Move (pos.X, pos.Y);
|
|
}
|
|
}
|
|
|
|
class Filler : View {
|
|
public Filler (Rect rect) : base (rect)
|
|
{
|
|
}
|
|
|
|
public override void Redraw (Rect region)
|
|
{
|
|
Driver.SetAttribute (ColorScheme.Focus);
|
|
var f = Frame;
|
|
|
|
for (int y = 0; y < f.Width; y++) {
|
|
Move (0, y);
|
|
for (int x = 0; x < f.Height; x++) {
|
|
Rune r;
|
|
switch (x % 3) {
|
|
case 0:
|
|
Driver.AddRune (y.ToString ().ToCharArray (0, 1) [0]);
|
|
if (y > 9)
|
|
Driver.AddRune (y.ToString ().ToCharArray (1, 1) [0]);
|
|
r = '.';
|
|
break;
|
|
case 1:
|
|
r = 'o';
|
|
break;
|
|
default:
|
|
r = 'O';
|
|
break;
|
|
}
|
|
Driver.AddRune (r);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
static void ShowTextAlignments (View container)
|
|
{
|
|
int i = 0;
|
|
string txt = "Hello world, how are you doing today";
|
|
container.Add (
|
|
new FrameView (new Rect (75, 3, txt.Length + 6, 20), "Text Alignments") {
|
|
new Label(new Rect(0, 1, 40, 3), $"{i+1}-{txt}") { TextAlignment = TextAlignment.Left },
|
|
new Label(new Rect(0, 5, 40, 3), $"{i+2}-{txt}") { TextAlignment = TextAlignment.Right },
|
|
new Label(new Rect(0, 9, 40, 3), $"{i+3}-{txt}") { TextAlignment = TextAlignment.Centered },
|
|
new Label(new Rect(0, 13, 40, 3), $"{i+4}-{txt}") { TextAlignment = TextAlignment.Justified }
|
|
});
|
|
}
|
|
|
|
static void ShowEntries (View container)
|
|
{
|
|
var scrollView = new ScrollView (new Rect (50, 10, 20, 8)) {
|
|
ContentSize = new Size (20, 50),
|
|
//ContentOffset = new Point (0, 0),
|
|
ShowVerticalScrollIndicator = true,
|
|
ShowHorizontalScrollIndicator = true
|
|
};
|
|
#if false
|
|
scrollView.Add (new Box10x (0, 0));
|
|
#else
|
|
scrollView.Add (new Filler (new Rect (0, 0, 40, 40)));
|
|
#endif
|
|
|
|
// This is just to debug the visuals of the scrollview when small
|
|
var scrollView2 = new ScrollView (new Rect (72, 10, 3, 3)) {
|
|
ContentSize = new Size (100, 100),
|
|
ShowVerticalScrollIndicator = true,
|
|
ShowHorizontalScrollIndicator = true
|
|
};
|
|
scrollView2.Add (new Box10x (0, 0));
|
|
var progress = new ProgressBar (new Rect (68, 1, 10, 1));
|
|
bool timer (MainLoop caller)
|
|
{
|
|
progress.Pulse ();
|
|
return true;
|
|
}
|
|
|
|
Application.MainLoop.AddTimeout (TimeSpan.FromMilliseconds (300), timer);
|
|
|
|
|
|
// A little convoluted, this is because I am using this to test the
|
|
// layout based on referencing elements of another view:
|
|
|
|
var login = new Label ("Login: ") { X = 3, Y = 6 };
|
|
var password = new Label ("Password: ") {
|
|
X = Pos.Left (login),
|
|
Y = Pos.Bottom (login) + 1
|
|
};
|
|
var loginText = new TextField ("") {
|
|
X = Pos.Right (password),
|
|
Y = Pos.Top (login),
|
|
Width = 40
|
|
};
|
|
|
|
var passText = new TextField ("") {
|
|
Secret = true,
|
|
X = Pos.Left (loginText),
|
|
Y = Pos.Top (password),
|
|
Width = Dim.Width (loginText)
|
|
};
|
|
|
|
var tf = new Button (3, 19, "Ok");
|
|
// Add some content
|
|
container.Add (
|
|
login,
|
|
loginText,
|
|
password,
|
|
passText,
|
|
new FrameView (new Rect (3, 10, 25, 6), "Options"){
|
|
new CheckBox (1, 0, "Remember me"),
|
|
new RadioGroup (1, 2, new [] { "_Personal", "_Company" }),
|
|
},
|
|
new ListView (new Rect (59, 6, 16, 4), new string [] {
|
|
"First row",
|
|
"<>",
|
|
"This is a very long row that should overflow what is shown",
|
|
"4th",
|
|
"There is an empty slot on the second row",
|
|
"Whoa",
|
|
"This is so cool"
|
|
}),
|
|
scrollView,
|
|
scrollView2,
|
|
tf,
|
|
new Button (10, 19, "Cancel"),
|
|
new TimeField (3, 20, DateTime.Now),
|
|
new TimeField (23, 20, DateTime.Now, true),
|
|
new DateField (3, 22, DateTime.Now),
|
|
new DateField (23, 22, DateTime.Now, true),
|
|
progress,
|
|
new Label (3, 24, "Press F9 (on Unix, ESC+9 is an alias) to activate the menubar"),
|
|
menuKeysStyle,
|
|
menuAutoMouseNav
|
|
|
|
);
|
|
container.SendSubviewToBack (tf);
|
|
}
|
|
|
|
public static Label ml2;
|
|
|
|
static void NewFile ()
|
|
{
|
|
var d = new Dialog (
|
|
"New File", 50, 20,
|
|
new Button ("Ok", is_default: true) { Clicked = () => { Application.RequestStop (); } },
|
|
new Button ("Cancel") { Clicked = () => { Application.RequestStop (); } });
|
|
ml2 = new Label (1, 1, "Mouse Debug Line");
|
|
d.Add (ml2);
|
|
Application.Run (d);
|
|
}
|
|
|
|
//
|
|
// Creates a nested editor
|
|
static void Editor (Toplevel top)
|
|
{
|
|
var tframe = top.Frame;
|
|
var ntop = new Toplevel (tframe);
|
|
var menu = new MenuBar (new MenuBarItem [] {
|
|
new MenuBarItem ("_File", new MenuItem [] {
|
|
new MenuItem ("_Close", "", () => {Application.RequestStop ();}),
|
|
}),
|
|
new MenuBarItem ("_Edit", new MenuItem [] {
|
|
new MenuItem ("_Copy", "", null),
|
|
new MenuItem ("C_ut", "", null),
|
|
new MenuItem ("_Paste", "", null)
|
|
}),
|
|
});
|
|
ntop.Add (menu);
|
|
|
|
string fname = null;
|
|
foreach (var s in new [] { "/etc/passwd", "c:\\windows\\win.ini" })
|
|
if (System.IO.File.Exists (s)) {
|
|
fname = s;
|
|
break;
|
|
}
|
|
|
|
var win = new Window (fname ?? "Untitled") {
|
|
X = 0,
|
|
Y = 1,
|
|
Width = Dim.Fill (),
|
|
Height = Dim.Fill ()
|
|
};
|
|
ntop.Add (win);
|
|
|
|
var text = new TextView (new Rect (0, 0, tframe.Width - 2, tframe.Height - 3));
|
|
|
|
if (fname != null)
|
|
text.Text = System.IO.File.ReadAllText (fname);
|
|
win.Add (text);
|
|
|
|
Application.Run (ntop);
|
|
}
|
|
|
|
static bool Quit ()
|
|
{
|
|
var n = MessageBox.Query (50, 7, "Quit Demo", "Are you sure you want to quit this demo?", "Yes", "No");
|
|
return n == 0;
|
|
}
|
|
|
|
static void Close ()
|
|
{
|
|
MessageBox.ErrorQuery (50, 7, "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") { AllowsMultipleSelection = true };
|
|
Application.Run (d);
|
|
|
|
if (!d.Canceled)
|
|
MessageBox.Query (50, 7, "Selected File", string.Join (", ", d.FilePaths), "Ok");
|
|
}
|
|
|
|
public static void ShowHex (Toplevel top)
|
|
{
|
|
var tframe = top.Frame;
|
|
var ntop = new Toplevel (tframe);
|
|
var menu = new MenuBar (new MenuBarItem [] {
|
|
new MenuBarItem ("_File", new MenuItem [] {
|
|
new MenuItem ("_Close", "", () => {Application.RequestStop ();}),
|
|
}),
|
|
});
|
|
ntop.Add (menu);
|
|
|
|
var win = new Window ("/etc/passwd") {
|
|
X = 0,
|
|
Y = 1,
|
|
Width = Dim.Fill (),
|
|
Height = Dim.Fill ()
|
|
};
|
|
ntop.Add (win);
|
|
|
|
var source = System.IO.File.OpenRead ("/etc/passwd");
|
|
var hex = new HexView (source) {
|
|
X = 0,
|
|
Y = 0,
|
|
Width = Dim.Fill (),
|
|
Height = Dim.Fill ()
|
|
};
|
|
win.Add (hex);
|
|
Application.Run (ntop);
|
|
|
|
}
|
|
|
|
public class MenuItemDetails : MenuItem {
|
|
ustring title;
|
|
string help;
|
|
Action action;
|
|
|
|
public MenuItemDetails (ustring title, string help, Action action) : base (title, help, action)
|
|
{
|
|
this.title = title;
|
|
this.help = help;
|
|
this.action = action;
|
|
}
|
|
|
|
public static MenuItemDetails Instance (MenuItem mi)
|
|
{
|
|
return (MenuItemDetails)mi.GetMenuItem ();
|
|
}
|
|
}
|
|
|
|
public delegate MenuItem MenuItemDelegate (MenuItemDetails menuItem);
|
|
|
|
public static void ShowMenuItem (MenuItem mi)
|
|
{
|
|
BindingFlags flags = BindingFlags.Public | BindingFlags.Static;
|
|
MethodInfo minfo = typeof (MenuItemDetails).GetMethod ("Instance", flags);
|
|
MenuItemDelegate mid = (MenuItemDelegate)Delegate.CreateDelegate (typeof (MenuItemDelegate), minfo);
|
|
MessageBox.Query (70, 7, mi.Title.ToString (),
|
|
$"{mi.Title.ToString ()} selected. Is from submenu: {mi.GetMenuBarItem ()}", "Ok");
|
|
}
|
|
|
|
static void MenuKeysStyle_Toggled (object sender, EventArgs e)
|
|
{
|
|
menu.UseKeysUpDownAsKeysLeftRight = menuKeysStyle.Checked;
|
|
}
|
|
|
|
static void MenuAutoMouseNav_Toggled (object sender, EventArgs e)
|
|
{
|
|
menu.WantMousePositionReports = menuAutoMouseNav.Checked;
|
|
}
|
|
|
|
|
|
static void Copy ()
|
|
{
|
|
TextField textField = menu.LastFocused as TextField;
|
|
if (textField != null && textField.SelectedLength != 0) {
|
|
textField.Copy ();
|
|
}
|
|
}
|
|
|
|
static void Cut ()
|
|
{
|
|
TextField textField = menu.LastFocused as TextField;
|
|
if (textField != null && textField.SelectedLength != 0) {
|
|
textField.Cut ();
|
|
}
|
|
}
|
|
|
|
static void Paste ()
|
|
{
|
|
TextField textField = menu.LastFocused as TextField;
|
|
if (textField != null) {
|
|
textField.Paste ();
|
|
}
|
|
}
|
|
|
|
static void Help ()
|
|
{
|
|
MessageBox.Query (50, 7, "Help", "This is a small help\nBe kind.", "Ok");
|
|
}
|
|
|
|
#region Selection Demo
|
|
|
|
static void ListSelectionDemo ()
|
|
{
|
|
var d = new Dialog ("Selection Demo", 60, 20,
|
|
new Button ("Ok", is_default: true) { Clicked = () => { Application.RequestStop (); } },
|
|
new Button ("Cancel") { Clicked = () => { Application.RequestStop (); } });
|
|
|
|
var animals = new List<string> () { "Alpaca", "Llama", "Lion", "Shark", "Goat" };
|
|
var msg = new Label ("Use space bar or control-t to toggle selection") {
|
|
X = 1,
|
|
Y = 1,
|
|
Width = Dim.Fill () - 1,
|
|
Height = 1
|
|
};
|
|
|
|
var list = new ListView (animals) {
|
|
X = 1,
|
|
Y = 3,
|
|
Width = Dim.Fill () - 4,
|
|
Height = Dim.Fill () - 4,
|
|
AllowsMarking = true,
|
|
AllowsMultipleSelection = false
|
|
};
|
|
d.Add (msg, list);
|
|
Application.Run (d);
|
|
|
|
var result = "";
|
|
for (int i = 0; i < animals.Count; i++) {
|
|
if (list.Source.IsMarked (i)) {
|
|
result += animals [i] + " ";
|
|
}
|
|
}
|
|
MessageBox.Query (60, 10, "Selected Animals", result == "" ? "No animals selected" : result, "Ok");
|
|
}
|
|
#endregion
|
|
|
|
|
|
public static Label ml;
|
|
public static MenuBar menu;
|
|
public static CheckBox menuKeysStyle;
|
|
public static CheckBox menuAutoMouseNav;
|
|
static void Main ()
|
|
{
|
|
if (Debugger.IsAttached)
|
|
CultureInfo.DefaultThreadCurrentUICulture = CultureInfo.GetCultureInfo ("en-US");
|
|
|
|
//Application.UseSystemConsole = true;
|
|
Application.Init ();
|
|
|
|
var top = Application.Top;
|
|
|
|
//Open ();
|
|
#if true
|
|
var win = new Window ("Hello") {
|
|
X = 0,
|
|
Y = 0,
|
|
Width = Dim.Fill (),
|
|
Height = Dim.Fill ()
|
|
};
|
|
#else
|
|
var tframe = top.Frame;
|
|
|
|
var win = new Window (new Rect (0, 1, tframe.Width, tframe.Height - 1), "Hello");
|
|
#endif
|
|
MenuItemDetails [] menuItems = {
|
|
new MenuItemDetails ("F_ind", "", null),
|
|
new MenuItemDetails ("_Replace", "", null),
|
|
new MenuItemDetails ("_Item1", "", null),
|
|
new MenuItemDetails ("_Not From Sub Menu", "", null)
|
|
};
|
|
|
|
menuItems [0].Action = () => ShowMenuItem (menuItems [0]);
|
|
menuItems [1].Action = () => ShowMenuItem (menuItems [1]);
|
|
menuItems [2].Action = () => ShowMenuItem (menuItems [2]);
|
|
menuItems [3].Action = () => ShowMenuItem (menuItems [3]);
|
|
|
|
menu = new MenuBar (new MenuBarItem [] {
|
|
new MenuBarItem ("_File", new MenuItem [] {
|
|
new MenuItem ("Text Editor Demo", "", () => { Editor (top); }),
|
|
new MenuItem ("_New", "Creates new file", NewFile),
|
|
new MenuItem ("_Open", "", Open),
|
|
new MenuItem ("_Hex", "", () => ShowHex (top)),
|
|
new MenuItem ("_Close", "", () => Close ()),
|
|
new MenuItem ("_Disabled", "", () => { }, () => false),
|
|
null,
|
|
new MenuItem ("_Quit", "", () => { if (Quit ()) top.Running = false; })
|
|
}),
|
|
new MenuBarItem ("_Edit", new MenuItem [] {
|
|
new MenuItem ("_Copy", "", Copy),
|
|
new MenuItem ("C_ut", "", Cut),
|
|
new MenuItem ("_Paste", "", Paste),
|
|
new MenuItem ("_Find and Replace",
|
|
new MenuBarItem (new MenuItem[] {menuItems [0], menuItems [1] })),
|
|
menuItems[3]
|
|
}),
|
|
new MenuBarItem ("_List Demos", new MenuItem [] {
|
|
new MenuItem ("Select Items", "", ListSelectionDemo),
|
|
}),
|
|
new MenuBarItem ("Test Menu and SubMenus", new MenuItem [] {
|
|
new MenuItem ("SubMenu1Item1",
|
|
new MenuBarItem (new MenuItem[] {
|
|
new MenuItem ("SubMenu2Item1",
|
|
new MenuBarItem (new MenuItem [] {
|
|
new MenuItem ("SubMenu3Item1",
|
|
new MenuBarItem (new MenuItem [] { menuItems [2] })
|
|
)
|
|
})
|
|
)
|
|
})
|
|
)
|
|
}),
|
|
});
|
|
|
|
menuKeysStyle = new CheckBox (3, 25, "UseKeysUpDownAsKeysLeftRight", true);
|
|
menuKeysStyle.Toggled += MenuKeysStyle_Toggled;
|
|
menuAutoMouseNav = new CheckBox (40, 25, "UseMenuAutoNavigation", true);
|
|
menuAutoMouseNav.Toggled += MenuAutoMouseNav_Toggled;
|
|
|
|
ShowEntries (win);
|
|
|
|
int count = 0;
|
|
ml = new Label (new Rect (3, 18, 47, 1), "Mouse: ");
|
|
Application.RootMouseEvent += delegate (MouseEvent me) {
|
|
ml.TextColor = Colors.TopLevel.Normal;
|
|
ml.Text = $"Mouse: ({me.X},{me.Y}) - {me.Flags} {count++}";
|
|
};
|
|
|
|
var test = new Label (3, 18, "Se iniciará el análisis");
|
|
win.Add (test);
|
|
win.Add (ml);
|
|
|
|
ShowTextAlignments (win);
|
|
|
|
var drag = new Label ("Drag: ") { X = 70, Y = 24 };
|
|
var dragText = new TextField ("") {
|
|
X = Pos.Right (drag),
|
|
Y = Pos.Top (drag),
|
|
Width = 40
|
|
};
|
|
|
|
var statusBar = new StatusBar (new StatusItem [] {
|
|
new StatusItem(Key.F1, "~F1~ Help", () => Help()),
|
|
new StatusItem(Key.F2, "~F2~ Load", null),
|
|
new StatusItem(Key.F3, "~F3~ Save", null),
|
|
new StatusItem(Key.ControlX, "~^X~ Quit", () => Quit()),
|
|
});
|
|
|
|
win.Add (drag, dragText);
|
|
|
|
top.Add (win);
|
|
//top.Add (menu);
|
|
top.Add (menu, statusBar, ml);
|
|
Application.Run ();
|
|
}
|
|
}
|