@@ -342,6 +342,7 @@ public interface OnInterceptTouchListener {
342
342
343
343
// This stores the length of the text in pridiction/swype buffer
344
344
private int mDelLen = 0 ;
345
+ private int mRDelLen = 0 ;
345
346
346
347
// The width and height. (This should be set at startup time -
347
348
// these values just prevent segfaults and divide by zero, etc.)
@@ -363,10 +364,17 @@ public interface OnInterceptTouchListener {
363
364
// Text before/after cursor
364
365
static String mTbf = " " ;
365
366
static String mTaf = " " ;
367
+ static InputConnection ic = null ;
366
368
367
- public static void updateTextFromCursor (String bef , String aft ){
369
+ public static void updateTextFromCursor (String bef , String aft , int compose ){
368
370
mTbf = bef ;
369
371
mTaf = aft ;
372
+ ic .getTextBeforeCursor (1024 , 0 );
373
+ ic .getTextAfterCursor (1024 , 0 );
374
+ int length = mTbf .length ();
375
+ if (compose == 1 && length > 0 ){
376
+ ic .setComposingRegion (length - 1 , length );
377
+ }
370
378
if (DEBUG ) Log .d (TAG , String .format ("mtbf: %s mtaf:%s <<<<<<<<<" , mTbf , mTaf ));
371
379
}
372
380
@@ -1168,17 +1176,17 @@ public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
1168
1176
outAttrs .inputType = inputType ;
1169
1177
// ask IME to avoid taking full screen on landscape mode
1170
1178
outAttrs .imeOptions = EditorInfo .IME_FLAG_NO_EXTRACT_UI ;
1171
- return new BaseInputConnection (this , false ){
1179
+ ic = new BaseInputConnection (this , false ){
1172
1180
1173
1181
private void deleteLastText (){
1174
1182
// send back space keys
1175
1183
if (DEBUG ) Log .i ("Python:" , String .format ("delete text%s" , mDelLen ));
1176
1184
1177
- if (mDelLen == 0 ){
1178
- return ;
1179
- }
1185
+ String message = "" ;
1180
1186
1181
- String message = String .format ("DEL:%s" , mDelLen );
1187
+ if (mDelLen == 0 ) return ;
1188
+
1189
+ message = String .format ("DEL:%s" , mDelLen );
1182
1190
dispatchCommand (message );
1183
1191
}
1184
1192
@@ -1200,12 +1208,6 @@ public boolean commitCompletion(CompletionInfo text){
1200
1208
return super .commitCompletion (text );
1201
1209
}
1202
1210
1203
- @ Override
1204
- public boolean commitCorrection (CorrectionInfo correctionInfo ){
1205
- if (DEBUG ) Log .i ("Python:" , String .format ("Commit Correction" ));
1206
- return super .commitCorrection (correctionInfo );
1207
- }
1208
-
1209
1211
@ Override
1210
1212
public boolean commitText (CharSequence text , int newCursorPosition ) {
1211
1213
// some code which takes the input and manipulates it and calls editText.getText().replace() afterwards
@@ -1223,17 +1225,11 @@ public boolean sendKeyEvent(KeyEvent event){
1223
1225
1224
1226
@ Override
1225
1227
public boolean setComposingRegion (int start , int end ){
1226
- if (DEBUG ) Log .d ("Python:" , String .format ("Set Composing Region %s %s" , start , end ));
1227
- //finishComposingText();
1228
- if (start < 0 || start > end )
1228
+ if (start < 0 || start > end || start == end )
1229
1229
return true ;
1230
- //if (start > 0) start -= 1;
1231
- end = Math .min (end , mTbf .length ());
1232
- if (end < 0 ) end = 0 ;
1233
- dispatchCommand (String .format ("SEL:%s,%s,%s" , mTbf .length (), start , end ));
1234
- this .setComposingText (mTbf .substring (start , end ), 1 );
1235
- return true ;
1236
- //return super.setComposingRegion(start, end);
1230
+ dispatchCommand (String .format ("SELWORD:" ));
1231
+ Log .d ("Python:" , String .format ("%s, %s" , mRDelLen , mTbf ));
1232
+ return super .setComposingRegion (start , end );
1237
1233
}
1238
1234
1239
1235
@ Override
@@ -1252,6 +1248,7 @@ public boolean setComposingText(CharSequence text,
1252
1248
@ Override
1253
1249
public boolean finishComposingText (){
1254
1250
if (DEBUG ) Log .i ("Python:" , String .format ("finish Composing Text" ));
1251
+ dispatchCommand (String .format ("SEL:0" ));
1255
1252
return super .finishComposingText ();
1256
1253
}
1257
1254
@@ -1260,10 +1257,6 @@ public boolean deleteSurroundingText (int beforeLength, int afterLength){
1260
1257
if (DEBUG ) Log .d ("Python:" , String .format ("delete surrounding Text %s %s" , beforeLength , afterLength ));
1261
1258
// move cursor to place from where to start deleting
1262
1259
// send right arrow keys
1263
- for (int i = 0 ; i < afterLength ; i ++){
1264
- nativeKey (45 , 1 , 39 );
1265
- nativeKey (45 , 0 , 39 );
1266
- }
1267
1260
// remove text before cursor
1268
1261
mDelLen = beforeLength + afterLength ;
1269
1262
this .deleteLastText ();
@@ -1308,6 +1301,7 @@ public boolean setSelection(int start, int end){
1308
1301
return super .setSelection (start , end );
1309
1302
}
1310
1303
};
1304
+ return ic ;
1311
1305
}
1312
1306
1313
1307
static void activateInput () {
0 commit comments