charmbracelet / bubbletea

A powerful little TUI framework 🏗
MIT License
27.99k stars 807 forks source link

IME input in wrong position #874

Open Bryan2333 opened 11 months ago

Bryan2333 commented 11 months ago

Describe the bug Candidate window of input method is at wrong position on Linux. The window is always at the left bottom side of the application.

Setup Please complete the following information along with version numbers, if applicable.

To Reproduce Steps to reproduce the behavior:

  1. Clone the repository
  2. Build the example like textinput, textarea
  3. Run the program
  4. Try to use input method like Fcitx5.

Source Code Just the provided example code

Expected behavior The candidate box following the cursor.

Screenshots Screenshot_20231128_164927.webp

Additional context

meowgorithm commented 11 months ago

Thanks for the report! This appears to be happening because Bubble Tea keeps the cursor in the lower left position while the various input types in Bubbles render a virtual (simulated) cursor. To solve for this we'll need some changes to the renderer, a low level cursor API, and some updates in Bubbles.

Related: https://github.com/charmbracelet/bubbles/issues/361

Additional reference (see "What Can Program Authors Do Today?" near the end): https://mitchellh.com/writing/grapheme-clusters-in-terminals

meowgorithm commented 2 months ago

Just a note that we're actively working on this as part of a larger renderer upgrade underway internally. No ETA but so far things are looking good.