refactor: extract wezterm-surface from termwiz
This commit is contained in:
19 files changed
+220
-103
No files matched your search
Generated
+33
-23
@@ -469,30 +469,15 @@ checksum = "6c335a9de639ba6a3e4107fe7763c9dcd4eb9422575f1191c2b8f2009f03fe4a"
|
||||
name = "bintree"
|
||||
version = "0.1.0"
|
||||
|
||||
[[package]]
|
||||
name = "bit-set"
|
||||
version = "0.5.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0700ddab506f33b20a03b13996eccd309a48e5ff77d0d95926aa0210fb4e95f1"
|
||||
dependencies = [
|
||||
"bit-vec 0.6.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bit-set"
|
||||
version = "0.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "08807e080ed7f9d5433fa9b275196cfc35414f66a0c79d864dc51a0d825231a3"
|
||||
dependencies = [
|
||||
"bit-vec 0.8.0",
|
||||
"bit-vec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bit-vec"
|
||||
version = "0.6.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb"
|
||||
|
||||
[[package]]
|
||||
name = "bit-vec"
|
||||
version = "0.8.0"
|
||||
@@ -1623,12 +1608,13 @@ checksum = "7360491ce676a36bf9bb3c56c1aa791658183a54d2744120f27285738d90465a"
|
||||
|
||||
[[package]]
|
||||
name = "fancy-regex"
|
||||
version = "0.11.0"
|
||||
version = "0.14.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b95f7c0680e4142284cf8b22c14a476e87d61b004a3a0861872b32ef7ead40a2"
|
||||
checksum = "6e24cb5a94bcae1e5408b0effca5cd7172ea3c5755049c5f3af4cd283a165298"
|
||||
dependencies = [
|
||||
"bit-set 0.5.3",
|
||||
"regex",
|
||||
"bit-set",
|
||||
"regex-automata",
|
||||
"regex-syntax",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -3498,7 +3484,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e380993072e52eef724eddfcde0ed013b0c023c3f0417336ed041aa9f076994e"
|
||||
dependencies = [
|
||||
"arrayvec",
|
||||
"bit-set 0.8.0",
|
||||
"bit-set",
|
||||
"bitflags 2.9.0",
|
||||
"cfg_aliases",
|
||||
"codespan-reporting",
|
||||
@@ -5682,6 +5668,7 @@ dependencies = [
|
||||
"wezterm-dynamic",
|
||||
"wezterm-escape-parser",
|
||||
"wezterm-input-types",
|
||||
"wezterm-surface",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
@@ -6960,6 +6947,29 @@ dependencies = [
|
||||
"whoami",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wezterm-surface"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bitflags 2.9.0",
|
||||
"fancy-regex",
|
||||
"finl_unicode",
|
||||
"fixedbitset",
|
||||
"k9",
|
||||
"ordered-float 4.6.0",
|
||||
"serde",
|
||||
"siphasher",
|
||||
"unicode-segmentation",
|
||||
"wezterm-bidi",
|
||||
"wezterm-blob-leases",
|
||||
"wezterm-cell",
|
||||
"wezterm-char-props",
|
||||
"wezterm-color-types",
|
||||
"wezterm-dynamic",
|
||||
"wezterm-escape-parser",
|
||||
"wezterm-input-types",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wezterm-term"
|
||||
version = "0.1.0"
|
||||
@@ -7057,7 +7067,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "671c25545d479b47d3f0a8e373aceb2060b67c6eb841b24ac8c32348151c7a0c"
|
||||
dependencies = [
|
||||
"arrayvec",
|
||||
"bit-vec 0.8.0",
|
||||
"bit-vec",
|
||||
"bitflags 2.9.0",
|
||||
"cfg_aliases",
|
||||
"document-features",
|
||||
@@ -7084,7 +7094,7 @@ dependencies = [
|
||||
"android_system_properties",
|
||||
"arrayvec",
|
||||
"ash",
|
||||
"bit-set 0.8.0",
|
||||
"bit-set",
|
||||
"bitflags 2.9.0",
|
||||
"block",
|
||||
"bytemuck",
|
||||
|
||||
+8
-6
@@ -14,6 +14,7 @@ members = [
|
||||
"wezterm-mux-server",
|
||||
"wezterm-open-url",
|
||||
"wezterm-ssh",
|
||||
"wezterm-surface",
|
||||
"wezterm-uds",
|
||||
]
|
||||
resolver = "2"
|
||||
@@ -86,14 +87,14 @@ enum-display-derive = "0.1"
|
||||
env-bootstrap = { path = "env-bootstrap" }
|
||||
env_logger = "0.11"
|
||||
euclid = {version="0.22", default-features=false}
|
||||
fancy-regex = "0.11"
|
||||
fancy-regex = {version="0.14", default-features=false, features=[]}
|
||||
fastrand = "2.0"
|
||||
filedescriptor = { version="0.8.3", path = "filedescriptor" }
|
||||
filenamegen = "0.2.6"
|
||||
filesystem = { path = "lua-api-crates/filesystem" }
|
||||
finl_unicode = { version = "1.3", git="https://github.com/wez/finl_unicode.git", branch="no_std" , default-features=false, features=["categories", "grapheme_clusters"]}
|
||||
fixed = "1.23"
|
||||
fixedbitset = "0.4"
|
||||
fixedbitset = {version="0.4", default-features=false}
|
||||
flume = "0.11"
|
||||
fnv = "1.0"
|
||||
fontconfig = { path = "deps/fontconfig" }
|
||||
@@ -239,14 +240,14 @@ wayland-client = "0.31"
|
||||
wayland-egl = "0.32"
|
||||
wayland-protocols = "0.32"
|
||||
wayland-protocols-plasma = { version="0.3.6", features=["client"] }
|
||||
wezterm-bidi = { version="0.2.3", path = "bidi" }
|
||||
wezterm-bidi = { version="0.2.3", path = "bidi", default-features=false}
|
||||
wezterm-blob-leases = { version="0.1.1", path = "wezterm-blob-leases"}
|
||||
wezterm-cell = { path = "wezterm-cell" }
|
||||
wezterm-cell = { path = "wezterm-cell"}
|
||||
wezterm-char-props = { path = "wezterm-char-props", default-features=false }
|
||||
wezterm-client = { path = "wezterm-client" }
|
||||
wezterm-color-types = { version="0.3", path = "color-types" }
|
||||
wezterm-color-types = { version="0.3", path = "color-types", default-features=false }
|
||||
wezterm-config-derive = { version="0.1", path="config/derive" }
|
||||
wezterm-dynamic = { version = "0.2.1", path = "wezterm-dynamic" }
|
||||
wezterm-dynamic = { version = "0.2.1", path = "wezterm-dynamic", default-features=false }
|
||||
wezterm-dynamic-derive = { version="0.1.1", path="wezterm-dynamic/derive" }
|
||||
wezterm-escape-parser = { version="0.1.0", path="wezterm-escape-parser" }
|
||||
wezterm-font = { path = "wezterm-font" }
|
||||
@@ -255,6 +256,7 @@ wezterm-input-types = { version="0.1", path = "wezterm-input-types", default-fea
|
||||
wezterm-mux-server-impl = { path = "wezterm-mux-server-impl" }
|
||||
wezterm-open-url = { path = "wezterm-open-url" }
|
||||
wezterm-ssh = { path = "wezterm-ssh" }
|
||||
wezterm-surface = { path = "wezterm-surface" }
|
||||
wezterm-term = { path = "term" }
|
||||
wezterm-toast-notification = { path = "wezterm-toast-notification" }
|
||||
wezterm-uds = { path = "wezterm-uds" }
|
||||
|
||||
@@ -9,6 +9,8 @@ test:
|
||||
check:
|
||||
cargo check
|
||||
cargo check -p wezterm-escape-parser
|
||||
cargo check -p wezterm-cell
|
||||
cargo check -p wezterm-surface
|
||||
|
||||
build:
|
||||
cargo build $(BUILD_OPTS) -p wezterm
|
||||
|
||||
+3
-2
@@ -45,12 +45,13 @@ wezterm-color-types = {workspace = true, features=["std"]}
|
||||
wezterm-dynamic = {workspace = true, features=["std"]}
|
||||
wezterm-escape-parser = {workspace = true, features=["std"]}
|
||||
wezterm-input-types.workspace = true
|
||||
wezterm-surface = {workspace = true, features=["std", "appdata"]}
|
||||
|
||||
[features]
|
||||
default = ["image", "tmux_cc"]
|
||||
widgets = ["cassowary", "fnv"]
|
||||
use_serde = ["serde", "wezterm-color-types/use_serde", "wezterm-blob-leases/serde", "bitflags/serde", "wezterm-input-types/serde", "wezterm-escape-parser/use_serde", "wezterm-cell/use_serde"]
|
||||
use_image = ["image", "dep:image", "wezterm-escape-parser/use_image", "wezterm-escape-parser/kitty-shm", "wezterm-cell/use_image"]
|
||||
use_serde = ["serde", "wezterm-color-types/use_serde", "wezterm-blob-leases/serde", "bitflags/serde", "wezterm-input-types/serde", "wezterm-escape-parser/use_serde", "wezterm-cell/use_serde", "wezterm-surface/use_serde"]
|
||||
use_image = ["image", "dep:image", "wezterm-escape-parser/use_image", "wezterm-escape-parser/kitty-shm", "wezterm-cell/use_image", "wezterm-surface/use_image"]
|
||||
image = ["sha2", "wezterm-blob-leases", "wezterm-escape-parser/image"]
|
||||
tmux_cc = ["pest", "pest_derive", "wezterm-escape-parser/tmux_cc"]
|
||||
docs = ["widgets", "use_serde", "image", "tmux_cc"]
|
||||
|
||||
+3
-3
@@ -42,12 +42,12 @@
|
||||
|
||||
pub mod caps;
|
||||
pub use wezterm_cell as cell;
|
||||
pub mod cellcluster;
|
||||
pub use wezterm_cell::color;
|
||||
pub use wezterm_surface::cellcluster;
|
||||
pub mod error;
|
||||
pub mod hyperlink;
|
||||
#[cfg(feature = "use_image")]
|
||||
pub use wezterm_cell::image;
|
||||
pub use wezterm_surface::hyperlink;
|
||||
pub mod input;
|
||||
pub mod istty;
|
||||
pub mod keymap;
|
||||
@@ -56,7 +56,7 @@ mod macros;
|
||||
pub use wezterm_char_props::nerdfonts;
|
||||
mod readbuf;
|
||||
pub mod render;
|
||||
pub mod surface;
|
||||
pub use wezterm_surface as surface;
|
||||
pub mod terminal;
|
||||
#[cfg(feature = "tmux_cc")]
|
||||
pub use wezterm_escape_parser::tmux_cc;
|
||||
|
||||
@@ -141,7 +141,7 @@ impl<'a> FieldInfo<'a> {
|
||||
quote!(
|
||||
#ident: match obj.get_by_str(#name) {
|
||||
Some(v) => {
|
||||
use std::convert::TryFrom;
|
||||
use core::convert::TryFrom;
|
||||
#check_deprecated
|
||||
let target = <#try_from>::from_dynamic(v, options)
|
||||
.map_err(|source| source.field_context(
|
||||
@@ -168,7 +168,7 @@ impl<'a> FieldInfo<'a> {
|
||||
quote!(
|
||||
#ident: match obj.get_by_str(&#name) {
|
||||
Some(v) => {
|
||||
use std::convert::TryFrom;
|
||||
use core::convert::TryFrom;
|
||||
#check_deprecated
|
||||
let target = <#try_from>::from_dynamic(v, options)
|
||||
.map_err(|source| source.field_context(
|
||||
@@ -194,7 +194,7 @@ impl<'a> FieldInfo<'a> {
|
||||
DefValue::None => {
|
||||
quote!(
|
||||
#ident: {
|
||||
use std::convert::TryFrom;
|
||||
use core::convert::TryFrom;
|
||||
let target = <#try_from>::from_dynamic(obj.get_by_str(#name).map(|v| {
|
||||
#check_deprecated
|
||||
v
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
[package]
|
||||
authors = ["Wez Furlong"]
|
||||
name = "wezterm-surface"
|
||||
version = "0.1.0"
|
||||
edition = "2018"
|
||||
repository = "https://github.com/wezterm/wezterm"
|
||||
description = "Surface and Line types for terminals"
|
||||
license = "MIT"
|
||||
documentation = "https://docs.rs/wezterm-surface"
|
||||
keywords = ["terminal", "surface", "line"]
|
||||
|
||||
[dependencies]
|
||||
bitflags = "2.0"
|
||||
fancy-regex.workspace = true
|
||||
finl_unicode.workspace = true
|
||||
fixedbitset.workspace = true
|
||||
ordered-float.workspace = true
|
||||
serde = {workspace=true, optional=true}
|
||||
siphasher.workspace = true
|
||||
unicode-segmentation.workspace = true
|
||||
wezterm-bidi.workspace = true
|
||||
wezterm-blob-leases = {workspace=true, optional=true}
|
||||
wezterm-cell = {workspace = true}
|
||||
wezterm-char-props.workspace = true
|
||||
wezterm-color-types = {workspace = true}
|
||||
wezterm-dynamic = {workspace = true}
|
||||
wezterm-escape-parser = {workspace = true}
|
||||
wezterm-input-types.workspace = true
|
||||
|
||||
[features]
|
||||
default = []
|
||||
std = ["fancy-regex/std", "wezterm-cell/std", "wezterm-dynamic/std", "wezterm-escape-parser/std", "fixedbitset/std", "fancy-regex/perf", "fancy-regex/unicode"]
|
||||
appdata = ["std"]
|
||||
use_serde = ["serde"] #, "wezterm-color-types/use_serde", "wezterm-blob-leases/serde", "bitflags/serde", "wezterm-input-types/serde", "wezterm-escape-parser/use_serde", "wezterm-cell/use_serde"]
|
||||
use_image = ["wezterm-cell/use_image"] # "image", "dep:image", "wezterm-escape-parser/use_image", "wezterm-escape-parser/kitty-shm", "wezterm-cell/use_image"]
|
||||
|
||||
[dev-dependencies]
|
||||
k9.workspace = true
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
use crate::cell::CellAttributes;
|
||||
use crate::surface::line::CellRef;
|
||||
use std::borrow::Cow;
|
||||
use crate::line::CellRef;
|
||||
use alloc::borrow::Cow;
|
||||
use wezterm_bidi::{BidiContext, Direction, ParagraphDirectionHint};
|
||||
use wezterm_cell::CellAttributes;
|
||||
use wezterm_char_props::emoji::Presentation;
|
||||
|
||||
extern crate alloc;
|
||||
use alloc::string::String;
|
||||
use alloc::vec;
|
||||
use alloc::vec::Vec;
|
||||
|
||||
/// A `CellCluster` is another representation of a Line.
|
||||
/// A `Vec<CellCluster>` is produced by walking through the Cells in
|
||||
/// a line and collecting succesive Cells with the same attributes
|
||||
@@ -1,13 +1,18 @@
|
||||
use crate::cell::{unicode_column_width, AttributeChange, CellAttributes};
|
||||
use crate::color::ColorAttribute;
|
||||
use crate::{CursorShape, CursorVisibility, Position};
|
||||
#[cfg(feature = "use_image")]
|
||||
pub use crate::image::{ImageData, TextureCoordinate};
|
||||
use crate::surface::{CursorShape, CursorVisibility, Position};
|
||||
use alloc::sync::Arc;
|
||||
use finl_unicode::grapheme_clusters::Graphemes;
|
||||
#[cfg(feature = "use_serde")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
use wezterm_cell::color::ColorAttribute;
|
||||
#[cfg(feature = "use_image")]
|
||||
use std::sync::Arc;
|
||||
pub use wezterm_cell::image::{ImageData, TextureCoordinate};
|
||||
use wezterm_cell::{unicode_column_width, AttributeChange, CellAttributes};
|
||||
|
||||
extern crate alloc;
|
||||
use alloc::string::String;
|
||||
use alloc::vec;
|
||||
use alloc::vec::Vec;
|
||||
|
||||
#[cfg_attr(feature = "use_serde", derive(Serialize, Deserialize))]
|
||||
#[derive(Debug, Clone, Eq, PartialEq)]
|
||||
@@ -4,14 +4,20 @@
|
||||
//! We use that as the foundation of our hyperlink support, and the game
|
||||
//! plan is to then implicitly enable the hyperlink attribute for a cell
|
||||
//! as we recognize linkable input text during print() processing.
|
||||
use crate::Result;
|
||||
use alloc::sync::Arc;
|
||||
use core::ops::Range;
|
||||
use fancy_regex::{Captures, Regex};
|
||||
#[cfg(feature = "use_serde")]
|
||||
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
||||
use std::ops::Range;
|
||||
use std::sync::Arc;
|
||||
use wezterm_dynamic::{FromDynamic, FromDynamicOptions, ToDynamic, Value};
|
||||
|
||||
extern crate alloc;
|
||||
use crate::alloc::borrow::ToOwned;
|
||||
use crate::alloc::string::ToString;
|
||||
use alloc::format;
|
||||
use alloc::string::String;
|
||||
use alloc::vec::Vec;
|
||||
|
||||
pub use wezterm_escape_parser::hyperlink::Hyperlink;
|
||||
|
||||
/// In addition to handling explicit escape sequences to enable
|
||||
@@ -61,7 +67,7 @@ impl FromDynamic for RegexWrap {
|
||||
fn from_dynamic(
|
||||
value: &Value,
|
||||
options: FromDynamicOptions,
|
||||
) -> std::result::Result<RegexWrap, wezterm_dynamic::Error> {
|
||||
) -> Result<RegexWrap, wezterm_dynamic::Error> {
|
||||
let s = String::from_dynamic(value, options)?;
|
||||
Ok(RegexWrap(Regex::new(&s).map_err(|e| e.to_string())?))
|
||||
}
|
||||
@@ -86,7 +92,7 @@ impl ToDynamic for RegexWrap {
|
||||
}
|
||||
|
||||
#[cfg(feature = "use_serde")]
|
||||
fn deserialize_regex<'de, D>(deserializer: D) -> std::result::Result<Regex, D::Error>
|
||||
fn deserialize_regex<'de, D>(deserializer: D) -> Result<Regex, D::Error>
|
||||
where
|
||||
D: Deserializer<'de>,
|
||||
{
|
||||
@@ -95,7 +101,7 @@ where
|
||||
}
|
||||
|
||||
#[cfg(feature = "use_serde")]
|
||||
fn serialize_regex<S>(regex: &Regex, serializer: S) -> std::result::Result<S::Ok, S::Error>
|
||||
fn serialize_regex<S>(regex: &Regex, serializer: S) -> Result<S::Ok, S::Error>
|
||||
where
|
||||
S: Serializer,
|
||||
{
|
||||
@@ -160,11 +166,15 @@ pub const GENERIC_HYPERLINK_PATTERN: &str = r"\b\w+://\S+[_/a-zA-Z0-9-]";
|
||||
|
||||
impl Rule {
|
||||
/// Construct a new rule. It may fail if the regex is invalid.
|
||||
pub fn new(regex: &str, format: &str) -> Result<Self> {
|
||||
pub fn new(regex: &str, format: &str) -> Result<Self, fancy_regex::Error> {
|
||||
Self::with_highlight(regex, format, 0)
|
||||
}
|
||||
|
||||
pub fn with_highlight(regex: &str, format: &str, highlight: usize) -> Result<Self> {
|
||||
pub fn with_highlight(
|
||||
regex: &str,
|
||||
format: &str,
|
||||
highlight: usize,
|
||||
) -> Result<Self, fancy_regex::Error> {
|
||||
Ok(Self {
|
||||
regex: Regex::new(regex)?,
|
||||
format: format.to_owned(),
|
||||
@@ -1,16 +1,26 @@
|
||||
use crate::cell::{Cell, CellAttributes};
|
||||
use crate::color::ColorAttribute;
|
||||
#[cfg(feature = "use_image")]
|
||||
use crate::image::ImageCell;
|
||||
use crate::surface::line::CellRef;
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
use crate::line::CellRef;
|
||||
use alloc::borrow::Cow;
|
||||
use core::cmp::min;
|
||||
use finl_unicode::grapheme_clusters::Graphemes;
|
||||
#[cfg(feature = "use_serde")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::borrow::Cow;
|
||||
use std::cmp::min;
|
||||
use wezterm_cell::color::ColorAttribute;
|
||||
#[cfg(feature = "use_image")]
|
||||
use wezterm_cell::image::ImageCell;
|
||||
use wezterm_cell::{Cell, CellAttributes};
|
||||
use wezterm_dynamic::{FromDynamic, ToDynamic};
|
||||
|
||||
extern crate alloc;
|
||||
use crate::alloc::borrow::ToOwned;
|
||||
use crate::alloc::string::ToString;
|
||||
use alloc::string::String;
|
||||
use alloc::vec;
|
||||
use alloc::vec::Vec;
|
||||
|
||||
pub mod cellcluster;
|
||||
pub mod change;
|
||||
pub mod hyperlink;
|
||||
pub mod line;
|
||||
|
||||
pub use self::change::{Change, LineAttribute};
|
||||
@@ -907,10 +917,10 @@ fn compute_position_change(current: usize, pos: &Position, limit: usize) -> usiz
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
use crate::cell::{AttributeChange, Intensity};
|
||||
use crate::color::AnsiColor;
|
||||
use crate::image::ImageData;
|
||||
use std::sync::Arc;
|
||||
use alloc::sync::Arc;
|
||||
use wezterm_cell::color::AnsiColor;
|
||||
use wezterm_cell::image::ImageData;
|
||||
use wezterm_cell::{AttributeChange, Intensity};
|
||||
|
||||
// The \x20's look a little awkward, but we can't use a plain
|
||||
// space in the first chararcter of a multi-line continuation;
|
||||
@@ -1180,7 +1190,7 @@ mod test {
|
||||
|
||||
#[test]
|
||||
fn attribute_setting() {
|
||||
use crate::cell::Intensity;
|
||||
use wezterm_cell::Intensity;
|
||||
|
||||
let mut s = Surface::new(3, 1);
|
||||
s.add_change("n");
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::cell::{Cell, CellAttributes};
|
||||
use std::hash::{Hash, Hasher};
|
||||
use core::hash::{Hash, Hasher};
|
||||
use wezterm_cell::{Cell, CellAttributes};
|
||||
use wezterm_char_props::emoji::Presentation;
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
@@ -1,11 +1,17 @@
|
||||
use crate::cell::{Cell, CellAttributes};
|
||||
use crate::surface::line::CellRef;
|
||||
use crate::line::CellRef;
|
||||
use core::convert::TryInto;
|
||||
use core::num::NonZeroU8;
|
||||
use finl_unicode::grapheme_clusters::Graphemes;
|
||||
use fixedbitset::FixedBitSet;
|
||||
#[cfg(feature = "use_serde")]
|
||||
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
||||
use std::convert::TryInto;
|
||||
use std::num::NonZeroU8;
|
||||
use wezterm_cell::{Cell, CellAttributes};
|
||||
|
||||
extern crate alloc;
|
||||
use alloc::boxed::Box;
|
||||
use alloc::string::String;
|
||||
use alloc::vec;
|
||||
use alloc::vec::Vec;
|
||||
|
||||
#[cfg_attr(feature = "use_serde", derive(Serialize, Deserialize))]
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
@@ -326,7 +332,7 @@ impl ClusteredLine {
|
||||
|
||||
pub(crate) struct ClusterLineCellIter<'a> {
|
||||
graphemes: Graphemes<'a>,
|
||||
clusters: std::slice::Iter<'a, Cluster>,
|
||||
clusters: core::slice::Iter<'a, Cluster>,
|
||||
cluster: Option<&'a Cluster>,
|
||||
idx: usize,
|
||||
cluster_total: usize,
|
||||
@@ -370,10 +376,10 @@ mod test {
|
||||
#[test]
|
||||
#[cfg(target_pointer_width = "64")]
|
||||
fn memory_usage() {
|
||||
assert_eq!(std::mem::size_of::<ClusteredLine>(), 64);
|
||||
assert_eq!(std::mem::size_of::<String>(), 24);
|
||||
assert_eq!(std::mem::size_of::<Vec<Cluster>>(), 24);
|
||||
assert_eq!(std::mem::size_of::<Option<Box<FixedBitSet>>>(), 8);
|
||||
assert_eq!(std::mem::size_of::<Option<NonZeroU8>>(), 1);
|
||||
assert_eq!(core::mem::size_of::<ClusteredLine>(), 64);
|
||||
assert_eq!(core::mem::size_of::<String>(), 24);
|
||||
assert_eq!(core::mem::size_of::<Vec<Cluster>>(), 24);
|
||||
assert_eq!(core::mem::size_of::<Option<Box<FixedBitSet>>>(), 8);
|
||||
assert_eq!(core::mem::size_of::<Option<NonZeroU8>>(), 1);
|
||||
}
|
||||
}
|
||||
@@ -1,22 +1,32 @@
|
||||
use crate::cell::{Cell, CellAttributes, SemanticType, UnicodeVersion};
|
||||
use crate::cellcluster::CellCluster;
|
||||
use crate::hyperlink::Rule;
|
||||
use crate::surface::line::cellref::CellRef;
|
||||
use crate::surface::line::clusterline::ClusteredLine;
|
||||
use crate::surface::line::linebits::LineBits;
|
||||
use crate::surface::line::storage::{CellStorage, VisibleCellIter};
|
||||
use crate::surface::line::vecstorage::{VecStorage, VecStorageIter};
|
||||
use crate::surface::{Change, SequenceNo, SEQ_ZERO};
|
||||
use crate::line::cellref::CellRef;
|
||||
use crate::line::clusterline::ClusteredLine;
|
||||
use crate::line::linebits::LineBits;
|
||||
use crate::line::storage::{CellStorage, VisibleCellIter};
|
||||
use crate::line::vecstorage::{VecStorage, VecStorageIter};
|
||||
use crate::{Change, SequenceNo, SEQ_ZERO};
|
||||
use alloc::borrow::Cow;
|
||||
#[cfg(feature = "appdata")]
|
||||
use alloc::sync::{Arc, Weak};
|
||||
#[cfg(feature = "appdata")]
|
||||
use core::any::Any;
|
||||
use core::hash::Hash;
|
||||
use core::ops::Range;
|
||||
use finl_unicode::grapheme_clusters::Graphemes;
|
||||
#[cfg(feature = "use_serde")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
use siphasher::sip128::{Hasher128, SipHasher};
|
||||
use std::any::Any;
|
||||
use std::borrow::Cow;
|
||||
use std::hash::Hash;
|
||||
use std::ops::Range;
|
||||
use std::sync::{Arc, Mutex, Weak};
|
||||
#[cfg(feature = "appdata")]
|
||||
use std::sync::Mutex;
|
||||
use wezterm_bidi::{Direction, ParagraphDirectionHint};
|
||||
use wezterm_cell::{Cell, CellAttributes, SemanticType, UnicodeVersion};
|
||||
|
||||
extern crate alloc;
|
||||
use crate::alloc::string::ToString;
|
||||
use alloc::string::String;
|
||||
use alloc::vec;
|
||||
use alloc::vec::Vec;
|
||||
|
||||
#[cfg_attr(feature = "use_serde", derive(Serialize, Deserialize))]
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
@@ -38,6 +48,7 @@ pub struct Line {
|
||||
zones: Vec<ZoneRange>,
|
||||
seqno: SequenceNo,
|
||||
bits: LineBits,
|
||||
#[cfg(feature = "appdata")]
|
||||
#[cfg_attr(feature = "use_serde", serde(skip))]
|
||||
appdata: Mutex<Option<Weak<dyn Any + Send + Sync>>>,
|
||||
}
|
||||
@@ -49,6 +60,7 @@ impl Clone for Line {
|
||||
zones: self.zones.clone(),
|
||||
seqno: self.seqno,
|
||||
bits: self.bits,
|
||||
#[cfg(feature = "appdata")]
|
||||
appdata: Mutex::new(self.appdata.lock().unwrap().clone()),
|
||||
}
|
||||
}
|
||||
@@ -70,6 +82,7 @@ impl Line {
|
||||
cells: CellStorage::V(VecStorage::new(cells)),
|
||||
seqno,
|
||||
zones: vec![],
|
||||
#[cfg(feature = "appdata")]
|
||||
appdata: Mutex::new(None),
|
||||
}
|
||||
}
|
||||
@@ -81,6 +94,7 @@ impl Line {
|
||||
cells: CellStorage::V(VecStorage::new(cells)),
|
||||
seqno,
|
||||
zones: vec![],
|
||||
#[cfg(feature = "appdata")]
|
||||
appdata: Mutex::new(None),
|
||||
}
|
||||
}
|
||||
@@ -95,6 +109,7 @@ impl Line {
|
||||
cells: CellStorage::C(ClusteredLine::new()),
|
||||
seqno,
|
||||
zones: vec![],
|
||||
#[cfg(feature = "appdata")]
|
||||
appdata: Mutex::new(None),
|
||||
}
|
||||
}
|
||||
@@ -125,6 +140,7 @@ impl Line {
|
||||
cells: CellStorage::V(VecStorage::new(cells)),
|
||||
seqno,
|
||||
zones: vec![],
|
||||
#[cfg(feature = "appdata")]
|
||||
appdata: Mutex::new(None),
|
||||
}
|
||||
}
|
||||
@@ -151,6 +167,7 @@ impl Line {
|
||||
bits: LineBits::NONE,
|
||||
seqno,
|
||||
zones: vec![],
|
||||
#[cfg(feature = "appdata")]
|
||||
appdata: Mutex::new(None),
|
||||
}
|
||||
}
|
||||
@@ -235,6 +252,7 @@ impl Line {
|
||||
/// and not for use by "middleware" crates.
|
||||
/// A Weak reference is stored.
|
||||
/// `get_appdata` is used to retrieve a previously stored reference.
|
||||
#[cfg(feature = "appdata")]
|
||||
pub fn set_appdata<T: Any + Send + Sync>(&self, appdata: Arc<T>) {
|
||||
let appdata: Arc<dyn Any + Send + Sync> = appdata;
|
||||
self.appdata
|
||||
@@ -243,6 +261,7 @@ impl Line {
|
||||
.replace(Arc::downgrade(&appdata));
|
||||
}
|
||||
|
||||
#[cfg(feature = "appdata")]
|
||||
pub fn clear_appdata(&self) {
|
||||
self.appdata.lock().unwrap().take();
|
||||
}
|
||||
@@ -250,6 +269,7 @@ impl Line {
|
||||
/// Retrieve the appdata for the line, if any.
|
||||
/// This may return None in the case where the underlying data has
|
||||
/// been released: Line only stores a Weak reference to it.
|
||||
#[cfg(feature = "appdata")]
|
||||
pub fn get_appdata(&self) -> Option<Arc<dyn Any + Send + Sync>> {
|
||||
self.appdata
|
||||
.lock()
|
||||
@@ -577,6 +597,7 @@ impl Line {
|
||||
if !logical.has_hyperlink() {
|
||||
for line in logical_line.iter_mut() {
|
||||
line.bits.set(LineBits::SCANNED_IMPLICIT_HYPERLINKS, true);
|
||||
#[cfg(feature = "appdata")]
|
||||
line.clear_appdata();
|
||||
}
|
||||
return;
|
||||
@@ -591,6 +612,7 @@ impl Line {
|
||||
**phys = logical;
|
||||
logical = remainder;
|
||||
phys.set_last_cell_was_wrapped(wrapped, seq);
|
||||
#[cfg(feature = "appdata")]
|
||||
phys.clear_appdata();
|
||||
if is_cluster {
|
||||
phys.compress_for_scrollback();
|
||||
@@ -631,6 +653,7 @@ impl Line {
|
||||
cells: CellStorage::V(VecStorage::new(cells)),
|
||||
seqno,
|
||||
zones: vec![],
|
||||
#[cfg(feature = "appdata")]
|
||||
appdata: Mutex::new(None),
|
||||
}
|
||||
}
|
||||
@@ -715,6 +738,7 @@ impl Line {
|
||||
cells: CellStorage::V(VecStorage::new(cells)),
|
||||
seqno: self.current_seqno(),
|
||||
zones: vec![],
|
||||
#[cfg(feature = "appdata")]
|
||||
appdata: Mutex::new(None),
|
||||
}
|
||||
}
|
||||
File renamed without changes.
File renamed without changes.
@@ -1,6 +1,6 @@
|
||||
use crate::surface::line::cellref::CellRef;
|
||||
use crate::surface::line::clusterline::{ClusterLineCellIter, ClusteredLine};
|
||||
use crate::surface::line::vecstorage::{VecStorage, VecStorageIter};
|
||||
use crate::line::cellref::CellRef;
|
||||
use crate::line::clusterline::{ClusterLineCellIter, ClusteredLine};
|
||||
use crate::line::vecstorage::{VecStorage, VecStorageIter};
|
||||
#[cfg(feature = "use_serde")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
#![cfg(test)]
|
||||
|
||||
use super::*;
|
||||
use crate::cell::{Cell, CellAttributes};
|
||||
use crate::hyperlink::{Hyperlink, Rule};
|
||||
use crate::surface::line::clusterline::ClusteredLine;
|
||||
use crate::surface::SEQ_ZERO;
|
||||
use crate::line::clusterline::ClusteredLine;
|
||||
use crate::SEQ_ZERO;
|
||||
use alloc::sync::Arc;
|
||||
use k9::assert_equal as assert_eq;
|
||||
use std::sync::Arc;
|
||||
use wezterm_cell::{Cell, CellAttributes};
|
||||
|
||||
/// There are 4 double-wide graphemes that occupy 2 cells each.
|
||||
/// When we join the lines, we must preserve the invisible blank
|
||||
@@ -302,7 +302,7 @@ Line {
|
||||
}
|
||||
|
||||
fn bold() -> CellAttributes {
|
||||
use crate::cell::Intensity;
|
||||
use wezterm_cell::Intensity;
|
||||
let mut attr = CellAttributes::default();
|
||||
attr.set_intensity(Intensity::Bold);
|
||||
attr
|
||||
@@ -1,9 +1,12 @@
|
||||
use crate::cell::Cell;
|
||||
use crate::surface::line::cellref::CellRef;
|
||||
use crate::line::cellref::CellRef;
|
||||
use alloc::sync::Arc;
|
||||
#[cfg(feature = "use_serde")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::sync::Arc;
|
||||
use unicode_segmentation::UnicodeSegmentation;
|
||||
use wezterm_cell::Cell;
|
||||
|
||||
extern crate alloc;
|
||||
use alloc::vec::Vec;
|
||||
|
||||
#[cfg_attr(feature = "use_serde", derive(Serialize, Deserialize))]
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
@@ -66,7 +69,7 @@ impl VecStorage {
|
||||
}
|
||||
}
|
||||
|
||||
impl std::ops::Deref for VecStorage {
|
||||
impl core::ops::Deref for VecStorage {
|
||||
type Target = Vec<Cell>;
|
||||
|
||||
fn deref(&self) -> &Vec<Cell> {
|
||||
@@ -74,7 +77,7 @@ impl std::ops::Deref for VecStorage {
|
||||
}
|
||||
}
|
||||
|
||||
impl std::ops::DerefMut for VecStorage {
|
||||
impl core::ops::DerefMut for VecStorage {
|
||||
fn deref_mut(&mut self) -> &mut Vec<Cell> {
|
||||
&mut self.cells
|
||||
}
|
||||
@@ -82,7 +85,7 @@ impl std::ops::DerefMut for VecStorage {
|
||||
|
||||
/// Iterates over a slice of Cell, yielding only visible cells
|
||||
pub(crate) struct VecStorageIter<'a> {
|
||||
pub cells: std::slice::Iter<'a, Cell>,
|
||||
pub cells: core::slice::Iter<'a, Cell>,
|
||||
pub idx: usize,
|
||||
pub skip_width: usize,
|
||||
}
|
||||
Reference in new issue
Block a user