@@ -73,7 +73,7 @@ static TextArea()
73
73
if ( ! ta . IsReadOnly )
74
74
{
75
75
e . Client = ta . _imClient ;
76
- }
76
+ }
77
77
} ) ;
78
78
}
79
79
@@ -627,7 +627,7 @@ public IDisposable AllowCaretOutsideSelection()
627
627
/// If the textview can be scrolled.
628
628
/// </summary>
629
629
/// <param name="line">The line to scroll to.</param>
630
- public void ScrollToLine ( int line )
630
+ public void ScrollToLine ( int line )
631
631
{
632
632
var viewPortLines = ( int ) ( this as IScrollable ) . Viewport . Height ;
633
633
@@ -1134,25 +1134,20 @@ public void RaiseScrollInvalidated(EventArgs e)
1134
1134
_logicalScrollable ? . RaiseScrollInvalidated ( e ) ;
1135
1135
}
1136
1136
1137
- private class TextAreaTextInputMethodClient : ITextInputMethodClient
1137
+ private class TextAreaTextInputMethodClient : TextInputMethodClient
1138
1138
{
1139
- private ITextEditable _textEditable ;
1140
1139
private TextArea _textArea ;
1141
1140
1142
1141
public TextAreaTextInputMethodClient ( )
1143
1142
{
1144
1143
1145
1144
}
1146
1145
1147
- public event EventHandler CursorRectangleChanged ;
1148
- public event EventHandler TextViewVisualChanged ;
1149
- public event EventHandler SurroundingTextChanged ;
1150
-
1151
- public Rect CursorRectangle
1146
+ public override Rect CursorRectangle
1152
1147
{
1153
1148
get
1154
- {
1155
- if ( _textArea == null )
1149
+ {
1150
+ if ( _textArea == null )
1156
1151
{
1157
1152
return default ;
1158
1153
}
@@ -1170,97 +1165,75 @@ public Rect CursorRectangle
1170
1165
}
1171
1166
}
1172
1167
1173
- public Visual TextViewVisual => _textArea ;
1168
+ public override Visual TextViewVisual => _textArea ;
1174
1169
1175
- public bool SupportsPreedit => false ;
1170
+ public override bool SupportsPreedit => false ;
1176
1171
1177
- public bool SupportsSurroundingText => true ;
1172
+ public override bool SupportsSurroundingText => true ;
1178
1173
1179
- public TextInputMethodSurroundingText SurroundingText
1174
+ public override string SurroundingText
1180
1175
{
1181
1176
get
1182
1177
{
1183
- if ( _textArea == null )
1178
+ if ( _textArea == null )
1184
1179
{
1185
1180
return default ;
1186
1181
}
1187
1182
1188
1183
var lineIndex = _textArea . Caret . Line ;
1189
1184
1190
- var position = _textArea . Caret . Position ;
1191
-
1192
1185
var documentLine = _textArea . Document . GetLineByNumber ( lineIndex ) ;
1193
1186
1194
1187
var text = _textArea . Document . GetText ( documentLine . Offset , documentLine . Length ) ;
1195
1188
1196
- return new TextInputMethodSurroundingText
1197
- {
1198
- AnchorOffset = 0 ,
1199
- CursorOffset = position . Column ,
1200
- Text = text
1201
- } ;
1189
+ return text ;
1202
1190
}
1203
1191
}
1204
1192
1205
- public ITextEditable TextEditable
1193
+ public override TextSelection Selection
1206
1194
{
1207
- get => _textEditable ;
1208
- set => _textEditable = value ;
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
+ }
1209
1204
}
1210
1205
1211
1206
public void SetTextArea ( TextArea textArea )
1212
1207
{
1213
- if ( _textArea != null )
1208
+ if ( _textArea != null )
1214
1209
{
1215
1210
_textArea . Caret . PositionChanged -= Caret_PositionChanged ;
1216
- _textArea . SelectionChanged -= TextArea_SelectionChanged ;
1217
1211
}
1218
1212
1219
1213
_textArea = textArea ;
1220
1214
1221
- if ( _textArea != null )
1215
+ if ( _textArea != null )
1222
1216
{
1223
1217
_textArea . Caret . PositionChanged += Caret_PositionChanged ;
1224
- _textArea . SelectionChanged += TextArea_SelectionChanged ;
1225
1218
}
1226
1219
1227
- TextViewVisualChanged ? . Invoke ( this , EventArgs . Empty ) ;
1220
+ RaiseTextViewVisualChanged ( ) ;
1228
1221
1229
- CursorRectangleChanged ? . Invoke ( this , EventArgs . Empty ) ;
1230
- }
1231
-
1232
- private void Caret_PositionChanged ( object sender , EventArgs e )
1233
- {
1234
- CursorRectangleChanged ? . Invoke ( this , e ) ;
1235
- }
1222
+ RaiseCursorRectangleChanged ( ) ;
1236
1223
1237
- private void TextArea_SelectionChanged ( object sender , EventArgs e )
1238
- {
1239
- SurroundingTextChanged ? . Invoke ( this , e ) ;
1224
+ RaiseSurroundingTextChanged ( ) ;
1240
1225
}
1241
1226
1242
- public void SelectInSurroundingText ( int start , int end )
1227
+ private void Caret_PositionChanged ( object sender , EventArgs e )
1243
1228
{
1244
- if ( _textArea == null )
1245
- {
1246
- return ;
1247
- }
1248
-
1249
- var selection = _textArea . Selection ;
1250
-
1251
- _textArea . Selection = _textArea . Selection . StartSelectionOrSetEndpoint (
1252
- new TextViewPosition ( selection . StartPosition . Line , start ) ,
1253
- new TextViewPosition ( selection . StartPosition . Line , end ) ) ;
1229
+ RaiseCursorRectangleChanged ( ) ;
1230
+ RaiseSurroundingTextChanged ( ) ;
1231
+ RaiseSelectionChanged ( ) ;
1254
1232
}
1255
1233
1256
- public void SetPreeditText ( string text )
1234
+ public override void SetPreeditText ( string text )
1257
1235
{
1258
-
1259
- }
1260
1236
1261
- public void SetComposingRegion ( TextRange ? region )
1262
- {
1263
- //ToDo
1264
1237
}
1265
1238
}
1266
1239
}
0 commit comments