@@ -73,7 +73,7 @@ static TextArea()
7373 if ( ! ta . IsReadOnly )
7474 {
7575 e . Client = ta . _imClient ;
76- }
76+ }
7777 } ) ;
7878 }
7979
@@ -627,7 +627,7 @@ public IDisposable AllowCaretOutsideSelection()
627627 /// If the textview can be scrolled.
628628 /// </summary>
629629 /// <param name="line">The line to scroll to.</param>
630- public void ScrollToLine ( int line )
630+ public void ScrollToLine ( int line )
631631 {
632632 var viewPortLines = ( int ) ( this as IScrollable ) . Viewport . Height ;
633633
@@ -1146,8 +1146,8 @@ public TextAreaTextInputMethodClient()
11461146 public override Rect CursorRectangle
11471147 {
11481148 get
1149- {
1150- if ( _textArea == null )
1149+ {
1150+ if ( _textArea == null )
11511151 {
11521152 return default ;
11531153 }
@@ -1175,7 +1175,7 @@ public override string SurroundingText
11751175 {
11761176 get
11771177 {
1178- if ( _textArea == null )
1178+ if ( _textArea == null )
11791179 {
11801180 return default ;
11811181 }
@@ -1190,56 +1190,50 @@ public override string SurroundingText
11901190 }
11911191 }
11921192
1193- public override TextSelection Selection { get ; set ; }
1193+ public override TextSelection Selection
1194+ {
1195+ get => new TextSelection ( _textArea . Caret . Position . Column , _textArea . Caret . Position . Column + _textArea . Selection . Length ) ;
1196+ set
1197+ {
1198+ var selection = _textArea . Selection ;
1199+
1200+ _textArea . Selection = selection . StartSelectionOrSetEndpoint (
1201+ new TextViewPosition ( selection . StartPosition . Line , value . Start ) ,
1202+ new TextViewPosition ( selection . StartPosition . Line , value . End ) ) ;
1203+ }
1204+ }
11941205
11951206 public void SetTextArea ( TextArea textArea )
11961207 {
1197- if ( _textArea != null )
1208+ if ( _textArea != null )
11981209 {
11991210 _textArea . Caret . PositionChanged -= Caret_PositionChanged ;
1200- _textArea . SelectionChanged -= TextArea_SelectionChanged ;
12011211 }
12021212
12031213 _textArea = textArea ;
12041214
1205- if ( _textArea != null )
1215+ if ( _textArea != null )
12061216 {
12071217 _textArea . Caret . PositionChanged += Caret_PositionChanged ;
1208- _textArea . SelectionChanged += TextArea_SelectionChanged ;
12091218 }
12101219
12111220 RaiseTextViewVisualChanged ( ) ;
12121221
12131222 RaiseCursorRectangleChanged ( ) ;
1223+
1224+ RaiseSurroundingTextChanged ( ) ;
12141225 }
12151226
12161227 private void Caret_PositionChanged ( object sender , EventArgs e )
12171228 {
12181229 RaiseCursorRectangleChanged ( ) ;
1219- }
1220-
1221- private void TextArea_SelectionChanged ( object sender , EventArgs e )
1222- {
12231230 RaiseSurroundingTextChanged ( ) ;
1224- }
1225-
1226- public void SelectInSurroundingText ( int start , int end )
1227- {
1228- if ( _textArea == null )
1229- {
1230- return ;
1231- }
1232-
1233- var selection = _textArea . Selection ;
1234-
1235- _textArea . Selection = _textArea . Selection . StartSelectionOrSetEndpoint (
1236- new TextViewPosition ( selection . StartPosition . Line , start ) ,
1237- new TextViewPosition ( selection . StartPosition . Line , end ) ) ;
1231+ RaiseSelectionChanged ( ) ;
12381232 }
12391233
12401234 public override void SetPreeditText ( string text )
12411235 {
1242-
1236+
12431237 }
12441238 }
12451239 }
0 commit comments