/// <param name="changeAnchor">選択の起点となるとインデックスを変更するなら真。そうでなければ偽</param>
public void SelectWord(int index, bool changeAnchor = false)
{
+ this.SelectSepartor(index, (c) => Util.IsWordSeparator(c), changeAnchor);
+ }
+
+ /// <summary>
+ /// 行単位で選択する
+ /// </summary>
+ /// <param name="index">探索を開始するインデックス</param>
+ /// <param name="changeAnchor">選択の起点となるとインデックスを変更するなら真。そうでなければ偽</param>
+ public void SelectLine(int index,bool changeAnchor = false)
+ {
+ this.SelectSepartor(index, (c) => c == Document.NewLine, changeAnchor);
+ }
+
+ /// <summary>
+ /// セパレーターで囲まれた範囲内を選択する
+ /// </summary>
+ /// <param name="index">探索を開始するインデックス</param>
+ /// <param name="find_sep_func">セパレーターなら真を返し、そうでないなら偽を返す</param>
+ /// <param name="changeAnchor">選択の起点となるとインデックスを変更するなら真。そうでなければ偽</param>
+ public void SelectSepartor(int index,Func<char,bool> find_sep_func, bool changeAnchor = false)
+ {
if (this.FireUpdateEvent == false)
throw new InvalidOperationException("");
+ if (find_sep_func == null)
+ throw new ArgumentNullException("find_sep_func must not be null");
+
if (this.Length <= 0 || index >= this.Length)
return;
Document str = this;
int start = index;
- while (start > 0 && !Util.IsWordSeparator(str[start]))
+ while (start > 0 && !find_sep_func(str[start]))
start--;
- if (Util.IsWordSeparator(str[start]))
+ if (find_sep_func(str[start]))
start++;
int end = index;
- while (end < this.Length && !Util.IsWordSeparator(str[end]))
+ while (end < this.Length && !find_sep_func(str[end]))
end++;
this.Select(start, end - start);
this.Document.SelectGrippers.BottomLeft.Enabled = false;
this.Document.SelectGrippers.BottomRight.Enabled = touched;
this.JumpCaret(e.Position);
- if (e.TapCount == 2)
+ if(e.TapCount == 2)
{
+ //タッチスクリーンでトリプルタップした場合、アンカーインデックスを単語の先頭にしないとバグる
this.Document.SelectGrippers.BottomLeft.Enabled = touched;
- //タッチスクリーンでダブルタップした場合、アンカーインデックスを単語の先頭にしないとバグる
- this.Document.SelectWord(this.Controller.SelectionStart, touched);
+ if (e.Position.X < this.Render.TextArea.X)
+ this.Document.SelectLine(this.Controller.SelectionStart, touched);
+ else
+ this.Document.SelectWord(this.Controller.SelectionStart, touched);
this.Refresh();
}
}
if (e.LeftButton == MouseButtonState.Pressed)
{
+ if (p.X < this.Render.TextArea.X)
+ this.Document.SelectLine((int)index);
+ else
+ this.Document.SelectWord((int)index);
- this.Document.SelectWord((int)index);
this.textStore.NotifySelectionChanged();
if(this.peer != null)
this.peer.OnNotifyCaretChanged();