diff --git a/jni/termExec.cpp b/jni/termExec.cpp index efc65c9..0f9c79e 100644 --- a/jni/termExec.cpp +++ b/jni/termExec.cpp @@ -267,6 +267,27 @@ static void android_os_Exec_setPtyWindowSize(JNIEnv *env, jobject clazz, ioctl(fd, TIOCSWINSZ, &sz); } +static void android_os_Exec_setPtyUTF8Mode(JNIEnv *env, jobject clazz, + jobject fileDescriptor, jboolean utf8Mode) +{ + int fd; + struct termios tios; + + fd = env->GetIntField(fileDescriptor, field_fileDescriptor_descriptor); + + if (env->ExceptionOccurred() != NULL) { + return; + } + + tcgetattr(fd, &tios); + if (utf8Mode) { + tios.c_iflag |= IUTF8; + } else { + tios.c_iflag &= ~IUTF8; + } + tcsetattr(fd, TCSANOW, &tios); +} + static int android_os_Exec_waitFor(JNIEnv *env, jobject clazz, jint procId) { int status; @@ -336,6 +357,8 @@ static JNINativeMethod method_table[] = { (void*) android_os_Exec_createSubProcess }, { "setPtyWindowSize", "(Ljava/io/FileDescriptor;IIII)V", (void*) android_os_Exec_setPtyWindowSize}, + { "setPtyUTF8Mode", "(Ljava/io/FileDescriptor;Z)V", + (void*) android_os_Exec_setPtyUTF8Mode}, { "waitFor", "(I)I", (void*) android_os_Exec_waitFor}, { "close", "(Ljava/io/FileDescriptor;)V", diff --git a/src/jackpal/androidterm/Exec.java b/src/jackpal/androidterm/Exec.java index b2f342f..ce53424 100644 --- a/src/jackpal/androidterm/Exec.java +++ b/src/jackpal/androidterm/Exec.java @@ -59,6 +59,13 @@ public class Exec public static native void setPtyWindowSize(FileDescriptor fd, int row, int col, int xpixel, int ypixel); + /** + * Set or clear UTF-8 mode for a given pty. Used by the terminal driver + * to implement correct erase behavior in cooked mode (Linux >= 2.6.4). + */ + public static native void setPtyUTF8Mode(FileDescriptor fd, + boolean utf8Mode); + /** * Causes the calling thread to wait for the process associated with the * receiver to finish executing.