Fixes #1210. Added AllowsReturn, AllowsTab and Multiline into the TextView. (#1249)

* Fixes #1234. Setting Handled to true in the KeyPress event avoids ProcessKey from running.

* Using literals values in Assert.Equal.

* Can't use numbers variables on the left side of an Assert.Equal/NotEqual, it must be literal (Linux only).

* Fixes #1241. Added SendKeys feature to the ConsoleDriver.

* Fixes SendKeys unit test.

* Changed Key.Null to '\0' (null string).

* Fixes the space bar when there are another previous char.

* Now the drivers are reading up to 255 from ASCII table.

* Fixes CursesDriver and WindowsDriver SendKeys.

* Fixes NetDriver SendKeys.

* Fixed unit test.

* Fixes #1210.  Added AllowsReturn, AllowsTab and Multiline into the TextView.

* Added a Single Line and Multiline toggle to the Text.cs scenario.

* Removing comment.
This commit is contained in:
BDisp
2021-04-27 16:48:35 +01:00
committed by GitHub
parent c4e744a382
commit c27da1b982
15 changed files with 1399 additions and 287 deletions

View File

@@ -226,7 +226,7 @@ namespace Terminal.Gui {
void GetConsoleInputType (ConsoleKeyInfo consoleKeyInfo)
{
InputResult inputResult = new InputResult {
EventType = EventType.key
EventType = EventType.Key
};
ConsoleKeyInfo newConsoleKeyInfo = consoleKeyInfo;
ConsoleKey key = 0;
@@ -280,7 +280,7 @@ namespace Terminal.Gui {
newConsoleKeyInfo = consoleKeyInfo;
break;
}
if (inputResult.EventType == EventType.key) {
if (inputResult.EventType == EventType.Key) {
inputResult.ConsoleKeyInfo = newConsoleKeyInfo;
} else {
inputResult.MouseEvent = mouseEvent;
@@ -440,7 +440,7 @@ namespace Terminal.Gui {
GetMouseEvent (cki);
return;
}
if (inputResult.EventType == EventType.key) {
if (inputResult.EventType == EventType.Key) {
inputResult.ConsoleKeyInfo = newConsoleKeyInfo;
} else {
inputResult.MouseEvent = mouseEvent;
@@ -1010,7 +1010,7 @@ namespace Terminal.Gui {
}
public enum EventType {
key = 1,
Key = 1,
Mouse = 2,
WindowSize = 3,
WindowPosition = 4
@@ -1441,7 +1441,7 @@ namespace Terminal.Gui {
case ConsoleKey.Enter:
return MapKeyModifiers (keyInfo, Key.Enter);
case ConsoleKey.Spacebar:
return MapKeyModifiers (keyInfo, Key.Space);
return MapKeyModifiers (keyInfo, keyInfo.KeyChar == 0 ? Key.Space : (Key)keyInfo.KeyChar);
case ConsoleKey.Backspace:
return MapKeyModifiers (keyInfo, Key.Backspace);
case ConsoleKey.Delete:
@@ -1506,7 +1506,7 @@ namespace Terminal.Gui {
return (Key)((uint)Key.F1 + delta);
}
if (keyInfo.KeyChar != 0) {
return (Key)((uint)keyInfo.KeyChar);
return MapKeyModifiers (keyInfo, (Key)((uint)keyInfo.KeyChar));
}
return (Key)(0xffffffff);
@@ -1557,7 +1557,7 @@ namespace Terminal.Gui {
void ProcessInput (NetEvents.InputResult inputEvent)
{
switch (inputEvent.EventType) {
case NetEvents.EventType.key:
case NetEvents.EventType.Key:
var map = MapKey (inputEvent.ConsoleKeyInfo);
if (map == (Key)0xffffffff) {
return;
@@ -1744,6 +1744,23 @@ namespace Terminal.Gui {
{
return false;
}
public override void SendKeys (char keyChar, ConsoleKey key, bool shift, bool alt, bool control)
{
NetEvents.InputResult input = new NetEvents.InputResult ();
ConsoleKey ck;
if (char.IsLetter (keyChar)) {
ck = key;
} else {
ck = (ConsoleKey)'\0';
}
input.EventType = NetEvents.EventType.Key;
input.ConsoleKeyInfo = new ConsoleKeyInfo (keyChar, ck, shift, alt, control);
try {
ProcessInput (input);
} catch (OverflowException) { }
}
#endregion
//