Skip to content

feat: support Unicode line editing#73

Merged
hengyunabc merged 1 commit into
masterfrom
codex/arthas-terminal-unicode
Jul 18, 2026
Merged

feat: support Unicode line editing#73
hengyunabc merged 1 commit into
masterfrom
codex/arthas-terminal-unicode

Conversation

@hengyunabc

Copy link
Copy Markdown
Collaborator

Summary

  • add Unicode-aware line editing for CJK wide characters, combining marks, and supplementary code points
  • keep the existing incremental update path for single-width input and redraw the line when display width changes
  • decode HTTP terminal input with the connection charset
  • add regression coverage for insertion, deletion, cursor movement, redraw, and binary decoding
  • advance the development version to 1.1.7.16-SNAPSHOT for Arthas integration

Why

The readline implementation assumed every accepted input value occupied exactly one terminal cell. As a result, CJK characters were rejected, and combining or supplementary characters could corrupt cursor positions and line updates. HTTP terminal input also relied on the platform default charset.

Impact

Termd terminals can now edit and submit Unicode command lines while preserving the existing fast path for ASCII input. Arthas consumes this snapshot to enable Chinese input across Telnet and WebSocket terminals.

Checks

  • mvn -Dtest=LineBufferTest,LineBufferUpdateTest,ReadlineTest,HttpTtyConnectionTest,BinaryEncodingTest,WcwidthTest test (87 tests passed on JDK 8)
  • mvn -DskipTests install
  • verified through Arthas Telnet and WebSocket end-to-end terminal tests

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds Unicode-aware line editing support across the readline stack so terminals can correctly handle wide CJK characters, combining marks, and supplementary code points, while preserving the incremental update fast path for single-width content and improving HTTP input decoding.

Changes:

  • Teach LineBuffer to accept non-single-width code points and fall back to a full redraw when wide/combining characters are present.
  • Fix prompt cursor computations to use Unicode code point length (not UTF-16 char length).
  • Add/extend regression tests covering Unicode editing behaviors and charset-aware HTTP decoding; bump snapshot version.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/main/java/io/termd/core/readline/LineBuffer.java Allow non-single-width code points; choose redraw vs incremental update based on display width properties.
src/main/java/io/termd/core/readline/Readline.java Compute prompt length using code points to support supplementary characters correctly.
src/main/java/io/termd/core/http/HttpTtyConnection.java Decode text input bytes using the connection charset instead of platform default.
src/test/java/io/termd/core/readline/TestTerm.java Update test terminal rendering model to handle wide/combining characters.
src/test/java/io/termd/core/readline/ReadlineTest.java Add regression tests for CJK, combining marks, and supplementary code point prompts/inputs.
src/test/java/io/termd/core/readline/LineBufferTest.java Enable previously-disabled multi-cell cursor position tests.
src/test/java/io/termd/core/io/BinaryEncodingTest.java Extend binary encoding coverage for CJK UTF-8 bytes.
src/test/java/io/termd/core/http/HttpTtyConnectionTest.java New regression test ensuring HTTP terminal input uses the configured charset.
pom.xml Bump version to 1.1.7.16-SNAPSHOT.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +154 to +159
private void writeCodePoint(int codePoint) {
int cellWidth = Wcwidth.of(codePoint);
if (cellWidth == 0) {
appendCombiningCodePoint(codePoint);
return;
}
Comment on lines +323 to +326
/**
* 非单宽字符采用整行重绘。终端显示的基本单位是单元格,整行重绘可以直接处理宽字符和组合字符,
* 也能在删除组合字符时清除已经附着在基础字符上的旧字形。
*/
Comment on lines 130 to 134
if ("read".equals(action)) {
lastAccessedTime = System.currentTimeMillis();
String data = obj.getString("data");
decoder.write(data.getBytes()); //write back echo
decoder.write(data.getBytes(charset)); // 按连接字符集进入统一解码链路
} else if ("resize".equals(action)) {
@hengyunabc
hengyunabc merged commit 39cfd87 into master Jul 18, 2026
6 checks passed
@hengyunabc
hengyunabc deleted the codex/arthas-terminal-unicode branch July 18, 2026 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants