-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TAB key in TextEdit, fill the space with different sizes #3879
base: master
Are you sure you want to change the base?
Conversation
TAB key in TextEdit, fill the space with different sizes emilk#3850 I want to use the following for accurate usage: egui\src\text_selection\text_cursor_state.rs 360 lines let width = unicode_width::UnicodeWidthChar::width_cjk(c).unwrap_or(2);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please try to make your code more readable with:
- better names
- documentation if names are not enough
- strong typing when it makes sense
@@ -98,3 +98,4 @@ log = { workspace = true, optional = true } | |||
puffin = { workspace = true, optional = true } | |||
ron = { version = "0.8", optional = true } | |||
serde = { version = "1", optional = true, features = ["derive", "rc"] } | |||
unicode-width = "0.1.11" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we avoid adding this dependency? It's not a huge one, but I wonder how much larger the .wasm becomes with these tables: https://github.com/unicode-rs/unicode-width/blob/master/src/tables.rs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we avoid adding this dependency? It's not a huge one, but I wonder how much larger the .wasm becomes with these tables: https://github.com/unicode-rs/unicode-width/blob/master/src/tables.rs
I don't think this dependency can be avoided. These are codes so they will not be very large and are essential for countries that use UTF8 characters. All pictograms are also affected by this.
CCursor::new(line_start_index) | ||
} | ||
|
||
pub fn create_char_line_indexes(text: &str) -> Vec<usize> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not a good name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not from an English-speaking country, so it's hard for me to choose even a single word.
I would appreciate it if emilk
could make a suggestion.
current_column | ||
} | ||
|
||
pub fn get_current_column_total_column( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you shouldn't be using get_
everywhere
https://rust-lang.github.io/api-guidelines/naming.html#getter-names-follow-rust-convention-c-getter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you shouldn't be using
get_
everywherehttps://rust-lang.github.io/api-guidelines/naming.html#getter-names-follow-rust-convention-c-getter
I'm not from an English-speaking country, so it's hard for me to choose even a single word.
I would appreciate it if emilk
could make a suggestion.
line_indexes | ||
} | ||
|
||
pub fn get_line_start_index(line_indexes: &mut [usize], index: usize) -> usize { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a lot of naked usize
. If you use CCursor
you can make it clear wether or not something is a byte offset or a character offset
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With this, we can easily find out the current Colume and line within TextEdit. I'm using this, and I'm sure others might want to use it too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does it return a byte index or a char index? The name doesn't tell me, neither does the return type.
What about the arguments, are they byte indexes or char indices? Try to put yourself into the shoes of someone who is just reading the function header
#3850
I want to use the following for accurate usage:
egui\src\text_selection\text_cursor_state.rs 360 lines
let width = unicode_width::UnicodeWidthChar::width_cjk(c).unwrap_or(2);