TextPoint startTextPoint = this.View.GetLayoutLineFromIndex(start);
TextPoint endTextPoint = this.View.GetLayoutLineFromIndex(start + length);
this.SelectByRectangle(new TextRectangle(startTextPoint, endTextPoint));
- if (startTextPoint.col == endTextPoint.col)
- this.View.InsertPoint = new SelectCollection(this.View.Selections);
- else
- this.View.InsertPoint = null;
}
else if(length != 0)
{
this.View.Selections.Add(Selection.Create(start, length));
- this.View.InsertPoint = null;
}
this.SelectionChanged(this, null);
}
this.SelectByRectangle(new TextRectangle(tp,end));
- if (width == 0)
- this.View.InsertPoint = new SelectCollection(this.View.Selections);
- else
- this.View.InsertPoint = null;
-
this.SelectionChanged(this, null);
}
this.Document.UnLock();
}
+ public bool IsRectInsertMode()
+ {
+ if (!this.RectSelection)
+ return false;
+ foreach(Selection sel in this.View.Selections)
+ {
+ if (sel.length != 0)
+ return false;
+ }
+ return true;
+ }
+
/// <summary>
/// キャレット位置の文字を一文字削除し、キャレット位置を後ろにずらす
/// </summary>
public void DoBackSpaceAction()
{
- if (this.View.InsertPoint != null)
+ if (this.IsRectInsertMode())
{
this.ReplaceBeforeSelectionArea(this.View.Selections, 1, "");
return;
if (str == "\t" && this.IndentMode == IndentMode.Space)
str = this.GetIndentSpace(CaretPos.col);
- if (this.View.InsertPoint != null)
+ if (this.IsRectInsertMode())
{
this.ReplaceBeforeSelectionArea(this.View.Selections, 0, str);
return;
this.Select(this.AnchorIndex, CaretPostion - this.AnchorIndex);
}else{
this.AnchorIndex = CaretPostion;
- this.View.InsertPoint = null;
this.Select(CaretPostion, 0);
}
}
if (this.RectSelection == false || this.Document.FireUpdateEvent == false)
throw new InvalidOperationException();
- SelectCollection temp = this.View.InsertPoint;
+ SelectCollection temp = this.View.Selections;
int selectStart = temp.First().start;
int selectEnd = temp.Last().start + temp.Last().length;
}
this.JumpCaret(StartIndex);
if (updateInsertPoint && newInsertPoint.Count > 0)
- this.View.InsertPoint = newInsertPoint;
+ this.View.Selections = newInsertPoint;
}
private string GetTextFromLineSelectArea(SelectCollection Selections)
this.CaretPostion = TextPoint.Null;
this.CaretLocation = new Point(this.render.TextArea.X, this.render.TextArea.Y);
this.LayoutLines.FoldingCollection.StatusChanged += FoldingCollection_StatusChanged;
- this.InsertPoint = null;
this.HideLineMarker = true;
this.IsFocused = false;
this.Selections = new SelectCollection();
internal SelectCollection Selections
{
get;
- private set;
+ set;
}
/// <summary>
}
/// <summary>
- /// 矩形選択モード中に文字列が挿入される位置を表す
- /// </summary>
- public SelectCollection InsertPoint
- {
- get;
- set;
- }
-
- /// <summary>
/// キャレットがある領域を示す
/// </summary>
public Point CaretLocation
pos.Y += this.LayoutLines.GetLayout(i).Height;
}
- if (this.InsertPoint != null)
- this.DrawInsertPoint();
+ this.DrawInsertPoint();
render.CacheContent();
}
void DrawInsertPoint()
{
+ //一つしかない場合は行選択の可能性がある
+ if (this.Selections.Count <= 1)
+ return;
IEditorRender render = (IEditorRender)base.render;
- foreach (Selection sel in this.InsertPoint)
+ foreach (Selection sel in this.Selections)
{
if (sel.length == 0)
{
public static void SetSelectionIndex(Controller controller,EditView view,int i_startIndex, int i_endIndex)
{
- if (controller.RectSelection && view.InsertPoint != null)
+ if (controller.IsRectInsertMode())
{
TextPoint start = view.LayoutLines.GetTextPointFromIndex(i_startIndex);
- TextPoint end = view.LayoutLines.GetTextPointFromIndex(view.InsertPoint.Last().start);
+ TextPoint end = view.LayoutLines.GetTextPointFromIndex(view.Selections.Last().start);
controller.JumpCaret(i_endIndex);
controller.Select(start, i_endIndex - i_startIndex, end.row - start.row);
}
view.LayoutLines[1] == "x\n" &&
view.LayoutLines[2] == "x");
Assert.IsTrue(
- view.InsertPoint[0].start == 0 &&
- view.InsertPoint[1].start == 2 &&
- view.InsertPoint[2].start == 4);
+ view.Selections[0].start == 0 &&
+ view.Selections[1].start == 2 &&
+ view.Selections[2].start == 4);
ctrl.DoInputString("x", true);
Assert.IsTrue(
- view.InsertPoint[0].start == 1 &&
- view.InsertPoint[1].start == 4 &&
- view.InsertPoint[2].start == 7);
+ view.Selections[0].start == 1 &&
+ view.Selections[1].start == 4 &&
+ view.Selections[2].start == 7);
doc.Clear();
doc.Append("a\nb\nc");