-
-
Notifications
You must be signed in to change notification settings - Fork 448
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Crash when input cjk character [linux] #2
Comments
Thanks for opening this issue! I still need to implement properly: Pull request are welcome if you want. Otherwise, I will try to fix this myself. |
I made 001a0ae to fix this issue. Could you confirm this fixed your issue? |
@ArthurSonzogni PS: most of CJK character is full-width character(=2 normal character), so it need to be specifically implemented. |
I see. It is not going to be easy, but making a fix seems doable. |
This should be fixed now! Please let me know whether everything is now perfect or not. I purposedly let a glitch. See the expectations of TextTest.CJK_2. // See https://github.com/ArthurSonzogni/FTXUI/issues/2#issuecomment-504871456
TEST(TextTest, CJK) {
auto element = text(L"测试") | border;
Screen screen(6, 3);
Render(screen, element.get());
EXPECT_EQ(
"┌────┐\n"
"│测试│\n"
"└────┘",
screen.ToString());
}
// See https://github.com/ArthurSonzogni/FTXUI/issues/2#issuecomment-504871456
TEST(TextTest, CJK_2) {
auto element = text(L"测试") | border;
Screen screen(5, 3);
Render(screen, element.get());
EXPECT_EQ(
"┌───┐\n"
"│测试\n"
"└───┘",
screen.ToString());
}
// See https://github.com/ArthurSonzogni/FTXUI/issues/2#issuecomment-504871456
TEST(TextTest, CJK_3) {
auto element = text(L"测试") | border;
Screen screen(4, 3);
Render(screen, element.get());
EXPECT_EQ(
"┌──┐\n"
"│测│\n"
"└──┘",
screen.ToString());
} When the text doesn't fit the allocated space, I let the last 2-width character to be displayed, which may be drawn outside of the allocated space. It looks good enough, but maybe I should reconsider this in the future. One question: I haven't understood whether I should use mk_wcswidth ou mk_wcswidth_cjk. Do you know which one is the correct one in my case? |
I have tested both input and output, it works! About the mk_wcswidth_cjk: reference: you can search "ambiguous full width" in google for details.. PS: I suggest to add an option to switch between two algorithms just like vim, xterm.js and gnome terminal |
there is an IME issue: Yes, you cannot get the preview text in terminal program, it just rendered by terminal emulator, but you can move it (by move the **real** cursor, even use *invisible* cursor.In some terminal emulator, invisible cursor will make the preview text disappear, but it's fine, because the IME has both preview text and float window) (some IME only use float window to preview character, the float window is also need to attach to the cursor position) it is a screenshot from whiptail possible fix:
|
Most CJK users use IME (input method) to type CJK characters. They need the cursor to be at the correct location, not in the bottom right corner. This CL does: * Move the cursor the focus() element. * Hide the cursor (and show it at exit) * Intercept SIGINT to guarantee proper cleanup all the time. This should fix the second issue mentionned on: #2
Thanks you so much for your explanation! I didn't manage to install any IME on my linux laptop. I tried ibus-anthy, but wasn't able to show the preview character box. Anyway, I think I fixed the cursor problem. In theory, it should work. |
@ArthurSonzogni Yes, it fixed .... almostly |
I see. Thanks! I just added a fix. |
Confirmed, fixed finally! |
+ 3 tests. The goal is to fix: ArthurSonzogni#2 (comment)
Most CJK users use IME (input method) to type CJK characters. They need the cursor to be at the correct location, not in the bottom right corner. This CL does: * Move the cursor the focus() element. * Hide the cursor (and show it at exit) * Intercept SIGINT to guarantee proper cleanup all the time. This should fix the second issue mentionned on: ArthurSonzogni#2
LANG=zh_CN.utf-8
LC_ALL=zh_CN.utf-8
https://github.com/ArthurSonzogni/FTXUI/blob/master/src/ftxui/screen/string.cpp#L8
The text was updated successfully, but these errors were encountered: