organize use statements

macos-click-through
Keith Simmons 3 years ago
parent 3c2250ed24
commit 5c4026c4a4

@ -6,6 +6,7 @@ use std::{
process::Stdio,
};
use nvim_rs::{error::LoopError, neovim::Neovim, Handler};
use tokio::{
io::split,
net::{TcpStream, ToSocketAddrs},
@ -13,8 +14,6 @@ use tokio::{
spawn,
task::JoinHandle,
};
use nvim_rs::{error::LoopError, neovim::Neovim, Handler};
use tokio_util::compat::TokioAsyncReadCompatExt;
use crate::bridge::{TxWrapper, WrapTx};

@ -1,7 +1,8 @@
use std::convert::TryInto;
use std::error;
use std::fmt;
use std::fmt::Debug;
use std::{
convert::TryInto,
error,
fmt::{self, Debug},
};
use log::debug;
use rmpv::Value;

@ -4,14 +4,15 @@ use nvim_rs::{Handler, Neovim};
use rmpv::Value;
use tokio::task;
use super::events::parse_redraw_event;
#[cfg(windows)]
use super::ui_commands::{ParallelCommand, UiCommand};
use crate::bridge::TxWrapper;
use crate::editor::EditorCommand;
use crate::error_handling::ResultPanicExplanation;
use crate::event_aggregator::EVENT_AGGREGATOR;
use crate::settings::SETTINGS;
use crate::bridge::ui_commands::{ParallelCommand, UiCommand};
use crate::{
bridge::{events::parse_redraw_event, TxWrapper},
editor::EditorCommand,
error_handling::ResultPanicExplanation,
event_aggregator::EVENT_AGGREGATOR,
settings::SETTINGS,
};
#[derive(Clone)]
pub struct NeovimHandler {}

@ -4,19 +4,18 @@ mod handler;
mod tx_wrapper;
mod ui_commands;
use std::path::Path;
use std::process::Stdio;
use std::sync::Arc;
use std::{path::Path, process::Stdio, sync::Arc};
use log::{error, info, warn};
use nvim_rs::UiAttachOptions;
use rmpv::Value;
use tokio::process::Command;
use tokio::runtime::Runtime;
use tokio::{process::Command, runtime::Runtime};
use crate::{
cmd_line::CmdLineSettings, error_handling::ResultPanicExplanation, running_tracker::*,
settings::*,
};
use crate::running_tracker::*;
use crate::settings::*;
use crate::{cmd_line::CmdLineSettings, error_handling::ResultPanicExplanation};
pub use events::*;
use handler::NeovimHandler;
pub use tx_wrapper::{TxWrapper, WrapTx};

@ -1,7 +1,10 @@
use std::{
io,
pin::Pin,
task::{Context, Poll},
};
use pin_project::pin_project;
use std::io;
use std::pin::Pin;
use std::task::{Context, Poll};
use tokio::{
io::{AsyncWrite, WriteHalf},
net::TcpStream,

@ -7,13 +7,13 @@ use log::trace;
use nvim_rs::{call_args, rpc::model::IntoVal, Neovim};
use tokio::sync::mpsc::unbounded_channel;
use crate::bridge::TxWrapper;
use crate::event_aggregator::EVENT_AGGREGATOR;
use crate::running_tracker::RUNNING_TRACKER;
#[cfg(windows)]
use crate::windows_utils::{
register_rightclick_directory, register_rightclick_file, unregister_rightclick,
};
use crate::{
bridge::TxWrapper, event_aggregator::EVENT_AGGREGATOR, running_tracker::RUNNING_TRACKER,
};
// Serial commands are any commands which must complete before the next value is sent. This
// includes keyboard and mouse input which would cause problems if sent out of order.

@ -1,5 +1,7 @@
use std::fmt::Debug;
use std::sync::mpsc::{SendError, Sender};
use std::{
fmt::Debug,
sync::mpsc::{SendError, Sender},
};
use log::trace;
use tokio::sync::mpsc::{error::SendError as TokioSendError, UnboundedSender};

@ -1,5 +1,4 @@
use crate::settings::*;
use crate::utils::Dimensions;
use crate::{dimensions::Dimensions, settings::*};
use clap::{App, Arg};

@ -1,6 +1,7 @@
use std::ops::{Div, Mul};
use glutin::dpi::PhysicalSize;
use serde::{Deserialize, Serialize};
use std::ops::{Div, Mul};
// Maybe this should be independent from serialization?
#[derive(Debug, Clone, Copy, Eq, PartialEq, Serialize, Deserialize)]

@ -1,9 +1,8 @@
use std::collections::HashMap;
use std::sync::Arc;
use std::{collections::HashMap, sync::Arc};
use skia_safe::Color4f;
use super::style::{Colors, Style};
use crate::editor::style::{Colors, Style};
#[derive(Debug, Clone, PartialEq)]
pub enum CursorShape {

@ -1,7 +1,6 @@
use std::sync::mpsc::{channel, Receiver, SendError, Sender};
use super::DrawCommand;
use crate::event_aggregator::EVENT_AGGREGATOR;
use crate::{editor::DrawCommand, event_aggregator::EVENT_AGGREGATOR};
pub struct DrawCommandBatcher {
window_draw_command_sender: Sender<DrawCommand>,

@ -1,6 +1,6 @@
use std::sync::Arc;
use super::style::Style;
use crate::editor::style::Style;
pub type GridCell = (String, Option<Arc<Style>>);

@ -4,17 +4,18 @@ mod grid;
mod style;
mod window;
use std::collections::HashMap;
use std::sync::Arc;
use std::thread;
use std::{collections::HashMap, sync::Arc, thread};
use log::{error, trace};
use crate::bridge::{GuiOption, RedrawEvent, WindowAnchor};
use crate::event_aggregator::EVENT_AGGREGATOR;
use crate::redraw_scheduler::REDRAW_SCHEDULER;
use crate::renderer::DrawCommand;
use crate::window::WindowCommand;
use crate::{
bridge::{GuiOption, RedrawEvent, WindowAnchor},
event_aggregator::EVENT_AGGREGATOR,
redraw_scheduler::REDRAW_SCHEDULER,
renderer::DrawCommand,
window::WindowCommand,
};
pub use cursor::{Cursor, CursorMode, CursorShape};
pub use draw_command_batcher::DrawCommandBatcher;
pub use grid::CharacterGrid;

@ -1,14 +1,13 @@
use std::collections::HashMap;
use std::sync::Arc;
use std::{collections::HashMap, sync::Arc};
use log::warn;
use unicode_segmentation::UnicodeSegmentation;
use super::grid::CharacterGrid;
use super::style::Style;
use super::{AnchorInfo, DrawCommand, DrawCommandBatcher};
use crate::bridge::GridLineCell;
use crate::renderer::{LineFragment, WindowDrawCommand};
use crate::{
bridge::GridLineCell,
editor::{grid::CharacterGrid, style::Style, AnchorInfo, DrawCommand, DrawCommandBatcher},
renderer::{LineFragment, WindowDrawCommand},
};
pub enum WindowType {
Editor,

@ -1,6 +1,8 @@
use std::any::{type_name, Any, TypeId};
use std::collections::{hash_map::Entry, HashMap};
use std::fmt::Debug;
use std::{
any::{type_name, Any, TypeId},
collections::{hash_map::Entry, HashMap},
fmt::Debug,
};
use parking_lot::{Mutex, RwLock};
use tokio::sync::mpsc::{unbounded_channel, UnboundedReceiver};

@ -1,8 +1,5 @@
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
#[cfg(not(test))]
use flexi_logger::{Cleanup, Criterion, Duplicate, Logger, Naming};
// Test naming occasionally uses camelCase with underscores to separate sections of
// the test name.
#[cfg_attr(test, allow(non_snake_case))]
@ -15,6 +12,7 @@ extern crate clap;
mod bridge;
mod channel_utils;
mod cmd_line;
mod dimensions;
mod editor;
mod error_handling;
mod event_aggregator;
@ -22,7 +20,6 @@ mod redraw_scheduler;
mod renderer;
mod running_tracker;
mod settings;
mod utils;
mod window;
mod windows_utils;
@ -33,6 +30,8 @@ extern crate lazy_static;
use std::env::args;
#[cfg(not(test))]
use flexi_logger::{Cleanup, Criterion, Duplicate, Logger, Naming};
use log::trace;
use bridge::start_bridge;

@ -1,6 +1,10 @@
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Mutex;
use std::time::Instant;
use std::{
sync::{
atomic::{AtomicBool, Ordering},
Mutex,
},
time::Instant,
};
use log::trace;

@ -1,7 +1,6 @@
use std::time::{Duration, Instant};
use crate::editor::Cursor;
use crate::redraw_scheduler::REDRAW_SCHEDULER;
use crate::{editor::Cursor, redraw_scheduler::REDRAW_SCHEDULER};
#[derive(Debug)]
pub enum BlinkState {

@ -1,10 +1,13 @@
use log::error;
use nvim_rs::Value;
use skia_safe::{paint::Style, BlendMode, Canvas, Color, Paint, Point, Rect};
use super::CursorSettings;
use crate::editor::Cursor;
use crate::renderer::{animation_utils::*, grid_renderer::GridRenderer};
use crate::settings::*;
use crate::{
editor::Cursor,
renderer::cursor_renderer::CursorSettings,
renderer::{animation_utils::*, grid_renderer::GridRenderer},
settings::*,
};
pub trait CursorVfx {
fn update(

@ -3,15 +3,16 @@ mod cursor_vfx;
use std::collections::HashMap;
// use neovide_derive::SettingGroup;
use skia_safe::{Canvas, Paint, Path, Point};
use super::{GridRenderer, RenderedWindow};
use crate::bridge::EditorMode;
use crate::editor::{Cursor, CursorShape};
use crate::redraw_scheduler::REDRAW_SCHEDULER;
use crate::renderer::animation_utils::*;
use crate::settings::{FromValue, SETTINGS};
use crate::{
bridge::EditorMode,
editor::{Cursor, CursorShape},
redraw_scheduler::REDRAW_SCHEDULER,
renderer::animation_utils::*,
renderer::{GridRenderer, RenderedWindow},
settings::{FromValue, SETTINGS},
};
use blink::*;

@ -3,14 +3,17 @@ use std::sync::Arc;
use log::trace;
use lru::LruCache;
use skia_safe::{TextBlob, TextBlobBuilder};
use swash::shape::ShapeContext;
use swash::text::cluster::{CharCluster, Parser, Status, Token};
use swash::text::Script;
use swash::Metrics;
use swash::{
shape::ShapeContext,
text::{
cluster::{CharCluster, Parser, Status, Token},
Script,
},
Metrics,
};
use unicode_segmentation::UnicodeSegmentation;
use super::font_loader::*;
use super::font_options::*;
use crate::renderer::fonts::{font_loader::*, font_options::*};
#[derive(new, Clone, Hash, PartialEq, Eq, Debug)]
struct ShapeKey {

@ -3,8 +3,7 @@ use std::sync::Arc;
use lru::LruCache;
use skia_safe::{font::Edging, Data, Font, FontHinting, FontMgr, FontStyle, Typeface};
use super::font_options::FontOptions;
use super::swash_font::SwashFont;
use crate::renderer::fonts::{font_options::FontOptions, swash_font::SwashFont};
static DEFAULT_FONT: &[u8] = include_bytes!("../../../assets/fonts/FiraCode-Regular.ttf");
static LAST_RESORT_FONT: &[u8] = include_bytes!("../../../assets/fonts/LastResort-Regular.ttf");

@ -4,11 +4,13 @@ use glutin::dpi::PhysicalSize;
use log::trace;
use skia_safe::{colors, dash_path_effect, BlendMode, Canvas, Color, Paint, Rect, HSV};
use super::{CachingShaper, RendererSettings};
use crate::editor::{Colors, Style};
use crate::settings::*;
use crate::utils::Dimensions;
use crate::window::WindowSettings;
use crate::{
dimensions::Dimensions,
editor::{Colors, Style},
renderer::{CachingShaper, RendererSettings},
settings::*,
window::WindowSettings,
};
pub struct GridRenderer {
pub shaper: CachingShaper,

@ -4,19 +4,24 @@ mod fonts;
pub mod grid_renderer;
mod rendered_window;
use crate::WindowSettings;
use std::cmp::Ordering;
use std::collections::{hash_map::Entry, HashMap};
use std::sync::Arc;
use std::{
cmp::Ordering,
collections::{hash_map::Entry, HashMap},
sync::Arc,
};
use log::error;
use skia_safe::Canvas;
use tokio::sync::mpsc::UnboundedReceiver;
use crate::bridge::EditorMode;
use crate::editor::{Cursor, Style};
use crate::event_aggregator::EVENT_AGGREGATOR;
use crate::settings::*;
use crate::{
bridge::EditorMode,
editor::{Cursor, Style},
event_aggregator::EVENT_AGGREGATOR,
settings::*,
WindowSettings,
};
use cursor_renderer::CursorRenderer;
pub use fonts::caching_shaper::CachingShaper;
pub use grid_renderer::GridRenderer;

@ -1,18 +1,19 @@
use std::collections::VecDeque;
use std::sync::Arc;
use std::{collections::VecDeque, sync::Arc};
use skia_safe::canvas::{SaveLayerRec, SrcRectConstraint};
use skia_safe::gpu::SurfaceOrigin;
use skia_safe::{
image_filters::blur, BlendMode, Budgeted, Canvas, Color, Image, ImageInfo, Paint, Point, Rect,
SamplingOptions, Surface, SurfaceProps, SurfacePropsFlags,
canvas::{SaveLayerRec, SrcRectConstraint},
gpu::SurfaceOrigin,
image_filters::blur,
BlendMode, Budgeted, Canvas, Color, Image, ImageInfo, Paint, Point, Rect, SamplingOptions,
Surface, SurfaceProps, SurfacePropsFlags,
};
use super::animation_utils::*;
use super::{GridRenderer, RendererSettings};
use crate::editor::Style;
use crate::redraw_scheduler::REDRAW_SCHEDULER;
use crate::utils::Dimensions;
use crate::{
dimensions::Dimensions,
editor::Style,
redraw_scheduler::REDRAW_SCHEDULER,
renderer::{animation_utils::*, GridRenderer, RendererSettings},
};
#[derive(Clone, Debug)]
pub struct LineFragment {

@ -1,22 +1,23 @@
use std::any::{Any, TypeId};
use std::collections::HashMap;
use std::convert::TryInto;
mod from_value;
mod window_geometry;
pub use from_value::FromValue;
use log::trace;
use nvim_rs::Neovim;
use parking_lot::RwLock;
pub use rmpv::Value;
use rmpv::Value;
use std::{
any::{Any, TypeId},
collections::HashMap,
convert::TryInto,
};
use crate::{bridge::TxWrapper, error_handling::ResultPanicExplanation};
pub use from_value::FromValue;
pub use window_geometry::{
load_last_window_settings, parse_window_geometry, save_window_geometry,
PersistentWindowSettings, DEFAULT_WINDOW_GEOMETRY,
};
use crate::bridge::TxWrapper;
use crate::error_handling::ResultPanicExplanation;
lazy_static! {
pub static ref SETTINGS: Settings = Settings::new();
}

@ -1,9 +1,9 @@
use crate::settings::SETTINGS;
use crate::utils::Dimensions;
use crate::window::WindowSettings;
use std::path::PathBuf;
use glutin::dpi::PhysicalPosition;
use serde::{Deserialize, Serialize};
use std::path::PathBuf;
use crate::{dimensions::Dimensions, settings::SETTINGS, window::WindowSettings};
const SETTINGS_FILE: &str = "neovide-settings.json";

@ -1,3 +0,0 @@
mod dimensions;
pub use dimensions::*;

@ -1,13 +1,15 @@
use glutin::event::{ElementState, Event, KeyEvent, WindowEvent};
use glutin::keyboard::Key;
use glutin::keyboard::Key::Dead;
use glutin::platform::modifier_supplement::KeyEventExtModifierSupplement;
use glutin::{
event::{ElementState, Event, KeyEvent, WindowEvent},
keyboard::{Key, Key::Dead},
platform::modifier_supplement::KeyEventExtModifierSupplement,
};
use crate::bridge::{SerialCommand, UiCommand};
use crate::event_aggregator::EVENT_AGGREGATOR;
use crate::settings::SETTINGS;
use crate::window::KeyboardSettings;
use crate::{
bridge::{SerialCommand, UiCommand},
event_aggregator::EVENT_AGGREGATOR,
settings::SETTINGS,
window::KeyboardSettings,
};
enum InputEvent {
KeyEvent(KeyEvent),
@ -89,8 +91,9 @@ impl KeyboardManager {
// And a key was pressed
if key_event.state == ElementState::Pressed {
if let Some(keybinding) = self.maybe_get_keybinding(key_event) {
EVENT_AGGREGATOR
.send(UiCommand::Serial(SerialCommand::Keyboard(keybinding)));
EVENT_AGGREGATOR.send(UiCommand::Serial(
SerialCommand::Keyboard(keybinding),
));
}
next_dead_key = None;
} else if key_event.state == ElementState::Released {
@ -103,8 +106,9 @@ impl KeyboardManager {
}
InputEvent::ImeInput(raw_input) => {
if self.prev_dead_key.is_none() {
EVENT_AGGREGATOR
.send(UiCommand::Serial(SerialCommand::Keyboard(raw_input.to_string())));
EVENT_AGGREGATOR.send(UiCommand::Serial(
SerialCommand::Keyboard(raw_input.to_string()),
));
}
}
}

@ -27,6 +27,7 @@ use renderer::SkiaRenderer;
use crate::{
bridge::{ParallelCommand, UiCommand},
cmd_line::CmdLineSettings,
dimensions::Dimensions,
editor::EditorCommand,
event_aggregator::EVENT_AGGREGATOR,
redraw_scheduler::REDRAW_SCHEDULER,
@ -35,7 +36,6 @@ use crate::{
settings::{
load_last_window_settings, save_window_geometry, PersistentWindowSettings, SETTINGS,
},
utils::Dimensions,
};
pub use settings::{KeyboardSettings, WindowSettings};

@ -8,12 +8,14 @@ use glutin::{
};
use skia_safe::Rect;
use super::keyboard_manager::KeyboardManager;
use crate::bridge::{SerialCommand, UiCommand};
use crate::event_aggregator::EVENT_AGGREGATOR;
use crate::renderer::{Renderer, WindowDrawDetails};
use crate::settings::SETTINGS;
use crate::window::WindowSettings;
use crate::{
bridge::{SerialCommand, UiCommand},
event_aggregator::EVENT_AGGREGATOR,
renderer::{Renderer, WindowDrawDetails},
settings::SETTINGS,
window::keyboard_manager::KeyboardManager,
window::WindowSettings,
};
fn clamp_position(
position: PhysicalPosition<f32>,

@ -1,9 +1,11 @@
use skia_safe::gpu::gl::FramebufferInfo;
use skia_safe::gpu::{BackendRenderTarget, DirectContext, SurfaceOrigin};
use skia_safe::{Canvas, ColorType, Surface};
use std::convert::TryInto;
use gl::types::*;
use skia_safe::{
gpu::{gl::FramebufferInfo, BackendRenderTarget, DirectContext, SurfaceOrigin},
Canvas, ColorType, Surface,
};
type WindowedContext = glutin::ContextWrapper<glutin::PossiblyCurrent, glutin::window::Window>;
fn create_surface(

@ -1,7 +1,7 @@
#[cfg(target_os = "windows")]
use {
std::ffi::CString,
std::ptr::{null, null_mut},
use std::{
ffi::CString,
ptr::{null, null_mut},
};
#[cfg(windows)]

Loading…
Cancel
Save