Implement the ability to hide the editor text with a given repeated character#394
Implement the ability to hide the editor text with a given repeated character#394StephanvanSchaik wants to merge 1 commit into
Conversation
|
I see that EDIT: I figured out how to expand the command output in the Github CI and fixed the no_std issues. clippy still seems to complain locally, which is what led to the confusion. |
|
I'm also very keen to have this functionality, but I think we'll need more sophisticated logic to handle character counting (one |
Oh, that is right, I forgot about this entirely (it is sometimes too easy to forget). Thanks for the reminder. Would it be fine to use the unicode-segmentation crate to count the grapheme clusters? It is currently not a dependency and I am not sure how parley intends on doing Unicode segmentation (i.e., what dependency to use for that functionality). |
53143be to
125440c
Compare
|
This is a desirable feature, but this is not the right design I think. Introducing more segmentation is not necessary if we use a style instead, for example; and it lets you set it up simply with a default style, or a range/tree style (and eventually, through Attributed Text). My suggestion is to address it through styles, call it grapheme replacement or cluster substitution or something, maybe make it use a &'static str (or a fixed length string type which reasonably accommodates values)... but there may be complications with that, which I have not thought of. |
10bc321 to
755da0b
Compare
755da0b to
1571886
Compare
Thanks for the pointer, this makes a lot more sense and also seems to be a lot simpler. I added the I am currently using I also set Finally, I am also unsure about whether the output layout should still contain |
|
Sorry for the extended delay in replying to this!
Probably we ought to use
Seems correct. We'll probably want some tests specifically for grapheme replacement too, but wouldn't want it enabled in existing tests.
I think the output layout shoudl be processed such that we can use draw_glyphs directly. I think this will be important so that things like mouse selection work properly (as they'll have the visually correct dimensions for the replaced glyphs). I think the replacement needs to happen in the core shaping pipeline once the text is "itemized" into to shaping clusters. Instead of (or after) mapping the cluster to glyphs by shaping, we should map the cluster to the replacement glyph (the replacement character itself should have it's glyph determined by shaping, although we may want to limit it to max one glyph). |
I am currently using a text input field in xilem as a password field, but there is currently no way to hide the text by replacing the actual buffer of characters with a repeated character such as an asterisk (i.e.,
'*'). Further looking into xilem and masonry, I found that the text input field leveragesPlainEditorin parley, so I am trying to extend that first.More specifically, this commit adds a
visible_bufferfield to hold the character buffer with the replaced characters and ahide_symbolfield to hold the character that needs to be shown (if any is set). This is to ensure that the originalbufferfield stays intact everywhere else (together with the corresponding logic), and this seems to be the least intrusive way to achieve this. Further, I have extendedupdate_layoutto update thevisible_bufferfield if the symbol or the length of the original buffer changed and to decide which buffer needs to be shown based on whether the symbol is set or not. Finally, this adds two methods to set and clear the symbol used for hiding the text.Extending this functionality to masonry/xilem should be as simple as calling those two methods once this lands. I think this is also neat because this makes it simple to add a show/hide password checkbox if desired.
Issue #327 is related, but we should keep that open even if this lands, because there are probably a bunch of corner cases or additional desired features, I am just trying to get the most awkward part out of the way which is that the password shouldn't be visible on the screen.