aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael <[email protected]>2017-08-08 11:29:03 -0400
committerMichael <[email protected]>2017-08-08 11:29:03 -0400
commit72fe64f28d02cf41aa90b636608421e9b86ab896 (patch)
treec689da52c270ca3f04ebfa26ebbb4f3b42ec079a
parent950b31ace3b599b40528d7fc030dfb9d6a342932 (diff)
downloadshiftos_thereturn-72fe64f28d02cf41aa90b636608421e9b86ab896.tar.gz
shiftos_thereturn-72fe64f28d02cf41aa90b636608421e9b86ab896.tar.bz2
shiftos_thereturn-72fe64f28d02cf41aa90b636608421e9b86ab896.zip
Block enter in terminal
-rw-r--r--ShiftOS.Frontend/Apps/Terminal.cs95
-rw-r--r--ShiftOS.Frontend/GUI/TextInput.cs2
-rw-r--r--ShiftOS.Frontend/GraphicsSubsystem/GraphicsContext.cs2
3 files changed, 53 insertions, 46 deletions
diff --git a/ShiftOS.Frontend/Apps/Terminal.cs b/ShiftOS.Frontend/Apps/Terminal.cs
index ff06dd0..6d01d9f 100644
--- a/ShiftOS.Frontend/Apps/Terminal.cs
+++ b/ShiftOS.Frontend/Apps/Terminal.cs
@@ -199,9 +199,12 @@ namespace ShiftOS.Frontend.Apps
private PointF CaretPosition = new PointF(2, 2);
private Size CaretSize = new Size(2, 15);
+ private bool doEnter = true;
protected override void OnKeyEvent(KeyEvent a)
{
+ if (a.Key != Keys.Enter)
+ doEnter = true;
if (a.ControlDown && (a.Key == Keys.OemPlus || a.Key == Keys.Add))
{
_zoomFactor *= 2;
@@ -221,66 +224,70 @@ namespace ShiftOS.Frontend.Apps
if (a.Key == Keys.Enter && !ReadOnly)
{
- if (!PerformTerminalBehaviours)
+ if (doEnter == true)
{
- Text = Text.Insert(Index, Environment.NewLine);
- Index += 2;
- RecalculateLayout();
- Invalidate();
- return;
- }
-
- try
- {
- if (!TerminalBackend.PrefixEnabled)
+ if (!PerformTerminalBehaviours)
{
- string textraw = Lines[Lines.Length - 1];
- TerminalBackend.SendText(textraw);
+ Text = Text.Insert(Index, Environment.NewLine);
+ Index += 2;
+ RecalculateLayout();
+ Invalidate();
return;
}
- var text = Lines;
- var text2 = text[text.Length - 1];
- var text3 = "";
- var text4 = Regex.Replace(text2, @"\t|\n|\r", "");
- WriteLine("");
- if (TerminalBackend.PrefixEnabled)
+ try
{
- text3 = text4.Remove(0, TerminalBackend.ShellOverride.Length);
- }
- if (!string.IsNullOrWhiteSpace(text3))
- {
- TerminalBackend.LastCommand = text3;
- TerminalBackend.SendText(text4);
- if (TerminalBackend.InStory == false)
+ if (!TerminalBackend.PrefixEnabled)
{
- {
- var result = SkinEngine.LoadedSkin.CurrentParser.ParseCommand(text3);
+ string textraw = Lines[Lines.Length - 1];
+ TerminalBackend.SendText(textraw);
+ return;
+ }
+ var text = Lines;
+ var text2 = text[text.Length - 1];
+ var text3 = "";
+ var text4 = Regex.Replace(text2, @"\t|\n|\r", "");
+ WriteLine("");
- if (result.Equals(default(KeyValuePair<string, Dictionary<string, string>>)))
- {
- Console.WriteLine("{ERR_SYNTAXERROR}");
- }
- else
+ if (TerminalBackend.PrefixEnabled)
+ {
+ text3 = text4.Remove(0, TerminalBackend.ShellOverride.Length);
+ }
+ if (!string.IsNullOrWhiteSpace(text3))
+ {
+ TerminalBackend.LastCommand = text3;
+ TerminalBackend.SendText(text4);
+ if (TerminalBackend.InStory == false)
+ {
{
- TerminalBackend.InvokeCommand(result.Key, result.Value);
- }
+ var result = SkinEngine.LoadedSkin.CurrentParser.ParseCommand(text3);
+ if (result.Equals(default(KeyValuePair<string, Dictionary<string, string>>)))
+ {
+ Console.WriteLine("{ERR_SYNTAXERROR}");
+ }
+ else
+ {
+ TerminalBackend.InvokeCommand(result.Key, result.Value);
+ }
+
+ }
}
}
}
- }
- catch
- {
- }
- finally
- {
- if (TerminalBackend.PrefixEnabled)
+ catch
{
- TerminalBackend.PrintPrompt();
}
- AppearanceManager.CurrentPosition = 0;
+ finally
+ {
+ if (TerminalBackend.PrefixEnabled)
+ {
+ TerminalBackend.PrintPrompt();
+ }
+ AppearanceManager.CurrentPosition = 0;
+ }
+ doEnter = false;
}
}
else if (a.Key == Keys.Back && !ReadOnly)
diff --git a/ShiftOS.Frontend/GUI/TextInput.cs b/ShiftOS.Frontend/GUI/TextInput.cs
index 36e21b1..1733a6a 100644
--- a/ShiftOS.Frontend/GUI/TextInput.cs
+++ b/ShiftOS.Frontend/GUI/TextInput.cs
@@ -72,6 +72,8 @@ namespace ShiftOS.Frontend.GUI
protected override void OnKeyEvent(KeyEvent e)
{
+ if (e.Key == Microsoft.Xna.Framework.Input.Keys.Enter)
+ return;
if(e.Key == Microsoft.Xna.Framework.Input.Keys.Left)
{
if (_index > 0)
diff --git a/ShiftOS.Frontend/GraphicsSubsystem/GraphicsContext.cs b/ShiftOS.Frontend/GraphicsSubsystem/GraphicsContext.cs
index e6479e9..df9c064 100644
--- a/ShiftOS.Frontend/GraphicsSubsystem/GraphicsContext.cs
+++ b/ShiftOS.Frontend/GraphicsSubsystem/GraphicsContext.cs
@@ -209,8 +209,6 @@ namespace ShiftOS.Frontend.GraphicsSubsystem
}
}
-
-
public class TextCache
{
public string Text { get; set; }