From 854f2f732acc4c1d9fa4126962149cae14f4d4e9 Mon Sep 17 00:00:00 2001 From: jpbruyere Date: Sun, 14 Aug 2016 03:45:57 +0200 Subject: * 0.crow, 1.crow, 2.crow, 5.crow, 7.crow: tests * GraphicObject.cs: enabled, code clean and naming conventions * Label.cs, TextBox.cs: debug * Interface.cs: keyboard repeat --- src/GraphicObjects/TextBox.cs | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) (limited to 'src/GraphicObjects/TextBox.cs') diff --git a/src/GraphicObjects/TextBox.cs b/src/GraphicObjects/TextBox.cs index 81fce3e2..2be9585a 100644 --- a/src/GraphicObjects/TextBox.cs +++ b/src/GraphicObjects/TextBox.cs @@ -76,14 +76,17 @@ namespace Crow switch (key) { case Key.Back: + if (CurrentPosition == 0) + return; this.DeleteChar(); break; case Key.Clear: break; case Key.Delete: - if (selectionIsEmpty) - CurrentColumn++; - else if (e.Shift) + if (selectionIsEmpty) { + if (!MoveRight ()) + return; + }else if (e.Shift) Interface.CurrentInterface.Clipboard = this.SelectedText; this.DeleteChar (); break; @@ -119,11 +122,11 @@ namespace Crow case Key.End: if (e.Shift) { if (selectionIsEmpty) - SelBegin = new Point (CurrentColumn, CurrentLine); + SelBegin = CurrentPosition; if (e.Control) CurrentLine = int.MaxValue; CurrentColumn = int.MaxValue; - SelRelease = new Point (CurrentColumn, CurrentLine); + SelRelease = CurrentPosition; break; } SelRelease = -1; @@ -134,7 +137,7 @@ namespace Crow case Key.Insert: if (e.Shift) this.Insert (Interface.CurrentInterface.Clipboard); - else if (e.Control) + else if (e.Control && !selectionIsEmpty) Interface.CurrentInterface.Clipboard = this.SelectedText; break; case Key.Left: @@ -143,40 +146,40 @@ namespace Crow SelBegin = new Point(CurrentColumn, CurrentLine); if (e.Control) GotoWordStart (); - else - CurrentColumn--; - SelRelease = new Point(CurrentColumn, CurrentLine); + else if (!MoveLeft ()) + return; + SelRelease = CurrentPosition; break; } SelRelease = -1; if (e.Control) GotoWordStart (); else - CurrentColumn--; + MoveLeft(); break; case Key.Right: if (e.Shift) { if (selectionIsEmpty) - SelBegin = new Point(CurrentColumn, CurrentLine); + SelBegin = CurrentPosition; if (e.Control) GotoWordEnd (); - else - CurrentColumn++; - SelRelease = new Point(CurrentColumn, CurrentLine); + else if (!MoveRight ()) + return; + SelRelease = CurrentPosition; break; } SelRelease = -1; if (e.Control) GotoWordEnd (); else - CurrentColumn++; + MoveRight (); break; case Key.Up: if (e.Shift) { if (selectionIsEmpty) - SelBegin = new Point(CurrentColumn, CurrentLine); + SelBegin = CurrentPosition; CurrentLine--; - SelRelease = new Point(CurrentColumn, CurrentLine); + SelRelease = CurrentPosition; break; } SelRelease = -1; @@ -185,9 +188,9 @@ namespace Crow case Key.Down: if (e.Shift) { if (selectionIsEmpty) - SelBegin = new Point(CurrentColumn, CurrentLine); + SelBegin = CurrentPosition; CurrentLine++; - SelRelease = new Point(CurrentColumn, CurrentLine); + SelRelease = CurrentPosition; break; } SelRelease = -1; -- cgit v1.3.1-4-g156e