Move the cursor to the input location.

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:
https://github.com/ArthurSonzogni/FTXUI/issues/2
This commit is contained in:
ArthurSonzogni
2019-06-29 18:52:58 +02:00
parent 38df095b4a
commit 86c3b60a6f
6 changed files with 85 additions and 30 deletions

View File

@@ -139,8 +139,11 @@ std::string Screen::ResetPosition() {
void Screen::Clear() {
pixels_ = std::vector<std::vector<Pixel>>(dimy_,
std::vector<Pixel>(dimx_, Pixel()));
cursor_.x = dimx_ - 1;
cursor_.y = dimy_ - 1;
}
// clang-format off
void Screen::ApplyShader() {
// Merge box characters togethers.
for (int y = 1; y < dimy_; ++y) {
@@ -150,26 +153,19 @@ void Screen::ApplyShader() {
wchar_t& cur = at(x, y);
// Left vs current
if (cur == U'' && left == U'')
cur = U'';
if (cur == U'' && left == U'')
left = U'';
if (cur == U'' && left == U'')
cur = U'';
if (cur == U'' && left == U'')
left = U'';
if (cur == U'' && left == U'') cur = U'';
if (cur == U'' && left == U'') left = U'';
if (cur == U'' && left == U'') cur = U'';
if (cur == U'' && left == U'') left = U'';
// Top vs current
if (cur == U'' && top == U'')
cur = U'';
if (cur == U'' && top == U'')
top = U'';
if (cur == U'' && top == U'')
cur = U'';
if (cur == U'' && top == U'')
top = U'';
if (cur == U'' && top == U'') cur = U'';
if (cur == U'' && top == U'') top = U'';
if (cur == U'' && top == U'') cur = U'';
if (cur == U'' && top == U'') top = U'';
}
}
}
// clang-format on
}; // namespace ftxui