@@ -570,6 +570,19 @@ public string SelectedText
570
570
/// </summary>
571
571
public bool Used { get ; set ; }
572
572
573
+ /// <summary>
574
+ /// Gets or sets whether the word forward and word backward navigation should use the same or equivalent rune type.
575
+ /// Default is <c>false</c> meaning using equivalent rune type.
576
+ /// </summary>
577
+ public bool UseSameRuneTypeForWords { get ; set ; }
578
+
579
+ /// <summary>
580
+ /// Gets or sets whether the word navigation should select only the word itself without spaces around it or with the
581
+ /// spaces at right.
582
+ /// Default is <c>false</c> meaning that the spaces at right are included in the selection.
583
+ /// </summary>
584
+ public bool SelectWordOnlyOnDoubleClick { get ; set ; }
585
+
573
586
/// <summary>Clear the selected text.</summary>
574
587
public void ClearAllSelection ( )
575
588
{
@@ -754,7 +767,7 @@ public void InsertText (string toAdd, bool useOldCursorPos = true)
754
767
public virtual void KillWordBackwards ( )
755
768
{
756
769
ClearAllSelection ( ) ;
757
- ( int col , int row ) ? newPos = GetModel ( ) . WordBackward ( _cursorPosition , 0 ) ;
770
+ ( int col , int row ) ? newPos = GetModel ( ) . WordBackward ( _cursorPosition , 0 , UseSameRuneTypeForWords ) ;
758
771
759
772
if ( newPos is null )
760
773
{
@@ -777,7 +790,7 @@ public virtual void KillWordBackwards ()
777
790
public virtual void KillWordForwards ( )
778
791
{
779
792
ClearAllSelection ( ) ;
780
- ( int col , int row ) ? newPos = GetModel ( ) . WordForward ( _cursorPosition , 0 ) ;
793
+ ( int col , int row ) ? newPos = GetModel ( ) . WordForward ( _cursorPosition , 0 , UseSameRuneTypeForWords ) ;
781
794
782
795
if ( newPos is null )
783
796
{
@@ -857,43 +870,15 @@ protected override bool OnMouseEvent (MouseEventArgs ev)
857
870
{
858
871
EnsureHasFocus ( ) ;
859
872
int x = PositionCursor ( ev ) ;
860
- int sbw = x ;
873
+ ( int startCol , int col , int row ) ? newPos = GetModel ( ) . ProcessDoubleClickSelection ( x , x , 0 , UseSameRuneTypeForWords , SelectWordOnlyOnDoubleClick ) ;
861
874
862
- if ( x == _text . Count
863
- || ( x > 0 && ( char ) _text [ x - 1 ] . Value != ' ' )
864
- || ( x > 0 && ( char ) _text [ x ] . Value == ' ' ) )
865
- {
866
- ( int col , int row ) ? newPosBw = GetModel ( ) . WordBackward ( x , 0 ) ;
867
-
868
- if ( newPosBw is null )
869
- {
870
- return true ;
871
- }
872
-
873
- sbw = newPosBw . Value . col ;
874
- }
875
-
876
- if ( sbw != - 1 )
877
- {
878
- x = sbw ;
879
- PositionCursor ( x ) ;
880
- }
881
-
882
- ( int col , int row ) ? newPosFw = GetModel ( ) . WordForward ( x , 0 ) ;
883
-
884
- if ( newPosFw is null )
875
+ if ( newPos is null )
885
876
{
886
877
return true ;
887
878
}
888
879
889
- ClearAllSelection ( ) ;
890
-
891
- if ( newPosFw . Value . col != - 1 && sbw != - 1 )
892
- {
893
- _cursorPosition = newPosFw . Value . col ;
894
- }
895
-
896
- PrepareSelection ( sbw , newPosFw . Value . col - sbw ) ;
880
+ SelectedStart = newPos . Value . startCol ;
881
+ CursorPosition = newPos . Value . col ;
897
882
}
898
883
else if ( ev . Flags == MouseFlags . Button1TripleClicked )
899
884
{
@@ -1502,7 +1487,7 @@ private void MoveRightExtend ()
1502
1487
private void MoveWordLeft ( )
1503
1488
{
1504
1489
ClearAllSelection ( ) ;
1505
- ( int col , int row ) ? newPos = GetModel ( ) . WordBackward ( _cursorPosition , 0 ) ;
1490
+ ( int col , int row ) ? newPos = GetModel ( ) . WordBackward ( _cursorPosition , 0 , UseSameRuneTypeForWords ) ;
1506
1491
1507
1492
if ( newPos is null )
1508
1493
{
@@ -1528,7 +1513,7 @@ private void MoveWordLeftExtend ()
1528
1513
1529
1514
if ( x > 0 )
1530
1515
{
1531
- ( int col , int row ) ? newPos = GetModel ( ) . WordBackward ( x , 0 ) ;
1516
+ ( int col , int row ) ? newPos = GetModel ( ) . WordBackward ( x , 0 , UseSameRuneTypeForWords ) ;
1532
1517
1533
1518
if ( newPos is null )
1534
1519
{
@@ -1548,7 +1533,7 @@ private void MoveWordLeftExtend ()
1548
1533
private void MoveWordRight ( )
1549
1534
{
1550
1535
ClearAllSelection ( ) ;
1551
- ( int col , int row ) ? newPos = GetModel ( ) . WordForward ( _cursorPosition , 0 ) ;
1536
+ ( int col , int row ) ? newPos = GetModel ( ) . WordForward ( _cursorPosition , 0 , UseSameRuneTypeForWords ) ;
1552
1537
1553
1538
if ( newPos is null )
1554
1539
{
@@ -1568,7 +1553,7 @@ private void MoveWordRightExtend ()
1568
1553
if ( _cursorPosition < _text . Count )
1569
1554
{
1570
1555
int x = _start > - 1 && _start > _cursorPosition ? _start : _cursorPosition ;
1571
- ( int col , int row ) ? newPos = GetModel ( ) . WordForward ( x , 0 ) ;
1556
+ ( int col , int row ) ? newPos = GetModel ( ) . WordForward ( x , 0 , UseSameRuneTypeForWords ) ;
1572
1557
1573
1558
if ( newPos is null )
1574
1559
{
0 commit comments