Skip to content

Commit 35246e1

Browse files
committed
WIP: kitkat_keyboard_fixes
1 parent 5643fa4 commit 35246e1

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

src/src/org/renpy/android/SDLSurfaceView.java

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767

6868
public class SDLSurfaceView extends SurfaceView implements SurfaceHolder.Callback, Runnable {
6969
static private final String TAG = "SDLSurface";
70-
static private final boolean DEBUG = false;
70+
static private final boolean DEBUG = true;
7171
static private final String mVertexShader =
7272
"uniform mat4 uMVPMatrix;\n" +
7373
"attribute vec4 aPosition;\n" +
@@ -361,8 +361,8 @@ public interface OnInterceptTouchListener {
361361
private ApplicationInfo ai;
362362

363363
// Text before/after cursor
364-
static String mTbf = "";
365-
static String mTaf = "";
364+
static String mTbf = " ";
365+
static String mTaf = " ";
366366

367367
public static void updateTextFromCursor(String bef, String aft){
368368
mTbf = bef;
@@ -1224,10 +1224,14 @@ public boolean sendKeyEvent(KeyEvent event){
12241224
@Override
12251225
public boolean setComposingRegion(int start, int end){
12261226
if (DEBUG) Log.d("Python:", String.format("Set Composing Region %s %s", start, end));
1227-
finishComposingText();
1227+
//finishComposingText();
12281228
if (start < 0 || start > end)
12291229
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);
12311235
return true;
12321236
//return super.setComposingRegion(start, end);
12331237
}
@@ -1283,20 +1287,19 @@ public CharSequence getSelectedText(int flags){
12831287
@Override
12841288
public CharSequence getTextBeforeCursor(int n, int flags){
12851289
if (DEBUG) Log.d("Python:", String.format("getTextBeforeCursor %s %s", n, flags));
1286-
/*int len = mTbf.length();
1290+
int len = mTbf.length();
12871291
int len_n = Math.min(len, n);
12881292
int start = Math.max(len - n, 0);
12891293
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;
12921296
}
12931297

12941298
@Override
12951299
public CharSequence getTextAfterCursor(int n, int flags){
12961300
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));
13001303
}
13011304

13021305
@Override

0 commit comments

Comments
 (0)