1 parent
bcc4015bc4
commit
c25e6820ef
5 files changed
+24
-1
No files matched your search
@@ -310,6 +310,9 @@ pub struct Config {
|
||||
#[dynamic(default)]
|
||||
pub debug_key_events: bool,
|
||||
|
||||
#[dynamic(default)]
|
||||
pub normalize_to_nfc: bool,
|
||||
|
||||
#[dynamic(default)]
|
||||
pub disable_default_key_bindings: bool,
|
||||
pub leader: Option<LeaderKey>,
|
||||
|
||||
@@ -97,6 +97,10 @@ impl wezterm_term::TerminalConfiguration for TermConfig {
|
||||
self.configuration().debug_key_events
|
||||
}
|
||||
|
||||
fn normalize_to_nfc(&self) -> bool {
|
||||
self.configuration().normalize_to_nfc
|
||||
}
|
||||
|
||||
fn bidi_mode(&self) -> BidiMode {
|
||||
let config = self.configuration();
|
||||
BidiMode {
|
||||
|
||||
@@ -27,6 +27,7 @@ num-traits = "0.2"
|
||||
ordered-float = "3.0"
|
||||
serde = {version="1.0", features = ["rc"]}
|
||||
terminfo = "0.7"
|
||||
unicode-normalization = "0.1.21"
|
||||
unicode-segmentation = "1.8"
|
||||
url = "2"
|
||||
wezterm-bidi = { path = "../bidi" }
|
||||
|
||||
@@ -193,6 +193,12 @@ pub trait TerminalConfiguration: std::fmt::Debug {
|
||||
}
|
||||
}
|
||||
|
||||
/// Whether to normalize incoming text runs to
|
||||
/// canonical NFC unicode representation
|
||||
fn normalize_to_nfc(&self) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
fn debug_key_events(&self) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ use termwiz::escape::{
|
||||
Action, ControlCode, DeviceControlMode, Esc, EscCode, OperatingSystemCommand, CSI,
|
||||
};
|
||||
use termwiz::input::KeyboardEncoding;
|
||||
use unicode_normalization::{is_nfc_quick, IsNormalized, UnicodeNormalization};
|
||||
use url::Url;
|
||||
use wezterm_bidi::ParagraphDirectionHint;
|
||||
|
||||
@@ -116,8 +117,16 @@ impl<'a> Performer<'a> {
|
||||
|
||||
let seqno = self.seqno;
|
||||
let mut p = std::mem::take(&mut self.print);
|
||||
let normalized: String;
|
||||
let text = if self.config.normalize_to_nfc() && is_nfc_quick(p.chars()) != IsNormalized::Yes
|
||||
{
|
||||
normalized = p.as_str().nfc().collect();
|
||||
normalized.as_str()
|
||||
} else {
|
||||
p.as_str()
|
||||
};
|
||||
|
||||
for g in unicode_segmentation::UnicodeSegmentation::graphemes(p.as_str(), true) {
|
||||
for g in unicode_segmentation::UnicodeSegmentation::graphemes(text, true) {
|
||||
let g = self.remap_grapheme(g);
|
||||
|
||||
let print_width = grapheme_column_width(g, Some(self.unicode_version));
|
||||
|
||||
Reference in new issue
Block a user