rustyline icon indicating copy to clipboard operation
rustyline copied to clipboard

Keep track of layout of input buffer spans

Open aljazerzen opened this issue 4 months ago • 15 comments

Builds on top of https://github.com/gwenn/rustyline/pull/2/files

When moving cursor up or down a line, it should not change columns. To be precise, it should not change columns on the screen.

Current implementation was making sure it was not changing number of graphemes from the beginning of the line. This works correctly, as long as prompt is empty. If it so not empty, the cursor moves up and down like this:

> c_mmand \
argument1
> command \
a_gument1

This PR changes this behavior to this:

> c_mmand \
argument1
> command \
arg_ment1

This change is also needed for continuation prompts.


To make this happen, I had to:

  • keep track of layout of input buffer spans (one for each line in the input buffer),
  • refactor Renderer::compute_layout into Layout::compute,
  • change LineBuffer::move_to_line to take Layout as a parameter,
  • fix State::move_cursor.

aljazerzen avatar Oct 22 '24 12:10 aljazerzen