diff options
author | Jeff Sharkey <jsharkey@android.com> | 2013-03-05 23:04:59 -0800 |
---|---|---|
committer | Jeff Sharkey <jsharkey@android.com> | 2013-03-05 23:09:48 -0800 |
commit | fd6f0973405ce609964fc35b66ee355be596795d (patch) | |
tree | ca69c35d8dcd5fc184f4298276e7858531f53206 /jni | |
parent | c8be1790590605603a8dca8f9ee93327c916de3f (diff) | |
download | android_packages_apps_Terminal-fd6f0973405ce609964fc35b66ee355be596795d.tar.gz android_packages_apps_Terminal-fd6f0973405ce609964fc35b66ee355be596795d.tar.bz2 android_packages_apps_Terminal-fd6f0973405ce609964fc35b66ee355be596795d.zip |
Decode UTF-32 chars.
Tested with emoji!
Change-Id: I1b3b45f7fdb950c3c29ddad1d80c082c1175a68a
Diffstat (limited to 'jni')
-rw-r--r-- | jni/com_android_terminal_Terminal.cpp | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/jni/com_android_terminal_Terminal.cpp b/jni/com_android_terminal_Terminal.cpp index 9f4b36e..2829761 100644 --- a/jni/com_android_terminal_Terminal.cpp +++ b/jni/com_android_terminal_Terminal.cpp @@ -522,19 +522,21 @@ static jint com_android_terminal_Terminal_nativeGetCellRun(JNIEnv* env, } memcpy(&prevCell, &cell, sizeof(VTermScreenCell)); - // TODO: remove this once terminal is resized - if (cell.width == 0) { - cell.width = 1; - } - - // TODO: support full UTF-32 characters - // for testing, 0x00020000 should become 0xD840 0xDC00 - unsigned int size = 1; - // Only include cell chars if they fit into run + uint32_t rawCell = cell.chars[0]; + unsigned int size = (rawCell < 0x10000) ? 1 : 2; if (dataSize + size <= data.size()) { - data[dataSize] = cell.chars[0]; - dataSize += size; + if (rawCell < 0x10000) { + data[dataSize++] = rawCell; + } else { + data[dataSize++] = (((rawCell - 0x10000) >> 10) & 0x3ff) + 0xd800; + data[dataSize++] = ((rawCell - 0x10000) & 0x3ff) + 0xdc00; + } + + for (int i = 1; i < cell.width; i++) { + data[dataSize++] = ' '; + } + colSize += cell.width; pos.col += cell.width; } else { |