diff --git a/Terminal.Gui/Core.cs b/Terminal.Gui/Core.cs
index c14898eb4..5adff8b13 100644
--- a/Terminal.Gui/Core.cs
+++ b/Terminal.Gui/Core.cs
@@ -75,7 +75,8 @@ namespace Terminal.Gui {
/// other View subclasses.
///
///
- public virtual bool ProcessKey (KeyEvent kb)
+ /// Contains the details about the key that produced the event.
+ public virtual bool ProcessKey (KeyEvent keyEvent)
{
return false;
}
@@ -101,7 +102,8 @@ namespace Terminal.Gui {
/// keypress when they have the focus.
///
///
- public virtual bool ProcessColdKey (KeyEvent kb)
+ /// Contains the details about the key that produced the event.
+ public virtual bool ProcessColdKey (KeyEvent keyEvent)
{
return false;
}
@@ -110,8 +112,8 @@ namespace Terminal.Gui {
/// Method invoked when a mouse event is generated
///
/// true, if the event was handled, false otherwise.
- /// Me.
- public virtual bool MouseEvent (MouseEvent me)
+ /// Contains the details about the mouse event.
+ public virtual bool MouseEvent (MouseEvent mouseEvent)
{
return false;
}
@@ -698,30 +700,33 @@ namespace Terminal.Gui {
focused.EnsureFocus ();
}
- public override bool ProcessKey (KeyEvent kb)
+ /// Contains the details about the key that produced the event.
+ public override bool ProcessKey (KeyEvent keyEvent)
{
- if (Focused?.ProcessKey (kb) == true)
+ if (Focused?.ProcessKey (keyEvent) == true)
return true;
return false;
}
- public override bool ProcessHotKey (KeyEvent kb)
+ /// Contains the details about the key that produced the event.
+ public override bool ProcessHotKey (KeyEvent keyEvent)
{
if (subviews == null || subviews.Count == 0)
return false;
foreach (var view in subviews)
- if (view.ProcessHotKey (kb))
+ if (view.ProcessHotKey (keyEvent))
return true;
return false;
}
- public override bool ProcessColdKey (KeyEvent kb)
+ /// Contains the details about the key that produced the event.
+ public override bool ProcessColdKey (KeyEvent keyEvent)
{
if (subviews == null || subviews.Count == 0)
return false;
foreach (var view in subviews)
- if (view.ProcessColdKey (kb))
+ if (view.ProcessColdKey (keyEvent))
return true;
return false;
}
@@ -916,12 +921,12 @@ namespace Terminal.Gui {
get => true;
}
- public override bool ProcessKey (KeyEvent kb)
+ public override bool ProcessKey (KeyEvent keyEvent)
{
- if (base.ProcessKey (kb))
+ if (base.ProcessKey (keyEvent))
return true;
- switch (kb.Key) {
+ switch (keyEvent.Key) {
case Key.ControlC:
// TODO: stop current execution of this container
break;
@@ -1048,7 +1053,7 @@ namespace Terminal.Gui {
///
///
///
- public virtual void Remove (View view)
+ public override void Remove (View view)
{
if (view == null)
return;
@@ -1088,7 +1093,7 @@ namespace Terminal.Gui {
// need to figure that out.
//
Point? dragPosition;
- public override bool MouseEvent(MouseEvent me)
+ public override bool MouseEvent(MouseEvent mouseEvent)
{
// The code is currently disabled, because the
// Driver.UncookMouse does not seem to have an effect if there is
@@ -1096,11 +1101,11 @@ namespace Terminal.Gui {
if (true)
return false;
- if ((me.Flags == MouseFlags.Button1Pressed|| me.Flags == MouseFlags.Button4Pressed)){
+ if ((mouseEvent.Flags == MouseFlags.Button1Pressed|| mouseEvent.Flags == MouseFlags.Button4Pressed)){
if (dragPosition.HasValue) {
- var dx = me.X - dragPosition.Value.X;
- var dy = me.Y - dragPosition.Value.Y;
+ var dx = mouseEvent.X - dragPosition.Value.X;
+ var dy = mouseEvent.Y - dragPosition.Value.Y;
var nx = Frame.X + dx;
var ny = Frame.Y + dy;
@@ -1110,7 +1115,7 @@ namespace Terminal.Gui {
ny = 0;
//Demo.ml2.Text = $"{dx},{dy}";
- dragPosition = new Point (me.X, me.Y);
+ dragPosition = new Point (mouseEvent.X, mouseEvent.Y);
// TODO: optimize, only SetNeedsDisplay on the before/after regions.
if (SuperView == null)
@@ -1122,8 +1127,8 @@ namespace Terminal.Gui {
return true;
} else {
// Only start grabbing if the user clicks on the title bar.
- if (me.Y == 0) {
- dragPosition = new Point (me.X, me.Y);
+ if (mouseEvent.Y == 0) {
+ dragPosition = new Point (mouseEvent.X, mouseEvent.Y);
Application.GrabMouse (this);
}
@@ -1132,7 +1137,7 @@ namespace Terminal.Gui {
}
}
- if (me.Flags == MouseFlags.Button1Released) {
+ if (mouseEvent.Flags == MouseFlags.Button1Released) {
Application.UngrabMouse ();
Driver.UncookMouse ();
diff --git a/Terminal.Gui/MonoCurses/mainloop.cs b/Terminal.Gui/MonoCurses/mainloop.cs
index f5e6bfee5..9fe55988a 100644
--- a/Terminal.Gui/MonoCurses/mainloop.cs
+++ b/Terminal.Gui/MonoCurses/mainloop.cs
@@ -25,7 +25,6 @@
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-using Mono.Unix.Native;
using System.Collections.Generic;
using System;
using System.Runtime.InteropServices;
@@ -38,10 +37,10 @@ namespace Mono.Terminal {
///
public class MainLoop {
///
- /// Condition on which to wake up from file descriptor activity
+ /// Condition on which to wake up from file descriptor activity. These match the Linux/BSD poll definitions.
///
[Flags]
- public enum Condition {
+ public enum Condition : short {
///
/// There is data to read
///
@@ -49,11 +48,11 @@ namespace Mono.Terminal {
///
/// Writing to the specified descriptor will not block
///
- PollOut = 2,
+ PollOut = 4,
///
/// There is urgent data to read
///
- PollPri = 4,
+ PollPri = 2,
///
/// Error condition on output
///
@@ -82,7 +81,25 @@ namespace Mono.Terminal {
Dictionary descriptorWatchers = new Dictionary();
SortedList timeouts = new SortedList ();
List> idleHandlers = new List> ();
-
+
+ [StructLayout(LayoutKind.Sequential)]
+ struct Pollfd {
+ public int fd;
+ public short events, revents;
+ }
+
+ [DllImport ("libc")]
+ extern static int poll ([In,Out]Pollfd[] ufds, uint nfds, int timeout);
+
+ [DllImport ("libc")]
+ extern static int pipe ([In,Out]int [] pipes);
+
+ [DllImport ("libc")]
+ extern static int read (int fd, IntPtr buf, IntPtr n);
+
+ [DllImport ("libc")]
+ extern static int write (int fd, IntPtr buf, IntPtr n);
+
Pollfd [] pollmap;
bool poll_dirty = true;
int [] wakeupPipes = new int [2];
@@ -93,16 +110,16 @@ namespace Mono.Terminal {
///
public MainLoop ()
{
- Syscall.pipe (wakeupPipes);
+ pipe (wakeupPipes);
AddWatch (wakeupPipes [0], Condition.PollIn, ml => {
- Syscall.read (wakeupPipes [0], ignore, 1);
+ read (wakeupPipes [0], ignore, (IntPtr) 1);
return true;
});
}
void Wakeup ()
{
- Syscall.write (wakeupPipes [1], ignore, 1);
+ write (wakeupPipes [1], ignore, (IntPtr) 1);
}
///
@@ -214,24 +231,6 @@ namespace Mono.Terminal {
timeouts.RemoveAt (idx);
}
- static PollEvents MapCondition (Condition condition)
- {
- PollEvents ret = 0;
- if ((condition & Condition.PollIn) != 0)
- ret |= PollEvents.POLLIN;
- if ((condition & Condition.PollOut) != 0)
- ret |= PollEvents.POLLOUT;
- if ((condition & Condition.PollPri) != 0)
- ret |= PollEvents.POLLPRI;
- if ((condition & Condition.PollErr) != 0)
- ret |= PollEvents.POLLERR;
- if ((condition & Condition.PollHup) != 0)
- ret |= PollEvents.POLLHUP;
- if ((condition & Condition.PollNval) != 0)
- ret |= PollEvents.POLLNVAL;
- return ret;
- }
-
void UpdatePollMap ()
{
if (!poll_dirty)
@@ -242,7 +241,7 @@ namespace Mono.Terminal {
int i = 0;
foreach (var fd in descriptorWatchers.Keys){
pollmap [i].fd = fd;
- pollmap [i].events = MapCondition (descriptorWatchers [fd].Condition);
+ pollmap [i].events = (short) descriptorWatchers [fd].Condition;
i++;
}
}
@@ -310,7 +309,7 @@ namespace Mono.Terminal {
UpdatePollMap ();
- n = Syscall.poll (pollmap, (uint) pollmap.Length, pollTimeout);
+ n = poll (pollmap, (uint) pollmap.Length, pollTimeout);
int ic;
lock (idleHandlers)
ic = idleHandlers.Count;
diff --git a/Terminal.Gui/Terminal.Gui.csproj b/Terminal.Gui/Terminal.Gui.csproj
index 97bdf464d..5a0ba7a64 100644
--- a/Terminal.Gui/Terminal.Gui.csproj
+++ b/Terminal.Gui/Terminal.Gui.csproj
@@ -30,7 +30,6 @@
-
..\packages\System.ValueTuple.4.4.0\lib\net461\System.ValueTuple.dll
diff --git a/Terminal.Gui/Views/Button.cs b/Terminal.Gui/Views/Button.cs
index 430eb9895..eaa8a1af1 100644
--- a/Terminal.Gui/Views/Button.cs
+++ b/Terminal.Gui/Views/Button.cs
@@ -61,7 +61,8 @@ namespace Terminal.Gui {
/// The size of the button is computed based on the
/// text length. This button is not a default button.
///
- public Button (string s) : this (0, 0, s) { }
+ /// The button's text
+ public Button (string text) : this (0, 0, text) { }
///
/// Public constructor, creates a button based on
@@ -72,7 +73,9 @@ namespace Terminal.Gui {
/// decoration is used, and the enter key on a
/// dialog would implicitly activate this button.
///
- public Button (string s, bool is_default) : this (0, 0, s, is_default) { }
+ /// The button's text
+ /// If set, this makes the button the default button in the current view, which means that if the user presses return on a view that does not handle return, it will be treated as if he had clicked on the button
+ public Button (string text, bool is_default) : this (0, 0, text, is_default) { }
///
/// Public constructor, creates a button based on
@@ -82,7 +85,10 @@ namespace Terminal.Gui {
/// The size of the button is computed based on the
/// text length. This button is not a default button.
///
- public Button (int x, int y, string s) : this (x, y, s, false) { }
+ /// X position where the button will be shown.
+ /// Y position where the button will be shown.
+ /// The button's text
+ public Button (int x, int y, string text) : this (x, y, text, false) { }
///
/// The text displayed by this widget.
@@ -128,13 +134,17 @@ namespace Terminal.Gui {
/// decoration is used, and the enter key on a
/// dialog would implicitly activate this button.
///
- public Button (int x, int y, string s, bool is_default)
- : base (new Rect (x, y, s.Length + 4 + (is_default ? 2 : 0), 1))
+ /// X position where the button will be shown.
+ /// Y position where the button will be shown.
+ /// The button's text
+ /// If set, this makes the button the default button in the current view, which means that if the user presses return on a view that does not handle return, it will be treated as if he had clicked on the button
+ public Button (int x, int y, string text, bool is_default)
+ : base (new Rect (x, y, text.Length + 4 + (is_default ? 2 : 0), 1))
{
CanFocus = true;
this.IsDefault = is_default;
- Text = s;
+ Text = text;
}
public override void Redraw (Rect region)
diff --git a/Terminal.Gui/Views/FrameView.cs b/Terminal.Gui/Views/FrameView.cs
index 5a0979a05..01aedd5fd 100644
--- a/Terminal.Gui/Views/FrameView.cs
+++ b/Terminal.Gui/Views/FrameView.cs
@@ -69,7 +69,7 @@ namespace Terminal.Gui {
///
///
///
- public virtual void Remove (View view)
+ public override void Remove (View view)
{
if (view == null)
return;
diff --git a/Terminal.Gui/Views/ListView.cs b/Terminal.Gui/Views/ListView.cs
index 437f35efe..31172428f 100644
--- a/Terminal.Gui/Views/ListView.cs
+++ b/Terminal.Gui/Views/ListView.cs
@@ -70,7 +70,7 @@ namespace Terminal.Gui {
/// and optionally mark elements of the list (controlled by the AllowsMark property).
///
///
- /// The ListView can either render an arbitrary IList object (for example, arrays, List
+ /// The ListView can either render an arbitrary IList object (for example, arrays, List<T>
/// and other collections) which are drawn by drawing the string/ustring contents or the
/// result of calling ToString(). Alternatively, you can provide you own IListDataSource
/// object that gives you full control of what is rendered.