emilk / egui

egui: an easy-to-use immediate mode GUI in Rust that runs on both web and native
https://www.egui.rs/
Apache License 2.0
22.26k stars 1.6k forks source link

terminal style cursor #768

Open TimUntersberger opened 3 years ago

TimUntersberger commented 3 years ago

Please make sure there is not already a similar issue!

Is your feature request related to a problem? Please describe. I am trying to replicate the thick block cursor in terminals using a multiline TextEdit, but when increasing the cursor width it doesn't shift the start of the cursor to the right.

Edit:

I guess a vim like cursor is more what I want. Being able to have the cursor like in normal mode or insert mode.

As you can see in the image below, the cursor overlaps with the last character. image

Also the width of the cursor changes depending on whether text is inside the textedit or not.

With character image

Without character image

Fixing the first problem will probably fix the varying cursor width problem.

Describe the solution you'd like The Cursor doesn't start at the center but at the leftmost point of the cursor.

emilk commented 3 years ago

If you want a vim-like cursor you also want the cursor width to follow the width of the (presumably monospace) font instead of being hard-coded. Perhaps we should have a block_cursor option in either TextEdit or Visuals?

TimUntersberger commented 3 years ago

If you want a vim-like cursor you also want the cursor width to follow the width of the (presumably monospace) font instead of being hard-coded.

👍

Perhaps we should have a block_cursor option in either TextEdit or Visuals?

Maybe adding a egui::style::Visuals::text_cursor_style method which accepts the following enum?

enum TextCursorStyle {
  Bar, // default
  Block
}