From 2ed71e284c37fde8c78fdb267e3fb59ee183fd46 Mon Sep 17 00:00:00 2001 From: tznind Date: Wed, 15 Mar 2023 19:35:21 +0000 Subject: [PATCH] Move all nested eventargs out of parent classes to root --- .../Configuration/ConfigurationManager.cs | 13 --- .../ConfigurationManagerEventArgs.cs | 18 ++++ .../Configuration/ThemeManagerEventArgs.cs | 24 +++++ Terminal.Gui/Configuration/ThemeScope.cs | 20 +--- Terminal.Gui/Core/Application.cs | 16 +--- Terminal.Gui/Core/CollectionNavigator.cs | 21 +--- Terminal.Gui/Core/FocusEventArgs.cs | 25 +++++ Terminal.Gui/Core/KeyEventEventArgs.cs | 25 +++++ .../Core/KeystrokeNavigatorEventArgs.cs | 22 +++++ Terminal.Gui/Core/ResizedEventArgs.cs | 32 +++++++ Terminal.Gui/Core/TitleEventArgs.cs | 46 +++++++++ Terminal.Gui/Core/Toplevel.cs | 22 ----- Terminal.Gui/Core/ToplevelClosingEventArgs.cs | 26 +++++ Terminal.Gui/Core/View.cs | 42 +------- Terminal.Gui/Core/Window.cs | 33 +------ Terminal.Gui/Views/CellActivatedEventArgs.cs | 43 +++++++++ .../Views/ContentsChangedEventArgs.cs | 32 +++++++ Terminal.Gui/Views/DateField.cs | 33 ------- Terminal.Gui/Views/DateTimeEventArgs.cs | 43 +++++++++ Terminal.Gui/Views/HexView.cs | 60 +----------- Terminal.Gui/Views/HexViewEditEventArgs.cs | 37 ++++++++ Terminal.Gui/Views/HexViewEventArgs.cs | 43 +++++++++ Terminal.Gui/Views/HistoryTextItem.cs | 36 +++++++ Terminal.Gui/Views/ListView.cs | 49 ---------- Terminal.Gui/Views/ListViewItemEventArgs.cs | 28 ++++++ Terminal.Gui/Views/ListViewRowEventArgs.cs | 27 ++++++ Terminal.Gui/Views/Menu.cs | 68 ------------- Terminal.Gui/Views/MenuClosingEventArgs.cs | 42 ++++++++ Terminal.Gui/Views/MenuOpeningEventArgs.cs | 32 +++++++ Terminal.Gui/Views/RadioGroup.cs | 26 ----- .../Views/SelectedCellChangedEventArgs.cs | 63 ++++++++++++ Terminal.Gui/Views/SelectedItemChangedArgs.cs | 29 ++++++ Terminal.Gui/Views/SplitterEventArgs.cs | 38 ++++++++ Terminal.Gui/Views/TabChangedEventArgs.cs | 31 ++++++ Terminal.Gui/Views/TabMouseEventArgs.cs | 36 +++++++ Terminal.Gui/Views/TabView.cs | 60 +----------- Terminal.Gui/Views/TableView.cs | 95 +------------------ Terminal.Gui/Views/TextChangedEventArgs.cs | 31 ++++++ Terminal.Gui/Views/TextChangingEventArgs.cs | 34 +++++++ Terminal.Gui/Views/TextField.cs | 42 -------- Terminal.Gui/Views/TextView.cs | 59 +----------- Terminal.Gui/Views/TileView.cs | 70 +------------- Terminal.Gui/Views/TitleEventArgs.cs | 42 ++++++++ Terminal.Gui/Windows/StepChangeEventArgs.cs | 38 ++++++++ Terminal.Gui/Windows/Wizard.cs | 52 +--------- Terminal.Gui/Windows/WizardButtonEventArgs.cs | 24 +++++ UICatalog/Scenarios/CsvEditor.cs | 6 +- UICatalog/Scenarios/HexEditor.cs | 4 +- UICatalog/Scenarios/InteractiveTree.cs | 2 +- UICatalog/Scenarios/MultiColouredTable.cs | 2 +- UICatalog/Scenarios/Notepad.cs | 4 +- UICatalog/Scenarios/TableEditor.cs | 4 +- UICatalog/Scenarios/TreeViewFileSystem.cs | 2 +- UICatalog/Scenarios/VkeyPacketSimulator.cs | 4 +- UICatalog/UICatalog.cs | 2 +- UnitTests/Application/ApplicationTests.cs | 2 +- .../Configuration/ConfigurationMangerTests.cs | 4 +- UnitTests/Core/ViewTests.cs | 6 +- UnitTests/UICatalog/ScenarioTests.cs | 2 +- UnitTests/Views/HexViewTests.cs | 2 +- 60 files changed, 983 insertions(+), 791 deletions(-) create mode 100644 Terminal.Gui/Configuration/ConfigurationManagerEventArgs.cs create mode 100644 Terminal.Gui/Configuration/ThemeManagerEventArgs.cs create mode 100644 Terminal.Gui/Core/FocusEventArgs.cs create mode 100644 Terminal.Gui/Core/KeyEventEventArgs.cs create mode 100644 Terminal.Gui/Core/KeystrokeNavigatorEventArgs.cs create mode 100644 Terminal.Gui/Core/ResizedEventArgs.cs create mode 100644 Terminal.Gui/Core/TitleEventArgs.cs create mode 100644 Terminal.Gui/Core/ToplevelClosingEventArgs.cs create mode 100644 Terminal.Gui/Views/CellActivatedEventArgs.cs create mode 100644 Terminal.Gui/Views/ContentsChangedEventArgs.cs create mode 100644 Terminal.Gui/Views/DateTimeEventArgs.cs create mode 100644 Terminal.Gui/Views/HexViewEditEventArgs.cs create mode 100644 Terminal.Gui/Views/HexViewEventArgs.cs create mode 100644 Terminal.Gui/Views/HistoryTextItem.cs create mode 100644 Terminal.Gui/Views/ListViewItemEventArgs.cs create mode 100644 Terminal.Gui/Views/ListViewRowEventArgs.cs create mode 100644 Terminal.Gui/Views/MenuClosingEventArgs.cs create mode 100644 Terminal.Gui/Views/MenuOpeningEventArgs.cs create mode 100644 Terminal.Gui/Views/SelectedCellChangedEventArgs.cs create mode 100644 Terminal.Gui/Views/SelectedItemChangedArgs.cs create mode 100644 Terminal.Gui/Views/SplitterEventArgs.cs create mode 100644 Terminal.Gui/Views/TabChangedEventArgs.cs create mode 100644 Terminal.Gui/Views/TabMouseEventArgs.cs create mode 100644 Terminal.Gui/Views/TextChangedEventArgs.cs create mode 100644 Terminal.Gui/Views/TextChangingEventArgs.cs create mode 100644 Terminal.Gui/Views/TitleEventArgs.cs create mode 100644 Terminal.Gui/Windows/StepChangeEventArgs.cs create mode 100644 Terminal.Gui/Windows/WizardButtonEventArgs.cs diff --git a/Terminal.Gui/Configuration/ConfigurationManager.cs b/Terminal.Gui/Configuration/ConfigurationManager.cs index 8222195a4..6048294dd 100644 --- a/Terminal.Gui/Configuration/ConfigurationManager.cs +++ b/Terminal.Gui/Configuration/ConfigurationManager.cs @@ -301,19 +301,6 @@ namespace Terminal.Gui.Configuration { return stream; } - /// - /// Event arguments for the events. - /// - public class ConfigurationManagerEventArgs : EventArgs { - - /// - /// Initializes a new instance of - /// - public ConfigurationManagerEventArgs () - { - } - } - /// /// Gets or sets whether the should throw an exception if it encounters /// an error on deserialization. If (the default), the error is logged and printed to the diff --git a/Terminal.Gui/Configuration/ConfigurationManagerEventArgs.cs b/Terminal.Gui/Configuration/ConfigurationManagerEventArgs.cs new file mode 100644 index 000000000..c29405f01 --- /dev/null +++ b/Terminal.Gui/Configuration/ConfigurationManagerEventArgs.cs @@ -0,0 +1,18 @@ +using System; + +#nullable enable + +namespace Terminal.Gui.Configuration { + /// + /// Event arguments for the events. + /// + public class ConfigurationManagerEventArgs : EventArgs { + + /// + /// Initializes a new instance of + /// + public ConfigurationManagerEventArgs () + { + } + } +} diff --git a/Terminal.Gui/Configuration/ThemeManagerEventArgs.cs b/Terminal.Gui/Configuration/ThemeManagerEventArgs.cs new file mode 100644 index 000000000..fd4d9ca56 --- /dev/null +++ b/Terminal.Gui/Configuration/ThemeManagerEventArgs.cs @@ -0,0 +1,24 @@ +using System; + +#nullable enable + +namespace Terminal.Gui.Configuration { + + /// + /// Event arguments for the events. + /// + public class ThemeManagerEventArgs : EventArgs { + /// + /// The name of the new active theme.. + /// + public string NewTheme { get; set; } = string.Empty; + + /// + /// Initializes a new instance of + /// + public ThemeManagerEventArgs (string newTheme) + { + NewTheme = newTheme; + } + } +} \ No newline at end of file diff --git a/Terminal.Gui/Configuration/ThemeScope.cs b/Terminal.Gui/Configuration/ThemeScope.cs index 35b568b32..6b5ee2eb0 100644 --- a/Terminal.Gui/Configuration/ThemeScope.cs +++ b/Terminal.Gui/Configuration/ThemeScope.cs @@ -110,7 +110,7 @@ namespace Terminal.Gui.Configuration { /// } /// } /// - public class ThemeManager : IDictionary { + public partial class ThemeManager : IDictionary { private static readonly ThemeManager _instance = new ThemeManager (); static ThemeManager () { } // Make sure it's truly lazy private ThemeManager () { } // Prevent instantiation outside @@ -152,24 +152,6 @@ namespace Terminal.Gui.Configuration { } } - /// - /// Event arguments for the events. - /// - public class ThemeManagerEventArgs : EventArgs { - /// - /// The name of the new active theme.. - /// - public string NewTheme { get; set; } = string.Empty; - - /// - /// Initializes a new instance of - /// - public ThemeManagerEventArgs (string newTheme) - { - NewTheme = newTheme; - } - } - /// /// Called when the selected theme has changed. Fires the event. /// diff --git a/Terminal.Gui/Core/Application.cs b/Terminal.Gui/Core/Application.cs index f38e31b21..561d6a8c4 100644 --- a/Terminal.Gui/Core/Application.cs +++ b/Terminal.Gui/Core/Application.cs @@ -59,7 +59,7 @@ namespace Terminal.Gui { /// to the mainloop, allowing user code to use async/await. /// /// - public static class Application { + public static partial class Application { static readonly Stack toplevels = new Stack (); /// @@ -1501,20 +1501,6 @@ namespace Terminal.Gui { } } - /// - /// Event arguments for the event. - /// - public class ResizedEventArgs : EventArgs { - /// - /// The number of rows in the resized terminal. - /// - public int Rows { get; set; } - /// - /// The number of columns in the resized terminal. - /// - public int Cols { get; set; } - } - /// /// Invoked when the terminal was resized. The new size of the terminal is provided. /// diff --git a/Terminal.Gui/Core/CollectionNavigator.cs b/Terminal.Gui/Core/CollectionNavigator.cs index 054fce106..e0dc7d44e 100644 --- a/Terminal.Gui/Core/CollectionNavigator.cs +++ b/Terminal.Gui/Core/CollectionNavigator.cs @@ -15,7 +15,7 @@ namespace Terminal.Gui { /// If the user pauses keystrokes for a short time (see ), the search string is cleared. /// /// - public class CollectionNavigator { + public partial class CollectionNavigator { /// /// Constructs a new CollectionNavigator. /// @@ -44,25 +44,6 @@ namespace Terminal.Gui { /// public IEnumerable Collection { get; set; } - /// - /// Event arguments for the event. - /// - public class KeystrokeNavigatorEventArgs : EventArgs{ - /// - /// he current . - /// - public string SearchString { get; } - - /// - /// Initializes a new instance of - /// - /// The current . - public KeystrokeNavigatorEventArgs (string searchString) - { - SearchString = searchString; - } - } - /// /// This event is invoked when changes. Useful for debugging. /// diff --git a/Terminal.Gui/Core/FocusEventArgs.cs b/Terminal.Gui/Core/FocusEventArgs.cs new file mode 100644 index 000000000..e019d5a0a --- /dev/null +++ b/Terminal.Gui/Core/FocusEventArgs.cs @@ -0,0 +1,25 @@ +using System; + +namespace Terminal.Gui { + + /// + /// Defines the event arguments for + /// + public class FocusEventArgs : EventArgs { + /// + /// Constructs. + /// + /// The view that gets or loses focus. + public FocusEventArgs (View view) { View = view; } + /// + /// Indicates if the current focus event has already been processed and the driver should stop notifying any other event subscriber. + /// Its important to set this value to true specially when updating any View's layout from inside the subscriber method. + /// + public bool Handled { get; set; } + /// + /// Indicates the current view that gets or loses focus. + /// + public View View { get; set; } + } + +} diff --git a/Terminal.Gui/Core/KeyEventEventArgs.cs b/Terminal.Gui/Core/KeyEventEventArgs.cs new file mode 100644 index 000000000..7e54483a8 --- /dev/null +++ b/Terminal.Gui/Core/KeyEventEventArgs.cs @@ -0,0 +1,25 @@ +using System; + +namespace Terminal.Gui { + + /// + /// Defines the event arguments for + /// + public class KeyEventEventArgs : EventArgs { + /// + /// Constructs. + /// + /// + public KeyEventEventArgs (KeyEvent ke) => KeyEvent = ke; + /// + /// The for the event. + /// + public KeyEvent KeyEvent { get; set; } + /// + /// Indicates if the current Key event has already been processed and the driver should stop notifying any other event subscriber. + /// Its important to set this value to true specially when updating any View's layout from inside the subscriber method. + /// + public bool Handled { get; set; } = false; + } + +} diff --git a/Terminal.Gui/Core/KeystrokeNavigatorEventArgs.cs b/Terminal.Gui/Core/KeystrokeNavigatorEventArgs.cs new file mode 100644 index 000000000..454f5a1e2 --- /dev/null +++ b/Terminal.Gui/Core/KeystrokeNavigatorEventArgs.cs @@ -0,0 +1,22 @@ +using System; + +namespace Terminal.Gui { + /// + /// Event arguments for the event. + /// + public class KeystrokeNavigatorEventArgs : EventArgs { + /// + /// he current . + /// + public string SearchString { get; } + + /// + /// Initializes a new instance of + /// + /// The current . + public KeystrokeNavigatorEventArgs (string searchString) + { + SearchString = searchString; + } + } +} diff --git a/Terminal.Gui/Core/ResizedEventArgs.cs b/Terminal.Gui/Core/ResizedEventArgs.cs new file mode 100644 index 000000000..a4cc81a0b --- /dev/null +++ b/Terminal.Gui/Core/ResizedEventArgs.cs @@ -0,0 +1,32 @@ +// +// Core.cs: The core engine for gui.cs +// +// Authors: +// Miguel de Icaza (miguel@gnome.org) +// +// Pending: +// - Check for NeedDisplay on the hierarchy and repaint +// - Layout support +// - "Colors" type or "Attributes" type? +// - What to surface as "BackgroundCOlor" when clearing a window, an attribute or colors? +// +// Optimizations +// - Add rendering limitation to the exposed area +using System; + +namespace Terminal.Gui { + + /// + /// Event arguments for the event. + /// + public class ResizedEventArgs : EventArgs { + /// + /// The number of rows in the resized terminal. + /// + public int Rows { get; set; } + /// + /// The number of columns in the resized terminal. + /// + public int Cols { get; set; } + } +} diff --git a/Terminal.Gui/Core/TitleEventArgs.cs b/Terminal.Gui/Core/TitleEventArgs.cs new file mode 100644 index 000000000..c20e9c56c --- /dev/null +++ b/Terminal.Gui/Core/TitleEventArgs.cs @@ -0,0 +1,46 @@ +// +// Authors: +// Miguel de Icaza (miguel@gnome.org) +// +// NOTE: Window is functionally identical to FrameView with the following exceptions. +// - Window is a Toplevel +// - FrameView Does not support padding (but should) +// - FrameView Does not support mouse dragging +// - FrameView Does not support IEnumerable +// Any updates done here should probably be done in FrameView as well; TODO: Merge these classes + +using System; +using NStack; + +namespace Terminal.Gui { + /// + /// Event arguments for Title change events. + /// + public class TitleEventArgs : EventArgs { + /// + /// The new Window Title. + /// + public ustring NewTitle { get; set; } + + /// + /// The old Window Title. + /// + public ustring OldTitle { get; set; } + + /// + /// Flag which allows canceling the Title change. + /// + public bool Cancel { get; set; } + + /// + /// Initializes a new instance of + /// + /// The that is/has been replaced. + /// The new to be replaced. + public TitleEventArgs (ustring oldTitle, ustring newTitle) + { + OldTitle = oldTitle; + NewTitle = newTitle; + } + } +} diff --git a/Terminal.Gui/Core/Toplevel.cs b/Terminal.Gui/Core/Toplevel.cs index ca53bb8ac..02727aa39 100644 --- a/Terminal.Gui/Core/Toplevel.cs +++ b/Terminal.Gui/Core/Toplevel.cs @@ -1050,26 +1050,4 @@ namespace Terminal.Gui { return string.Compare (x.Id.ToString (), y.Id.ToString ()); } } - /// - /// implementation for the event. - /// - public class ToplevelClosingEventArgs : EventArgs { - /// - /// The toplevel requesting stop. - /// - public View RequestingTop { get; } - /// - /// Provides an event cancellation option. - /// - public bool Cancel { get; set; } - - /// - /// Initializes the event arguments with the requesting toplevel. - /// - /// The . - public ToplevelClosingEventArgs (Toplevel requestingTop) - { - RequestingTop = requestingTop; - } - } } diff --git a/Terminal.Gui/Core/ToplevelClosingEventArgs.cs b/Terminal.Gui/Core/ToplevelClosingEventArgs.cs new file mode 100644 index 000000000..b4b1b0de8 --- /dev/null +++ b/Terminal.Gui/Core/ToplevelClosingEventArgs.cs @@ -0,0 +1,26 @@ +using System; + +namespace Terminal.Gui { + /// + /// implementation for the event. + /// + public class ToplevelClosingEventArgs : EventArgs { + /// + /// The toplevel requesting stop. + /// + public View RequestingTop { get; } + /// + /// Provides an event cancellation option. + /// + public bool Cancel { get; set; } + + /// + /// Initializes the event arguments with the requesting toplevel. + /// + /// The . + public ToplevelClosingEventArgs (Toplevel requestingTop) + { + RequestingTop = requestingTop; + } + } +} diff --git a/Terminal.Gui/Core/View.cs b/Terminal.Gui/Core/View.cs index 95dde58a5..1c1372b47 100644 --- a/Terminal.Gui/Core/View.cs +++ b/Terminal.Gui/Core/View.cs @@ -101,7 +101,7 @@ namespace Terminal.Gui { /// frames for the vies that use . /// /// - public class View : Responder, ISupportInitializeNotification { + public partial class View : Responder, ISupportInitializeNotification { internal enum Direction { Forward, @@ -1331,26 +1331,6 @@ namespace Terminal.Gui { } } - /// - /// Defines the event arguments for - /// - public class FocusEventArgs : EventArgs { - /// - /// Constructs. - /// - /// The view that gets or loses focus. - public FocusEventArgs (View view) { View = view; } - /// - /// Indicates if the current focus event has already been processed and the driver should stop notifying any other event subscriber. - /// Its important to set this value to true specially when updating any View's layout from inside the subscriber method. - /// - public bool Handled { get; set; } - /// - /// Indicates the current view that gets or loses focus. - /// - public View View { get; set; } - } - /// /// Method invoked when a subview is being added to this view. /// @@ -1690,26 +1670,6 @@ namespace Terminal.Gui { SuperView?.SetFocus (this); } - /// - /// Defines the event arguments for - /// - public class KeyEventEventArgs : EventArgs { - /// - /// Constructs. - /// - /// - public KeyEventEventArgs (KeyEvent ke) => KeyEvent = ke; - /// - /// The for the event. - /// - public KeyEvent KeyEvent { get; set; } - /// - /// Indicates if the current Key event has already been processed and the driver should stop notifying any other event subscriber. - /// Its important to set this value to true specially when updating any View's layout from inside the subscriber method. - /// - public bool Handled { get; set; } = false; - } - /// /// Invoked when a character key is pressed and occurs after the key up event. /// diff --git a/Terminal.Gui/Core/Window.cs b/Terminal.Gui/Core/Window.cs index cbf958a89..b89845d5c 100644 --- a/Terminal.Gui/Core/Window.cs +++ b/Terminal.Gui/Core/Window.cs @@ -24,7 +24,7 @@ namespace Terminal.Gui { /// The 'client area' of a is a rectangle deflated by one or more rows/columns from . A this time there is no /// API to determine this rectangle. /// - public class Window : Toplevel { + public partial class Window : Toplevel { View contentView; ustring title = ustring.Empty; @@ -343,37 +343,6 @@ namespace Terminal.Gui { base.TextAlignment = contentView.TextAlignment = value; } } - - /// - /// Event arguments for change events. - /// - public class TitleEventArgs : EventArgs { - /// - /// The new Window Title. - /// - public ustring NewTitle { get; set; } - - /// - /// The old Window Title. - /// - public ustring OldTitle { get; set; } - - /// - /// Flag which allows canceling the Title change. - /// - public bool Cancel { get; set; } - - /// - /// Initializes a new instance of - /// - /// The that is/has been replaced. - /// The new to be replaced. - public TitleEventArgs (ustring oldTitle, ustring newTitle) - { - OldTitle = oldTitle; - NewTitle = newTitle; - } - } /// /// Called before the changes. Invokes the event, which can be cancelled. /// diff --git a/Terminal.Gui/Views/CellActivatedEventArgs.cs b/Terminal.Gui/Views/CellActivatedEventArgs.cs new file mode 100644 index 000000000..2cb558776 --- /dev/null +++ b/Terminal.Gui/Views/CellActivatedEventArgs.cs @@ -0,0 +1,43 @@ +using System; +using System.Data; + +namespace Terminal.Gui { + + + /// + /// Defines the event arguments for event + /// + public class CellActivatedEventArgs : EventArgs { + /// + /// The current table to which the new indexes refer. May be null e.g. if selection change is the result of clearing the table from the view + /// + /// + public DataTable Table { get; } + + + /// + /// The column index of the cell that is being activated + /// + /// + public int Col { get; } + + /// + /// The row index of the cell that is being activated + /// + /// + public int Row { get; } + + /// + /// Creates a new instance of arguments describing a cell being activated in + /// + /// + /// + /// + public CellActivatedEventArgs (DataTable t, int col, int row) + { + Table = t; + Col = col; + Row = row; + } + } +} diff --git a/Terminal.Gui/Views/ContentsChangedEventArgs.cs b/Terminal.Gui/Views/ContentsChangedEventArgs.cs new file mode 100644 index 000000000..38c27538e --- /dev/null +++ b/Terminal.Gui/Views/ContentsChangedEventArgs.cs @@ -0,0 +1,32 @@ +// TextView.cs: multi-line text editing +using System; + +namespace Terminal.Gui { + + /// + /// Event arguments for events for when the contents of the TextView change. E.g. the event. + /// + public class ContentsChangedEventArgs : EventArgs { + /// + /// Creates a new instance. + /// + /// Contains the row where the change occurred. + /// Contains the column where the change occured. + public ContentsChangedEventArgs (int currentRow, int currentColumn) + { + Row = currentRow; + Col = currentColumn; + } + + /// + /// + /// Contains the row where the change occurred. + /// + public int Row { get; private set; } + + /// + /// Contains the column where the change occurred. + /// + public int Col { get; private set; } + } +} diff --git a/Terminal.Gui/Views/DateField.cs b/Terminal.Gui/Views/DateField.cs index 98c1ae095..8f0c1f5f2 100644 --- a/Terminal.Gui/Views/DateField.cs +++ b/Terminal.Gui/Views/DateField.cs @@ -421,37 +421,4 @@ namespace Terminal.Gui { DateChanged?.Invoke (this,args); } } - - /// - /// Defines the event arguments for and events. - /// - public class DateTimeEventArgs : EventArgs { - /// - /// The old or value. - /// - public T OldValue { get; } - - /// - /// The new or value. - /// - public T NewValue { get; } - - /// - /// The or format. - /// - public string Format { get; } - - /// - /// Initializes a new instance of - /// - /// The old or value. - /// The new or value. - /// The or format string. - public DateTimeEventArgs (T oldValue, T newValue, string format) - { - OldValue = oldValue; - NewValue = newValue; - Format = format; - } - } } \ No newline at end of file diff --git a/Terminal.Gui/Views/DateTimeEventArgs.cs b/Terminal.Gui/Views/DateTimeEventArgs.cs new file mode 100644 index 000000000..2c69bb997 --- /dev/null +++ b/Terminal.Gui/Views/DateTimeEventArgs.cs @@ -0,0 +1,43 @@ +// +// DateField.cs: text entry for date +// +// Author: Barry Nolte +// +// Licensed under the MIT license +// +using System; + +namespace Terminal.Gui { + /// + /// Defines the event arguments for and events. + /// + public class DateTimeEventArgs : EventArgs { + /// + /// The old or value. + /// + public T OldValue { get; } + + /// + /// The new or value. + /// + public T NewValue { get; } + + /// + /// The or format. + /// + public string Format { get; } + + /// + /// Initializes a new instance of + /// + /// The old or value. + /// The new or value. + /// The or format string. + public DateTimeEventArgs (T oldValue, T newValue, string format) + { + OldValue = oldValue; + NewValue = newValue; + Format = format; + } + } +} \ No newline at end of file diff --git a/Terminal.Gui/Views/HexView.cs b/Terminal.Gui/Views/HexView.cs index 910e9e105..3d9850f62 100644 --- a/Terminal.Gui/Views/HexView.cs +++ b/Terminal.Gui/Views/HexView.cs @@ -34,7 +34,7 @@ namespace Terminal.Gui { /// to an offset in the stream. /// /// - public class HexView : View { + public partial class HexView : View { SortedDictionary edits = new SortedDictionary (); Stream source; long displayStart, pos; @@ -631,63 +631,5 @@ namespace Terminal.Gui { return base.OnEnter (view); } - - /// - /// Defines the event arguments for event. - /// - public class HexViewEditEventArgs : EventArgs { - - /// - /// Creates a new instance of the class. - /// - /// - /// - public HexViewEditEventArgs (long position, byte newValue) - { - Position = position; - NewValue = newValue; - } - - /// - /// Gets the location of the edit. - /// - public long Position { get; } - - /// - /// Gets the new value for that . - /// - public byte NewValue { get; } - } - /// - /// Defines the event arguments for event. - /// - public class HexViewEventArgs : EventArgs { - /// - /// Gets the current character position starting at one, related to the . - /// - public long Position { get; private set; } - /// - /// Gets the current cursor position starting at one for both, line and column. - /// - public Point CursorPosition { get; private set; } - - /// - /// The bytes length per line. - /// - public int BytesPerLine { get; private set; } - - /// - /// Initializes a new instance of - /// - /// The character position. - /// The cursor position. - /// Line bytes length. - public HexViewEventArgs (long pos, Point cursor, int lineLength) - { - Position = pos; - CursorPosition = cursor; - BytesPerLine = lineLength; - } - } } } diff --git a/Terminal.Gui/Views/HexViewEditEventArgs.cs b/Terminal.Gui/Views/HexViewEditEventArgs.cs new file mode 100644 index 000000000..76185b6c4 --- /dev/null +++ b/Terminal.Gui/Views/HexViewEditEventArgs.cs @@ -0,0 +1,37 @@ +// +// HexView.cs: A hexadecimal viewer +// +// TODO: +// - Support searching and highlighting of the search result +// - Bug showing the last line +// +using System; + +namespace Terminal.Gui { + /// + /// Defines the event arguments for event. + /// + public class HexViewEditEventArgs : EventArgs { + + /// + /// Creates a new instance of the class. + /// + /// + /// + public HexViewEditEventArgs (long position, byte newValue) + { + Position = position; + NewValue = newValue; + } + + /// + /// Gets the location of the edit. + /// + public long Position { get; } + + /// + /// Gets the new value for that . + /// + public byte NewValue { get; } + } +} diff --git a/Terminal.Gui/Views/HexViewEventArgs.cs b/Terminal.Gui/Views/HexViewEventArgs.cs new file mode 100644 index 000000000..7847f68d0 --- /dev/null +++ b/Terminal.Gui/Views/HexViewEventArgs.cs @@ -0,0 +1,43 @@ +// +// HexView.cs: A hexadecimal viewer +// +// TODO: +// - Support searching and highlighting of the search result +// - Bug showing the last line +// +using System; +using System.IO; + +namespace Terminal.Gui { + /// + /// Defines the event arguments for event. + /// + public class HexViewEventArgs : EventArgs { + /// + /// Gets the current character position starting at one, related to the . + /// + public long Position { get; private set; } + /// + /// Gets the current cursor position starting at one for both, line and column. + /// + public Point CursorPosition { get; private set; } + + /// + /// The bytes length per line. + /// + public int BytesPerLine { get; private set; } + + /// + /// Initializes a new instance of + /// + /// The character position. + /// The cursor position. + /// Line bytes length. + public HexViewEventArgs (long pos, Point cursor, int lineLength) + { + Position = pos; + CursorPosition = cursor; + BytesPerLine = lineLength; + } + } +} diff --git a/Terminal.Gui/Views/HistoryTextItem.cs b/Terminal.Gui/Views/HistoryTextItem.cs new file mode 100644 index 000000000..7b1dfe80e --- /dev/null +++ b/Terminal.Gui/Views/HistoryTextItem.cs @@ -0,0 +1,36 @@ +// TextView.cs: multi-line text editing +using System; +using System.Collections.Generic; +using Rune = System.Rune; + +namespace Terminal.Gui { + partial class HistoryText { + public class HistoryTextItem : EventArgs{ + public List> Lines; + public Point CursorPosition; + public LineStatus LineStatus; + public bool IsUndoing; + public Point FinalCursorPosition; + public HistoryTextItem RemovedOnAdded; + + public HistoryTextItem (List> lines, Point curPos, LineStatus linesStatus) + { + Lines = lines; + CursorPosition = curPos; + LineStatus = linesStatus; + } + + public HistoryTextItem (HistoryTextItem historyTextItem) + { + Lines = new List> (historyTextItem.Lines); + CursorPosition = new Point (historyTextItem.CursorPosition.X, historyTextItem.CursorPosition.Y); + LineStatus = historyTextItem.LineStatus; + } + + public override string ToString () + { + return $"(Count: {Lines.Count}, Cursor: {CursorPosition}, Status: {LineStatus})"; + } + } + } +} diff --git a/Terminal.Gui/Views/ListView.cs b/Terminal.Gui/Views/ListView.cs index 506cf7019..ce62a2cf0 100644 --- a/Terminal.Gui/Views/ListView.cs +++ b/Terminal.Gui/Views/ListView.cs @@ -938,53 +938,4 @@ namespace Terminal.Gui { return -1; } } - - /// - /// for events. - /// - public class ListViewItemEventArgs : EventArgs { - /// - /// The index of the item. - /// - public int Item { get; } - /// - /// The item. - /// - public object Value { get; } - - /// - /// Initializes a new instance of - /// - /// The index of the item. - /// The item - public ListViewItemEventArgs (int item, object value) - { - Item = item; - Value = value; - } - } - - /// - /// used by the event. - /// - public class ListViewRowEventArgs : EventArgs { - /// - /// The current row being rendered. - /// - public int Row { get; } - /// - /// The used by current row or - /// null to maintain the current attribute. - /// - public Attribute? RowAttribute { get; set; } - - /// - /// Initializes with the current row. - /// - /// - public ListViewRowEventArgs (int row) - { - Row = row; - } - } } diff --git a/Terminal.Gui/Views/ListViewItemEventArgs.cs b/Terminal.Gui/Views/ListViewItemEventArgs.cs new file mode 100644 index 000000000..a23efac01 --- /dev/null +++ b/Terminal.Gui/Views/ListViewItemEventArgs.cs @@ -0,0 +1,28 @@ +using System; + +namespace Terminal.Gui { + /// + /// for events. + /// + public class ListViewItemEventArgs : EventArgs { + /// + /// The index of the item. + /// + public int Item { get; } + /// + /// The item. + /// + public object Value { get; } + + /// + /// Initializes a new instance of + /// + /// The index of the item. + /// The item + public ListViewItemEventArgs (int item, object value) + { + Item = item; + Value = value; + } + } +} diff --git a/Terminal.Gui/Views/ListViewRowEventArgs.cs b/Terminal.Gui/Views/ListViewRowEventArgs.cs new file mode 100644 index 000000000..64caddb7b --- /dev/null +++ b/Terminal.Gui/Views/ListViewRowEventArgs.cs @@ -0,0 +1,27 @@ +using System; + +namespace Terminal.Gui { + /// + /// used by the event. + /// + public class ListViewRowEventArgs : EventArgs { + /// + /// The current row being rendered. + /// + public int Row { get; } + /// + /// The used by current row or + /// null to maintain the current attribute. + /// + public Attribute? RowAttribute { get; set; } + + /// + /// Initializes with the current row. + /// + /// + public ListViewRowEventArgs (int row) + { + Row = row; + } + } +} diff --git a/Terminal.Gui/Views/Menu.cs b/Terminal.Gui/Views/Menu.cs index a8e0cf34e..230b869ac 100644 --- a/Terminal.Gui/Views/Menu.cs +++ b/Terminal.Gui/Views/Menu.cs @@ -2004,72 +2004,4 @@ namespace Terminal.Gui { return base.OnEnter (view); } } - - /// - /// An which allows passing a cancelable menu opening event or replacing with a new . - /// - public class MenuOpeningEventArgs : EventArgs { - /// - /// The current parent. - /// - public MenuBarItem CurrentMenu { get; } - - /// - /// The new to be replaced. - /// - public MenuBarItem NewMenuBarItem { get; set; } - /// - /// Flag that allows the cancellation of the event. If set to in the - /// event handler, the event will be canceled. - /// - public bool Cancel { get; set; } - - /// - /// Initializes a new instance of . - /// - /// The current parent. - public MenuOpeningEventArgs (MenuBarItem currentMenu) - { - CurrentMenu = currentMenu; - } - } - - /// - /// An which allows passing a cancelable menu closing event. - /// - public class MenuClosingEventArgs : EventArgs { - /// - /// The current parent. - /// - public MenuBarItem CurrentMenu { get; } - - /// - /// Indicates whether the current menu will reopen. - /// - public bool Reopen { get; } - - /// - /// Indicates whether the current menu is a sub-menu. - /// - public bool IsSubMenu { get; } - - /// - /// Flag that allows the cancellation of the event. If set to in the - /// event handler, the event will be canceled. - /// - public bool Cancel { get; set; } - - /// - /// Initializes a new instance of . - /// - /// The current parent. - /// Whether the current menu will reopen. - /// Indicates whether it is a sub-menu. - public MenuClosingEventArgs (MenuBarItem currentMenu, bool reopen, bool isSubMenu) - { - CurrentMenu = currentMenu; - Reopen = reopen; - IsSubMenu = isSubMenu; - } - } } diff --git a/Terminal.Gui/Views/MenuClosingEventArgs.cs b/Terminal.Gui/Views/MenuClosingEventArgs.cs new file mode 100644 index 000000000..934ab1d41 --- /dev/null +++ b/Terminal.Gui/Views/MenuClosingEventArgs.cs @@ -0,0 +1,42 @@ +using System; + +namespace Terminal.Gui { + /// + /// An which allows passing a cancelable menu closing event. + /// + public class MenuClosingEventArgs : EventArgs { + /// + /// The current parent. + /// + public MenuBarItem CurrentMenu { get; } + + /// + /// Indicates whether the current menu will reopen. + /// + public bool Reopen { get; } + + /// + /// Indicates whether the current menu is a sub-menu. + /// + public bool IsSubMenu { get; } + + /// + /// Flag that allows the cancellation of the event. If set to in the + /// event handler, the event will be canceled. + /// + public bool Cancel { get; set; } + + /// + /// Initializes a new instance of . + /// + /// The current parent. + /// Whether the current menu will reopen. + /// Indicates whether it is a sub-menu. + public MenuClosingEventArgs (MenuBarItem currentMenu, bool reopen, bool isSubMenu) + { + CurrentMenu = currentMenu; + Reopen = reopen; + IsSubMenu = isSubMenu; + } + } +} diff --git a/Terminal.Gui/Views/MenuOpeningEventArgs.cs b/Terminal.Gui/Views/MenuOpeningEventArgs.cs new file mode 100644 index 000000000..a57c8b07b --- /dev/null +++ b/Terminal.Gui/Views/MenuOpeningEventArgs.cs @@ -0,0 +1,32 @@ +using System; + +namespace Terminal.Gui { + /// + /// An which allows passing a cancelable menu opening event or replacing with a new . + /// + public class MenuOpeningEventArgs : EventArgs { + /// + /// The current parent. + /// + public MenuBarItem CurrentMenu { get; } + + /// + /// The new to be replaced. + /// + public MenuBarItem NewMenuBarItem { get; set; } + /// + /// Flag that allows the cancellation of the event. If set to in the + /// event handler, the event will be canceled. + /// + public bool Cancel { get; set; } + + /// + /// Initializes a new instance of . + /// + /// The current parent. + public MenuOpeningEventArgs (MenuBarItem currentMenu) + { + CurrentMenu = currentMenu; + } + } +} diff --git a/Terminal.Gui/Views/RadioGroup.cs b/Terminal.Gui/Views/RadioGroup.cs index 474baebc1..6a27d1bca 100644 --- a/Terminal.Gui/Views/RadioGroup.cs +++ b/Terminal.Gui/Views/RadioGroup.cs @@ -422,30 +422,4 @@ namespace Terminal.Gui { /// Horizontal } - - /// - /// Event arguments for the SelectedItemChagned event. - /// - public class SelectedItemChangedArgs : EventArgs { - /// - /// Gets the index of the item that was previously selected. -1 if there was no previous selection. - /// - public int PreviousSelectedItem { get; } - - /// - /// Gets the index of the item that is now selected. -1 if there is no selection. - /// - public int SelectedItem { get; } - - /// - /// Initializes a new class. - /// - /// - /// - public SelectedItemChangedArgs (int selectedItem, int previousSelectedItem) - { - PreviousSelectedItem = previousSelectedItem; - SelectedItem = selectedItem; - } - } } diff --git a/Terminal.Gui/Views/SelectedCellChangedEventArgs.cs b/Terminal.Gui/Views/SelectedCellChangedEventArgs.cs new file mode 100644 index 000000000..13dd3bfb5 --- /dev/null +++ b/Terminal.Gui/Views/SelectedCellChangedEventArgs.cs @@ -0,0 +1,63 @@ +using System; +using System.Data; + +namespace Terminal.Gui { + + + /// + /// Defines the event arguments for + /// + public class SelectedCellChangedEventArgs : EventArgs { + /// + /// The current table to which the new indexes refer. May be null e.g. if selection change is the result of clearing the table from the view + /// + /// + public DataTable Table { get; } + + + /// + /// The previous selected column index. May be invalid e.g. when the selection has been changed as a result of replacing the existing Table with a smaller one + /// + /// + public int OldCol { get; } + + + /// + /// The newly selected column index. + /// + /// + public int NewCol { get; } + + + /// + /// The previous selected row index. May be invalid e.g. when the selection has been changed as a result of deleting rows from the table + /// + /// + public int OldRow { get; } + + + /// + /// The newly selected row index. + /// + /// + public int NewRow { get; } + + /// + /// Creates a new instance of arguments describing a change in selected cell in a + /// + /// + /// + /// + /// + /// + public SelectedCellChangedEventArgs (DataTable t, int oldCol, int newCol, int oldRow, int newRow) + { + Table = t; + OldCol = oldCol; + NewCol = newCol; + OldRow = oldRow; + NewRow = newRow; + } + } + +} diff --git a/Terminal.Gui/Views/SelectedItemChangedArgs.cs b/Terminal.Gui/Views/SelectedItemChangedArgs.cs new file mode 100644 index 000000000..60e9728bc --- /dev/null +++ b/Terminal.Gui/Views/SelectedItemChangedArgs.cs @@ -0,0 +1,29 @@ +using System; + +namespace Terminal.Gui { + /// + /// Event arguments for the SelectedItemChagned event. + /// + public class SelectedItemChangedArgs : EventArgs { + /// + /// Gets the index of the item that was previously selected. -1 if there was no previous selection. + /// + public int PreviousSelectedItem { get; } + + /// + /// Gets the index of the item that is now selected. -1 if there is no selection. + /// + public int SelectedItem { get; } + + /// + /// Initializes a new class. + /// + /// + /// + public SelectedItemChangedArgs (int selectedItem, int previousSelectedItem) + { + PreviousSelectedItem = previousSelectedItem; + SelectedItem = selectedItem; + } + } +} diff --git a/Terminal.Gui/Views/SplitterEventArgs.cs b/Terminal.Gui/Views/SplitterEventArgs.cs new file mode 100644 index 000000000..cd2faebff --- /dev/null +++ b/Terminal.Gui/Views/SplitterEventArgs.cs @@ -0,0 +1,38 @@ +using System; + +namespace Terminal.Gui { + /// + /// Provides data for events. + /// + public class SplitterEventArgs : EventArgs { + + /// + /// Creates a new instance of the class. + /// + /// in which splitter is being moved. + /// Index of the splitter being moved in . + /// The new of the splitter line. + public SplitterEventArgs (TileView tileView, int idx, Pos splitterDistance) + { + SplitterDistance = splitterDistance; + TileView = tileView; + Idx = idx; + } + + /// + /// New position of the splitter line (see ). + /// + public Pos SplitterDistance { get; } + + /// + /// Container (sender) of the event. + /// + public TileView TileView { get; } + + /// + /// Gets the index of the splitter that is being moved. This can be + /// used to index + /// + public int Idx { get; } + } +} diff --git a/Terminal.Gui/Views/TabChangedEventArgs.cs b/Terminal.Gui/Views/TabChangedEventArgs.cs new file mode 100644 index 000000000..5d890a1bc --- /dev/null +++ b/Terminal.Gui/Views/TabChangedEventArgs.cs @@ -0,0 +1,31 @@ +using System; + +namespace Terminal.Gui { + + /// + /// Describes a change in + /// + public class TabChangedEventArgs : EventArgs { + + /// + /// The previously selected tab. May be null + /// + public TabView.Tab OldTab { get; } + + /// + /// The currently selected tab. May be null + /// + public TabView.Tab NewTab { get; } + + /// + /// Documents a tab change + /// + /// + /// + public TabChangedEventArgs (TabView.Tab oldTab, TabView.Tab newTab) + { + OldTab = oldTab; + NewTab = newTab; + } + } +} diff --git a/Terminal.Gui/Views/TabMouseEventArgs.cs b/Terminal.Gui/Views/TabMouseEventArgs.cs new file mode 100644 index 000000000..e6d06d2b0 --- /dev/null +++ b/Terminal.Gui/Views/TabMouseEventArgs.cs @@ -0,0 +1,36 @@ +using System; + +namespace Terminal.Gui { + + /// + /// Describes a mouse event over a specific in a . + /// + public class TabMouseEventArgs : EventArgs { + + /// + /// Gets the (if any) that the mouse + /// was over when the occurred. + /// + /// This will be null if the click is after last tab + /// or before first. + public TabView.Tab Tab { get; } + + /// + /// Gets the actual mouse event. Use to cancel this event + /// and perform custom behavior (e.g. show a context menu). + /// + public MouseEvent MouseEvent { get; } + + /// + /// Creates a new instance of the class. + /// + /// that the mouse was over when the event occurred. + /// The mouse activity being reported + public TabMouseEventArgs (TabView.Tab tab, MouseEvent mouseEvent) + { + Tab = tab; + MouseEvent = mouseEvent; + } + } + +} diff --git a/Terminal.Gui/Views/TabView.cs b/Terminal.Gui/Views/TabView.cs index 40ba26bd4..35affc9b5 100644 --- a/Terminal.Gui/Views/TabView.cs +++ b/Terminal.Gui/Views/TabView.cs @@ -9,7 +9,7 @@ namespace Terminal.Gui { /// /// Control that hosts multiple sub views, presenting a single one at once /// - public class TabView : View { + public partial class TabView : View { private Tab selectedTab; /// @@ -771,37 +771,6 @@ namespace Terminal.Gui { TabClicked?.Invoke (this, tabMouseEventArgs); } - /// - /// Describes a mouse event over a specific in a . - /// - public class TabMouseEventArgs : EventArgs { - - /// - /// Gets the (if any) that the mouse - /// was over when the occurred. - /// - /// This will be null if the click is after last tab - /// or before first. - public Tab Tab { get; } - - /// - /// Gets the actual mouse event. Use to cancel this event - /// and perform custom behavior (e.g. show a context menu). - /// - public MouseEvent MouseEvent { get; } - - /// - /// Creates a new instance of the class. - /// - /// that the mouse was over when the event occurred. - /// The mouse activity being reported - public TabMouseEventArgs (Tab tab, MouseEvent mouseEvent) - { - Tab = tab; - MouseEvent = mouseEvent; - } - } - /// /// A single tab in a /// @@ -867,33 +836,6 @@ namespace Terminal.Gui { public bool TabsOnBottom { get; set; } = false; } - - /// - /// Describes a change in - /// - public class TabChangedEventArgs : EventArgs { - - /// - /// The previously selected tab. May be null - /// - public Tab OldTab { get; } - - /// - /// The currently selected tab. May be null - /// - public Tab NewTab { get; } - - /// - /// Documents a tab change - /// - /// - /// - public TabChangedEventArgs (Tab oldTab, Tab newTab) - { - OldTab = oldTab; - NewTab = newTab; - } - } #endregion } } diff --git a/Terminal.Gui/Views/TableView.cs b/Terminal.Gui/Views/TableView.cs index 6ea192531..06bce3571 100644 --- a/Terminal.Gui/Views/TableView.cs +++ b/Terminal.Gui/Views/TableView.cs @@ -13,44 +13,7 @@ namespace Terminal.Gui { /// /// See TableView Deep Dive for more information. /// - public class TableView : View { - - /// - /// Defines the event arguments for event - /// - public class CellActivatedEventArgs : EventArgs { - /// - /// The current table to which the new indexes refer. May be null e.g. if selection change is the result of clearing the table from the view - /// - /// - public DataTable Table { get; } - - - /// - /// The column index of the cell that is being activated - /// - /// - public int Col { get; } - - /// - /// The row index of the cell that is being activated - /// - /// - public int Row { get; } - - /// - /// Creates a new instance of arguments describing a cell being activated in - /// - /// - /// - /// - public CellActivatedEventArgs (DataTable t, int col, int row) - { - Table = t; - Col = col; - Row = row; - } - } + public partial class TableView : View { private int columnOffset; private int rowOffset; @@ -2001,62 +1964,6 @@ namespace Terminal.Gui { } } - /// - /// Defines the event arguments for - /// - public class SelectedCellChangedEventArgs : EventArgs { - /// - /// The current table to which the new indexes refer. May be null e.g. if selection change is the result of clearing the table from the view - /// - /// - public DataTable Table { get; } - - - /// - /// The previous selected column index. May be invalid e.g. when the selection has been changed as a result of replacing the existing Table with a smaller one - /// - /// - public int OldCol { get; } - - - /// - /// The newly selected column index. - /// - /// - public int NewCol { get; } - - - /// - /// The previous selected row index. May be invalid e.g. when the selection has been changed as a result of deleting rows from the table - /// - /// - public int OldRow { get; } - - - /// - /// The newly selected row index. - /// - /// - public int NewRow { get; } - - /// - /// Creates a new instance of arguments describing a change in selected cell in a - /// - /// - /// - /// - /// - /// - public SelectedCellChangedEventArgs (DataTable t, int oldCol, int newCol, int oldRow, int newRow) - { - Table = t; - OldCol = oldCol; - NewCol = newCol; - OldRow = oldRow; - NewRow = newRow; - } - } - /// /// Describes a selected region of the table /// diff --git a/Terminal.Gui/Views/TextChangedEventArgs.cs b/Terminal.Gui/Views/TextChangedEventArgs.cs new file mode 100644 index 000000000..942a2b267 --- /dev/null +++ b/Terminal.Gui/Views/TextChangedEventArgs.cs @@ -0,0 +1,31 @@ +// +// TextField.cs: single-line text editor with Emacs keybindings +// +// Authors: +// Miguel de Icaza (miguel@gnome.org) +// + +using System; +using NStack; + +namespace Terminal.Gui { + /// + /// Event args for the event + /// + public class TextChangedEventArgs : EventArgs { + + /// + /// Creates a new instance of the class + /// + /// + public TextChangedEventArgs (ustring oldValue) + { + OldValue = oldValue; + } + + /// + /// The old value before the text changed + /// + public ustring OldValue { get; } + } +} diff --git a/Terminal.Gui/Views/TextChangingEventArgs.cs b/Terminal.Gui/Views/TextChangingEventArgs.cs new file mode 100644 index 000000000..db0b5c8a5 --- /dev/null +++ b/Terminal.Gui/Views/TextChangingEventArgs.cs @@ -0,0 +1,34 @@ +// +// TextField.cs: single-line text editor with Emacs keybindings +// +// Authors: +// Miguel de Icaza (miguel@gnome.org) +// + +using System; +using NStack; + +namespace Terminal.Gui { + /// + /// An which allows passing a cancelable new text value event. + /// + public class TextChangingEventArgs : EventArgs { + /// + /// The new text to be replaced. + /// + public ustring NewText { get; set; } + /// + /// Flag which allows to cancel the new text value. + /// + public bool Cancel { get; set; } + + /// + /// Initializes a new instance of + /// + /// The new to be replaced. + public TextChangingEventArgs (ustring newText) + { + NewText = newText; + } + } +} diff --git a/Terminal.Gui/Views/TextField.cs b/Terminal.Gui/Views/TextField.cs index f907ad529..062c2e7c0 100644 --- a/Terminal.Gui/Views/TextField.cs +++ b/Terminal.Gui/Views/TextField.cs @@ -1308,48 +1308,6 @@ namespace Terminal.Gui { historyText.Clear (Text); } } - - /// - /// An which allows passing a cancelable new text value event. - /// - public class TextChangingEventArgs : EventArgs { - /// - /// The new text to be replaced. - /// - public ustring NewText { get; set; } - /// - /// Flag which allows to cancel the new text value. - /// - public bool Cancel { get; set; } - - /// - /// Initializes a new instance of - /// - /// The new to be replaced. - public TextChangingEventArgs (ustring newText) - { - NewText = newText; - } - } - /// - /// Event args for the event - /// - public class TextChangedEventArgs : EventArgs { - - /// - /// Creates a new instance of the class - /// - /// - public TextChangedEventArgs (ustring oldValue) - { - OldValue = oldValue; - } - - /// - /// The old value before the text changed - /// - public ustring OldValue { get; } - } /// /// Renders an overlay on another view at a given point that allows selecting /// from a range of 'autocomplete' options. diff --git a/Terminal.Gui/Views/TextView.cs b/Terminal.Gui/Views/TextView.cs index 424727aff..488350008 100644 --- a/Terminal.Gui/Views/TextView.cs +++ b/Terminal.Gui/Views/TextView.cs @@ -515,7 +515,7 @@ namespace Terminal.Gui { } } - class HistoryText { + partial class HistoryText { public enum LineStatus { Original, Replaced, @@ -523,34 +523,6 @@ namespace Terminal.Gui { Added } - public class HistoryTextItem : EventArgs{ - public List> Lines; - public Point CursorPosition; - public LineStatus LineStatus; - public bool IsUndoing; - public Point FinalCursorPosition; - public HistoryTextItem RemovedOnAdded; - - public HistoryTextItem (List> lines, Point curPos, LineStatus linesStatus) - { - Lines = lines; - CursorPosition = curPos; - LineStatus = linesStatus; - } - - public HistoryTextItem (HistoryTextItem historyTextItem) - { - Lines = new List> (historyTextItem.Lines); - CursorPosition = new Point (historyTextItem.CursorPosition.X, historyTextItem.CursorPosition.Y); - LineStatus = historyTextItem.LineStatus; - } - - public override string ToString () - { - return $"(Count: {Lines.Count}, Cursor: {CursorPosition}, Status: {LineStatus})"; - } - } - List historyTextItems = new List (); int idxHistoryText = -1; ustring originalText; @@ -1129,7 +1101,7 @@ namespace Terminal.Gui { /// /// /// - public class TextView : View { + public partial class TextView : View { TextModel model = new TextModel (); int topRow; int leftColumn; @@ -2709,33 +2681,6 @@ namespace Terminal.Gui { OnUnwrappedCursorPosition (); } - /// - /// Event arguments for events for when the contents of the TextView change. E.g. the event. - /// - public class ContentsChangedEventArgs : EventArgs { - /// - /// Creates a new instance. - /// - /// Contains the row where the change occurred. - /// Contains the column where the change occured. - public ContentsChangedEventArgs (int currentRow, int currentColumn) - { - Row = currentRow; - Col = currentColumn; - } - - /// - /// - /// Contains the row where the change occurred. - /// - public int Row { get; private set; } - - /// - /// Contains the column where the change occurred. - /// - public int Col { get; private set; } - } - /// /// Called when the contents of the TextView change. E.g. when the user types text or deletes text. Raises /// the event. diff --git a/Terminal.Gui/Views/TileView.cs b/Terminal.Gui/Views/TileView.cs index 5c0a09c6c..b0b8f5e27 100644 --- a/Terminal.Gui/Views/TileView.cs +++ b/Terminal.Gui/Views/TileView.cs @@ -10,7 +10,7 @@ namespace Terminal.Gui { /// A consisting of a moveable bar that divides /// the display area into resizeable . /// - public class TileView : View { + public partial class TileView : View { TileView parentTileView; /// @@ -24,7 +24,7 @@ namespace Terminal.Gui { /// new instances use /// or . /// - public class Tile { + public partial class Tile { /// /// The that is contained in this . /// Add new child views to this member for multiple @@ -61,37 +61,6 @@ namespace Terminal.Gui { private string _title = string.Empty; - /// - /// An which allows passing a cancelable new value event. - /// - public class TitleEventArgs : EventArgs { - /// - /// The new Window Title. - /// - public ustring NewTitle { get; set; } - - /// - /// The old Window Title. - /// - public ustring OldTitle { get; set; } - - /// - /// Flag which allows cancelling the Title change. - /// - public bool Cancel { get; set; } - - /// - /// Initializes a new instance of - /// - /// The that is/has been replaced. - /// The new to be replaced. - public TitleEventArgs (ustring oldTitle, ustring newTitle) - { - OldTitle = oldTitle; - NewTitle = newTitle; - } - } - /// /// Called before the changes. Invokes the event, which can be cancelled. /// @@ -1107,41 +1076,6 @@ namespace Terminal.Gui { } - /// - /// Provides data for events. - /// - public class SplitterEventArgs : EventArgs { - - /// - /// Creates a new instance of the class. - /// - /// in which splitter is being moved. - /// Index of the splitter being moved in . - /// The new of the splitter line. - public SplitterEventArgs (TileView tileView, int idx, Pos splitterDistance) - { - SplitterDistance = splitterDistance; - TileView = tileView; - Idx = idx; - } - - /// - /// New position of the splitter line (see ). - /// - public Pos SplitterDistance { get; } - - /// - /// Container (sender) of the event. - /// - public TileView TileView { get; } - - /// - /// Gets the index of the splitter that is being moved. This can be - /// used to index - /// - public int Idx { get; } - } - /// /// Represents a method that will handle splitter events. /// diff --git a/Terminal.Gui/Views/TitleEventArgs.cs b/Terminal.Gui/Views/TitleEventArgs.cs new file mode 100644 index 000000000..90af8a8af --- /dev/null +++ b/Terminal.Gui/Views/TitleEventArgs.cs @@ -0,0 +1,42 @@ +using NStack; +using System; + +namespace Terminal.Gui { + + public partial class TileView { + + public partial class Tile { + /// + /// An which allows passing a cancelable new value event. + /// + public class TitleEventArgs : EventArgs { + /// + /// The new Window Title. + /// + public ustring NewTitle { get; set; } + + /// + /// The old Window Title. + /// + public ustring OldTitle { get; set; } + + /// + /// Flag which allows cancelling the Title change. + /// + public bool Cancel { get; set; } + + /// + /// Initializes a new instance of + /// + /// The that is/has been replaced. + /// The new to be replaced. + public TitleEventArgs (ustring oldTitle, ustring newTitle) + { + OldTitle = oldTitle; + NewTitle = newTitle; + } + } + } + + } +} diff --git a/Terminal.Gui/Windows/StepChangeEventArgs.cs b/Terminal.Gui/Windows/StepChangeEventArgs.cs new file mode 100644 index 000000000..9bbc0e240 --- /dev/null +++ b/Terminal.Gui/Windows/StepChangeEventArgs.cs @@ -0,0 +1,38 @@ +using System; + +namespace Terminal.Gui { + + public partial class Wizard { + /// + /// for events. + /// + public class StepChangeEventArgs : EventArgs { + /// + /// The current (or previous) . + /// + public WizardStep OldStep { get; } + + /// + /// The the is changing to or has changed to. + /// + public WizardStep NewStep { get; } + + /// + /// Event handlers can set to true before returning to cancel the step transition. + /// + public bool Cancel { get; set; } + + /// + /// Initializes a new instance of + /// + /// The current . + /// The new . + public StepChangeEventArgs (WizardStep oldStep, WizardStep newStep) + { + OldStep = oldStep; + NewStep = newStep; + Cancel = false; + } + } + } +} \ No newline at end of file diff --git a/Terminal.Gui/Windows/Wizard.cs b/Terminal.Gui/Windows/Wizard.cs index ea774ca96..3d277d8d9 100644 --- a/Terminal.Gui/Windows/Wizard.cs +++ b/Terminal.Gui/Windows/Wizard.cs @@ -54,7 +54,7 @@ namespace Terminal.Gui { /// Application.Shutdown (); /// /// - public class Wizard : Dialog { + public partial class Wizard : Dialog { /// /// Represents a basic step that is displayed in a . The view is divided horizontally in two. On the left is the /// content view where s can be added, On the right is the help for the step. @@ -615,24 +615,6 @@ namespace Terminal.Gui { } private ustring wizardTitle = ustring.Empty; - /// - /// for transition events. - /// - public class WizardButtonEventArgs : EventArgs { - /// - /// Set to true to cancel the transition to the next step. - /// - public bool Cancel { get; set; } - - /// - /// Initializes a new instance of - /// - public WizardButtonEventArgs () - { - Cancel = false; - } - } - /// /// Raised when the Back button in the is clicked. The Back button is always /// the first button in the array of Buttons passed to the constructor, if any. @@ -663,38 +645,6 @@ namespace Terminal.Gui { /// public event EventHandler Cancelled; - /// - /// for events. - /// - public class StepChangeEventArgs : EventArgs { - /// - /// The current (or previous) . - /// - public WizardStep OldStep { get; } - - /// - /// The the is changing to or has changed to. - /// - public WizardStep NewStep { get; } - - /// - /// Event handlers can set to true before returning to cancel the step transition. - /// - public bool Cancel { get; set; } - - /// - /// Initializes a new instance of - /// - /// The current . - /// The new . - public StepChangeEventArgs (WizardStep oldStep, WizardStep newStep) - { - OldStep = oldStep; - NewStep = newStep; - Cancel = false; - } - } - /// /// This event is raised when the current ) is about to change. Use /// to abort the transition. diff --git a/Terminal.Gui/Windows/WizardButtonEventArgs.cs b/Terminal.Gui/Windows/WizardButtonEventArgs.cs new file mode 100644 index 000000000..277aa672f --- /dev/null +++ b/Terminal.Gui/Windows/WizardButtonEventArgs.cs @@ -0,0 +1,24 @@ +using System; + +namespace Terminal.Gui { + + public partial class Wizard { + /// + /// for transition events. + /// + public class WizardButtonEventArgs : EventArgs { + /// + /// Set to true to cancel the transition to the next step. + /// + public bool Cancel { get; set; } + + /// + /// Initializes a new instance of + /// + public WizardButtonEventArgs () + { + Cancel = false; + } + } + } +} \ No newline at end of file diff --git a/UICatalog/Scenarios/CsvEditor.cs b/UICatalog/Scenarios/CsvEditor.cs index 14ee9fade..7a17beb03 100644 --- a/UICatalog/Scenarios/CsvEditor.cs +++ b/UICatalog/Scenarios/CsvEditor.cs @@ -114,7 +114,7 @@ namespace UICatalog.Scenarios { } } - private void OnSelectedCellChanged (object sender, TableView.SelectedCellChangedEventArgs e) + private void OnSelectedCellChanged (object sender, SelectedCellChangedEventArgs e) { // only update the text box if the user is not manually editing it if (!selectedCellLabel.HasFocus) @@ -472,7 +472,7 @@ namespace UICatalog.Scenarios { } - private void TableViewKeyPress (object sender, View.KeyEventEventArgs e) + private void TableViewKeyPress (object sender, KeyEventEventArgs e) { if (e.KeyEvent.Key == Key.DeleteChar) { @@ -540,7 +540,7 @@ namespace UICatalog.Scenarios { enteredText = okPressed ? tf.Text.ToString () : null; return okPressed; } - private void EditCurrentCell (object sender, TableView.CellActivatedEventArgs e) + private void EditCurrentCell (object sender, CellActivatedEventArgs e) { if (e.Table == null) return; diff --git a/UICatalog/Scenarios/HexEditor.cs b/UICatalog/Scenarios/HexEditor.cs index cce25fd92..62f39cdef 100644 --- a/UICatalog/Scenarios/HexEditor.cs +++ b/UICatalog/Scenarios/HexEditor.cs @@ -64,7 +64,7 @@ namespace UICatalog.Scenarios { Application.Top.Add (statusBar); } - private void _hexView_PositionChanged (object sender, HexView.HexViewEventArgs obj) + private void _hexView_PositionChanged (object sender, HexViewEventArgs obj) { siPositionChanged.Title = $"Position: {obj.Position} Line: {obj.CursorPosition.Y} Col: {obj.CursorPosition.X} Line length: {obj.BytesPerLine}"; statusBar.SetNeedsDisplay (); @@ -75,7 +75,7 @@ namespace UICatalog.Scenarios { _hexView.AllowEdits = (bool)(miAllowEdits.Checked = !miAllowEdits.Checked); } - private void _hexView_Edited (object sender, HexView.HexViewEditEventArgs e) + private void _hexView_Edited (object sender, HexViewEditEventArgs e) { _saved = false; } diff --git a/UICatalog/Scenarios/InteractiveTree.cs b/UICatalog/Scenarios/InteractiveTree.cs index 6cfd71fd1..e209f9d00 100644 --- a/UICatalog/Scenarios/InteractiveTree.cs +++ b/UICatalog/Scenarios/InteractiveTree.cs @@ -49,7 +49,7 @@ namespace UICatalog.Scenarios { } - private void TreeView_KeyPress (object sender, View.KeyEventEventArgs obj) + private void TreeView_KeyPress (object sender, KeyEventEventArgs obj) { if (obj.KeyEvent.Key == Key.DeleteChar) { diff --git a/UICatalog/Scenarios/MultiColouredTable.cs b/UICatalog/Scenarios/MultiColouredTable.cs index 75b67a0f6..88788ae69 100644 --- a/UICatalog/Scenarios/MultiColouredTable.cs +++ b/UICatalog/Scenarios/MultiColouredTable.cs @@ -98,7 +98,7 @@ namespace UICatalog.Scenarios { enteredText = okPressed ? tf.Text.ToString () : null; return okPressed; } - private void EditCurrentCell (object sender, TableView.CellActivatedEventArgs e) + private void EditCurrentCell (object sender, CellActivatedEventArgs e) { if (e.Table == null) return; diff --git a/UICatalog/Scenarios/Notepad.cs b/UICatalog/Scenarios/Notepad.cs index 5fc6edbed..a55643f45 100644 --- a/UICatalog/Scenarios/Notepad.cs +++ b/UICatalog/Scenarios/Notepad.cs @@ -74,12 +74,12 @@ namespace UICatalog.Scenarios { New (); } - private void TabView_SelectedTabChanged (object sender, TabView.TabChangedEventArgs e) + private void TabView_SelectedTabChanged (object sender, TabChangedEventArgs e) { lenStatusItem.Title = $"Len:{e.NewTab?.View?.Text?.Length ?? 0}"; } - private void TabView_TabClicked (object sender, TabView.TabMouseEventArgs e) + private void TabView_TabClicked (object sender, TabMouseEventArgs e) { // we are only interested in right clicks if(!e.MouseEvent.Flags.HasFlag(MouseFlags.Button3Clicked)) { diff --git a/UICatalog/Scenarios/TableEditor.cs b/UICatalog/Scenarios/TableEditor.cs index 6a0c9cd17..d7af084cb 100644 --- a/UICatalog/Scenarios/TableEditor.cs +++ b/UICatalog/Scenarios/TableEditor.cs @@ -345,7 +345,7 @@ namespace UICatalog.Scenarios { } - private void TableViewKeyPress (object sender, View.KeyEventEventArgs e) + private void TableViewKeyPress (object sender, KeyEventEventArgs e) { if (e.KeyEvent.Key == Key.DeleteChar) { @@ -748,7 +748,7 @@ namespace UICatalog.Scenarios { tableView.Table = BuildSimpleDataTable (big ? 30 : 5, big ? 1000 : 5); } - private void EditCurrentCell (object sender, TableView.CellActivatedEventArgs e) + private void EditCurrentCell (object sender, CellActivatedEventArgs e) { if (e.Table == null) return; diff --git a/UICatalog/Scenarios/TreeViewFileSystem.cs b/UICatalog/Scenarios/TreeViewFileSystem.cs index b895e4841..d72c7b883 100644 --- a/UICatalog/Scenarios/TreeViewFileSystem.cs +++ b/UICatalog/Scenarios/TreeViewFileSystem.cs @@ -106,7 +106,7 @@ namespace UICatalog.Scenarios { ShowPropertiesOf (e.NewValue); } - private void TreeViewFiles_KeyPress (object sender, View.KeyEventEventArgs obj) + private void TreeViewFiles_KeyPress (object sender, KeyEventEventArgs obj) { if (obj.KeyEvent.Key == (Key.R | Key.CtrlMask)) { diff --git a/UICatalog/Scenarios/VkeyPacketSimulator.cs b/UICatalog/Scenarios/VkeyPacketSimulator.cs index c76050910..5baeacfd3 100644 --- a/UICatalog/Scenarios/VkeyPacketSimulator.cs +++ b/UICatalog/Scenarios/VkeyPacketSimulator.cs @@ -122,7 +122,7 @@ namespace UICatalog.Scenarios { } }; - View.KeyEventEventArgs unknownChar = null; + KeyEventEventArgs unknownChar = null; tvInput.KeyPress += (s, e) => { if (e.KeyEvent.Key == (Key.Q | Key.CtrlMask)) { @@ -229,7 +229,7 @@ namespace UICatalog.Scenarios { }; } - private void AddKeyboardStrokes (View.KeyEventEventArgs e) + private void AddKeyboardStrokes (KeyEventEventArgs e) { var ke = e.KeyEvent; var km = new KeyModifiers (); diff --git a/UICatalog/UICatalog.cs b/UICatalog/UICatalog.cs index e8e243af5..8c74ca7f9 100644 --- a/UICatalog/UICatalog.cs +++ b/UICatalog/UICatalog.cs @@ -651,7 +651,7 @@ namespace UICatalog { Application.Top.SetNeedsDisplay (); } - void KeyDownHandler (object sender, View.KeyEventEventArgs a) + void KeyDownHandler (object sender, KeyEventEventArgs a) { if (a.KeyEvent.IsCapslock) { Capslock.Title = "Caps: On"; diff --git a/UnitTests/Application/ApplicationTests.cs b/UnitTests/Application/ApplicationTests.cs index ad73e43ea..7aec50b33 100644 --- a/UnitTests/Application/ApplicationTests.cs +++ b/UnitTests/Application/ApplicationTests.cs @@ -582,7 +582,7 @@ namespace Terminal.Gui.ApplicationTests { int keyUps = 0; var output = string.Empty; - Application.Top.KeyUp += (object sender, View.KeyEventEventArgs args) => { + Application.Top.KeyUp += (object sender, KeyEventEventArgs args) => { if (args.KeyEvent.Key != (Key.CtrlMask | Key.Q)) { output += (char)args.KeyEvent.KeyValue; } diff --git a/UnitTests/Configuration/ConfigurationMangerTests.cs b/UnitTests/Configuration/ConfigurationMangerTests.cs index a37833a0c..73ae84b14 100644 --- a/UnitTests/Configuration/ConfigurationMangerTests.cs +++ b/UnitTests/Configuration/ConfigurationMangerTests.cs @@ -775,7 +775,7 @@ namespace Terminal.Gui.ConfigurationTests { ConfigurationManager.Updated += ConfigurationManager_Updated; bool fired = false; - void ConfigurationManager_Updated (object sender, ConfigurationManager.ConfigurationManagerEventArgs obj) + void ConfigurationManager_Updated (object sender, ConfigurationManagerEventArgs obj) { fired = true; // assert @@ -801,7 +801,7 @@ namespace Terminal.Gui.ConfigurationTests { ConfigurationManager.Reset (); ConfigurationManager.Applied += ConfigurationManager_Applied; bool fired = false; - void ConfigurationManager_Applied (object sender, ConfigurationManager.ConfigurationManagerEventArgs obj) + void ConfigurationManager_Applied (object sender, ConfigurationManagerEventArgs obj) { fired = true; // assert diff --git a/UnitTests/Core/ViewTests.cs b/UnitTests/Core/ViewTests.cs index 343768c21..c68a9e86e 100644 --- a/UnitTests/Core/ViewTests.cs +++ b/UnitTests/Core/ViewTests.cs @@ -1539,7 +1539,7 @@ namespace Terminal.Gui.CoreTests { var tf = new TextField (); tf.KeyPress += Tf_KeyPress; - void Tf_KeyPress (object sender, View.KeyEventEventArgs obj) + void Tf_KeyPress (object sender, KeyEventEventArgs obj) { if (obj.KeyEvent.Key == (Key.Q | Key.CtrlMask)) { obj.Handled = tfQuiting = true; @@ -1551,7 +1551,7 @@ namespace Terminal.Gui.CoreTests { var top = Application.Top; top.KeyPress += Top_KeyPress; - void Top_KeyPress (object sender, View.KeyEventEventArgs obj) + void Top_KeyPress (object sender, KeyEventEventArgs obj) { if (obj.KeyEvent.Key == (Key.Q | Key.CtrlMask)) { obj.Handled = topQuiting = true; @@ -1599,7 +1599,7 @@ namespace Terminal.Gui.CoreTests { var tf = new TextField (); tf.KeyPress += Tf_KeyPress; - void Tf_KeyPress (object sender, View.KeyEventEventArgs obj) + void Tf_KeyPress (object sender, KeyEventEventArgs obj) { if (obj.KeyEvent.Key == (Key.Q | Key.CtrlMask)) { obj.Handled = tfQuiting = true; diff --git a/UnitTests/UICatalog/ScenarioTests.cs b/UnitTests/UICatalog/ScenarioTests.cs index b530d1d69..dc484eca6 100644 --- a/UnitTests/UICatalog/ScenarioTests.cs +++ b/UnitTests/UICatalog/ScenarioTests.cs @@ -121,7 +121,7 @@ namespace UICatalog.Tests { }; var token = Application.MainLoop.AddTimeout (TimeSpan.FromMilliseconds (ms), abortCallback); - Application.Top.KeyPress += (object sender, View.KeyEventEventArgs args) => { + Application.Top.KeyPress += (object sender, KeyEventEventArgs args) => { Assert.Equal (Key.CtrlMask | Key.Q, args.KeyEvent.Key); }; diff --git a/UnitTests/Views/HexViewTests.cs b/UnitTests/Views/HexViewTests.cs index 41f45f845..fdfca94de 100644 --- a/UnitTests/Views/HexViewTests.cs +++ b/UnitTests/Views/HexViewTests.cs @@ -254,7 +254,7 @@ namespace Terminal.Gui.ViewTests { public void PositionChanged_Event () { var hv = new HexView (LoadStream ()) { Width = Dim.Fill (), Height = Dim.Fill () }; - HexView.HexViewEventArgs hexViewEventArgs = null; + HexViewEventArgs hexViewEventArgs = null; hv.PositionChanged += (s, e) => hexViewEventArgs = e; Application.Top.Add (hv); Application.Begin (Application.Top);