termimad icon indicating copy to clipboard operation
termimad copied to clipboard

add an example of incrementally printing markdown

Open ifsheldon opened this issue 2 years ago • 4 comments

This is a minimum code example for incrementally printing markdown. This should close #42

ifsheldon avatar Sep 15 '23 12:09 ifsheldon

There's a problem: the save/restore thing breaks as soon as there's a scrollbar.

I can run it with clear & cargo run --example incremental_print_markdown but otherwise it doesn't work.

Canop avatar Sep 15 '23 12:09 Canop

I think it's fine. It's an MVP after all. Otherwise, I guess we need to do something like you did in render_input_markdown, which is to use Area. But I haven't tried out to embed one Area in the current terminal instead of opening up a new alternate screen.

BTW, do you know why this happens? I'm not very familiar with nitty gritty of terminals. From my view, the code logic is fine regardless scrollbar. I tested it on my Mac default terminal and iTerm2 and Warp. Former 2 have this issue, but Warp seems to handle it pretty well.

ifsheldon avatar Sep 15 '23 14:09 ifsheldon

There's a problem: the save/restore thing breaks as soon as there's a scrollbar.

I fixed this in commit fb5b0eb by calculating where the anchored cursor should be instead of storing a fixed cursor position.

ifsheldon avatar Sep 16 '23 11:09 ifsheldon