|
67 | 67 |
|
68 | 68 | public class SDLSurfaceView extends SurfaceView implements SurfaceHolder.Callback, Runnable {
|
69 | 69 | static private final String TAG = "SDLSurface";
|
70 |
| - static private final boolean DEBUG = false; |
| 70 | + static private final boolean DEBUG = true; |
71 | 71 | static private final String mVertexShader =
|
72 | 72 | "uniform mat4 uMVPMatrix;\n" +
|
73 | 73 | "attribute vec4 aPosition;\n" +
|
@@ -361,8 +361,8 @@ public interface OnInterceptTouchListener {
|
361 | 361 | private ApplicationInfo ai;
|
362 | 362 |
|
363 | 363 | // Text before/after cursor
|
364 |
| - static String mTbf = ""; |
365 |
| - static String mTaf = ""; |
| 364 | + static String mTbf = " "; |
| 365 | + static String mTaf = " "; |
366 | 366 |
|
367 | 367 | public static void updateTextFromCursor(String bef, String aft){
|
368 | 368 | mTbf = bef;
|
@@ -1224,10 +1224,14 @@ public boolean sendKeyEvent(KeyEvent event){
|
1224 | 1224 | @Override
|
1225 | 1225 | public boolean setComposingRegion(int start, int end){
|
1226 | 1226 | if (DEBUG) Log.d("Python:", String.format("Set Composing Region %s %s", start, end));
|
1227 |
| - finishComposingText(); |
| 1227 | + //finishComposingText(); |
1228 | 1228 | if (start < 0 || start > end)
|
1229 | 1229 | return true;
|
1230 |
| - //dispatchCommand(String.format("SEL:%s,%s,%s", mTbf.length(), start, end)); |
| 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); |
1231 | 1235 | return true;
|
1232 | 1236 | //return super.setComposingRegion(start, end);
|
1233 | 1237 | }
|
@@ -1283,20 +1287,19 @@ public CharSequence getSelectedText(int flags){
|
1283 | 1287 | @Override
|
1284 | 1288 | public CharSequence getTextBeforeCursor(int n, int flags){
|
1285 | 1289 | if (DEBUG) Log.d("Python:", String.format("getTextBeforeCursor %s %s", n, flags));
|
1286 |
| - /*int len = mTbf.length(); |
| 1290 | + int len = mTbf.length(); |
1287 | 1291 | int len_n = Math.min(len, n);
|
1288 | 1292 | int start = Math.max(len - n, 0);
|
1289 | 1293 | String tbf = mTbf.substring(start, start + len_n);
|
1290 |
| - return tbf;*/ |
1291 |
| - return super.getTextBeforeCursor(n, flags); |
| 1294 | + Log.d("Python:", String.format("getTextBeforeCursor [%s]", tbf)); |
| 1295 | + return tbf; |
1292 | 1296 | }
|
1293 | 1297 |
|
1294 | 1298 | @Override
|
1295 | 1299 | public CharSequence getTextAfterCursor(int n, int flags){
|
1296 | 1300 | if (DEBUG) Log.d("Python:", String.format("getTextAfterCursor %s %s", n, flags));
|
1297 |
| - Log.d("Python:", String.format("TextAfterCursor %s", mTaf)); |
1298 |
| - //return mTaf.substring(0, Math.min(mTaf.length(), n)); |
1299 |
| - return super.getTextAfterCursor(n, flags); |
| 1301 | + Log.d("Python:", String.format("TextAfterCursor [%s]", mTaf)); |
| 1302 | + return mTaf.substring(0, Math.min(mTaf.length(), n)); |
1300 | 1303 | }
|
1301 | 1304 |
|
1302 | 1305 | @Override
|
|
0 commit comments