Damson: a Material You code editor in Rust

Runs Kate's syntax definitions directly, on a hand-written editor core.
Spring-driven UI with a pop-out scrolling preview, baked-in terminal
grown from a morphing button, jelly tabs, command palette, side panels,
git, language servers and hot exit.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
astar76 2026-11-06 17:05:28 -06:00
commit 8151aa71c0
35 changed files with 13923 additions and 0 deletions

1500
src/app.rs Normal file

File diff suppressed because it is too large Load diff

73
src/config.rs Normal file
View file

@ -0,0 +1,73 @@
//! Settings, stored as JSON in ~/.config/damson/settings.json.
use serde::{Deserialize, Serialize};
use std::path::PathBuf;
pub const APP_NAME: &str = "Damson";
#[derive(Serialize, Deserialize, Clone, PartialEq)]
#[serde(default)]
pub struct Settings {
pub color_source: String, // "auto", "caelestia", "kde", "custom"
pub custom_color: String,
pub mode: String, // "auto", "dark", "light"
pub scheme: String, // "tonal", "vibrant", "expressive", "mono"
pub motion: u8, // 0 off, 1 calm, 2 bouncy, 3 jelly
pub font_size: f32,
pub mono_font: String,
pub tab_width: usize,
pub spaces: bool,
pub auto_close: bool,
pub word_wrap: bool,
pub line_numbers: bool,
pub show_whitespace: bool,
pub indent_guides: bool,
pub preview: bool,
pub lens: bool,
pub trim_on_save: bool,
pub restore_session: bool,
pub shell: String,
pub terminal_font: f32,
pub lsp: bool,
pub recent: Vec<String>,
pub win: [f32; 2],
}
impl Default for Settings {
fn default() -> Self {
Settings {
color_source: "auto".into(), custom_color: "#7f5fc4".into(), mode: "auto".into(), scheme: "tonal".into(),
motion: 2, font_size: 14.0, mono_font: String::new(), tab_width: 4, spaces: true, auto_close: true,
word_wrap: false, line_numbers: true, show_whitespace: false, indent_guides: true, preview: true,
lens: true, trim_on_save: false, restore_session: true, shell: String::new(), terminal_font: 13.0,
lsp: true, recent: vec![], win: [1400.0, 900.0],
}
}
}
pub fn config_dir() -> PathBuf {
dirs::config_dir().unwrap_or_else(|| PathBuf::from(".")).join("damson")
}
impl Settings {
pub fn load() -> Settings {
std::fs::read(config_dir().join("settings.json")).ok().and_then(|b| serde_json::from_slice(&b).ok()).unwrap_or_default()
}
pub fn save(&self) {
let dir = config_dir();
let _ = std::fs::create_dir_all(&dir);
if let Ok(j) = serde_json::to_vec_pretty(self) {
let tmp = dir.join("settings.json.tmp");
if std::fs::write(&tmp, j).is_ok() {
let _ = std::fs::rename(tmp, dir.join("settings.json"));
}
}
}
pub fn note_recent(&mut self, path: &str) {
self.recent.retain(|p| p != path);
self.recent.insert(0, path.to_string());
self.recent.truncate(16);
}
}

102
src/git.rs Normal file
View file

@ -0,0 +1,102 @@
//! Git, by running `git`: branch and file status for the panel, changed lines for the gutter.
use std::collections::HashMap;
use std::path::{Path, PathBuf};
use std::process::Command;
#[derive(Default, Clone)]
pub struct GitState {
pub root: Option<PathBuf>,
pub branch: String,
pub ahead: String,
/// (index status, worktree status, path relative to root)
pub files: Vec<(char, char, String)>,
/// Per file: first line, line count, kind (0 add, 1 change, 2 delete).
pub marks: HashMap<PathBuf, Vec<(usize, usize, u8)>>,
}
fn git(dir: &Path, args: &[&str]) -> Option<String> {
let o = Command::new("git").arg("-C").arg(dir).args(args).output().ok()?;
o.status.success().then(|| String::from_utf8_lossy(&o.stdout).into_owned())
}
pub fn run(dir: &Path, args: &[&str]) -> Result<String, String> {
let o = Command::new("git").arg("-C").arg(dir).args(args).output().map_err(|e| e.to_string())?;
if o.status.success() { Ok(String::from_utf8_lossy(&o.stdout).into_owned()) } else { Err(String::from_utf8_lossy(&o.stderr).trim().to_string()) }
}
/// Reads hunks from `git diff -U0` output.
pub fn parse_hunks(diff: &str) -> Vec<(usize, usize, u8)> {
let mut v = vec![];
for l in diff.lines() {
let Some(rest) = l.strip_prefix("@@ -") else { continue };
let mut parts = rest.split(' ');
let (Some(old), Some(new)) = (parts.next(), parts.next()) else { continue };
let num = |s: &str| -> (usize, usize) {
let mut it = s.trim_start_matches(['+', '-']).split(',');
let a = it.next().and_then(|x| x.parse().ok()).unwrap_or(0);
let b = it.next().and_then(|x| x.parse().ok()).unwrap_or(1);
(a, b)
};
let ((_, oc), (ns, nc)) = (num(old), num(new));
if nc == 0 {
v.push((ns, 1, 2));
} else {
v.push((ns.saturating_sub(1), nc, if oc == 0 { 0 } else { 1 }));
}
}
v
}
pub fn scan(dir: &Path) -> GitState {
let mut st = GitState::default();
let Some(root) = git(dir, &["rev-parse", "--show-toplevel"]) else { return st };
let root = PathBuf::from(root.trim());
st.branch = git(&root, &["branch", "--show-current"]).unwrap_or_default().trim().to_string();
if st.branch.is_empty() {
st.branch = git(&root, &["rev-parse", "--short", "HEAD"]).unwrap_or_default().trim().to_string();
}
if let Some(s) = git(&root, &["rev-list", "--left-right", "--count", "@{u}...HEAD"]) {
let mut p = s.split_whitespace();
let (b, a) = (p.next().unwrap_or("0"), p.next().unwrap_or("0"));
st.ahead = match (a, b) { ("0", "0") => String::new(), ("0", b) => format!("↓{b}"), (a, "0") => format!("↑{a}"), (a, b) => format!("↑{a} ↓{b}") };
}
for l in git(&root, &["status", "--porcelain=v1", "-uall"]).unwrap_or_default().lines() {
let cs: Vec<char> = l.chars().collect();
if cs.len() > 3 {
let path: String = cs[3..].iter().collect();
let path = path.rsplit(" -> ").next().unwrap_or("").trim_matches('"').to_string();
st.files.push((cs[0], cs[1], path));
}
}
let diff = git(&root, &["diff", "-U0", "--no-color", "--no-ext-diff"]).unwrap_or_default();
let mut cur: Option<PathBuf> = None;
let mut chunk = String::new();
let flush = |p: &Option<PathBuf>, c: &mut String, m: &mut HashMap<PathBuf, Vec<(usize, usize, u8)>>| {
if let Some(p) = p { m.insert(p.clone(), parse_hunks(c)); }
c.clear();
};
for l in diff.lines() {
if let Some(f) = l.strip_prefix("+++ b/") {
flush(&cur, &mut chunk, &mut st.marks);
cur = Some(root.join(f));
} else if l.starts_with("@@") {
chunk.push_str(l);
chunk.push('\n');
}
}
flush(&cur, &mut chunk, &mut st.marks);
st.root = Some(root);
st
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn hunks_become_added_changed_and_deleted() {
let d = "@@ -3,0 +4,2 @@\n@@ -9 +11 @@\n@@ -20,2 +21,0 @@\n";
assert_eq!(parse_hunks(d), vec![(3, 2, 0), (10, 1, 1), (21, 1, 2)]);
}
}

146
src/icondata.rs Normal file
View file

@ -0,0 +1,146 @@
//! Material Symbols Rounded (Apache 2.0) path data, viewBox 0 -960 960 960. Generated by tools/gen_icons.py.
pub const ICONS: &[(&str, &str)] = &[
("account_tree", "M600 -200V-240H520Q487 -240 463.5 -263.5Q440 -287 440 -320V-640H360V-600Q360 -567 336.5 -543.5Q313 -520 280 -520H160Q127 -520 103.5 -543.5Q80 -567 80 -600V-760Q80 -793 103.5 -816.5Q127 -840 160 -840H280Q313 -840 336.5 -816.5Q360 -793 360 -760V-720H600V-760Q600 -793 623.5 -816.5Q647 -840 680 -840H800Q833 -840 856.5 -816.5Q880 -793 880 -760V-600Q880 -567 856.5 -543.5Q833 -520 800 -520H680Q647 -520 623.5 -543.5Q600 -567 600 -600V-640H520V-320Q520 -320 520 -320Q520 -320 520 -320H600V-360Q600 -393 623.5 -416.5Q647 -440 680 -440H800Q833 -440 856.5 -416.5Q880 -393 880 -360V-200Q880 -167 856.5 -143.5Q833 -120 800 -120H680Q647 -120 623.5 -143.5Q600 -167 600 -200ZM160 -760V-600ZM680 -360V-200ZM680 -760V-600ZM680 -600H800V-760H680ZM680 -200H800V-360H680ZM160 -600H280V-760H160Z"),
("account_tree_fill", "M600 -200V-240H520Q487 -240 463.5 -263.5Q440 -287 440 -320V-640H360V-600Q360 -567 336.5 -543.5Q313 -520 280 -520H160Q127 -520 103.5 -543.5Q80 -567 80 -600V-760Q80 -793 103.5 -816.5Q127 -840 160 -840H280Q313 -840 336.5 -816.5Q360 -793 360 -760V-720H600V-760Q600 -793 623.5 -816.5Q647 -840 680 -840H800Q833 -840 856.5 -816.5Q880 -793 880 -760V-600Q880 -567 856.5 -543.5Q833 -520 800 -520H680Q647 -520 623.5 -543.5Q600 -567 600 -600V-640H520V-320Q520 -320 520 -320Q520 -320 520 -320H600V-360Q600 -393 623.5 -416.5Q647 -440 680 -440H800Q833 -440 856.5 -416.5Q880 -393 880 -360V-200Q880 -167 856.5 -143.5Q833 -120 800 -120H680Q647 -120 623.5 -143.5Q600 -167 600 -200ZM160 -760H280V-600H160ZM680 -360H800V-200H680ZM680 -760H800V-600H680ZM680 -600H800V-760H680ZM680 -200H800V-360H680ZM160 -600H280V-760H160Z"),
("add", "M440 -440H240Q223 -440 211.5 -451.5Q200 -463 200 -480Q200 -497 211.5 -508.5Q223 -520 240 -520H440V-720Q440 -737 451.5 -748.5Q463 -760 480 -760Q497 -760 508.5 -748.5Q520 -737 520 -720V-520H720Q737 -520 748.5 -508.5Q760 -497 760 -480Q760 -463 748.5 -451.5Q737 -440 720 -440H520V-240Q520 -223 508.5 -211.5Q497 -200 480 -200Q463 -200 451.5 -211.5Q440 -223 440 -240Z"),
("arrow_back", "M313 -440 509 -244Q521 -232 520.5 -216Q520 -200 508 -188Q496 -177 480 -176.5Q464 -176 452 -188L188 -452Q182 -458 179.5 -465Q177 -472 177 -480Q177 -488 179.5 -495Q182 -502 188 -508L452 -772Q463 -783 479.5 -783Q496 -783 508 -772Q520 -760 520 -743.5Q520 -727 508 -715L313 -520H760Q777 -520 788.5 -508.5Q800 -497 800 -480Q800 -463 788.5 -451.5Q777 -440 760 -440Z"),
("arrow_downward", "M440 -313V-760Q440 -777 451.5 -788.5Q463 -800 480 -800Q497 -800 508.5 -788.5Q520 -777 520 -760V-313L716 -509Q728 -521 744 -520.5Q760 -520 772 -508Q783 -496 783.5 -480Q784 -464 772 -452L508 -188Q502 -182 495 -179.5Q488 -177 480 -177Q472 -177 465 -179.5Q458 -182 452 -188L188 -452Q177 -463 177 -479.5Q177 -496 188 -508Q200 -520 216.5 -520Q233 -520 245 -508Z"),
("arrow_forward", "M647 -440H200Q183 -440 171.5 -451.5Q160 -463 160 -480Q160 -497 171.5 -508.5Q183 -520 200 -520H647L451 -716Q439 -728 439.5 -744Q440 -760 452 -772Q464 -783 480 -783.5Q496 -784 508 -772L772 -508Q778 -502 780.5 -495Q783 -488 783 -480Q783 -472 780.5 -465Q778 -458 772 -452L508 -188Q497 -177 480.5 -177Q464 -177 452 -188Q440 -200 440 -216.5Q440 -233 452 -245Z"),
("arrow_upward", "M440 -647 244 -451Q232 -439 216 -439.5Q200 -440 188 -452Q177 -464 176.5 -480Q176 -496 188 -508L452 -772Q458 -778 465 -780.5Q472 -783 480 -783Q488 -783 495 -780.5Q502 -778 508 -772L772 -508Q783 -497 783 -480.5Q783 -464 772 -452Q760 -440 743.5 -440Q727 -440 715 -452L520 -647V-200Q520 -183 508.5 -171.5Q497 -160 480 -160Q463 -160 451.5 -171.5Q440 -183 440 -200Z"),
("article", "M200 -120Q167 -120 143.5 -143.5Q120 -167 120 -200V-760Q120 -793 143.5 -816.5Q167 -840 200 -840H760Q793 -840 816.5 -816.5Q840 -793 840 -760V-200Q840 -167 816.5 -143.5Q793 -120 760 -120ZM200 -200H760Q760 -200 760 -200Q760 -200 760 -200V-760Q760 -760 760 -760Q760 -760 760 -760H200Q200 -760 200 -760Q200 -760 200 -760V-200Q200 -200 200 -200Q200 -200 200 -200ZM200 -760Q200 -760 200 -760Q200 -760 200 -760V-200Q200 -200 200 -200Q200 -200 200 -200Q200 -200 200 -200Q200 -200 200 -200V-760Q200 -760 200 -760Q200 -760 200 -760ZM320 -280H520Q537 -280 548.5 -291.5Q560 -303 560 -320Q560 -337 548.5 -348.5Q537 -360 520 -360H320Q303 -360 291.5 -348.5Q280 -337 280 -320Q280 -303 291.5 -291.5Q303 -280 320 -280ZM320 -440H640Q657 -440 668.5 -451.5Q680 -463 680 -480Q680 -497 668.5 -508.5Q657 -520 640 -520H320Q303 -520 291.5 -508.5Q280 -497 280 -480Q280 -463 291.5 -451.5Q303 -440 320 -440ZM320 -600H640Q657 -600 668.5 -611.5Q680 -623 680 -640Q680 -657 668.5 -668.5Q657 -680 640 -680H320Q303 -680 291.5 -668.5Q280 -657 280 -640Q280 -623 291.5 -611.5Q303 -600 320 -600Z"),
("article_fill", "M200 -120Q167 -120 143.5 -143.5Q120 -167 120 -200V-760Q120 -793 143.5 -816.5Q167 -840 200 -840H760Q793 -840 816.5 -816.5Q840 -793 840 -760V-200Q840 -167 816.5 -143.5Q793 -120 760 -120ZM200 -200H760Q760 -200 760 -200Q760 -200 760 -200V-760Q760 -760 760 -760Q760 -760 760 -760H200Q200 -760 200 -760Q200 -760 200 -760V-200Q200 -200 200 -200Q200 -200 200 -200ZM200 -760H760Q760 -760 760 -760Q760 -760 760 -760V-200Q760 -200 760 -200Q760 -200 760 -200H200Q200 -200 200 -200Q200 -200 200 -200V-760Q200 -760 200 -760Q200 -760 200 -760ZM320 -280H520Q537 -280 548.5 -291.5Q560 -303 560 -320Q560 -337 548.5 -348.5Q537 -360 520 -360H320Q303 -360 291.5 -348.5Q280 -337 280 -320Q280 -303 291.5 -291.5Q303 -280 320 -280ZM320 -440H640Q657 -440 668.5 -451.5Q680 -463 680 -480Q680 -497 668.5 -508.5Q657 -520 640 -520H320Q303 -520 291.5 -508.5Q280 -497 280 -480Q280 -463 291.5 -451.5Q303 -440 320 -440ZM320 -600H640Q657 -600 668.5 -611.5Q680 -623 680 -640Q680 -657 668.5 -668.5Q657 -680 640 -680H320Q303 -680 291.5 -668.5Q280 -657 280 -640Q280 -623 291.5 -611.5Q303 -600 320 -600Z"),
("bolt", "M422 -232 629 -480H469L498 -707L313 -440H452ZM360 -360H236Q212 -360 200.5 -381.5Q189 -403 203 -423L502 -853Q512 -867 528 -872.5Q544 -878 561 -872Q578 -866 586 -851Q594 -836 592 -819L560 -560H715Q741 -560 751.5 -537Q762 -514 745 -494L416 -100Q405 -87 389 -83Q373 -79 358 -86Q343 -93 334.5 -107.5Q326 -122 328 -139ZM471 -470Z"),
("bolt_fill", "M422 -232 629 -480H469L498 -707L313 -440H452ZM360 -360H236Q212 -360 200.5 -381.5Q189 -403 203 -423L502 -853Q512 -867 528 -872.5Q544 -878 561 -872Q578 -866 586 -851Q594 -836 592 -819L560 -560H715Q741 -560 751.5 -537Q762 -514 745 -494L416 -100Q405 -87 389 -83Q373 -79 358 -86Q343 -93 334.5 -107.5Q326 -122 328 -139ZM422 -232 452 -440H313L498 -707L469 -480H629Z"),
("bookmark", "M480 -240 312 -168Q272 -151 236 -174.5Q200 -198 200 -241V-760Q200 -793 223.5 -816.5Q247 -840 280 -840H680Q713 -840 736.5 -816.5Q760 -793 760 -760V-241Q760 -198 724 -174.5Q688 -151 648 -168ZM480 -328 680 -242Q680 -242 680 -242Q680 -242 680 -242V-760Q680 -760 680 -760Q680 -760 680 -760H280Q280 -760 280 -760Q280 -760 280 -760V-242Q280 -242 280 -242Q280 -242 280 -242ZM480 -760H280Q280 -760 280 -760Q280 -760 280 -760Q280 -760 280 -760Q280 -760 280 -760H680Q680 -760 680 -760Q680 -760 680 -760Q680 -760 680 -760Q680 -760 680 -760Z"),
("bookmark_add", "M480 -240 312 -168Q272 -151 236 -174.5Q200 -198 200 -241V-760Q200 -793 223.5 -816.5Q247 -840 280 -840H480Q497 -840 508.5 -828.5Q520 -817 520 -800Q520 -783 508.5 -771.5Q497 -760 480 -760H280Q280 -760 280 -760Q280 -760 280 -760V-242Q280 -242 280 -242Q280 -242 280 -242L480 -328L680 -242Q680 -242 680 -242Q680 -242 680 -242V-480Q680 -497 691.5 -508.5Q703 -520 720 -520Q737 -520 748.5 -508.5Q760 -497 760 -480V-241Q760 -198 724 -174.5Q688 -151 648 -168ZM480 -760H280Q280 -760 280 -760Q280 -760 280 -760Q280 -760 280 -760Q280 -760 280 -760H520Q520 -760 520 -760Q520 -760 520 -760Q520 -760 520 -760Q520 -760 520 -760Q520 -760 520 -760Q520 -760 520 -760ZM680 -680H640Q623 -680 611.5 -691.5Q600 -703 600 -720Q600 -737 611.5 -748.5Q623 -760 640 -760H680V-800Q680 -817 691.5 -828.5Q703 -840 720 -840Q737 -840 748.5 -828.5Q760 -817 760 -800V-760H800Q817 -760 828.5 -748.5Q840 -737 840 -720Q840 -703 828.5 -691.5Q817 -680 800 -680H760V-640Q760 -623 748.5 -611.5Q737 -600 720 -600Q703 -600 691.5 -611.5Q680 -623 680 -640Z"),
("bookmark_add_fill", "M480 -240 312 -168Q272 -151 236 -174.5Q200 -198 200 -241V-760Q200 -793 223.5 -816.5Q247 -840 280 -840H498Q518 -840 529 -822.5Q540 -805 531 -785Q529 -779 527.5 -773Q526 -767 524 -760H280Q280 -760 280 -760Q280 -760 280 -760V-242Q280 -242 280 -242Q280 -242 280 -242L480 -328L680 -242Q680 -242 680 -242Q680 -242 680 -242V-524Q692 -522 701.5 -521.5Q711 -521 720 -521Q737 -521 748.5 -510.5Q760 -500 760 -484V-241Q760 -198 724 -174.5Q688 -151 648 -168ZM480 -328 280 -242Q280 -242 280 -242Q280 -242 280 -242V-760Q280 -760 280 -760Q280 -760 280 -760H524Q522 -750 521 -740.5Q520 -731 520 -720Q520 -648 565.5 -593Q611 -538 680 -524V-242Q680 -242 680 -242Q680 -242 680 -242ZM680 -680H640Q623 -680 611.5 -691.5Q600 -703 600 -720Q600 -737 611.5 -748.5Q623 -760 640 -760H680V-800Q680 -817 691.5 -828.5Q703 -840 720 -840Q737 -840 748.5 -828.5Q760 -817 760 -800V-760H800Q817 -760 828.5 -748.5Q840 -737 840 -720Q840 -703 828.5 -691.5Q817 -680 800 -680H760V-640Q760 -623 748.5 -611.5Q737 -600 720 -600Q703 -600 691.5 -611.5Q680 -623 680 -640Z"),
("bookmark_fill", "M480 -240 312 -168Q272 -151 236 -174.5Q200 -198 200 -241V-760Q200 -793 223.5 -816.5Q247 -840 280 -840H680Q713 -840 736.5 -816.5Q760 -793 760 -760V-241Q760 -198 724 -174.5Q688 -151 648 -168ZM480 -328 680 -242Q680 -242 680 -242Q680 -242 680 -242V-760Q680 -760 680 -760Q680 -760 680 -760H280Q280 -760 280 -760Q280 -760 280 -760V-242Q280 -242 280 -242Q280 -242 280 -242ZM480 -328 280 -242Q280 -242 280 -242Q280 -242 280 -242V-760Q280 -760 280 -760Q280 -760 280 -760H680Q680 -760 680 -760Q680 -760 680 -760V-242Q680 -242 680 -242Q680 -242 680 -242Z"),
("build", "M360 -360Q260 -360 190 -430Q120 -500 120 -600Q120 -620 123 -640Q126 -660 134 -678Q139 -688 146.5 -693Q154 -698 163 -700Q172 -702 181.5 -699.5Q191 -697 199 -689L304 -584L376 -656L271 -761Q263 -769 260.5 -778.5Q258 -788 260 -797Q262 -806 267 -813.5Q272 -821 282 -826Q300 -834 320 -837Q340 -840 360 -840Q460 -840 530 -770Q600 -700 600 -600Q600 -577 596 -556.5Q592 -536 584 -516L786 -316Q815 -287 815 -245Q815 -203 786 -174Q757 -145 715 -145Q673 -145 644 -175L444 -376Q424 -368 403.5 -364Q383 -360 360 -360ZM360 -440Q386 -440 412 -448Q438 -456 459 -473L702 -230Q707 -225 715.5 -225.5Q724 -226 729 -231Q734 -236 734 -244.5Q734 -253 729 -258L486 -500Q504 -520 512 -546.5Q520 -573 520 -600Q520 -660 481.5 -704.5Q443 -749 386 -758L460 -684Q472 -672 472 -656Q472 -640 460 -628L332 -500Q320 -488 304 -488Q288 -488 276 -500L202 -574Q211 -517 255.5 -478.5Q300 -440 360 -440ZM469 -491Q469 -491 469 -491Q469 -491 469 -491Q469 -491 469 -491Q469 -491 469 -491Q469 -491 469 -491Q469 -491 469 -491Q469 -491 469 -491Q469 -491 469 -491Q469 -491 469 -491Q469 -491 469 -491Q469 -491 469 -491Q469 -491 469 -491Q469 -491 469 -491Q469 -491 469 -491Q469 -491 469 -491Q469 -491 469 -491Z"),
("build_fill", "M360 -360Q260 -360 190 -430Q120 -500 120 -600Q120 -620 123 -640Q126 -660 134 -678Q139 -688 146.5 -693Q154 -698 163 -700Q172 -702 181.5 -699.5Q191 -697 199 -689L304 -584L376 -656L271 -761Q263 -769 260.5 -778.5Q258 -788 260 -797Q262 -806 267 -813.5Q272 -821 282 -826Q300 -834 320 -837Q340 -840 360 -840Q460 -840 530 -770Q600 -700 600 -600Q600 -577 596 -556.5Q592 -536 584 -516L786 -316Q815 -287 815 -245Q815 -203 786 -174Q757 -145 715 -145Q673 -145 644 -175L444 -376Q424 -368 403.5 -364Q383 -360 360 -360ZM360 -440Q386 -440 412 -448Q438 -456 459 -473L702 -230Q707 -225 715.5 -225.5Q724 -226 729 -231Q734 -236 734 -244.5Q734 -253 729 -258L486 -500Q504 -520 512 -546.5Q520 -573 520 -600Q520 -660 481.5 -704.5Q443 -749 386 -758L460 -684Q472 -672 472 -656Q472 -640 460 -628L332 -500Q320 -488 304 -488Q288 -488 276 -500L202 -574Q211 -517 255.5 -478.5Q300 -440 360 -440ZM360 -440Q300 -440 255.5 -478.5Q211 -517 202 -574L276 -500Q288 -488 304 -488Q320 -488 332 -500L460 -628Q472 -640 472 -656Q472 -672 460 -684L386 -758Q443 -749 481.5 -704.5Q520 -660 520 -600Q520 -573 512 -546.5Q504 -520 486 -500L728 -258Q733 -253 733 -244.5Q733 -236 728 -231Q723 -226 715 -225.5Q707 -225 702 -230L459 -473Q438 -456 412 -448Q386 -440 360 -440Z"),
("call_split", "M240 -664V-600Q240 -583 228.5 -571.5Q217 -560 200 -560Q183 -560 171.5 -571.5Q160 -583 160 -600V-760Q160 -777 171.5 -788.5Q183 -800 200 -800H360Q377 -800 388.5 -788.5Q400 -777 400 -760Q400 -743 388.5 -731.5Q377 -720 360 -720H296L497 -519Q508 -508 514 -493.5Q520 -479 520 -463V-200Q520 -183 508.5 -171.5Q497 -160 480 -160Q463 -160 451.5 -171.5Q440 -183 440 -200V-464Q440 -464 440 -464Q440 -464 440 -464ZM720 -664 622 -565Q610 -553 593.5 -553Q577 -553 565 -565Q553 -577 553 -594Q553 -611 565 -623L664 -720H600Q583 -720 571.5 -731.5Q560 -743 560 -760Q560 -777 571.5 -788.5Q583 -800 600 -800H760Q777 -800 788.5 -788.5Q800 -777 800 -760V-600Q800 -583 788.5 -571.5Q777 -560 760 -560Q743 -560 731.5 -571.5Q720 -583 720 -600Z"),
("check", "M382 -354 721 -693Q733 -705 749 -705Q765 -705 777 -693Q789 -681 789 -664.5Q789 -648 777 -636L410 -268Q398 -256 382 -256Q366 -256 354 -268L182 -440Q170 -452 170.5 -468.5Q171 -485 183 -497Q195 -509 211.5 -509Q228 -509 240 -497Z"),
("check_circle", "M424 -408 338 -494Q327 -505 310 -505Q293 -505 282 -494Q271 -483 271 -466Q271 -449 282 -438L396 -324Q408 -312 424 -312Q440 -312 452 -324L678 -550Q689 -561 689 -578Q689 -595 678 -606Q667 -617 650 -617Q633 -617 622 -606ZM480 -80Q397 -80 324 -111.5Q251 -143 197 -197Q143 -251 111.5 -324Q80 -397 80 -480Q80 -563 111.5 -636Q143 -709 197 -763Q251 -817 324 -848.5Q397 -880 480 -880Q563 -880 636 -848.5Q709 -817 763 -763Q817 -709 848.5 -636Q880 -563 880 -480Q880 -397 848.5 -324Q817 -251 763 -197Q709 -143 636 -111.5Q563 -80 480 -80ZM480 -160Q614 -160 707 -253Q800 -346 800 -480Q800 -614 707 -707Q614 -800 480 -800Q346 -800 253 -707Q160 -614 160 -480Q160 -346 253 -253Q346 -160 480 -160ZM480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Z"),
("check_circle_fill", "M424 -408 338 -494Q327 -505 310 -505Q293 -505 282 -494Q271 -483 271 -466Q271 -449 282 -438L396 -324Q408 -312 424 -312Q440 -312 452 -324L678 -550Q689 -561 689 -578Q689 -595 678 -606Q667 -617 650 -617Q633 -617 622 -606ZM480 -80Q397 -80 324 -111.5Q251 -143 197 -197Q143 -251 111.5 -324Q80 -397 80 -480Q80 -563 111.5 -636Q143 -709 197 -763Q251 -817 324 -848.5Q397 -880 480 -880Q563 -880 636 -848.5Q709 -817 763 -763Q817 -709 848.5 -636Q880 -563 880 -480Q880 -397 848.5 -324Q817 -251 763 -197Q709 -143 636 -111.5Q563 -80 480 -80ZM480 -160Q614 -160 707 -253Q800 -346 800 -480Q800 -614 707 -707Q614 -800 480 -800Q346 -800 253 -707Q160 -614 160 -480Q160 -346 253 -253Q346 -160 480 -160ZM480 -160Q346 -160 253 -253Q160 -346 160 -480Q160 -614 253 -707Q346 -800 480 -800Q614 -800 707 -707Q800 -614 800 -480Q800 -346 707 -253Q614 -160 480 -160Z"),
("chevron_left", "M432 -480 588 -324Q599 -313 599 -296Q599 -279 588 -268Q577 -257 560 -257Q543 -257 532 -268L348 -452Q342 -458 339.5 -465Q337 -472 337 -480Q337 -488 339.5 -495Q342 -502 348 -508L532 -692Q543 -703 560 -703Q577 -703 588 -692Q599 -681 599 -664Q599 -647 588 -636Z"),
("chevron_right", "M504 -480 348 -636Q337 -647 337 -664Q337 -681 348 -692Q359 -703 376 -703Q393 -703 404 -692L588 -508Q594 -502 596.5 -495Q599 -488 599 -480Q599 -472 596.5 -465Q594 -458 588 -452L404 -268Q393 -257 376 -257Q359 -257 348 -268Q337 -279 337 -296Q337 -313 348 -324Z"),
("close", "M480 -424 284 -228Q273 -217 256 -217Q239 -217 228 -228Q217 -239 217 -256Q217 -273 228 -284L424 -480L228 -676Q217 -687 217 -704Q217 -721 228 -732Q239 -743 256 -743Q273 -743 284 -732L480 -536L676 -732Q687 -743 704 -743Q721 -743 732 -732Q743 -721 743 -704Q743 -687 732 -676L536 -480L732 -284Q743 -273 743 -256Q743 -239 732 -228Q721 -217 704 -217Q687 -217 676 -228Z"),
("close_fullscreen", "M400 -344 164 -108Q153 -97 136 -97Q119 -97 108 -108Q97 -119 97 -136Q97 -153 108 -164L344 -400H200Q183 -400 171.5 -411.5Q160 -423 160 -440Q160 -457 171.5 -468.5Q183 -480 200 -480H440Q457 -480 468.5 -468.5Q480 -457 480 -440V-200Q480 -183 468.5 -171.5Q457 -160 440 -160Q423 -160 411.5 -171.5Q400 -183 400 -200ZM616 -560H760Q777 -560 788.5 -548.5Q800 -537 800 -520Q800 -503 788.5 -491.5Q777 -480 760 -480H520Q503 -480 491.5 -491.5Q480 -503 480 -520V-760Q480 -777 491.5 -788.5Q503 -800 520 -800Q537 -800 548.5 -788.5Q560 -777 560 -760V-616L796 -852Q807 -863 824 -863Q841 -863 852 -852Q863 -841 863 -824Q863 -807 852 -796Z"),
("code", "M193 -479 348 -324Q359 -313 359 -296Q359 -279 348 -268Q337 -257 320 -257Q303 -257 292 -268L108 -452Q102 -458 99.5 -465Q97 -472 97 -480Q97 -488 99.5 -495Q102 -502 108 -508L292 -692Q304 -704 320.5 -704Q337 -704 349 -692Q361 -680 361 -663.5Q361 -647 349 -635ZM767 -481 612 -636Q601 -647 601 -664Q601 -681 612 -692Q623 -703 640 -703Q657 -703 668 -692L852 -508Q858 -502 860.5 -495Q863 -488 863 -480Q863 -472 860.5 -465Q858 -458 852 -452L668 -268Q656 -256 640 -256.5Q624 -257 612 -269Q600 -281 600 -297.5Q600 -314 612 -326Z"),
("commit", "M284 -440H120Q103 -440 91.5 -451.5Q80 -463 80 -480Q80 -497 91.5 -508.5Q103 -520 120 -520H284Q298 -589 352.5 -634.5Q407 -680 480 -680Q553 -680 607.5 -634.5Q662 -589 676 -520H840Q857 -520 868.5 -508.5Q880 -497 880 -480Q880 -463 868.5 -451.5Q857 -440 840 -440H676Q662 -371 607.5 -325.5Q553 -280 480 -280Q407 -280 352.5 -325.5Q298 -371 284 -440ZM480 -360Q530 -360 565 -395Q600 -430 600 -480Q600 -530 565 -565Q530 -600 480 -600Q430 -600 395 -565Q360 -530 360 -480Q360 -430 395 -395Q430 -360 480 -360Z"),
("content_copy", "M360 -240Q327 -240 303.5 -263.5Q280 -287 280 -320V-800Q280 -833 303.5 -856.5Q327 -880 360 -880H720Q753 -880 776.5 -856.5Q800 -833 800 -800V-320Q800 -287 776.5 -263.5Q753 -240 720 -240ZM360 -320H720Q720 -320 720 -320Q720 -320 720 -320V-800Q720 -800 720 -800Q720 -800 720 -800H360Q360 -800 360 -800Q360 -800 360 -800V-320Q360 -320 360 -320Q360 -320 360 -320ZM200 -80Q167 -80 143.5 -103.5Q120 -127 120 -160V-680Q120 -697 131.5 -708.5Q143 -720 160 -720Q177 -720 188.5 -708.5Q200 -697 200 -680V-160Q200 -160 200 -160Q200 -160 200 -160H600Q617 -160 628.5 -148.5Q640 -137 640 -120Q640 -103 628.5 -91.5Q617 -80 600 -80ZM360 -320Q360 -320 360 -320Q360 -320 360 -320V-800Q360 -800 360 -800Q360 -800 360 -800Q360 -800 360 -800Q360 -800 360 -800V-320Q360 -320 360 -320Q360 -320 360 -320Z"),
("content_copy_fill", "M360 -240Q327 -240 303.5 -263.5Q280 -287 280 -320V-800Q280 -833 303.5 -856.5Q327 -880 360 -880H720Q753 -880 776.5 -856.5Q800 -833 800 -800V-320Q800 -287 776.5 -263.5Q753 -240 720 -240ZM360 -320H720Q720 -320 720 -320Q720 -320 720 -320V-800Q720 -800 720 -800Q720 -800 720 -800H360Q360 -800 360 -800Q360 -800 360 -800V-320Q360 -320 360 -320Q360 -320 360 -320ZM200 -80Q167 -80 143.5 -103.5Q120 -127 120 -160V-680Q120 -697 131.5 -708.5Q143 -720 160 -720Q177 -720 188.5 -708.5Q200 -697 200 -680V-160Q200 -160 200 -160Q200 -160 200 -160H600Q617 -160 628.5 -148.5Q640 -137 640 -120Q640 -103 628.5 -91.5Q617 -80 600 -80ZM360 -320Q360 -320 360 -320Q360 -320 360 -320V-800Q360 -800 360 -800Q360 -800 360 -800H720Q720 -800 720 -800Q720 -800 720 -800V-320Q720 -320 720 -320Q720 -320 720 -320Z"),
("content_cut", "M480 -400 386 -306Q394 -291 397 -274Q400 -257 400 -240Q400 -174 353 -127Q306 -80 240 -80Q174 -80 127 -127Q80 -174 80 -240Q80 -306 127 -353Q174 -400 240 -400Q257 -400 274 -397Q291 -394 306 -386L400 -480L306 -574Q291 -566 274 -563Q257 -560 240 -560Q174 -560 127 -607Q80 -654 80 -720Q80 -786 127 -833Q174 -880 240 -880Q306 -880 353 -833Q400 -786 400 -720Q400 -703 397 -686Q394 -669 386 -654L824 -216Q851 -189 836 -154.5Q821 -120 783 -120Q772 -120 761.5 -124.5Q751 -129 743 -137ZM600 -520 520 -600 743 -823Q751 -831 761.5 -835.5Q772 -840 783 -840Q821 -840 835.5 -805Q850 -770 823 -743ZM240 -640Q273 -640 296.5 -663.5Q320 -687 320 -720Q320 -753 296.5 -776.5Q273 -800 240 -800Q207 -800 183.5 -776.5Q160 -753 160 -720Q160 -687 183.5 -663.5Q207 -640 240 -640ZM480 -460Q488 -460 494 -466Q500 -472 500 -480Q500 -488 494 -494Q488 -500 480 -500Q472 -500 466 -494Q460 -488 460 -480Q460 -472 466 -466Q472 -460 480 -460ZM240 -160Q273 -160 296.5 -183.5Q320 -207 320 -240Q320 -273 296.5 -296.5Q273 -320 240 -320Q207 -320 183.5 -296.5Q160 -273 160 -240Q160 -207 183.5 -183.5Q207 -160 240 -160Z"),
("content_paste", "M200 -120Q167 -120 143.5 -143.5Q120 -167 120 -200V-760Q120 -793 143.5 -816.5Q167 -840 200 -840H367Q378 -875 410 -897.5Q442 -920 480 -920Q520 -920 551.5 -897.5Q583 -875 594 -840H760Q793 -840 816.5 -816.5Q840 -793 840 -760V-200Q840 -167 816.5 -143.5Q793 -120 760 -120ZM200 -200H760Q760 -200 760 -200Q760 -200 760 -200V-760Q760 -760 760 -760Q760 -760 760 -760H680V-680Q680 -663 668.5 -651.5Q657 -640 640 -640H320Q303 -640 291.5 -651.5Q280 -663 280 -680V-760H200Q200 -760 200 -760Q200 -760 200 -760V-200Q200 -200 200 -200Q200 -200 200 -200ZM480 -760Q497 -760 508.5 -771.5Q520 -783 520 -800Q520 -817 508.5 -828.5Q497 -840 480 -840Q463 -840 451.5 -828.5Q440 -817 440 -800Q440 -783 451.5 -771.5Q463 -760 480 -760Z"),
("contrast", "M480 -80Q397 -80 324 -111.5Q251 -143 197 -197Q143 -251 111.5 -324Q80 -397 80 -480Q80 -563 111.5 -636Q143 -709 197 -763Q251 -817 324 -848.5Q397 -880 480 -880Q563 -880 636 -848.5Q709 -817 763 -763Q817 -709 848.5 -636Q880 -563 880 -480Q880 -397 848.5 -324Q817 -251 763 -197Q709 -143 636 -111.5Q563 -80 480 -80ZM520 -163Q639 -178 719.5 -267.5Q800 -357 800 -480Q800 -603 719.5 -692.5Q639 -782 520 -797Z"),
("dark_mode", "M480 -120Q329 -120 224.5 -224.5Q120 -329 120 -480Q120 -618 210 -719.5Q300 -821 440 -838Q453 -840 463 -834.5Q473 -829 479 -820Q485 -811 485.5 -799Q486 -787 478 -776Q461 -750 452.5 -721Q444 -692 444 -660Q444 -570 507 -507Q570 -444 660 -444Q691 -444 721.5 -453Q752 -462 776 -478Q787 -485 798.5 -484.5Q810 -484 819 -479Q829 -474 834.5 -464Q840 -454 838 -440Q824 -302 720.5 -211Q617 -120 480 -120ZM480 -200Q568 -200 638 -248.5Q708 -297 740 -375Q720 -370 700 -367Q680 -364 660 -364Q537 -364 450.5 -450.5Q364 -537 364 -660Q364 -680 367 -700Q370 -720 375 -740Q297 -708 248.5 -638Q200 -568 200 -480Q200 -364 282 -282Q364 -200 480 -200ZM470 -470Q470 -470 470 -470Q470 -470 470 -470Q470 -470 470 -470Q470 -470 470 -470Q470 -470 470 -470Q470 -470 470 -470Q470 -470 470 -470Q470 -470 470 -470Q470 -470 470 -470Q470 -470 470 -470Q470 -470 470 -470Q470 -470 470 -470Z"),
("dark_mode_fill", "M480 -120Q329 -120 224.5 -224.5Q120 -329 120 -480Q120 -618 210 -719.5Q300 -821 440 -838Q453 -840 463 -834.5Q473 -829 479 -820Q485 -811 485.5 -799Q486 -787 478 -776Q461 -750 452.5 -721Q444 -692 444 -660Q444 -570 507 -507Q570 -444 660 -444Q691 -444 721.5 -453Q752 -462 776 -478Q787 -485 798.5 -484.5Q810 -484 819 -479Q829 -474 834.5 -464Q840 -454 838 -440Q824 -302 720.5 -211Q617 -120 480 -120ZM480 -200Q568 -200 638 -248.5Q708 -297 740 -375Q720 -370 700 -367Q680 -364 660 -364Q537 -364 450.5 -450.5Q364 -537 364 -660Q364 -680 367 -700Q370 -720 375 -740Q297 -708 248.5 -638Q200 -568 200 -480Q200 -364 282 -282Q364 -200 480 -200ZM480 -200Q364 -200 282 -282Q200 -364 200 -480Q200 -568 248.5 -638Q297 -708 375 -740Q370 -720 367 -700Q364 -680 364 -660Q364 -537 450.5 -450.5Q537 -364 660 -364Q680 -364 700 -367Q720 -370 740 -375Q708 -297 638 -248.5Q568 -200 480 -200Z"),
("data_object", "M600 -160Q583 -160 571.5 -171.5Q560 -183 560 -200Q560 -217 571.5 -228.5Q583 -240 600 -240H680Q697 -240 708.5 -251.5Q720 -263 720 -280V-360Q720 -398 742 -429Q764 -460 800 -473V-487Q764 -500 742 -531Q720 -562 720 -600V-680Q720 -697 708.5 -708.5Q697 -720 680 -720H600Q583 -720 571.5 -731.5Q560 -743 560 -760Q560 -777 571.5 -788.5Q583 -800 600 -800H680Q730 -800 765 -765Q800 -730 800 -680V-600Q800 -583 811.5 -571.5Q823 -560 840 -560Q857 -560 868.5 -548.5Q880 -537 880 -520V-440Q880 -423 868.5 -411.5Q857 -400 840 -400Q823 -400 811.5 -388.5Q800 -377 800 -360V-280Q800 -230 765 -195Q730 -160 680 -160ZM280 -160Q230 -160 195 -195Q160 -230 160 -280V-360Q160 -377 148.5 -388.5Q137 -400 120 -400Q103 -400 91.5 -411.5Q80 -423 80 -440V-520Q80 -537 91.5 -548.5Q103 -560 120 -560Q137 -560 148.5 -571.5Q160 -583 160 -600V-680Q160 -730 195 -765Q230 -800 280 -800H360Q377 -800 388.5 -788.5Q400 -777 400 -760Q400 -743 388.5 -731.5Q377 -720 360 -720H280Q263 -720 251.5 -708.5Q240 -697 240 -680V-600Q240 -562 218 -531Q196 -500 160 -487V-473Q196 -460 218 -429Q240 -398 240 -360V-280Q240 -263 251.5 -251.5Q263 -240 280 -240H360Q377 -240 388.5 -228.5Q400 -217 400 -200Q400 -183 388.5 -171.5Q377 -160 360 -160Z"),
("delete", "M280 -120Q247 -120 223.5 -143.5Q200 -167 200 -200V-720Q183 -720 171.5 -731.5Q160 -743 160 -760Q160 -777 171.5 -788.5Q183 -800 200 -800H360Q360 -817 371.5 -828.5Q383 -840 400 -840H560Q577 -840 588.5 -828.5Q600 -817 600 -800H760Q777 -800 788.5 -788.5Q800 -777 800 -760Q800 -743 788.5 -731.5Q777 -720 760 -720V-200Q760 -167 736.5 -143.5Q713 -120 680 -120ZM680 -720H280V-200Q280 -200 280 -200Q280 -200 280 -200H680Q680 -200 680 -200Q680 -200 680 -200ZM440 -320V-600Q440 -617 428.5 -628.5Q417 -640 400 -640Q383 -640 371.5 -628.5Q360 -617 360 -600V-320Q360 -303 371.5 -291.5Q383 -280 400 -280Q417 -280 428.5 -291.5Q440 -303 440 -320ZM600 -320V-600Q600 -617 588.5 -628.5Q577 -640 560 -640Q543 -640 531.5 -628.5Q520 -617 520 -600V-320Q520 -303 531.5 -291.5Q543 -280 560 -280Q577 -280 588.5 -291.5Q600 -303 600 -320ZM280 -720V-200Q280 -200 280 -200Q280 -200 280 -200Q280 -200 280 -200Q280 -200 280 -200Z"),
("delete_fill", "M280 -120Q247 -120 223.5 -143.5Q200 -167 200 -200V-720Q183 -720 171.5 -731.5Q160 -743 160 -760Q160 -777 171.5 -788.5Q183 -800 200 -800H360Q360 -817 371.5 -828.5Q383 -840 400 -840H560Q577 -840 588.5 -828.5Q600 -817 600 -800H760Q777 -800 788.5 -788.5Q800 -777 800 -760Q800 -743 788.5 -731.5Q777 -720 760 -720V-200Q760 -167 736.5 -143.5Q713 -120 680 -120ZM680 -720H280V-200Q280 -200 280 -200Q280 -200 280 -200H680Q680 -200 680 -200Q680 -200 680 -200ZM440 -320V-600Q440 -617 428.5 -628.5Q417 -640 400 -640Q383 -640 371.5 -628.5Q360 -617 360 -600V-320Q360 -303 371.5 -291.5Q383 -280 400 -280Q417 -280 428.5 -291.5Q440 -303 440 -320ZM600 -320V-600Q600 -617 588.5 -628.5Q577 -640 560 -640Q543 -640 531.5 -628.5Q520 -617 520 -600V-320Q520 -303 531.5 -291.5Q543 -280 560 -280Q577 -280 588.5 -291.5Q600 -303 600 -320ZM280 -720H680V-200Q680 -200 680 -200Q680 -200 680 -200H280Q280 -200 280 -200Q280 -200 280 -200Z"),
("description", "M360 -240H600Q617 -240 628.5 -251.5Q640 -263 640 -280Q640 -297 628.5 -308.5Q617 -320 600 -320H360Q343 -320 331.5 -308.5Q320 -297 320 -280Q320 -263 331.5 -251.5Q343 -240 360 -240ZM360 -400H600Q617 -400 628.5 -411.5Q640 -423 640 -440Q640 -457 628.5 -468.5Q617 -480 600 -480H360Q343 -480 331.5 -468.5Q320 -457 320 -440Q320 -423 331.5 -411.5Q343 -400 360 -400ZM240 -80Q207 -80 183.5 -103.5Q160 -127 160 -160V-800Q160 -833 183.5 -856.5Q207 -880 240 -880H527Q543 -880 557.5 -874Q572 -868 583 -857L777 -663Q788 -652 794 -637.5Q800 -623 800 -607V-160Q800 -127 776.5 -103.5Q753 -80 720 -80ZM520 -640V-800H240Q240 -800 240 -800Q240 -800 240 -800V-160Q240 -160 240 -160Q240 -160 240 -160H720Q720 -160 720 -160Q720 -160 720 -160V-600H560Q543 -600 531.5 -611.5Q520 -623 520 -640ZM240 -800V-640Q240 -623 240 -611.5Q240 -600 240 -600V-800V-640Q240 -623 240 -611.5Q240 -600 240 -600V-160Q240 -160 240 -160Q240 -160 240 -160Q240 -160 240 -160Q240 -160 240 -160V-800Q240 -800 240 -800Q240 -800 240 -800Z"),
("description_fill", "M360 -240H600Q617 -240 628.5 -251.5Q640 -263 640 -280Q640 -297 628.5 -308.5Q617 -320 600 -320H360Q343 -320 331.5 -308.5Q320 -297 320 -280Q320 -263 331.5 -251.5Q343 -240 360 -240ZM360 -400H600Q617 -400 628.5 -411.5Q640 -423 640 -440Q640 -457 628.5 -468.5Q617 -480 600 -480H360Q343 -480 331.5 -468.5Q320 -457 320 -440Q320 -423 331.5 -411.5Q343 -400 360 -400ZM240 -80Q207 -80 183.5 -103.5Q160 -127 160 -160V-800Q160 -833 183.5 -856.5Q207 -880 240 -880H527Q543 -880 557.5 -874Q572 -868 583 -857L777 -663Q788 -652 794 -637.5Q800 -623 800 -607V-160Q800 -127 776.5 -103.5Q753 -80 720 -80ZM520 -640V-800H240Q240 -800 240 -800Q240 -800 240 -800V-160Q240 -160 240 -160Q240 -160 240 -160H720Q720 -160 720 -160Q720 -160 720 -160V-600H560Q543 -600 531.5 -611.5Q520 -623 520 -640ZM240 -800H520V-640Q520 -623 531.5 -611.5Q543 -600 560 -600H720L520 -800V-640Q520 -623 531.5 -611.5Q543 -600 560 -600H720V-160Q720 -160 720 -160Q720 -160 720 -160H240Q240 -160 240 -160Q240 -160 240 -160V-800Q240 -800 240 -800Q240 -800 240 -800Z"),
("difference", "M500 -600V-560Q500 -543 511.5 -531.5Q523 -520 540 -520Q557 -520 568.5 -531.5Q580 -543 580 -560V-600H620Q637 -600 648.5 -611.5Q660 -623 660 -640Q660 -657 648.5 -668.5Q637 -680 620 -680H580V-720Q580 -737 568.5 -748.5Q557 -760 540 -760Q523 -760 511.5 -748.5Q500 -737 500 -720V-680H460Q443 -680 431.5 -668.5Q420 -657 420 -640Q420 -623 431.5 -611.5Q443 -600 460 -600ZM460 -360H620Q637 -360 648.5 -371.5Q660 -383 660 -400Q660 -417 648.5 -428.5Q637 -440 620 -440H460Q443 -440 431.5 -428.5Q420 -417 420 -400Q420 -383 431.5 -371.5Q443 -360 460 -360ZM320 -200Q287 -200 263.5 -223.5Q240 -247 240 -280V-840Q240 -873 263.5 -896.5Q287 -920 320 -920H567Q583 -920 597.5 -914Q612 -908 623 -897L817 -703Q828 -692 834 -677.5Q840 -663 840 -647V-280Q840 -247 816.5 -223.5Q793 -200 760 -200ZM320 -280H760Q760 -280 760 -280Q760 -280 760 -280V-640L560 -840H320Q320 -840 320 -840Q320 -840 320 -840V-280Q320 -280 320 -280Q320 -280 320 -280ZM160 -40Q127 -40 103.5 -63.5Q80 -87 80 -120V-640Q80 -657 91.5 -668.5Q103 -680 120 -680Q137 -680 148.5 -668.5Q160 -657 160 -640V-120Q160 -120 160 -120Q160 -120 160 -120H560Q577 -120 588.5 -108.5Q600 -97 600 -80Q600 -63 588.5 -51.5Q577 -40 560 -40ZM320 -280Q320 -280 320 -280Q320 -280 320 -280V-840Q320 -840 320 -840Q320 -840 320 -840V-640V-280Q320 -280 320 -280Q320 -280 320 -280Z"),
("difference_fill", "M500 -600V-560Q500 -543 511.5 -531.5Q523 -520 540 -520Q557 -520 568.5 -531.5Q580 -543 580 -560V-600H620Q637 -600 648.5 -611.5Q660 -623 660 -640Q660 -657 648.5 -668.5Q637 -680 620 -680H580V-720Q580 -737 568.5 -748.5Q557 -760 540 -760Q523 -760 511.5 -748.5Q500 -737 500 -720V-680H460Q443 -680 431.5 -668.5Q420 -657 420 -640Q420 -623 431.5 -611.5Q443 -600 460 -600ZM460 -360H620Q637 -360 648.5 -371.5Q660 -383 660 -400Q660 -417 648.5 -428.5Q637 -440 620 -440H460Q443 -440 431.5 -428.5Q420 -417 420 -400Q420 -383 431.5 -371.5Q443 -360 460 -360ZM320 -200Q287 -200 263.5 -223.5Q240 -247 240 -280V-840Q240 -873 263.5 -896.5Q287 -920 320 -920H567Q583 -920 597.5 -914Q612 -908 623 -897L817 -703Q828 -692 834 -677.5Q840 -663 840 -647V-280Q840 -247 816.5 -223.5Q793 -200 760 -200ZM320 -280H760Q760 -280 760 -280Q760 -280 760 -280V-640L560 -840H320Q320 -840 320 -840Q320 -840 320 -840V-280Q320 -280 320 -280Q320 -280 320 -280ZM160 -40Q127 -40 103.5 -63.5Q80 -87 80 -120V-640Q80 -657 91.5 -668.5Q103 -680 120 -680Q137 -680 148.5 -668.5Q160 -657 160 -640V-120Q160 -120 160 -120Q160 -120 160 -120H560Q577 -120 588.5 -108.5Q600 -97 600 -80Q600 -63 588.5 -51.5Q577 -40 560 -40ZM320 -280Q320 -280 320 -280Q320 -280 320 -280V-840Q320 -840 320 -840Q320 -840 320 -840H560L760 -640V-280Q760 -280 760 -280Q760 -280 760 -280Z"),
("do_not_disturb_on", "M320 -440H640Q657 -440 668.5 -451.5Q680 -463 680 -480Q680 -497 668.5 -508.5Q657 -520 640 -520H320Q303 -520 291.5 -508.5Q280 -497 280 -480Q280 -463 291.5 -451.5Q303 -440 320 -440ZM480 -80Q397 -80 324 -111.5Q251 -143 197 -197Q143 -251 111.5 -324Q80 -397 80 -480Q80 -563 111.5 -636Q143 -709 197 -763Q251 -817 324 -848.5Q397 -880 480 -880Q563 -880 636 -848.5Q709 -817 763 -763Q817 -709 848.5 -636Q880 -563 880 -480Q880 -397 848.5 -324Q817 -251 763 -197Q709 -143 636 -111.5Q563 -80 480 -80ZM480 -160Q614 -160 707 -253Q800 -346 800 -480Q800 -614 707 -707Q614 -800 480 -800Q346 -800 253 -707Q160 -614 160 -480Q160 -346 253 -253Q346 -160 480 -160ZM480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Z"),
("do_not_disturb_on_fill", "M320 -440H640Q657 -440 668.5 -451.5Q680 -463 680 -480Q680 -497 668.5 -508.5Q657 -520 640 -520H320Q303 -520 291.5 -508.5Q280 -497 280 -480Q280 -463 291.5 -451.5Q303 -440 320 -440ZM480 -80Q397 -80 324 -111.5Q251 -143 197 -197Q143 -251 111.5 -324Q80 -397 80 -480Q80 -563 111.5 -636Q143 -709 197 -763Q251 -817 324 -848.5Q397 -880 480 -880Q563 -880 636 -848.5Q709 -817 763 -763Q817 -709 848.5 -636Q880 -563 880 -480Q880 -397 848.5 -324Q817 -251 763 -197Q709 -143 636 -111.5Q563 -80 480 -80ZM480 -160Q614 -160 707 -253Q800 -346 800 -480Q800 -614 707 -707Q614 -800 480 -800Q346 -800 253 -707Q160 -614 160 -480Q160 -346 253 -253Q346 -160 480 -160ZM480 -160Q346 -160 253 -253Q160 -346 160 -480Q160 -614 253 -707Q346 -800 480 -800Q614 -800 707 -707Q800 -614 800 -480Q800 -346 707 -253Q614 -160 480 -160Z"),
("download", "M452 -348 308 -492Q296 -504 296.5 -520Q297 -536 308 -548Q320 -560 336.5 -560.5Q353 -561 365 -549L440 -474V-760Q440 -777 451.5 -788.5Q463 -800 480 -800Q497 -800 508.5 -788.5Q520 -777 520 -760V-474L595 -549Q607 -561 623.5 -560.5Q640 -560 652 -548Q663 -536 663.5 -520Q664 -504 652 -492L508 -348Q502 -342 495 -339.5Q488 -337 480 -337Q472 -337 465 -339.5Q458 -342 452 -348ZM240 -160Q207 -160 183.5 -183.5Q160 -207 160 -240V-320Q160 -337 171.5 -348.5Q183 -360 200 -360Q217 -360 228.5 -348.5Q240 -337 240 -320V-240Q240 -240 240 -240Q240 -240 240 -240H720Q720 -240 720 -240Q720 -240 720 -240V-320Q720 -337 731.5 -348.5Q743 -360 760 -360Q777 -360 788.5 -348.5Q800 -337 800 -320V-240Q800 -207 776.5 -183.5Q753 -160 720 -160Z"),
("edit", "M200 -200H257L648 -591L591 -648L200 -257ZM160 -120Q143 -120 131.5 -131.5Q120 -143 120 -160V-257Q120 -273 126 -287.5Q132 -302 143 -313L648 -817Q660 -828 674.5 -834Q689 -840 705 -840Q721 -840 736 -834Q751 -828 762 -816L817 -760Q829 -749 834.5 -734Q840 -719 840 -704Q840 -688 834.5 -673.5Q829 -659 817 -647L313 -143Q302 -132 287.5 -126Q273 -120 257 -120ZM760 -704 704 -760ZM619 -619 591 -648 648 -591Z"),
("edit_fill", "M200 -200H257L648 -591L591 -648L200 -257ZM160 -120Q143 -120 131.5 -131.5Q120 -143 120 -160V-257Q120 -273 126 -287.5Q132 -302 143 -313L648 -817Q660 -828 674.5 -834Q689 -840 705 -840Q721 -840 736 -834Q751 -828 762 -816L817 -760Q829 -749 834.5 -734Q840 -719 840 -704Q840 -688 834.5 -673.5Q829 -659 817 -647L313 -143Q302 -132 287.5 -126Q273 -120 257 -120ZM704 -648 760 -704 704 -760 648 -704ZM200 -200V-257L591 -648L648 -591L257 -200Z"),
("error", "M480 -280Q497 -280 508.5 -291.5Q520 -303 520 -320Q520 -337 508.5 -348.5Q497 -360 480 -360Q463 -360 451.5 -348.5Q440 -337 440 -320Q440 -303 451.5 -291.5Q463 -280 480 -280ZM520 -480V-640Q520 -657 508.5 -668.5Q497 -680 480 -680Q463 -680 451.5 -668.5Q440 -657 440 -640V-480Q440 -463 451.5 -451.5Q463 -440 480 -440Q497 -440 508.5 -451.5Q520 -463 520 -480ZM480 -80Q397 -80 324 -111.5Q251 -143 197 -197Q143 -251 111.5 -324Q80 -397 80 -480Q80 -563 111.5 -636Q143 -709 197 -763Q251 -817 324 -848.5Q397 -880 480 -880Q563 -880 636 -848.5Q709 -817 763 -763Q817 -709 848.5 -636Q880 -563 880 -480Q880 -397 848.5 -324Q817 -251 763 -197Q709 -143 636 -111.5Q563 -80 480 -80ZM480 -160Q614 -160 707 -253Q800 -346 800 -480Q800 -614 707 -707Q614 -800 480 -800Q346 -800 253 -707Q160 -614 160 -480Q160 -346 253 -253Q346 -160 480 -160ZM480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Z"),
("error_fill", "M480 -280Q497 -280 508.5 -291.5Q520 -303 520 -320Q520 -337 508.5 -348.5Q497 -360 480 -360Q463 -360 451.5 -348.5Q440 -337 440 -320Q440 -303 451.5 -291.5Q463 -280 480 -280ZM520 -480V-640Q520 -657 508.5 -668.5Q497 -680 480 -680Q463 -680 451.5 -668.5Q440 -657 440 -640V-480Q440 -463 451.5 -451.5Q463 -440 480 -440Q497 -440 508.5 -451.5Q520 -463 520 -480ZM480 -80Q397 -80 324 -111.5Q251 -143 197 -197Q143 -251 111.5 -324Q80 -397 80 -480Q80 -563 111.5 -636Q143 -709 197 -763Q251 -817 324 -848.5Q397 -880 480 -880Q563 -880 636 -848.5Q709 -817 763 -763Q817 -709 848.5 -636Q880 -563 880 -480Q880 -397 848.5 -324Q817 -251 763 -197Q709 -143 636 -111.5Q563 -80 480 -80ZM480 -160Q614 -160 707 -253Q800 -346 800 -480Q800 -614 707 -707Q614 -800 480 -800Q346 -800 253 -707Q160 -614 160 -480Q160 -346 253 -253Q346 -160 480 -160ZM480 -160Q346 -160 253 -253Q160 -346 160 -480Q160 -614 253 -707Q346 -800 480 -800Q614 -800 707 -707Q800 -614 800 -480Q800 -346 707 -253Q614 -160 480 -160Z"),
("expand_less", "M480 -529 324 -373Q313 -362 296 -362Q279 -362 268 -373Q257 -384 257 -401Q257 -418 268 -429L452 -613Q458 -619 465 -621.5Q472 -624 480 -624Q488 -624 495 -621.5Q502 -619 508 -613L692 -429Q703 -418 703 -401Q703 -384 692 -373Q681 -362 664 -362Q647 -362 636 -373Z"),
("expand_more", "M452 -373 268 -557Q257 -568 257 -585Q257 -602 268 -613Q279 -624 296 -624Q313 -624 324 -613L480 -457L636 -613Q647 -624 664 -624Q681 -624 692 -613Q703 -602 703 -585Q703 -568 692 -557L508 -373Q502 -367 495 -364.5Q488 -362 480 -362Q472 -362 465 -364.5Q458 -367 452 -373Z"),
("find_replace", "M440 -720Q377 -720 326.5 -685.5Q276 -651 254 -595Q248 -580 234.5 -572.5Q221 -565 205 -568Q189 -571 179.5 -583.5Q170 -596 175 -610Q202 -694 274 -747Q346 -800 440 -800Q499 -800 550.5 -777.5Q602 -755 640 -716V-760Q640 -777 651.5 -788.5Q663 -800 680 -800Q697 -800 708.5 -788.5Q720 -777 720 -760V-600Q720 -583 708.5 -571.5Q697 -560 680 -560H520Q503 -560 491.5 -571.5Q480 -583 480 -600Q480 -617 491.5 -628.5Q503 -640 520 -640H600Q571 -676 530.5 -698Q490 -720 440 -720ZM440 -240Q381 -240 329.5 -262.5Q278 -285 240 -324V-280Q240 -263 228.5 -251.5Q217 -240 200 -240Q183 -240 171.5 -251.5Q160 -263 160 -280V-440Q160 -457 171.5 -468.5Q183 -480 200 -480H360Q377 -480 388.5 -468.5Q400 -457 400 -440Q400 -423 388.5 -411.5Q377 -400 360 -400H280Q309 -364 349.5 -342Q390 -320 440 -320Q502 -320 551.5 -353Q601 -386 624 -440Q631 -456 644.5 -465.5Q658 -475 675 -472Q692 -468 700 -454Q708 -440 703 -424Q696 -404 686.5 -386.5Q677 -369 664 -352L812 -204Q823 -193 823 -176Q823 -159 812 -148Q801 -137 784 -137Q767 -137 756 -148L608 -296Q572 -269 529.5 -254.5Q487 -240 440 -240Z"),
("folder", "M160 -160Q127 -160 103.5 -183.5Q80 -207 80 -240V-720Q80 -753 103.5 -776.5Q127 -800 160 -800H367Q383 -800 397.5 -794Q412 -788 423 -777L480 -720H800Q833 -720 856.5 -696.5Q880 -673 880 -640V-240Q880 -207 856.5 -183.5Q833 -160 800 -160ZM160 -240H800Q800 -240 800 -240Q800 -240 800 -240V-640Q800 -640 800 -640Q800 -640 800 -640H447L367 -720Q367 -720 367 -720Q367 -720 367 -720H160Q160 -720 160 -720Q160 -720 160 -720V-240Q160 -240 160 -240Q160 -240 160 -240ZM160 -240Q160 -240 160 -240Q160 -240 160 -240V-720Q160 -720 160 -720Q160 -720 160 -720Q160 -720 160 -720Q160 -720 160 -720V-640Q160 -640 160 -640Q160 -640 160 -640V-240Q160 -240 160 -240Q160 -240 160 -240Z"),
("folder_fill", "M160 -160Q127 -160 103.5 -183.5Q80 -207 80 -240V-720Q80 -753 103.5 -776.5Q127 -800 160 -800H367Q383 -800 397.5 -794Q412 -788 423 -777L480 -720H800Q833 -720 856.5 -696.5Q880 -673 880 -640V-240Q880 -207 856.5 -183.5Q833 -160 800 -160ZM160 -240H800Q800 -240 800 -240Q800 -240 800 -240V-640Q800 -640 800 -640Q800 -640 800 -640H447L367 -720Q367 -720 367 -720Q367 -720 367 -720H160Q160 -720 160 -720Q160 -720 160 -720V-240Q160 -240 160 -240Q160 -240 160 -240ZM160 -240Q160 -240 160 -240Q160 -240 160 -240V-720Q160 -720 160 -720Q160 -720 160 -720H367Q367 -720 367 -720Q367 -720 367 -720L447 -640H800Q800 -640 800 -640Q800 -640 800 -640V-240Q800 -240 800 -240Q800 -240 800 -240Z"),
("folder_open", "M160 -160Q127 -160 103.5 -183.5Q80 -207 80 -240V-720Q80 -753 103.5 -776.5Q127 -800 160 -800H367Q383 -800 397.5 -794Q412 -788 423 -777L480 -720H840Q857 -720 868.5 -708.5Q880 -697 880 -680Q880 -663 868.5 -651.5Q857 -640 840 -640H447L367 -720H160Q160 -720 160 -720Q160 -720 160 -720V-240Q160 -240 160 -240Q160 -240 160 -240L239 -503Q247 -529 268.5 -544.5Q290 -560 316 -560H832Q873 -560 896.5 -527.5Q920 -495 909 -457L837 -217Q829 -191 807.5 -175.5Q786 -160 760 -160ZM244 -240H760Q760 -240 760 -240Q760 -240 760 -240L832 -480Q832 -480 832 -480Q832 -480 832 -480H316Q316 -480 316 -480Q316 -480 316 -480ZM160 -502V-720Q160 -720 160 -720Q160 -720 160 -720V-640Q160 -640 160 -601Q160 -562 160 -502ZM244 -240 316 -480Q316 -480 316 -480Q316 -480 316 -480Q316 -480 316 -480Q316 -480 316 -480L244 -240Q244 -240 244 -240Q244 -240 244 -240Z"),
("folder_open_fill", "M160 -160Q127 -160 103.5 -183.5Q80 -207 80 -240V-720Q80 -753 103.5 -776.5Q127 -800 160 -800H367Q383 -800 397.5 -794Q412 -788 423 -777L480 -720H840Q857 -720 868.5 -708.5Q880 -697 880 -680Q880 -663 868.5 -651.5Q857 -640 840 -640H447L367 -720H160Q160 -720 160 -720Q160 -720 160 -720V-240Q160 -240 160 -240Q160 -240 160 -240L239 -503Q247 -529 268.5 -544.5Q290 -560 316 -560H832Q873 -560 896.5 -527.5Q920 -495 909 -457L837 -217Q829 -191 807.5 -175.5Q786 -160 760 -160ZM244 -240H760Q760 -240 760 -240Q760 -240 760 -240L832 -480Q832 -480 832 -480Q832 -480 832 -480H316Q316 -480 316 -480Q316 -480 316 -480ZM160 -502V-720Q160 -720 160 -720Q160 -720 160 -720H367L447 -640H314Q252 -640 206 -601Q160 -562 160 -502ZM244 -240 316 -480Q316 -480 316 -480Q316 -480 316 -480H832Q832 -480 832 -480Q832 -480 832 -480L760 -240Q760 -240 760 -240Q760 -240 760 -240Z"),
("folder_zip", "M640 -480V-560H720V-480ZM640 -400H560V-480H640ZM640 -320V-400H720V-320ZM447 -640 367 -720H160Q160 -720 160 -720Q160 -720 160 -720V-240Q160 -240 160 -240Q160 -240 160 -240H560V-320H640V-240H800Q800 -240 800 -240Q800 -240 800 -240V-640Q800 -640 800 -640Q800 -640 800 -640H640V-560H560V-640ZM160 -160Q127 -160 103.5 -183.5Q80 -207 80 -240V-720Q80 -753 103.5 -776.5Q127 -800 160 -800H367Q383 -800 397.5 -794Q412 -788 423 -777L480 -720H800Q833 -720 856.5 -696.5Q880 -673 880 -640V-240Q880 -207 856.5 -183.5Q833 -160 800 -160ZM160 -240Q160 -240 160 -240Q160 -240 160 -240V-640Q160 -640 160 -640Q160 -640 160 -640V-720Q160 -720 160 -720Q160 -720 160 -720Q160 -720 160 -720Q160 -720 160 -720V-240Q160 -240 160 -240Q160 -240 160 -240Z"),
("folder_zip_fill", "M640 -480V-560H720V-480ZM640 -400H560V-480H640ZM640 -320V-400H720V-320ZM447 -640 367 -720H160Q160 -720 160 -720Q160 -720 160 -720V-240Q160 -240 160 -240Q160 -240 160 -240H560V-320H640V-240H800Q800 -240 800 -240Q800 -240 800 -240V-640Q800 -640 800 -640Q800 -640 800 -640H640V-560H560V-640ZM160 -160Q127 -160 103.5 -183.5Q80 -207 80 -240V-720Q80 -753 103.5 -776.5Q127 -800 160 -800H367Q383 -800 397.5 -794Q412 -788 423 -777L480 -720H800Q833 -720 856.5 -696.5Q880 -673 880 -640V-240Q880 -207 856.5 -183.5Q833 -160 800 -160ZM160 -240H800Q800 -240 800 -240Q800 -240 800 -240V-640Q800 -640 800 -640Q800 -640 800 -640H447L367 -720Q367 -720 367 -720Q367 -720 367 -720H160Q160 -720 160 -720Q160 -720 160 -720V-240Q160 -240 160 -240Q160 -240 160 -240Z"),
("format_align_left", "M160 -120Q143 -120 131.5 -131.5Q120 -143 120 -160Q120 -177 131.5 -188.5Q143 -200 160 -200H800Q817 -200 828.5 -188.5Q840 -177 840 -160Q840 -143 828.5 -131.5Q817 -120 800 -120ZM160 -280Q143 -280 131.5 -291.5Q120 -303 120 -320Q120 -337 131.5 -348.5Q143 -360 160 -360H560Q577 -360 588.5 -348.5Q600 -337 600 -320Q600 -303 588.5 -291.5Q577 -280 560 -280ZM160 -440Q143 -440 131.5 -451.5Q120 -463 120 -480Q120 -497 131.5 -508.5Q143 -520 160 -520H800Q817 -520 828.5 -508.5Q840 -497 840 -480Q840 -463 828.5 -451.5Q817 -440 800 -440ZM160 -600Q143 -600 131.5 -611.5Q120 -623 120 -640Q120 -657 131.5 -668.5Q143 -680 160 -680H560Q577 -680 588.5 -668.5Q600 -657 600 -640Q600 -623 588.5 -611.5Q577 -600 560 -600ZM160 -760Q143 -760 131.5 -771.5Q120 -783 120 -800Q120 -817 131.5 -828.5Q143 -840 160 -840H800Q817 -840 828.5 -828.5Q840 -817 840 -800Q840 -783 828.5 -771.5Q817 -760 800 -760Z"),
("format_indent_increase", "M160 -120Q143 -120 131.5 -131.5Q120 -143 120 -160Q120 -177 131.5 -188.5Q143 -200 160 -200H800Q817 -200 828.5 -188.5Q840 -177 840 -160Q840 -143 828.5 -131.5Q817 -120 800 -120ZM480 -280Q463 -280 451.5 -291.5Q440 -303 440 -320Q440 -337 451.5 -348.5Q463 -360 480 -360H800Q817 -360 828.5 -348.5Q840 -337 840 -320Q840 -303 828.5 -291.5Q817 -280 800 -280ZM480 -440Q463 -440 451.5 -451.5Q440 -463 440 -480Q440 -497 451.5 -508.5Q463 -520 480 -520H800Q817 -520 828.5 -508.5Q840 -497 840 -480Q840 -463 828.5 -451.5Q817 -440 800 -440ZM480 -600Q463 -600 451.5 -611.5Q440 -623 440 -640Q440 -657 451.5 -668.5Q463 -680 480 -680H800Q817 -680 828.5 -668.5Q840 -657 840 -640Q840 -623 828.5 -611.5Q817 -600 800 -600ZM160 -760Q143 -760 131.5 -771.5Q120 -783 120 -800Q120 -817 131.5 -828.5Q143 -840 160 -840H800Q817 -840 828.5 -828.5Q840 -817 840 -800Q840 -783 828.5 -771.5Q817 -760 800 -760ZM154 -354Q144 -344 132 -349Q120 -354 120 -368V-592Q120 -606 132 -611Q144 -616 154 -606L266 -494Q272 -488 272 -480Q272 -472 266 -466Z"),
("format_list_bulleted", "M400 -200Q383 -200 371.5 -211.5Q360 -223 360 -240Q360 -257 371.5 -268.5Q383 -280 400 -280H800Q817 -280 828.5 -268.5Q840 -257 840 -240Q840 -223 828.5 -211.5Q817 -200 800 -200ZM400 -440Q383 -440 371.5 -451.5Q360 -463 360 -480Q360 -497 371.5 -508.5Q383 -520 400 -520H800Q817 -520 828.5 -508.5Q840 -497 840 -480Q840 -463 828.5 -451.5Q817 -440 800 -440ZM400 -680Q383 -680 371.5 -691.5Q360 -703 360 -720Q360 -737 371.5 -748.5Q383 -760 400 -760H800Q817 -760 828.5 -748.5Q840 -737 840 -720Q840 -703 828.5 -691.5Q817 -680 800 -680ZM200 -160Q167 -160 143.5 -183.5Q120 -207 120 -240Q120 -273 143.5 -296.5Q167 -320 200 -320Q233 -320 256.5 -296.5Q280 -273 280 -240Q280 -207 256.5 -183.5Q233 -160 200 -160ZM200 -400Q167 -400 143.5 -423.5Q120 -447 120 -480Q120 -513 143.5 -536.5Q167 -560 200 -560Q233 -560 256.5 -536.5Q280 -513 280 -480Q280 -447 256.5 -423.5Q233 -400 200 -400ZM200 -640Q167 -640 143.5 -663.5Q120 -687 120 -720Q120 -753 143.5 -776.5Q167 -800 200 -800Q233 -800 256.5 -776.5Q280 -753 280 -720Q280 -687 256.5 -663.5Q233 -640 200 -640Z"),
("fullscreen", "M200 -200H280Q297 -200 308.5 -188.5Q320 -177 320 -160Q320 -143 308.5 -131.5Q297 -120 280 -120H160Q143 -120 131.5 -131.5Q120 -143 120 -160V-280Q120 -297 131.5 -308.5Q143 -320 160 -320Q177 -320 188.5 -308.5Q200 -297 200 -280ZM760 -200V-280Q760 -297 771.5 -308.5Q783 -320 800 -320Q817 -320 828.5 -308.5Q840 -297 840 -280V-160Q840 -143 828.5 -131.5Q817 -120 800 -120H680Q663 -120 651.5 -131.5Q640 -143 640 -160Q640 -177 651.5 -188.5Q663 -200 680 -200ZM200 -760V-680Q200 -663 188.5 -651.5Q177 -640 160 -640Q143 -640 131.5 -651.5Q120 -663 120 -680V-800Q120 -817 131.5 -828.5Q143 -840 160 -840H280Q297 -840 308.5 -828.5Q320 -817 320 -800Q320 -783 308.5 -771.5Q297 -760 280 -760ZM760 -760H680Q663 -760 651.5 -771.5Q640 -783 640 -800Q640 -817 651.5 -828.5Q663 -840 680 -840H800Q817 -840 828.5 -828.5Q840 -817 840 -800V-680Q840 -663 828.5 -651.5Q817 -640 800 -640Q783 -640 771.5 -651.5Q760 -663 760 -680Z"),
("history", "M480 -120Q354 -120 257 -196.5Q160 -273 131 -392Q127 -407 137 -419.5Q147 -432 164 -434Q180 -436 193 -428Q206 -420 211 -404Q235 -314 310 -257Q385 -200 480 -200Q597 -200 678.5 -281.5Q760 -363 760 -480Q760 -597 678.5 -678.5Q597 -760 480 -760Q411 -760 351 -728Q291 -696 250 -640H320Q337 -640 348.5 -628.5Q360 -617 360 -600Q360 -583 348.5 -571.5Q337 -560 320 -560H160Q143 -560 131.5 -571.5Q120 -583 120 -600V-760Q120 -777 131.5 -788.5Q143 -800 160 -800Q177 -800 188.5 -788.5Q200 -777 200 -760V-706Q251 -770 324.5 -805Q398 -840 480 -840Q555 -840 620.5 -811.5Q686 -783 734.5 -734.5Q783 -686 811.5 -620.5Q840 -555 840 -480Q840 -405 811.5 -339.5Q783 -274 734.5 -225.5Q686 -177 620.5 -148.5Q555 -120 480 -120ZM520 -496 620 -396Q631 -385 631 -368Q631 -351 620 -340Q609 -329 592 -329Q575 -329 564 -340L452 -452Q446 -458 443 -465.5Q440 -473 440 -481V-640Q440 -657 451.5 -668.5Q463 -680 480 -680Q497 -680 508.5 -668.5Q520 -657 520 -640Z"),
("home", "M240 -200H360V-400Q360 -417 371.5 -428.5Q383 -440 400 -440H560Q577 -440 588.5 -428.5Q600 -417 600 -400V-200H720V-560Q720 -560 720 -560Q720 -560 720 -560L480 -740Q480 -740 480 -740Q480 -740 480 -740L240 -560Q240 -560 240 -560Q240 -560 240 -560ZM160 -200V-560Q160 -579 168.5 -596Q177 -613 192 -624L432 -804Q453 -820 480 -820Q507 -820 528 -804L768 -624Q783 -613 791.5 -596Q800 -579 800 -560V-200Q800 -167 776.5 -143.5Q753 -120 720 -120H560Q543 -120 531.5 -131.5Q520 -143 520 -160V-360Q520 -360 520 -360Q520 -360 520 -360H440Q440 -360 440 -360Q440 -360 440 -360V-160Q440 -143 428.5 -131.5Q417 -120 400 -120H240Q207 -120 183.5 -143.5Q160 -167 160 -200ZM480 -470Q480 -470 480 -470Q480 -470 480 -470Q480 -470 480 -470Q480 -470 480 -470Q480 -470 480 -470Q480 -470 480 -470Z"),
("home_fill", "M240 -200H360V-400Q360 -417 371.5 -428.5Q383 -440 400 -440H560Q577 -440 588.5 -428.5Q600 -417 600 -400V-200H720V-560Q720 -560 720 -560Q720 -560 720 -560L480 -740Q480 -740 480 -740Q480 -740 480 -740L240 -560Q240 -560 240 -560Q240 -560 240 -560ZM160 -200V-560Q160 -579 168.5 -596Q177 -613 192 -624L432 -804Q453 -820 480 -820Q507 -820 528 -804L768 -624Q783 -613 791.5 -596Q800 -579 800 -560V-200Q800 -167 776.5 -143.5Q753 -120 720 -120H600Q583 -120 571.5 -131.5Q560 -143 560 -160V-360Q560 -377 548.5 -388.5Q537 -400 520 -400H440Q423 -400 411.5 -388.5Q400 -377 400 -360V-160Q400 -143 388.5 -131.5Q377 -120 360 -120H240Q207 -120 183.5 -143.5Q160 -167 160 -200ZM240 -200V-560L480 -740Q480 -740 480 -740Q480 -740 480 -740L720 -560V-200H600V-400Q600 -417 588.5 -428.5Q577 -440 560 -440H400Q383 -440 371.5 -428.5Q360 -417 360 -400V-200Z"),
("info", "M520 -320V-480Q520 -497 508.5 -508.5Q497 -520 480 -520Q463 -520 451.5 -508.5Q440 -497 440 -480V-320Q440 -303 451.5 -291.5Q463 -280 480 -280Q497 -280 508.5 -291.5Q520 -303 520 -320ZM520 -640Q520 -657 508.5 -668.5Q497 -680 480 -680Q463 -680 451.5 -668.5Q440 -657 440 -640Q440 -623 451.5 -611.5Q463 -600 480 -600Q497 -600 508.5 -611.5Q520 -623 520 -640ZM480 -80Q397 -80 324 -111.5Q251 -143 197 -197Q143 -251 111.5 -324Q80 -397 80 -480Q80 -563 111.5 -636Q143 -709 197 -763Q251 -817 324 -848.5Q397 -880 480 -880Q563 -880 636 -848.5Q709 -817 763 -763Q817 -709 848.5 -636Q880 -563 880 -480Q880 -397 848.5 -324Q817 -251 763 -197Q709 -143 636 -111.5Q563 -80 480 -80ZM480 -160Q614 -160 707 -253Q800 -346 800 -480Q800 -614 707 -707Q614 -800 480 -800Q346 -800 253 -707Q160 -614 160 -480Q160 -346 253 -253Q346 -160 480 -160ZM480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Z"),
("info_fill", "M520 -320V-480Q520 -497 508.5 -508.5Q497 -520 480 -520Q463 -520 451.5 -508.5Q440 -497 440 -480V-320Q440 -303 451.5 -291.5Q463 -280 480 -280Q497 -280 508.5 -291.5Q520 -303 520 -320ZM520 -640Q520 -657 508.5 -668.5Q497 -680 480 -680Q463 -680 451.5 -668.5Q440 -657 440 -640Q440 -623 451.5 -611.5Q463 -600 480 -600Q497 -600 508.5 -611.5Q520 -623 520 -640ZM480 -80Q397 -80 324 -111.5Q251 -143 197 -197Q143 -251 111.5 -324Q80 -397 80 -480Q80 -563 111.5 -636Q143 -709 197 -763Q251 -817 324 -848.5Q397 -880 480 -880Q563 -880 636 -848.5Q709 -817 763 -763Q817 -709 848.5 -636Q880 -563 880 -480Q880 -397 848.5 -324Q817 -251 763 -197Q709 -143 636 -111.5Q563 -80 480 -80ZM480 -160Q614 -160 707 -253Q800 -346 800 -480Q800 -614 707 -707Q614 -800 480 -800Q346 -800 253 -707Q160 -614 160 -480Q160 -346 253 -253Q346 -160 480 -160ZM480 -160Q346 -160 253 -253Q160 -346 160 -480Q160 -614 253 -707Q346 -800 480 -800Q614 -800 707 -707Q800 -614 800 -480Q800 -346 707 -253Q614 -160 480 -160Z"),
("keyboard_arrow_down", "M452 -372 268 -556Q257 -567 257 -584Q257 -601 268 -612Q279 -623 296 -623Q313 -623 324 -612L480 -456L636 -612Q647 -623 664 -623Q681 -623 692 -612Q703 -601 703 -584Q703 -567 692 -556L508 -372Q502 -366 495 -363.5Q488 -361 480 -361Q472 -361 465 -363.5Q458 -366 452 -372Z"),
("keyboard_arrow_right", "M504 -480 348 -636Q337 -647 337 -664Q337 -681 348 -692Q359 -703 376 -703Q393 -703 404 -692L588 -508Q594 -502 596.5 -495Q599 -488 599 -480Q599 -472 596.5 -465Q594 -458 588 -452L404 -268Q393 -257 376 -257Q359 -257 348 -268Q337 -279 337 -296Q337 -313 348 -324Z"),
("keyboard_arrow_up", "M480 -528 324 -372Q313 -361 296 -361Q279 -361 268 -372Q257 -383 257 -400Q257 -417 268 -428L452 -612Q464 -624 480 -624Q496 -624 508 -612L692 -428Q703 -417 703 -400Q703 -383 692 -372Q681 -361 664 -361Q647 -361 636 -372Z"),
("keyboard_command_key", "M260 -120Q202 -120 161 -161Q120 -202 120 -260Q120 -318 161 -359Q202 -400 260 -400H320V-560H260Q202 -560 161 -601Q120 -642 120 -700Q120 -758 161 -799Q202 -840 260 -840Q318 -840 359 -799Q400 -758 400 -700V-640H560V-700Q560 -758 601 -799Q642 -840 700 -840Q758 -840 799 -799Q840 -758 840 -700Q840 -642 799 -601Q758 -560 700 -560H640V-400H700Q758 -400 799 -359Q840 -318 840 -260Q840 -202 799 -161Q758 -120 700 -120Q642 -120 601 -161Q560 -202 560 -260V-320H400V-260Q400 -202 359 -161Q318 -120 260 -120ZM260 -200Q285 -200 302.5 -217.5Q320 -235 320 -260V-320H260Q235 -320 217.5 -302.5Q200 -285 200 -260Q200 -235 217.5 -217.5Q235 -200 260 -200ZM700 -200Q725 -200 742.5 -217.5Q760 -235 760 -260Q760 -285 742.5 -302.5Q725 -320 700 -320H640V-260Q640 -235 657.5 -217.5Q675 -200 700 -200ZM400 -400H560V-560H400ZM260 -640H320V-700Q320 -725 302.5 -742.5Q285 -760 260 -760Q235 -760 217.5 -742.5Q200 -725 200 -700Q200 -675 217.5 -657.5Q235 -640 260 -640ZM640 -640H700Q725 -640 742.5 -657.5Q760 -675 760 -700Q760 -725 742.5 -742.5Q725 -760 700 -760Q675 -760 657.5 -742.5Q640 -725 640 -700Z"),
("language", "M480.5 -80Q398 -80 325 -111.5Q252 -143 197.5 -197.5Q143 -252 111.5 -325Q80 -398 80 -480.5Q80 -563 111.5 -635.5Q143 -708 197.5 -762.5Q252 -817 325 -848.5Q398 -880 480.5 -880Q563 -880 635.5 -848.5Q708 -817 762.5 -762.5Q817 -708 848.5 -635.5Q880 -563 880 -480.5Q880 -398 848.5 -325Q817 -252 762.5 -197.5Q708 -143 635.5 -111.5Q563 -80 480.5 -80ZM480 -162Q506 -198 525 -237Q544 -276 556 -320H404Q416 -276 435 -237Q454 -198 480 -162ZM376 -178Q358 -211 344.5 -246.5Q331 -282 322 -320H204Q233 -270 276.5 -233Q320 -196 376 -178ZM584 -178Q640 -196 683.5 -233Q727 -270 756 -320H638Q629 -282 615.5 -246.5Q602 -211 584 -178ZM170 -400H306Q303 -420 301.5 -439.5Q300 -459 300 -480Q300 -501 301.5 -520.5Q303 -540 306 -560H170Q165 -540 162.5 -520.5Q160 -501 160 -480Q160 -459 162.5 -439.5Q165 -420 170 -400ZM386 -400H574Q577 -420 578.5 -439.5Q580 -459 580 -480Q580 -501 578.5 -520.5Q577 -540 574 -560H386Q383 -540 381.5 -520.5Q380 -501 380 -480Q380 -459 381.5 -439.5Q383 -420 386 -400ZM654 -400H790Q795 -420 797.5 -439.5Q800 -459 800 -480Q800 -501 797.5 -520.5Q795 -540 790 -560H654Q657 -540 658.5 -520.5Q660 -501 660 -480Q660 -459 658.5 -439.5Q657 -420 654 -400ZM638 -640H756Q727 -690 683.5 -727Q640 -764 584 -782Q602 -749 615.5 -713.5Q629 -678 638 -640ZM404 -640H556Q544 -684 525 -723Q506 -762 480 -798Q454 -762 435 -723Q416 -684 404 -640ZM204 -640H322Q331 -678 344.5 -713.5Q358 -749 376 -782Q320 -764 276.5 -727Q233 -690 204 -640Z"),
("light_mode", "M480 -360Q530 -360 565 -395Q600 -430 600 -480Q600 -530 565 -565Q530 -600 480 -600Q430 -600 395 -565Q360 -530 360 -480Q360 -430 395 -395Q430 -360 480 -360ZM480 -280Q397 -280 338.5 -338.5Q280 -397 280 -480Q280 -563 338.5 -621.5Q397 -680 480 -680Q563 -680 621.5 -621.5Q680 -563 680 -480Q680 -397 621.5 -338.5Q563 -280 480 -280ZM80 -440Q63 -440 51.5 -451.5Q40 -463 40 -480Q40 -497 51.5 -508.5Q63 -520 80 -520H160Q177 -520 188.5 -508.5Q200 -497 200 -480Q200 -463 188.5 -451.5Q177 -440 160 -440ZM800 -440Q783 -440 771.5 -451.5Q760 -463 760 -480Q760 -497 771.5 -508.5Q783 -520 800 -520H880Q897 -520 908.5 -508.5Q920 -497 920 -480Q920 -463 908.5 -451.5Q897 -440 880 -440ZM440 -800V-880Q440 -897 451.5 -908.5Q463 -920 480 -920Q497 -920 508.5 -908.5Q520 -897 520 -880V-800Q520 -783 508.5 -771.5Q497 -760 480 -760Q463 -760 451.5 -771.5Q440 -783 440 -800ZM440 -80V-160Q440 -177 451.5 -188.5Q463 -200 480 -200Q497 -200 508.5 -188.5Q520 -177 520 -160V-80Q520 -63 508.5 -51.5Q497 -40 480 -40Q463 -40 451.5 -51.5Q440 -63 440 -80ZM226 -678 183 -720Q171 -731 171.5 -748Q172 -765 183 -777Q195 -789 212 -789Q229 -789 240 -777L282 -734Q293 -722 293 -706Q293 -690 282 -678Q271 -666 254.5 -666.5Q238 -667 226 -678ZM720 -183 678 -226Q667 -238 667 -254.5Q667 -271 678 -282Q689 -294 705.5 -293.5Q722 -293 734 -282L777 -240Q789 -229 788.5 -212Q788 -195 777 -183Q765 -171 748 -171Q731 -171 720 -183ZM678 -678Q666 -689 666.5 -705.5Q667 -722 678 -734L720 -777Q731 -789 748 -788.5Q765 -788 777 -777Q789 -765 789 -748Q789 -731 777 -720L734 -678Q722 -667 706 -667Q690 -667 678 -678ZM183 -183Q171 -195 171 -212Q171 -229 183 -240L226 -282Q238 -293 254.5 -293Q271 -293 282 -282Q294 -271 293.5 -254.5Q293 -238 282 -226L240 -183Q229 -171 212 -171.5Q195 -172 183 -183ZM480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Z"),
("light_mode_fill", "M480 -360Q530 -360 565 -395Q600 -430 600 -480Q600 -530 565 -565Q530 -600 480 -600Q430 -600 395 -565Q360 -530 360 -480Q360 -430 395 -395Q430 -360 480 -360ZM480 -280Q397 -280 338.5 -338.5Q280 -397 280 -480Q280 -563 338.5 -621.5Q397 -680 480 -680Q563 -680 621.5 -621.5Q680 -563 680 -480Q680 -397 621.5 -338.5Q563 -280 480 -280ZM80 -440Q63 -440 51.5 -451.5Q40 -463 40 -480Q40 -497 51.5 -508.5Q63 -520 80 -520H160Q177 -520 188.5 -508.5Q200 -497 200 -480Q200 -463 188.5 -451.5Q177 -440 160 -440ZM800 -440Q783 -440 771.5 -451.5Q760 -463 760 -480Q760 -497 771.5 -508.5Q783 -520 800 -520H880Q897 -520 908.5 -508.5Q920 -497 920 -480Q920 -463 908.5 -451.5Q897 -440 880 -440ZM440 -800V-880Q440 -897 451.5 -908.5Q463 -920 480 -920Q497 -920 508.5 -908.5Q520 -897 520 -880V-800Q520 -783 508.5 -771.5Q497 -760 480 -760Q463 -760 451.5 -771.5Q440 -783 440 -800ZM440 -80V-160Q440 -177 451.5 -188.5Q463 -200 480 -200Q497 -200 508.5 -188.5Q520 -177 520 -160V-80Q520 -63 508.5 -51.5Q497 -40 480 -40Q463 -40 451.5 -51.5Q440 -63 440 -80ZM226 -678 183 -720Q171 -731 171.5 -748Q172 -765 183 -777Q195 -789 212 -789Q229 -789 240 -777L282 -734Q293 -722 293 -706Q293 -690 282 -678Q271 -666 254.5 -666.5Q238 -667 226 -678ZM720 -183 678 -226Q667 -238 667 -254.5Q667 -271 678 -282Q689 -294 705.5 -293.5Q722 -293 734 -282L777 -240Q789 -229 788.5 -212Q788 -195 777 -183Q765 -171 748 -171Q731 -171 720 -183ZM678 -678Q666 -689 666.5 -705.5Q667 -722 678 -734L720 -777Q731 -789 748 -788.5Q765 -788 777 -777Q789 -765 789 -748Q789 -731 777 -720L734 -678Q722 -667 706 -667Q690 -667 678 -678ZM183 -183Q171 -195 171 -212Q171 -229 183 -240L226 -282Q238 -293 254.5 -293Q271 -293 282 -282Q294 -271 293.5 -254.5Q293 -238 282 -226L240 -183Q229 -171 212 -171.5Q195 -172 183 -183ZM480 -360Q430 -360 395 -395Q360 -430 360 -480Q360 -530 395 -565Q430 -600 480 -600Q530 -600 565 -565Q600 -530 600 -480Q600 -430 565 -395Q530 -360 480 -360Z"),
("line_end", "M780 -380Q749 -380 724 -397Q699 -414 688 -440H120Q103 -440 91.5 -451.5Q80 -463 80 -480Q80 -497 91.5 -508.5Q103 -520 120 -520H688Q699 -546 724 -563Q749 -580 780 -580Q822 -580 851 -551Q880 -522 880 -480Q880 -438 851 -409Q822 -380 780 -380Z"),
("list", "M320 -600Q303 -600 291.5 -611.5Q280 -623 280 -640Q280 -657 291.5 -668.5Q303 -680 320 -680H800Q817 -680 828.5 -668.5Q840 -657 840 -640Q840 -623 828.5 -611.5Q817 -600 800 -600ZM320 -440Q303 -440 291.5 -451.5Q280 -463 280 -480Q280 -497 291.5 -508.5Q303 -520 320 -520H800Q817 -520 828.5 -508.5Q840 -497 840 -480Q840 -463 828.5 -451.5Q817 -440 800 -440ZM320 -280Q303 -280 291.5 -291.5Q280 -303 280 -320Q280 -337 291.5 -348.5Q303 -360 320 -360H800Q817 -360 828.5 -348.5Q840 -337 840 -320Q840 -303 828.5 -291.5Q817 -280 800 -280ZM160 -600Q143 -600 131.5 -611.5Q120 -623 120 -640Q120 -657 131.5 -668.5Q143 -680 160 -680Q177 -680 188.5 -668.5Q200 -657 200 -640Q200 -623 188.5 -611.5Q177 -600 160 -600ZM160 -440Q143 -440 131.5 -451.5Q120 -463 120 -480Q120 -497 131.5 -508.5Q143 -520 160 -520Q177 -520 188.5 -508.5Q200 -497 200 -480Q200 -463 188.5 -451.5Q177 -440 160 -440ZM160 -280Q143 -280 131.5 -291.5Q120 -303 120 -320Q120 -337 131.5 -348.5Q143 -360 160 -360Q177 -360 188.5 -348.5Q200 -337 200 -320Q200 -303 188.5 -291.5Q177 -280 160 -280Z"),
("looks_one", "M480 -600V-320Q480 -303 491.5 -291.5Q503 -280 520 -280Q537 -280 548.5 -291.5Q560 -303 560 -320V-640Q560 -657 548.5 -668.5Q537 -680 520 -680H440Q423 -680 411.5 -668.5Q400 -657 400 -640Q400 -623 411.5 -611.5Q423 -600 440 -600ZM200 -120Q167 -120 143.5 -143.5Q120 -167 120 -200V-760Q120 -793 143.5 -816.5Q167 -840 200 -840H760Q793 -840 816.5 -816.5Q840 -793 840 -760V-200Q840 -167 816.5 -143.5Q793 -120 760 -120ZM200 -200H760Q760 -200 760 -200Q760 -200 760 -200V-760Q760 -760 760 -760Q760 -760 760 -760H200Q200 -760 200 -760Q200 -760 200 -760V-200Q200 -200 200 -200Q200 -200 200 -200ZM200 -760Q200 -760 200 -760Q200 -760 200 -760V-200Q200 -200 200 -200Q200 -200 200 -200Q200 -200 200 -200Q200 -200 200 -200V-760Q200 -760 200 -760Q200 -760 200 -760Z"),
("looks_one_fill", "M480 -600V-320Q480 -303 491.5 -291.5Q503 -280 520 -280Q537 -280 548.5 -291.5Q560 -303 560 -320V-640Q560 -657 548.5 -668.5Q537 -680 520 -680H440Q423 -680 411.5 -668.5Q400 -657 400 -640Q400 -623 411.5 -611.5Q423 -600 440 -600ZM200 -120Q167 -120 143.5 -143.5Q120 -167 120 -200V-760Q120 -793 143.5 -816.5Q167 -840 200 -840H760Q793 -840 816.5 -816.5Q840 -793 840 -760V-200Q840 -167 816.5 -143.5Q793 -120 760 -120ZM200 -200H760Q760 -200 760 -200Q760 -200 760 -200V-760Q760 -760 760 -760Q760 -760 760 -760H200Q200 -760 200 -760Q200 -760 200 -760V-200Q200 -200 200 -200Q200 -200 200 -200ZM200 -760H760Q760 -760 760 -760Q760 -760 760 -760V-200Q760 -200 760 -200Q760 -200 760 -200H200Q200 -200 200 -200Q200 -200 200 -200V-760Q200 -760 200 -760Q200 -760 200 -760Z"),
("manage_search", "M120 -200Q103 -200 91.5 -211.5Q80 -223 80 -240Q80 -257 91.5 -268.5Q103 -280 120 -280H440Q457 -280 468.5 -268.5Q480 -257 480 -240Q480 -223 468.5 -211.5Q457 -200 440 -200ZM120 -400Q103 -400 91.5 -411.5Q80 -423 80 -440Q80 -457 91.5 -468.5Q103 -480 120 -480H240Q257 -480 268.5 -468.5Q280 -457 280 -440Q280 -423 268.5 -411.5Q257 -400 240 -400ZM120 -600Q103 -600 91.5 -611.5Q80 -623 80 -640Q80 -657 91.5 -668.5Q103 -680 120 -680H240Q257 -680 268.5 -668.5Q280 -657 280 -640Q280 -623 268.5 -611.5Q257 -600 240 -600ZM560 -320Q477 -320 418.5 -378.5Q360 -437 360 -520Q360 -603 418.5 -661.5Q477 -720 560 -720Q643 -720 701.5 -661.5Q760 -603 760 -520Q760 -491 751.5 -462.5Q743 -434 726 -410L852 -284Q863 -273 863 -256Q863 -239 852 -228Q841 -217 824 -217Q807 -217 796 -228L670 -354Q646 -337 617.5 -328.5Q589 -320 560 -320ZM560 -400Q610 -400 645 -435Q680 -470 680 -520Q680 -570 645 -605Q610 -640 560 -640Q510 -640 475 -605Q440 -570 440 -520Q440 -470 475 -435Q510 -400 560 -400Z"),
("map", "M574 -129 360 -204 174 -132Q164 -128 154.5 -129.5Q145 -131 137 -136Q129 -141 124.5 -149.5Q120 -158 120 -169V-730Q120 -743 127.5 -753Q135 -763 148 -768L334 -831Q340 -833 346.5 -834Q353 -835 360 -835Q367 -835 373.5 -834Q380 -833 386 -831L600 -756L786 -828Q796 -832 805.5 -830.5Q815 -829 823 -824Q831 -819 835.5 -810.5Q840 -802 840 -791V-230Q840 -217 832.5 -207Q825 -197 812 -192L626 -129Q620 -127 613.5 -126Q607 -125 600 -125Q593 -125 586.5 -126Q580 -127 574 -129ZM560 -218V-686L400 -742V-274ZM640 -218 760 -258V-732L640 -686ZM200 -228 320 -274V-742L200 -702ZM640 -686V-218ZM320 -742V-274Z"),
("map_fill", "M574 -129 360 -204 174 -132Q164 -128 154.5 -129.5Q145 -131 137 -136Q129 -141 124.5 -149.5Q120 -158 120 -169V-730Q120 -743 127.5 -753Q135 -763 148 -768L334 -831Q340 -833 346.5 -834Q353 -835 360 -835Q367 -835 373.5 -834Q380 -833 386 -831L600 -756L786 -828Q796 -832 805.5 -830.5Q815 -829 823 -824Q831 -819 835.5 -810.5Q840 -802 840 -791V-230Q840 -217 832.5 -207Q825 -197 812 -192L626 -129Q620 -127 613.5 -126Q607 -125 600 -125Q593 -125 586.5 -126Q580 -127 574 -129ZM560 -218V-686L400 -742V-274ZM640 -218 760 -258V-732L640 -686ZM200 -228 320 -274V-742L200 -702ZM640 -686 760 -732V-258L640 -218ZM200 -702 320 -742V-274L200 -228Z"),
("match_case", "M247 -364 215 -275Q211 -264 202 -258Q193 -252 182 -252Q163 -252 152.5 -267.5Q142 -283 149 -300L287 -668Q291 -679 300.5 -685.5Q310 -692 321 -692H349Q360 -692 370 -685.5Q380 -679 384 -668L522 -299Q529 -282 518 -267Q507 -252 489 -252Q478 -252 469 -258.5Q460 -265 456 -276L425 -364ZM270 -428H401L337 -610H333ZM665 -242Q614 -242 584 -269.5Q554 -297 554 -342Q554 -386 588.5 -414.5Q623 -443 677 -443Q700 -443 722 -439Q744 -435 760 -428V-440Q760 -469 739.5 -487Q719 -505 685 -505Q670 -505 655.5 -500.5Q641 -496 629 -487Q616 -477 604.5 -480Q593 -483 586 -491Q579 -499 579 -510Q579 -521 590 -529Q610 -545 635 -552.5Q660 -560 686 -560Q755 -560 789 -527.5Q823 -495 823 -430V-283Q823 -270 813.5 -261Q804 -252 791 -252Q778 -252 769 -261.5Q760 -271 760 -284V-289H756Q742 -266 718 -254Q694 -242 665 -242ZM677 -296Q712 -296 736.5 -320Q761 -344 761 -376Q747 -384 727.5 -388.5Q708 -393 689 -393Q657 -393 639 -379Q621 -365 621 -342Q621 -322 637 -309Q653 -296 677 -296Z"),
("memory", "M360 -400V-560Q360 -577 371.5 -588.5Q383 -600 400 -600H560Q577 -600 588.5 -588.5Q600 -577 600 -560V-400Q600 -383 588.5 -371.5Q577 -360 560 -360H400Q383 -360 371.5 -371.5Q360 -383 360 -400ZM440 -440H520V-520H440ZM360 -160V-200H280Q247 -200 223.5 -223.5Q200 -247 200 -280V-360H160Q143 -360 131.5 -371.5Q120 -383 120 -400Q120 -417 131.5 -428.5Q143 -440 160 -440H200V-520H160Q143 -520 131.5 -531.5Q120 -543 120 -560Q120 -577 131.5 -588.5Q143 -600 160 -600H200V-680Q200 -713 223.5 -736.5Q247 -760 280 -760H360V-800Q360 -817 371.5 -828.5Q383 -840 400 -840Q417 -840 428.5 -828.5Q440 -817 440 -800V-760H520V-800Q520 -817 531.5 -828.5Q543 -840 560 -840Q577 -840 588.5 -828.5Q600 -817 600 -800V-760H680Q713 -760 736.5 -736.5Q760 -713 760 -680V-600H800Q817 -600 828.5 -588.5Q840 -577 840 -560Q840 -543 828.5 -531.5Q817 -520 800 -520H760V-440H800Q817 -440 828.5 -428.5Q840 -417 840 -400Q840 -383 828.5 -371.5Q817 -360 800 -360H760V-280Q760 -247 736.5 -223.5Q713 -200 680 -200H600V-160Q600 -143 588.5 -131.5Q577 -120 560 -120Q543 -120 531.5 -131.5Q520 -143 520 -160V-200H440V-160Q440 -143 428.5 -131.5Q417 -120 400 -120Q383 -120 371.5 -131.5Q360 -143 360 -160ZM680 -280Q680 -280 680 -280Q680 -280 680 -280V-680Q680 -680 680 -680Q680 -680 680 -680H280Q280 -680 280 -680Q280 -680 280 -680V-280Q280 -280 280 -280Q280 -280 280 -280ZM480 -480Z"),
("memory_fill", "M360 -400V-560Q360 -577 371.5 -588.5Q383 -600 400 -600H560Q577 -600 588.5 -588.5Q600 -577 600 -560V-400Q600 -383 588.5 -371.5Q577 -360 560 -360H400Q383 -360 371.5 -371.5Q360 -383 360 -400ZM440 -440H520V-520H440ZM360 -160V-200H280Q247 -200 223.5 -223.5Q200 -247 200 -280V-360H160Q143 -360 131.5 -371.5Q120 -383 120 -400Q120 -417 131.5 -428.5Q143 -440 160 -440H200V-520H160Q143 -520 131.5 -531.5Q120 -543 120 -560Q120 -577 131.5 -588.5Q143 -600 160 -600H200V-680Q200 -713 223.5 -736.5Q247 -760 280 -760H360V-800Q360 -817 371.5 -828.5Q383 -840 400 -840Q417 -840 428.5 -828.5Q440 -817 440 -800V-760H520V-800Q520 -817 531.5 -828.5Q543 -840 560 -840Q577 -840 588.5 -828.5Q600 -817 600 -800V-760H680Q713 -760 736.5 -736.5Q760 -713 760 -680V-600H800Q817 -600 828.5 -588.5Q840 -577 840 -560Q840 -543 828.5 -531.5Q817 -520 800 -520H760V-440H800Q817 -440 828.5 -428.5Q840 -417 840 -400Q840 -383 828.5 -371.5Q817 -360 800 -360H760V-280Q760 -247 736.5 -223.5Q713 -200 680 -200H600V-160Q600 -143 588.5 -131.5Q577 -120 560 -120Q543 -120 531.5 -131.5Q520 -143 520 -160V-200H440V-160Q440 -143 428.5 -131.5Q417 -120 400 -120Q383 -120 371.5 -131.5Q360 -143 360 -160ZM680 -280Q680 -280 680 -280Q680 -280 680 -280V-680Q680 -680 680 -680Q680 -680 680 -680H280Q280 -680 280 -680Q280 -680 280 -680V-280Q280 -280 280 -280Q280 -280 280 -280ZM440 -440V-520H520V-440Z"),
("merge", "M480 -344 284 -148Q273 -137 256.5 -136.5Q240 -136 228 -148Q217 -159 217 -176Q217 -193 228 -204L393 -370Q416 -393 428 -422Q440 -451 440 -483V-687L404 -651Q393 -640 376.5 -640Q360 -640 348 -652Q337 -663 337 -680Q337 -697 348 -708L452 -812Q464 -824 480 -824Q496 -824 508 -812L612 -708Q623 -697 623.5 -680.5Q624 -664 612 -652Q601 -641 584 -641Q567 -641 556 -652L520 -687V-483Q520 -451 532 -422Q544 -393 567 -370L732 -204Q743 -193 743.5 -176.5Q744 -160 732 -148Q721 -137 704 -137Q687 -137 676 -148Z"),
("minimize", "M280 -120Q263 -120 251.5 -131.5Q240 -143 240 -160Q240 -177 251.5 -188.5Q263 -200 280 -200H680Q697 -200 708.5 -188.5Q720 -177 720 -160Q720 -143 708.5 -131.5Q697 -120 680 -120Z"),
("more_horiz", "M240 -400Q207 -400 183.5 -423.5Q160 -447 160 -480Q160 -513 183.5 -536.5Q207 -560 240 -560Q273 -560 296.5 -536.5Q320 -513 320 -480Q320 -447 296.5 -423.5Q273 -400 240 -400ZM480 -400Q447 -400 423.5 -423.5Q400 -447 400 -480Q400 -513 423.5 -536.5Q447 -560 480 -560Q513 -560 536.5 -536.5Q560 -513 560 -480Q560 -447 536.5 -423.5Q513 -400 480 -400ZM720 -400Q687 -400 663.5 -423.5Q640 -447 640 -480Q640 -513 663.5 -536.5Q687 -560 720 -560Q753 -560 776.5 -536.5Q800 -513 800 -480Q800 -447 776.5 -423.5Q753 -400 720 -400Z"),
("more_vert", "M480 -160Q447 -160 423.5 -183.5Q400 -207 400 -240Q400 -273 423.5 -296.5Q447 -320 480 -320Q513 -320 536.5 -296.5Q560 -273 560 -240Q560 -207 536.5 -183.5Q513 -160 480 -160ZM480 -400Q447 -400 423.5 -423.5Q400 -447 400 -480Q400 -513 423.5 -536.5Q447 -560 480 -560Q513 -560 536.5 -536.5Q560 -513 560 -480Q560 -447 536.5 -423.5Q513 -400 480 -400ZM480 -640Q447 -640 423.5 -663.5Q400 -687 400 -720Q400 -753 423.5 -776.5Q447 -800 480 -800Q513 -800 536.5 -776.5Q560 -753 560 -720Q560 -687 536.5 -663.5Q513 -640 480 -640Z"),
("motion_mode", "M200 -766V-194Q183 -211 168 -230Q153 -249 140 -269V-691Q153 -711 168 -730Q183 -749 200 -766ZM360 -862V-98Q339 -105 319 -113.5Q299 -122 280 -133V-827Q299 -838 319 -846.5Q339 -855 360 -862ZM640 -113V-847Q746 -800 813 -702Q880 -604 880 -480Q880 -356 813 -258Q746 -160 640 -113ZM480 -80Q470 -80 460 -80.5Q450 -81 440 -82V-878Q450 -879 460 -879.5Q470 -880 480 -880Q500 -880 520 -878Q540 -876 560 -872V-88Q540 -84 520 -82Q500 -80 480 -80Z"),
("move_up", "M320 -160Q203 -160 121.5 -241.5Q40 -323 40 -440Q40 -547 110.5 -626.5Q181 -706 287 -718L251 -756Q240 -768 240 -784Q240 -800 251 -811Q263 -823 280 -823Q297 -823 308 -812L412 -708Q424 -696 424 -680Q424 -664 412 -652L309 -549Q297 -537 280.5 -537Q264 -537 252 -549Q241 -561 241 -577.5Q241 -594 252 -605L283 -636Q212 -622 166 -567Q120 -512 120 -440Q120 -357 178.5 -298.5Q237 -240 320 -240H400Q417 -240 428.5 -228.5Q440 -217 440 -200Q440 -183 428.5 -171.5Q417 -160 400 -160ZM560 -520Q543 -520 531.5 -531.5Q520 -543 520 -560V-760Q520 -777 531.5 -788.5Q543 -800 560 -800H840Q857 -800 868.5 -788.5Q880 -777 880 -760V-560Q880 -543 868.5 -531.5Q857 -520 840 -520ZM560 -160Q543 -160 531.5 -171.5Q520 -183 520 -200V-400Q520 -417 531.5 -428.5Q543 -440 560 -440H840Q857 -440 868.5 -428.5Q880 -417 880 -400V-200Q880 -183 868.5 -171.5Q857 -160 840 -160ZM600 -240H800V-360H600Z"),
("new_window", "M200 -120Q167 -120 143.5 -143.5Q120 -167 120 -200V-760Q120 -793 143.5 -816.5Q167 -840 200 -840H400Q417 -840 428.5 -828.5Q440 -817 440 -800Q440 -783 428.5 -771.5Q417 -760 400 -760H200Q200 -760 200 -760Q200 -760 200 -760V-200Q200 -200 200 -200Q200 -200 200 -200H760Q760 -200 760 -200Q760 -200 760 -200V-400Q760 -417 771.5 -428.5Q783 -440 800 -440Q817 -440 828.5 -428.5Q840 -417 840 -400V-200Q840 -167 816.5 -143.5Q793 -120 760 -120ZM640 -640H560Q543 -640 531.5 -651.5Q520 -663 520 -680Q520 -697 531.5 -708.5Q543 -720 560 -720H640V-800Q640 -817 651.5 -828.5Q663 -840 680 -840Q697 -840 708.5 -828.5Q720 -817 720 -800V-720H800Q817 -720 828.5 -708.5Q840 -697 840 -680Q840 -663 828.5 -651.5Q817 -640 800 -640H720V-560Q720 -543 708.5 -531.5Q697 -520 680 -520Q663 -520 651.5 -531.5Q640 -543 640 -560Z"),
("open_in_full", "M160 -120Q143 -120 131.5 -131.5Q120 -143 120 -160V-400Q120 -417 131.5 -428.5Q143 -440 160 -440Q177 -440 188.5 -428.5Q200 -417 200 -400V-256L704 -760H560Q543 -760 531.5 -771.5Q520 -783 520 -800Q520 -817 531.5 -828.5Q543 -840 560 -840H800Q817 -840 828.5 -828.5Q840 -817 840 -800V-560Q840 -543 828.5 -531.5Q817 -520 800 -520Q783 -520 771.5 -531.5Q760 -543 760 -560V-704L256 -200H400Q417 -200 428.5 -188.5Q440 -177 440 -160Q440 -143 428.5 -131.5Q417 -120 400 -120Z"),
("open_in_new", "M200 -120Q167 -120 143.5 -143.5Q120 -167 120 -200V-760Q120 -793 143.5 -816.5Q167 -840 200 -840H440Q457 -840 468.5 -828.5Q480 -817 480 -800Q480 -783 468.5 -771.5Q457 -760 440 -760H200Q200 -760 200 -760Q200 -760 200 -760V-200Q200 -200 200 -200Q200 -200 200 -200H760Q760 -200 760 -200Q760 -200 760 -200V-440Q760 -457 771.5 -468.5Q783 -480 800 -480Q817 -480 828.5 -468.5Q840 -457 840 -440V-200Q840 -167 816.5 -143.5Q793 -120 760 -120ZM760 -704 416 -360Q405 -349 388 -349Q371 -349 360 -360Q349 -371 349 -388Q349 -405 360 -416L704 -760H600Q583 -760 571.5 -771.5Q560 -783 560 -800Q560 -817 571.5 -828.5Q583 -840 600 -840H800Q817 -840 828.5 -828.5Q840 -817 840 -800V-600Q840 -583 828.5 -571.5Q817 -560 800 -560Q783 -560 771.5 -571.5Q760 -583 760 -600Z"),
("palette", "M480 -80Q398 -80 325 -111.5Q252 -143 197.5 -197.5Q143 -252 111.5 -325Q80 -398 80 -480Q80 -563 112.5 -636Q145 -709 200.5 -763Q256 -817 330 -848.5Q404 -880 488 -880Q568 -880 639 -852.5Q710 -825 763.5 -776.5Q817 -728 848.5 -661.5Q880 -595 880 -518Q880 -403 810 -341.5Q740 -280 640 -280H566Q557 -280 553.5 -275Q550 -270 550 -264Q550 -252 565 -229.5Q580 -207 580 -178Q580 -128 552.5 -104Q525 -80 480 -80ZM480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480ZM260 -440Q286 -440 303 -457Q320 -474 320 -500Q320 -526 303 -543Q286 -560 260 -560Q234 -560 217 -543Q200 -526 200 -500Q200 -474 217 -457Q234 -440 260 -440ZM380 -600Q406 -600 423 -617Q440 -634 440 -660Q440 -686 423 -703Q406 -720 380 -720Q354 -720 337 -703Q320 -686 320 -660Q320 -634 337 -617Q354 -600 380 -600ZM580 -600Q606 -600 623 -617Q640 -634 640 -660Q640 -686 623 -703Q606 -720 580 -720Q554 -720 537 -703Q520 -686 520 -660Q520 -634 537 -617Q554 -600 580 -600ZM700 -440Q726 -440 743 -457Q760 -474 760 -500Q760 -526 743 -543Q726 -560 700 -560Q674 -560 657 -543Q640 -526 640 -500Q640 -474 657 -457Q674 -440 700 -440ZM480 -160Q489 -160 494.5 -165Q500 -170 500 -178Q500 -192 485 -211Q470 -230 470 -268Q470 -310 499 -335Q528 -360 570 -360H640Q706 -360 753 -398.5Q800 -437 800 -518Q800 -639 707.5 -719.5Q615 -800 488 -800Q352 -800 256 -707Q160 -614 160 -480Q160 -347 253.5 -253.5Q347 -160 480 -160Z"),
("palette_fill", "M480 -80Q398 -80 325 -111.5Q252 -143 197.5 -197.5Q143 -252 111.5 -325Q80 -398 80 -480Q80 -563 112.5 -636Q145 -709 200.5 -763Q256 -817 330 -848.5Q404 -880 488 -880Q568 -880 639 -852.5Q710 -825 763.5 -776.5Q817 -728 848.5 -661.5Q880 -595 880 -518Q880 -403 810 -341.5Q740 -280 640 -280H566Q557 -280 553.5 -275Q550 -270 550 -264Q550 -252 565 -229.5Q580 -207 580 -178Q580 -128 552.5 -104Q525 -80 480 -80ZM480 -160Q347 -160 253.5 -253.5Q160 -347 160 -480Q160 -614 256 -707Q352 -800 488 -800Q615 -800 707.5 -719.5Q800 -639 800 -518Q800 -437 753 -398.5Q706 -360 640 -360H570Q528 -360 499 -335Q470 -310 470 -268Q470 -230 485 -211Q500 -192 500 -178Q500 -170 494.5 -165Q489 -160 480 -160ZM260 -440Q286 -440 303 -457Q320 -474 320 -500Q320 -526 303 -543Q286 -560 260 -560Q234 -560 217 -543Q200 -526 200 -500Q200 -474 217 -457Q234 -440 260 -440ZM380 -600Q406 -600 423 -617Q440 -634 440 -660Q440 -686 423 -703Q406 -720 380 -720Q354 -720 337 -703Q320 -686 320 -660Q320 -634 337 -617Q354 -600 380 -600ZM580 -600Q606 -600 623 -617Q640 -634 640 -660Q640 -686 623 -703Q606 -720 580 -720Q554 -720 537 -703Q520 -686 520 -660Q520 -634 537 -617Q554 -600 580 -600ZM700 -440Q726 -440 743 -457Q760 -474 760 -500Q760 -526 743 -543Q726 -560 700 -560Q674 -560 657 -543Q640 -526 640 -500Q640 -474 657 -457Q674 -440 700 -440ZM480 -160Q489 -160 494.5 -165Q500 -170 500 -178Q500 -192 485 -211Q470 -230 470 -268Q470 -310 499 -335Q528 -360 570 -360H640Q706 -360 753 -398.5Q800 -437 800 -518Q800 -639 707.5 -719.5Q615 -800 488 -800Q352 -800 256 -707Q160 -614 160 -480Q160 -347 253.5 -253.5Q347 -160 480 -160Z"),
("pin_drop", "M480 -301Q579 -381 629.5 -455Q680 -529 680 -594Q680 -684 624 -742Q568 -800 480 -800Q392 -800 336 -742Q280 -684 280 -594Q280 -529 330.5 -455Q381 -381 480 -301ZM434 -235Q316 -329 258 -418.5Q200 -508 200 -594Q200 -719 278 -799.5Q356 -880 480 -880Q604 -880 682 -799.5Q760 -719 760 -594Q760 -508 702 -418.5Q644 -329 526 -235Q516 -227 504 -223Q492 -219 480 -219Q468 -219 456 -223Q444 -227 434 -235ZM480 -520Q513 -520 536.5 -543.5Q560 -567 560 -600Q560 -633 536.5 -656.5Q513 -680 480 -680Q447 -680 423.5 -656.5Q400 -633 400 -600Q400 -567 423.5 -543.5Q447 -520 480 -520ZM240 -80Q223 -80 211.5 -91.5Q200 -103 200 -120Q200 -137 211.5 -148.5Q223 -160 240 -160H720Q737 -160 748.5 -148.5Q760 -137 760 -120Q760 -103 748.5 -91.5Q737 -80 720 -80ZM480 -600Q480 -600 480 -600Q480 -600 480 -600Q480 -600 480 -600Q480 -600 480 -600Q480 -600 480 -600Q480 -600 480 -600Q480 -600 480 -600Q480 -600 480 -600Z"),
("pin_drop_fill", "M480 -301Q579 -381 629.5 -455Q680 -529 680 -594Q680 -684 624 -742Q568 -800 480 -800Q392 -800 336 -742Q280 -684 280 -594Q280 -529 330.5 -455Q381 -381 480 -301ZM434 -235Q316 -329 258 -418.5Q200 -508 200 -594Q200 -719 278 -799.5Q356 -880 480 -880Q604 -880 682 -799.5Q760 -719 760 -594Q760 -508 702 -418.5Q644 -329 526 -235Q516 -227 504 -223Q492 -219 480 -219Q468 -219 456 -223Q444 -227 434 -235ZM480 -520Q513 -520 536.5 -543.5Q560 -567 560 -600Q560 -633 536.5 -656.5Q513 -680 480 -680Q447 -680 423.5 -656.5Q400 -633 400 -600Q400 -567 423.5 -543.5Q447 -520 480 -520ZM240 -80Q223 -80 211.5 -91.5Q200 -103 200 -120Q200 -137 211.5 -148.5Q223 -160 240 -160H720Q737 -160 748.5 -148.5Q760 -137 760 -120Q760 -103 748.5 -91.5Q737 -80 720 -80ZM480 -301Q381 -381 330.5 -455Q280 -529 280 -594Q280 -684 336 -742Q392 -800 480 -800Q568 -800 624 -742Q680 -684 680 -594Q680 -529 629.5 -455Q579 -381 480 -301Z"),
("play_arrow", "M320 -273V-687Q320 -704 332 -715.5Q344 -727 360 -727Q365 -727 370.5 -725.5Q376 -724 381 -721L707 -514Q716 -508 720.5 -499Q725 -490 725 -480Q725 -470 720.5 -461Q716 -452 707 -446L381 -239Q376 -236 370.5 -234.5Q365 -233 360 -233Q344 -233 332 -244.5Q320 -256 320 -273ZM400 -480ZM400 -346 610 -480 400 -614Z"),
("play_arrow_fill", "M320 -273V-687Q320 -704 332 -715.5Q344 -727 360 -727Q365 -727 370.5 -725.5Q376 -724 381 -721L707 -514Q716 -508 720.5 -499Q725 -490 725 -480Q725 -470 720.5 -461Q716 -452 707 -446L381 -239Q376 -236 370.5 -234.5Q365 -233 360 -233Q344 -233 332 -244.5Q320 -256 320 -273ZM400 -614 610 -480 400 -346ZM400 -346 610 -480 400 -614Z"),
("push_pin", "M640 -760V-480L708 -412Q714 -406 717 -398.5Q720 -391 720 -383V-360Q720 -343 708.5 -331.5Q697 -320 680 -320H520V-86Q520 -69 508.5 -57.5Q497 -46 480 -46Q463 -46 451.5 -57.5Q440 -69 440 -86V-320H280Q263 -320 251.5 -331.5Q240 -343 240 -360V-383Q240 -391 243 -398.5Q246 -406 252 -412L320 -480V-760Q303 -760 291.5 -771.5Q280 -783 280 -800Q280 -817 291.5 -828.5Q303 -840 320 -840H640Q657 -840 668.5 -828.5Q680 -817 680 -800Q680 -783 668.5 -771.5Q657 -760 640 -760ZM354 -400H606L560 -446V-760H400V-446ZM480 -400Z"),
("push_pin_fill", "M640 -760V-480L708 -412Q714 -406 717 -398.5Q720 -391 720 -383V-360Q720 -343 708.5 -331.5Q697 -320 680 -320H520V-86Q520 -69 508.5 -57.5Q497 -46 480 -46Q463 -46 451.5 -57.5Q440 -69 440 -86V-320H280Q263 -320 251.5 -331.5Q240 -343 240 -360V-383Q240 -391 243 -398.5Q246 -406 252 -412L320 -480V-760Q303 -760 291.5 -771.5Q280 -783 280 -800Q280 -817 291.5 -828.5Q303 -840 320 -840H640Q657 -840 668.5 -828.5Q680 -817 680 -800Q680 -783 668.5 -771.5Q657 -760 640 -760ZM354 -400H606L560 -446V-760H400V-446ZM354 -400 400 -446V-760H560V-446L606 -400Z"),
("redo", "M648 -560H396Q333 -560 286.5 -520Q240 -480 240 -420Q240 -360 286.5 -320Q333 -280 396 -280H640Q657 -280 668.5 -268.5Q680 -257 680 -240Q680 -223 668.5 -211.5Q657 -200 640 -200H396Q299 -200 229.5 -263Q160 -326 160 -420Q160 -514 229.5 -577Q299 -640 396 -640H648L572 -716Q561 -727 561 -744Q561 -761 572 -772Q583 -783 600 -783Q617 -783 628 -772L772 -628Q778 -622 780.5 -615Q783 -608 783 -600Q783 -592 780.5 -585Q778 -578 772 -572L628 -428Q617 -417 600 -417Q583 -417 572 -428Q561 -439 561 -456Q561 -473 572 -484Z"),
("refresh", "M480 -160Q346 -160 253 -253Q160 -346 160 -480Q160 -614 253 -707Q346 -800 480 -800Q549 -800 612 -771.5Q675 -743 720 -690V-760Q720 -777 731.5 -788.5Q743 -800 760 -800Q777 -800 788.5 -788.5Q800 -777 800 -760V-560Q800 -543 788.5 -531.5Q777 -520 760 -520H560Q543 -520 531.5 -531.5Q520 -543 520 -560Q520 -577 531.5 -588.5Q543 -600 560 -600H688Q656 -656 600.5 -688Q545 -720 480 -720Q380 -720 310 -650Q240 -580 240 -480Q240 -380 310 -310Q380 -240 480 -240Q548 -240 604.5 -274.5Q661 -309 692 -367Q700 -381 714.5 -386.5Q729 -392 744 -387Q760 -382 767 -366Q774 -350 766 -336Q725 -256 649 -208Q573 -160 480 -160Z"),
("regular_expression", "M80 -482Q80 -551 102.5 -615.5Q125 -680 169 -734Q180 -747 196.5 -748Q213 -749 225 -737Q237 -725 237.5 -708.5Q238 -692 227 -678Q194 -636 177 -586Q160 -536 160 -482Q160 -428 178 -378Q196 -328 228 -286Q239 -272 238.5 -256Q238 -240 226 -228Q214 -216 197.5 -216.5Q181 -217 170 -230Q127 -284 103.5 -348.5Q80 -413 80 -482ZM380 -240Q355 -240 337.5 -257.5Q320 -275 320 -300Q320 -325 337.5 -342.5Q355 -360 380 -360Q405 -360 422.5 -342.5Q440 -325 440 -300Q440 -275 422.5 -257.5Q405 -240 380 -240ZM519 -480V-511L493 -495Q479 -487 462.5 -491.5Q446 -496 438 -510Q430 -524 434.5 -540.5Q439 -557 453 -565L479 -580L452 -595Q438 -603 434 -619.5Q430 -636 438 -650Q446 -665 462.5 -668.5Q479 -672 493 -664L519 -649V-680Q519 -697 530.5 -708.5Q542 -720 559 -720Q576 -720 587.5 -708.5Q599 -697 599 -680V-649L625 -665Q639 -673 655.5 -668.5Q672 -664 680 -650Q688 -636 683.5 -619.5Q679 -603 665 -595L639 -580L666 -565Q680 -557 684 -540.5Q688 -524 680 -510Q672 -495 655.5 -491.5Q639 -488 625 -496L599 -511V-480Q599 -463 587.5 -451.5Q576 -440 559 -440Q542 -440 530.5 -451.5Q519 -463 519 -480ZM880 -482Q880 -413 857.5 -348.5Q835 -284 791 -230Q780 -217 763.5 -216.5Q747 -216 735 -228Q723 -240 722.5 -256Q722 -272 733 -286Q766 -328 783 -378Q800 -428 800 -482Q800 -536 782 -586Q764 -636 732 -678Q721 -692 722 -708.5Q723 -725 735 -737Q747 -749 763 -748Q779 -747 790 -734Q833 -680 856.5 -615.5Q880 -551 880 -482Z"),
("remove", "M240 -440Q223 -440 211.5 -451.5Q200 -463 200 -480Q200 -497 211.5 -508.5Q223 -520 240 -520H720Q737 -520 748.5 -508.5Q760 -497 760 -480Q760 -463 748.5 -451.5Q737 -440 720 -440Z"),
("restart_alt", "M393 -132Q290 -161 225 -245.5Q160 -330 160 -440Q160 -497 179 -548.5Q198 -600 233 -643Q244 -655 260 -655.5Q276 -656 289 -643Q300 -632 300.5 -616Q301 -600 290 -586Q266 -555 253 -518Q240 -481 240 -440Q240 -359 287.5 -295.5Q335 -232 410 -209Q423 -205 431.5 -194Q440 -183 440 -170Q440 -150 426 -138.5Q412 -127 393 -132ZM567 -132Q548 -127 534 -139Q520 -151 520 -171Q520 -183 528.5 -194Q537 -205 550 -209Q625 -233 672.5 -296Q720 -359 720 -440Q720 -540 650 -610Q580 -680 480 -680H477L493 -664Q504 -653 504 -636Q504 -619 493 -608Q482 -597 465 -597Q448 -597 437 -608L353 -692Q347 -698 344.5 -705Q342 -712 342 -720Q342 -728 344.5 -735Q347 -742 353 -748L437 -832Q448 -843 465 -843Q482 -843 493 -832Q504 -821 504 -804Q504 -787 493 -776L477 -760H480Q614 -760 707 -667Q800 -574 800 -440Q800 -331 735 -246Q670 -161 567 -132Z"),
("rocket_launch", "M284 -506Q298 -534 313 -560Q328 -586 346 -612L290 -623Q290 -623 290 -623Q290 -623 290 -623L206 -539Q206 -539 206 -539Q206 -539 206 -539ZM766 -781Q696 -779 616.5 -740Q537 -701 472 -636Q430 -594 397 -546Q364 -498 348 -456Q348 -456 348 -456Q348 -456 348 -456L462 -343Q462 -343 462 -343Q462 -343 462 -343Q504 -359 552 -392Q600 -425 642 -467Q707 -532 746 -611Q785 -690 787 -760Q787 -764 785.5 -768Q784 -772 781 -775Q778 -778 774 -779.5Q770 -781 766 -781ZM546 -541Q523 -564 523 -597.5Q523 -631 546 -654Q569 -677 603 -677Q637 -677 660 -654Q683 -631 683 -597.5Q683 -564 660 -541Q637 -518 603 -518Q569 -518 546 -541ZM512 -279 545 -200Q545 -200 545 -200Q545 -200 545 -200L629 -284Q629 -284 629 -284Q629 -284 629 -284L618 -340Q592 -322 566 -307.5Q540 -293 512 -279ZM863 -813Q871 -703 827 -598.5Q783 -494 688 -399Q688 -399 688 -399Q688 -399 688 -399L708 -300Q712 -280 706 -261Q700 -242 686 -228L560 -102Q545 -87 524 -90.5Q503 -94 495 -114L434 -257L263 -428L120 -489Q100 -497 96 -518Q92 -539 107 -554L233 -680Q247 -694 266.5 -700Q286 -706 306 -702L405 -682Q405 -682 405 -682Q405 -682 405 -682Q500 -777 604.5 -821Q709 -865 819 -857Q827 -856 835 -852.5Q843 -849 849 -843Q855 -837 858.5 -829Q862 -821 863 -813ZM157 -321Q192 -356 242.5 -356.5Q293 -357 328 -322Q363 -287 362.5 -236.5Q362 -186 327 -151Q279 -103 213.5 -94Q148 -85 82 -76Q91 -142 100 -207.5Q109 -273 157 -321ZM214 -265Q197 -248 190.5 -224Q184 -200 180 -175Q205 -179 229 -185Q253 -191 270 -208Q282 -220 283 -237Q284 -254 272 -266Q260 -278 243 -277.5Q226 -277 214 -265Z"),
("rocket_launch_fill", "M245 -474Q271 -540 307.5 -601Q344 -662 390 -716L338 -727Q318 -731 299 -725Q280 -719 266 -705L140 -579Q125 -564 128.5 -543Q132 -522 152 -514ZM833 -864Q727 -869 631.5 -823Q536 -777 461.3 -702.3Q413 -654 376.5 -598Q340 -542 313 -480Q308 -467 308 -453.5Q308 -440 318 -430L443 -305Q453 -295 466.5 -295Q480 -295 493 -300Q555 -327 611 -363.5Q667 -400 715.3 -448.3Q790 -523 836 -618.5Q882 -714 877 -820Q877 -828 873 -836Q869 -844 863 -850Q857 -856 849 -860Q841 -864 833 -864ZM579 -566Q556 -589 556 -622.5Q556 -656 579 -679Q602 -702 635.5 -702Q669 -702 692 -679Q715 -656 715 -622.5Q715 -589 692 -566Q669 -543 635.5 -543Q602 -543 579 -566ZM487 -232 527 -139Q535 -119 556 -115Q577 -111 592 -126L718 -252Q732 -266 738 -285.5Q744 -305 740 -325L730 -377Q675 -331 614.5 -294.5Q554 -258 487 -232ZM635 -622Q635 -622 635 -622Q635 -622 635 -622Q635 -622 635 -622Q635 -622 635 -622Q635 -622 635 -622Q635 -622 635 -622Q635 -622 635 -622Q635 -622 635 -622Q635 -622 635 -622Q635 -622 635 -622Q635 -622 635 -622Q635 -622 635 -622Q635 -622 635 -622Q635 -622 635 -622Q635 -622 635 -622Q635 -622 635 -622Q635 -622 635 -622Q635 -622 635 -622Q635 -622 635 -622Q635 -622 635 -622ZM162 -318Q196.8 -353 247.1 -353.5Q297.3 -354 332.2 -319Q367 -284 367 -234Q367 -184 332 -149Q284 -101 218.5 -92Q153 -83 87 -74Q96 -140 105.5 -205.5Q115 -271 162 -318ZM239 -226Q239 -226 239 -226Q239 -226 239 -226Q239 -226 239 -226Q239 -226 239 -226Q239 -226 239 -226Q239 -226 239 -226Q239 -226 239 -226Q239 -226 239 -226Z"),
("save", "M200 -120Q167 -120 143.5 -143.5Q120 -167 120 -200V-760Q120 -793 143.5 -816.5Q167 -840 200 -840H647Q663 -840 677.5 -834Q692 -828 703 -817L817 -703Q828 -692 834 -677.5Q840 -663 840 -647V-200Q840 -167 816.5 -143.5Q793 -120 760 -120ZM760 -646 646 -760H200Q200 -760 200 -760Q200 -760 200 -760V-200Q200 -200 200 -200Q200 -200 200 -200H760Q760 -200 760 -200Q760 -200 760 -200ZM480 -240Q530 -240 565 -275Q600 -310 600 -360Q600 -410 565 -445Q530 -480 480 -480Q430 -480 395 -445Q360 -410 360 -360Q360 -310 395 -275Q430 -240 480 -240ZM280 -560H560Q577 -560 588.5 -571.5Q600 -583 600 -600V-680Q600 -697 588.5 -708.5Q577 -720 560 -720H280Q263 -720 251.5 -708.5Q240 -697 240 -680V-600Q240 -583 251.5 -571.5Q263 -560 280 -560ZM200 -646V-200Q200 -200 200 -200Q200 -200 200 -200Q200 -200 200 -200Q200 -200 200 -200V-760Q200 -760 200 -760Q200 -760 200 -760Z"),
("save_as", "M200 -120Q167 -120 143.5 -143.5Q120 -167 120 -200V-760Q120 -793 143.5 -816.5Q167 -840 200 -840H647Q663 -840 677.5 -834Q692 -828 703 -817L817 -703Q828 -692 834 -677.5Q840 -663 840 -647V-520Q840 -503 828.5 -491.5Q817 -480 800 -480Q783 -480 771.5 -491.5Q760 -503 760 -520V-647L647 -760H200Q200 -760 200 -760Q200 -760 200 -760V-200Q200 -200 200 -200Q200 -200 200 -200H400Q417 -200 428.5 -188.5Q440 -177 440 -160Q440 -143 428.5 -131.5Q417 -120 400 -120ZM200 -760V-647V-478Q200 -475 200 -465.5Q200 -456 200 -441V-200Q200 -200 200 -200Q200 -200 200 -200V-760Q200 -760 200 -760Q200 -760 200 -760ZM520 -80V-146Q520 -154 523 -161.5Q526 -169 532 -175L741 -383Q750 -392 761 -396Q772 -400 783 -400Q795 -400 806 -395.5Q817 -391 826 -382L863 -345Q871 -336 875.5 -325Q880 -314 880 -303Q880 -292 876 -280.5Q872 -269 863 -260L655 -52Q649 -46 641.5 -43Q634 -40 626 -40H560Q543 -40 531.5 -51.5Q520 -63 520 -80ZM820 -303 783 -340ZM580 -100H618L739 -222L721 -241L702 -259L580 -138ZM721 -241 702 -259 739 -222ZM280 -560H560Q577 -560 588.5 -571.5Q600 -583 600 -600V-680Q600 -697 588.5 -708.5Q577 -720 560 -720H280Q263 -720 251.5 -708.5Q240 -697 240 -680V-600Q240 -583 251.5 -571.5Q263 -560 280 -560ZM480 -240Q481 -240 482 -240Q483 -240 484 -240L600 -355Q600 -357 600 -357.5Q600 -358 600 -360Q600 -410 565 -445Q530 -480 480 -480Q430 -480 395 -445Q360 -410 360 -360Q360 -310 395 -275Q430 -240 480 -240Z"),
("save_as_fill", "M200 -120Q167 -120 143.5 -143.5Q120 -167 120 -200V-760Q120 -793 143.5 -816.5Q167 -840 200 -840H647Q663 -840 677.5 -834Q692 -828 703 -817L817 -703Q828 -692 834 -677.5Q840 -663 840 -647V-513Q840 -496 826.5 -486Q813 -476 796 -479Q787 -480 778 -480Q769 -480 760 -478V-647L647 -760H200Q200 -760 200 -760Q200 -760 200 -760V-200Q200 -200 200 -200Q200 -200 200 -200H444Q443 -199 442 -198Q441 -197 440 -196Q440 -177 440 -158Q440 -139 440 -120ZM647 -760 760 -647V-478Q740 -475 721 -465.5Q702 -456 686 -441L444 -200H200Q200 -200 200 -200Q200 -200 200 -200V-760Q200 -760 200 -760Q200 -760 200 -760ZM520 -80V-146Q520 -154 523 -161.5Q526 -169 532 -175L741 -383Q750 -392 761 -396Q772 -400 783 -400Q795 -400 806 -395.5Q817 -391 826 -382L863 -345Q871 -336 875.5 -325Q880 -314 880 -303Q880 -292 876 -280.5Q872 -269 863 -260L655 -52Q649 -46 641.5 -43Q634 -40 626 -40H560Q543 -40 531.5 -51.5Q520 -63 520 -80ZM783 -264 820 -303 783 -340 745 -302ZM580 -100H618L739 -222L721 -241L702 -259L580 -138ZM580 -100V-138L702 -259L739 -222L618 -100ZM280 -560H560Q577 -560 588.5 -571.5Q600 -583 600 -600V-680Q600 -697 588.5 -708.5Q577 -720 560 -720H280Q263 -720 251.5 -708.5Q240 -697 240 -680V-600Q240 -583 251.5 -571.5Q263 -560 280 -560ZM480 -240Q481 -240 482 -240Q483 -240 484 -240L600 -355Q600 -357 600 -357.5Q600 -358 600 -360Q600 -410 565 -445Q530 -480 480 -480Q430 -480 395 -445Q360 -410 360 -360Q360 -310 395 -275Q430 -240 480 -240Z"),
("save_fill", "M200 -120Q167 -120 143.5 -143.5Q120 -167 120 -200V-760Q120 -793 143.5 -816.5Q167 -840 200 -840H647Q663 -840 677.5 -834Q692 -828 703 -817L817 -703Q828 -692 834 -677.5Q840 -663 840 -647V-200Q840 -167 816.5 -143.5Q793 -120 760 -120ZM760 -646 646 -760H200Q200 -760 200 -760Q200 -760 200 -760V-200Q200 -200 200 -200Q200 -200 200 -200H760Q760 -200 760 -200Q760 -200 760 -200ZM480 -240Q530 -240 565 -275Q600 -310 600 -360Q600 -410 565 -445Q530 -480 480 -480Q430 -480 395 -445Q360 -410 360 -360Q360 -310 395 -275Q430 -240 480 -240ZM280 -560H560Q577 -560 588.5 -571.5Q600 -583 600 -600V-680Q600 -697 588.5 -708.5Q577 -720 560 -720H280Q263 -720 251.5 -708.5Q240 -697 240 -680V-600Q240 -583 251.5 -571.5Q263 -560 280 -560ZM760 -646V-200Q760 -200 760 -200Q760 -200 760 -200H200Q200 -200 200 -200Q200 -200 200 -200V-760Q200 -760 200 -760Q200 -760 200 -760H646Z"),
("search", "M380 -320Q271 -320 195.5 -395.5Q120 -471 120 -580Q120 -689 195.5 -764.5Q271 -840 380 -840Q489 -840 564.5 -764.5Q640 -689 640 -580Q640 -536 626 -497Q612 -458 588 -428L812 -204Q823 -193 823 -176Q823 -159 812 -148Q801 -137 784 -137Q767 -137 756 -148L532 -372Q502 -348 463 -334Q424 -320 380 -320ZM380 -400Q455 -400 507.5 -452.5Q560 -505 560 -580Q560 -655 507.5 -707.5Q455 -760 380 -760Q305 -760 252.5 -707.5Q200 -655 200 -580Q200 -505 252.5 -452.5Q305 -400 380 -400Z"),
("segment", "M400 -240Q383 -240 371.5 -251.5Q360 -263 360 -280Q360 -297 371.5 -308.5Q383 -320 400 -320H800Q817 -320 828.5 -308.5Q840 -297 840 -280Q840 -263 828.5 -251.5Q817 -240 800 -240ZM400 -440Q383 -440 371.5 -451.5Q360 -463 360 -480Q360 -497 371.5 -508.5Q383 -520 400 -520H800Q817 -520 828.5 -508.5Q840 -497 840 -480Q840 -463 828.5 -451.5Q817 -440 800 -440ZM160 -640Q143 -640 131.5 -651.5Q120 -663 120 -680Q120 -697 131.5 -708.5Q143 -720 160 -720H800Q817 -720 828.5 -708.5Q840 -697 840 -680Q840 -663 828.5 -651.5Q817 -640 800 -640Z"),
("select_all", "M160 -760Q143 -760 131.5 -771.5Q120 -783 120 -800Q120 -817 131.5 -828.5Q143 -840 160 -840Q177 -840 188.5 -828.5Q200 -817 200 -800Q200 -783 188.5 -771.5Q177 -760 160 -760ZM320 -760Q303 -760 291.5 -771.5Q280 -783 280 -800Q280 -817 291.5 -828.5Q303 -840 320 -840Q337 -840 348.5 -828.5Q360 -817 360 -800Q360 -783 348.5 -771.5Q337 -760 320 -760ZM480 -760Q463 -760 451.5 -771.5Q440 -783 440 -800Q440 -817 451.5 -828.5Q463 -840 480 -840Q497 -840 508.5 -828.5Q520 -817 520 -800Q520 -783 508.5 -771.5Q497 -760 480 -760ZM640 -760Q623 -760 611.5 -771.5Q600 -783 600 -800Q600 -817 611.5 -828.5Q623 -840 640 -840Q657 -840 668.5 -828.5Q680 -817 680 -800Q680 -783 668.5 -771.5Q657 -760 640 -760ZM800 -760Q783 -760 771.5 -771.5Q760 -783 760 -800Q760 -817 771.5 -828.5Q783 -840 800 -840Q817 -840 828.5 -828.5Q840 -817 840 -800Q840 -783 828.5 -771.5Q817 -760 800 -760ZM160 -600Q143 -600 131.5 -611.5Q120 -623 120 -640Q120 -657 131.5 -668.5Q143 -680 160 -680Q177 -680 188.5 -668.5Q200 -657 200 -640Q200 -623 188.5 -611.5Q177 -600 160 -600ZM800 -600Q783 -600 771.5 -611.5Q760 -623 760 -640Q760 -657 771.5 -668.5Q783 -680 800 -680Q817 -680 828.5 -668.5Q840 -657 840 -640Q840 -623 828.5 -611.5Q817 -600 800 -600ZM160 -440Q143 -440 131.5 -451.5Q120 -463 120 -480Q120 -497 131.5 -508.5Q143 -520 160 -520Q177 -520 188.5 -508.5Q200 -497 200 -480Q200 -463 188.5 -451.5Q177 -440 160 -440ZM800 -440Q783 -440 771.5 -451.5Q760 -463 760 -480Q760 -497 771.5 -508.5Q783 -520 800 -520Q817 -520 828.5 -508.5Q840 -497 840 -480Q840 -463 828.5 -451.5Q817 -440 800 -440ZM160 -280Q143 -280 131.5 -291.5Q120 -303 120 -320Q120 -337 131.5 -348.5Q143 -360 160 -360Q177 -360 188.5 -348.5Q200 -337 200 -320Q200 -303 188.5 -291.5Q177 -280 160 -280ZM800 -280Q783 -280 771.5 -291.5Q760 -303 760 -320Q760 -337 771.5 -348.5Q783 -360 800 -360Q817 -360 828.5 -348.5Q840 -337 840 -320Q840 -303 828.5 -291.5Q817 -280 800 -280ZM160 -120Q143 -120 131.5 -131.5Q120 -143 120 -160Q120 -177 131.5 -188.5Q143 -200 160 -200Q177 -200 188.5 -188.5Q200 -177 200 -160Q200 -143 188.5 -131.5Q177 -120 160 -120ZM320 -120Q303 -120 291.5 -131.5Q280 -143 280 -160Q280 -177 291.5 -188.5Q303 -200 320 -200Q337 -200 348.5 -188.5Q360 -177 360 -160Q360 -143 348.5 -131.5Q337 -120 320 -120ZM480 -120Q463 -120 451.5 -131.5Q440 -143 440 -160Q440 -177 451.5 -188.5Q463 -200 480 -200Q497 -200 508.5 -188.5Q520 -177 520 -160Q520 -143 508.5 -131.5Q497 -120 480 -120ZM640 -120Q623 -120 611.5 -131.5Q600 -143 600 -160Q600 -177 611.5 -188.5Q623 -200 640 -200Q657 -200 668.5 -188.5Q680 -177 680 -160Q680 -143 668.5 -131.5Q657 -120 640 -120ZM800 -120Q783 -120 771.5 -131.5Q760 -143 760 -160Q760 -177 771.5 -188.5Q783 -200 800 -200Q817 -200 828.5 -188.5Q840 -177 840 -160Q840 -143 828.5 -131.5Q817 -120 800 -120ZM360 -280Q327 -280 303.5 -303.5Q280 -327 280 -360V-600Q280 -633 303.5 -656.5Q327 -680 360 -680H600Q633 -680 656.5 -656.5Q680 -633 680 -600V-360Q680 -327 656.5 -303.5Q633 -280 600 -280ZM360 -360H600Q600 -360 600 -360Q600 -360 600 -360V-600Q600 -600 600 -600Q600 -600 600 -600H360Q360 -600 360 -600Q360 -600 360 -600V-360Q360 -360 360 -360Q360 -360 360 -360Z"),
("settings", "M433 -80Q406 -80 386.5 -98Q367 -116 363 -142L354 -208Q341 -213 329.5 -220Q318 -227 307 -235L245 -209Q220 -198 195 -207Q170 -216 156 -239L109 -321Q95 -344 101 -370Q107 -396 128 -413L181 -453Q180 -460 180 -466.5Q180 -473 180 -480Q180 -487 180 -493.5Q180 -500 181 -507L128 -547Q107 -564 101 -590Q95 -616 109 -639L156 -721Q170 -744 195 -753Q220 -762 245 -751L307 -725Q318 -733 330 -740Q342 -747 354 -752L363 -818Q367 -844 386.5 -862Q406 -880 433 -880H527Q554 -880 573.5 -862Q593 -844 597 -818L606 -752Q619 -747 630.5 -740Q642 -733 653 -725L715 -751Q740 -762 765 -753Q790 -744 804 -721L851 -639Q865 -616 859 -590Q853 -564 832 -547L779 -507Q780 -500 780 -493.5Q780 -487 780 -480Q780 -473 780 -466.5Q780 -460 778 -453L831 -413Q852 -396 858 -370Q864 -344 850 -321L802 -239Q788 -216 763 -207Q738 -198 713 -209L653 -235Q642 -227 630 -220Q618 -213 606 -208L597 -142Q593 -116 573.5 -98Q554 -80 527 -80ZM440 -160H519L533 -266Q564 -274 590.5 -289.5Q617 -305 639 -327L738 -286L777 -354L691 -419Q696 -433 698 -448.5Q700 -464 700 -480Q700 -496 698 -511.5Q696 -527 691 -541L777 -606L738 -674L639 -632Q617 -655 590.5 -670.5Q564 -686 533 -694L520 -800H441L427 -694Q396 -686 369.5 -670.5Q343 -655 321 -633L222 -674L183 -606L269 -542Q264 -527 262 -512Q260 -497 260 -480Q260 -464 262 -449Q264 -434 269 -419L183 -354L222 -286L321 -328Q343 -305 369.5 -289.5Q396 -274 427 -266ZM482 -340Q540 -340 581 -381Q622 -422 622 -480Q622 -538 581 -579Q540 -620 482 -620Q423 -620 382.5 -579Q342 -538 342 -480Q342 -422 382.5 -381Q423 -340 482 -340ZM480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Z"),
("settings_fill", "M433 -80Q406 -80 386.5 -98Q367 -116 363 -142L354 -208Q341 -213 329.5 -220Q318 -227 307 -235L245 -209Q220 -198 195 -207Q170 -216 156 -239L109 -321Q95 -344 101 -370Q107 -396 128 -413L181 -453Q180 -460 180 -466.5Q180 -473 180 -480Q180 -487 180 -493.5Q180 -500 181 -507L128 -547Q107 -564 101 -590Q95 -616 109 -639L156 -721Q170 -744 195 -753Q220 -762 245 -751L307 -725Q318 -733 330 -740Q342 -747 354 -752L363 -818Q367 -844 386.5 -862Q406 -880 433 -880H527Q554 -880 573.5 -862Q593 -844 597 -818L606 -752Q619 -747 630.5 -740Q642 -733 653 -725L715 -751Q740 -762 765 -753Q790 -744 804 -721L851 -639Q865 -616 859 -590Q853 -564 832 -547L779 -507Q780 -500 780 -493.5Q780 -487 780 -480Q780 -473 780 -466.5Q780 -460 778 -453L831 -413Q852 -396 858 -370Q864 -344 850 -321L802 -239Q788 -216 763 -207Q738 -198 713 -209L653 -235Q642 -227 630 -220Q618 -213 606 -208L597 -142Q593 -116 573.5 -98Q554 -80 527 -80ZM440 -160H519L533 -266Q564 -274 590.5 -289.5Q617 -305 639 -327L738 -286L777 -354L691 -419Q696 -433 698 -448.5Q700 -464 700 -480Q700 -496 698 -511.5Q696 -527 691 -541L777 -606L738 -674L639 -632Q617 -655 590.5 -670.5Q564 -686 533 -694L520 -800H441L427 -694Q396 -686 369.5 -670.5Q343 -655 321 -633L222 -674L183 -606L269 -542Q264 -527 262 -512Q260 -497 260 -480Q260 -464 262 -449Q264 -434 269 -419L183 -354L222 -286L321 -328Q343 -305 369.5 -289.5Q396 -274 427 -266ZM482 -340Q540 -340 581 -381Q622 -422 622 -480Q622 -538 581 -579Q540 -620 482 -620Q423 -620 382.5 -579Q342 -538 342 -480Q342 -422 382.5 -381Q423 -340 482 -340ZM440 -160 427 -266Q396 -274 369.5 -289.5Q343 -305 321 -328L222 -286L183 -354L269 -419Q264 -434 262 -449Q260 -464 260 -480Q260 -497 262 -512Q264 -527 269 -542L183 -606L222 -674L321 -633Q343 -655 369.5 -670.5Q396 -686 427 -694L441 -800H520L533 -694Q564 -686 590.5 -670.5Q617 -655 639 -632L738 -674L777 -606L691 -541Q696 -527 698 -511.5Q700 -496 700 -480Q700 -464 698 -448.5Q696 -433 691 -419L777 -354L738 -286L639 -327Q617 -305 590.5 -289.5Q564 -274 533 -266L519 -160Z"),
("splitscreen", "M200 -520Q167 -520 143.5 -543.5Q120 -567 120 -600V-760Q120 -793 143.5 -816.5Q167 -840 200 -840H760Q793 -840 816.5 -816.5Q840 -793 840 -760V-600Q840 -567 816.5 -543.5Q793 -520 760 -520ZM200 -600H760Q760 -600 760 -600Q760 -600 760 -600V-760Q760 -760 760 -760Q760 -760 760 -760H200Q200 -760 200 -760Q200 -760 200 -760V-600Q200 -600 200 -600Q200 -600 200 -600ZM200 -120Q167 -120 143.5 -143.5Q120 -167 120 -200V-360Q120 -393 143.5 -416.5Q167 -440 200 -440H760Q793 -440 816.5 -416.5Q840 -393 840 -360V-200Q840 -167 816.5 -143.5Q793 -120 760 -120ZM200 -200H760Q760 -200 760 -200Q760 -200 760 -200V-360Q760 -360 760 -360Q760 -360 760 -360H200Q200 -360 200 -360Q200 -360 200 -360V-200Q200 -200 200 -200Q200 -200 200 -200ZM200 -600Q200 -600 200 -600Q200 -600 200 -600V-760Q200 -760 200 -760Q200 -760 200 -760Q200 -760 200 -760Q200 -760 200 -760V-600Q200 -600 200 -600Q200 -600 200 -600ZM200 -200Q200 -200 200 -200Q200 -200 200 -200V-360Q200 -360 200 -360Q200 -360 200 -360Q200 -360 200 -360Q200 -360 200 -360V-200Q200 -200 200 -200Q200 -200 200 -200Z"),
("splitscreen_fill", "M200 -520Q167 -520 143.5 -543.5Q120 -567 120 -600V-760Q120 -793 143.5 -816.5Q167 -840 200 -840H760Q793 -840 816.5 -816.5Q840 -793 840 -760V-600Q840 -567 816.5 -543.5Q793 -520 760 -520ZM200 -600H760Q760 -600 760 -600Q760 -600 760 -600V-760Q760 -760 760 -760Q760 -760 760 -760H200Q200 -760 200 -760Q200 -760 200 -760V-600Q200 -600 200 -600Q200 -600 200 -600ZM200 -120Q167 -120 143.5 -143.5Q120 -167 120 -200V-360Q120 -393 143.5 -416.5Q167 -440 200 -440H760Q793 -440 816.5 -416.5Q840 -393 840 -360V-200Q840 -167 816.5 -143.5Q793 -120 760 -120ZM200 -200H760Q760 -200 760 -200Q760 -200 760 -200V-360Q760 -360 760 -360Q760 -360 760 -360H200Q200 -360 200 -360Q200 -360 200 -360V-200Q200 -200 200 -200Q200 -200 200 -200ZM200 -600Q200 -600 200 -600Q200 -600 200 -600V-760Q200 -760 200 -760Q200 -760 200 -760H760Q760 -760 760 -760Q760 -760 760 -760V-600Q760 -600 760 -600Q760 -600 760 -600ZM200 -200Q200 -200 200 -200Q200 -200 200 -200V-360Q200 -360 200 -360Q200 -360 200 -360H760Q760 -360 760 -360Q760 -360 760 -360V-200Q760 -200 760 -200Q760 -200 760 -200Z"),
("splitscreen_right", "M600 -120Q567 -120 543.5 -143.5Q520 -167 520 -200V-760Q520 -793 543.5 -816.5Q567 -840 600 -840H760Q793 -840 816.5 -816.5Q840 -793 840 -760V-200Q840 -167 816.5 -143.5Q793 -120 760 -120ZM200 -120Q167 -120 143.5 -143.5Q120 -167 120 -200V-760Q120 -793 143.5 -816.5Q167 -840 200 -840H360Q393 -840 416.5 -816.5Q440 -793 440 -760V-200Q440 -167 416.5 -143.5Q393 -120 360 -120ZM200 -760V-200Q200 -200 200 -200Q200 -200 200 -200H360Q360 -200 360 -200Q360 -200 360 -200V-760Q360 -760 360 -760Q360 -760 360 -760H200Q200 -760 200 -760Q200 -760 200 -760Z"),
("stop", "M240 -320V-640Q240 -673 263.5 -696.5Q287 -720 320 -720H640Q673 -720 696.5 -696.5Q720 -673 720 -640V-320Q720 -287 696.5 -263.5Q673 -240 640 -240H320Q287 -240 263.5 -263.5Q240 -287 240 -320ZM320 -320H640Q640 -320 640 -320Q640 -320 640 -320V-640Q640 -640 640 -640Q640 -640 640 -640H320Q320 -640 320 -640Q320 -640 320 -640V-320Q320 -320 320 -320Q320 -320 320 -320ZM480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Z"),
("stop_fill", "M240 -320V-640Q240 -673 263.5 -696.5Q287 -720 320 -720H640Q673 -720 696.5 -696.5Q720 -673 720 -640V-320Q720 -287 696.5 -263.5Q673 -240 640 -240H320Q287 -240 263.5 -263.5Q240 -287 240 -320ZM320 -320H640Q640 -320 640 -320Q640 -320 640 -320V-640Q640 -640 640 -640Q640 -640 640 -640H320Q320 -640 320 -640Q320 -640 320 -640V-320Q320 -320 320 -320Q320 -320 320 -320ZM320 -320Q320 -320 320 -320Q320 -320 320 -320V-640Q320 -640 320 -640Q320 -640 320 -640H640Q640 -640 640 -640Q640 -640 640 -640V-320Q640 -320 640 -320Q640 -320 640 -320Z"),
("swap_vert", "M320 -480V-727L245 -652Q234 -641 217.5 -641Q201 -641 189 -652Q177 -664 177 -680.5Q177 -697 189 -709L332 -852Q338 -858 345 -860.5Q352 -863 360 -863Q368 -863 375 -860.5Q382 -858 388 -852L532 -708Q544 -696 543.5 -680Q543 -664 531 -652Q519 -641 503 -640.5Q487 -640 475 -652L400 -727V-480Q400 -463 388.5 -451.5Q377 -440 360 -440Q343 -440 331.5 -451.5Q320 -463 320 -480ZM572 -108 428 -252Q416 -264 416.5 -280Q417 -296 429 -308Q441 -319 457 -319.5Q473 -320 485 -308L560 -233V-480Q560 -497 571.5 -508.5Q583 -520 600 -520Q617 -520 628.5 -508.5Q640 -497 640 -480V-233L715 -308Q726 -319 742.5 -319Q759 -319 771 -308Q783 -296 783 -279.5Q783 -263 771 -251L628 -108Q622 -102 615 -99.5Q608 -97 600 -97Q592 -97 585 -99.5Q578 -102 572 -108Z"),
("sync", "M240 -478Q240 -433 257 -390.5Q274 -348 310 -312L320 -302V-360Q320 -377 331.5 -388.5Q343 -400 360 -400Q377 -400 388.5 -388.5Q400 -377 400 -360V-200Q400 -183 388.5 -171.5Q377 -160 360 -160H200Q183 -160 171.5 -171.5Q160 -183 160 -200Q160 -217 171.5 -228.5Q183 -240 200 -240H270L254 -254Q202 -300 181 -359Q160 -418 160 -478Q160 -572 208 -648.5Q256 -725 337 -766Q351 -774 366.5 -767Q382 -760 387 -744Q392 -729 386.5 -714Q381 -699 367 -691Q309 -659 274.5 -602.5Q240 -546 240 -478ZM720 -482Q720 -527 703 -569.5Q686 -612 650 -648L640 -658V-600Q640 -583 628.5 -571.5Q617 -560 600 -560Q583 -560 571.5 -571.5Q560 -583 560 -600V-760Q560 -777 571.5 -788.5Q583 -800 600 -800H760Q777 -800 788.5 -788.5Q800 -777 800 -760Q800 -743 788.5 -731.5Q777 -720 760 -720H690L706 -706Q755 -657 777.5 -599.5Q800 -542 800 -482Q800 -388 752 -311.5Q704 -235 623 -194Q609 -186 593.5 -193Q578 -200 573 -216Q568 -231 573.5 -246Q579 -261 593 -269Q651 -301 685.5 -357.5Q720 -414 720 -482Z"),
("tab", "M160 -240H800Q800 -240 800 -240Q800 -240 800 -240V-560H560Q543 -560 531.5 -571.5Q520 -583 520 -600V-720H160Q160 -720 160 -720Q160 -720 160 -720V-240Q160 -240 160 -240Q160 -240 160 -240ZM160 -160Q127 -160 103.5 -183.5Q80 -207 80 -240V-720Q80 -753 103.5 -776.5Q127 -800 160 -800H800Q833 -800 856.5 -776.5Q880 -753 880 -720V-240Q880 -207 856.5 -183.5Q833 -160 800 -160ZM160 -240Q160 -240 160 -240Q160 -240 160 -240V-720Q160 -720 160 -720Q160 -720 160 -720Q160 -720 160 -720Q160 -720 160 -720V-240Q160 -240 160 -240Q160 -240 160 -240Z"),
("tab_fill", "M160 -240H800Q800 -240 800 -240Q800 -240 800 -240V-560H560Q543 -560 531.5 -571.5Q520 -583 520 -600V-720H160Q160 -720 160 -720Q160 -720 160 -720V-240Q160 -240 160 -240Q160 -240 160 -240ZM160 -160Q127 -160 103.5 -183.5Q80 -207 80 -240V-720Q80 -753 103.5 -776.5Q127 -800 160 -800H800Q833 -800 856.5 -776.5Q880 -753 880 -720V-240Q880 -207 856.5 -183.5Q833 -160 800 -160ZM800 -240Q800 -240 800 -240Q800 -240 800 -240V-720Q800 -720 800 -720Q800 -720 800 -720H160Q160 -720 160 -720Q160 -720 160 -720V-240Q160 -240 160 -240Q160 -240 160 -240Z"),
("tag", "M360 -320 327 -189Q324 -176 314 -168Q304 -160 290 -160Q271 -160 259 -175Q247 -190 252 -208L280 -320H171Q151 -320 139 -335.5Q127 -351 132 -370Q135 -384 146 -392Q157 -400 171 -400H300L340 -560H231Q211 -560 199 -575.5Q187 -591 192 -610Q195 -624 206 -632Q217 -640 231 -640H360L393 -771Q396 -784 406 -792Q416 -800 430 -800Q449 -800 461 -785Q473 -770 468 -752L440 -640H600L633 -771Q636 -784 646 -792Q656 -800 670 -800Q689 -800 701 -785Q713 -770 708 -752L680 -640H789Q809 -640 821 -624.5Q833 -609 828 -590Q825 -576 814 -568Q803 -560 789 -560H660L620 -400H729Q749 -400 761 -384.5Q773 -369 768 -350Q765 -336 754 -328Q743 -320 729 -320H600L567 -189Q564 -176 554 -168Q544 -160 530 -160Q511 -160 499 -175Q487 -190 492 -208L520 -320ZM380 -400H540L580 -560H420Z"),
("terminal", "M160 -160Q127 -160 103.5 -183.5Q80 -207 80 -240V-720Q80 -753 103.5 -776.5Q127 -800 160 -800H800Q833 -800 856.5 -776.5Q880 -753 880 -720V-240Q880 -207 856.5 -183.5Q833 -160 800 -160ZM160 -240H800Q800 -240 800 -240Q800 -240 800 -240V-640H160V-240Q160 -240 160 -240Q160 -240 160 -240ZM347 -440 271 -516Q259 -528 259.5 -544Q260 -560 272 -572Q284 -583 300 -583.5Q316 -584 328 -572L432 -468Q444 -456 444 -440Q444 -424 432 -412L328 -308Q317 -297 300.5 -296.5Q284 -296 272 -308Q261 -319 261 -336Q261 -353 272 -364ZM520 -280Q503 -280 491.5 -291.5Q480 -303 480 -320Q480 -337 491.5 -348.5Q503 -360 520 -360H680Q697 -360 708.5 -348.5Q720 -337 720 -320Q720 -303 708.5 -291.5Q697 -280 680 -280Z"),
("text_fields", "M280 -220V-680H140Q115 -680 97.5 -697.5Q80 -715 80 -740Q80 -765 97.5 -782.5Q115 -800 140 -800H540Q565 -800 582.5 -782.5Q600 -765 600 -740Q600 -715 582.5 -697.5Q565 -680 540 -680H400V-220Q400 -195 382.5 -177.5Q365 -160 340 -160Q315 -160 297.5 -177.5Q280 -195 280 -220ZM640 -220V-480H580Q555 -480 537.5 -497.5Q520 -515 520 -540Q520 -565 537.5 -582.5Q555 -600 580 -600H820Q845 -600 862.5 -582.5Q880 -565 880 -540Q880 -515 862.5 -497.5Q845 -480 820 -480H760V-220Q760 -195 742.5 -177.5Q725 -160 700 -160Q675 -160 657.5 -177.5Q640 -195 640 -220Z"),
("tune", "M440 -160V-320Q440 -337 451.5 -348.5Q463 -360 480 -360Q497 -360 508.5 -348.5Q520 -337 520 -320V-280H800Q817 -280 828.5 -268.5Q840 -257 840 -240Q840 -223 828.5 -211.5Q817 -200 800 -200H520V-160Q520 -143 508.5 -131.5Q497 -120 480 -120Q463 -120 451.5 -131.5Q440 -143 440 -160ZM160 -200Q143 -200 131.5 -211.5Q120 -223 120 -240Q120 -257 131.5 -268.5Q143 -280 160 -280H320Q337 -280 348.5 -268.5Q360 -257 360 -240Q360 -223 348.5 -211.5Q337 -200 320 -200ZM280 -400V-440H160Q143 -440 131.5 -451.5Q120 -463 120 -480Q120 -497 131.5 -508.5Q143 -520 160 -520H280V-560Q280 -577 291.5 -588.5Q303 -600 320 -600Q337 -600 348.5 -588.5Q360 -577 360 -560V-400Q360 -383 348.5 -371.5Q337 -360 320 -360Q303 -360 291.5 -371.5Q280 -383 280 -400ZM480 -440Q463 -440 451.5 -451.5Q440 -463 440 -480Q440 -497 451.5 -508.5Q463 -520 480 -520H800Q817 -520 828.5 -508.5Q840 -497 840 -480Q840 -463 828.5 -451.5Q817 -440 800 -440ZM600 -640V-800Q600 -817 611.5 -828.5Q623 -840 640 -840Q657 -840 668.5 -828.5Q680 -817 680 -800V-760H800Q817 -760 828.5 -748.5Q840 -737 840 -720Q840 -703 828.5 -691.5Q817 -680 800 -680H680V-640Q680 -623 668.5 -611.5Q657 -600 640 -600Q623 -600 611.5 -611.5Q600 -623 600 -640ZM160 -680Q143 -680 131.5 -691.5Q120 -703 120 -720Q120 -737 131.5 -748.5Q143 -760 160 -760H480Q497 -760 508.5 -748.5Q520 -737 520 -720Q520 -703 508.5 -691.5Q497 -680 480 -680Z"),
("undo", "M320 -200Q303 -200 291.5 -211.5Q280 -223 280 -240Q280 -257 291.5 -268.5Q303 -280 320 -280H564Q627 -280 673.5 -320Q720 -360 720 -420Q720 -480 673.5 -520Q627 -560 564 -560H312L388 -484Q399 -473 399 -456Q399 -439 388 -428Q377 -417 360 -417Q343 -417 332 -428L188 -572Q182 -578 179.5 -585Q177 -592 177 -600Q177 -608 179.5 -615Q182 -622 188 -628L332 -772Q343 -783 360 -783Q377 -783 388 -772Q399 -761 399 -744Q399 -727 388 -716L312 -640H564Q661 -640 730.5 -577Q800 -514 800 -420Q800 -326 730.5 -263Q661 -200 564 -200Z"),
("unfold_less", "M480 -284 384 -188Q373 -177 356 -177Q339 -177 328 -188Q317 -199 317 -216Q317 -233 328 -244L452 -368Q458 -374 465 -376.5Q472 -379 480 -379Q488 -379 495 -376.5Q502 -374 508 -368L632 -244Q643 -233 643 -216Q643 -199 632 -188Q621 -177 604 -177Q587 -177 576 -188ZM480 -676 576 -772Q587 -783 604 -783Q621 -783 632 -772Q643 -761 643 -744Q643 -727 632 -716L508 -592Q502 -586 495 -583.5Q488 -581 480 -581Q472 -581 465 -583.5Q458 -586 452 -592L328 -716Q317 -727 317 -744Q317 -761 328 -772Q339 -783 356 -783Q373 -783 384 -772Z"),
("unfold_more", "M480 -236 573 -329Q585 -341 602 -341Q619 -341 631 -329Q643 -317 643 -300Q643 -283 631 -271L508 -148Q502 -142 495 -139.5Q488 -137 480 -137Q472 -137 465 -139.5Q458 -142 452 -148L329 -271Q317 -283 317 -300Q317 -317 329 -329Q341 -341 358 -341Q375 -341 387 -329ZM480 -720 387 -627Q375 -615 358 -615Q341 -615 329 -627Q317 -639 317 -656Q317 -673 329 -685L452 -808Q458 -814 465 -816.5Q472 -819 480 -819Q488 -819 495 -816.5Q502 -814 508 -808L631 -685Q643 -673 643 -656Q643 -639 631 -627Q619 -615 602 -615Q585 -615 573 -627Z"),
("upload", "M240 -160Q207 -160 183.5 -183.5Q160 -207 160 -240V-320Q160 -337 171.5 -348.5Q183 -360 200 -360Q217 -360 228.5 -348.5Q240 -337 240 -320V-240Q240 -240 240 -240Q240 -240 240 -240H720Q720 -240 720 -240Q720 -240 720 -240V-320Q720 -337 731.5 -348.5Q743 -360 760 -360Q777 -360 788.5 -348.5Q800 -337 800 -320V-240Q800 -207 776.5 -183.5Q753 -160 720 -160ZM440 -646 365 -571Q353 -559 336.5 -559.5Q320 -560 308 -572Q297 -584 296.5 -600Q296 -616 308 -628L452 -772Q458 -778 465 -780.5Q472 -783 480 -783Q488 -783 495 -780.5Q502 -778 508 -772L652 -628Q664 -616 663.5 -600Q663 -584 652 -572Q640 -560 623.5 -559.5Q607 -559 595 -571L520 -646V-360Q520 -343 508.5 -331.5Q497 -320 480 -320Q463 -320 451.5 -331.5Q440 -343 440 -360Z"),
("vertical_split", "M160 -360Q143 -360 131.5 -371.5Q120 -383 120 -400Q120 -417 131.5 -428.5Q143 -440 160 -440H400Q417 -440 428.5 -428.5Q440 -417 440 -400Q440 -383 428.5 -371.5Q417 -360 400 -360ZM160 -200Q143 -200 131.5 -211.5Q120 -223 120 -240Q120 -257 131.5 -268.5Q143 -280 160 -280H400Q417 -280 428.5 -268.5Q440 -257 440 -240Q440 -223 428.5 -211.5Q417 -200 400 -200ZM160 -520Q143 -520 131.5 -531.5Q120 -543 120 -560Q120 -577 131.5 -588.5Q143 -600 160 -600H400Q417 -600 428.5 -588.5Q440 -577 440 -560Q440 -543 428.5 -531.5Q417 -520 400 -520ZM160 -680Q143 -680 131.5 -691.5Q120 -703 120 -720Q120 -737 131.5 -748.5Q143 -760 160 -760H400Q417 -760 428.5 -748.5Q440 -737 440 -720Q440 -703 428.5 -691.5Q417 -680 400 -680ZM600 -200Q567 -200 543.5 -223.5Q520 -247 520 -280V-680Q520 -713 543.5 -736.5Q567 -760 600 -760H760Q793 -760 816.5 -736.5Q840 -713 840 -680V-280Q840 -247 816.5 -223.5Q793 -200 760 -200ZM600 -280H760Q760 -280 760 -280Q760 -280 760 -280V-680Q760 -680 760 -680Q760 -680 760 -680H600Q600 -680 600 -680Q600 -680 600 -680V-280Q600 -280 600 -280Q600 -280 600 -280ZM680 -480Q680 -480 680 -480Q680 -480 680 -480Q680 -480 680 -480Q680 -480 680 -480Q680 -480 680 -480Q680 -480 680 -480Q680 -480 680 -480Q680 -480 680 -480Z"),
("vertical_split_fill", "M160 -360Q143 -360 131.5 -371.5Q120 -383 120 -400Q120 -417 131.5 -428.5Q143 -440 160 -440H400Q417 -440 428.5 -428.5Q440 -417 440 -400Q440 -383 428.5 -371.5Q417 -360 400 -360ZM160 -200Q143 -200 131.5 -211.5Q120 -223 120 -240Q120 -257 131.5 -268.5Q143 -280 160 -280H400Q417 -280 428.5 -268.5Q440 -257 440 -240Q440 -223 428.5 -211.5Q417 -200 400 -200ZM160 -520Q143 -520 131.5 -531.5Q120 -543 120 -560Q120 -577 131.5 -588.5Q143 -600 160 -600H400Q417 -600 428.5 -588.5Q440 -577 440 -560Q440 -543 428.5 -531.5Q417 -520 400 -520ZM160 -680Q143 -680 131.5 -691.5Q120 -703 120 -720Q120 -737 131.5 -748.5Q143 -760 160 -760H400Q417 -760 428.5 -748.5Q440 -737 440 -720Q440 -703 428.5 -691.5Q417 -680 400 -680ZM600 -200Q567 -200 543.5 -223.5Q520 -247 520 -280V-680Q520 -713 543.5 -736.5Q567 -760 600 -760H760Q793 -760 816.5 -736.5Q840 -713 840 -680V-280Q840 -247 816.5 -223.5Q793 -200 760 -200ZM600 -280H760Q760 -280 760 -280Q760 -280 760 -280V-680Q760 -680 760 -680Q760 -680 760 -680H600Q600 -680 600 -680Q600 -680 600 -680V-280Q600 -280 600 -280Q600 -280 600 -280ZM600 -280Q600 -280 600 -280Q600 -280 600 -280V-680Q600 -680 600 -680Q600 -680 600 -680H760Q760 -680 760 -680Q760 -680 760 -680V-280Q760 -280 760 -280Q760 -280 760 -280Z"),
("view_sidebar", "M160 -160Q127 -160 103.5 -183.5Q80 -207 80 -240V-720Q80 -753 103.5 -776.5Q127 -800 160 -800H800Q833 -800 856.5 -776.5Q880 -753 880 -720V-240Q880 -207 856.5 -183.5Q833 -160 800 -160ZM700 -613H800Q800 -613 800 -613Q800 -613 800 -613V-720Q800 -720 800 -720Q800 -720 800 -720H700Q700 -720 700 -720Q700 -720 700 -720V-613Q700 -613 700 -613Q700 -613 700 -613ZM700 -427H800Q800 -427 800 -427Q800 -427 800 -427V-533Q800 -533 800 -533Q800 -533 800 -533H700Q700 -533 700 -533Q700 -533 700 -533V-427Q700 -427 700 -427Q700 -427 700 -427ZM160 -240H620Q620 -240 620 -240Q620 -240 620 -240V-720Q620 -720 620 -720Q620 -720 620 -720H160Q160 -720 160 -720Q160 -720 160 -720V-240Q160 -240 160 -240Q160 -240 160 -240ZM700 -240H800Q800 -240 800 -240Q800 -240 800 -240V-347Q800 -347 800 -347Q800 -347 800 -347H700Q700 -347 700 -347Q700 -347 700 -347V-240Q700 -240 700 -240Q700 -240 700 -240Z"),
("view_sidebar_fill", "M480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480Q480 -480 480 -480ZM780 -640H820Q845 -640 862.5 -657.5Q880 -675 880 -700V-740Q880 -765 862.5 -782.5Q845 -800 820 -800H780Q755 -800 737.5 -782.5Q720 -765 720 -740V-700Q720 -675 737.5 -657.5Q755 -640 780 -640ZM780 -400H820Q845 -400 862.5 -417.5Q880 -435 880 -460V-500Q880 -525 862.5 -542.5Q845 -560 820 -560H780Q755 -560 737.5 -542.5Q720 -525 720 -500V-460Q720 -435 737.5 -417.5Q755 -400 780 -400ZM160 -160H560Q593 -160 616.5 -183.5Q640 -207 640 -240V-720Q640 -753 616.5 -776.5Q593 -800 560 -800H160Q127 -800 103.5 -776.5Q80 -753 80 -720V-240Q80 -207 103.5 -183.5Q127 -160 160 -160ZM780 -160H820Q845 -160 862.5 -177.5Q880 -195 880 -220V-260Q880 -285 862.5 -302.5Q845 -320 820 -320H780Q755 -320 737.5 -302.5Q720 -285 720 -260V-220Q720 -195 737.5 -177.5Q755 -160 780 -160Z"),
("visibility", "M480 -320Q555 -320 607.5 -372.5Q660 -425 660 -500Q660 -575 607.5 -627.5Q555 -680 480 -680Q405 -680 352.5 -627.5Q300 -575 300 -500Q300 -425 352.5 -372.5Q405 -320 480 -320ZM480 -392Q435 -392 403.5 -423.5Q372 -455 372 -500Q372 -545 403.5 -576.5Q435 -608 480 -608Q525 -608 556.5 -576.5Q588 -545 588 -500Q588 -455 556.5 -423.5Q525 -392 480 -392ZM61 -462Q56 -471 53.5 -480.5Q51 -490 51 -500Q51 -510 53.5 -519.5Q56 -529 61 -538Q125 -656 235.5 -728Q346 -800 480 -800Q614 -800 724.5 -728Q835 -656 899 -538Q904 -529 906.5 -519.5Q909 -510 909 -500Q909 -490 906.5 -480.5Q904 -471 899 -462Q835 -344 724.5 -272Q614 -200 480 -200Q346 -200 235.5 -272Q125 -344 61 -462ZM480 -500Q480 -500 480 -500Q480 -500 480 -500Q480 -500 480 -500Q480 -500 480 -500Q480 -500 480 -500Q480 -500 480 -500Q480 -500 480 -500Q480 -500 480 -500ZM832 -500Q782 -601 687.5 -660.5Q593 -720 480 -720Q367 -720 272.5 -660.5Q178 -601 128 -500Q178 -399 272.5 -339.5Q367 -280 480 -280Q593 -280 687.5 -339.5Q782 -399 832 -500Z"),
("visibility_fill", "M480 -320Q555 -320 607.5 -372.5Q660 -425 660 -500Q660 -575 607.5 -627.5Q555 -680 480 -680Q405 -680 352.5 -627.5Q300 -575 300 -500Q300 -425 352.5 -372.5Q405 -320 480 -320ZM480 -392Q435 -392 403.5 -423.5Q372 -455 372 -500Q372 -545 403.5 -576.5Q435 -608 480 -608Q525 -608 556.5 -576.5Q588 -545 588 -500Q588 -455 556.5 -423.5Q525 -392 480 -392ZM61 -462Q56 -471 53.5 -480.5Q51 -490 51 -500Q51 -510 53.5 -519.5Q56 -529 61 -538Q125 -656 235.5 -728Q346 -800 480 -800Q614 -800 724.5 -728Q835 -656 899 -538Q904 -529 906.5 -519.5Q909 -510 909 -500Q909 -490 906.5 -480.5Q904 -471 899 -462Q835 -344 724.5 -272Q614 -200 480 -200Q346 -200 235.5 -272Q125 -344 61 -462ZM128 -500Q178 -601 272.5 -660.5Q367 -720 480 -720Q593 -720 687.5 -660.5Q782 -601 832 -500Q782 -399 687.5 -339.5Q593 -280 480 -280Q367 -280 272.5 -339.5Q178 -399 128 -500ZM832 -500Q782 -601 687.5 -660.5Q593 -720 480 -720Q367 -720 272.5 -660.5Q178 -601 128 -500Q178 -399 272.5 -339.5Q367 -280 480 -280Q593 -280 687.5 -339.5Q782 -399 832 -500Z"),
("warning", "M109 -120Q98 -120 89 -125.5Q80 -131 75 -140Q70 -149 69.5 -159.5Q69 -170 75 -180L445 -820Q451 -830 460.5 -835Q470 -840 480 -840Q490 -840 499.5 -835Q509 -830 515 -820L885 -180Q891 -170 890.5 -159.5Q890 -149 885 -140Q880 -131 871 -125.5Q862 -120 851 -120ZM178 -200H782L480 -720ZM480 -240Q497 -240 508.5 -251.5Q520 -263 520 -280Q520 -297 508.5 -308.5Q497 -320 480 -320Q463 -320 451.5 -308.5Q440 -297 440 -280Q440 -263 451.5 -251.5Q463 -240 480 -240ZM520 -400V-520Q520 -537 508.5 -548.5Q497 -560 480 -560Q463 -560 451.5 -548.5Q440 -537 440 -520V-400Q440 -383 451.5 -371.5Q463 -360 480 -360Q497 -360 508.5 -371.5Q520 -383 520 -400ZM480 -460Z"),
("warning_fill", "M109 -120Q98 -120 89 -125.5Q80 -131 75 -140Q70 -149 69.5 -159.5Q69 -170 75 -180L445 -820Q451 -830 460.5 -835Q470 -840 480 -840Q490 -840 499.5 -835Q509 -830 515 -820L885 -180Q891 -170 890.5 -159.5Q890 -149 885 -140Q880 -131 871 -125.5Q862 -120 851 -120ZM178 -200H782L480 -720ZM480 -240Q497 -240 508.5 -251.5Q520 -263 520 -280Q520 -297 508.5 -308.5Q497 -320 480 -320Q463 -320 451.5 -308.5Q440 -297 440 -280Q440 -263 451.5 -251.5Q463 -240 480 -240ZM520 -400V-520Q520 -537 508.5 -548.5Q497 -560 480 -560Q463 -560 451.5 -548.5Q440 -537 440 -520V-400Q440 -383 451.5 -371.5Q463 -360 480 -360Q497 -360 508.5 -371.5Q520 -383 520 -400ZM178 -200 480 -720 782 -200Z"),
("wrap_text", "M200 -460Q183 -460 171.5 -471.5Q160 -483 160 -500Q160 -517 171.5 -528.5Q183 -540 200 -540H690Q753 -540 796.5 -496.5Q840 -453 840 -390Q840 -327 796.5 -283.5Q753 -240 690 -240H594L616 -218Q628 -206 627.5 -190Q627 -174 616 -162Q604 -150 587.5 -149.5Q571 -149 559 -161L468 -252Q462 -258 459.5 -265Q457 -272 457 -280Q457 -288 459.5 -295Q462 -302 468 -308L559 -399Q571 -411 587.5 -411Q604 -411 616 -399Q627 -387 627.5 -370.5Q628 -354 616 -342L594 -320H690Q719 -320 739.5 -340.5Q760 -361 760 -390Q760 -419 739.5 -439.5Q719 -460 690 -460ZM200 -240Q183 -240 171.5 -251.5Q160 -263 160 -280Q160 -297 171.5 -308.5Q183 -320 200 -320H320Q337 -320 348.5 -308.5Q360 -297 360 -280Q360 -263 348.5 -251.5Q337 -240 320 -240ZM200 -680Q183 -680 171.5 -691.5Q160 -703 160 -720Q160 -737 171.5 -748.5Q183 -760 200 -760H760Q777 -760 788.5 -748.5Q800 -737 800 -720Q800 -703 788.5 -691.5Q777 -680 760 -680Z"),
];

10
src/lib.rs Normal file
View file

@ -0,0 +1,10 @@
pub mod app;
pub mod config;
pub mod git;
pub mod icondata;
pub mod lsp;
pub mod motion;
pub mod syntax;
pub mod text;
pub mod theme;
pub mod ui;

293
src/lsp.rs Normal file
View file

@ -0,0 +1,293 @@
//! A small Language Server Protocol client: diagnostics, completion, hover and go-to-definition.
//! One server runs per language, found on PATH; every message comes back through the app's channel.
use serde_json::{json, Value};
use std::collections::HashMap;
use std::io::{BufRead, BufReader, Read, Write};
use std::path::{Path, PathBuf};
use std::process::{Child, ChildStdin, Command, Stdio};
use std::sync::mpsc::Sender;
#[derive(Clone, Debug, PartialEq)]
pub struct Diag {
pub line: usize,
pub col: usize,
pub end_col: usize,
pub severity: u8,
pub msg: String,
}
#[derive(Clone, Debug)]
pub struct CompletionItem {
pub label: String,
pub insert: String,
pub detail: String,
pub kind: u8,
}
pub enum LspEvent {
Diagnostics(PathBuf, Vec<Diag>),
Completion(Vec<CompletionItem>),
Hover(String),
Definition(PathBuf, usize, usize),
Ready(String),
}
/// The server to run for a Kate language name.
pub fn server_for(lang: &str) -> Option<(&'static str, &'static [&'static str], &'static str)> {
Some(match lang {
"Rust" => ("rust-analyzer", &[], "rust"),
"C" => ("clangd", &[], "c"),
"C++" | "ISO C++" => ("clangd", &[], "cpp"),
"Python" => ("pylsp", &[], "python"),
"Go" => ("gopls", &[], "go"),
"TypeScript" => ("typescript-language-server", &["--stdio"], "typescript"),
"JavaScript" => ("typescript-language-server", &["--stdio"], "javascript"),
"Bash" => ("bash-language-server", &["start"], "shellscript"),
"Lua" => ("lua-language-server", &[], "lua"),
_ => return None,
})
}
fn on_path(bin: &str) -> bool {
std::env::var_os("PATH").is_some_and(|p| std::env::split_paths(&p).any(|d| d.join(bin).is_file()))
}
pub fn uri(p: &Path) -> String {
let mut s = String::from("file://");
for b in p.to_string_lossy().bytes() {
if b.is_ascii_alphanumeric() || b"/-_.~".contains(&b) { s.push(b as char) } else { s.push_str(&format!("%{b:02X}")) }
}
s
}
pub fn path_of(uri: &str) -> Option<PathBuf> {
let raw = uri.strip_prefix("file://")?.as_bytes();
let (mut out, mut i) = (vec![], 0);
while i < raw.len() {
if raw[i] == b'%' && i + 2 < raw.len() {
if let Ok(v) = u8::from_str_radix(&String::from_utf8_lossy(&raw[i + 1..i + 3]), 16) {
out.push(v);
i += 3;
continue;
}
}
out.push(raw[i]);
i += 1;
}
Some(PathBuf::from(String::from_utf8_lossy(&out).into_owned()))
}
#[derive(Clone, Copy, PartialEq)]
enum Pending { Init, Completion, Hover, Definition }
pub struct Client {
pub bin: String,
stdin: ChildStdin,
child: Child,
next: i64,
pending: HashMap<i64, Pending>,
ready: bool,
queue: Vec<Value>,
}
impl Client {
/// Starts a server; replies arrive on `tx` wrapped by `wrap`.
pub fn start(bin: &str, args: &[&str], root: &Path, key: String, tx: Sender<(String, Value)>) -> Option<Client> {
if !on_path(bin) {
return None;
}
let mut child = Command::new(bin).args(args).current_dir(root).stdin(Stdio::piped()).stdout(Stdio::piped()).stderr(Stdio::null()).spawn().ok()?;
let stdin = child.stdin.take()?;
let stdout = child.stdout.take()?;
std::thread::spawn(move || {
let mut r = BufReader::new(stdout);
loop {
let mut len = 0usize;
loop {
let mut l = String::new();
if r.read_line(&mut l).ok().filter(|n| *n > 0).is_none() { return }
let l = l.trim();
if l.is_empty() { break }
if let Some(v) = l.strip_prefix("Content-Length:") { len = v.trim().parse().unwrap_or(0) }
}
let mut buf = vec![0; len];
if r.read_exact(&mut buf).is_err() { return }
if let Ok(v) = serde_json::from_slice::<Value>(&buf) {
if tx.send((key.clone(), v)).is_err() { return }
}
}
});
let mut c = Client { bin: bin.to_string(), stdin, child, next: 1, pending: HashMap::new(), ready: false, queue: vec![] };
c.pending.insert(0, Pending::Init);
c.raw(&json!({"jsonrpc": "2.0", "id": 0, "method": "initialize", "params": {
"processId": std::process::id(),
"rootUri": uri(root),
"capabilities": {"textDocument": {
"publishDiagnostics": {},
"completion": {"completionItem": {"snippetSupport": false}},
"hover": {"contentFormat": ["plaintext", "markdown"]},
"definition": {},
"synchronization": {"didSave": true},
}},
}}));
Some(c)
}
fn raw(&mut self, v: &Value) {
let body = v.to_string();
let _ = write!(self.stdin, "Content-Length: {}\r\n\r\n{}", body.len(), body);
let _ = self.stdin.flush();
}
fn send(&mut self, v: Value) {
if self.ready { self.raw(&v) } else { self.queue.push(v) }
}
pub fn notify(&mut self, method: &str, params: Value) {
self.send(json!({"jsonrpc": "2.0", "method": method, "params": params}));
}
fn request(&mut self, method: &str, params: Value, kind: Pending) {
let id = self.next;
self.next += 1;
self.pending.insert(id, kind);
self.send(json!({"jsonrpc": "2.0", "id": id, "method": method, "params": params}));
}
pub fn did_open(&mut self, path: &Path, lang: &str, version: i64, text: &str) {
self.notify("textDocument/didOpen", json!({"textDocument": {"uri": uri(path), "languageId": lang, "version": version, "text": text}}));
}
pub fn did_change(&mut self, path: &Path, version: i64, text: &str) {
self.notify("textDocument/didChange", json!({"textDocument": {"uri": uri(path), "version": version}, "contentChanges": [{"text": text}]}));
}
pub fn did_save(&mut self, path: &Path) {
self.notify("textDocument/didSave", json!({"textDocument": {"uri": uri(path)}}));
}
fn at(path: &Path, line: usize, col: usize) -> Value {
json!({"textDocument": {"uri": uri(path)}, "position": {"line": line, "character": col}})
}
pub fn completion(&mut self, path: &Path, line: usize, col: usize) {
self.request("textDocument/completion", Self::at(path, line, col), Pending::Completion);
}
pub fn hover(&mut self, path: &Path, line: usize, col: usize) {
self.request("textDocument/hover", Self::at(path, line, col), Pending::Hover);
}
pub fn definition(&mut self, path: &Path, line: usize, col: usize) {
self.request("textDocument/definition", Self::at(path, line, col), Pending::Definition);
}
/// Turns a raw server message into an event, answering anything that needs an answer.
pub fn handle(&mut self, v: Value) -> Option<LspEvent> {
if let Some(id) = v.get("id").and_then(Value::as_i64) {
if v.get("method").is_some() {
// a request from the server: nothing here needs more than an empty reply
self.raw(&json!({"jsonrpc": "2.0", "id": id, "result": Value::Null}));
return None;
}
let kind = self.pending.remove(&id)?;
let res = v.get("result").cloned().unwrap_or(Value::Null);
return match kind {
Pending::Init => {
self.raw(&json!({"jsonrpc": "2.0", "method": "initialized", "params": {}}));
self.ready = true;
for m in std::mem::take(&mut self.queue) { self.raw(&m) }
Some(LspEvent::Ready(self.bin.clone()))
}
Pending::Completion => Some(LspEvent::Completion(parse_completion(&res))),
Pending::Hover => parse_hover(&res).map(LspEvent::Hover),
Pending::Definition => parse_definition(&res),
};
}
if v.get("method").and_then(Value::as_str) == Some("textDocument/publishDiagnostics") {
let p = v.get("params")?;
let path = path_of(p.get("uri")?.as_str()?)?;
return Some(LspEvent::Diagnostics(path, parse_diags(p)));
}
None
}
}
impl Drop for Client {
fn drop(&mut self) {
let _ = self.child.kill();
let _ = self.child.wait();
}
}
pub fn parse_diags(p: &Value) -> Vec<Diag> {
let Some(list) = p.get("diagnostics").and_then(Value::as_array) else { return vec![] };
list.iter().filter_map(|d| {
let s = d.get("range")?.get("start")?;
let e = d.get("range")?.get("end")?;
Some(Diag {
line: s.get("line")?.as_u64()? as usize,
col: s.get("character")?.as_u64()? as usize,
end_col: e.get("character")?.as_u64()? as usize,
severity: d.get("severity").and_then(Value::as_u64).unwrap_or(1) as u8,
msg: d.get("message")?.as_str()?.to_string(),
})
}).collect()
}
pub fn parse_completion(res: &Value) -> Vec<CompletionItem> {
let items = res.get("items").or(Some(res)).and_then(Value::as_array);
items.map(|v| v.iter().take(200).filter_map(|i| {
let label = i.get("label")?.as_str()?.trim().to_string();
let edit = i.get("textEdit").and_then(|t| t.get("newText")).and_then(Value::as_str);
let insert = edit.or(i.get("insertText").and_then(Value::as_str)).unwrap_or(&label).to_string();
let detail = i.get("detail").and_then(Value::as_str).unwrap_or("").to_string();
Some(CompletionItem { label, insert, detail, kind: i.get("kind").and_then(Value::as_u64).unwrap_or(1) as u8 })
}).collect()).unwrap_or_default()
}
pub fn parse_hover(res: &Value) -> Option<String> {
let c = res.get("contents")?;
let t = match c {
Value::String(s) => s.clone(),
Value::Array(a) => a.iter().filter_map(|x| x.as_str().map(str::to_string).or_else(|| x.get("value")?.as_str().map(str::to_string))).collect::<Vec<_>>().join("\n"),
v => v.get("value")?.as_str()?.to_string(),
};
let t = t.trim();
(!t.is_empty()).then(|| t.to_string())
}
pub fn parse_definition(res: &Value) -> Option<LspEvent> {
let first = if res.is_array() { res.get(0)? } else { res };
let uri = first.get("uri").or(first.get("targetUri"))?.as_str()?;
let r = first.get("range").or(first.get("targetSelectionRange"))?;
let s = r.get("start")?;
Some(LspEvent::Definition(path_of(uri)?, s.get("line")?.as_u64()? as usize, s.get("character")?.as_u64()? as usize))
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn uris_round_trip_with_spaces_and_unicode() {
let p = Path::new("/home/a b/caffè.rs");
assert_eq!(path_of(&uri(p)).unwrap(), p);
}
#[test]
fn parses_server_replies() {
let c = json!({"isIncomplete": false, "items": [{"label": " push", "textEdit": {"newText": "push"}, "detail": "fn", "kind": 2}]});
let v = parse_completion(&c);
assert_eq!((v[0].label.as_str(), v[0].insert.as_str()), ("push", "push"));
assert_eq!(parse_hover(&json!({"contents": {"kind": "markdown", "value": "fn a()"}})).unwrap(), "fn a()");
let d = parse_diags(&json!({"diagnostics": [{"range": {"start": {"line": 3, "character": 1}, "end": {"line": 3, "character": 4}}, "severity": 2, "message": "m"}]}));
assert_eq!(d[0].line, 3);
assert_eq!(d[0].severity, 2);
match parse_definition(&json!([{"uri": "file:///a.rs", "range": {"start": {"line": 1, "character": 2}, "end": {"line": 1, "character": 3}}}])) {
Some(LspEvent::Definition(p, 1, 2)) => assert_eq!(p, PathBuf::from("/a.rs")),
_ => panic!(),
}
}
}

34
src/main.rs Normal file
View file

@ -0,0 +1,34 @@
use damson::{app::App, config};
use eframe::egui;
fn app_icon() -> egui::IconData {
let size = 256u32;
let mut pm = resvg::tiny_skia::Pixmap::new(size, size).unwrap();
if let Ok(tree) = resvg::usvg::Tree::from_str(include_str!("../assets/damson.svg"), &resvg::usvg::Options::default()) {
let s = size as f32 / tree.size().width();
resvg::render(&tree, resvg::tiny_skia::Transform::from_scale(s, s), &mut pm.as_mut());
}
let mut rgba = pm.take();
for px in rgba.chunks_exact_mut(4) {
let a = px[3] as u32;
if a > 0 && a < 255 {
for c in &mut px[..3] { *c = ((*c as u32 * 255 + a / 2) / a).min(255) as u8 }
}
}
egui::IconData { rgba, width: size, height: size }
}
fn main() -> eframe::Result {
let files: Vec<String> = std::env::args().skip(1).filter(|a| !a.starts_with("--")).collect();
let [w, h] = config::Settings::load().win;
let viewport = egui::ViewportBuilder::default()
.with_title(config::APP_NAME)
.with_app_id("damson")
.with_inner_size([w.max(800.0), h.max(520.0)])
.with_min_inner_size([760.0, 480.0])
.with_decorations(false)
.with_transparent(true)
.with_icon(std::sync::Arc::new(app_icon()));
let options = eframe::NativeOptions { viewport, multisampling: 4, ..Default::default() };
eframe::run_native(config::APP_NAME, options, Box::new(move |cc| Ok(Box::new(App::new(cc, files)))))
}

200
src/motion.rs Normal file
View file

@ -0,0 +1,200 @@
//! Spring physics for all motion. `spring(id, target, preset)` is the immediate-mode form: call it
//! each frame with where the value should be and it gives back where it is now.
//! The presets are Material 3 Expressive's spatial tokens.
use std::cell::{Cell, RefCell};
use std::collections::HashMap;
#[derive(Clone, Copy, Debug)]
pub struct Preset {
pub stiffness: f32,
pub damping: f32,
}
pub const FAST: Preset = Preset { stiffness: 1400.0, damping: 0.62 };
pub const DEFAULT: Preset = Preset { stiffness: 700.0, damping: 0.68 };
pub const SLOW: Preset = Preset { stiffness: 300.0, damping: 0.74 };
/// For colours, opacity and anything else that shouldn't overshoot.
pub const EFFECT: Preset = Preset { stiffness: 900.0, damping: 1.0 };
thread_local! {
static BUSY: Cell<bool> = const { Cell::new(false) };
static LEVEL: Cell<u8> = const { Cell::new(2) };
static DT: Cell<f32> = const { Cell::new(1.0 / 60.0) };
static MAP: RefCell<HashMap<String, Slot>> = RefCell::new(HashMap::new());
}
struct Slot {
s: Spring,
frame: u64,
}
thread_local! {
static FRAME: Cell<u64> = const { Cell::new(0) };
}
/// Starts a frame; `level` is the Settings motion choice.
pub fn begin_frame(dt: f32, level: u8) {
DT.with(|d| d.set(dt.clamp(0.001, 0.05)));
LEVEL.with(|l| l.set(level));
BUSY.with(|b| b.set(false));
FRAME.with(|f| f.set(f.get() + 1));
}
/// Did anything move this frame? If so the next frame must be drawn.
pub fn busy() -> bool {
BUSY.with(|b| b.get())
}
pub fn keep_alive() {
BUSY.with(|b| b.set(true));
}
pub fn dt() -> f32 {
DT.with(|d| d.get())
}
fn adjusted(p: Preset) -> Preset {
match LEVEL.with(|l| l.get()) {
1 => Preset { stiffness: p.stiffness, damping: p.damping.max(1.0) },
3 => Preset { stiffness: p.stiffness * 0.8, damping: (p.damping * 0.62).min(1.0) },
_ => p,
}
}
#[derive(Clone, Copy, Debug)]
pub struct Spring {
pub x: f32,
pub v: f32,
pub target: f32,
}
impl Spring {
pub fn new(x: f32) -> Spring {
Spring { x, v: 0.0, target: x }
}
pub fn settled(&self) -> bool {
self.x == self.target
}
pub fn snap(&mut self, x: f32) {
*self = Spring::new(x);
}
/// Advances one frame, returning the new value.
pub fn step(&mut self, p: Preset) -> f32 {
if self.settled() {
return self.x;
}
if LEVEL.with(|l| l.get()) == 0 {
self.snap(self.target);
return self.x;
}
let p = adjusted(p);
let w = p.stiffness.sqrt();
let c = 2.0 * p.damping * w;
let range = (self.target - self.x).abs().max(1.0);
let mut left = dt();
while left > 0.0 {
let h = left.min(0.002);
let a = -p.stiffness * (self.x - self.target) - c * self.v;
self.v += a * h;
self.x += self.v * h;
left -= h;
}
if (self.x - self.target).abs() < 0.002 * range.min(50.0) && self.v.abs() < 0.05 * range.min(50.0) {
self.snap(self.target);
} else {
keep_alive();
}
self.x
}
}
/// The value of the spring called `id`, heading for `target`.
pub fn spring(id: impl AsRef<str>, target: f32, p: Preset) -> f32 {
let frame = FRAME.with(|f| f.get());
MAP.with(|m| {
let mut m = m.borrow_mut();
if let Some(slot) = m.get_mut(id.as_ref()) {
slot.s.target = target;
if slot.frame != frame {
slot.frame = frame;
slot.s.step(p);
}
slot.s.x
} else {
m.insert(id.as_ref().to_string(), Slot { s: Spring::new(target), frame });
target
}
})
}
/// Like `spring`, but a new id starts at `from` so the value animates in.
pub fn spring_from(id: impl AsRef<str>, from: f32, target: f32, p: Preset) -> f32 {
let frame = FRAME.with(|f| f.get());
MAP.with(|m| {
m.borrow_mut().entry(id.as_ref().to_string()).or_insert_with(|| Slot { s: Spring::new(from), frame: frame.saturating_sub(1) });
});
spring(id, target, p)
}
/// Gives a spring a shove, for hits like a keypress or save.
pub fn kick(id: impl AsRef<str>, velocity: f32) {
MAP.with(|m| {
if let Some(s) = m.borrow_mut().get_mut(id.as_ref()) {
s.s.v += velocity;
s.s.x += 0.0001;
}
});
}
/// Forgets a spring, so the next use starts fresh.
pub fn forget(id: impl AsRef<str>) {
MAP.with(|m| { m.borrow_mut().remove(id.as_ref()); });
}
/// Eased 0..1 for staggered lists: `t` seconds since the start, `delay` for this item.
pub fn stagger(t: f32, delay: f32, dur: f32) -> f32 {
if LEVEL.with(|l| l.get()) == 0 {
return 1.0;
}
let x = ((t - delay) / dur).clamp(0.0, 1.0);
let c = 1.70158;
1.0 + (c + 1.0) * (x - 1.0).powi(3) + c * (x - 1.0).powi(2)
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn spring_overshoots_then_settles() {
begin_frame(1.0 / 60.0, 2);
let mut s = Spring::new(0.0);
s.target = 100.0;
let mut peak: f32 = 0.0;
for _ in 0..240 {
begin_frame(1.0 / 60.0, 2);
peak = peak.max(s.step(DEFAULT));
}
assert!(peak > 100.5, "bouncy spring should overshoot, peak {peak}");
assert!(s.settled());
assert_eq!(s.x, 100.0);
}
#[test]
fn calm_never_overshoots_and_off_snaps() {
let mut s = Spring::new(0.0);
s.target = 100.0;
for _ in 0..240 {
begin_frame(1.0 / 60.0, 1);
assert!(s.step(DEFAULT) <= 100.0);
}
let mut s = Spring::new(0.0);
s.target = 5.0;
begin_frame(1.0 / 60.0, 0);
assert_eq!(s.step(DEFAULT), 5.0);
}
}

237
src/syntax/def.rs Normal file
View file

@ -0,0 +1,237 @@
//! Compiled form of a Kate syntax definition. All definitions live in one `Compiled` arena, because
//! rules include contexts from other definitions (`##Doxygen`, `##Comments`, …).
use fancy_regex::Regex;
use std::collections::{HashMap, HashSet};
use std::sync::Arc;
pub type StyleId = u16;
pub type CtxId = u32;
#[derive(Clone, Copy, PartialEq, Eq, Debug, Hash)]
pub enum DefStyle {
Normal, Keyword, Function, Variable, ControlFlow, Operator, BuiltIn, Extension, Preprocessor,
Attribute, Char, SpecialChar, String, VerbatimString, SpecialString, Import, DataType, DecVal,
BaseN, Float, Constant, Comment, Documentation, Annotation, CommentVar, RegionMarker,
Information, Warning, Alert, Others, Error,
}
impl DefStyle {
pub fn parse(s: &str) -> DefStyle {
use DefStyle::*;
match s.trim_start_matches("ds").to_ascii_lowercase().as_str() {
"keyword" => Keyword, "function" => Function, "variable" => Variable,
"controlflow" => ControlFlow, "operator" => Operator, "builtin" => BuiltIn,
"extension" => Extension, "preprocessor" => Preprocessor, "attribute" => Attribute,
"char" => Char, "specialchar" => SpecialChar, "string" => String,
"verbatimstring" => VerbatimString, "specialstring" => SpecialString, "import" => Import,
"datatype" => DataType, "decval" => DecVal, "basen" => BaseN, "float" => Float,
"constant" => Constant, "comment" => Comment, "documentation" => Documentation,
"annotation" => Annotation, "commentvar" => CommentVar, "regionmarker" => RegionMarker,
"information" => Information, "warning" => Warning, "alert" => Alert, "others" => Others,
"error" => Error, _ => Normal,
}
}
/// The name Kate's `.theme` files use for this style.
pub fn theme_key(self) -> &'static str {
use DefStyle::*;
match self {
Normal => "Normal", Keyword => "Keyword", Function => "Function", Variable => "Variable",
ControlFlow => "ControlFlow", Operator => "Operator", BuiltIn => "BuiltIn",
Extension => "Extension", Preprocessor => "Preprocessor", Attribute => "Attribute",
Char => "Char", SpecialChar => "SpecialChar", String => "String",
VerbatimString => "VerbatimString", SpecialString => "SpecialString", Import => "Import",
DataType => "DataType", DecVal => "DecVal", BaseN => "BaseN", Float => "Float",
Constant => "Constant", Comment => "Comment", Documentation => "Documentation",
Annotation => "Annotation", CommentVar => "CommentVar", RegionMarker => "RegionMarker",
Information => "Information", Warning => "Warning", Alert => "Alert", Others => "Others",
Error => "Error",
}
}
pub const ALL: [DefStyle; 31] = {
use DefStyle::*;
[Normal, Keyword, Function, Variable, ControlFlow, Operator, BuiltIn, Extension, Preprocessor,
Attribute, Char, SpecialChar, String, VerbatimString, SpecialString, Import, DataType, DecVal,
BaseN, Float, Constant, Comment, Documentation, Annotation, CommentVar, RegionMarker,
Information, Warning, Alert, Others, Error]
};
}
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct StyleInfo {
pub base: DefStyle,
pub bold: Option<bool>,
pub italic: Option<bool>,
pub underline: bool,
}
/// What a rule (or a line end) does to the context stack.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub struct Switch {
pub pops: u8,
pub push: Option<CtxId>,
}
impl Switch {
pub fn is_stay(&self) -> bool {
self.pops == 0 && self.push.is_none()
}
}
pub enum Matcher {
DetectChar { c: char, dyn_idx: Option<usize> },
Detect2Chars { a: char, b: char },
AnyChar(Vec<char>),
StringDetect { s: String, ci: bool, dynamic: bool },
WordDetect { s: String, ci: bool },
Regex { re: Option<Arc<Regex>>, source: String, ci: bool, minimal: bool, dynamic: bool },
Keyword { list: Arc<KeywordList>, ci: bool },
Int, Float, HlCOct, HlCHex, HlCStringChar, HlCChar,
RangeDetect { a: char, b: char },
LineContinue { c: char },
DetectSpaces,
DetectIdentifier,
}
#[derive(Default)]
pub struct KeywordList {
pub cased: HashSet<String>,
pub folded: HashSet<String>,
}
pub struct Rule {
pub matcher: Matcher,
pub style: Option<StyleId>,
pub switch: Switch,
pub look_ahead: bool,
pub first_non_space: bool,
pub column: Option<usize>,
pub begin_region: Option<u32>,
pub end_region: Option<u32>,
/// Bit set of the ASCII word delimiters of the owning definition.
pub delims: Arc<Delims>,
}
pub struct Delims(pub [bool; 128]);
impl Delims {
pub fn new(weak: &str, extra: &str) -> Delims {
let mut d = [false; 128];
for c in " \t.():!+,-<=>%&*/;?[]^{|}~\\".chars().chain(extra.chars()) {
if (c as usize) < 128 {
d[c as usize] = true;
}
}
for c in weak.chars() {
if (c as usize) < 128 {
d[c as usize] = false;
}
}
Delims(d)
}
#[inline]
pub fn is(&self, c: u8) -> bool {
c < 128 && self.0[c as usize]
}
}
pub struct Context {
pub style: StyleId,
pub rules: Vec<Rule>,
pub line_end: Switch,
pub line_empty: Option<Switch>,
pub fallthrough: Option<Switch>,
pub dynamic: bool,
}
/// Comment syntax and folding mode from a definition's `<general>` block.
#[derive(Clone, Default, Debug)]
pub struct DefMeta {
pub line_comment: Option<String>,
pub block_comment: Option<(String, String)>,
pub indent_fold: bool,
}
#[derive(Default)]
pub struct Compiled {
pub contexts: Vec<Context>,
pub styles: Vec<StyleInfo>,
pub regions: HashMap<String, u32>,
pub bad_regexes: Vec<(String, String)>,
}
/// Rewrites the PCRE syntax the regex crates don't take; returns the pattern to compile.
pub fn translate_regex(src: &str, ci: bool, minimal: bool) -> String {
let mut out = String::with_capacity(src.len() + 8);
if ci || minimal {
out.push_str("(?");
if ci { out.push('i') }
if minimal { out.push('U') }
out.push(')');
}
let cs: Vec<char> = src.chars().collect();
let (mut i, mut in_class) = (0, false);
while i < cs.len() {
let c = cs[i];
if c == '\\' && i + 1 < cs.len() {
match cs[i + 1] {
'h' => out.push_str(if in_class { " \\t" } else { "[ \\t]" }),
'H' if !in_class => out.push_str("[^ \\t]"),
// a literal character the regex crate refuses to see escaped
'<' | '>' | '"' | '\'' | '`' | '=' | '!' | '%' | ';' | ':' | ',' | '@' | '/' | '_' => out.push(cs[i + 1]),
n => { out.push('\\'); out.push(n) }
}
i += 2;
continue;
}
if in_class {
if c == '[' && cs.get(i + 1) == Some(&':') {
out.push('[');
} else if c == '[' {
out.push_str("\\[");
} else {
if c == ']' { in_class = false }
out.push(c);
}
if c == '[' && cs.get(i + 1) == Some(&':') {
// copy a POSIX class whole so its closing bracket doesn't end the set
i += 1;
while i < cs.len() {
out.push(cs[i]);
if cs[i] == ']' { break }
i += 1;
}
}
i += 1;
continue;
}
match c {
'[' => {
in_class = true;
out.push('[');
if cs.get(i + 1) == Some(&'^') { out.push('^'); i += 1 }
if cs.get(i + 1) == Some(&']') { out.push_str("\\]"); i += 1 }
}
'(' if cs.get(i + 1) == Some(&'?') && cs.get(i + 2) == Some(&'#') => {
while i < cs.len() && cs[i] != ')' { i += 1 }
}
'(' if cs.get(i + 1) == Some(&'?') && cs.get(i + 2) == Some(&'|') => {
out.push_str("(?:");
i += 2;
}
_ => out.push(c),
}
i += 1;
}
out
}
pub fn compile_regex(src: &str, ci: bool, minimal: bool) -> Result<Regex, String> {
fancy_regex::RegexBuilder::new(&translate_regex(src, ci, minimal))
.backtrack_limit(20_000)
.build()
.map_err(|e| e.to_string())
}

440
src/syntax/engine.rs Normal file
View file

@ -0,0 +1,440 @@
//! Walks one line through the compiled contexts, following the rules KSyntaxHighlighting uses.
use super::def::*;
use std::collections::HashMap;
use std::sync::Arc;
#[derive(Clone, PartialEq, Eq, Debug)]
pub struct Frame {
pub ctx: CtxId,
pub captures: Option<Arc<Vec<String>>>,
}
/// The context stack at the end of a line. Equal states mean later lines need no re-highlighting.
#[derive(Clone, PartialEq, Eq, Debug, Default)]
pub struct State {
pub stack: Vec<Frame>,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct Span {
pub start: u32,
pub end: u32,
pub style: StyleId,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum FoldEvent {
Begin(u32),
End(u32),
}
#[derive(Clone, Debug, Default, PartialEq)]
pub struct LineResult {
pub spans: Vec<Span>,
pub folds: Vec<(u32, FoldEvent)>,
}
fn word_at(line: &[u8], at: usize, d: &Delims) -> bool {
at == 0 || d.is(line[at - 1])
}
fn word_end(line: &[u8], at: usize, d: &Delims) -> bool {
at >= line.len() || d.is(line[at])
}
fn char_at(text: &str, at: usize) -> Option<char> {
text.get(at..)?.chars().next()
}
fn starts_with_ci(hay: &str, needle: &str) -> Option<usize> {
let (mut h, mut n) = (hay.chars(), needle.chars());
let mut used = 0;
loop {
let Some(nc) = n.next() else { return Some(used) };
let hc = h.next()?;
if !hc.to_lowercase().eq(nc.to_lowercase()) {
return None;
}
used += hc.len_utf8();
}
}
fn is_ident_start(c: u8) -> bool {
c.is_ascii_alphabetic() || c == b'_' || c >= 128
}
fn is_ident(c: u8) -> bool {
c.is_ascii_alphanumeric() || c == b'_' || c >= 128
}
fn c_escape(l: &[u8], at: usize) -> Option<usize> {
if l.get(at) != Some(&b'\\') {
return None;
}
let n = *l.get(at + 1)?;
Some(match n {
b'a' | b'b' | b'e' | b'f' | b'n' | b'r' | b't' | b'v' | b'\'' | b'"' | b'\\' | b'?' => at + 2,
b'x' => {
let mut i = at + 2;
while i < l.len() && i < at + 4 && l[i].is_ascii_hexdigit() { i += 1 }
if i == at + 2 { return None }
i
}
b'0'..=b'7' => {
let mut i = at + 1;
while i < l.len() && i < at + 4 && (b'0'..=b'7').contains(&l[i]) { i += 1 }
i
}
_ => return None,
})
}
fn match_float(l: &[u8], at: usize, d: &Delims) -> Option<usize> {
if !word_at(l, at, d) {
return None;
}
let mut i = at;
let digits_a = { let s = i; while i < l.len() && l[i].is_ascii_digit() { i += 1 } i - s };
let mut dot = false;
let mut digits_b = 0;
if l.get(i) == Some(&b'.') {
dot = true;
i += 1;
let s = i;
while i < l.len() && l[i].is_ascii_digit() { i += 1 }
digits_b = i - s;
}
if digits_a + digits_b == 0 {
return None;
}
let mut exp = false;
if matches!(l.get(i), Some(b'e' | b'E')) {
let mut j = i + 1;
if matches!(l.get(j), Some(b'+' | b'-')) { j += 1 }
let s = j;
while j < l.len() && l[j].is_ascii_digit() { j += 1 }
if j > s {
exp = true;
i = j;
}
}
(dot || exp).then_some(i)
}
/// Per-line memo of where each regex rule next matches, so a miss is only searched for once.
#[derive(Default)]
struct RegexMemo {
next: HashMap<*const Rule, Option<(usize, usize, Arc<Vec<String>>)>>,
}
pub struct Highlighter<'a> {
pub c: &'a Compiled,
dyn_cache: HashMap<String, Option<Arc<fancy_regex::Regex>>>,
}
impl<'a> Highlighter<'a> {
pub fn new(c: &'a Compiled) -> Self {
Highlighter { c, dyn_cache: HashMap::new() }
}
fn apply(&self, st: &mut State, sw: Switch, caps: Option<Arc<Vec<String>>>) {
for _ in 0..sw.pops {
if st.stack.len() > 1 {
st.stack.pop();
}
}
if let Some(p) = sw.push {
let keep = self.c.contexts[p as usize].dynamic;
st.stack.push(Frame { ctx: p, captures: if keep { caps } else { None } });
}
}
pub fn initial(root: CtxId) -> State {
State { stack: vec![Frame { ctx: root, captures: None }] }
}
fn try_rule(&mut self, r: &Rule, text: &str, at: usize, first: usize, caps: &Option<Arc<Vec<String>>>, memo: &mut RegexMemo) -> Option<(usize, Option<Arc<Vec<String>>>)> {
if r.first_non_space && at != first {
return None;
}
if let Some(col) = r.column {
if col != at {
return None;
}
}
let l = text.as_bytes();
let d = &*r.delims;
let end = match &r.matcher {
Matcher::DetectChar { c, dyn_idx } => {
let want = match dyn_idx {
Some(i) => caps.as_ref().and_then(|v| v.get(*i)).and_then(|s| s.chars().next())?,
None => *c,
};
let h = char_at(text, at)?;
(h == want).then(|| at + h.len_utf8())?
}
Matcher::Detect2Chars { a, b } => {
let mut it = text[at..].chars();
let (x, y) = (it.next()?, it.next()?);
(x == *a && y == *b).then(|| at + x.len_utf8() + y.len_utf8())?
}
Matcher::AnyChar(set) => {
let h = char_at(text, at)?;
set.contains(&h).then(|| at + h.len_utf8())?
}
Matcher::StringDetect { s, ci, dynamic } => {
let owned;
let needle: &str = if *dynamic {
owned = substitute(s, caps, false);
&owned
} else {
s
};
if needle.is_empty() {
return None;
}
if *ci {
at + starts_with_ci(&text[at..], needle)?
} else {
text[at..].starts_with(needle).then(|| at + needle.len())?
}
}
Matcher::WordDetect { s, ci } => {
if !word_at(l, at, d) {
return None;
}
let e = if *ci { at + starts_with_ci(&text[at..], s)? } else { text[at..].starts_with(s.as_str()).then(|| at + s.len())? };
if !word_end(l, e, d) {
return None;
}
e
}
Matcher::Keyword { list, ci } => {
if !word_at(l, at, d) {
return None;
}
let mut e = at;
while e < l.len() && !d.is(l[e]) { e += 1 }
if e == at {
return None;
}
let w = &text[at..e];
let hit = if *ci { list.folded.contains(&w.to_lowercase()) } else { list.cased.contains(w) };
if !hit {
return None;
}
e
}
Matcher::Int => {
if !word_at(l, at, d) {
return None;
}
let mut e = at;
while e < l.len() && l[e].is_ascii_digit() { e += 1 }
if e == at {
return None;
}
e
}
Matcher::Float => match_float(l, at, d)?,
Matcher::HlCOct => {
if !word_at(l, at, d) || l.get(at) != Some(&b'0') {
return None;
}
let mut e = at + 1;
while e < l.len() && (b'0'..=b'7').contains(&l[e]) { e += 1 }
if e == at + 1 {
return None;
}
e
}
Matcher::HlCHex => {
if !word_at(l, at, d) || l.get(at) != Some(&b'0') || !matches!(l.get(at + 1), Some(b'x' | b'X')) {
return None;
}
let mut e = at + 2;
while e < l.len() && l[e].is_ascii_hexdigit() { e += 1 }
if e == at + 2 {
return None;
}
e
}
Matcher::HlCStringChar => c_escape(l, at)?,
Matcher::HlCChar => {
if l.get(at) != Some(&b'\'') {
return None;
}
let inner = if l.get(at + 1) == Some(&b'\\') { c_escape(l, at + 1)? } else { at + 1 + char_at(text, at + 1).filter(|c| *c != '\'')?.len_utf8() };
if l.get(inner) != Some(&b'\'') {
return None;
}
inner + 1
}
Matcher::RangeDetect { a, b } => {
if char_at(text, at)? != *a {
return None;
}
let start = at + a.len_utf8();
start + text[start..].find(*b)? + b.len_utf8()
}
Matcher::LineContinue { c } => {
let h = char_at(text, at)?;
(h == *c && at + h.len_utf8() == text.len()).then_some(text.len())?
}
Matcher::DetectSpaces => {
let mut e = at;
while e < l.len() && (l[e] == b' ' || l[e] == b'\t') { e += 1 }
if e == at {
return None;
}
e
}
Matcher::DetectIdentifier => {
if !is_ident_start(*l.get(at)?) {
return None;
}
let mut e = at + 1;
while e < l.len() && is_ident(l[e]) { e += 1 }
e
}
Matcher::Regex { re, source, ci, minimal, dynamic } => {
let re: Arc<fancy_regex::Regex> = if *dynamic {
let pat = substitute(source, caps, true);
self.dyn_cache
.entry(format!("{}{}{pat}", *ci as u8, *minimal as u8))
.or_insert_with(|| compile_regex(&pat, *ci, *minimal).ok().map(Arc::new))
.clone()?
} else {
re.clone()?
};
let key = r as *const Rule;
if let Some(entry) = memo.next.get(&key) {
match entry {
None => return None,
Some((s, e, c)) if *s >= at => {
return (*s == at && *e > at).then(|| (*e, Some(c.clone())));
}
_ => {}
}
}
let found = re.captures_from_pos(text, at).ok().flatten();
let Some(m) = found else {
memo.next.insert(key, None);
return None;
};
let whole = m.get(0)?;
let v: Vec<String> = (0..m.len()).map(|i| m.get(i).map(|x| x.as_str().to_string()).unwrap_or_default()).collect();
let v = Arc::new(v);
memo.next.insert(key, Some((whole.start(), whole.end(), v.clone())));
if whole.start() != at || whole.end() == at {
return None;
}
return Some((whole.end(), Some(v)));
}
};
Some((end, None))
}
/// Highlights `text` (no line break), moving `st` to the state at the end of the line.
pub fn line(&mut self, text: &str, st: &mut State) -> LineResult {
let mut out = LineResult::default();
let c = self.c;
if st.stack.is_empty() {
return out;
}
let first = text.len() - text.trim_start_matches([' ', '\t']).len();
let mut memo = RegexMemo::default();
let mut at = 0usize;
let mut continued = false;
// lookahead and fallthrough switches consume nothing; this bounds a definition that loops
let mut idle = 0;
if text.is_empty() {
let mut guard = 0;
loop {
let top = st.stack.last().unwrap().ctx as usize;
let Some(sw) = c.contexts[top].line_empty.or(Some(c.contexts[top].line_end)) else { break };
if sw.is_stay() || guard > 32 { break }
self.apply(st, sw, None);
guard += 1;
if c.contexts[top].line_empty.is_some() { break }
}
return out;
}
'outer: while at < text.len() {
let top = st.stack.last().unwrap().clone();
let ctx = &c.contexts[top.ctx as usize];
for r in &ctx.rules {
let Some((end, caps)) = self.try_rule(r, text, at, first, &top.captures, &mut memo) else { continue };
if let Some(id) = r.end_region { out.folds.push((at as u32, FoldEvent::End(id))) }
if let Some(id) = r.begin_region { out.folds.push((at as u32, FoldEvent::Begin(id))) }
if r.look_ahead {
if r.switch.is_stay() { continue }
self.apply(st, r.switch, caps);
idle += 1;
if idle > 64 { break }
continue 'outer;
}
self.apply(st, r.switch, caps);
let style = r.style.unwrap_or_else(|| c.contexts[st.stack.last().unwrap().ctx as usize].style);
push(&mut out.spans, at, end, style);
continued = matches!(r.matcher, Matcher::LineContinue { .. });
at = end;
idle = 0;
continue 'outer;
}
if let Some(sw) = ctx.fallthrough {
if idle <= 64 {
self.apply(st, sw, None);
idle += 1;
continue;
}
}
let w = char_at(text, at).map_or(1, |x| x.len_utf8());
push(&mut out.spans, at, at + w, ctx.style);
at += w;
continued = false;
idle = 0;
}
if !continued {
let mut guard = 0;
loop {
let sw = c.contexts[st.stack.last().unwrap().ctx as usize].line_end;
if sw.is_stay() || guard > 32 { break }
self.apply(st, sw, None);
guard += 1;
}
}
out
}
}
fn push(v: &mut Vec<Span>, a: usize, b: usize, style: StyleId) {
if let Some(l) = v.last_mut() {
if l.style == style && l.end as usize == a {
l.end = b as u32;
return;
}
}
v.push(Span { start: a as u32, end: b as u32, style });
}
fn substitute(s: &str, caps: &Option<Arc<Vec<String>>>, for_regex: bool) -> String {
let mut out = String::with_capacity(s.len());
let cs: Vec<char> = s.chars().collect();
let mut i = 0;
while i < cs.len() {
if cs[i] == '%' && cs.get(i + 1).is_some_and(|c| c.is_ascii_digit()) {
let n = cs[i + 1].to_digit(10).unwrap() as usize;
let v = caps.as_ref().and_then(|c| c.get(n)).map(String::as_str).unwrap_or("");
if for_regex { out.push_str(&fancy_regex::escape(v)) } else { out.push_str(v) }
i += 2;
} else {
out.push(cs[i]);
i += 1;
}
}
out
}

12
src/syntax/mod.rs Normal file
View file

@ -0,0 +1,12 @@
//! Runs Kate's own syntax definitions (the KSyntaxHighlighting XML format).
//!
//! `def` reads the XML into compiled contexts and rules, `engine` walks a line through them, and
//! `registry` finds definitions on disk and picks one for a file.
pub mod def;
pub mod engine;
pub mod registry;
pub use def::{DefStyle, StyleId};
pub use engine::{FoldEvent, LineResult, Span, State};
pub use registry::{Language, Registry};

482
src/syntax/registry.rs Normal file
View file

@ -0,0 +1,482 @@
//! Finds syntax definitions, chooses one for a file, and compiles them on demand.
use super::def::*;
use super::engine::{Highlighter, State};
use std::collections::{HashMap, HashSet};
use std::io::Read;
use std::path::{Path, PathBuf};
use std::sync::Arc;
#[derive(Clone, Debug)]
pub struct Language {
pub name: String,
pub alternatives: Vec<String>,
pub section: String,
pub extensions: Vec<String>,
pub mimetypes: Vec<String>,
pub priority: i32,
pub hidden: bool,
pub path: PathBuf,
}
struct Loaded {
root: CtxId,
meta: DefMeta,
}
pub struct Registry {
pub languages: Vec<Language>,
by_name: HashMap<String, usize>,
loaded: HashMap<String, Loaded>,
pub compiled: Compiled,
lists: HashMap<(String, String), Arc<KeywordList>>,
}
pub fn search_dirs() -> Vec<PathBuf> {
let mut v = vec![];
if let Some(d) = dirs::data_dir() {
v.push(d.join("org.kde.syntax-highlighting/syntax"));
v.push(d.join("damson/syntax"));
}
let shared = std::env::var("XDG_DATA_DIRS").unwrap_or_else(|_| "/usr/local/share:/usr/share".into());
for d in shared.split(':').filter(|s| !s.is_empty()) {
v.push(Path::new(d).join("org.kde.syntax-highlighting/syntax"));
v.push(Path::new(d).join("org.kde.syntax-highlighting/syntax-bundled"));
}
if let Ok(exe) = std::env::current_exe() {
if let Some(d) = exe.parent() {
v.push(d.join("syntax"));
v.push(d.join("../share/damson/syntax"));
}
}
v
}
/// Pulls `name="…"` attributes out of the `<language …>` tag without parsing the whole file.
fn header_attrs(head: &str) -> HashMap<String, String> {
let mut map = HashMap::new();
let Some(start) = head.find("<language") else { return map };
let rest = &head[start + 9..];
let tag_end = {
let (mut q, mut end) = (None, rest.len());
for (i, c) in rest.char_indices() {
match (q, c) {
(None, '"' | '\'') => q = Some(c),
(Some(x), _) if x == c => q = None,
(None, '>') => { end = i; break }
_ => {}
}
}
end
};
let tag = &rest[..tag_end];
let b = tag.as_bytes();
let mut i = 0;
while i < b.len() {
while i < b.len() && b[i].is_ascii_whitespace() { i += 1 }
let ks = i;
while i < b.len() && b[i] != b'=' && !b[i].is_ascii_whitespace() { i += 1 }
let key = &tag[ks..i];
while i < b.len() && (b[i] == b'=' || b[i].is_ascii_whitespace()) { i += 1 }
if i >= b.len() { break }
let q = b[i];
if q != b'"' && q != b'\'' { i += 1; continue }
i += 1;
let vs = i;
while i < b.len() && b[i] != q { i += 1 }
map.insert(key.to_string(), tag[vs..i.min(tag.len())].replace("&amp;", "&").replace("&lt;", "<").replace("&gt;", ">"));
i += 1;
}
map
}
fn glob_match(pat: &str, name: &str) -> bool {
let p: Vec<char> = pat.chars().collect();
let n: Vec<char> = name.chars().collect();
let (mut i, mut j, mut star, mut mark) = (0, 0, None, 0);
while j < n.len() {
if i < p.len() && (p[i] == '?' || p[i] == n[j]) {
i += 1;
j += 1;
} else if i < p.len() && p[i] == '*' {
star = Some(i);
mark = j;
i += 1;
} else if let Some(s) = star {
i = s + 1;
mark += 1;
j = mark;
} else {
return false;
}
}
while i < p.len() && p[i] == '*' { i += 1 }
i == p.len()
}
impl Registry {
pub fn scan() -> Registry {
Self::scan_dirs(&search_dirs())
}
pub fn scan_dirs(dirs: &[PathBuf]) -> Registry {
let mut languages: Vec<Language> = vec![];
let mut by_name: HashMap<String, usize> = HashMap::new();
for dir in dirs {
let Ok(rd) = std::fs::read_dir(dir) else { continue };
let mut files: Vec<PathBuf> = rd.flatten().map(|e| e.path()).filter(|p| p.extension().is_some_and(|e| e == "xml")).collect();
files.sort();
for path in files {
// earlier folders win, so a definition in the user's folder replaces the system one
let mut buf = [0u8; 8192];
let Ok(n) = std::fs::File::open(&path).and_then(|mut f| f.read(&mut buf)) else { continue };
let head = String::from_utf8_lossy(&buf[..n]);
let a = header_attrs(&head);
let Some(name) = a.get("name").cloned() else { continue };
if by_name.contains_key(&name) { continue }
let split = |k: &str| a.get(k).map(|s| s.split(';').map(|x| x.trim().to_string()).filter(|x| !x.is_empty()).collect()).unwrap_or_default();
by_name.insert(name.clone(), languages.len());
languages.push(Language {
alternatives: split("alternativeNames"),
section: a.get("section").cloned().unwrap_or_default(),
extensions: split("extensions"),
mimetypes: split("mimetype"),
priority: a.get("priority").and_then(|p| p.parse().ok()).unwrap_or(0),
hidden: a.get("hidden").is_some_and(|h| h == "true" || h == "1"),
path,
name,
});
}
}
Registry { languages, by_name, loaded: HashMap::new(), compiled: Compiled::default(), lists: HashMap::new() }
}
/// The definition for a file name, by Kate's rule: the highest priority among matching globs.
pub fn detect(&self, file_name: &str, first_line: &str) -> Option<&str> {
let best = self.languages.iter().filter(|l| !l.hidden && l.extensions.iter().any(|g| glob_match(g, file_name))).max_by_key(|l| l.priority);
if let Some(l) = best {
return Some(&l.name);
}
let s = first_line.trim_end();
if let Some(rest) = s.strip_prefix("#!") {
let word = rest.trim().rsplit('/').next().unwrap_or("");
let word = if word.starts_with("env") { rest.split_whitespace().nth(1).unwrap_or("") } else { word.split_whitespace().next().unwrap_or("") };
let name = match word.trim_end_matches(|c: char| c.is_ascii_digit() || c == '.') {
"python" => "Python",
"bash" | "sh" | "zsh" | "dash" | "ksh" => "Bash",
"fish" => "Fish",
"node" | "deno" => "JavaScript",
"ruby" => "Ruby",
"perl" => "Perl",
"lua" => "Lua",
"php" => "PHP",
_ => return None,
};
return self.by_name.contains_key(name).then_some(name);
}
None
}
pub fn meta(&mut self, name: &str) -> DefMeta {
self.load(name);
self.loaded.get(name).map(|l| l.meta.clone()).unwrap_or_default()
}
pub fn initial_state(&mut self, name: &str) -> Option<State> {
self.load(name)?;
self.loaded.get(name).map(|l| Highlighter::initial(l.root))
}
fn intern_list(&mut self, def: &str, name: &str, doc: roxmltree::Node) -> Arc<KeywordList> {
let key = (def.to_string(), name.to_string());
if let Some(l) = self.lists.get(&key) {
return l.clone();
}
let mut list = KeywordList::default();
let mut seen = HashSet::new();
self.collect_list(name, doc, &mut list, &mut seen);
let a = Arc::new(list);
self.lists.insert(key, a.clone());
a
}
fn collect_list(&self, name: &str, doc: roxmltree::Node, out: &mut KeywordList, seen: &mut HashSet<String>) {
if !seen.insert(name.to_string()) {
return;
}
let Some(node) = doc.descendants().find(|n| n.has_tag_name("list") && n.attribute("name") == Some(name)) else { return };
for ch in node.children().filter(|n| n.is_element()) {
match ch.tag_name().name() {
"item" => {
if let Some(t) = ch.text() {
let t = t.trim();
out.cased.insert(t.to_string());
out.folded.insert(t.to_lowercase());
}
}
"include" => {
if let Some(t) = ch.text() {
self.collect_list(t.trim(), doc, out, seen);
}
}
_ => {}
}
}
}
fn region(&mut self, def: &str, name: &str) -> u32 {
let n = self.compiled.regions.len() as u32;
*self.compiled.regions.entry(format!("{def}\0{name}")).or_insert(n)
}
/// Compiles a definition and everything it includes. Returns its root context.
pub fn load(&mut self, name: &str) -> Option<CtxId> {
if let Some(l) = self.loaded.get(name) {
return Some(l.root);
}
let idx = *self.by_name.get(name)?;
let path = self.languages[idx].path.clone();
let text = std::fs::read_to_string(&path).ok()?;
let opts = roxmltree::ParsingOptions { allow_dtd: true, ..Default::default() };
let doc = roxmltree::Document::parse_with_options(&text, opts).ok()?;
let root_el = doc.root_element();
let hl = root_el.children().find(|n| n.has_tag_name("highlighting"))?;
let general = root_el.children().find(|n| n.has_tag_name("general"));
// styles
let mut style_of: HashMap<String, StyleId> = HashMap::new();
if let Some(items) = hl.children().find(|n| n.has_tag_name("itemDatas")) {
for it in items.children().filter(|n| n.has_tag_name("itemData")) {
let info = StyleInfo {
base: DefStyle::parse(it.attribute("defStyleNum").unwrap_or("dsNormal")),
bold: it.attribute("bold").map(truthy),
italic: it.attribute("italic").map(truthy),
underline: it.attribute("underline").is_some_and(truthy),
};
self.compiled.styles.push(info);
style_of.insert(it.attribute("name").unwrap_or("").to_string(), (self.compiled.styles.len() - 1) as StyleId);
}
}
if self.compiled.styles.is_empty() {
self.compiled.styles.push(StyleInfo { base: DefStyle::Normal, bold: None, italic: None, underline: false });
}
let default_style = style_of.values().copied().min().unwrap_or(0);
// reserve context ids first: contexts refer to each other, and other definitions to these
let ctxs: Vec<roxmltree::Node> = hl.children().find(|n| n.has_tag_name("contexts")).map(|c| c.children().filter(|n| n.has_tag_name("context")).collect()).unwrap_or_default();
if ctxs.is_empty() {
return None;
}
let base = self.compiled.contexts.len() as CtxId;
let mut ids: HashMap<String, CtxId> = HashMap::new();
for (i, c) in ctxs.iter().enumerate() {
ids.entry(c.attribute("name").unwrap_or("").to_string()).or_insert(base + i as CtxId);
let placeholder = Context { style: 0, rules: vec![], line_end: Switch::default(), line_empty: None, fallthrough: None, dynamic: false };
self.compiled.contexts.push(placeholder);
}
let mut meta = DefMeta::default();
if let Some(g) = general {
if let Some(cm) = g.children().find(|n| n.has_tag_name("comments")) {
for c in cm.children().filter(|n| n.has_tag_name("comment")) {
match c.attribute("name") {
Some("singleLine") => meta.line_comment = c.attribute("start").map(str::to_string),
Some("multiLine") => meta.block_comment = c.attribute("start").zip(c.attribute("end")).map(|(a, b)| (a.to_string(), b.to_string())),
_ => {}
}
}
}
if let Some(f) = g.children().find(|n| n.has_tag_name("folding")) {
meta.indent_fold = f.attribute("indentationsensitive").is_some_and(truthy);
}
}
self.loaded.insert(name.to_string(), Loaded { root: base, meta });
let kw = general.and_then(|g| g.children().find(|n| n.has_tag_name("keywords")));
let default_ci = kw.and_then(|k| k.attribute("casesensitive")).is_some_and(|v| !truthy(v));
let delims = Arc::new(Delims::new(kw.and_then(|k| k.attribute("weakDeliminator")).unwrap_or(""), kw.and_then(|k| k.attribute("additionalDeliminator")).unwrap_or("")));
// first pass: own rules, with include markers; second pass flattens the includes
let mut includes: Vec<(usize, usize, CtxId, bool)> = vec![];
for (i, c) in ctxs.iter().enumerate() {
let cid = (base as usize) + i;
let style = c.attribute("attribute").and_then(|a| style_of.get(a).copied()).unwrap_or(default_style);
let line_end = self.switch(c.attribute("lineEndContext"), &ids, name);
let line_empty = c.attribute("lineEmptyContext").map(|s| self.switch(Some(s), &ids, name));
let fall = if let Some(f) = c.attribute("fallthroughContext") { Some(self.switch(Some(f), &ids, name)) } else if c.attribute("fallthrough").is_some_and(truthy) { Some(Switch::default()) } else { None };
let fall = fall.filter(|s| !s.is_stay());
let mut rules = vec![];
for r in c.children().filter(|n| n.is_element()) {
self.rule(r, &mut rules, &mut includes, cid, doc.root_element(), name, &ids, &style_of, default_ci, &delims);
}
let dynamic = c.attribute("dynamic").is_some_and(truthy);
self.compiled.contexts[cid] = Context { style, rules, line_end, line_empty, fallthrough: fall, dynamic };
}
self.flatten(&includes);
Some(base)
}
fn flatten(&mut self, includes: &[(usize, usize, CtxId, bool)]) {
// process in reverse so insertion indices of earlier includes in a context stay valid
for (cid, at, target, attrib) in includes.iter().rev() {
let mut seen = HashSet::from([*cid as CtxId]);
let extra = self.clone_rules(*target, &mut seen);
let ctx = &mut self.compiled.contexts[*cid];
let at = (*at).min(ctx.rules.len());
ctx.rules.splice(at..at, extra);
if *attrib {
let (s, f) = { let t = &self.compiled.contexts[*target as usize]; (t.style, t.fallthrough) };
let ctx = &mut self.compiled.contexts[*cid];
ctx.style = s;
if ctx.fallthrough.is_none() { ctx.fallthrough = f }
}
}
}
fn clone_rules(&self, target: CtxId, _seen: &mut HashSet<CtxId>) -> Vec<Rule> {
self.compiled.contexts[target as usize].rules.iter().map(clone_rule).collect()
}
fn switch(&mut self, spec: Option<&str>, ids: &HashMap<String, CtxId>, def: &str) -> Switch {
let Some(mut s) = spec else { return Switch::default() };
let mut out = Switch::default();
s = s.trim();
if s.is_empty() || s == "#stay" {
return out;
}
while let Some(r) = s.strip_prefix("#pop") {
out.pops += 1;
s = r;
}
let s = s.strip_prefix('!').unwrap_or(s);
if s.is_empty() {
return out;
}
out.push = self.resolve(s, ids, def);
out
}
fn resolve(&mut self, s: &str, ids: &HashMap<String, CtxId>, def: &str) -> Option<CtxId> {
if let Some((ctx, other)) = s.split_once("##") {
let other = other.trim();
if other == def {
return if ctx.is_empty() { ids.values().min().copied() } else { ids.get(ctx).copied() };
}
let root = self.load(other)?;
if ctx.is_empty() {
return Some(root);
}
return self.find_ctx(other, ctx);
}
ids.get(s).copied()
}
/// A named context of an already-loaded definition. Names are re-read from its file.
fn find_ctx(&self, def: &str, ctx: &str) -> Option<CtxId> {
let idx = *self.by_name.get(def)?;
let text = std::fs::read_to_string(&self.languages[idx].path).ok()?;
let opts = roxmltree::ParsingOptions { allow_dtd: true, ..Default::default() };
let doc = roxmltree::Document::parse_with_options(&text, opts).ok()?;
let root = self.loaded.get(def)?.root;
let hl = doc.root_element().children().find(|n| n.has_tag_name("highlighting"))?;
let pos = hl.children().find(|n| n.has_tag_name("contexts"))?.children().filter(|n| n.has_tag_name("context")).position(|c| c.attribute("name") == Some(ctx))?;
Some(root + pos as CtxId)
}
#[allow(clippy::too_many_arguments)]
fn rule(&mut self, r: roxmltree::Node, out: &mut Vec<Rule>, inc: &mut Vec<(usize, usize, CtxId, bool)>, cid: usize, doc: roxmltree::Node, def: &str, ids: &HashMap<String, CtxId>, styles: &HashMap<String, StyleId>, default_ci: bool, delims: &Arc<Delims>) {
let tag = r.tag_name().name();
if tag == "IncludeRules" {
if let Some(t) = r.attribute("context").and_then(|s| self.resolve(s, ids, def)) {
inc.push((cid, out.len(), t, r.attribute("includeAttrib").is_some_and(truthy)));
}
return;
}
let a = |k: &str| r.attribute(k);
let ch = |k: &str| a(k).and_then(|s| s.chars().next());
let ci = a("insensitive").map(truthy).unwrap_or(false);
let dynamic = a("dynamic").is_some_and(truthy);
let matcher = match tag {
"DetectChar" => {
let c = ch("char").unwrap_or('\0');
let dyn_idx = (dynamic && c.is_ascii_digit()).then(|| c.to_digit(10).unwrap() as usize);
Matcher::DetectChar { c, dyn_idx }
}
"Detect2Chars" => Matcher::Detect2Chars { a: ch("char").unwrap_or('\0'), b: ch("char1").unwrap_or('\0') },
"AnyChar" => Matcher::AnyChar(a("String").unwrap_or("").chars().collect()),
"StringDetect" => Matcher::StringDetect { s: a("String").unwrap_or("").to_string(), ci, dynamic },
"WordDetect" => Matcher::WordDetect { s: a("String").unwrap_or("").to_string(), ci },
"RegExpr" => {
let source = a("String").unwrap_or("").to_string();
let minimal = a("minimal").is_some_and(truthy);
let re = if dynamic { None } else {
match compile_regex(&source, ci, minimal) {
Ok(r) => Some(Arc::new(r)),
Err(e) => {
self.compiled.bad_regexes.push((format!("{def}: {source}"), e));
None
}
}
};
Matcher::Regex { re, source, ci, minimal, dynamic }
}
"keyword" => {
let name = a("String").unwrap_or("");
let list = self.intern_list(def, name, doc);
let ci = a("insensitive").map(truthy).unwrap_or(default_ci);
Matcher::Keyword { list, ci }
}
"Int" => Matcher::Int,
"Float" => Matcher::Float,
"HlCOct" => Matcher::HlCOct,
"HlCHex" => Matcher::HlCHex,
"HlCStringChar" => Matcher::HlCStringChar,
"HlCChar" => Matcher::HlCChar,
"RangeDetect" => Matcher::RangeDetect { a: ch("char").unwrap_or('\0'), b: ch("char1").unwrap_or('\0') },
"LineContinue" => Matcher::LineContinue { c: ch("char").unwrap_or('\\') },
"DetectSpaces" => Matcher::DetectSpaces,
"DetectIdentifier" => Matcher::DetectIdentifier,
_ => return,
};
let switch = self.switch(a("context"), ids, def);
let begin_region = a("beginRegion").map(|n| self.region(def, n));
let end_region = a("endRegion").map(|n| self.region(def, n));
out.push(Rule {
matcher,
style: a("attribute").and_then(|s| styles.get(s).copied()),
switch,
look_ahead: a("lookAhead").is_some_and(truthy),
first_non_space: a("firstNonSpace").is_some_and(truthy),
column: a("column").and_then(|c| c.parse().ok()),
begin_region,
end_region,
delims: delims.clone(),
});
}
}
fn truthy(s: &str) -> bool {
matches!(s.to_ascii_lowercase().as_str(), "1" | "true")
}
fn clone_rule(r: &Rule) -> Rule {
let matcher = match &r.matcher {
Matcher::DetectChar { c, dyn_idx } => Matcher::DetectChar { c: *c, dyn_idx: *dyn_idx },
Matcher::Detect2Chars { a, b } => Matcher::Detect2Chars { a: *a, b: *b },
Matcher::AnyChar(v) => Matcher::AnyChar(v.clone()),
Matcher::StringDetect { s, ci, dynamic } => Matcher::StringDetect { s: s.clone(), ci: *ci, dynamic: *dynamic },
Matcher::WordDetect { s, ci } => Matcher::WordDetect { s: s.clone(), ci: *ci },
Matcher::Regex { re, source, ci, minimal, dynamic } => Matcher::Regex { re: re.clone(), source: source.clone(), ci: *ci, minimal: *minimal, dynamic: *dynamic },
Matcher::Keyword { list, ci } => Matcher::Keyword { list: list.clone(), ci: *ci },
Matcher::Int => Matcher::Int,
Matcher::Float => Matcher::Float,
Matcher::HlCOct => Matcher::HlCOct,
Matcher::HlCHex => Matcher::HlCHex,
Matcher::HlCStringChar => Matcher::HlCStringChar,
Matcher::HlCChar => Matcher::HlCChar,
Matcher::RangeDetect { a, b } => Matcher::RangeDetect { a: *a, b: *b },
Matcher::LineContinue { c } => Matcher::LineContinue { c: *c },
Matcher::DetectSpaces => Matcher::DetectSpaces,
Matcher::DetectIdentifier => Matcher::DetectIdentifier,
};
Rule { matcher, style: r.style, switch: r.switch, look_ahead: r.look_ahead, first_non_space: r.first_non_space, column: r.column, begin_region: r.begin_region, end_region: r.end_region, delims: r.delims.clone() }
}

264
src/text/buffer.rs Normal file
View file

@ -0,0 +1,264 @@
//! The text itself: a rope, any number of selections, and grouped undo.
use ropey::Rope;
use std::ops::Range;
use std::time::{Duration, Instant};
/// One selection; `anchor == head` is a plain cursor. Positions are char indices into the rope.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct Sel {
pub anchor: usize,
pub head: usize,
/// Column to return to while moving through shorter lines.
pub want_col: Option<usize>,
}
impl Sel {
pub fn cursor(at: usize) -> Sel {
Sel { anchor: at, head: at, want_col: None }
}
pub fn range(&self) -> Range<usize> {
self.anchor.min(self.head)..self.anchor.max(self.head)
}
pub fn is_empty(&self) -> bool {
self.anchor == self.head
}
}
/// Typing runs of the same kind undo together.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum EditKind {
Typing,
Deleting,
Other,
}
#[derive(Clone, Debug)]
struct Edit {
pos: usize,
del: String,
ins: String,
}
#[derive(Clone, Debug)]
struct Group {
edits: Vec<Edit>,
before: Vec<Sel>,
after: Vec<Sel>,
kind: EditKind,
at: Instant,
}
/// Lines touched by an edit: `old` lines starting at `first` became `new` lines.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct LineChange {
pub first: usize,
pub old: usize,
pub new: usize,
}
pub struct Buffer {
pub rope: Rope,
pub sels: Vec<Sel>,
pub primary: usize,
undo: Vec<Group>,
redo: Vec<Group>,
/// Bumped on every text change.
pub version: u64,
saved_marker: Option<usize>,
/// Line changes since the document last looked; drained by `Doc`.
pub changes: Vec<LineChange>,
}
const COALESCE: Duration = Duration::from_millis(900);
impl Buffer {
pub fn new(text: &str) -> Buffer {
Buffer { rope: Rope::from_str(text), sels: vec![Sel::cursor(0)], primary: 0, undo: vec![], redo: vec![], version: 0, saved_marker: Some(0), changes: vec![] }
}
pub fn mark_saved(&mut self) {
self.saved_marker = Some(self.undo.len());
}
pub fn is_modified(&self) -> bool {
self.saved_marker != Some(self.undo.len())
}
pub fn can_undo(&self) -> bool {
!self.undo.is_empty()
}
pub fn can_redo(&self) -> bool {
!self.redo.is_empty()
}
pub fn len(&self) -> usize {
self.rope.len_chars()
}
pub fn is_empty(&self) -> bool {
self.len() == 0
}
pub fn lines(&self) -> usize {
self.rope.len_lines()
}
pub fn head(&self) -> usize {
self.sels[self.primary.min(self.sels.len() - 1)].head
}
/// (line, char column) of a position.
pub fn pos(&self, at: usize) -> (usize, usize) {
let at = at.min(self.len());
let l = self.rope.char_to_line(at);
(l, at - self.rope.line_to_char(l))
}
pub fn at(&self, line: usize, col: usize) -> usize {
let line = line.min(self.lines() - 1);
self.rope.line_to_char(line) + col.min(self.line_len(line))
}
/// Length of a line in chars, without its line break.
pub fn line_len(&self, line: usize) -> usize {
let s = self.rope.line(line);
let mut n = s.len_chars();
while n > 0 && matches!(s.char(n - 1), '\n' | '\r') {
n -= 1;
}
n
}
pub fn line_text(&self, line: usize) -> String {
if line >= self.lines() {
return String::new();
}
let mut s = self.rope.line(line).to_string();
while s.ends_with('\n') || s.ends_with('\r') {
s.pop();
}
s
}
pub fn text(&self, r: Range<usize>) -> String {
self.rope.slice(r).to_string()
}
/// Replaces ranges with texts. The ranges may come in any order but must not overlap.
/// `place` gets, for each change in order, where its new text starts and how long it is, and
/// returns the selection that should follow it.
pub fn apply(&mut self, mut changes: Vec<(Range<usize>, String)>, kind: EditKind, place: impl Fn(usize, usize, usize) -> Sel) {
changes.sort_by_key(|c| c.0.start);
let before = self.sels.clone();
let mut delta = 0isize;
let mut after = vec![];
for (i, (r, s)) in changes.iter().enumerate() {
let start = (r.start as isize + delta) as usize;
let n = s.chars().count();
after.push(place(i, start, n));
delta += n as isize - r.len() as isize;
}
// back to front, so earlier positions stay valid
let mut edits = vec![];
for (r, s) in changes.into_iter().rev() {
if r.is_empty() && s.is_empty() {
continue;
}
let del = self.rope.slice(r.clone()).to_string();
self.raw_edit(r.start, r.end, &s);
edits.push(Edit { pos: r.start, del, ins: s });
}
self.set_sels(after);
if edits.is_empty() {
return;
}
self.redo.clear();
let now = Instant::now();
let saved_here = self.saved_marker == Some(self.undo.len());
if let Some(g) = self.undo.last_mut() {
if kind != EditKind::Other && g.kind == kind && now - g.at < COALESCE && !saved_here {
g.edits.extend(edits);
g.after = self.sels.clone();
g.at = now;
return;
}
}
if self.saved_marker.is_some_and(|m| m > self.undo.len()) {
self.saved_marker = None;
}
self.undo.push(Group { edits, before, after: self.sels.clone(), kind, at: now });
}
fn raw_edit(&mut self, start: usize, end: usize, ins: &str) {
let first = self.rope.char_to_line(start);
let last = self.rope.char_to_line(end);
self.rope.remove(start..end);
self.rope.insert(start, ins);
let new = ins.matches('\n').count();
self.changes.push(LineChange { first, old: last - first + 1, new: new + 1 });
self.version += 1;
}
pub fn undo(&mut self) -> bool {
let Some(g) = self.undo.pop() else { return false };
for e in g.edits.iter().rev() {
self.raw_edit(e.pos, e.pos + e.ins.chars().count(), &e.del);
}
self.set_sels(g.before.clone());
self.redo.push(g);
true
}
pub fn redo(&mut self) -> bool {
let Some(mut g) = self.redo.pop() else { return false };
for e in g.edits.iter() {
self.raw_edit(e.pos, e.pos + e.del.chars().count(), &e.ins);
}
self.set_sels(g.after.clone());
g.at = Instant::now() - COALESCE;
self.undo.push(g);
true
}
/// Sets the selections, sorted, with overlapping ones merged. The last one becomes primary.
pub fn set_sels(&mut self, mut v: Vec<Sel>) {
if v.is_empty() {
v.push(Sel::cursor(0));
}
let len = self.len();
for s in &mut v {
s.anchor = s.anchor.min(len);
s.head = s.head.min(len);
}
let last = v[v.len() - 1];
v.sort_by_key(|s| s.range().start);
let mut out: Vec<Sel> = vec![];
for s in v {
if let Some(p) = out.last_mut() {
let (pr, sr) = (p.range(), s.range());
if sr.start < pr.end || (sr.start == pr.end && (pr.is_empty() || sr.is_empty())) {
let (a, b) = (pr.start.min(sr.start), pr.end.max(sr.end));
let backward = p.head < p.anchor;
*p = Sel { anchor: if backward { b } else { a }, head: if backward { a } else { b }, want_col: None };
continue;
}
}
out.push(s);
}
self.primary = out.iter().position(|s| s.range().contains(&last.head) || s.head == last.head).unwrap_or(out.len() - 1);
self.sels = out;
}
pub fn set_cursor(&mut self, at: usize) {
self.set_sels(vec![Sel::cursor(at)]);
}
pub fn selected_text(&self) -> String {
let parts: Vec<String> = self.sels.iter().filter(|s| !s.is_empty()).map(|s| self.text(s.range())).collect();
parts.join("\n")
}
}

635
src/text/commands.rs Normal file
View file

@ -0,0 +1,635 @@
//! Editing commands on a `Buffer`. Every command works on all selections at once.
use super::buffer::{Buffer, EditKind, Sel};
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
pub enum Move {
Left, Right, Up, Down, WordLeft, WordRight, Home, End, DocStart, DocEnd, PageUp(usize), PageDown(usize),
}
fn is_word(c: char) -> bool {
c.is_alphanumeric() || c == '_'
}
pub struct Prefs {
pub tab_width: usize,
pub spaces: bool,
pub auto_close: bool,
}
impl Default for Prefs {
fn default() -> Self {
Prefs { tab_width: 4, spaces: true, auto_close: true }
}
}
impl Buffer {
fn word_left(&self, mut at: usize) -> usize {
let c = |i: usize| self.rope.char(i);
while at > 0 && c(at - 1).is_whitespace() { at -= 1 }
if at == 0 { return 0 }
let word = is_word(c(at - 1));
while at > 0 && !c(at - 1).is_whitespace() && is_word(c(at - 1)) == word { at -= 1 }
at
}
fn word_right(&self, mut at: usize) -> usize {
let n = self.len();
let c = |i: usize| self.rope.char(i);
while at < n && c(at).is_whitespace() { at += 1 }
if at == n { return n }
let word = is_word(c(at));
while at < n && !c(at).is_whitespace() && is_word(c(at)) == word { at += 1 }
at
}
/// The word around a position.
pub fn word_at(&self, at: usize) -> std::ops::Range<usize> {
let n = self.len();
let (mut a, mut b) = (at.min(n), at.min(n));
while a > 0 && is_word(self.rope.char(a - 1)) { a -= 1 }
while b < n && is_word(self.rope.char(b)) { b += 1 }
a..b
}
fn first_text_col(&self, line: usize) -> usize {
self.rope.line(line).chars().take(self.line_len(line)).take_while(|c| *c == ' ' || *c == '\t').count()
}
fn step(&self, s: &Sel, m: Move) -> (usize, Option<usize>) {
let (line, col) = self.pos(s.head);
let vertical = |lines: isize| {
let want = s.want_col.unwrap_or(col);
let target = (line as isize + lines).clamp(0, self.lines() as isize - 1) as usize;
if target == line {
let edge = if lines < 0 { 0 } else { self.len() };
return (edge, None);
}
(self.at(target, want), Some(want))
};
match m {
Move::Left => (s.head.saturating_sub(1), None),
Move::Right => ((s.head + 1).min(self.len()), None),
Move::Up => vertical(-1),
Move::Down => vertical(1),
Move::PageUp(n) => vertical(-(n as isize)),
Move::PageDown(n) => vertical(n as isize),
Move::WordLeft => (self.word_left(s.head), None),
Move::WordRight => (self.word_right(s.head), None),
Move::Home => {
let t = self.first_text_col(line);
(self.at(line, if col == t { 0 } else { t }), None)
}
Move::End => (self.at(line, usize::MAX), None),
Move::DocStart => (0, None),
Move::DocEnd => (self.len(), None),
}
}
pub fn move_cursors(&mut self, m: Move, extend: bool) {
let next: Vec<Sel> = self.sels.iter().map(|s| {
// a selection collapses towards the direction of travel
if !extend && !s.is_empty() && matches!(m, Move::Left | Move::Right) {
let r = s.range();
return Sel::cursor(if m == Move::Left { r.start } else { r.end });
}
let (h, want) = self.step(s, m);
Sel { anchor: if extend { s.anchor } else { h }, head: h, want_col: want }
}).collect();
self.set_sels(next);
}
pub fn select_all(&mut self) {
self.set_sels(vec![Sel { anchor: 0, head: self.len(), want_col: None }]);
}
/// Inserts text at every cursor; when the paste has one line per cursor, each gets its own.
pub fn insert(&mut self, text: &str, kind: EditKind) {
let parts: Vec<&str> = text.split('\n').collect();
let per_cursor = self.sels.len() > 1 && parts.len() == self.sels.len();
let changes = self.sels.iter().enumerate().map(|(i, s)| (s.range(), if per_cursor { parts[i].to_string() } else { text.to_string() })).collect();
self.apply(changes, kind, |_, st, n| Sel::cursor(st + n));
}
/// Typed text: wraps selections in brackets, closes pairs and types over closers.
pub fn type_text(&mut self, text: &str, p: &Prefs) {
let mut cs = text.chars();
let (Some(c), None) = (cs.next(), cs.next()) else {
return self.insert(text, EditKind::Typing);
};
let close = match c { '(' => ')', '[' => ']', '{' => '}', '"' => '"', '\'' => '\'', '`' => '`', _ => '\0' };
if p.auto_close {
if close != '\0' && self.sels.iter().all(|s| !s.is_empty()) {
let changes = self.sels.iter().map(|s| (s.range(), format!("{c}{}{close}", self.text(s.range())))).collect();
return self.apply(changes, EditKind::Other, |_, st, n| Sel { anchor: st + 1, head: st + n - 1, want_col: None });
}
if matches!(c, ')' | ']' | '}' | '"' | '\'' | '`') && self.sels.iter().all(|s| s.is_empty() && s.head < self.len() && self.rope.char(s.head) == c) {
let next = self.sels.iter().map(|s| Sel::cursor(s.head + 1)).collect();
return self.set_sels(next);
}
let boundary = |s: &Sel| {
let after = (s.head < self.len()).then(|| self.rope.char(s.head));
let before = (s.head > 0).then(|| self.rope.char(s.head - 1));
let free_after = after.is_none_or(|a| a.is_whitespace() || ")]}>,;:".contains(a));
let quote = matches!(c, '"' | '\'' | '`');
free_after && !(quote && before.is_some_and(is_word))
};
if close != '\0' && self.sels.iter().all(|s| s.is_empty() && boundary(s)) {
let changes = self.sels.iter().map(|s| (s.range(), format!("{c}{close}"))).collect();
return self.apply(changes, EditKind::Typing, |_, st, _| Sel::cursor(st + 1));
}
}
self.insert(text, EditKind::Typing);
}
pub fn newline(&mut self, p: &Prefs) {
let items: Vec<(std::ops::Range<usize>, String, usize)> = self.sels.iter().map(|s| {
let r = s.range();
let (line, col) = self.pos(r.start);
let lt = self.line_text(line);
let indent: String = lt.chars().take(col).take_while(|c| *c == ' ' || *c == '\t').collect();
let before = lt.chars().take(col).collect::<String>();
let before = before.trim_end();
let opens = before.ends_with(['{', '(', '[']) || before.ends_with(':');
let closes = r.end < self.len() && matches!(self.rope.char(r.end), '}' | ')' | ']');
let unit = if p.spaces { " ".repeat(p.tab_width) } else { "\t".to_string() };
let mut t = format!("\n{indent}");
let mut back = 0;
if opens {
t.push_str(&unit);
if closes && !before.ends_with(':') {
let tail = format!("\n{indent}");
back = tail.chars().count();
t.push_str(&tail);
}
}
(r, t, back)
}).collect();
let backs: Vec<usize> = items.iter().map(|i| i.2).collect();
let mut order: Vec<usize> = (0..items.len()).collect();
order.sort_by_key(|i| items[*i].0.start);
let ordered_backs: Vec<usize> = order.iter().map(|i| backs[*i]).collect();
self.apply(items.into_iter().map(|i| (i.0, i.1)).collect(), EditKind::Other, move |i, st, n| Sel::cursor(st + n - ordered_backs[i]));
}
pub fn backspace(&mut self, p: &Prefs) {
let changes = self.sels.iter().map(|s| {
if !s.is_empty() {
return (s.range(), String::new());
}
let at = s.head;
if at == 0 {
return (0..0, String::new());
}
let (line, col) = self.pos(at);
let lead = self.first_text_col(line);
// inside indentation, remove back to the previous tab stop
if col > 0 && col <= lead && p.spaces && self.rope.char(at - 1) == ' ' {
let n = ((col - 1) % p.tab_width) + 1;
return (at - n..at, String::new());
}
let prev = self.rope.char(at - 1);
let next = (at < self.len()).then(|| self.rope.char(at));
let pair = matches!((prev, next), ('(', Some(')')) | ('[', Some(']')) | ('{', Some('}')) | ('"', Some('"')) | ('\'', Some('\'')) | ('`', Some('`')));
(at - 1..if pair { at + 1 } else { at }, String::new())
}).collect();
self.apply(changes, EditKind::Deleting, |_, st, _| Sel::cursor(st));
}
pub fn delete_forward(&mut self) {
let n = self.len();
let changes = self.sels.iter().map(|s| (if s.is_empty() { s.head..(s.head + 1).min(n) } else { s.range() }, String::new())).collect();
self.apply(changes, EditKind::Deleting, |_, st, _| Sel::cursor(st));
}
pub fn delete_word(&mut self, forward: bool) {
let changes = self.sels.iter().map(|s| {
let r = if !s.is_empty() { s.range() } else if forward { s.head..self.word_right(s.head) } else { self.word_left(s.head)..s.head };
(r, String::new())
}).collect();
self.apply(changes, EditKind::Deleting, |_, st, _| Sel::cursor(st));
}
/// Whole lines covered by the selections, merged, first to last.
fn covered_lines(&self) -> Vec<(usize, usize)> {
let mut v: Vec<(usize, usize)> = vec![];
for s in &self.sels {
let r = s.range();
let a = self.pos(r.start).0;
let (mut b, c) = self.pos(r.end);
if !s.is_empty() && c == 0 && b > a { b -= 1 }
match v.last_mut() {
Some(l) if a <= l.1 + 1 => l.1 = l.1.max(b),
_ => v.push((a, b)),
}
}
v
}
fn line_start(&self, l: usize) -> usize {
self.rope.line_to_char(l)
}
/// Runs `f` for each line's change, keeping selections on the same text.
fn edit_lines(&mut self, f: impl Fn(&Buffer, usize) -> Option<(std::ops::Range<usize>, String)>) {
let mut changes = vec![];
for (a, b) in self.covered_lines() {
for l in a..=b {
if let Some(c) = f(self, l) {
changes.push(c);
}
}
}
let map = |at: usize| {
let mut pos = at as isize;
for (r, s) in &changes {
if r.end <= at { pos += s.chars().count() as isize - r.len() as isize }
else if r.start < at { pos += (s.chars().count() as isize - r.len() as isize).max(r.start as isize - at as isize) }
}
pos.max(0) as usize
};
let next: Vec<Sel> = self.sels.iter().map(|s| Sel { anchor: map(s.anchor), head: map(s.head), want_col: None }).collect();
self.apply(changes, EditKind::Other, |_, _, _| Sel::cursor(0));
self.set_sels(next);
}
pub fn indent(&mut self, p: &Prefs) {
if self.sels.iter().all(|s| s.is_empty() || self.pos(s.anchor).0 == self.pos(s.head).0) {
let changes = self.sels.iter().map(|s| {
let t = if p.spaces { " ".repeat(p.tab_width - self.pos(s.range().start).1 % p.tab_width) } else { "\t".to_string() };
(s.range(), t)
}).collect();
return self.apply(changes, EditKind::Typing, |_, st, n| Sel::cursor(st + n));
}
let unit = if p.spaces { " ".repeat(p.tab_width) } else { "\t".to_string() };
self.edit_lines(|b, l| (b.line_len(l) > 0).then(|| (b.line_start(l)..b.line_start(l), unit.clone())));
}
pub fn unindent(&mut self, p: &Prefs) {
let w = p.tab_width;
self.edit_lines(|b, l| {
let t = b.line_text(l);
let n = if t.starts_with('\t') { 1 } else { t.chars().take(w).take_while(|c| *c == ' ').count() };
(n > 0).then(|| (b.line_start(l)..b.line_start(l) + n, String::new()))
});
}
pub fn toggle_comment(&mut self, line: Option<&str>, block: Option<(&str, &str)>) {
let Some(tok) = line else {
let Some((a, b)) = block else { return };
let changes = self.sels.iter().map(|s| {
let t = self.text(s.range());
let inner = t.strip_prefix(a).and_then(|x| x.strip_suffix(b));
(s.range(), inner.map(str::to_string).unwrap_or_else(|| format!("{a}{t}{b}")))
}).collect();
return self.apply(changes, EditKind::Other, |_, st, n| Sel { anchor: st, head: st + n, want_col: None });
};
let lines = self.covered_lines();
let all = lines.iter().all(|(a, b)| (*a..=*b).all(|l| {
let t = self.line_text(l);
t.trim().is_empty() || t.trim_start().starts_with(tok)
}));
let col = lines.iter().flat_map(|(a, b)| *a..=*b).filter(|l| !self.line_text(*l).trim().is_empty()).map(|l| self.first_text_col(l)).min().unwrap_or(0);
self.edit_lines(|b, l| {
let t = b.line_text(l);
if t.trim().is_empty() {
return None;
}
if all {
let c = b.first_text_col(l);
let n = tok.chars().count();
let extra = t.chars().nth(c + n).is_some_and(|x| x == ' ') as usize;
let s = b.line_start(l) + c;
Some((s..s + n + extra, String::new()))
} else {
let s = b.line_start(l) + col;
Some((s..s, format!("{tok} ")))
}
});
}
pub fn duplicate_lines(&mut self) {
let mut changes = vec![];
for (a, b) in self.covered_lines() {
let end = if b + 1 < self.lines() { self.line_start(b + 1) } else { self.len() };
let mut t = self.text(self.line_start(a)..end);
if !t.ends_with('\n') { t.insert(0, '\n'); }
changes.push((end..end, t));
}
let sels = self.sels.clone();
self.apply(changes, EditKind::Other, |_, _, _| Sel::cursor(0));
self.set_sels(sels);
}
pub fn delete_lines(&mut self) {
let mut changes = vec![];
for (a, b) in self.covered_lines() {
let start = self.line_start(a);
let r = if b + 1 < self.lines() { start..self.line_start(b + 1) } else { start.saturating_sub(1)..self.len() };
changes.push((r, String::new()));
}
self.apply(changes, EditKind::Other, |_, st, _| Sel::cursor(st));
}
pub fn move_lines(&mut self, up: bool) {
let cov = self.covered_lines();
let (first, last) = (cov[0].0, cov[cov.len() - 1].1);
if (up && first == 0) || (!up && last + 1 >= self.lines()) {
return;
}
let (a, b) = if up { (first - 1, last) } else { (first, last + 1) };
let end = if b + 1 < self.lines() { self.line_start(b + 1) } else { self.len() };
let start = self.line_start(a);
let mut ls: Vec<String> = (a..=b).map(|l| self.line_text(l)).collect();
let shift;
if up {
let l = ls.remove(0);
shift = -((l.chars().count() + 1) as isize);
ls.push(l);
} else {
let l = ls.pop().unwrap();
shift = l.chars().count() as isize + 1;
ls.insert(0, l);
}
let mut t = ls.join("\n");
if b + 1 < self.lines() { t.push('\n') }
let sels: Vec<Sel> = self.sels.iter().map(|s| Sel { anchor: (s.anchor as isize + shift) as usize, head: (s.head as isize + shift) as usize, want_col: s.want_col }).collect();
self.apply(vec![(start..end, t)], EditKind::Other, |_, _, _| Sel::cursor(0));
self.set_sels(sels);
}
pub fn join_lines(&mut self) {
let mut changes = vec![];
for (a, b) in self.covered_lines() {
let b = if a == b { (a + 1).min(self.lines() - 1) } else { b };
for l in a..b {
let e = self.at(l, usize::MAX);
let s = self.line_start(l + 1) + self.first_text_col(l + 1);
changes.push((e..s, " ".to_string()));
}
}
self.apply(changes, EditKind::Other, |_, st, _| Sel::cursor(st));
}
pub fn transform(&mut self, f: impl Fn(&str) -> String) {
let changes = self.sels.iter().map(|s| {
let r = if s.is_empty() { self.word_at(s.head) } else { s.range() };
let t = f(&self.text(r.clone()));
(r, t)
}).collect();
self.apply(changes, EditKind::Other, |_, st, n| Sel { anchor: st, head: st + n, want_col: None });
}
pub fn sort_lines(&mut self) {
let mut changes = vec![];
for (a, b) in self.covered_lines() {
if a == b { continue }
let mut ls: Vec<String> = (a..=b).map(|l| self.line_text(l)).collect();
ls.sort();
changes.push((self.line_start(a)..self.at(b, usize::MAX), ls.join("\n")));
}
self.apply(changes, EditKind::Other, |_, st, n| Sel { anchor: st, head: st + n, want_col: None });
}
pub fn trim_trailing(&mut self) {
let mut changes = vec![];
for l in 0..self.lines() {
let t = self.line_text(l);
let n = t.trim_end_matches([' ', '\t']).chars().count();
let total = t.chars().count();
if n < total {
let s = self.line_start(l);
changes.push((s + n..s + total, String::new()));
}
}
let map: Vec<(usize, usize)> = changes.iter().map(|c: &(std::ops::Range<usize>, String)| (c.0.start, c.0.len())).collect();
let fix = |at: usize| at - map.iter().map(|(s, n)| if *s + *n <= at { *n } else if *s < at { at - *s } else { 0 }).sum::<usize>();
let next: Vec<Sel> = self.sels.iter().map(|s| Sel { anchor: fix(s.anchor), head: fix(s.head), want_col: None }).collect();
self.apply(changes, EditKind::Other, |_, _, _| Sel::cursor(0));
self.set_sels(next);
}
/// Adds a cursor on the line above or below each edge cursor (Kate's Ctrl+Alt+Up/Down).
pub fn add_cursor_vertical(&mut self, down: bool) {
let edge = if down { self.sels.iter().max_by_key(|s| s.head) } else { self.sels.iter().min_by_key(|s| s.head) };
let Some(s) = edge.copied() else { return };
let (l, c) = self.pos(s.head);
let want = s.want_col.unwrap_or(c);
if (down && l + 1 >= self.lines()) || (!down && l == 0) {
return;
}
let t = if down { l + 1 } else { l - 1 };
let at = self.at(t, want);
let mut v = self.sels.clone();
v.push(Sel { anchor: at, head: at, want_col: Some(want) });
self.set_sels(v);
}
/// Selects the word under the cursor, then each next occurrence (Kate's Alt+J).
pub fn select_next(&mut self) {
let last = self.sels[self.primary];
if last.is_empty() {
let r = self.word_at(last.head);
if r.is_empty() { return }
let mut v = self.sels.clone();
v[self.primary] = Sel { anchor: r.start, head: r.end, want_col: None };
return self.set_sels(v);
}
let needle = self.text(last.range());
let hay = self.rope.to_string();
let byte = self.rope.char_to_byte(last.range().end);
let hit = hay[byte..].find(&needle).map(|i| i + byte).or_else(|| hay.find(&needle));
let Some(b) = hit else { return };
let a = self.rope.byte_to_char(b);
if self.sels.iter().any(|s| s.range().start == a) { return }
let mut v = self.sels.clone();
v.push(Sel { anchor: a, head: a + needle.chars().count(), want_col: None });
self.set_sels(v);
}
/// The bracket matching one next to a position.
pub fn matching_bracket(&self, at: usize) -> Option<(usize, usize)> {
let pairs = [('(', ')'), ('[', ']'), ('{', '}')];
let probe = |i: usize| -> Option<(usize, usize)> {
let c = self.rope.get_char(i)?;
let (open, close, fwd) = pairs.iter().find_map(|(a, b)| if c == *a { Some((*a, *b, true)) } else if c == *b { Some((*a, *b, false)) } else { None })?;
let (mut depth, mut j, mut steps) = (0i32, i as isize, 0);
while j >= 0 && (j as usize) < self.len() && steps < 200_000 {
let x = self.rope.char(j as usize);
if x == open { depth += if fwd { 1 } else { -1 } }
if x == close { depth += if fwd { -1 } else { 1 } }
if depth == 0 { return Some((i, j as usize)) }
j += if fwd { 1 } else { -1 };
steps += 1;
}
None
};
probe(at).or_else(|| at.checked_sub(1).and_then(probe))
}
}
#[cfg(test)]
mod tests {
use super::*;
fn b(t: &str) -> Buffer { Buffer::new(t) }
fn text(b: &Buffer) -> String { b.rope.to_string() }
fn p() -> Prefs { Prefs::default() }
#[test]
fn typing_undoes_as_one_group() {
let mut x = b("");
for c in "hello".chars() { x.type_text(&c.to_string(), &p()); }
assert_eq!(text(&x), "hello");
assert!(x.is_modified());
x.undo();
assert_eq!(text(&x), "");
assert!(!x.is_modified());
x.redo();
assert_eq!(text(&x), "hello");
}
#[test]
fn multi_cursor_types_everywhere_and_undoes() {
let mut x = b("a\nb\nc");
x.add_cursor_vertical(true);
x.add_cursor_vertical(true);
assert_eq!(x.sels.len(), 3);
x.insert("> ", EditKind::Other);
assert_eq!(text(&x), "> a\n> b\n> c");
x.undo();
assert_eq!(text(&x), "a\nb\nc");
assert_eq!(x.sels.len(), 3);
}
#[test]
fn brackets_pair_wrap_and_type_over() {
let mut x = b("");
x.type_text("(", &p());
assert_eq!(text(&x), "()");
x.type_text(")", &p());
assert_eq!(text(&x), "()");
assert_eq!(x.head(), 2);
let mut y = b("word");
y.select_all();
y.type_text("[", &p());
assert_eq!(text(&y), "[word]");
assert_eq!(y.selected_text(), "word");
}
#[test]
fn apostrophe_after_a_word_does_not_pair() {
let mut x = b("don");
x.set_cursor(3);
x.type_text("'", &p());
assert_eq!(text(&x), "don'");
}
#[test]
fn newline_indents_and_splits_braces() {
let mut x = b(" fn a() {}");
x.set_cursor(10);
x.newline(&p());
assert_eq!(text(&x), " fn a() {\n \n }");
assert_eq!(x.pos(x.head()), (1, 6));
}
#[test]
fn multi_cursor_newline_keeps_each_cursor() {
let mut x = b("{}\n{}");
x.set_sels(vec![Sel::cursor(1), Sel::cursor(4)]);
x.newline(&p());
assert_eq!(text(&x), "{\n \n}\n{\n \n}");
assert_eq!(x.sels.len(), 2);
assert_eq!(x.pos(x.sels[0].head), (1, 4));
assert_eq!(x.pos(x.sels[1].head), (4, 4));
}
#[test]
fn backspace_clears_indent_stop_and_pairs() {
let mut x = b(" a");
x.set_cursor(8);
x.backspace(&p());
assert_eq!(text(&x), " a");
let mut y = b("()");
y.set_cursor(1);
y.backspace(&p());
assert_eq!(text(&y), "");
}
#[test]
fn comment_toggles_on_and_off() {
let mut x = b(" a\n b");
x.select_all();
x.toggle_comment(Some("//"), None);
assert_eq!(text(&x), " // a\n // b");
x.toggle_comment(Some("//"), None);
assert_eq!(text(&x), " a\n b");
}
#[test]
fn move_and_duplicate_lines() {
let mut x = b("one\ntwo\nthree");
x.set_cursor(x.at(1, 1));
x.move_lines(true);
assert_eq!(text(&x), "two\none\nthree");
assert_eq!(x.pos(x.head()), (0, 1));
x.move_lines(false);
x.move_lines(false);
assert_eq!(text(&x), "one\nthree\ntwo");
assert_eq!(x.pos(x.head()), (2, 1));
x.duplicate_lines();
assert_eq!(text(&x), "one\nthree\ntwo\ntwo");
}
#[test]
fn selection_kept_through_indent() {
let mut x = b("a\nb");
x.select_all();
x.indent(&p());
assert_eq!(text(&x), " a\n b");
x.unindent(&p());
assert_eq!(text(&x), "a\nb");
}
#[test]
fn next_occurrence_wraps() {
let mut x = b("foo bar foo");
x.set_cursor(1);
x.select_next();
assert_eq!(x.selected_text(), "foo");
x.select_next();
assert_eq!(x.sels.len(), 2);
}
#[test]
fn saved_point_survives_undo_past_it() {
let mut x = b("");
x.insert("a", EditKind::Other);
x.mark_saved();
x.insert("b", EditKind::Other);
x.undo();
assert!(!x.is_modified());
x.undo();
assert!(x.is_modified());
x.insert("c", EditKind::Other);
assert!(x.is_modified());
}
#[test]
fn matching_brackets() {
let x = b("a(b[c]d)");
assert_eq!(x.matching_bracket(1), Some((1, 7)));
assert_eq!(x.matching_bracket(8), Some((7, 1)));
}
#[test]
fn vertical_move_keeps_column() {
let mut x = b("long line\nx\nlong line");
x.set_cursor(6);
x.move_cursors(Move::Down, false);
assert_eq!(x.pos(x.head()), (1, 1));
x.move_cursors(Move::Down, false);
assert_eq!(x.pos(x.head()), (2, 6));
}
}

419
src/text/doc.rs Normal file
View file

@ -0,0 +1,419 @@
//! An open file: its buffer plus highlighting, folding, and file details.
use super::buffer::{Buffer, LineChange};
use crate::syntax::def::DefMeta;
use crate::syntax::engine::Highlighter;
use crate::syntax::{FoldEvent, Registry, Span, State};
use std::collections::{BTreeSet, HashMap};
use std::path::PathBuf;
use std::sync::Arc;
use std::time::SystemTime;
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
pub enum Eol { Lf, CrLf, Cr }
impl Eol {
pub fn label(self) -> &'static str {
match self { Eol::Lf => "LF", Eol::CrLf => "CRLF", Eol::Cr => "CR" }
}
pub fn text(self) -> &'static str {
match self { Eol::Lf => "\n", Eol::CrLf => "\r\n", Eol::Cr => "\r" }
}
}
#[derive(Clone, Default)]
pub struct LineHl {
pub spans: Arc<Vec<Span>>,
pub folds: Arc<Vec<(u32, FoldEvent)>>,
pub end: Option<Arc<State>>,
}
pub struct Doc {
pub id: u64,
pub buf: Buffer,
pub path: Option<PathBuf>,
pub language: String,
pub meta: DefMeta,
pub encoding: &'static encoding_rs::Encoding,
pub bom: bool,
pub eol: Eol,
pub mtime: Option<SystemTime>,
pub hl: Vec<LineHl>,
start_state: Option<Arc<State>>,
/// First line that may be out of date, and the line up to which it certainly is.
dirty: Option<(usize, usize)>,
pub folded: BTreeSet<usize>,
pub fold_ends: HashMap<usize, usize>,
fold_version: u64,
pub bookmarks: BTreeSet<usize>,
/// Bumped whenever the colours of any line change; the preview redraws from this.
pub hl_version: u64,
/// App time of the last save, for the tick on the tab.
pub saved_at: f64,
}
fn decode(bytes: &[u8]) -> (String, &'static encoding_rs::Encoding, bool) {
if let Some((enc, skip)) = encoding_rs::Encoding::for_bom(bytes) {
let (t, _) = enc.decode_without_bom_handling(&bytes[skip..]);
return (t.into_owned(), enc, true);
}
match std::str::from_utf8(bytes) {
Ok(s) => (s.to_string(), encoding_rs::UTF_8, false),
Err(_) => {
let (t, _) = encoding_rs::WINDOWS_1252.decode_without_bom_handling(bytes);
(t.into_owned(), encoding_rs::WINDOWS_1252, false)
}
}
}
impl Doc {
pub fn new(id: u64, text: &str, path: Option<PathBuf>, reg: &mut Registry) -> Doc {
let eol = if text.contains("\r\n") { Eol::CrLf } else if text.contains('\r') { Eol::Cr } else { Eol::Lf };
let norm = if eol == Eol::Lf { text.to_string() } else { text.replace("\r\n", "\n").replace('\r', "\n") };
let mut d = Doc {
id, buf: Buffer::new(&norm), path, language: String::new(), meta: DefMeta::default(),
encoding: encoding_rs::UTF_8, bom: false, eol, mtime: None, hl: vec![], start_state: None,
dirty: None, folded: BTreeSet::new(), fold_ends: HashMap::new(), fold_version: u64::MAX,
bookmarks: BTreeSet::new(), hl_version: 0, saved_at: f64::MIN,
};
let name = d.file_name();
let first = d.buf.line_text(0);
let lang = reg.detect(&name, &first).map(str::to_string).unwrap_or_else(|| "None".to_string());
d.set_language(&lang, reg);
d
}
pub fn open(id: u64, path: PathBuf, reg: &mut Registry) -> std::io::Result<Doc> {
let bytes = std::fs::read(&path)?;
let (text, enc, bom) = decode(&bytes);
let mtime = std::fs::metadata(&path).and_then(|m| m.modified()).ok();
let mut d = Doc::new(id, &text, Some(path), reg);
d.encoding = enc;
d.bom = bom;
d.mtime = mtime;
Ok(d)
}
/// Replaces the text with what's on disk, as an edit, so it can be undone.
pub fn reload(&mut self) -> std::io::Result<()> {
let Some(path) = self.path.clone() else { return Ok(()) };
let bytes = std::fs::read(&path)?;
let (text, enc, bom) = decode(&bytes);
let keep = self.buf.head();
self.buf.select_all();
self.buf.insert(&text.replace("\r\n", "\n").replace('\r', "\n"), super::EditKind::Other);
self.buf.set_cursor(keep);
self.encoding = enc;
self.bom = bom;
self.mtime = std::fs::metadata(&path).and_then(|m| m.modified()).ok();
// it matches the disk now, whatever it held before
self.buf.mark_saved();
Ok(())
}
pub fn file_name(&self) -> String {
self.path.as_ref().and_then(|p| p.file_name()).map(|n| n.to_string_lossy().into_owned()).unwrap_or_default()
}
pub fn title(&self) -> String {
let n = self.file_name();
if n.is_empty() { "Untitled".to_string() } else { n }
}
pub fn set_language(&mut self, name: &str, reg: &mut Registry) {
self.language = name.to_string();
self.meta = reg.meta(name);
self.start_state = reg.initial_state(name).map(Arc::new);
self.hl = vec![LineHl::default(); self.buf.lines()];
self.dirty = Some((0, self.buf.lines()));
self.hl_version += 1;
self.fold_version = u64::MAX;
}
pub fn save(&mut self) -> std::io::Result<()> {
let Some(path) = self.path.clone() else {
return Err(std::io::Error::other("no file name"));
};
let mut text = self.buf.rope.to_string();
if self.eol != Eol::Lf {
text = text.replace('\n', self.eol.text());
}
let (enc, _, _) = self.encoding.encode(&text);
let mut bytes = Vec::with_capacity(enc.len() + 3);
if self.bom && self.encoding == encoding_rs::UTF_8 {
bytes.extend_from_slice(&[0xEF, 0xBB, 0xBF]);
}
bytes.extend_from_slice(&enc);
// write beside the file, then swap, so a crash mid-save can't leave half a file
// (a symlink stays a link: the swap happens at the file it points to)
let target = std::fs::canonicalize(&path).unwrap_or_else(|_| path.clone());
let name = target.file_name().map(|n| n.to_string_lossy().into_owned()).unwrap_or_default();
let tmp = target.with_file_name(format!(".{name}.damson-tmp"));
std::fs::write(&tmp, &bytes)?;
if let Ok(m) = std::fs::metadata(&target) {
let _ = std::fs::set_permissions(&tmp, m.permissions());
}
std::fs::rename(&tmp, &target)?;
self.mtime = std::fs::metadata(&path).and_then(|m| m.modified()).ok();
self.buf.mark_saved();
Ok(())
}
/// Brings the line tables in step with edits made to the buffer.
pub fn sync_edits(&mut self) {
let changes: Vec<LineChange> = std::mem::take(&mut self.buf.changes);
for c in changes {
let end = (c.first + c.old).min(self.hl.len());
let first = c.first.min(self.hl.len());
self.hl.splice(first..end, std::iter::repeat_n(LineHl::default(), c.new));
let delta = c.new as isize - c.old as isize;
let shift = |s: &BTreeSet<usize>| -> BTreeSet<usize> {
s.iter().filter_map(|l| {
if *l < c.first { Some(*l) }
else if *l >= c.first + c.old { Some((*l as isize + delta) as usize) }
else if delta == 0 { Some(*l) } else { None }
}).collect()
};
self.folded = shift(&self.folded);
self.bookmarks = shift(&self.bookmarks);
let (a, b) = self.dirty.unwrap_or((c.first, c.first));
let b = if b >= c.first + c.old { (b as isize + delta) as usize } else { c.first + c.new };
self.dirty = Some((a.min(c.first), b.max(c.first + c.new)));
}
self.hl.resize(self.buf.lines(), LineHl::default());
}
pub fn highlight_pending(&self) -> bool {
self.dirty.is_some() && self.start_state.is_some()
}
/// Highlights onward from the first dirty line until `until`, or until `max_lines` are done,
/// stopping early when a line ends in the same state it had before.
pub fn highlight(&mut self, reg: &Registry, until: usize, max_lines: usize) {
self.sync_edits();
let Some(start_state) = self.start_state.clone() else {
self.dirty = None;
return;
};
let Some((mut line, must)) = self.dirty else { return };
let total = self.buf.lines();
let mut state: State = if line == 0 {
(*start_state).clone()
} else {
match self.hl.get(line - 1).and_then(|h| h.end.clone()) {
Some(s) => (*s).clone(),
None => (*start_state).clone(),
}
};
let mut h = Highlighter::new(&reg.compiled);
let mut done = 0;
while line < total && ((line <= until && done < 3000) || done < max_lines) {
let text = self.buf.line_text(line);
let r = h.line(&text, &mut state);
let same = self.hl[line].end.as_deref() == Some(&state);
self.hl[line] = LineHl { spans: Arc::new(r.spans), folds: Arc::new(r.folds), end: Some(Arc::new(state.clone())) };
line += 1;
done += 1;
if same && line >= must {
self.dirty = None;
self.hl_version += 1;
self.fold_version = u64::MAX;
return;
}
}
self.hl_version += 1;
self.fold_version = u64::MAX;
self.dirty = if line >= total { None } else { Some((line, must)) };
}
/// Works out which lines start a foldable range.
pub fn refresh_folds(&mut self, tab: usize) {
if self.fold_version == self.hl_version {
return;
}
self.fold_version = self.hl_version;
self.fold_ends.clear();
if self.meta.indent_fold {
self.indent_folds(tab);
} else {
let mut stack: Vec<(u32, usize)> = vec![];
for (l, h) in self.hl.iter().enumerate() {
for (_, ev) in h.folds.iter() {
match ev {
FoldEvent::Begin(r) => stack.push((*r, l)),
FoldEvent::End(r) => {
if let Some(p) = stack.iter().rposition(|s| s.0 == *r) {
let (_, start) = stack[p];
stack.truncate(p);
if l > start {
let e = self.fold_ends.entry(start).or_insert(l);
*e = (*e).max(l);
}
}
}
}
}
}
}
let keep = self.fold_ends.clone();
self.folded.retain(|l| keep.contains_key(l));
}
fn indent_folds(&mut self, tab: usize) {
let n = self.buf.lines().min(200_000);
let indent: Vec<Option<usize>> = (0..n).map(|l| {
let t = self.buf.line_text(l);
if t.trim().is_empty() { return None }
Some(t.chars().take_while(|c| c.is_whitespace()).map(|c| if c == '\t' { tab } else { 1 }).sum())
}).collect();
let mut stack: Vec<(usize, usize)> = vec![];
let mut last = 0;
for (l, i) in indent.iter().enumerate() {
let Some(i) = i else { continue };
while let Some(&(si, start)) = stack.last() {
if *i <= si {
stack.pop();
if last > start { self.fold_ends.insert(start, last); }
} else { break }
}
stack.push((*i, l));
last = l;
}
for (_, start) in stack {
if last > start { self.fold_ends.insert(start, last); }
}
}
pub fn toggle_fold(&mut self, line: usize) {
if !self.folded.remove(&line) && self.fold_ends.contains_key(&line) {
self.folded.insert(line);
}
}
/// Is this line hidden inside a folded range?
pub fn hidden_lines(&self) -> Vec<(usize, usize)> {
let mut v: Vec<(usize, usize)> = vec![];
for l in &self.folded {
let Some(e) = self.fold_ends.get(l) else { continue };
if v.last().is_some_and(|p| *l < p.1) { continue }
v.push((*l + 1, *e));
}
v
}
}
#[cfg(test)]
mod tests {
use super::*;
use crate::syntax::DefStyle;
fn style(d: &Doc, reg: &Registry, line: usize, col: u32) -> DefStyle {
let s = d.hl[line].spans.iter().find(|s| s.start <= col && col < s.end).unwrap();
reg.compiled.styles[s.style as usize].base
}
#[test]
fn opening_a_block_comment_recolours_later_lines_and_undo_restores() {
let mut reg = Registry::scan();
let mut d = Doc::new(1, "let a = 1;\nlet b = 2;\nlet c = 3;\n", Some("x.rs".into()), &mut reg);
d.highlight(&reg, 10, 1000);
assert_eq!(d.language, "Rust");
assert_eq!(style(&d, &reg, 2, 0), DefStyle::Keyword);
d.buf.set_cursor(0);
d.buf.insert("/*", crate::text::EditKind::Other);
d.highlight(&reg, 10, 1000);
assert_eq!(style(&d, &reg, 2, 0), DefStyle::Comment);
d.buf.undo();
d.highlight(&reg, 10, 1000);
assert_eq!(style(&d, &reg, 2, 0), DefStyle::Keyword);
}
#[test]
fn line_tables_track_insert_and_delete() {
let mut reg = Registry::scan();
let mut d = Doc::new(1, "a\nb\nc\n", Some("x.rs".into()), &mut reg);
d.highlight(&reg, 10, 1000);
d.buf.set_cursor(2);
d.buf.insert("x\ny\n", crate::text::EditKind::Other);
d.sync_edits();
assert_eq!(d.hl.len(), d.buf.lines());
d.buf.select_all();
d.buf.insert("", crate::text::EditKind::Other);
d.sync_edits();
assert_eq!(d.hl.len(), 1);
}
#[test]
fn folds_come_from_syntax_and_indentation() {
let mut reg = Registry::scan();
let mut d = Doc::new(1, "fn a() {\n b();\n}\n", Some("x.rs".into()), &mut reg);
d.highlight(&reg, 10, 1000);
d.refresh_folds(4);
assert_eq!(d.fold_ends.get(&0), Some(&2));
let mut p = Doc::new(2, "def a():\n b()\n c()\nd()\n", Some("x.py".into()), &mut reg);
p.highlight(&reg, 10, 1000);
p.refresh_folds(4);
assert_eq!(p.fold_ends.get(&0), Some(&2));
}
#[test]
fn saving_keeps_a_symlink_a_symlink() {
let dir = std::env::temp_dir().join(format!("damson-link-{}", std::process::id()));
std::fs::create_dir_all(&dir).unwrap();
let (real, link) = (dir.join("real.txt"), dir.join("link.txt"));
std::fs::write(&real, "old").unwrap();
std::os::unix::fs::symlink(&real, &link).unwrap();
let mut reg = Registry::scan();
let mut d = Doc::new(1, "new", Some(link.clone()), &mut reg);
d.save().unwrap();
assert!(std::fs::symlink_metadata(&link).unwrap().file_type().is_symlink());
assert_eq!(std::fs::read_to_string(&real).unwrap(), "new");
std::fs::remove_dir_all(dir).unwrap();
}
#[test]
fn reload_can_be_undone_and_reads_latin1() {
let dir = std::env::temp_dir().join(format!("damson-reload-{}", std::process::id()));
std::fs::create_dir_all(&dir).unwrap();
let p = dir.join("a.txt");
std::fs::write(&p, "one").unwrap();
let mut reg = Registry::scan();
let mut d = Doc::open(1, p.clone(), &mut reg).unwrap();
d.buf.insert("unsaved ", crate::text::EditKind::Other);
std::fs::write(&p, [b'c', b'a', b'f', 0xE9]).unwrap();
d.reload().unwrap();
assert_eq!(d.buf.rope.to_string(), "caf\u{e9}");
assert!(!d.buf.is_modified());
d.buf.undo();
assert_eq!(d.buf.rope.to_string(), "unsaved one");
std::fs::remove_dir_all(dir).unwrap();
}
#[test]
fn jumping_deep_into_a_huge_file_stays_bounded() {
let mut reg = Registry::scan();
let text = "let x = 1;\n".repeat(200_000);
let mut d = Doc::new(1, &text, Some("x.rs".into()), &mut reg);
let t = std::time::Instant::now();
d.highlight(&reg, 190_000, 0);
assert!(d.highlight_pending(), "should stop early and finish in the background");
assert!(t.elapsed().as_millis() < 500, "took {:?}", t.elapsed());
}
#[test]
fn save_round_trips_crlf() {
let dir = std::env::temp_dir().join(format!("damson-doc-{}", std::process::id()));
std::fs::create_dir_all(&dir).unwrap();
let p = dir.join("a.txt");
std::fs::write(&p, "one\r\ntwo\r\n").unwrap();
let mut reg = Registry::scan();
let mut d = Doc::open(1, p.clone(), &mut reg).unwrap();
assert_eq!(d.eol, Eol::CrLf);
d.buf.set_cursor(0);
d.buf.insert("z", crate::text::EditKind::Other);
d.save().unwrap();
assert_eq!(std::fs::read_to_string(&p).unwrap(), "zone\r\ntwo\r\n");
assert!(!d.buf.is_modified());
std::fs::remove_dir_all(dir).unwrap();
}
}

6
src/text/mod.rs Normal file
View file

@ -0,0 +1,6 @@
pub mod buffer;
pub mod commands;
pub mod doc;
pub use buffer::{Buffer, EditKind, Sel};
pub use doc::Doc;

268
src/theme.rs Normal file
View file

@ -0,0 +1,268 @@
//! Material You colours: taken from Caelestia's scheme, or built from a seed in OKLCH space
//! (tone == CIE L*). Also picks the colours code is drawn in.
use crate::config::Settings;
use crate::syntax::DefStyle;
use eframe::egui::Color32;
use std::path::PathBuf;
fn srgb_to_lin(c: f64) -> f64 {
if c <= 0.04045 { c / 12.92 } else { ((c + 0.055) / 1.055).powf(2.4) }
}
fn lin_to_srgb(c: f64) -> f64 {
if c <= 0.0031308 { 12.92 * c } else { 1.055 * c.powf(1.0 / 2.4) - 0.055 }
}
pub fn rgb_to_oklch(c: Color32) -> (f64, f64, f64) {
let (r, g, b) = (srgb_to_lin(c.r() as f64 / 255.0), srgb_to_lin(c.g() as f64 / 255.0), srgb_to_lin(c.b() as f64 / 255.0));
let l = (0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b).cbrt();
let m = (0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b).cbrt();
let s = (0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b).cbrt();
let ll = 0.2104542553 * l + 0.7936177850 * m - 0.0040720468 * s;
let a = 1.9779984951 * l - 2.4285922050 * m + 0.4505937099 * s;
let bb = 0.0259040371 * l + 0.7827717662 * m - 0.8086757660 * s;
(ll, a.hypot(bb), bb.atan2(a).to_degrees().rem_euclid(360.0))
}
fn oklch_to_lin(l: f64, c: f64, h: f64) -> (f64, f64, f64) {
let (a, b) = (c * h.to_radians().cos(), c * h.to_radians().sin());
let l_ = (l + 0.3963377774 * a + 0.2158037573 * b).powi(3);
let m_ = (l - 0.1055613458 * a - 0.0638541728 * b).powi(3);
let s_ = (l - 0.0894841775 * a - 1.2914855480 * b).powi(3);
(
4.0767416621 * l_ - 3.3077115913 * m_ + 0.2309699292 * s_,
-1.2684380046 * l_ + 2.6097574011 * m_ - 0.3413193965 * s_,
-0.0041960863 * l_ - 0.7034186147 * m_ + 1.7076147010 * s_,
)
}
fn in_gamut(x: (f64, f64, f64)) -> bool {
[x.0, x.1, x.2].iter().all(|v| (-1e-4..=1.0001).contains(v))
}
pub fn oklch(l: f64, c: f64, h: f64) -> Color32 {
let mut rgb = oklch_to_lin(l, c, h);
if !in_gamut(rgb) {
let (mut lo, mut hi) = (0.0, c);
for _ in 0..18 {
let mid = (lo + hi) / 2.0;
if in_gamut(oklch_to_lin(l, mid, h)) { lo = mid } else { hi = mid }
}
rgb = oklch_to_lin(l, lo, h);
}
let q = |x: f64| (lin_to_srgb(x.clamp(0.0, 1.0)) * 255.0).round() as u8;
Color32::from_rgb(q(rgb.0), q(rgb.1), q(rgb.2))
}
fn tone_l(t: f64) -> f64 {
if t <= 8.0 { (t / 903.2963).cbrt() } else { (t + 16.0) / 116.0 }
}
#[derive(Clone, Copy)]
struct Tonal { h: f64, c: f64 }
impl Tonal {
fn at(&self, t: f64) -> Color32 {
oklch(tone_l(t), self.c, self.h)
}
}
pub fn mix(a: Color32, b: Color32, t: f32) -> Color32 {
let t = t.clamp(0.0, 1.0);
let l = |x: u8, y: u8| (x as f32 + (y as f32 - x as f32) * t).round() as u8;
Color32::from_rgba_unmultiplied(l(a.r(), b.r()), l(a.g(), b.g()), l(a.b(), b.b()), l(a.a(), b.a()))
}
pub fn alpha(c: Color32, a: f32) -> Color32 {
let [r, g, b, _] = c.to_srgba_unmultiplied();
Color32::from_rgba_unmultiplied(r, g, b, (a.clamp(0.0, 1.0) * 255.0).round() as u8)
}
pub fn hex(s: &str) -> Option<Color32> {
let s = s.trim().trim_start_matches('#');
if s.len() != 6 {
return None;
}
let v = u32::from_str_radix(s, 16).ok()?;
Some(Color32::from_rgb((v >> 16) as u8, (v >> 8) as u8, v as u8))
}
#[derive(Clone)]
pub struct Theme {
pub dark: bool,
pub primary: Color32, pub on_primary: Color32,
pub primary_container: Color32, pub on_primary_container: Color32,
pub secondary: Color32,
pub secondary_container: Color32, pub on_secondary_container: Color32,
pub tertiary: Color32,
pub tertiary_container: Color32, pub on_tertiary_container: Color32,
pub error: Color32, pub on_error: Color32,
pub surface: Color32,
pub lowest: Color32, pub low: Color32, pub container: Color32, pub high: Color32, pub highest: Color32,
pub on_surface: Color32, pub on_variant: Color32,
pub outline: Color32, pub outline_variant: Color32,
pub syntax: [Color32; 31],
pub ansi: [Color32; 16],
/// Hues used for added/changed/removed marks.
pub added: Color32, pub changed: Color32, pub removed: Color32,
}
fn caelestia_path() -> PathBuf {
dirs::state_dir().unwrap_or_else(|| PathBuf::from(".")).join("caelestia/scheme.json")
}
fn kde_accent() -> (Option<Color32>, Option<bool>) {
let Some(p) = dirs::config_dir().map(|d| d.join("kdeglobals")) else { return (None, None) };
let Ok(txt) = std::fs::read_to_string(p) else { return (None, None) };
let parse = |s: &str| -> Option<Color32> {
let v: Vec<u8> = s.split(',').take(3).filter_map(|x| x.trim().parse().ok()).collect();
(v.len() == 3).then(|| Color32::from_rgb(v[0], v[1], v[2]))
};
let (mut sec, mut accent, mut sel, mut win) = (String::new(), None, None, None);
for line in txt.lines() {
if let Some(s) = line.trim().strip_prefix('[').and_then(|l| l.strip_suffix(']')) {
sec = s.to_string();
} else if let Some((k, v)) = line.split_once('=') {
match (sec.as_str(), k.trim()) {
("General", "AccentColor") => accent = parse(v),
("Colors:Selection", "BackgroundNormal") => sel = parse(v),
("Colors:Window", "BackgroundNormal") => win = parse(v),
_ => {}
}
}
}
(accent.or(sel), win.map(|w| rgb_to_oklch(w).0 < 0.6))
}
/// Seed colour and dark flag from Caelestia's current scheme.
fn caelestia_seed() -> Option<(Color32, bool)> {
let v: serde_json::Value = serde_json::from_slice(&std::fs::read(caelestia_path()).ok()?).ok()?;
let seed = hex(v["colours"]["primary"].as_str()?)?;
Some((seed, v["mode"].as_str() != Some("light")))
}
/// Something that changes when the desktop's colours do.
pub fn source_stamp() -> Option<std::time::SystemTime> {
let a = std::fs::metadata(caelestia_path()).ok().and_then(|m| m.modified().ok());
let b = dirs::config_dir().and_then(|d| std::fs::metadata(d.join("kdeglobals")).ok()).and_then(|m| m.modified().ok());
a.max(b)
}
impl Theme {
pub fn build(s: &Settings) -> Theme {
let (kde_seed, kde_dark) = kde_accent();
let cael = caelestia_seed();
let fallback = Color32::from_rgb(0x7f, 0x5f, 0xc4);
let custom = hex(&s.custom_color);
let (seed, sys_dark) = match s.color_source.as_str() {
"custom" => (custom.unwrap_or(fallback), cael.map(|c| c.1).or(kde_dark)),
"kde" => (kde_seed.unwrap_or(fallback), kde_dark),
"caelestia" => (cael.map(|c| c.0).or(kde_seed).unwrap_or(fallback), cael.map(|c| c.1)),
_ => (cael.map(|c| c.0).or(kde_seed).unwrap_or(fallback), cael.map(|c| c.1).or(kde_dark)),
};
let dark = match s.mode.as_str() { "dark" => true, "light" => false, _ => sys_dark.unwrap_or(true) };
Self::from_seed(seed, dark, &s.scheme)
}
pub fn from_seed(seed: Color32, dark: bool, scheme: &str) -> Theme {
let (_, sc, sh) = rgb_to_oklch(seed);
let (pc, sec_c, ter_c, ter_shift, neutral_c) = match scheme {
"vibrant" => (sc.clamp(0.13, 0.19), 0.08, 0.11, 45.0, 0.022),
"expressive" => (sc.clamp(0.10, 0.16), 0.07, 0.12, 130.0, 0.026),
"mono" => (0.012, 0.008, 0.012, 0.0, 0.004),
_ => (sc.clamp(0.085, 0.15), 0.04, 0.075, 60.0, 0.014),
};
let p = Tonal { h: sh, c: pc };
let sec = Tonal { h: sh, c: sec_c };
let ter = Tonal { h: (sh + ter_shift) % 360.0, c: ter_c };
let err = Tonal { h: 25.0, c: 0.17 };
let n = Tonal { h: sh, c: neutral_c };
let nv = Tonal { h: sh, c: (neutral_c * 1.8).max(0.016) };
let d = |dk: f64, lt: f64| if dark { dk } else { lt };
// code colours: fixed hue families pulled a little towards the seed so they sit in the scheme
let tone = d(82.0, 38.0);
let chroma = if scheme == "mono" { 0.02 } else if scheme == "vibrant" { 0.135 } else { 0.105 };
let pull = |h: f64| {
let delta = (sh - h + 540.0).rem_euclid(360.0) - 180.0;
h + delta * 0.14
};
let hue = |h: f64, t: f64, c: f64| oklch(tone_l(t), chroma * c, pull(h));
let main = n.at(d(90.0, 14.0));
let dim = nv.at(d(62.0, 48.0));
let key = p.at(d(80.0, 40.0));
let ctl = Tonal { h: (sh + 300.0) % 360.0, c: pc.max(0.1) }.at(d(80.0, 40.0));
let func = hue(235.0, tone + d(3.0, 0.0), 1.0);
let typ = ter.at(d(82.0, 38.0));
let string = hue(145.0, tone, 1.0);
let special = hue(175.0, tone, 1.0);
let number = hue(60.0, tone, 1.1);
let constant = hue(30.0, tone, 1.1);
let prep = hue(95.0, tone, 1.0);
let warn = hue(85.0, tone, 1.3);
let attr = hue(350.0, tone, 0.9);
let mut syntax = [main; 31];
for st in DefStyle::ALL {
use DefStyle::*;
syntax[st as usize] = match st {
Normal | Variable | Others => main,
Keyword => key, ControlFlow => ctl, Function => func, Operator => nv.at(d(78.0, 36.0)),
BuiltIn | Extension => func, Preprocessor | Import => prep, Attribute | Annotation => attr,
Char | SpecialChar | SpecialString => special, String | VerbatimString => string,
DataType => typ, DecVal | BaseN | Float => number, Constant => constant,
Comment | Documentation | CommentVar | RegionMarker => dim,
Information => func, Warning => warn, Alert => constant, Error => err.at(d(80.0, 40.0)),
};
}
let a = |h: f64, t: f64| oklch(tone_l(t), 0.12, pull(h));
let (lo, hi) = (d(72.0, 42.0), d(84.0, 54.0));
let ansi = [
n.at(d(24.0, 22.0)), a(25.0, lo), a(145.0, lo), a(85.0, lo), a(250.0, lo), a(320.0, lo), a(195.0, lo), n.at(d(82.0, 70.0)),
n.at(d(46.0, 44.0)), a(25.0, hi), a(145.0, hi), a(85.0, hi), a(250.0, hi), a(320.0, hi), a(195.0, hi), n.at(d(96.0, 92.0)),
];
Theme {
dark,
primary: p.at(d(80.0, 40.0)), on_primary: p.at(d(20.0, 100.0)),
primary_container: p.at(d(30.0, 90.0)), on_primary_container: p.at(d(90.0, 10.0)),
secondary: sec.at(d(80.0, 40.0)),
secondary_container: sec.at(d(30.0, 90.0)), on_secondary_container: sec.at(d(90.0, 10.0)),
tertiary: ter.at(d(80.0, 40.0)),
tertiary_container: ter.at(d(30.0, 90.0)), on_tertiary_container: ter.at(d(90.0, 10.0)),
error: err.at(d(80.0, 40.0)), on_error: err.at(d(20.0, 100.0)),
surface: n.at(d(6.0, 98.0)),
lowest: n.at(d(4.0, 100.0)), low: n.at(d(10.0, 96.0)), container: n.at(d(12.0, 94.0)),
high: n.at(d(17.0, 92.0)), highest: n.at(d(22.0, 90.0)),
on_surface: n.at(d(90.0, 10.0)), on_variant: nv.at(d(80.0, 30.0)),
outline: nv.at(d(60.0, 50.0)), outline_variant: nv.at(d(30.0, 80.0)),
syntax, ansi,
added: hue(145.0, d(74.0, 48.0), 1.3), changed: hue(235.0, d(74.0, 48.0), 1.3), removed: err.at(d(70.0, 50.0)),
}
}
}
#[cfg(test)]
mod tests {
use super::*;
fn contrast(a: Color32, b: Color32) -> f64 {
let lum = |c: Color32| 0.2126 * srgb_to_lin(c.r() as f64 / 255.0) + 0.7152 * srgb_to_lin(c.g() as f64 / 255.0) + 0.0722 * srgb_to_lin(c.b() as f64 / 255.0);
let (x, y) = (lum(a), lum(b));
(x.max(y) + 0.05) / (x.min(y) + 0.05)
}
#[test]
fn code_stays_readable_on_every_scheme() {
for seed in ["#7f5fc4", "#d0485e", "#3f9c6b", "#c8a020", "#2b7fd4"] {
for dark in [true, false] {
for sc in ["tonal", "vibrant", "expressive", "mono"] {
let t = Theme::from_seed(hex(seed).unwrap(), dark, sc);
for st in DefStyle::ALL {
let c = contrast(t.syntax[st as usize], t.low);
assert!(c >= 3.0, "{seed} dark={dark} {sc} {st:?} contrast {c:.2}");
}
}
}
}
}
}

75
src/ui/commands.rs Normal file
View file

@ -0,0 +1,75 @@
//! Everything the app can be told to do, for shortcuts, menus and the command palette.
#[derive(Clone, Debug, PartialEq)]
pub enum Cmd {
New, Open, OpenFolder, Save, SaveAs, SaveAll, CloseTab, ReopenClosed, Reload, Quit,
Undo, Redo, Cut, Copy, Paste, SelectAll,
Comment, DuplicateLines, DeleteLines, MoveLinesUp, MoveLinesDown, JoinLines, Indent, Unindent,
Upper, Lower, Capitalize, SortLines, TrimTrailing, CursorAbove, CursorBelow, SelectNext,
Find, Replace, FindInFiles, GotoLine, Palette, QuickOpen, Languages, Symbols,
ToggleTerminal, NewTerminal, RunFile, TerminalHere,
ToggleSidebar, Side(usize), SplitRight, SplitDown, CloseSplit, FocusNextPane,
Zen, ToggleWrap, ToggleWhitespace, ToggleNumbers, TogglePreview, ToggleLens, ZoomIn, ZoomOut, ZoomReset,
FoldHere, FoldAll, UnfoldAll, ToggleBookmark, NextBookmark, PrevBookmark,
GotoDefinition, Hover, Complete, NextProblem,
ToggleDark, Settings, About,
NextTab, PrevTab, TabAt(usize),
GitRefresh,
}
pub struct Entry {
pub cmd: Cmd,
pub label: &'static str,
pub ic: &'static str,
pub keys: &'static str,
}
macro_rules! e {
($c:expr, $l:literal, $i:literal, $k:literal) => { Entry { cmd: $c, label: $l, ic: $i, keys: $k } };
}
pub fn all() -> Vec<Entry> {
use Cmd::*;
vec![
e!(New, "New file", "add", "Ctrl+N"), e!(Open, "Open file…", "folder_open", "Ctrl+O"),
e!(OpenFolder, "Open folder…", "folder", "Ctrl+Shift+O"), e!(Save, "Save", "save", "Ctrl+S"),
e!(SaveAs, "Save as…", "save_as", "Ctrl+Shift+S"), e!(SaveAll, "Save all", "save", "Ctrl+L"),
e!(CloseTab, "Close tab", "close", "Ctrl+W"), e!(ReopenClosed, "Reopen closed tab", "history", "Ctrl+Shift+T"),
e!(Reload, "Reload from disk", "refresh", "F5"), e!(Quit, "Quit", "close", "Ctrl+Q"),
e!(Undo, "Undo", "undo", "Ctrl+Z"), e!(Redo, "Redo", "redo", "Ctrl+Y"),
e!(Cut, "Cut", "content_cut", "Ctrl+X"), e!(Copy, "Copy", "content_copy", "Ctrl+C"),
e!(Paste, "Paste", "content_paste", "Ctrl+V"), e!(SelectAll, "Select all", "select_all", "Ctrl+A"),
e!(Comment, "Toggle comment", "code", "Ctrl+/"), e!(DuplicateLines, "Duplicate lines", "content_copy", "Ctrl+Alt+Shift+Down"),
e!(DeleteLines, "Delete lines", "delete", "Ctrl+K"), e!(MoveLinesUp, "Move lines up", "arrow_upward", "Ctrl+Shift+Up"),
e!(MoveLinesDown, "Move lines down", "arrow_downward", "Ctrl+Shift+Down"), e!(JoinLines, "Join lines", "merge", "Ctrl+J"),
e!(Indent, "Indent", "format_indent_increase", "Tab"), e!(Unindent, "Unindent", "format_align_left", "Shift+Tab"),
e!(Upper, "Uppercase", "text_fields", "Ctrl+U"), e!(Lower, "Lowercase", "text_fields", "Ctrl+Shift+U"),
e!(Capitalize, "Capitalize", "text_fields", "Ctrl+Alt+U"), e!(SortLines, "Sort lines", "swap_vert", ""),
e!(TrimTrailing, "Trim trailing spaces", "format_align_left", ""),
e!(CursorAbove, "Add cursor above", "keyboard_arrow_up", "Ctrl+Alt+Up"), e!(CursorBelow, "Add cursor below", "keyboard_arrow_down", "Ctrl+Alt+Down"),
e!(SelectNext, "Select next occurrence", "select_all", "Alt+J"),
e!(Find, "Find", "search", "Ctrl+F"), e!(Replace, "Find and replace", "find_replace", "Ctrl+R"),
e!(FindInFiles, "Find in files", "manage_search", "Ctrl+Shift+F"), e!(GotoLine, "Go to line", "tag", "Ctrl+G"),
e!(Palette, "Command palette", "keyboard_command_key", "Ctrl+Shift+P"), e!(QuickOpen, "Quick open file", "description", "Ctrl+P"),
e!(Languages, "Change language", "language", ""), e!(Symbols, "Go to symbol", "data_object", "Ctrl+Shift+R"),
e!(ToggleTerminal, "Show or hide terminal", "terminal", "F4"), e!(NewTerminal, "New terminal", "add", "Ctrl+Shift+`"),
e!(RunFile, "Run this file in the terminal", "play_arrow", "Ctrl+F5"), e!(TerminalHere, "Terminal at this file", "terminal", ""),
e!(ToggleSidebar, "Show or hide side panel", "view_sidebar", "Ctrl+B"),
e!(Side(0), "Files", "folder", "Alt+1"), e!(Side(1), "Search", "search", "Alt+2"), e!(Side(2), "Outline", "account_tree", "Alt+3"),
e!(Side(3), "Git", "commit", "Alt+4"), e!(Side(4), "Problems", "error", "Alt+5"),
e!(SplitRight, "Split right", "vertical_split", "Ctrl+Shift+L"), e!(SplitDown, "Split down", "splitscreen", ""),
e!(CloseSplit, "Close split", "close_fullscreen", ""), e!(FocusNextPane, "Next split", "tab", "Alt+Tab"),
e!(Zen, "Zen mode", "fullscreen", "F11"), e!(ToggleWrap, "Word wrap", "wrap_text", "F10"),
e!(ToggleWhitespace, "Show whitespace", "visibility", ""), e!(ToggleNumbers, "Line numbers", "looks_one", "F11+Shift"),
e!(TogglePreview, "Scrolling preview", "map", ""), e!(ToggleLens, "Preview lens", "manage_search", ""),
e!(ZoomIn, "Larger text", "add", "Ctrl+="), e!(ZoomOut, "Smaller text", "remove", "Ctrl+-"), e!(ZoomReset, "Default text size", "text_fields", "Ctrl+0"),
e!(FoldHere, "Fold or unfold here", "unfold_less", "Ctrl+Shift+-"), e!(FoldAll, "Fold everything", "unfold_less", "Ctrl+Shift+["),
e!(UnfoldAll, "Unfold everything", "unfold_more", "Ctrl+Shift+]"),
e!(ToggleBookmark, "Toggle bookmark", "bookmark_add", "Ctrl+Shift+B"), e!(NextBookmark, "Next bookmark", "bookmark", "Alt+PageDown"), e!(PrevBookmark, "Previous bookmark", "bookmark", "Alt+PageUp"),
e!(GotoDefinition, "Go to definition", "arrow_forward", "F12"), e!(Hover, "Show symbol info", "info", "Ctrl+I"),
e!(Complete, "Show completions", "code", "Ctrl+Space"), e!(NextProblem, "Next problem", "warning", "F8"),
e!(ToggleDark, "Switch light or dark", "contrast", ""), e!(Settings, "Settings", "settings", "Ctrl+,"), e!(About, "About Damson", "info", ""),
e!(NextTab, "Next tab", "chevron_right", "Ctrl+Tab"), e!(PrevTab, "Previous tab", "chevron_left", "Ctrl+Shift+Tab"),
e!(GitRefresh, "Refresh git status", "sync", ""),
]
}

639
src/ui/editor.rs Normal file
View file

@ -0,0 +1,639 @@
//! The text surface: gutter, code, selections and carets, all drawn by hand. Scroll position, the
//! current-line bubble and the caret are springs, so nothing here ever jumps.
use super::morph::{self, Morph};
use super::{fonts, widgets::*};
use crate::app::{App, Pane};
use crate::motion::{self, spring, Preset, Spring};
use crate::syntax::Registry;
use crate::text::commands::{Move, Prefs};
use crate::text::{Doc, EditKind, Sel};
use crate::theme::{alpha, Theme};
use eframe::egui::{self, pos2, text::LayoutJob, vec2, Color32, Event, FontId, Key, Modifiers, PointerButton, Pos2, Rect, Sense, TextFormat, Ui};
use std::sync::Arc;
use unicode_width::UnicodeWidthChar;
const CARET: Preset = Preset { stiffness: 1700.0, damping: 0.78 };
const SCROLL: Preset = Preset { stiffness: 520.0, damping: 1.0 };
/// Visual rows, when wrapping or folding make them differ from lines.
#[derive(Default)]
pub struct Rows {
key: (u64, u64, usize, usize),
/// (line, first char column) of each row; `None` means rows and lines are the same.
map: Option<Arc<Vec<(u32, u32)>>>,
}
#[derive(Clone, Copy, PartialEq, Debug)]
pub struct Metrics {
pub cw: f32,
pub lh: f32,
pub font: f32,
}
pub struct Tab {
pub doc: u64,
pub scroll: Spring,
pub scroll_x: f32,
pub caret: [Spring; 2],
pub rows: Rows,
pub beacon: Option<(usize, f64)>,
pub block_anchor: Option<Pos2>,
pub click: (f64, usize, u8),
pub drag_word: Option<std::ops::Range<usize>>,
pub born: f64,
}
impl Tab {
pub fn new(doc: u64, now: f64) -> Tab {
Tab { doc, scroll: Spring::new(0.0), scroll_x: 0.0, caret: [Spring::new(0.0), Spring::new(0.0)], rows: Rows::default(), beacon: None, block_anchor: None, click: (0.0, 0, 0), drag_word: None, born: now }
}
}
pub fn cell_width(c: char, x: usize, tab: usize) -> usize {
if c == '\t' { tab - x % tab } else { c.width().unwrap_or(0).max(if c.is_control() { 0 } else { 1 }) }
}
/// Screen cells before char column `col` of `line`.
pub fn vis_col(line: &str, col: usize, tab: usize) -> usize {
let mut x = 0;
for c in line.chars().take(col) {
x += cell_width(c, x, tab);
}
x
}
/// The char column nearest to `cells` screen cells into `line`.
pub fn col_at(line: &str, cells: f32, tab: usize) -> usize {
let mut x = 0;
for (i, c) in line.chars().enumerate() {
let w = cell_width(c, x, tab);
if (x as f32 + w as f32 / 2.0) > cells {
return i;
}
x += w;
}
line.chars().count()
}
/// Builds the coloured text of part of a line, with tabs opened out into spaces.
pub fn line_job(doc: &Doc, reg: &Registry, t: &Theme, line: usize, cols: (usize, usize), font: &FontId, tab: usize, ws: bool) -> LayoutJob {
let text = doc.buf.line_text(line);
let spans: &[crate::syntax::Span] = doc.hl.get(line).map(|h| h.spans.as_slice()).unwrap_or(&[]);
let mut job = LayoutJob::default();
job.wrap.max_width = f32::INFINITY;
let normal = t.syntax[0];
let (mut si, mut x, mut byte) = (0, 0usize, 0u32);
let mut run = String::new();
let mut cur: Option<(Color32, bool, bool)> = None;
let flush = |job: &mut LayoutJob, run: &mut String, st: Option<(Color32, bool, bool)>| {
if run.is_empty() { return }
let (color, italics, underline) = st.unwrap_or((normal, false, false));
let fmt = TextFormat { font_id: font.clone(), color, italics, underline: if underline { egui::Stroke::new(1.0, color) } else { egui::Stroke::NONE }, ..Default::default() };
job.append(run, 0.0, fmt);
run.clear();
};
for (i, c) in text.chars().enumerate() {
let w = cell_width(c, x, tab);
if i >= cols.0 && i < cols.1 {
while si < spans.len() && spans[si].end <= byte { si += 1 }
let style = spans.get(si).filter(|s| s.start <= byte).and_then(|s| reg.compiled.styles.get(s.style as usize));
let st = match style {
Some(s) => (t.syntax[s.base as usize], s.italic.unwrap_or(matches!(s.base, crate::syntax::DefStyle::Comment | crate::syntax::DefStyle::Documentation)), s.underline),
None => (normal, false, false),
};
if cur != Some(st) {
flush(&mut job, &mut run, cur);
cur = Some(st);
}
if c == '\t' {
run.extend(std::iter::repeat_n(' ', w));
} else if ws && c == ' ' {
run.push('·');
} else {
run.push(c);
}
}
x += w;
byte += c.len_utf8() as u32;
}
flush(&mut job, &mut run, cur);
job
}
impl Rows {
fn refresh(&mut self, doc: &Doc, wrap: usize, tab: usize) {
let folds = doc.folded.iter().fold(doc.folded.len() as u64, |h, l| h.wrapping_mul(31).wrapping_add(*l as u64));
let key = (doc.buf.version, folds, wrap, tab);
if self.key == key {
return;
}
self.key = key;
if wrap == 0 && doc.folded.is_empty() {
self.map = None;
return;
}
let hidden = doc.hidden_lines();
let mut v = Vec::with_capacity(doc.buf.lines());
let (mut h, mut l, total) = (0, 0, doc.buf.lines());
while l < total {
if h < hidden.len() && l >= hidden[h].0 {
l = hidden[h].1 + 1;
h += 1;
continue;
}
v.push((l as u32, 0));
if wrap > 0 && doc.buf.rope.line(l).len_chars() > wrap / 2 {
// long-line break at a word gap where one is close enough
let text = doc.buf.line_text(l);
let (mut x, mut last_gap, mut start) = (0, 0, 0);
for (i, c) in text.chars().enumerate() {
let w = cell_width(c, x, tab);
if x + w > wrap {
let cut = if last_gap > start + wrap / 3 { last_gap } else { i };
v.push((l as u32, cut as u32));
start = cut;
x = text.chars().skip(cut).take(i - cut).fold(0, |a, ch| a + cell_width(ch, a, tab));
}
if c == ' ' { last_gap = i + 1 }
x += w;
}
}
l += 1;
}
self.map = Some(Arc::new(v));
}
pub fn count(&self, doc: &Doc) -> usize {
self.map.as_ref().map_or(doc.buf.lines(), |m| m.len())
}
/// (line, first column) of a row.
pub fn row(&self, r: usize) -> (usize, usize) {
match &self.map {
Some(m) => m.get(r).map_or((usize::MAX, 0), |x| (x.0 as usize, x.1 as usize)),
None => (r, 0),
}
}
/// The last column shown in a row (exclusive).
fn row_end(&self, r: usize, doc: &Doc) -> usize {
let (l, _) = self.row(r);
match self.map.as_ref().and_then(|m| m.get(r + 1)) {
Some(n) if n.0 as usize == l => n.1 as usize,
_ => doc.buf.line_len(l),
}
}
pub fn row_of(&self, line: usize, col: usize) -> usize {
match &self.map {
None => line,
Some(m) => m.partition_point(|x| (x.0 as usize, x.1 as usize) <= (line, col)).saturating_sub(1),
}
}
}
fn prefs(a: &App) -> Prefs {
Prefs { tab_width: a.s.tab_width, spaces: a.s.spaces, auto_close: a.s.auto_close }
}
impl App {
pub fn metrics(&self, ui: &Ui) -> Metrics {
let font = self.s.font_size;
let id = fonts::mono(font);
let cw = ui.fonts_mut(|f| f.glyph_width(&id, 'M'));
Metrics { cw, lh: (font * 1.55).round(), font }
}
/// Draws one open tab of a pane in `rect`.
pub fn editor(&mut self, ui: &mut Ui, pane: usize, rect: Rect) {
let m = self.metrics(ui);
let t = self.t.clone();
let id = self.pane_focus_id(pane);
let Some(doc_id) = self.panes[pane].tabs.get(self.panes[pane].active).map(|x| x.doc) else { return };
let digits = self.docs.get(&doc_id).map_or(3, |d| d.buf.lines().to_string().len().max(3));
let gutter = if self.s.line_numbers { digits as f32 * m.cw * 0.92 + 42.0 } else { 34.0 };
let code = Rect::from_min_max(pos2(rect.left() + gutter, rect.top()), rect.max);
let wrap = if self.s.word_wrap { ((code.width() - 24.0) / m.cw).max(20.0) as usize } else { 0 };
let tab_w = self.s.tab_width;
let (rect_h, resp) = (rect.height(), ui.interact(rect, id, Sense::click_and_drag()));
if resp.hovered() {
ui.ctx().set_cursor_icon(if ui.input(|i| i.pointer.hover_pos()).is_some_and(|p| p.x >= code.left()) { egui::CursorIcon::Text } else { egui::CursorIcon::Default });
}
if resp.clicked() || resp.drag_started() {
resp.request_focus();
self.focus_pane = pane;
}
let focused = resp.has_focus();
if focused {
ui.ctx().memory_mut(|mem| mem.set_focus_lock_filter(id, egui::EventFilter { tab: true, horizontal_arrows: true, vertical_arrows: true, escape: false }));
self.keyboard(ui, pane, m, rect_h);
}
{
let doc = self.docs.get_mut(&doc_id).unwrap();
doc.sync_edits();
doc.refresh_folds(tab_w);
let p = &mut self.panes[pane];
let tb = &mut p.tabs[p.active];
tb.rows.refresh(doc, wrap, tab_w);
}
self.pointer(ui, pane, doc_id, &resp, code, m);
// scrolling, with a small rubber band past either end
let (count, head_row) = {
let doc = &self.docs[&doc_id];
let tb = &self.panes[pane].tabs[self.panes[pane].active];
let (l, c) = doc.buf.pos(doc.buf.head());
(tb.rows.count(doc), tb.rows.row_of(l, c))
};
let max = (count as f32 * m.lh - rect.height() * 0.5).max(0.0);
let wheel = if resp.hovered() || ui.rect_contains_pointer(rect) { (crate::ui::widgets::wheel(ui), ui.input(|i| i.modifiers)) } else { (egui::Vec2::ZERO, Modifiers::NONE) };
let pending_reveal = focused && std::mem::take(&mut self.reveal);
{
let tb = { let p = &mut self.panes[pane]; let a = p.active; &mut p.tabs[a] };
if wheel.1.command {
if wheel.0.y != 0.0 {
self.s.font_size = (self.s.font_size + wheel.0.y.signum()).clamp(8.0, 40.0);
}
} else {
tb.scroll.target -= wheel.0.y * 1.6;
tb.scroll_x = (tb.scroll_x - wheel.0.x).max(0.0);
}
if tb.scroll.target < 0.0 {
tb.scroll.target = if tb.scroll.target < -60.0 { -60.0 } else { tb.scroll.target * 0.8 };
} else if tb.scroll.target > max {
tb.scroll.target = max + (tb.scroll.target - max).min(60.0) * 0.8;
}
if tb.scroll.target.abs() < 0.5 { tb.scroll.target = 0.0 }
if pending_reveal && focused {
let y = head_row as f32 * m.lh;
let (top, bot) = (tb.scroll.target + m.lh * 2.0, tb.scroll.target + rect.height() - m.lh * 3.0);
if y < top { tb.scroll.target = (y - m.lh * 2.0).max(0.0) }
else if y > bot { tb.scroll.target = y - rect.height() + m.lh * 3.0 }
}
tb.scroll.step(SCROLL);
}
let (scroll, scroll_x) = { let tb = &self.panes[pane].tabs[self.panes[pane].active]; (tb.scroll.x, tb.scroll_x) };
// make sure what's on screen, and a bit beyond, has colours
let first = (scroll / m.lh).floor().max(0.0) as usize;
let shown = (rect.height() / m.lh).ceil() as usize + 1;
let last_line = {
let tb = &self.panes[pane].tabs[self.panes[pane].active];
let d = &self.docs[&doc_id];
let r = tb.rows.row((first + shown).min(tb.rows.count(d).saturating_sub(1))).0;
r.min(d.buf.lines())
};
let doc = self.docs.get_mut(&doc_id).unwrap();
doc.highlight(&self.reg, last_line + 40, 0);
let doc = &self.docs[&doc_id];
let tb = &self.panes[pane].tabs[self.panes[pane].active];
let clip = rect.shrink2(vec2(0.0, 4.0));
let painter = ui.painter_at(clip);
let code_clip = Rect::from_min_max(pos2(code.left(), clip.top()), clip.max);
let code_p = ui.painter_at(code_clip);
let font = fonts::mono(m.font);
let y_of = |row: usize| rect.top() + 6.0 + row as f32 * m.lh - scroll;
let x0 = code.left() + 6.0 - scroll_x;
// indent guides, selections and search hits sit behind the text
let rows: Vec<(usize, (usize, usize), usize)> = (first..(first + shown).min(count)).map(|r| (r, tb.rows.row(r), tb.rows.row_end(r, doc))).collect();
let cur_line = doc.buf.pos(doc.buf.head()).0;
// the current line is a bubble that slides between lines
let bubble_y = spring(format!("cur/{pane}"), rect.top() + 6.0 + head_row as f32 * m.lh, Preset { stiffness: 1100.0, damping: 0.72 }) - scroll;
if doc.buf.sels.len() == 1 && doc.buf.sels[0].is_empty() {
let r = Rect::from_min_size(pos2(rect.left() + 6.0, bubble_y), vec2(rect.width() - 12.0, m.lh));
painter.rect_filled(r, cr(10.0), alpha(t.primary, if focused { 0.08 } else { 0.04 }));
}
for (_, (line, _), _) in &rows {
if *line >= doc.buf.lines() { continue }
}
let line_cols = |line: usize| doc.buf.line_text(line);
for s in doc.buf.sels.iter().filter(|s| !s.is_empty()) {
let r = s.range();
let (a, b) = (doc.buf.pos(r.start), doc.buf.pos(r.end));
for (row, (line, c0), c1) in &rows {
if *line < a.0 || *line > b.0 || *line >= doc.buf.lines() { continue }
let text = line_cols(*line);
let from = if *line == a.0 { a.1.max(*c0) } else { *c0 };
let to = if *line == b.0 { b.1.min(*c1) } else { *c1 };
if from > to || (*line == a.0 && a.1 > *c1) { continue }
let base = vis_col(&text, *c0, tab_w);
let xa = (vis_col(&text, from, tab_w) - base) as f32 * m.cw;
let eol = if *line < b.0 && to == *c1 { m.cw * 0.6 } else { 0.0 };
let xb = (vis_col(&text, to, tab_w) - base) as f32 * m.cw + eol;
let sr = Rect::from_min_max(pos2(x0 + xa, y_of(*row)), pos2(x0 + xb, y_of(*row) + m.lh));
code_p.rect_filled(sr, cr(5.0), alpha(t.primary, 0.3));
}
}
for (a, b, is_current) in self.find_hits_in(doc_id, doc, &rows) {
let (line, c0) = doc.buf.pos(a);
let text = doc.buf.line_text(line);
let Some(row) = rows.iter().find(|r| r.1.0 == line && r.1.1 <= c0 && c0 <= r.2) else { continue };
let base = vis_col(&text, row.1.1, tab_w);
let xa = (vis_col(&text, c0, tab_w) - base) as f32 * m.cw;
let xb = (vis_col(&text, c0 + (b - a), tab_w) - base) as f32 * m.cw;
let sr = Rect::from_min_max(pos2(x0 + xa - 1.0, y_of(row.0) + 1.0), pos2(x0 + xb + 1.0, y_of(row.0) + m.lh - 1.0));
code_p.rect_filled(sr, cr(5.0), if is_current { alpha(t.tertiary, 0.6) } else { alpha(t.tertiary, 0.24) });
}
if let Some((a, b)) = doc.buf.matching_bracket(doc.buf.head()) {
for at in [a, b] {
let (line, col) = doc.buf.pos(at);
let Some(row) = rows.iter().find(|r| r.1.0 == line && r.1.1 <= col && col < r.2) else { continue };
let text = doc.buf.line_text(line);
let x = (vis_col(&text, col, tab_w) - vis_col(&text, row.1.1, tab_w)) as f32 * m.cw;
let r = Rect::from_min_size(pos2(x0 + x - 1.0, y_of(row.0) + 1.0), vec2(m.cw + 2.0, m.lh - 2.0));
let pop = spring(format!("br/{pane}/{}", (at == a) as u8), 1.0, motion::FAST);
code_p.rect_filled(scale_rect(r, pop), cr(5.0), alpha(t.primary, 0.26));
}
}
let g_font = fonts::mono((m.font * 0.86).round());
for (row, (line, c0), c1) in &rows {
if *line >= doc.buf.lines() { continue }
let y = y_of(*row);
if *c0 == 0 {
if self.s.line_numbers {
let col = if *line == cur_line { t.primary } else { alpha(t.on_variant, 0.55) };
painter.text(pos2(rect.left() + gutter - 22.0, y + m.lh / 2.0), egui::Align2::RIGHT_CENTER, (line + 1).to_string(), g_font.clone(), col);
}
if doc.bookmarks.contains(line) {
painter.circle_filled(pos2(rect.left() + 11.0, y + m.lh / 2.0), 4.0, t.tertiary);
}
self.gutter_marks(&painter, doc, *line, pos2(rect.left() + gutter - 2.0, y), m.lh);
if doc.fold_ends.contains_key(line) {
let folded = doc.folded.contains(line);
let hover = ui.input(|i| i.pointer.hover_pos()).is_some_and(|p| rect.contains(p) && p.x < code.left() + 4.0);
let vis = if folded { 1.0 } else { spring(format!("foldv/{pane}"), hover as u8 as f32, motion::EFFECT) };
if vis > 0.01 {
let turn = spring(format!("fold/{doc_id}/{line}"), !folded as u8 as f32, motion::DEFAULT);
morph::paint(&painter, pos2(rect.left() + gutter - 12.0, y + m.lh / 2.0), 15.0, Morph::Fold, turn, alpha(t.on_variant, vis * 0.9), t.low);
}
}
}
if self.s.indent_guides && *c0 == 0 {
let text = doc.buf.line_text(*line);
let lead = vis_col(&text, text.chars().take_while(|c| *c == ' ' || *c == '\t').count(), tab_w);
let mut g = tab_w;
while g < lead {
let x = x0 + g as f32 * m.cw;
code_p.line_segment([pos2(x, y), pos2(x, y + m.lh)], egui::Stroke::new(1.0, alpha(t.outline_variant, 0.5)));
g += tab_w;
}
}
let job = line_job(doc, &self.reg, &t, *line, (*c0, *c1), &font, tab_w, self.s.show_whitespace);
let galley = ui.painter().layout_job(job);
let gy = y + (m.lh - galley.size().y) / 2.0;
code_p.galley(pos2(x0, gy), galley, t.syntax[0]);
if doc.folded.contains(line) {
let px = (doc.buf.line_len(*line) + 2) as f32 * m.cw;
let tag = Rect::from_min_size(pos2(x0 + px, y + 3.0), vec2(m.cw * 5.0, m.lh - 6.0));
code_p.rect_filled(tag, cr(tag.height() / 2.0), t.secondary_container);
let n = doc.fold_ends.get(line).map_or(0, |e| e - line);
code_p.text(tag.center(), egui::Align2::CENTER_CENTER, n.to_string(), fonts::mono(m.font * 0.75), t.on_secondary_container);
}
}
if let Some((line, born)) = tb.beacon {
let age = (ui.input(|i| i.time) - born) as f32;
if age < 0.9 {
let row = tb.rows.row_of(line, 0);
let k = 1.0 - (age / 0.9);
let r = Rect::from_min_size(pos2(rect.left() + 6.0, y_of(row)), vec2(rect.width() - 12.0, m.lh));
let grow = motion::stagger(age, 0.0, 0.35);
painter.rect_filled(r.expand2(vec2(0.0, 5.0 * (1.0 - grow))), cr(10.0), alpha(t.primary, 0.34 * k * k));
motion::keep_alive();
}
}
// carets: the primary glides, the rest are placed directly
let now = ui.input(|i| i.time);
let idle = (now - self.last_input) as f32;
let blink = if focused { if idle < 0.7 { 1.0 } else { (0.5 + 0.5 * ((idle - 0.7) * 3.6).cos()).clamp(0.0, 1.0) } } else { 0.0 };
let primary = doc.buf.primary;
let caret_at = |at: usize| -> Option<Pos2> {
let (line, col) = doc.buf.pos(at);
let row = tb.rows.row_of(line, col);
let text = doc.buf.line_text(line);
let (_, c0) = tb.rows.row(row);
let x = (vis_col(&text, col, tab_w) - vis_col(&text, c0, tab_w)) as f32 * m.cw;
Some(pos2(x, row as f32 * m.lh))
};
let positions: Vec<Option<Pos2>> = doc.buf.sels.iter().map(|s| caret_at(s.head)).collect();
for (i, p) in positions.iter().enumerate() {
let Some(p) = p else { continue };
if i != primary {
let pos = pos2(x0 + p.x, rect.top() + 6.0 + p.y - scroll);
code_p.rect_filled(Rect::from_min_size(pos, vec2(2.0, m.lh)), cr(1.0), alpha(t.primary, blink));
}
}
let target = positions.get(primary).copied().flatten();
let tb_mut = { let p = &mut self.panes[pane]; let a = p.active; &mut p.tabs[a] };
if let Some(p) = target {
tb_mut.caret[0].target = p.x;
tb_mut.caret[1].target = p.y;
let (x, y) = (tb_mut.caret[0].step(CARET), tb_mut.caret[1].step(CARET));
let speed = tb_mut.caret[0].v.abs() + tb_mut.caret[1].v.abs();
let stretch = (speed / 900.0).min(1.0);
let squash = spring(format!("caret-kick/{pane}"), 0.0, motion::FAST);
let w = 2.2 + stretch * 5.0 + squash.abs() * 3.0;
let h = m.lh * (1.0 - 0.2 * squash.abs());
let r = Rect::from_min_size(pos2(x0 + x - w / 2.0 + 1.0, rect.top() + 6.0 + y - scroll + (m.lh - h) / 2.0), vec2(w, h));
code_p.rect_filled(r, cr(w / 2.0), alpha(t.primary, blink.max(stretch)));
}
if focused && idle < 30.0 {
ui.ctx().request_repaint_after(std::time::Duration::from_millis(40));
}
}
fn keyboard(&mut self, ui: &mut Ui, pane: usize, m: Metrics, height: f32) {
let Some(doc_id) = self.panes[pane].tabs.get(self.panes[pane].active).map(|x| x.doc) else { return };
let events = ui.input(|i| i.events.clone());
let p = prefs(self);
let page = (height / m.lh) as usize;
let mut acted = false;
let mut typed = false;
for ev in events {
let doc = self.docs.get_mut(&doc_id).unwrap();
match ev {
Event::Text(s) => {
if s.chars().all(|c| !c.is_control()) {
doc.buf.type_text(&s, &p);
acted = true;
typed = true;
}
}
Event::Ime(egui::ImeEvent::Commit(s)) => {
doc.buf.insert(&s, EditKind::Typing);
acted = true;
}
Event::Paste(s) => {
doc.buf.insert(&s.replace("\r\n", "\n"), EditKind::Other);
acted = true;
}
Event::Copy => {
let t = doc.buf.selected_text();
if !t.is_empty() { ui.ctx().copy_text(t) }
}
Event::Cut => {
let t = doc.buf.selected_text();
if !t.is_empty() {
ui.ctx().copy_text(t);
doc.buf.insert("", EditKind::Other);
acted = true;
}
}
Event::Key { key, pressed: true, modifiers: md, .. } => {
let (cmd, sh, alt) = (md.command, md.shift, md.alt);
acted = true;
let mv = |doc: &mut Doc, k: Move| doc.buf.move_cursors(k, sh);
match key {
Key::ArrowLeft if !alt => mv(doc, if cmd { Move::WordLeft } else { Move::Left }),
Key::ArrowRight if !alt => mv(doc, if cmd { Move::WordRight } else { Move::Right }),
Key::ArrowUp if !cmd && !alt => mv(doc, Move::Up),
Key::ArrowDown if !cmd && !alt => mv(doc, Move::Down),
Key::Home => mv(doc, if cmd { Move::DocStart } else { Move::Home }),
Key::End => mv(doc, if cmd { Move::DocEnd } else { Move::End }),
Key::PageUp if !alt => mv(doc, Move::PageUp(page)),
Key::PageDown if !alt => mv(doc, Move::PageDown(page)),
Key::Enter if !cmd => doc.buf.newline(&p),
Key::Backspace => if cmd { doc.buf.delete_word(false) } else { doc.buf.backspace(&p) },
Key::Delete => if cmd { doc.buf.delete_word(true) } else { doc.buf.delete_forward() },
Key::Tab if !cmd => if sh { doc.buf.unindent(&p) } else { doc.buf.indent(&p) },
Key::Escape => {
let keep = doc.buf.sels[doc.buf.primary];
doc.buf.set_sels(vec![Sel::cursor(keep.head)]);
}
_ => acted = false,
}
}
_ => {}
}
}
if acted {
self.reveal = true;
self.last_input = ui.input(|i| i.time);
if typed {
motion::spring(format!("caret-kick/{pane}"), 0.0, motion::FAST);
motion::kick(format!("caret-kick/{pane}"), 4.0);
}
ui.ctx().request_repaint();
}
}
fn pointer(&mut self, ui: &mut Ui, pane: usize, doc_id: u64, resp: &egui::Response, code: Rect, m: Metrics) {
let hover = ui.input(|i| i.pointer.interact_pos());
let Some(pos) = hover else { return };
let mods = ui.input(|i| i.modifiers);
let now = ui.input(|i| i.time);
let tab_w = self.s.tab_width;
let doc = self.docs.get_mut(&doc_id).unwrap();
let p = &mut self.panes[pane];
let a = p.active;
let tb = &mut p.tabs[a];
let locate = |tb: &Tab, doc: &Doc, pos: Pos2| -> usize {
let row = ((pos.y - code.top() - 6.0 + tb.scroll.x) / m.lh).floor().max(0.0) as usize;
let (line, c0) = tb.rows.row(row.min(tb.rows.count(doc).saturating_sub(1)));
if line >= doc.buf.lines() { return doc.buf.len() }
let text = doc.buf.line_text(line);
let base = vis_col(&text, c0, tab_w);
let cells = (pos.x - code.left() - 6.0 + tb.scroll_x) / m.cw + base as f32;
doc.buf.at(line, col_at(&text, cells, tab_w))
};
if resp.contains_pointer() && ui.input(|i| i.pointer.button_pressed(PointerButton::Primary)) {
if pos.x < code.left() {
let row = ((pos.y - code.top() - 6.0 + tb.scroll.x) / m.lh).floor().max(0.0) as usize;
let (line, _) = tb.rows.row(row);
if line < doc.buf.lines() {
if doc.fold_ends.contains_key(&line) { doc.toggle_fold(line) }
else {
let at = doc.buf.at(line, 0);
doc.buf.set_cursor(at);
}
}
return;
}
let at = locate(tb, doc, pos);
let multi = if now - tb.click.0 < 0.35 && tb.click.1 == at { (tb.click.2 % 3) + 1 } else { 1 };
tb.click = (now, at, multi);
self.last_input = now;
let (line, _) = doc.buf.pos(at);
if mods.alt {
tb.block_anchor = Some(pos);
} else if mods.command {
let mut v = doc.buf.sels.clone();
v.push(Sel::cursor(at));
doc.buf.set_sels(v);
} else if mods.shift {
let s = doc.buf.sels[doc.buf.primary];
doc.buf.set_sels(vec![Sel { anchor: s.anchor, head: at, want_col: None }]);
} else {
match multi {
2 => {
let r = doc.buf.word_at(at);
tb.drag_word = Some(r.clone());
doc.buf.set_sels(vec![Sel { anchor: r.start, head: r.end, want_col: None }]);
}
3 => {
let end = if line + 1 < doc.buf.lines() { doc.buf.at(line + 1, 0) } else { doc.buf.len() };
let s = doc.buf.at(line, 0);
tb.drag_word = Some(s..end);
doc.buf.set_sels(vec![Sel { anchor: s, head: end, want_col: None }]);
}
_ => {
tb.drag_word = None;
doc.buf.set_cursor(at);
}
}
}
}
if resp.dragged_by(PointerButton::Primary) && pos.x >= code.left() - 40.0 {
if let Some(anchor) = tb.block_anchor {
// Alt-drag: one cursor per line, a block selection
let (r0, r1) = (anchor.y.min(pos.y), anchor.y.max(pos.y));
let (c0, c1) = (anchor.x, pos.x);
let top = ((r0 - code.top() - 6.0 + tb.scroll.x) / m.lh).floor().max(0.0) as usize;
let bot = ((r1 - code.top() - 6.0 + tb.scroll.x) / m.lh).floor().max(0.0) as usize;
let cell = |x: f32| (x - code.left() - 6.0 + tb.scroll_x) / m.cw;
let mut v = vec![];
for row in top..=bot.min(tb.rows.count(doc).saturating_sub(1)) {
let (line, _) = tb.rows.row(row);
let text = doc.buf.line_text(line);
let (a, b) = (doc.buf.at(line, col_at(&text, cell(c0), tab_w)), doc.buf.at(line, col_at(&text, cell(c1), tab_w)));
v.push(Sel { anchor: a, head: b, want_col: None });
}
doc.buf.set_sels(v);
} else {
let at = locate(tb, doc, pos);
if let Some(w) = tb.drag_word.clone() {
let (anchor, head) = if at < w.start { (w.end, at) } else { (w.start, at.max(w.end)) };
doc.buf.set_sels(vec![Sel { anchor, head, want_col: None }]);
} else if doc.buf.sels.len() == 1 {
let s = doc.buf.sels[0];
doc.buf.set_sels(vec![Sel { anchor: s.anchor, head: at, want_col: None }]);
}
}
// keep selecting past the edges
if pos.y < code.top() + 10.0 { tb.scroll.target -= 18.0; motion::keep_alive() }
if pos.y > code.bottom() - 10.0 { tb.scroll.target += 18.0; motion::keep_alive() }
}
if resp.drag_stopped() {
tb.block_anchor = None;
tb.drag_word = None;
}
if resp.secondary_clicked() {
let at = locate(tb, doc, pos);
if !doc.buf.sels.iter().any(|s| s.range().contains(&at)) {
doc.buf.set_cursor(at);
}
self.editor_menu(pos);
}
}
pub fn editor_scroll_of(pane: &Pane) -> f32 {
pane.tabs.get(pane.active).map_or(0.0, |t| t.scroll.x)
}
}

189
src/ui/find.rs Normal file
View file

@ -0,0 +1,189 @@
//! The find bubble: floats over the top of the editor and unfolds a replace row when asked.
use super::morph::{self, Morph};
use super::{fonts, widgets::*};
use crate::app::App;
use crate::motion::{self, spring};
use crate::text::{Doc, EditKind, Sel};
use eframe::egui::{self, pos2, vec2, Align2, Id, Key, Rect, Ui};
#[derive(Default)]
pub struct Find {
pub open: bool,
pub replace: bool,
pub query: String,
pub with: String,
pub case: bool,
pub word: bool,
pub regex: bool,
pub focus: bool,
/// Char ranges of every match, for the doc in `key.0`.
pub hits: Vec<(usize, usize)>,
pub cur: usize,
key: (u64, u64, String, u8),
pub error: bool,
}
const MAX_HITS: usize = 50_000;
impl Find {
pub fn refresh(&mut self, doc: &Doc) {
let flags = self.case as u8 | (self.word as u8) << 1 | (self.regex as u8) << 2;
let key = (doc.id, doc.buf.version, self.query.clone(), flags);
if key == self.key {
return;
}
self.key = key;
self.hits.clear();
self.error = false;
if self.query.is_empty() {
return;
}
let pat = if self.regex { self.query.clone() } else { regex::escape(&self.query) };
let pat = if self.word { format!(r"\b(?:{pat})\b") } else { pat };
let re = regex::RegexBuilder::new(&pat).case_insensitive(!self.case).multi_line(true).build();
let Ok(re) = re else { self.error = true; return };
let text = doc.buf.rope.to_string();
for m in re.find_iter(&text).take(MAX_HITS) {
if m.is_empty() { continue }
self.hits.push((doc.buf.rope.byte_to_char(m.start()), doc.buf.rope.byte_to_char(m.end())));
}
let head = doc.buf.head();
self.cur = self.hits.iter().position(|h| h.0 >= head).unwrap_or(0);
}
}
impl App {
pub fn find_hits_in(&self, doc_id: u64, doc: &Doc, rows: &[(usize, (usize, usize), usize)]) -> Vec<(usize, usize, bool)> {
if !self.find.open || self.find.key.0 != doc_id || rows.is_empty() {
return vec![];
}
let lines = doc.buf.lines();
let first = doc.buf.rope.line_to_char(rows[0].1.0.min(lines - 1));
let last_line = rows[rows.len() - 1].1.0.min(lines - 1);
let end = doc.buf.at(last_line, usize::MAX);
let a = self.find.hits.partition_point(|h| h.1 < first);
self.find.hits[a..].iter().enumerate().take_while(|(_, h)| h.0 <= end).map(|(i, h)| (h.0, h.1, a + i == self.find.cur)).collect()
}
fn find_refresh(&mut self) {
if let Some(d) = self.cur_doc_id().and_then(|i| self.docs.get(&i)) {
self.find.refresh(d);
}
}
pub fn find_step(&mut self, ctx: &egui::Context, back: bool) {
let n = self.find.hits.len();
if n == 0 {
return;
}
self.find.cur = if back { (self.find.cur + n - 1) % n } else { (self.find.cur + 1) % n };
self.find_show(ctx);
}
fn find_show(&mut self, ctx: &egui::Context) {
let Some(&(a, b)) = self.find.hits.get(self.find.cur) else { return };
if let Some(d) = self.cur_doc_mut() {
d.buf.set_sels(vec![Sel { anchor: a, head: b, want_col: None }]);
let line = d.buf.pos(a).0;
self.jump_to_line(ctx, line);
}
}
fn replace_one(&mut self, ctx: &egui::Context) {
let Some(&(a, b)) = self.find.hits.get(self.find.cur) else { return };
let with = self.find.with.clone();
if let Some(d) = self.cur_doc_mut() {
d.buf.apply(vec![(a..b, with)], EditKind::Other, |_, st, n| Sel::cursor(st + n));
}
self.find_refresh();
self.find_show(ctx);
}
fn replace_all(&mut self) {
let hits = self.find.hits.clone();
let with = self.find.with.clone();
let n = hits.len();
if let Some(d) = self.cur_doc_mut() {
let ch = hits.into_iter().map(|(a, b)| (a..b, with.clone())).collect();
d.buf.apply(ch, EditKind::Other, |_, st, n| Sel::cursor(st + n));
}
self.toast("find_replace", format!("Replaced {n} matches"));
}
pub fn find_bar(&mut self, ui: &mut Ui, card: Rect) {
let t = self.t.clone();
let k = spring("find/open", self.find.open as u8 as f32, motion::DEFAULT);
if k < 0.01 && !self.find.open {
return;
}
let rep = spring("find/rep", self.find.replace as u8 as f32, motion::DEFAULT).clamp(0.0, 1.2);
self.find_refresh();
let w = (card.width() - 150.0).clamp(300.0, 500.0);
let h = 52.0 + 46.0 * rep;
let target = Rect::from_min_size(pos2(card.right() - 108.0 - w, card.top() + 10.0), vec2(w, h));
let origin = Rect::from_center_size(pos2(target.right() - 26.0, target.top() + 26.0), vec2(44.0, 44.0));
let rect = lerp_rect(origin, target, k);
egui::Area::new(Id::unique("findbar")).order(egui::Order::Foreground).fixed_pos(rect.min).interactable(true).show(ui.ctx(), |ui| {
ui.set_clip_rect(rect.expand(30.0));
let p = ui.painter().clone();
shadow(&p, rect, 24.0, k.clamp(0.0, 1.0), t.dark);
p.rect_filled(rect, cr(24.0), t.high);
if k < 0.6 {
return;
}
let row = Rect::from_min_size(rect.min, vec2(rect.width(), 52.0));
if morph::button(ui, &t, Rect::from_center_size(pos2(rect.left() + 26.0, row.center().y), vec2(34.0, 34.0)), "find/more", Morph::Fold, self.find.replace, "Replace", t.high).clicked() {
self.find.replace = !self.find.replace;
}
let tools = 4.0 * 32.0 + 124.0;
let field = Rect::from_min_max(pos2(rect.left() + 48.0, row.top() + 9.0), pos2(rect.right() - tools, row.bottom() - 9.0));
let te = ui.put(field, egui::TextEdit::singleline(&mut self.find.query).frame(egui::Frame::NONE).hint_text("Find").font(fonts::ui(14.0)).align(Align2::LEFT_CENTER).text_color(if self.find.error { t.error } else { t.on_surface }));
if self.find.focus {
self.find.focus = false;
te.request_focus();
let mut st = egui::text_edit::TextEditState::load(ui.ctx(), te.id).unwrap_or_default();
let all = egui::text::CCursorRange::two(egui::text::CCursor::new(0), egui::text::CCursor::new(self.find.query.chars().count()));
st.cursor.set_char_range(Some(all));
st.store(ui.ctx(), te.id);
}
if te.has_focus() || te.lost_focus() {
let (enter, shift) = ui.input(|i| (i.key_pressed(Key::Enter), i.modifiers.shift));
if enter {
self.find_step(ui.ctx(), shift);
te.request_focus();
}
}
let count = if self.find.query.is_empty() { String::new() } else if self.find.hits.is_empty() { "None".to_string() } else { format!("{}/{}", self.find.cur + 1, self.find.hits.len()) };
p.text(pos2(rect.right() - tools + 52.0, row.center().y), Align2::CENTER_CENTER, count, fonts::ui(12.0), t.on_variant);
let mut x = rect.right() - 142.0;
for (key, tip, label, on) in [("find/case", "Match case", "Aa", self.find.case), ("find/word", "Whole word", "ab", self.find.word), ("find/re", "Regular expression", ".*", self.find.regex)] {
let r = Rect::from_center_size(pos2(x, row.center().y), vec2(30.0, 30.0));
let resp = icon_btn(ui, &t, r, key, "", tip, on);
p.text(r.center(), Align2::CENTER_CENTER, label, fonts::med(12.0), if on { t.on_secondary_container } else { t.on_variant });
if resp.clicked() {
match key { "find/case" => self.find.case ^= true, "find/word" => self.find.word ^= true, _ => self.find.regex ^= true }
}
x += 30.0;
}
if icon_btn(ui, &t, Rect::from_center_size(pos2(x + 2.0, row.center().y), vec2(30.0, 30.0)), "find/next", "keyboard_arrow_down", "Next (Enter)", false).clicked() { self.find_step(ui.ctx(), false) }
if morph::button(ui, &t, Rect::from_center_size(pos2(x + 32.0, row.center().y), vec2(30.0, 30.0)), "find/close", Morph::SearchClose, self.find.open, "Close (Esc)", t.high).clicked() { self.find_close(ui.ctx()) }
if rep > 0.5 {
let y = row.bottom() - 2.0;
let f2 = Rect::from_min_max(pos2(rect.left() + 48.0, y + 8.0), pos2(rect.right() - 170.0, y + 34.0));
ui.put(f2, egui::TextEdit::singleline(&mut self.find.with).frame(egui::Frame::NONE).hint_text("Replace with").font(fonts::ui(14.0)).align(Align2::LEFT_CENTER).text_color(t.on_surface));
if pill(ui, &t, Rect::from_min_size(pos2(rect.right() - 164.0, y + 6.0), vec2(74.0, 30.0)), "find/r1", "", "Replace", Tone::Tonal).clicked() { self.replace_one(ui.ctx()) }
if pill(ui, &t, Rect::from_min_size(pos2(rect.right() - 86.0, y + 6.0), vec2(74.0, 30.0)), "find/ra", "", "All", Tone::Tonal).clicked() { self.replace_all() }
}
});
if self.find.open && ui.input(|i| i.key_pressed(Key::Escape)) {
self.find_close(ui.ctx());
}
}
pub fn find_close(&mut self, ctx: &egui::Context) {
self.find.open = false;
self.find.hits.clear();
self.focus_editor(ctx);
}
}

Some files were not shown because too many files have changed in this diff Show more