|
@@ -302,7 +302,7 @@ namespace Terminal.Gui {
|
|
|
for (int i = 0; i < cki.Length; i++) {
|
|
|
var ck = cki [i];
|
|
|
if (NumberOfCSI > 0 && nCSI - curCSI > NumberOfCSI) {
|
|
|
- if (cki [i + 1].KeyChar == '\x1b' && previousKChar != '\0') {
|
|
|
+ if (i + 1 < cki.Length && cki [i + 1].KeyChar == '\x1b' && previousKChar != '\0') {
|
|
|
curCSI++;
|
|
|
previousKChar = '\0';
|
|
|
} else {
|
|
@@ -506,7 +506,8 @@ namespace Terminal.Gui {
|
|
|
bool isButtonDoubleClicked;
|
|
|
bool isButtonTripleClicked;
|
|
|
bool isProcContBtnPressedRuning;
|
|
|
- bool isButtonReleased;
|
|
|
+ Point point = new Point ();
|
|
|
+ //bool isButtonReleased;
|
|
|
|
|
|
void GetMouseEvent (ConsoleKeyInfo [] cki)
|
|
|
{
|
|
@@ -695,6 +696,7 @@ namespace Terminal.Gui {
|
|
|
mouseEvent.Position.X = point.X;
|
|
|
mouseEvent.Position.Y = point.Y;
|
|
|
mouseEvent.ButtonState = buttonState;
|
|
|
+ //System.Diagnostics.Debug.WriteLine ($"ButtonState: {mouseEvent.ButtonState} X: {mouseEvent.Position.X} Y: {mouseEvent.Position.Y}");
|
|
|
|
|
|
if ((buttonState & MouseButtonState.Button1Pressed) != 0
|
|
|
|| (buttonState & MouseButtonState.Button2Pressed) != 0
|
|
@@ -715,7 +717,10 @@ namespace Terminal.Gui {
|
|
|
if (isButtonClicked && !isButtonDoubleClicked && lastMouseEvent.Position != default && lastMouseEvent.Position == point
|
|
|
&& ((buttonState & MouseButtonState.Button1Pressed) != 0
|
|
|
|| (buttonState & MouseButtonState.Button2Pressed) != 0
|
|
|
- || (buttonState & MouseButtonState.Button3Pressed) != 0)) {
|
|
|
+ || (buttonState & MouseButtonState.Button3Pressed) != 0
|
|
|
+ || (buttonState & MouseButtonState.Button1Released) != 0
|
|
|
+ || (buttonState & MouseButtonState.Button2Released) != 0
|
|
|
+ || (buttonState & MouseButtonState.Button3Released) != 0)) {
|
|
|
isButtonDoubleClicked = true;
|
|
|
ProcessButtonDoubleClicked (mouseEvent);
|
|
|
Application.MainLoop.AddIdle (() => {
|
|
@@ -731,22 +736,25 @@ namespace Terminal.Gui {
|
|
|
if (isButtonDoubleClicked && lastMouseEvent.Position != default && lastMouseEvent.Position == point
|
|
|
&& ((buttonState & MouseButtonState.Button1Pressed) != 0
|
|
|
|| (buttonState & MouseButtonState.Button2Pressed) != 0
|
|
|
- || (buttonState & MouseButtonState.Button3Pressed) != 0)) {
|
|
|
+ || (buttonState & MouseButtonState.Button3Pressed) != 0
|
|
|
+ || (buttonState & MouseButtonState.Button1Released) != 0
|
|
|
+ || (buttonState & MouseButtonState.Button2Released) != 0
|
|
|
+ || (buttonState & MouseButtonState.Button3Released) != 0)) {
|
|
|
isButtonTripleClicked = true;
|
|
|
ProcessButtonTripleClicked (mouseEvent);
|
|
|
inputReady.Set ();
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- if (!isButtonPressed && !isButtonClicked && !isButtonDoubleClicked && !isButtonTripleClicked
|
|
|
- && !isButtonReleased
|
|
|
- && ((buttonState & MouseButtonState.Button1Released) == 0
|
|
|
- && (buttonState & MouseButtonState.Button2Released) == 0
|
|
|
- && (buttonState & MouseButtonState.Button3Released) == 0)) {
|
|
|
- ProcessButtonReleased (lastMouseEvent);
|
|
|
- inputReady.Set ();
|
|
|
- return;
|
|
|
- }
|
|
|
+ //if (!isButtonPressed && !isButtonClicked && !isButtonDoubleClicked && !isButtonTripleClicked
|
|
|
+ // && !isButtonReleased && lastMouseEvent.ButtonState != 0
|
|
|
+ // && ((buttonState & MouseButtonState.Button1Released) == 0
|
|
|
+ // && (buttonState & MouseButtonState.Button2Released) == 0
|
|
|
+ // && (buttonState & MouseButtonState.Button3Released) == 0)) {
|
|
|
+ // ProcessButtonReleased (lastMouseEvent);
|
|
|
+ // inputReady.Set ();
|
|
|
+ // return;
|
|
|
+ //}
|
|
|
|
|
|
inputResultQueue.Enqueue (new InputResult () {
|
|
|
EventType = EventType.Mouse,
|
|
@@ -773,11 +781,21 @@ namespace Terminal.Gui {
|
|
|
|
|
|
lastMouseEvent = mouseEvent;
|
|
|
if (isButtonPressed && !isButtonClicked && !isButtonDoubleClicked && !isButtonTripleClicked && !isProcContBtnPressedRuning) {
|
|
|
- isButtonReleased = false;
|
|
|
- Application.MainLoop.AddIdle (() => {
|
|
|
- ProcessContinuousButtonPressedAsync ().ConfigureAwait (false);
|
|
|
- return false;
|
|
|
- });
|
|
|
+ //isButtonReleased = false;
|
|
|
+ if ((buttonState & MouseButtonState.ReportMousePosition) != 0) {
|
|
|
+ point = new Point ();
|
|
|
+ } else {
|
|
|
+ point = new Point () {
|
|
|
+ X = mouseEvent.Position.X,
|
|
|
+ Y = mouseEvent.Position.Y
|
|
|
+ };
|
|
|
+ }
|
|
|
+ if ((buttonState & MouseButtonState.ReportMousePosition) == 0) {
|
|
|
+ Application.MainLoop.AddIdle (() => {
|
|
|
+ Task.Run (async () => await ProcessContinuousButtonPressedAsync (mouseEvent));
|
|
|
+ return false;
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
inputReady.Set ();
|
|
@@ -799,7 +817,7 @@ namespace Terminal.Gui {
|
|
|
me.ButtonState &= ~MouseButtonState.Button3Released;
|
|
|
me.ButtonState |= MouseButtonState.Button3Clicked;
|
|
|
}
|
|
|
- isButtonReleased = true;
|
|
|
+ //isButtonReleased = true;
|
|
|
|
|
|
inputResultQueue.Enqueue (new InputResult () {
|
|
|
EventType = EventType.Mouse,
|
|
@@ -823,7 +841,7 @@ namespace Terminal.Gui {
|
|
|
me.ButtonState &= ~MouseButtonState.Button3Pressed;
|
|
|
me.ButtonState |= MouseButtonState.Button3DoubleClicked;
|
|
|
}
|
|
|
- isButtonReleased = true;
|
|
|
+ //isButtonReleased = true;
|
|
|
|
|
|
inputResultQueue.Enqueue (new InputResult () {
|
|
|
EventType = EventType.Mouse,
|
|
@@ -847,7 +865,7 @@ namespace Terminal.Gui {
|
|
|
me.ButtonState &= ~MouseButtonState.Button3Pressed;
|
|
|
me.ButtonState |= MouseButtonState.Button3TripleClicked;
|
|
|
}
|
|
|
- isButtonReleased = true;
|
|
|
+ //isButtonReleased = true;
|
|
|
|
|
|
inputResultQueue.Enqueue (new InputResult () {
|
|
|
EventType = EventType.Mouse,
|
|
@@ -855,54 +873,56 @@ namespace Terminal.Gui {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- async Task ProcessContinuousButtonPressedAsync ()
|
|
|
+ async Task ProcessContinuousButtonPressedAsync (MouseEvent mouseEvent)
|
|
|
{
|
|
|
isProcContBtnPressedRuning = true;
|
|
|
- Point point = new Point ();
|
|
|
+ await Task.Delay (200);
|
|
|
while (isButtonPressed) {
|
|
|
- await Task.Delay (200);
|
|
|
+ await Task.Delay (100);
|
|
|
+ var me = new MouseEvent () {
|
|
|
+ Position = new Point (mouseEvent.Position.X, mouseEvent.Position.Y),
|
|
|
+ ButtonState=mouseEvent.ButtonState
|
|
|
+ };
|
|
|
var view = Application.wantContinuousButtonPressedView;
|
|
|
- if (isButtonPressed && !Console.KeyAvailable
|
|
|
- && !isButtonClicked && !isButtonDoubleClicked && !isButtonTripleClicked
|
|
|
- && (view != null || view == null && lastMouseEvent.Position != point)) {
|
|
|
- point = lastMouseEvent.Position;
|
|
|
+ if (view == null) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ if (isButtonPressed && (mouseEvent.ButtonState & MouseButtonState.ReportMousePosition) == 0) {
|
|
|
inputResultQueue.Enqueue (new InputResult () {
|
|
|
EventType = EventType.Mouse,
|
|
|
- MouseEvent = lastMouseEvent
|
|
|
+ MouseEvent = me
|
|
|
});
|
|
|
inputReady.Set ();
|
|
|
- } else {
|
|
|
- break;
|
|
|
}
|
|
|
}
|
|
|
isProcContBtnPressedRuning = false;
|
|
|
//isButtonPressed = false;
|
|
|
}
|
|
|
|
|
|
- void ProcessButtonReleased (MouseEvent mouseEvent)
|
|
|
- {
|
|
|
- var me = new MouseEvent () {
|
|
|
- Position = mouseEvent.Position,
|
|
|
- ButtonState = mouseEvent.ButtonState
|
|
|
- };
|
|
|
- if ((mouseEvent.ButtonState & MouseButtonState.Button1Pressed) != 0) {
|
|
|
- me.ButtonState &= ~(MouseButtonState.Button1Pressed | MouseButtonState.ReportMousePosition);
|
|
|
- me.ButtonState |= MouseButtonState.Button1Released;
|
|
|
- } else if ((mouseEvent.ButtonState & MouseButtonState.Button2Pressed) != 0) {
|
|
|
- me.ButtonState &= ~(MouseButtonState.Button2Pressed | MouseButtonState.ReportMousePosition);
|
|
|
- me.ButtonState |= MouseButtonState.Button2Released;
|
|
|
- } else if ((mouseEvent.ButtonState & MouseButtonState.Button3Pressed) != 0) {
|
|
|
- me.ButtonState &= ~(MouseButtonState.Button3Pressed | MouseButtonState.ReportMousePosition);
|
|
|
- me.ButtonState |= MouseButtonState.Button3Released;
|
|
|
- }
|
|
|
- isButtonReleased = true;
|
|
|
- lastMouseEvent = me;
|
|
|
-
|
|
|
- inputResultQueue.Enqueue (new InputResult () {
|
|
|
- EventType = EventType.Mouse,
|
|
|
- MouseEvent = me
|
|
|
- });
|
|
|
- }
|
|
|
+ //void ProcessButtonReleased (MouseEvent mouseEvent)
|
|
|
+ //{
|
|
|
+ // var me = new MouseEvent () {
|
|
|
+ // Position = mouseEvent.Position,
|
|
|
+ // ButtonState = mouseEvent.ButtonState
|
|
|
+ // };
|
|
|
+ // if ((mouseEvent.ButtonState & MouseButtonState.Button1Pressed) != 0) {
|
|
|
+ // me.ButtonState &= ~(MouseButtonState.Button1Pressed | MouseButtonState.ReportMousePosition);
|
|
|
+ // me.ButtonState |= MouseButtonState.Button1Released;
|
|
|
+ // } else if ((mouseEvent.ButtonState & MouseButtonState.Button2Pressed) != 0) {
|
|
|
+ // me.ButtonState &= ~(MouseButtonState.Button2Pressed | MouseButtonState.ReportMousePosition);
|
|
|
+ // me.ButtonState |= MouseButtonState.Button2Released;
|
|
|
+ // } else if ((mouseEvent.ButtonState & MouseButtonState.Button3Pressed) != 0) {
|
|
|
+ // me.ButtonState &= ~(MouseButtonState.Button3Pressed | MouseButtonState.ReportMousePosition);
|
|
|
+ // me.ButtonState |= MouseButtonState.Button3Released;
|
|
|
+ // }
|
|
|
+ // isButtonReleased = true;
|
|
|
+ // lastMouseEvent = me;
|
|
|
+
|
|
|
+ // inputResultQueue.Enqueue (new InputResult () {
|
|
|
+ // EventType = EventType.Mouse,
|
|
|
+ // MouseEvent = me
|
|
|
+ // });
|
|
|
+ //}
|
|
|
|
|
|
ConsoleModifiers GetConsoleModifiers (uint keyChar)
|
|
|
{
|
|
@@ -1104,7 +1124,7 @@ namespace Terminal.Gui {
|
|
|
} else {
|
|
|
if (CursesDriver.Is_WSL_Platform ()) {
|
|
|
Clipboard = new WSLClipboard ();
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
Clipboard = new CursesClipboard ();
|
|
|
}
|
|
|
}
|