OSDN Git Service

桁折モード有効時に行単位で移動するようにした
authortest <test@yahoo.co.jp>
Mon, 14 Dec 2020 11:46:14 +0000 (20:46 +0900)
committertest <test@yahoo.co.jp>
Mon, 14 Dec 2020 11:46:14 +0000 (20:46 +0900)
Core/Controller.cs

index 3907808..f2a8f4c 100644 (file)
@@ -854,19 +854,31 @@ namespace FooEditEngine
         /// <returns>移動後のキャレット位置</returns>
         public TextPoint GetTextPointAfterMoveLine(int count, TextPoint current)
         {
-            int row = current.row + count;
+            if(this.Document.LineBreak == LineBreakMethod.None)
+            {
+                int row = current.row + count;
 
-            if (row < 0)
-                row = 0;
-            else if (row >= this.View.LayoutLines.Count)
-                row = this.View.LayoutLines.Count - 1;
+                if (row < 0)
+                    row = 0;
+                else if (row >= this.View.LayoutLines.Count)
+                    row = this.View.LayoutLines.Count - 1;
 
-            row = this.View.AdjustRow(row, count > 0);
+                row = this.View.AdjustRow(row, count > 0);
 
-            Point pos = this.View.LayoutLines.GetLayout(current.row).GetPostionFromIndex(current.col);
-            int col = this.View.LayoutLines.GetLayout(row).GetIndexFromPostion(pos.X, pos.Y);
+                Point pos = this.View.LayoutLines.GetLayout(current.row).GetPostionFromIndex(current.col);
+                int col = this.View.LayoutLines.GetLayout(row).GetIndexFromPostion(pos.X, pos.Y);
+                return new TextPoint(row, col);
+            }
+            else
+            {
+                Point pos = this.View.GetPostionFromTextPoint(current);
+                pos.Y += this.View.render.emSize.Height * count;
+                //この値を足さないとうまく動作しない
+                pos.Y += this.View.render.emSize.Height / 2;   
+                var new_tp = this.View.GetTextPointFromPostion(pos,TextPointSearchRange.Full);
+                return new_tp;
 
-            return new TextPoint(row, col);
+            }
         }