sl-sh-dev / sl-liner

Readline like line editor (fork of https://gitlab.redox-os.org/redox-os/liner).
MIT License
1 stars 0 forks source link

Editor uses Vec<char> instead of grapheme cluster #7

Closed gpwclark closed 2 years ago

gpwclark commented 3 years ago

issue because using key strings on ut8 code points represented as multiple characters like

“नमस्ते”

just doesn't work properly.

One possible solution is to adopt unicode-segmentation crate to reduce the impact on code.

gpwclark commented 3 years ago

make sure to use unicode-width packge to get proper length.

gpwclark commented 3 years ago

something like

        #[derive(Debug, Clone, Copy, PartialEq, Eq)]
        enum GraphemeCluster {
            Char(char),
            Cluster(Option<Vec<char>>),
        }

in a vector... maybe? make the common case simpler but accomodates code points that can be up to 6 bytes.