web: the library checks for wasm32 (carried)

This commit is contained in:
ZacharyZhang-NY committed 2026-09-29 19:16:41 -04:00
1 parent fe467d2bfe
commit a03df0987c
44 files changed
+141 -104

No files matched your search

+5 -1
View File
@@ -11,11 +11,12 @@ Ely GPUI Component. A component library for GPUI, in light and dark.
- Codes: `qrcode` (QR) and `barcoders` (Code 128, EAN-13), both MIT OR Apache-2.0, default features off. `rqrr` 0.11 ((MIT OR Apache-2.0) AND ISC, default features off) reads QR codes from the host's frames.
- macOS extras (tray icon, Dock badge) call AppKit through `cocoa` 0.26 and `objc` 0.2, the crates gpui already links.
- Web views: `wry` 0.57 (Apache-2.0 OR MIT, default features off, macOS only) lays a child WKWebView over the window.
- Terminal: `alacritty_terminal` 0.26 (Apache-2.0, default features off) for the grid, its parser and the pseudo-terminal; `futures` carries its events.
- Terminal: `alacritty_terminal` 0.26 (Apache-2.0, default features off, native only) for the grid, its parser and the pseudo-terminal; `futures` carries its events. `vte` 0.15 (Apache-2.0 OR MIT), the parser it re-exports, reads `AnsiText`'s codes alone, so colored output builds for wasm32.
- Diffs: `similar` 3.2 (Apache-2.0) for line and word diffs and three-way merges; its `unicode` feature splits words at punctuation.
- Markdown: `pulldown-cmark` 0.13 (MIT, default features off) for CommonMark with tables, tasks, strikethrough, footnotes and math.
- Pictures: `image` 0.25 (MIT OR Apache-2.0), the crate gpui decodes with, default features off; it turns decoded frames and rims map tiles.
- Maps: Natural Earth's 110m countries (public domain). `assets/maps/countries.geojson`, trimmed by `scripts/countries.py` to an ISO code, a name and positions to 0.01°, backs `maps::WorldMap`; the gallery's tiles are cut from the same file, z0 to z3, by `scripts/tiles.py` with Pillow.
- Web: on wasm32, `web-time` 1.1 (MIT OR Apache-2.0) gives the `Instant` gpui's executor returns, std's own natively; jiff takes `js`, rust-embed `debug-embed`, similar `wasm32_web_time`.
- Gallery: `examples/gallery`. Website: `frontend/` (Vite 8, pnpm), built after the components: a home page in motion with three.js and smooth scroll, and a components page with categories on the left and the chosen component on the right, after astryx.atmeta.com and gpui-kit.com. Each component runs live from the gallery built for wasm32 through gpui_web, in an iframe, never as a screenshot. It deploys to Cloudflare through `npx wrangler`.
## Commands
@@ -23,6 +24,7 @@ Ely GPUI Component. A component library for GPUI, in light and dark.
- `cargo run --example gallery` opens the gallery. `-- --page <slug>` starts on a page.
- `cargo run --example gallery -- --capture <dir>` writes PNGs of every page, light and dark, top to bottom, then each page's scripted states, including windows the demos open. macOS only.
- `cargo run --example gallery -- --narrow 280 --capture <dir>` lays each page, header and body, at that width in a padded card and shoots it without its script, whose aims are measured at full width. Demos that set their own width run past the card.
- `RUSTC_BOOTSTRAP=1 cargo check --lib --target wasm32-unknown-unknown` checks the web build; gpui_web's `wasm_thread` needs the bootstrap, as Zed's web examples do.
- `cargo test --lib --features test-support`, `cargo clippy --all-targets --features test-support -- -D warnings`, `cargo fmt --check`. `scripts/check.sh` runs them with the house rules.
- `rm -rf target/debug/incremental` and `cargo clean -p ely-gpui-component` after each task item keep the disk lean. Cargo keeps every old build of the crate and its tests under a new hash; by T25 they had filled the disk.
- `scripts/icons.sh <lucide-name>...` adds icons. Then add a line to `IconName` in `src/primitives/icon.rs`.
@@ -173,6 +175,8 @@ Ely GPUI Component. A component library for GPUI, in light and dark.
- A component built on `lists::Tree` fills its box; the host gives it a height. A fixed-width column beside a `flex_1` one takes `flex_none`, or it shrinks.
- Editor rows read their text through `CodeEditor::row_text`: a multi-line ghost cuts its line, and the rest follows the ghost's last line.
- gpui clears `debug_bounds` each frame: a test sees an element leave as well as appear.
- Time reads `web_time::Instant`: std's compiles for wasm32 and panics in the browser. `scripts/check.sh` refuses std's in `src`.
- What cannot build for wasm32 is absent there through `cfg(not(target_family = "wasm"))`, never faked: the live terminal, `Terminal` and `Launch` with their grid, keys and search.
- The system time zone comes from `typography::format::system_zone`, which fails loud; jiff's `TimeZone::system()` falls back to UTC in silence.
- A Select with nothing to pick stays shut: disabled, it shows its placeholder; open, it fails (`media::DeviceSelector` says no device was found).
- A list opens with its cursor on the current choice: Select on the chosen row, Combobox on its value, MultiSelect on the first one ticked, SelectableList on its first selected row. A selection the owner makes, not the echo of the list's own pick, moves SelectableList's cursor there.
Generated
+5
View File
@@ -1678,6 +1678,8 @@ dependencies = [
"similar",
"smallvec",
"unicode-segmentation",
"vte",
"web-time",
"wry",
]
@@ -3119,10 +3121,12 @@ dependencies = [
"jiff-core",
"jiff-static",
"jiff-tzdb-platform",
"js-sys",
"log",
"portable-atomic",
"portable-atomic-util",
"serde_core",
"wasm-bindgen",
"windows-link 0.2.1",
]
@@ -5649,6 +5653,7 @@ checksum = "4f66ca1f7aca2474dc10c942eb22feffc897735f54cd1db90138c2fddb490987"
dependencies = [
"bstr",
"unicode-segmentation",
"web-time",
]
[[package]]
+10 -1
View File
@@ -14,7 +14,6 @@ runtime_shaders = ["gpui_platform/runtime_shaders"]
test-support = ["gpui/test-support"]
[dependencies]
alacritty_terminal = { version = "0.26", default-features = false }
anyhow = "1"
barcoders = { version = "2", default-features = false, features = ["std"] }
emojis = "0.9"
@@ -37,6 +36,16 @@ serde_json = { version = "1", features = ["preserve_order"] }
similar = { version = "3.2", default-features = false, features = ["std", "text", "inline", "unicode"] }
smallvec = "1"
unicode-segmentation = "1"
vte = { version = "0.15", default-features = false, features = ["std", "ansi"] }
web-time = "1.1"
[target.'cfg(not(target_family = "wasm"))'.dependencies]
alacritty_terminal = { version = "0.26", default-features = false }
[target.'cfg(target_family = "wasm")'.dependencies]
jiff = { version = "0.2", features = ["js"] }
rust-embed = { version = "8.12", features = ["debug-embed"] }
similar = { version = "3.2", default-features = false, features = ["wasm32_web_time"] }
[target.'cfg(target_os = "macos")'.dependencies]
block = "0.1"
+2
View File
@@ -17,4 +17,6 @@ raw=$(awk '/#\[cfg\(test\)\]/{nextfile} /(^|[^.[:alnum:]_])px\(/{print FILENAME"
[ -z "$raw" ] || { echo "raw px in components:"; echo "$raw"; fail=1; }
deferred=$(grep -rn 'deferred(' src --include='*.rs' | grep -v '^src/primitives/layer.rs' || true)
[ -z "$deferred" ] || { echo "gpui deferred outside primitives::raise:"; echo "$deferred"; fail=1; }
instant=$(grep -rnE '(^|[^_[:alnum:]])time::(Instant|\{[^}]*Instant)' src || true)
[ -z "$instant" ] || { echo "std Instant panics in the browser, use web_time::Instant:"; echo "$instant"; fail=1; }
exit $fail
+3 -1
View File
@@ -1,4 +1,6 @@
use std::time::{Duration, Instant};
use std::time::Duration;
use web_time::Instant;
use crate::motion;
+2 -1
View File
@@ -1,6 +1,6 @@
use std::{
f32::consts::{FRAC_PI_2, PI, TAU},
time::{Duration, Instant},
time::Duration,
};
use gpui::{
@@ -8,6 +8,7 @@ use gpui::{
MouseMoveEvent, ParentElement, PathBuilder, Pixels, Point, Refineable, RenderOnce,
SharedString, StatefulInteractiveElement, StyleRefinement, Styled, Window, canvas, div, point,
};
use web_time::Instant;
use super::{
axes::anchored,
+1 -2
View File
@@ -1,10 +1,9 @@
use std::time::Instant;
use gpui::{
App, Bounds, ContentMask, Div, ElementId, Entity, InteractiveElement, IntoElement,
ParentElement, PathBuilder, Pixels, Refineable, RenderOnce, StyleRefinement, Styled, Window,
canvas, div, fill, size,
};
use web_time::Instant;
use super::{
axes::beside,
+2 -4
View File
@@ -1,13 +1,11 @@
use std::{
rc::Rc,
time::{Duration, Instant},
};
use std::{rc::Rc, time::Duration};
use gpui::{
App, ElementId, Entity, FontWeight, InteractiveElement, IntoElement, MouseButton,
ParentElement, RenderOnce, SharedString, StatefulInteractiveElement, Styled, Window, div,
prelude::*, relative, transparent_black,
};
use web_time::Instant;
use super::stream::StreamingText;
use crate::{
+2 -1
View File
@@ -1,10 +1,11 @@
use std::time::{Duration, Instant};
use std::time::Duration;
use gpui::{
App, ElementId, HighlightStyle, IntoElement, ParentElement, RenderOnce, SharedString, Styled,
StyledText, Window, div,
};
use unicode_segmentation::UnicodeSegmentation;
use web_time::Instant;
use super::code::CodeBlock;
use crate::{
+2 -1
View File
@@ -1,6 +1,7 @@
use std::{rc::Rc, time::Instant};
use std::rc::Rc;
use gpui::{App, ElementId, IntoElement, ParentElement, RenderOnce, Styled, Window, div};
use web_time::Instant;
use crate::{
buttons::{ButtonVariant, IconButton},
+2 -4
View File
@@ -1,13 +1,11 @@
use std::{
rc::Rc,
time::{Duration, Instant},
};
use std::{rc::Rc, time::Duration};
use gpui::{
AnyElement, App, Div, ElementId, HoverListenerMode, InteractiveElement, IntoElement,
MouseButton, ParentElement, RenderOnce, StatefulInteractiveElement, StyleRefinement, Styled,
Task, Window, div, prelude::*, relative,
};
use web_time::Instant;
use crate::{
motion,
+2 -4
View File
@@ -1,11 +1,9 @@
use std::{
rc::Rc,
time::{Duration, Instant},
};
use std::{rc::Rc, time::Duration};
use gpui::{
App, ElementId, IntoElement, ParentElement, RenderOnce, Styled, Task, Window, div, prelude::*,
};
use web_time::Instant;
use crate::{
forms::Run,
+2 -1
View File
@@ -1,10 +1,11 @@
use std::time::{Duration, Instant};
use std::time::Duration;
use anyhow::anyhow;
use gpui::{
Context, Entity, FocusHandle, IntoElement, ParentElement, Pixels, Render, Styled,
TestAppContext, VisualTestContext, Window, div, px,
};
use web_time::Instant;
use super::{press, settle, setup, wait};
use crate::{
+2 -4
View File
@@ -1,7 +1,4 @@
use std::{
rc::Rc,
time::{Duration, Instant},
};
use std::{rc::Rc, time::Duration};
use gpui::{
Anchor, Animation, AnimationExt, AnyElement, App, ClickEvent, Context, ElementId, Entity,
@@ -9,6 +6,7 @@ use gpui::{
RenderOnce, SharedString, StatefulInteractiveElement, Styled, Task, Window, anchored, canvas,
div, point, prelude::*, relative,
};
use web_time::Instant;
use crate::{
buttons::{Button, ButtonVariant, IconButton},
+2 -4
View File
@@ -1,9 +1,7 @@
use std::{
ops::Range,
time::{Duration, Instant},
};
use std::{ops::Range, time::Duration};
use unicode_segmentation::UnicodeSegmentation;
use web_time::Instant;
pub(crate) fn prev_grapheme(text: &str, offset: usize) -> usize {
text.grapheme_indices(true)
+1 -2
View File
@@ -1,11 +1,10 @@
use std::time::Instant;
use gpui::{
Animation, AnimationExt, AnyElement, App, ElementId, Entity, FontWeight, InteractiveElement,
IntoElement, ParentElement, Pixels, RenderOnce, SharedString, StatefulInteractiveElement,
Styled, Window, canvas, div,
};
use smallvec::SmallVec;
use web_time::Instant;
use crate::{
motion,
+2 -5
View File
@@ -1,8 +1,4 @@
use std::{
cell::Cell,
rc::Rc,
time::{Duration, Instant},
};
use std::{cell::Cell, rc::Rc, time::Duration};
use gpui::{
AnyElement, App, Axis, Bounds, Canvas, Div, ElementId, EmptyView, Entity, EntityId,
@@ -11,6 +7,7 @@ use gpui::{
div, point, prelude::*,
};
use smallvec::SmallVec;
use web_time::Instant;
use super::ScrollShadow;
use crate::{motion, theme::ActiveTheme};
+2 -4
View File
@@ -1,12 +1,10 @@
use std::{
rc::Rc,
time::{Duration, Instant},
};
use std::{rc::Rc, time::Duration};
use gpui::{
AnyElement, App, ElementId, IntoElement, ParentElement, Pixels, RenderOnce, ScrollHandle,
Styled, Window, canvas, div, point, prelude::*,
};
use web_time::Instant;
use crate::{
buttons::{ButtonVariant, IconButton},
+1 -2
View File
@@ -1,10 +1,9 @@
use std::time::Instant;
use gpui::{
Animation, AnimationExt, AnyElement, App, ElementId, InteractiveElement, IntoElement,
ParentElement, RenderOnce, Styled, Window, div,
};
use smallvec::SmallVec;
use web_time::Instant;
use crate::{motion, theme::ActiveTheme};
+1
View File
@@ -65,6 +65,7 @@ pub fn init(cx: &mut App) {
]);
forms::bind_keys(cx);
editor::bind_keys(cx);
#[cfg(not(target_family = "wasm"))]
terminal::bind_keys(cx);
documents::bind_keys(cx);
}
+2 -4
View File
@@ -1,12 +1,10 @@
use std::{
rc::Rc,
time::{Duration, Instant},
};
use std::{rc::Rc, time::Duration};
use gpui::{
App, Div, ElementId, InteractiveElement, IntoElement, MouseButton, ParentElement, RenderOnce,
ScrollHandle, SharedString, StatefulInteractiveElement, StyleRefinement, Styled, Window, div,
};
use web_time::Instant;
use super::ListItem;
use crate::primitives::tab_stop;
+2 -1
View File
@@ -1,10 +1,11 @@
use std::{rc::Rc, time::Instant};
use std::rc::Rc;
use gpui::{
AnyElement, App, ElementId, InteractiveElement, IntoElement, MouseButton, ParentElement,
Pixels, RenderOnce, ScrollDelta, SharedString, StatefulInteractiveElement, Styled, TouchPhase,
Window, div, prelude::*,
};
use web_time::Instant;
use crate::{
data_display::Tone,
+1 -1
View File
@@ -26,7 +26,7 @@ const JUMP: f64 = 10.0;
/// When the pointer last moved over the player, and whether a wake is set to hide the controls.
struct Watch {
moved: std::time::Instant,
moved: web_time::Instant,
waking: bool,
}
+2 -1
View File
@@ -1,9 +1,10 @@
use std::{rc::Rc, time::Instant};
use std::rc::Rc;
use gpui::{
AnyElement, App, ElementId, IntoElement, ParentElement, RenderOnce, Styled, Window, div,
prelude::*,
};
use web_time::Instant;
use crate::{
buttons::{Button, ButtonVariant, IconButton, ToggleButton, ToggleItem},
+2 -1
View File
@@ -1,10 +1,11 @@
use std::time::{Duration, Instant};
use std::time::Duration;
use gpui::{
Context, Entity, IntoElement, Modifiers, MouseButton, ParentElement, Render, ScrollDelta,
ScrollWheelEvent, SharedString, Styled, TestAppContext, TouchPhase, VisualTestContext, Window,
div, point, px,
};
use web_time::Instant;
use super::{picture, press, settle, setup, tab_to};
use crate::media::{
+2 -1
View File
@@ -1,9 +1,10 @@
use std::{rc::Rc, time::Instant};
use std::rc::Rc;
use gpui::{
App, ElementId, IntoElement, MouseButton, ParentElement, RenderOnce, SharedString, Styled,
Window, div, prelude::*,
};
use web_time::Instant;
use crate::{
buttons::{Button, ButtonVariant},
+1 -2
View File
@@ -1,9 +1,8 @@
use std::time::Instant;
use gpui::{
App, Context, Entity, InteractiveElement, IntoElement, Modifiers, ParentElement, Render,
Styled, TestAppContext, Window, div, px,
};
use web_time::Instant;
use super::{press, settle, setup, tab_to};
use crate::{
+5 -2
View File
@@ -1,9 +1,10 @@
use std::time::{Duration, Instant};
use std::time::Duration;
use gpui::{
App, ElementId, FocusHandle, InteractiveElement, IntoElement, ParentElement, RenderOnce,
Styled, Task, Window, div,
};
use web_time::Instant;
use crate::{
buttons::{Button, ButtonVariant},
@@ -202,7 +203,9 @@ impl RenderOnce for Stopwatch {
#[cfg(test)]
mod tests {
use std::time::{Duration, Instant};
use std::time::Duration;
use web_time::Instant;
use super::{Run, tenths};
+2 -1
View File
@@ -1,6 +1,6 @@
use std::{
f32::consts::{PI, TAU},
time::{Duration, Instant},
time::Duration,
};
use gpui::{
@@ -9,6 +9,7 @@ use gpui::{
prelude::*,
};
use smallvec::SmallVec;
use web_time::Instant;
use super::{NUDGE, SLOW, duration, ease_out_cubic};
use crate::theme::ActiveTheme;
+2 -1
View File
@@ -1,9 +1,10 @@
use std::{collections::HashMap, rc::Rc, time::Instant};
use std::{collections::HashMap, rc::Rc};
use gpui::{
AnyElement, App, ElementId, Entity, IntoElement, ParentElement, Pixels, RenderOnce,
SharedString, Styled, Window, canvas, div,
};
use web_time::Instant;
use super::{BASE, duration, ease_in_out_cubic, ease_out_cubic};
use crate::theme::{ActiveTheme, Elevation};
+2 -1
View File
@@ -1,4 +1,4 @@
use std::{f32::consts::PI, time::Instant};
use std::f32::consts::PI;
use gpui::{
Animation, AnimationExt, AnyElement, App, Div, ElementId, InteractiveElement, IntoElement,
@@ -6,6 +6,7 @@ use gpui::{
prelude::*, radians,
};
use smallvec::SmallVec;
use web_time::Instant;
use super::{BASE, FAST, NUDGE, Skeleton, Spinner, changes, duration, ease_out_cubic};
use crate::{
+2 -4
View File
@@ -1,7 +1,4 @@
use std::{
f32::consts::TAU,
time::{Duration, Instant},
};
use std::{f32::consts::TAU, time::Duration};
use gpui::{
Animation, AnimationExt, AnyElement, App, Bounds, Div, ElementId, Hsla, InteractiveElement,
@@ -10,6 +7,7 @@ use gpui::{
px, size,
};
use smallvec::SmallVec;
use web_time::Instant;
use super::{
duration,
+2 -1
View File
@@ -1,10 +1,11 @@
use std::time::{Duration, Instant};
use std::time::Duration;
use gpui::{
Animation, AnimationExt, AnyElement, App, ElementId, IntoElement, ParentElement, RenderOnce,
Styled, Window, div,
};
use smallvec::SmallVec;
use web_time::Instant;
use super::{BASE, NUDGE, duration, ease_out_cubic};
use crate::theme::ActiveTheme;
+5 -5
View File
@@ -1,11 +1,9 @@
use std::{
rc::Rc,
time::{Duration, Instant},
};
use std::{rc::Rc, time::Duration};
use gpui::{
App, ElementId, Entity, IntoElement, ParentElement, RenderOnce, Styled, Task, Window, div,
};
use web_time::Instant;
use crate::{
buttons::{Button, ButtonVariant, IconButton},
@@ -298,7 +296,9 @@ impl RenderOnce for PomodoroTimer {
#[cfg(test)]
mod tests {
use std::time::{Duration, Instant};
use std::time::Duration;
use web_time::Instant;
use super::{Cycle, Lengths, Phase};
+1 -1
View File
@@ -2,10 +2,10 @@ use gpui::{
AnyElement, Context, Entity, IntoElement, KeyBinding, KeyUpEvent, Keystroke, Modifiers,
ParentElement, Render, Styled, TestAppContext, VisualTestContext, Window, div, px,
};
use std::time::Instant;
use gpui::SharedString;
use jiff::civil::date;
use web_time::Instant;
use super::{AssigneePicker, IssueId, Person, Priority, Status, StatusSelect, Task, TaskList};
use crate::{documents::Checklist, forms::bind_keys, primitives::FocusNext, theme::Theme};
+2 -4
View File
@@ -1,12 +1,10 @@
use std::{
rc::Rc,
time::{Duration, Instant},
};
use std::{rc::Rc, time::Duration};
use gpui::{
App, ElementId, InteractiveElement, IntoElement, ParentElement, RenderOnce, SharedString,
Styled, Task, Window, div,
};
use web_time::Instant;
use crate::{
buttons::{Button, ButtonVariant},
+2 -1
View File
@@ -1,9 +1,10 @@
use std::time::{Duration, Instant};
use std::time::Duration;
use gpui::{
Animation, AnimationExt, AnyElement, App, ElementId, IntoElement, ParentElement, RenderOnce,
Styled, Task, Window, div, prelude::*,
};
use web_time::Instant;
use crate::{
buttons::{ButtonVariant, IconButton},
+15 -7
View File
@@ -1,13 +1,10 @@
use std::ops::Range;
use std::ops::{Index, Range};
use alacritty_terminal::{
term::color::Colors,
vte::ansi::{Attr, Color, Handler, Processor},
};
use gpui::{
App, FontStyle, FontWeight, HighlightStyle, IntoElement, ParentElement, RenderOnce,
SharedString, StrikethroughStyle, Styled, StyledText, UnderlineStyle, Window, div,
};
use vte::ansi::{Attr, Color, Handler, Processor, Rgb};
use super::colors::Ink;
use crate::theme::{ActiveTheme, TextSize};
@@ -93,9 +90,20 @@ pub(crate) fn printed(source: &str) -> (String, Vec<(Range<usize>, Pen)>) {
(printed.text, printed.spans)
}
/// Plain text sets no colors with OSC 4, 10 or 11.
struct Unset;
impl Index<usize> for Unset {
type Output = Option<Rgb>;
fn index(&self, _: usize) -> &Option<Rgb> {
&None
}
}
impl Pen {
fn style(&self, ink: &Ink, rule: gpui::Pixels) -> HighlightStyle {
let set = Colors::default();
let set = Unset;
let paint =
|color: Option<Color>, plain| color.map_or(plain, |color| ink.resolve(color, &set));
let (mut fg, mut bg) = (paint(self.fg, ink.fg), paint(self.bg, ink.bg));
@@ -158,7 +166,7 @@ impl RenderOnce for AnsiText {
#[cfg(test)]
mod tests {
use alacritty_terminal::vte::ansi::NamedColor;
use vte::ansi::NamedColor;
use super::*;
+15 -9
View File
@@ -1,8 +1,7 @@
use alacritty_terminal::{
term::color::Colors,
vte::ansi::{Color, NamedColor, Rgb},
};
use std::ops::Index;
use gpui::{Hsla, Rgba};
use vte::ansi::{Color, NamedColor, Rgb};
use crate::theme::Palette;
@@ -24,7 +23,7 @@ impl Ink {
}
/// A color as painted, after any the program set with OSC 4, 10 or 11.
pub(crate) fn resolve(&self, color: Color, set: &Colors) -> Hsla {
pub(crate) fn resolve(&self, color: Color, set: &impl Set) -> Hsla {
match color {
Color::Spec(spec) => hsla(spec),
Color::Indexed(index) => self.indexed(index as usize, set),
@@ -32,8 +31,8 @@ impl Ink {
}
}
fn named(&self, name: NamedColor, set: &Colors) -> Hsla {
if let Some(spec) = set[name] {
fn named(&self, name: NamedColor, set: &impl Set) -> Hsla {
if let Some(spec) = set[name as usize] {
return hsla(spec);
}
match name {
@@ -49,7 +48,7 @@ impl Ink {
}
}
fn indexed(&self, index: usize, set: &Colors) -> Hsla {
fn indexed(&self, index: usize, set: &impl Set) -> Hsla {
if let Some(spec) = set[index] {
return hsla(spec);
}
@@ -76,7 +75,8 @@ impl Ink {
}
/// Color `index` as an answer to a program's query.
pub(crate) fn query(&self, index: usize, set: &Colors) -> Rgb {
#[cfg(not(target_family = "wasm"))]
pub(crate) fn query(&self, index: usize, set: &impl Set) -> Rgb {
let color = match index {
256 => self.named(NamedColor::Foreground, set),
257 => self.named(NamedColor::Background, set),
@@ -93,6 +93,11 @@ impl Ink {
}
}
/// Colors a program set with OSC 4, 10 or 11, by index.
pub(crate) trait Set: Index<usize, Output = Option<Rgb>> {}
impl<T: Index<usize, Output = Option<Rgb>>> Set for T {}
fn hsla(spec: Rgb) -> Hsla {
let channel = |value: u8| f32::from(value) / 255.0;
Rgba {
@@ -106,6 +111,7 @@ fn hsla(spec: Rgb) -> Hsla {
#[cfg(test)]
mod tests {
use alacritty_terminal::term::color::Colors;
use gpui::{black, white};
use super::*;
+10
View File
@@ -1,28 +1,38 @@
mod ansi;
mod block;
mod colors;
#[cfg(not(target_family = "wasm"))]
mod frame;
mod history;
#[cfg(not(target_family = "wasm"))]
mod input;
#[cfg(not(target_family = "wasm"))]
mod keys;
mod links;
mod logs;
#[cfg(not(target_family = "wasm"))]
mod paint;
mod processes;
#[cfg(not(target_family = "wasm"))]
mod pty;
#[cfg(not(target_family = "wasm"))]
mod search;
mod shells;
#[cfg(all(test, feature = "test-support"))]
mod tests;
#[cfg(not(target_family = "wasm"))]
mod view;
pub use ansi::AnsiText;
pub use block::{CommandBlock, CommandState};
pub use history::{CommandHistory, PastCommand};
#[cfg(not(target_family = "wasm"))]
pub(crate) use input::bind_keys;
pub use links::{Target, links};
pub use logs::{LogLevel, LogLine, LogViewer};
pub use processes::{Process, ProcessList};
#[cfg(not(target_family = "wasm"))]
pub use pty::Launch;
pub use shells::{ShellChoice, ShellSelector, TerminalToolbar};
#[cfg(not(target_family = "wasm"))]
pub use view::{Terminal, TerminalEvent};
+2 -1
View File
@@ -1,4 +1,4 @@
use std::{borrow::Cow, process::ExitStatus, rc::Rc, sync::Arc, time::Instant};
use std::{borrow::Cow, process::ExitStatus, rc::Rc, sync::Arc};
use alacritty_terminal::{
event::{Event, Notify, OnResize},
@@ -13,6 +13,7 @@ use gpui::{
App, ClipboardItem, Context, EventEmitter, FocusHandle, Focusable, IntoElement, ParentElement,
Pixels, Point, Render, SharedString, Size, Styled, Task, Window, div, font, prelude::*, size,
};
use web_time::Instant;
use super::{
colors::Ink,
+2 -1
View File
@@ -20,9 +20,10 @@ mod tooling;
#[cfg(all(test, feature = "test-support"))]
mod tests;
use std::time::{Duration, Instant};
use std::time::Duration;
use gpui::{App, Global, SharedString, WindowAppearance};
use web_time::Instant;
use crate::motion;
pub use calendar::CalendarSizes;
+4 -7
View File
@@ -1,9 +1,4 @@
use std::{
collections::VecDeque,
fmt,
rc::Rc,
time::{Duration, Instant},
};
use std::{collections::VecDeque, fmt, rc::Rc, time::Duration};
use gpui::{
AnyElement, App, DispatchPhase, ElementId, InteractiveElement, IntoElement, KeyContext,
@@ -12,6 +7,7 @@ use gpui::{
Window, canvas, div, prelude::FluentBuilder,
};
use smallvec::SmallVec;
use web_time::Instant;
use crate::{
layout::on_axis,
@@ -264,9 +260,10 @@ impl RenderOnce for EventLogger {
#[cfg(test)]
mod tests {
use std::time::{Duration, Instant};
use std::time::Duration;
use gpui::{Modifiers, MouseButton, point, px};
use web_time::Instant;
use super::{KEPT, Log, Seen};
+5 -5
View File
@@ -1,12 +1,10 @@
use std::{
collections::VecDeque,
time::{Duration, Instant},
};
use std::{collections::VecDeque, time::Duration};
use gpui::{
App, Bounds, ElementId, FontWeight, InteractiveElement, IntoElement, ParentElement, RenderOnce,
Styled, Window, canvas, div, fill, point, size,
};
use web_time::Instant;
use crate::{
theme::{ActiveTheme, Radius, TextSize},
@@ -183,7 +181,9 @@ impl RenderOnce for FpsMeter {
#[cfg(test)]
mod tests {
use std::time::{Duration, Instant};
use std::time::Duration;
use web_time::Instant;
use super::{Frames, missed};