diff options
author | Steven Luo <steven+android@steven676.net> | 2012-09-25 01:51:18 -0700 |
---|---|---|
committer | Steven Luo <steven+android@steven676.net> | 2012-09-30 23:54:16 -0700 |
commit | fe682aeb592a7e7560d3b549558b1a50c06453b2 (patch) | |
tree | e4e7d8f84cdf0329a77b587ea68ad7c1e9dc6572 | |
parent | 389f1179671657f2997a17dd73abffe2739359ad (diff) | |
download | AndroidTerm-fe682aeb592a7e7560d3b549558b1a50c06453b2.tar.gz |
Fix inserting wide char into column previously occupied by normal-width char
Since an East Asian wide character takes two screen columns, if we're
inserting one into a spot previously occupied by a normal-width
character, we need to overwrite the contents of the column to the right
of the position into which the character is inserted. We do this
shifting the contents of the rest of the line left in the array, then
updating our idea of the storage used -- or at least that's what's
supposed to happen.
There are at least two problems with the current implementation:
(1) findStartOfColumn() is used in a few places to get the spot in the
array where a column starts, but this relies on the offset array, which
is potentially out of date at this point. Fix this by adding the shift
(which will be used to update the offset array later) to the value
whenever we use findStartOfColumn().
(2) When truncating the line by reducing the storage used count, we
currently effectively reduce the count by the size of the last column in
the line, which is not necessarily the same as the size of the
overwritten column. We should instead adjust by the size of the
just-overwritten column (which is readily available to us at this
point).
Fixes #145, and potentially a class of other difficult-to-reproduce bugs
involving East Asian wide character support.
-rw-r--r-- | libraries/emulatorview/src/jackpal/androidterm/emulatorview/UnicodeTranscript.java | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/libraries/emulatorview/src/jackpal/androidterm/emulatorview/UnicodeTranscript.java b/libraries/emulatorview/src/jackpal/androidterm/emulatorview/UnicodeTranscript.java index 584b643..8254403 100644 --- a/libraries/emulatorview/src/jackpal/androidterm/emulatorview/UnicodeTranscript.java +++ b/libraries/emulatorview/src/jackpal/androidterm/emulatorview/UnicodeTranscript.java @@ -964,7 +964,7 @@ class FullUnicodeLine { int nextWidth = UnicodeTranscript.charWidth(text, nextPos); int nextLen; if (column + nextWidth + 1 < columns) { - nextLen = findStartOfColumn(column + nextWidth + 1) - nextPos; + nextLen = findStartOfColumn(column + nextWidth + 1) + shift - nextPos; } else { nextLen = spaceUsed - nextPos; } @@ -983,7 +983,7 @@ class FullUnicodeLine { shift -= nextLen; // Truncate the line - offset[0] = (short) findStartOfColumn(columns - 1); + offset[0] -= nextLen; } // Correct the offset for the next column to reflect width change |