From fa9ec0c377305126f4c810be198bdca68d71a275 Mon Sep 17 00:00:00 2001 From: Rory Dudley Date: Thu, 12 Dec 2024 17:59:32 -0700 Subject: Rewrite of the buffer code + proper UTF-8 support This patch rewrites much of the code in src/buffer.rs to (utlimately), be less buggy. It also changed getchar() to have proper support for UTF-8 characters. The autocomplete function was also enhanced to support completions with filenames that have spaces in their paths. It handles these by placing a backslash ('\') before each space in the filename. There is not yet any completion support with quote ('), nor double-quote characters ("). The buffer is still navigable with arrow keys, so arbitrary deletions and insertions are still possible. Deletions and insertions with multi-width UTF-8 characters work as expected. Signed-off-by: Rory Dudley --- src/poem/read.rs | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'src/poem/read.rs') diff --git a/src/poem/read.rs b/src/poem/read.rs index baf6a1d..8b83e58 100644 --- a/src/poem/read.rs +++ b/src/poem/read.rs @@ -357,7 +357,16 @@ impl Readable for Poem { channel = Some(Rune::Notes); } verse.add(&mut word, channel); - channel = Some(rune); + if last != Rune::Read + && last != Rune::Write + && last != Rune::Write2 + && last != Rune::WriteAll + && last != Rune::Addendum + && last != Rune::Addendum2 + && last != Rune::AddendumAll + { + channel = Some(rune); + } } Rune::Special => { @@ -383,15 +392,6 @@ impl Readable for Poem { poem!(chars, j, i, c, verse, word, env); } - // Indicates an environment variable to fork with, - // if the verse's stanza is empty so far - // Rune::Environment => { - // word.push(c); - // if verse.is_empty() { - // channel = Some(rune); - // } - // } - // Indicates a file operation (<, >, or >>) Rune::Read | Rune::Write @@ -402,7 +402,6 @@ impl Readable for Poem { | Rune::AddendumAll => { channel = Some(rune); verse.add(&mut word, channel); - // channel = Some(rune); verse.io.push(rune); } -- cgit v1.2.3