aboutsummaryrefslogtreecommitdiff
path: root/alacritty/src/string.rs
diff options
context:
space:
mode:
authorKirill Chibisov <contact@kchibisov.com>2022-08-29 16:29:13 +0300
committerGitHub <noreply@github.com>2022-08-29 16:29:13 +0300
commit18f9c2793924aec91c80a69ccb45f529adaffae5 (patch)
tree63cda75c8203c39a7437bd1812653f74494f878f /alacritty/src/string.rs
parent791f79a02a4bbb509c257af2849e411d32f4c18b (diff)
downloadr-alacritty-18f9c2793924aec91c80a69ccb45f529adaffae5.tar.gz
r-alacritty-18f9c2793924aec91c80a69ccb45f529adaffae5.tar.bz2
r-alacritty-18f9c2793924aec91c80a69ccb45f529adaffae5.zip
Add inline input method support
This commit adds support for inline IME handling. It also makes the search bar use underline cursor instead of using '_' character. Fixes #1613.
Diffstat (limited to 'alacritty/src/string.rs')
-rw-r--r--alacritty/src/string.rs14
1 files changed, 7 insertions, 7 deletions
diff --git a/alacritty/src/string.rs b/alacritty/src/string.rs
index 4a758b34..a111166d 100644
--- a/alacritty/src/string.rs
+++ b/alacritty/src/string.rs
@@ -5,7 +5,7 @@ use std::str::Chars;
use unicode_width::UnicodeWidthChar;
/// The action performed by [`StrShortener`].
-#[derive(Clone, Copy, PartialEq, Eq)]
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum TextAction {
/// Yield a spacer.
Spacer,
@@ -93,7 +93,7 @@ impl<'a> StrShortener<'a> {
let num_chars = iter.last().map_or(offset, |(idx, _)| idx + 1);
let skip_chars = num_chars - offset;
- let text_action = if num_chars <= max_width || shortener.is_none() {
+ let text_action = if current_len < max_width || shortener.is_none() {
TextAction::Char
} else {
TextAction::Shortener
@@ -203,8 +203,8 @@ mod tests {
&StrShortener::new(s, len * 2, ShortenDirection::Left, Some('.')).collect::<String>()
);
- let s = "こJんにちはP";
- let len = 2 + 1 + 2 + 2 + 2 + 2 + 1;
+ let s = "ちはP";
+ let len = 2 + 2 + 1;
assert_eq!(
".",
&StrShortener::new(s, 1, ShortenDirection::Right, Some('.')).collect::<String>()
@@ -226,7 +226,7 @@ mod tests {
);
assert_eq!(
- "こ .",
+ "ち .",
&StrShortener::new(s, 3, ShortenDirection::Right, Some('.')).collect::<String>()
);
@@ -236,12 +236,12 @@ mod tests {
);
assert_eq!(
- "こ Jん に ち は P",
+ "ち は P",
&StrShortener::new(s, len * 2, ShortenDirection::Left, Some('.')).collect::<String>()
);
assert_eq!(
- "こ Jん に ち は P",
+ "ち は P",
&StrShortener::new(s, len * 2, ShortenDirection::Right, Some('.')).collect::<String>()
);
}