1
1
mirror of https://github.com/wez/wezterm.git synced 2024-11-22 04:56:12 +03:00

encoding my preferred import grouping in the rustfmt config

This uses an unstable option in rustfmt, you `cargo +nightly fmt`
needs to be used to format the code correctly.
This commit is contained in:
Wez Furlong 2022-01-17 13:49:44 -07:00
parent 8f31aed3f1
commit e4ed2c93e2
46 changed files with 67 additions and 110 deletions

View File

@ -45,6 +45,6 @@ jobs:
- name: Build
run: |
source $HOME/.cargo/env
cargo fmt --all -- --check
cargo +nightly fmt --all -- --check

View File

@ -1,4 +1,5 @@
# Please keep these in alphabetical order.
# https://github.com/rust-lang/rustfmt/issues/3149
edition = "2018"
imports_granularity = "Module"
tab_spaces = 4

View File

@ -2,10 +2,9 @@ use crate::background::Gradient;
use crate::bell::{AudibleBell, VisualBell};
use crate::color::{ColorSchemeFile, HsbTransform, Palette, TabBarStyle, WindowFrameConfig};
use crate::daemon::DaemonOptions;
use crate::font::{AllowSquareGlyphOverflow, StyleRule, TextStyle};
use crate::font::{
FontLocatorSelection, FontRasterizerSelection, FontShaperSelection, FreeTypeLoadFlags,
FreeTypeLoadTarget,
AllowSquareGlyphOverflow, FontLocatorSelection, FontRasterizerSelection, FontShaperSelection,
FreeTypeLoadFlags, FreeTypeLoadTarget, StyleRule, TextStyle,
};
use crate::frontend::FrontEndSelection;
use crate::keyassignment::{KeyAssignment, MouseEventTrigger, SpawnCommand};

View File

@ -1,7 +1,5 @@
use crate::de_notnan;
use crate::keys::KeyNoAction;
use crate::ConfigHandle;
use crate::LeaderKey;
use crate::{de_notnan, ConfigHandle, LeaderKey};
use luahelper::impl_lua_conversion;
use ordered_float::NotNan;
use serde::{Deserialize, Serialize};

View File

@ -1,6 +1,5 @@
use crate::keyassignment::KeyAssignment;
use crate::Gradient;
use crate::{FontAttributes, FontStretch, FontWeight, FreeTypeLoadTarget, TextStyle};
use crate::{FontAttributes, FontStretch, FontWeight, FreeTypeLoadTarget, Gradient, TextStyle};
use anyhow::anyhow;
use bstr::BString;
pub use luahelper::*;

View File

@ -1,6 +1,5 @@
use std::env;
use std::fs;
use std::path::{Path, PathBuf};
use std::{env, fs};
fn new_build() -> cc::Build {
let mut cfg = cc::Build::new();

View File

@ -8,9 +8,7 @@ use std::os::windows::prelude::*;
use std::ptr;
use std::sync::Once;
use std::time::Duration;
use winapi::shared::ws2def::AF_INET;
use winapi::shared::ws2def::INADDR_LOOPBACK;
use winapi::shared::ws2def::SOCKADDR_IN;
use winapi::shared::ws2def::{AF_INET, INADDR_LOOPBACK, SOCKADDR_IN};
use winapi::um::fileapi::*;
use winapi::um::handleapi::*;
use winapi::um::minwinbase::SECURITY_ATTRIBUTES;

View File

@ -16,10 +16,8 @@ use crossbeam::channel::{unbounded as channel, Receiver, Sender};
use filedescriptor::{FileDescriptor, Pipe};
use portable_pty::*;
use rangeset::RangeSet;
use std::cell::RefCell;
use std::cell::RefMut;
use std::io::BufWriter;
use std::io::Write;
use std::cell::{RefCell, RefMut};
use std::io::{BufWriter, Write};
use std::ops::Range;
use std::rc::Rc;
use std::sync::Arc;

View File

@ -4,13 +4,11 @@ use crate::pane::alloc_pane_id;
use crate::tab::{Tab, TabId};
use crate::tmux::{TmuxDomain, TmuxDomainState, TmuxRemotePane, TmuxTab};
use crate::tmux_pty::TmuxPty;
use crate::Mux;
use crate::Pane;
use crate::{Mux, Pane};
use anyhow::anyhow;
use portable_pty::{MasterPty, PtySize};
use std::collections::HashSet;
use std::fmt::Debug;
use std::fmt::Write;
use std::fmt::{Debug, Write};
use std::rc::Rc;
use std::sync::{Arc, Condvar, Mutex};
use termwiz::tmux_cc::*;

View File

@ -1,12 +1,8 @@
use crate::{
tmux::{RefTmuxRemotePane, TmuxCmdQueue, TmuxDomainState},
tmux_commands::SendKeys,
};
use crate::tmux::{RefTmuxRemotePane, TmuxCmdQueue, TmuxDomainState};
use crate::tmux_commands::SendKeys;
use portable_pty::{Child, ChildKiller, ExitStatus, MasterPty};
use std::{
io::{Read, Write},
sync::{Arc, Condvar, Mutex},
};
use std::io::{Read, Write};
use std::sync::{Arc, Condvar, Mutex};
pub(crate) struct TmuxReader {
rx: flume::Receiver<String>,

View File

@ -15,8 +15,7 @@ use serial::{
BaudRate, CharSize, FlowControl, Parity, PortSettings, SerialPort, StopBits, SystemPort,
};
use std::ffi::{OsStr, OsString};
use std::io::Result as IoResult;
use std::io::{Read, Write};
use std::io::{Read, Result as IoResult, Write};
use std::sync::{Arc, Mutex};
use std::time::Duration;

View File

@ -11,8 +11,7 @@ use crate::{
use filedescriptor::{AsRawSocketDescriptor, POLLIN};
use ssh2::{Channel, Session};
use std::collections::HashMap;
use std::io::Result as IoResult;
use std::io::{Read, Write};
use std::io::{Read, Result as IoResult, Write};
use std::sync::{Arc, Condvar, Mutex};
/// Represents a pty channel within a session.

View File

@ -4,12 +4,10 @@ use crate::{Child, CommandBuilder, MasterPty, PtyPair, PtySize, PtySystem, Slave
use anyhow::{bail, Error};
use filedescriptor::FileDescriptor;
use libc::{self, winsize};
use std::io;
use std::io::{Read, Write};
use std::mem;
use std::os::unix::io::{AsRawFd, FromRawFd, RawFd};
use std::os::unix::process::CommandExt;
use std::ptr;
use std::{io, mem, ptr};
#[derive(Default)]
pub struct UnixPtySystem {}

View File

@ -1,8 +1,7 @@
use crate::win::psuedocon::HPCON;
use anyhow::{ensure, Error};
use std::io::Error as IoError;
use std::mem;
use std::ptr;
use std::{mem, ptr};
use winapi::shared::minwindef::DWORD;
use winapi::um::processthreadsapi::*;

View File

@ -7,12 +7,11 @@ use lazy_static::lazy_static;
use shared_library::shared_library;
use std::ffi::OsString;
use std::io::Error as IoError;
use std::mem;
use std::os::windows::ffi::OsStringExt;
use std::os::windows::io::{AsRawHandle, FromRawHandle};
use std::path::Path;
use std::ptr;
use std::sync::Mutex;
use std::{mem, ptr};
use winapi::shared::minwindef::DWORD;
use winapi::shared::winerror::{HRESULT, S_OK};
use winapi::um::handleapi::*;

View File

@ -9,8 +9,7 @@ use super::VisibleRowIndex;
use serde::{Deserialize, Serialize};
use std::time::{Duration, Instant};
pub use termwiz::input::KeyCode;
pub use termwiz::input::Modifiers as KeyModifiers;
pub use termwiz::input::{KeyCode, Modifiers as KeyModifiers};
#[cfg_attr(feature = "use_serde", derive(Deserialize, Serialize))]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]

View File

@ -8,9 +8,8 @@ use anyhow::Context;
use std::collections::{HashMap, HashSet};
use std::sync::Arc;
use std::time::Duration;
use termwiz::escape::apc::KittyImageData;
use termwiz::escape::apc::{
KittyFrameCompositionMode, KittyImage, KittyImageCompression, KittyImageDelete,
KittyFrameCompositionMode, KittyImage, KittyImageCompression, KittyImageData, KittyImageDelete,
KittyImageFormat, KittyImageFrame, KittyImageFrameCompose, KittyImagePlacement,
KittyImageTransmit, KittyImageVerbosity,
};

View File

@ -2,8 +2,7 @@ use crate::terminal::Alert;
use crate::terminalstate::{
default_color_map, CharSet, MouseEncoding, TabStop, UnicodeVersionStackEntry,
};
use crate::{ClipboardSelection, Position, TerminalState, VisibleRowIndex};
use crate::{DCS, ST};
use crate::{ClipboardSelection, Position, TerminalState, VisibleRowIndex, DCS, ST};
use log::{debug, error};
use num_traits::FromPrimitive;
use std::fmt::Write;

View File

@ -18,8 +18,7 @@ pub mod parser;
pub use self::apc::KittyImage;
pub use self::csi::CSI;
pub use self::esc::Esc;
pub use self::esc::EscCode;
pub use self::esc::{Esc, EscCode};
pub use self::osc::OperatingSystemCommand;
use vtparse::CsiParam;

View File

@ -696,8 +696,7 @@ mod test {
use crate::escape::{Action, Esc, EscCode};
use crate::input::InputEvent;
use crate::terminal::unix::{Purge, SetAttributeWhen, UnixTty};
use crate::terminal::ScreenSize;
use crate::terminal::{cast, Terminal, TerminalWaker};
use crate::terminal::{cast, ScreenSize, Terminal, TerminalWaker};
use libc::winsize;
use std::io::{Error as IoError, ErrorKind, Read, Result as IoResult, Write};
use std::mem;

View File

@ -24,8 +24,7 @@ use std::collections::HashMap;
use std::io::{Read, Write};
use std::marker::Unpin;
use std::net::TcpStream;
use std::path::Path;
use std::path::PathBuf;
use std::path::{Path, PathBuf};
use std::thread;
use std::time::Duration;
use thiserror::Error;

View File

@ -13,8 +13,7 @@ use mux::{Mux, MuxNotification};
use portable_pty::PtySize;
use rangeset::RangeSet;
use ratelim::RateLimiter;
use std::cell::RefCell;
use std::cell::RefMut;
use std::cell::{RefCell, RefMut};
use std::collections::HashMap;
use std::ops::Range;
use std::rc::Rc;

View File

@ -19,8 +19,7 @@ use termwiz::cell::{Cell, CellAttributes, Underline};
use termwiz::color::AnsiColor;
use termwiz::surface::{SequenceNo, SEQ_ZERO};
use url::Url;
use wezterm_term::{KeyCode, KeyModifiers};
use wezterm_term::{Line, StableRowIndex};
use wezterm_term::{KeyCode, KeyModifiers, Line, StableRowIndex};
const MAX_POLL_INTERVAL: Duration = Duration::from_secs(30);
const BASE_POLL_INTERVAL: Duration = Duration::from_millis(20);

View File

@ -5,10 +5,8 @@ use anyhow::{anyhow, ensure, Error};
use config::{FontStretch, FontWeight};
pub use fontconfig::*;
use std::ffi::{CStr, CString};
use std::fmt;
use std::mem;
use std::os::raw::{c_char, c_int};
use std::ptr;
use std::{fmt, mem, ptr};
pub const FC_MONO: i32 = 100;
pub const FC_DUAL: i32 = 90;

View File

@ -4,9 +4,8 @@ use freetype;
pub use harfbuzz::*;
use anyhow::{ensure, Error};
use std::mem;
use std::os::raw::c_char;
use std::slice;
use std::{mem, slice};
extern "C" {
fn hb_ft_font_set_load_flags(font: *mut hb_font_t, load_flags: i32);

View File

@ -7,8 +7,7 @@ use anyhow::bail;
use color_types::linear_u8_to_srgb8;
use config::{FreeTypeLoadFlags, FreeTypeLoadTarget};
use std::cell::RefCell;
use std::mem;
use std::slice;
use std::{mem, slice};
pub struct FreeTypeRasterizer {
has_color: bool,

View File

@ -1,8 +1,7 @@
use crate::ftwrap;
use crate::hbwrap as harfbuzz;
use crate::parser::ParsedFont;
use crate::shaper::{FallbackIdx, FontMetrics, FontShaper, GlyphInfo};
use crate::units::*;
use crate::{ftwrap, hbwrap as harfbuzz};
use anyhow::{anyhow, Context};
use config::ConfigHandle;
use log::error;

View File

@ -6,11 +6,10 @@ use ::window::bitmaps::atlas::{Atlas, OutOfTextureSpace, Sprite};
use ::window::bitmaps::ImageTexture;
use ::window::bitmaps::{BitmapImage, Image, Texture2d};
use ::window::color::SrgbaPixel;
use ::window::glium;
use ::window::glium::backend::Context as GliumContext;
use ::window::glium::texture::SrgbTexture2d;
use ::window::glium::CapabilitiesSource;
use ::window::{Point, Rect};
use ::window::{glium, Point, Rect};
use anyhow::Context;
use config::{AllowSquareGlyphOverflow, TextStyle};
use euclid::num::Zero;

View File

@ -42,9 +42,7 @@ mod update;
mod utilsprites;
pub use selection::SelectionMode;
pub use termwindow::set_window_class;
pub use termwindow::TermWindow;
pub use termwindow::ICON_DATA;
pub use termwindow::{set_window_class, TermWindow, ICON_DATA};
#[derive(Debug, StructOpt)]
#[structopt(

View File

@ -13,10 +13,9 @@ mod launcher;
mod quickselect;
mod search;
pub use confirm_close_pane::confirm_close_pane;
pub use confirm_close_pane::confirm_close_tab;
pub use confirm_close_pane::confirm_close_window;
pub use confirm_close_pane::confirm_quit_program;
pub use confirm_close_pane::{
confirm_close_pane, confirm_close_tab, confirm_close_window, confirm_quit_program,
};
pub use copy::CopyOverlay;
pub use debug::show_debug_overlay;
pub use launcher::{launcher, LauncherArgs, LauncherFlags};

View File

@ -250,16 +250,14 @@ impl<'a> std::hash::Hash for (dyn ShapeCacheKeyTrait + 'a) {
mod test {
use super::*;
use crate::glyphcache::GlyphCache;
use crate::shapecache::GlyphPosition;
use crate::shapecache::ShapedInfo;
use crate::shapecache::{GlyphPosition, ShapedInfo};
use crate::utilsprites::RenderMetrics;
use config::{FontAttributes, TextStyle};
use k9::assert_equal as assert_eq;
use std::rc::Rc;
use termwiz::cell::CellAttributes;
use termwiz::surface::{Line, SEQ_ZERO};
use wezterm_font::FontConfiguration;
use wezterm_font::LoadedFont;
use wezterm_font::{FontConfiguration, LoadedFont};
fn cluster_and_shape<T>(
render_metrics: &RenderMetrics,

View File

@ -2,8 +2,7 @@ use crate::termwindow::{PaneInformation, TabInformation, UIItem, UIItemType};
use config::lua::{format_as_escapes, FormatItem};
use config::{ConfigHandle, TabBarColors};
use mlua::FromLua;
use termwiz::cell::unicode_column_width;
use termwiz::cell::{Cell, CellAttributes};
use termwiz::cell::{unicode_column_width, Cell, CellAttributes};
use termwiz::color::ColorSpec;
use termwiz::escape::csi::Sgr;
use termwiz::escape::parser::Parser;

View File

@ -17,8 +17,7 @@ use crate::shapecache::*;
use crate::tabbar::{TabBarItem, TabBarState};
use ::wezterm_term::input::MouseButton as TMB;
use ::window::*;
use anyhow::Context;
use anyhow::{anyhow, ensure};
use anyhow::{anyhow, ensure, Context};
use config::keyassignment::{
ClipboardCopyDestination, ClipboardPasteSource, InputMap, KeyAssignment, QuickSelectArguments,
SpawnCommand,

View File

@ -1,6 +1,5 @@
use super::box_model::*;
use crate::customglyph::BlockKey;
use crate::customglyph::*;
use crate::customglyph::{BlockKey, *};
use crate::glium::texture::SrgbTexture2d;
use crate::glyphcache::{CachedGlyph, GlyphCache};
use crate::quad::Quad;
@ -13,12 +12,11 @@ use crate::termwindow::{
use crate::utilsprites::RenderMetrics;
use ::window::bitmaps::atlas::OutOfTextureSpace;
use ::window::bitmaps::{TextureCoord, TextureRect, TextureSize};
use ::window::glium;
use ::window::glium::uniforms::{
MagnifySamplerFilter, MinifySamplerFilter, Sampler, SamplerWrapFunction,
};
use ::window::glium::{uniform, BlendingFunction, LinearBlendingFactor, Surface};
use ::window::{DeadKeyStatus, PointF, RectF, SizeF, WindowOps};
use ::window::{glium, DeadKeyStatus, PointF, RectF, SizeF, WindowOps};
use anyhow::anyhow;
use config::{
ConfigHandle, Dimension, DimensionContext, HsbTransform, TabBarColors, TextStyle,

View File

@ -1,7 +1,6 @@
use crate::ICON_DATA;
use anyhow::anyhow;
use config::configuration;
use config::wezterm_version;
use config::{configuration, wezterm_version};
use http_req::request::{HttpVersion, Request};
use http_req::uri::Uri;
use mux::connui::ConnectionUI;

View File

@ -4,8 +4,7 @@ use crate::sessionwrap::SessionWrap;
use filedescriptor::{socketpair, FileDescriptor};
use portable_pty::{ExitStatus, PtySize};
use smol::channel::{bounded, Receiver, TryRecvError};
use std::collections::HashMap;
use std::collections::VecDeque;
use std::collections::{HashMap, VecDeque};
use std::io::{Read, Write};
use std::sync::Mutex;

View File

@ -1,11 +1,10 @@
use super::{Metadata, SessionRequest, SessionSender, SftpChannelResult, SftpRequest};
use smol::channel::{bounded, Sender};
use smol::future::FutureExt;
use std::fmt;
use std::future::Future;
use std::io;
use std::pin::Pin;
use std::task::{Context, Poll};
use std::{fmt, io};
pub(crate) type FileId = usize;

View File

@ -1,5 +1,6 @@
use crate::sshd::session;
use assert_fs::{prelude::*, TempDir};
use assert_fs::prelude::*;
use assert_fs::TempDir;
use predicates::prelude::*;
use rstest::*;
use std::convert::TryInto;

View File

@ -1,5 +1,6 @@
use crate::sshd::session;
use assert_fs::{prelude::*, TempDir};
use assert_fs::prelude::*;
use assert_fs::TempDir;
use rstest::*;
use smol::io::{AsyncReadExt, AsyncWriteExt};
use std::convert::TryInto;

View File

@ -1,4 +1,5 @@
use assert_fs::{prelude::*, TempDir};
use assert_fs::prelude::*;
use assert_fs::TempDir;
use once_cell::sync::{Lazy, OnceCell};
use rstest::*;
use std::collections::HashMap;

View File

@ -8,9 +8,9 @@ mod bindings {
::windows::include_bindings!();
}
use bindings::{
Windows::Data::Xml::Dom::XmlDocument, Windows::Foundation::*, Windows::UI::Notifications::*,
};
use bindings::Windows::Data::Xml::Dom::XmlDocument;
use bindings::Windows::Foundation::*;
use bindings::Windows::UI::Notifications::*;
use windows::{Error as WinError, IInspectable, Interface};
fn unwrap_arg<T>(a: &Option<T>) -> Result<&T, WinError> {

View File

@ -10,7 +10,8 @@ use std::rc::Rc;
use winapi::um::winbase::INFINITE;
use winapi::um::winnt::HANDLE;
use winapi::um::winuser::*;
use winreg::{enums::HKEY_CURRENT_USER, RegKey};
use winreg::enums::HKEY_CURRENT_USER;
use winreg::RegKey;
pub struct Connection {
event_handle: HANDLE,

View File

@ -23,7 +23,8 @@ pub fn is_running_in_rdp_session() -> bool {
use winapi::shared::minwindef::DWORD;
use winapi::um::processthreadsapi::{GetCurrentProcessId, ProcessIdToSessionId};
use winapi::um::winuser::{GetSystemMetrics, SM_REMOTESESSION};
use winreg::{enums::HKEY_LOCAL_MACHINE, RegKey};
use winreg::enums::HKEY_LOCAL_MACHINE;
use winreg::RegKey;
if unsafe { GetSystemMetrics(SM_REMOTESESSION) } != 0 {
return true;

View File

@ -5,8 +5,7 @@ use std::io::Error as IoError;
use std::os::raw::c_void;
use std::ptr::{null, null_mut};
use winapi::shared::windef::*;
use winapi::um::libloaderapi::GetModuleHandleW;
use winapi::um::libloaderapi::*;
use winapi::um::libloaderapi::{GetModuleHandleW, *};
use winapi::um::wingdi::*;
use winapi::um::winuser::*;

View File

@ -1,10 +1,9 @@
use super::*;
use crate::connection::ConnectionOps;
use crate::Appearance;
use crate::{
Clipboard, DeadKeyStatus, Dimensions, Handled, KeyCode, KeyEvent, Modifiers, MouseButtons,
MouseCursor, MouseEvent, MouseEventKind, MousePress, Point, RawKeyEvent, Rect, ScreenPoint,
WindowDecorations, WindowEvent, WindowEventSender, WindowOps, WindowState,
Appearance, Clipboard, DeadKeyStatus, Dimensions, Handled, KeyCode, KeyEvent, Modifiers,
MouseButtons, MouseCursor, MouseEvent, MouseEventKind, MousePress, Point, RawKeyEvent, Rect,
ScreenPoint, WindowDecorations, WindowEvent, WindowEventSender, WindowOps, WindowState,
};
use anyhow::{bail, Context};
use async_trait::async_trait;
@ -35,7 +34,8 @@ use winapi::um::uxtheme::{
};
use winapi::um::wingdi::LOGFONTW;
use winapi::um::winuser::*;
use winreg::{enums::HKEY_CURRENT_USER, RegKey};
use winreg::enums::HKEY_CURRENT_USER;
use winreg::RegKey;
const GCS_RESULTSTR: DWORD = 0x800;
const GCS_COMPSTR: DWORD = 0x8;

View File

@ -1,8 +1,7 @@
use super::*;
use crate::bitmaps::*;
use crate::connection::ConnectionOps;
use crate::os::xkeysyms;
use crate::os::{Connection, Window};
use crate::os::{xkeysyms, Connection, Window};
use crate::{
Appearance, Clipboard, DeadKeyStatus, Dimensions, MouseButtons, MouseCursor, MouseEvent,
MouseEventKind, MousePress, Point, Rect, ScreenPoint, WindowDecorations, WindowEvent,