style: apply nightly rustfmt import grouping across the workspace

rustfmt.toml sets group_imports, imports_granularity and imports_layout,
which are nightly-only; agents formatted with stable rustfmt, which
ignored them. This is a formatting-only pass with `cargo +nightly fmt`.

Test Plan:
- cargo clippy --workspace --all-targets -- -D warnings
- cargo test --workspace
This commit is contained in:
ddidderr committed 2026-10-12 05:03:37 +02:00
1 parent 3fd4ea6ae9
commit 126da77a37
259 files changed
+2495 -1547

No files matched your search

+10 -5
View File
@@ -6,9 +6,11 @@
use ghostty_terminal::page::Cell as PageCell;
use crate::cursor::Style as CursorStyle;
use crate::opengl::shaders::{CellBg, CellText};
use crate::size::{CellCountInt, GridSize};
use crate::{
cursor::Style as CursorStyle,
opengl::shaders::{CellBg, CellText},
size::{CellCountInt, GridSize},
};
/// The possible cell content keys that exist.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
@@ -297,9 +299,12 @@ fn is_powerline(ch: u32) -> bool {
#[cfg(test)]
mod tests {
use ghostty_terminal::{
render::RenderState,
terminal::{Options, Terminal},
};
use super::*;
use ghostty_terminal::render::RenderState;
use ghostty_terminal::terminal::{Options, Terminal};
fn fg(x: u16, y: u16) -> CellText {
CellText {
+2 -1
View File
@@ -84,10 +84,11 @@ pub fn style(state: &RenderState, opts: StyleOptions) -> Option<Style> {
#[cfg(test)]
mod tests {
use super::*;
use ghostty_terminal::terminal::{Options, ScrollViewport, Terminal};
use ghostty_vt::modes::Mode;
use super::*;
fn o(preedit: bool, focused: bool, blink_visible: bool) -> StyleOptions {
StyleOptions {
preedit,
+82 -44
View File
@@ -40,54 +40,91 @@
//! [`Renderer::display_unrealized`], dropping the `Renderer`) must run on the
//! thread with the GL context current. The renderer thread never does.
use std::collections::HashSet;
use std::sync::atomic::{AtomicBool, AtomicU8, Ordering};
use std::sync::{Arc, Mutex, MutexGuard, PoisonError};
use std::time::Instant;
use std::{
collections::HashSet,
sync::{
Arc,
Mutex,
MutexGuard,
PoisonError,
atomic::{AtomicBool, AtomicU8, Ordering},
},
time::Instant,
};
use ghostty_config::config::Config;
use ghostty_config::path::Path as ConfigPath;
use ghostty_config::types_a::{BoldColor, FontShapingBreak, TerminalColor, WindowPaddingColor};
use ghostty_config::types_b::{
AlphaBlending, BackgroundBlur, BackgroundImageFit, BackgroundImagePosition, WindowColorspace,
use ghostty_config::{
config::Config,
path::Path as ConfigPath,
types_a::{BoldColor, FontShapingBreak, TerminalColor, WindowPaddingColor},
types_b::{
AlphaBlending,
BackgroundBlur,
BackgroundImageFit,
BackgroundImagePosition,
WindowColorspace,
},
};
use ghostty_font::{
Atlas,
Presentation,
SPRITE_INDEX,
SharedGrid,
Sprite,
Style as FontStyle,
face::{Constraint, ConstraintSize, RenderOptions},
nerd_font_attributes::get_constraint,
shape::{self, Cache as ShaperCache, RunIterator, RunOptions, TextRun},
shaper::run::RunCell,
};
use ghostty_font::face::{Constraint, ConstraintSize, RenderOptions};
use ghostty_font::nerd_font_attributes::get_constraint;
use ghostty_font::shape::{self, Cache as ShaperCache, RunIterator, RunOptions, TextRun};
use ghostty_font::shaper::run::RunCell;
use ghostty_font::{Atlas, Presentation, SPRITE_INDEX, SharedGrid, Sprite, Style as FontStyle};
use ghostty_input::Mods;
use ghostty_terminal::highlight::Flattened;
use ghostty_terminal::page::{self, Cell as PageCell, Wide};
use ghostty_terminal::page_list::Scrollbar;
use ghostty_terminal::point::{Coordinate, Tag};
use ghostty_terminal::render::{Cursor as RenderCursor, Dirty, RenderState, Row as RenderRow};
use ghostty_terminal::style::{self, Style};
use ghostty_terminal::terminal::ScrollViewport;
use ghostty_vt::color::Rgb;
use ghostty_vt::modes::Mode;
use ghostty_vt::sgr::Underline;
use ghostty_terminal::{
highlight::Flattened,
page::{self, Cell as PageCell, Wide},
page_list::Scrollbar,
point::{Coordinate, Tag},
render::{Cursor as RenderCursor, Dirty, RenderState, Row as RenderRow},
style::{self, Style},
terminal::ScrollViewport,
};
use ghostty_vt::{color::Rgb, modes::Mode, sgr::Underline};
use crate::backend::Health;
use crate::cell::{self, Contents, Key as CellKey};
use crate::cursor::{self, Style as CursorStyle};
use crate::image::{self, Gpu};
use crate::link;
use crate::math;
use crate::opengl::buffer::Buffer;
use crate::opengl::gl::{self, Gl, Primitive};
use crate::opengl::render_pass::{Attachment, AttachmentTarget, Draw, Step};
use crate::opengl::shaders::{
BgImage, BgImageFit, BgImageInfo, BgImagePosition, Bools, CellBg, CellText, CellTextAtlas,
PaddingExtend, Shaders, Uniforms,
use crate::{
backend::Health,
cell::{self, Contents, Key as CellKey},
cursor::{self, Style as CursorStyle},
image::{self, Gpu},
link,
math,
opengl::{
self,
OpenGL,
Sampler,
Target,
Texture,
buffer::Buffer,
gl::{self, Gl, Primitive},
render_pass::{Attachment, AttachmentTarget, Draw, Step},
shaders::{
BgImage,
BgImageFit,
BgImageInfo,
BgImagePosition,
Bools,
CellBg,
CellText,
CellTextAtlas,
PaddingExtend,
Shaders,
Uniforms,
},
},
options::Options,
overlay::{self, Overlay},
row::never_extend_bg,
shadertoy::{self, PathItem},
size::{CellSize, GridSize, Padding, Size},
state::{Preedit, SharedState},
};
use crate::opengl::{self, OpenGL, Sampler, Target, Texture};
use crate::options::Options;
use crate::overlay::{self, Overlay};
use crate::row::never_extend_bg;
use crate::shadertoy::{self, PathItem};
use crate::size::{CellSize, GridSize, Padding, Size};
use crate::state::{Preedit, SharedState};
/// The graphics API used by the renderer on Linux.
pub type GraphicsApi = OpenGL;
@@ -3287,9 +3324,10 @@ impl DrawState {
#[cfg(test)]
mod tests {
use super::*;
use ghostty_config::types_a::Color as ConfigColor;
use super::*;
fn rgb(r: u8, g: u8, b: u8) -> Rgb {
Rgb { r, g, b }
}
+31 -18
View File
@@ -6,23 +6,34 @@
//! GL context) and uploaded to the GPU on the thread that owns the context
//! (`State::upload`, called from `draw_frame`).
use std::collections::HashMap;
use std::time::Instant;
use std::{collections::HashMap, time::Instant};
use ghostty_terminal::kitty::graphics_command::TransmissionFormat;
use ghostty_terminal::kitty::graphics_storage::{ImageStorage, TerminalInfo};
use ghostty_terminal::kitty::{Image as KittyImage, unicode};
use ghostty_terminal::page_list::PageList;
use ghostty_terminal::point::Tag;
use ghostty_terminal::terminal::Terminal;
use ghostty_terminal::{
kitty::{
Image as KittyImage,
graphics_command::TransmissionFormat,
graphics_storage::{ImageStorage, TerminalInfo},
unicode,
},
page_list::PageList,
point::Tag,
terminal::Terminal,
};
use crate::opengl::gl::{Gl, Primitive};
use crate::opengl::pipeline::Pipeline;
use crate::opengl::render_pass::{Draw, RenderPass, Step};
use crate::opengl::shaders::Image as ImageVertex;
use crate::opengl::{Buffer, Texture, buffer, texture};
use crate::overlay::Overlay;
use crate::size::CellSize;
use crate::{
opengl::{
Buffer,
Texture,
buffer,
gl::{Gl, Primitive},
pipeline::Pipeline,
render_pass::{Draw, RenderPass, Step},
shaders::Image as ImageVertex,
texture,
},
overlay::Overlay,
size::CellSize,
};
/// The GPU objects needed to upload and draw images. Built per frame from
/// the graphics API (the API itself is mutably borrowed by the frame while
@@ -1062,9 +1073,11 @@ mod tests {
#[test]
fn kitty_update_builds_sorted_viewport_placements() {
use ghostty_terminal::kitty::graphics_storage::{Location, Placement as KPlacement};
use ghostty_terminal::point::{Coordinate, Point};
use ghostty_terminal::terminal::Options;
use ghostty_terminal::{
kitty::graphics_storage::{Location, Placement as KPlacement},
point::{Coordinate, Point},
terminal::Options,
};
let mut t = Terminal::new(Options::new(10, 10)).unwrap();
t.width_px = 100;
+7 -5
View File
@@ -2,10 +2,11 @@
use std::collections::HashSet;
use ghostty_input::Mods;
use ghostty_input::link::{Highlight, Link as InputLink};
use ghostty_terminal::point::Coordinate;
use ghostty_terminal::render::RenderState;
use ghostty_input::{
Mods,
link::{Highlight, Link as InputLink},
};
use ghostty_terminal::{point::Coordinate, render::RenderState};
use onig::{Regex, Region, SearchOptions};
#[derive(Debug, thiserror::Error)]
@@ -155,10 +156,11 @@ impl Set {
#[cfg(test)]
mod tests {
use super::*;
use ghostty_input::link::Action;
use ghostty_terminal::terminal::{Options, Terminal};
use super::*;
fn link(regex: &str, highlight: Highlight) -> InputLink {
InputLink {
regex: regex.to_string(),
+7 -6
View File
@@ -2,14 +2,15 @@
use std::sync::Arc;
use ghostty_config::config::Config;
use ghostty_font::shared_grid_set::Key as SharedGridKey;
use ghostty_font::{SharedGrid, SharedGridSet};
use ghostty_font::{SharedGrid, SharedGridSet, shared_grid_set::Key as SharedGridKey};
use ghostty_terminal::highlight::Flattened;
use crate::generic::DerivedConfig as RendererDerivedConfig;
use crate::link;
use crate::size::Size;
use crate::thread::DerivedConfig as ThreadDerivedConfig;
use crate::{
generic::DerivedConfig as RendererDerivedConfig,
link,
size::Size,
thread::DerivedConfig as ThreadDerivedConfig,
};
/// The messages that can be sent to a renderer thread.
pub enum Message {
+5 -3
View File
@@ -1,9 +1,11 @@
//! Wrapper for handling render frames (`opengl/Frame.zig`).
use std::sync::Arc;
use super::OpenGL;
use super::render_pass::{Attachment, Options as RenderPassOptions, RenderPass};
use super::target::Target;
use super::{
OpenGL,
render_pass::{Attachment, Options as RenderPassOptions, RenderPass},
target::Target,
};
use crate::backend::Health;
/// Options for beginning a frame.
+7 -4
View File
@@ -13,8 +13,7 @@
//! * Pointer-carrying calls (`buffer_data`, `tex_image_2d`, ...) are only given
//! Rust slices, so lengths are always valid for the pointed memory.
use std::ffi::c_void;
use std::sync::Arc;
use std::{ffi::c_void, sync::Arc};
use glow::HasContext;
@@ -57,8 +56,12 @@ impl std::fmt::Debug for Gl {
// Re-exported raw handle types.
pub use glow::{
Buffer as RawBuffer, Framebuffer as RawFramebuffer, Program as RawProgram,
Renderbuffer as RawRenderbuffer, Sampler as RawSampler, Texture as RawTexture,
Buffer as RawBuffer,
Framebuffer as RawFramebuffer,
Program as RawProgram,
Renderbuffer as RawRenderbuffer,
Sampler as RawSampler,
Texture as RawTexture,
VertexArray as RawVertexArray,
};
+20 -12
View File
@@ -16,23 +16,31 @@ pub mod shaders;
pub mod target;
pub mod texture;
use std::ffi::c_void;
use std::sync::Arc;
use std::{ffi::c_void, sync::Arc};
use ghostty_font::atlas::{Atlas, Format as AtlasFormat};
pub use self::buffer::Buffer;
pub use self::frame::Frame;
pub use self::gl::Gl;
use self::gl::{
BufferTarget, BufferUsage, FramebufferTarget, InternalFormat, MagFilter, MinFilter,
PixelFormat, TextureTarget, Wrap,
BufferTarget,
BufferUsage,
FramebufferTarget,
InternalFormat,
MagFilter,
MinFilter,
PixelFormat,
TextureTarget,
Wrap,
};
pub use self::{
buffer::Buffer,
frame::Frame,
gl::Gl,
pipeline::Pipeline,
render_pass::RenderPass,
sampler::Sampler,
target::Target,
texture::Texture,
};
pub use self::pipeline::Pipeline;
pub use self::render_pass::RenderPass;
pub use self::sampler::Sampler;
pub use self::target::Target;
pub use self::texture::Texture;
use crate::shadertoy;
pub type GraphicsApi = OpenGL;
@@ -1,6 +1,12 @@
//! Wrapper for handling render pipelines (`opengl/Pipeline.zig`).
use super::gl::{
self, AttribType, FramebufferTarget, Gl, RawFramebuffer, RawProgram, RawVertexArray,
self,
AttribType,
FramebufferTarget,
Gl,
RawFramebuffer,
RawProgram,
RawVertexArray,
};
/// Vertex step function.
@@ -1,11 +1,11 @@
//! Wrapper for handling render passes (`opengl/RenderPass.zig`).
use super::gl::{
Attachment as GlAttachment, BufferTarget, FramebufferTarget, Gl, Primitive, RawBuffer,
use super::{
gl::{Attachment as GlAttachment, BufferTarget, FramebufferTarget, Gl, Primitive, RawBuffer},
pipeline::Pipeline,
sampler::Sampler,
target::Target,
texture::Texture,
};
use super::pipeline::Pipeline;
use super::sampler::Sampler;
use super::target::Target;
use super::texture::Texture;
/// What a color attachment renders into.
pub enum AttachmentTarget<'a> {
@@ -1,8 +1,10 @@
//! Shader pipelines and GPU data layouts for OpenGL (`opengl/shaders.zig`).
use bytemuck::{Pod, Zeroable};
use super::gl::{self, AttribType, Gl};
use super::pipeline::{Attribute, Options as PipelineOptions, Pipeline, StepFunction, Vertex};
use super::{
gl::{self, AttribType, Gl},
pipeline::{Attribute, Options as PipelineOptions, Pipeline, StepFunction, Vertex},
};
use crate::math::Mat;
/// `shaders/glsl/common.glsl`, the only `#include`d file.
@@ -464,9 +466,10 @@ impl Vertex for BgImage {
#[cfg(test)]
mod tests {
use super::*;
use core::mem::{offset_of, size_of};
use super::*;
#[test]
fn uniforms_std140_layout() {
// Offsets from the std140 rules applied to the `Globals` block in
+7 -1
View File
@@ -2,7 +2,13 @@
//!
//! In this case, an OpenGL renderbuffer-backed framebuffer.
use super::gl::{
self, Attachment, FramebufferTarget, Gl, InternalFormat, RawFramebuffer, RawRenderbuffer,
self,
Attachment,
FramebufferTarget,
Gl,
InternalFormat,
RawFramebuffer,
RawRenderbuffer,
};
/// Options for initializing a Target
@@ -1,6 +1,14 @@
//! Wrapper for handling textures (`opengl/Texture.zig`).
use super::gl::{
self, Gl, InternalFormat, MagFilter, MinFilter, PixelFormat, RawTexture, TextureTarget, Wrap,
self,
Gl,
InternalFormat,
MagFilter,
MinFilter,
PixelFormat,
RawTexture,
TextureTarget,
Wrap,
};
/// Options for initializing a texture.
+1 -2
View File
@@ -3,8 +3,7 @@ use std::sync::Arc;
use ghostty_font::SharedGrid;
use crate::generic::Host;
use crate::size::Size;
use crate::{generic::Host, size::Size};
/// Options for constructing a renderer.
///
+10 -5
View File
@@ -10,11 +10,15 @@
//! then get the resulting image with [`Overlay::pending_image`] to upload to
//! the GPU. This works in concert with [`crate::image::State`].
use ghostty_terminal::page::{SemanticContent, SemanticPrompt};
use ghostty_terminal::render::RenderState;
use ghostty_terminal::{
page::{SemanticContent, SemanticPrompt},
render::RenderState,
};
use crate::image::{Pending, PixelFormat};
use crate::size::{CellSize, Size};
use crate::{
image::{Pending, PixelFormat},
size::{CellSize, Size},
};
/// The colors we use for overlays.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
@@ -394,9 +398,10 @@ fn checked_i32(v: usize) -> Result<i32, Overflow> {
#[cfg(test)]
mod tests {
use ghostty_terminal::terminal::{Options, Terminal};
use super::*;
use crate::size::{Padding, ScreenSize};
use ghostty_terminal::terminal::{Options, Terminal};
fn size(w: u32, h: u32) -> Size {
Size {
+6 -3
View File
@@ -1,7 +1,9 @@
//! Row heuristics for the renderer (`renderer/row.zig`).
use ghostty_terminal::page::{Cell, ContentTag, Row, SemanticPrompt};
use ghostty_terminal::style::Style;
use ghostty_terminal::{
page::{Cell, ContentTag, Row, SemanticPrompt},
style::Style,
};
use ghostty_vt::color::{Palette, Rgb};
/// Returns true if the row of this pin should never have its background
@@ -82,9 +84,10 @@ fn style_at(cell: Cell, styles: &[Style], x: usize) -> Style {
#[cfg(test)]
mod tests {
use super::*;
use ghostty_vt::color;
use super::*;
const BG: Rgb = Rgb { r: 1, g: 2, b: 3 };
#[test]
+10 -7
View File
@@ -8,14 +8,16 @@
//! `docs/rewrite/notes/ghostty-renderer-R1.md` for the (small) source
//! adaptations needed for naga's Vulkan-flavoured GLSL frontend.
use crate::shadertoy_sampler;
use std::io::Read;
use std::path::Path;
use std::{io::Read, path::Path};
use bytemuck::{Pod, Zeroable};
use naga::back::glsl as glsl_out;
use naga::front::glsl as glsl_in;
use naga::valid::{Capabilities, ModuleInfo, ValidationFlags, Validator};
use naga::{
back::glsl as glsl_out,
front::glsl as glsl_in,
valid::{Capabilities, ModuleInfo, ValidationFlags, Validator},
};
use crate::shadertoy_sampler;
/// The shadertoy prefix (declares the uniforms and the `main` entry point).
pub const PREFIX: &str = include_str!("../shaders/shadertoy_prefix.glsl");
@@ -349,9 +351,10 @@ pub mod test_shaders {
#[cfg(test)]
mod tests {
use super::*;
use core::mem::{offset_of, size_of};
use super::*;
#[test]
fn spirv() {
let src = glsl_from_shader(TEST_CRT);
+1 -3
View File
@@ -3,9 +3,7 @@
use std::sync::{Arc, Mutex};
use ghostty_input::Mods;
use ghostty_terminal::point::Coordinate;
use ghostty_terminal::size::CellCountInt;
use ghostty_terminal::terminal::Terminal;
use ghostty_terminal::{point::Coordinate, size::CellCountInt, terminal::Terminal};
use crate::overlay::Feature as OverlayFeature;
+10 -7
View File
@@ -31,17 +31,20 @@
//! The event loop (libxev in Zig) is replaced by a `crossbeam_channel::select!`
//! over the wakeup / stop / draw-now channels and the next timer deadline.
use std::sync::Arc;
use std::time::{Duration, Instant};
use std::{
sync::Arc,
time::{Duration, Instant},
};
use crossbeam_channel::{Receiver, Sender, bounded, never, select};
use ghostty_config::config::Config;
use ghostty_config::types_a::CustomShaderAnimation;
use ghostty_config::{config::Config, types_a::CustomShaderAnimation};
use ghostty_datastruct::blocking_queue::{BlockingQueue, Timeout};
use crate::generic::{Host, Renderer};
use crate::message::Message;
use crate::state::SharedState;
use crate::{
generic::{Host, Renderer},
message::Message,
state::SharedState,
};
/// 120 FPS
pub const DRAW_INTERVAL: Duration = Duration::from_millis(8);