aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS.Frontend/GUI/TextInput.cs
diff options
context:
space:
mode:
authorMichael <[email protected]>2017-07-03 22:03:58 -0400
committerMichael <[email protected]>2017-07-03 22:03:58 -0400
commitd23c5cc29dc47537d1cf6069f27009750fd80919 (patch)
tree971c8db7c7ef08c5efa1d867b98bfc01b2096f97 /ShiftOS.Frontend/GUI/TextInput.cs
parent23e622ffc37fa7b2f5c21378b60912af46289575 (diff)
downloadshiftos_thereturn-d23c5cc29dc47537d1cf6069f27009750fd80919.tar.gz
shiftos_thereturn-d23c5cc29dc47537d1cf6069f27009750fd80919.tar.bz2
shiftos_thereturn-d23c5cc29dc47537d1cf6069f27009750fd80919.zip
HELP ME. I can't get autoscroll working in terminall.
Diffstat (limited to 'ShiftOS.Frontend/GUI/TextInput.cs')
-rw-r--r--ShiftOS.Frontend/GUI/TextInput.cs42
1 files changed, 42 insertions, 0 deletions
diff --git a/ShiftOS.Frontend/GUI/TextInput.cs b/ShiftOS.Frontend/GUI/TextInput.cs
index e59e927..c4e5260 100644
--- a/ShiftOS.Frontend/GUI/TextInput.cs
+++ b/ShiftOS.Frontend/GUI/TextInput.cs
@@ -17,6 +17,48 @@ namespace ShiftOS.Frontend.GUI
private int _index = 0;
private Font _font = new Font("Tahoma", 9f);
+ public int Index
+ {
+ get
+ {
+ return _index;
+ }
+ set
+ {
+ if (_index == value)
+ return;
+ if(_text.Length == 0)
+ {
+ _index = 0;
+ return;
+ }
+ _index = MathHelper.Clamp(value, 0, _text.Length - 1);
+ if (_text[_index] == '\n')
+ _index++;
+ Invalidate();
+ }
+ }
+
+ public string Text
+ {
+ get
+ {
+ return _text;
+ }
+ set
+ {
+ if (_text == value)
+ return;
+
+ _text = value;
+ if(_index >= _text.Length)
+ {
+ _index = _text.Length - 1;
+ }
+ Invalidate();
+ }
+ }
+
protected override void OnKeyEvent(KeyEvent e)
{
if(e.Key == Microsoft.Xna.Framework.Input.Keys.Left)