aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRogueAI42 <[email protected]>2017-08-01 17:47:09 +1000
committerRogueAI42 <[email protected]>2017-08-01 17:47:09 +1000
commitaa3de1b749800a6f82f4b04d559af33e0f450610 (patch)
treeec863a0dd86f5d4f3345c45ddcaa28cde0ae1e71
parent1c9767380fca1ecda794b207737d3c4ec4cfaa82 (diff)
downloadshiftos_thereturn-aa3de1b749800a6f82f4b04d559af33e0f450610.tar.gz
shiftos_thereturn-aa3de1b749800a6f82f4b04d559af33e0f450610.tar.bz2
shiftos_thereturn-aa3de1b749800a6f82f4b04d559af33e0f450610.zip
stab in the dark to fix this startup exception
It doesn't actually happen for me. I rewrote GetCurrentLine() to be more consistent with the rest of the codebase about newlines, hopefully this will work for everyone.
-rw-r--r--ShiftOS.Frontend/Apps/Terminal.cs18
1 files changed, 6 insertions, 12 deletions
diff --git a/ShiftOS.Frontend/Apps/Terminal.cs b/ShiftOS.Frontend/Apps/Terminal.cs
index 5cf899f..0f8ddde 100644
--- a/ShiftOS.Frontend/Apps/Terminal.cs
+++ b/ShiftOS.Frontend/Apps/Terminal.cs
@@ -76,13 +76,14 @@ namespace ShiftOS.Frontend.Apps
Dock = GUI.DockStyle.Fill;
}
+
+ private static readonly string[] delimiters = { Environment.NewLine };
public string[] Lines
{
get
{
- return Text.Split(new[] { Environment.NewLine }, StringSplitOptions.None);
-
+ return Text.Split(delimiters, StringSplitOptions.None);
}
}
@@ -121,18 +122,11 @@ namespace ShiftOS.Frontend.Apps
}
+ private static readonly Regex regexNl = new Regex(Regex.Escape(Environment.NewLine));
+
public int GetCurrentLine()
{
- int line = 0;
- for(int i = 0; i < Index; i++)
- {
- if(Text[i]=='\n')
- {
- line++;
- continue;
- }
- }
- return line;
+ return regexNl.Matches(Text.Substring(0, Index)).Count;
}
float _vertOffset = 0.0f;