diff options
author | Kirill Chibisov <contact@kchibisov.com> | 2020-05-03 06:52:57 +0300 |
---|---|---|
committer | Kirill Chibisov <contact@kchibisov.com> | 2020-05-04 03:07:23 +0300 |
commit | d61228056171f89b866c61871f837a50c3cd48ea (patch) | |
tree | 69ef78283c53ced053856c1ad40db5f535df9d03 /alacritty/src | |
parent | fa94fc3388829cd919d2b4c14d8f0ef842a7bcc2 (diff) | |
download | alacritty-d61228056171f89b866c61871f837a50c3cd48ea.tar.gz alacritty-d61228056171f89b866c61871f837a50c3cd48ea.zip |
Add period to comments to follow styleperiod
Diffstat (limited to 'alacritty/src')
-rw-r--r-- | alacritty/src/cli.rs | 6 | ||||
-rw-r--r-- | alacritty/src/config/bindings.rs | 35 | ||||
-rw-r--r-- | alacritty/src/config/mod.rs | 20 | ||||
-rw-r--r-- | alacritty/src/config/monitor.rs | 4 | ||||
-rw-r--r-- | alacritty/src/config/mouse.rs | 8 | ||||
-rw-r--r-- | alacritty/src/config/ui_config.rs | 8 | ||||
-rw-r--r-- | alacritty/src/cursor.rs | 26 | ||||
-rw-r--r-- | alacritty/src/display.rs | 6 | ||||
-rw-r--r-- | alacritty/src/event.rs | 35 | ||||
-rw-r--r-- | alacritty/src/input.rs | 90 | ||||
-rw-r--r-- | alacritty/src/logging.rs | 8 | ||||
-rw-r--r-- | alacritty/src/main.rs | 56 | ||||
-rw-r--r-- | alacritty/src/renderer/mod.rs | 243 | ||||
-rw-r--r-- | alacritty/src/renderer/rects.rs | 8 | ||||
-rw-r--r-- | alacritty/src/url.rs | 28 | ||||
-rw-r--r-- | alacritty/src/window.rs | 34 |
16 files changed, 308 insertions, 307 deletions
diff --git a/alacritty/src/cli.rs b/alacritty/src/cli.rs index 2137c9c8..5f6b7804 100644 --- a/alacritty/src/cli.rs +++ b/alacritty/src/cli.rs @@ -30,7 +30,7 @@ const CONFIG_PATH: &str = "%APPDATA%\\alacritty\\alacritty.yml"; #[cfg(target_os = "macos")] const CONFIG_PATH: &str = "$HOME/.config/alacritty/alacritty.yml"; -/// Options specified on the command line +/// Options specified on the command line. pub struct Options { pub live_config_reload: Option<bool>, pub print_events: bool, @@ -241,8 +241,8 @@ impl Options { if let Some(mut args) = matches.values_of("command") { // The following unwrap is guaranteed to succeed. - // If 'command' exists it must also have a first item since - // Arg::min_values(1) is set. + // If `command` exists it must also have a first item since + // `Arg::min_values(1)` is set. let command = String::from(args.next().unwrap()); let args = args.map(String::from).collect(); options.command = Some(Shell::new_with_args(command, args)); diff --git a/alacritty/src/config/bindings.rs b/alacritty/src/config/bindings.rs index d6520441..eb29f2d4 100644 --- a/alacritty/src/config/bindings.rs +++ b/alacritty/src/config/bindings.rs @@ -25,21 +25,21 @@ use serde_yaml::Value as SerdeValue; use alacritty_terminal::term::TermMode; use alacritty_terminal::vi_mode::ViMotion; -/// Describes a state and action to take in that state +/// Describes a state and action to take in that state. /// -/// This is the shared component of `MouseBinding` and `KeyBinding` +/// This is the shared component of `MouseBinding` and `KeyBinding`. #[derive(Debug, Clone, PartialEq, Eq)] pub struct Binding<T> { - /// Modifier keys required to activate binding + /// Modifier keys required to activate binding. pub mods: ModifiersState, - /// String to send to pty if mods and mode match + /// String to send to pty if mods and mode match. pub action: Action, - /// Terminal mode required to activate binding + /// Terminal mode required to activate binding. pub mode: TermMode, - /// excluded terminal modes where the binding won't be activated + /// excluded terminal modes where the binding won't be activated. pub notmode: TermMode, /// This property is used as part of the trigger detection code. @@ -48,10 +48,10 @@ pub struct Binding<T> { pub trigger: T, } -/// Bindings that are triggered by a keyboard key +/// Bindings that are triggered by a keyboard key. pub type KeyBinding = Binding<Key>; -/// Bindings that are triggered by a mouse button +/// Bindings that are triggered by a mouse button. pub type MouseBinding = Binding<MouseButton>; impl<T: Eq> Binding<T> { @@ -68,19 +68,19 @@ impl<T: Eq> Binding<T> { #[inline] pub fn triggers_match(&self, binding: &Binding<T>) -> bool { - // Check the binding's key and modifiers + // Check the binding's key and modifiers. if self.trigger != binding.trigger || self.mods != binding.mods { return false; } - // Completely empty modes match all modes + // Completely empty modes match all modes. if (self.mode.is_empty() && self.notmode.is_empty()) || (binding.mode.is_empty() && binding.notmode.is_empty()) { return true; } - // Check for intersection (equality is required since empty does not intersect itself) + // Check for intersection (equality is required since empty does not intersect itself). (self.mode == binding.mode || self.mode.intersects(binding.mode)) && (self.notmode == binding.notmode || self.notmode.intersects(binding.notmode)) } @@ -171,7 +171,7 @@ pub enum Action { /// Toggle fullscreen. ToggleFullscreen, - /// Toggle simple fullscreen on macos. + /// Toggle simple fullscreen on macOS. #[cfg(target_os = "macos")] ToggleSimpleFullscreen, @@ -410,7 +410,7 @@ pub fn default_key_bindings() -> Vec<KeyBinding> { // 8 | Shift + Alt + Control // ---------+--------------------------- // - // from: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-PC-Style-Function-Keys + // from: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-PC-Style-Function-Keys. let mut modifiers = vec![ ModifiersState::SHIFT, ModifiersState::ALT, @@ -452,8 +452,9 @@ pub fn default_key_bindings() -> Vec<KeyBinding> { F20, mods, ~TermMode::VI; Action::Esc(format!("\x1b[34;{}~", modifiers_code)); )); - // We're adding the following bindings with `Shift` manually above, so skipping them here - // modifiers_code != Shift + // We're adding the following bindings with `Shift` manually above, so skipping them here. + + // modifiers_code != Shift. if modifiers_code != 2 { bindings.extend(bindings!( KeyBinding; @@ -525,7 +526,7 @@ pub fn platform_key_bindings() -> Vec<KeyBinding> { ) } -// Don't return any bindings for tests since they are commented-out by default +// Don't return any bindings for tests since they are commented-out by default. #[cfg(test)] pub fn platform_key_bindings() -> Vec<KeyBinding> { vec![] @@ -956,7 +957,7 @@ impl CommandWrapper { } } -/// Newtype for implementing deserialize on glutin Mods +/// Newtype for implementing deserialize on glutin Mods. /// /// Our deserialize impl wouldn't be covered by a derive(Deserialize); see the /// impl below. diff --git a/alacritty/src/config/mod.rs b/alacritty/src/config/mod.rs index bb05d980..f416039c 100644 --- a/alacritty/src/config/mod.rs +++ b/alacritty/src/config/mod.rs @@ -22,22 +22,22 @@ use crate::config::ui_config::UIConfig; pub type Config = TermConfig<UIConfig>; -/// Result from config loading +/// Result from config loading. pub type Result<T> = std::result::Result<T, Error>; -/// Errors occurring during config loading +/// Errors occurring during config loading. #[derive(Debug)] pub enum Error { - /// Config file not found + /// Config file not found. NotFound, - /// Couldn't read $HOME environment variable + /// Couldn't read $HOME environment variable. ReadingEnvHome(env::VarError), - /// io error reading file + /// io error reading file. Io(io::Error), - /// Not valid yaml or missing parameters + /// Not valid yaml or missing parameters. Yaml(serde_yaml::Error), } @@ -96,7 +96,7 @@ impl From<serde_yaml::Error> for Error { /// 4. $HOME/.alacritty.yml #[cfg(not(windows))] pub fn installed_config() -> Option<PathBuf> { - // Try using XDG location by default + // Try using XDG location by default. xdg::BaseDirectories::with_prefix("alacritty") .ok() .and_then(|xdg| xdg.find_config_file("alacritty.yml")) @@ -107,12 +107,12 @@ pub fn installed_config() -> Option<PathBuf> { }) .or_else(|| { if let Ok(home) = env::var("HOME") { - // Fallback path: $HOME/.config/alacritty/alacritty.yml + // Fallback path: $HOME/.config/alacritty/alacritty.yml. let fallback = PathBuf::from(&home).join(".config/alacritty/alacritty.yml"); if fallback.exists() { return Some(fallback); } - // Fallback path: $HOME/.alacritty.yml + // Fallback path: $HOME/.alacritty.yml. let fallback = PathBuf::from(&home).join(".alacritty.yml"); if fallback.exists() { return Some(fallback); @@ -146,7 +146,7 @@ pub fn reload_from(path: &PathBuf) -> Result<Config> { fn read_config(path: &PathBuf) -> Result<Config> { let mut contents = fs::read_to_string(path)?; - // Remove UTF-8 BOM + // Remove UTF-8 BOM. if contents.starts_with('\u{FEFF}') { contents = contents.split_off(3); } diff --git a/alacritty/src/config/monitor.rs b/alacritty/src/config/monitor.rs index 8dc5379a..d91b2e4b 100644 --- a/alacritty/src/config/monitor.rs +++ b/alacritty/src/config/monitor.rs @@ -28,11 +28,11 @@ impl Monitor { watcher(tx, Duration::from_millis(10)).expect("Unable to spawn file watcher"); let config_path = ::std::fs::canonicalize(path).expect("canonicalize config path"); - // Get directory of config + // Get directory of config. let mut parent = config_path.clone(); parent.pop(); - // Watch directory + // Watch directory. watcher .watch(&parent, RecursiveMode::NonRecursive) .expect("watch alacritty.yml dir"); diff --git a/alacritty/src/config/mouse.rs b/alacritty/src/config/mouse.rs index b7832b4a..9192aba9 100644 --- a/alacritty/src/config/mouse.rs +++ b/alacritty/src/config/mouse.rs @@ -24,11 +24,11 @@ pub struct Mouse { #[serde(default)] #[derive(Clone, Debug, Deserialize, PartialEq, Eq)] pub struct Url { - // Program for opening links + /// Program for opening links. #[serde(deserialize_with = "deserialize_launcher")] pub launcher: Option<CommandWrapper>, - // Modifier used to open links + /// Modifier used to open links. #[serde(deserialize_with = "failure_default")] modifiers: ModsWrapper, } @@ -47,10 +47,10 @@ where { let default = Url::default().launcher; - // Deserialize to generic value + // Deserialize to generic value. let val = serde_yaml::Value::deserialize(deserializer)?; - // Accept `None` to disable the launcher + // Accept `None` to disable the launcher. if val.as_str().filter(|v| v.to_lowercase() == "none").is_some() { return Ok(None); } diff --git a/alacritty/src/config/ui_config.rs b/alacritty/src/config/ui_config.rs index 13a3b04e..49e54e05 100644 --- a/alacritty/src/config/ui_config.rs +++ b/alacritty/src/config/ui_config.rs @@ -11,11 +11,11 @@ pub struct UIConfig { #[serde(default, deserialize_with = "failure_default")] pub mouse: Mouse, - /// Keybindings + /// Keybindings. #[serde(default = "default_key_bindings", deserialize_with = "deserialize_key_bindings")] pub key_bindings: Vec<KeyBinding>, - /// Bindings for the mouse + /// Bindings for the mouse. #[serde(default = "default_mouse_bindings", deserialize_with = "deserialize_mouse_bindings")] pub mouse_bindings: Vec<MouseBinding>, } @@ -63,7 +63,7 @@ where { let values = Vec::<serde_yaml::Value>::deserialize(deserializer)?; - // Skip all invalid values + // Skip all invalid values. let mut bindings = Vec::with_capacity(values.len()); for value in values { match Binding::<T>::deserialize(value) { @@ -74,7 +74,7 @@ where } } - // Remove matching default bindings + // Remove matching default bindings. for binding in bindings.iter() { default.retain(|b| !b.triggers_match(binding)); } diff --git a/alacritty/src/cursor.rs b/alacritty/src/cursor.rs index 253fdaa7..aaed521a 100644 --- a/alacritty/src/cursor.rs +++ b/alacritty/src/cursor.rs @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -//! Helpers for creating different cursor glyphs from font metrics +//! Helpers for creating different cursor glyphs from font metrics. use std::cmp; @@ -28,13 +28,13 @@ pub fn get_cursor_glyph( is_wide: bool, cursor_thickness: f64, ) -> RasterizedGlyph { - // Calculate the cell metrics + // Calculate the cell metrics. let height = metrics.line_height as i32 + i32::from(offset_y); let mut width = metrics.average_advance as i32 + i32::from(offset_x); let line_width = cmp::max((cursor_thickness * f64::from(width)).round() as i32, 1); - // Double the cursor width if it's above a double-width glyph + // Double the cursor width if it's above a double-width glyph. if is_wide { width *= 2; } @@ -48,12 +48,12 @@ pub fn get_cursor_glyph( } } -// Returns a custom underline cursor character +/// Return a custom underline cursor character. pub fn get_underline_cursor_glyph(width: i32, line_width: i32) -> RasterizedGlyph { - // Create a new rectangle, the height is relative to the font width + // Create a new rectangle, the height is relative to the font width. let buf = vec![255u8; (width * line_width * 3) as usize]; - // Create a custom glyph with the rectangle data attached to it + // Create a custom glyph with the rectangle data attached to it. RasterizedGlyph { c: ' ', top: line_width, @@ -64,7 +64,7 @@ pub fn get_underline_cursor_glyph(width: i32, line_width: i32) -> RasterizedGlyp } } -// Returns a custom beam cursor character +/// Return a custom beam cursor character. pub fn get_beam_cursor_glyph(height: i32, line_width: i32) -> RasterizedGlyph { // Create a new rectangle that is at least one pixel wide let buf = vec![255u8; (line_width * height * 3) as usize]; @@ -80,9 +80,9 @@ pub fn get_beam_cursor_glyph(height: i32, line_width: i32) -> RasterizedGlyph { } } -// Returns a custom box cursor character +/// Returns a custom box cursor character pub fn get_box_cursor_glyph(height: i32, width: i32, line_width: i32) -> RasterizedGlyph { - // Create a new box outline rectangle + // Create a new box outline rectangle. let mut buf = Vec::with_capacity((width * height * 3) as usize); for y in 0..height { for x in 0..width { @@ -98,15 +98,15 @@ pub fn get_box_cursor_glyph(height: i32, width: i32, line_width: i32) -> Rasteri } } - // Create a custom glyph with the rectangle data attached to it + // Create a custom glyph with the rectangle data attached to it. RasterizedGlyph { c: ' ', top: height, left: 0, height, width, buf: BitmapBuffer::RGB(buf) } } -// Returns a custom block cursor character +/// Return a custom block cursor character. pub fn get_block_cursor_glyph(height: i32, width: i32) -> RasterizedGlyph { - // Create a completely filled glyph + // Create a completely filled glyph. let buf = vec![255u8; (width * height * 3) as usize]; - // Create a custom glyph with the rectangle data attached to it + // Create a custom glyph with the rectangle data attached to it. RasterizedGlyph { c: ' ', top: height, left: 0, height, width, buf: BitmapBuffer::RGB(buf) } } diff --git a/alacritty/src/display.rs b/alacritty/src/display.rs index aabd2631..aca91e4e 100644 --- a/alacritty/src/display.rs +++ b/alacritty/src/display.rs @@ -219,7 +219,7 @@ impl Display { // Update OpenGL projection. renderer.resize(&size_info); - // Call `clear` before showing the window, to make sure the surface is initialized. + // Clear screen. let background_color = config.colors.primary.background; renderer.with_api(&config, &size_info, |api| { api.clear(background_color); @@ -244,7 +244,7 @@ impl Display { // Set window position. // - // TODO: replace `set_position` with `with_position` once available + // TODO: replace `set_position` with `with_position` once available. // Upstream issue: https://github.com/rust-windowing/winit/issues/806. if let Some(position) = config.window.position { window.set_outer_position(PhysicalPosition::from((position.x, position.y))); @@ -376,7 +376,7 @@ impl Display { pty_size.height -= pty_size.cell_height * lines as f32; } - // Resize PTY. + // Resize pty. pty_resize_handle.on_resize(&pty_size); // Resize terminal. diff --git a/alacritty/src/event.rs b/alacritty/src/event.rs index 94c9a735..7ec7a70f 100644 --- a/alacritty/src/event.rs +++ b/alacritty/src/event.rs @@ -1,4 +1,4 @@ -//! Process window events +//! Process window events. use std::borrow::Cow; use std::cmp::max; use std::env; @@ -91,7 +91,7 @@ impl<'a, N: Notify + 'a, T: EventListener> input::ActionContext<T> for ActionCon fn scroll(&mut self, scroll: Scroll) { self.terminal.scroll_display(scroll); - // Update selection + // Update selection. if self.terminal.mode().contains(TermMode::VI) && self.terminal.selection().as_ref().map(|s| s.is_empty()) != Some(true) { @@ -125,7 +125,7 @@ impl<'a, N: Notify + 'a, T: EventListener> input::ActionContext<T> for ActionCon fn update_selection(&mut self, point: Point, side: Side) { let point = self.terminal.visible_to_buffer(point); - // Update selection if one exists + // Update selection if one exists. let vi_mode = self.terminal.mode().contains(TermMode::VI); if let Some(selection) = self.terminal.selection_mut() { selection.update(point, side); @@ -306,7 +306,7 @@ pub enum ClickState { TripleClick, } -/// State of the mouse +/// State of the mouse. #[derive(Debug)] pub struct Mouse { pub x: usize, @@ -346,7 +346,7 @@ impl Default for Mouse { } } -/// The event processor +/// The event processor. /// /// Stores some state from received events and dispatches actions when they are /// triggered. @@ -364,10 +364,9 @@ pub struct Processor<N> { } impl<N: Notify + OnResize> Processor<N> { - /// Create a new event processor + /// Create a new event processor. /// - /// Takes a writer which is expected to be hooked up to the write end of a - /// pty. + /// Takes a writer which is expected to be hooked up to the write end of a pty. pub fn new( notifier: N, message_buffer: MessageBuffer, @@ -528,11 +527,11 @@ impl<N: Notify + OnResize> Processor<N> { } }); - // Write ref tests to disk + // Write ref tests to disk. self.write_ref_test_results(&terminal.lock()); } - /// Handle events from glutin + /// Handle events from glutin. /// /// Doesn't take self mutably due to borrow checking. fn handle_event<T>( @@ -546,11 +545,11 @@ impl<N: Notify + OnResize> Processor<N> { Event::DPRChanged(scale_factor, (width, height)) => { let display_update_pending = &mut processor.ctx.display_update_pending; - // Push current font to update its DPR + // Push current font to update its DPR. display_update_pending.font = Some(processor.ctx.config.font.clone().with_size(*processor.ctx.font_size)); - // Resize to event's dimensions, since no resize event is emitted on Wayland + // Resize to event's dimensions, since no resize event is emitted on Wayland. display_update_pending.dimensions = Some(PhysicalSize::new(width, height)); processor.ctx.size_info.dpr = scale_factor; @@ -592,7 +591,7 @@ impl<N: Notify + OnResize> Processor<N> { WindowEvent::KeyboardInput { input, is_synthetic: false, .. } => { processor.key_input(input); if input.state == ElementState::Pressed { - // Hide cursor while typing + // Hide cursor while typing. if processor.ctx.config.ui_config.mouse.hide_when_typing { processor.ctx.window.set_mouse_visible(false); } @@ -667,7 +666,7 @@ impl<N: Notify + OnResize> Processor<N> { } } - /// Check if an event is irrelevant and can be skipped + /// Check if an event is irrelevant and can be skipped. fn skip_event(event: &GlutinEvent<Event>) -> bool { match event { GlutinEvent::WindowEvent { event, .. } => match event { @@ -709,7 +708,7 @@ impl<N: Notify + OnResize> Processor<N> { processor.ctx.terminal.update_config(&config); - // Reload cursor if we've changed its thickness + // Reload cursor if we've changed its thickness. if (processor.ctx.config.cursor.thickness() - config.cursor.thickness()).abs() > std::f64::EPSILON { @@ -717,7 +716,7 @@ impl<N: Notify + OnResize> Processor<N> { } if processor.ctx.config.font != config.font { - // Do not update font size if it has been changed at runtime + // Do not update font size if it has been changed at runtime. if *processor.ctx.font_size == processor.ctx.config.font.size { *processor.ctx.font_size = config.font.size; } @@ -738,13 +737,13 @@ impl<N: Notify + OnResize> Processor<N> { processor.ctx.terminal.dirty = true; } - // Write the ref test results to the disk + // Write the ref test results to the disk. pub fn write_ref_test_results<T>(&self, terminal: &Term<T>) { if !self.config.debug.ref_test { return; } - // dump grid state + // dump grid state. let mut grid = terminal.grid().clone(); grid.initialize_all(&Cell::default()); grid.truncate(); diff --git a/alacritty/src/input.rs b/alacritty/src/input.rs index b84c9a53..f47493b5 100644 --- a/alacritty/src/input.rs +++ b/alacritty/src/input.rs @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. // -//! Handle input from glutin +//! Handle input from glutin. //! //! Certain key combinations should send some escape sequence back to the pty. //! In order to figure that out, state about which modifier keys are pressed @@ -50,7 +50,7 @@ use crate::event::{ClickState, Mouse}; use crate::url::{Url, Urls}; use crate::window::Window; -/// Font size change interval +/// Font size change interval. pub const FONT_SIZE_STEP: f32 = 0.5; /// Processes input from glutin. @@ -100,7 +100,7 @@ trait Execute<T: EventListener> { } impl<T, U: EventListener> Execute<U> for Binding<T> { - /// Execute the action associate with this binding + /// Execute the action associate with this binding. #[inline] fn execute<A: ActionContext<U>>(&self, ctx: &mut A) { self.action.execute(ctx) @@ -116,7 +116,7 @@ impl Action { let cursor_point = ctx.terminal().vi_mode_cursor.point; ctx.toggle_selection(ty, cursor_point, Side::Left); - // Make sure initial selection is not empty + // Make sure initial selection is not empty. if let Some(selection) = ctx.terminal_mut().selection_mut() { selection.include_all(); } @@ -185,7 +185,7 @@ impl<T: EventListener> Execute<T> for Action { Action::DecreaseFontSize => ctx.change_font_size(FONT_SIZE_STEP * -1.), Action::ResetFontSize => ctx.reset_font_size(), Action::ScrollPageUp => { - // Move vi mode cursor + // Move vi mode cursor. let term = ctx.terminal_mut(); let scroll_lines = term.grid().num_lines().0 as isize; term.vi_mode_cursor = term.vi_mode_cursor.scroll(term, scroll_lines); @@ -193,7 +193,7 @@ impl<T: EventListener> Execute<T> for Action { ctx.scroll(Scroll::PageUp); }, Action::ScrollPageDown => { - // Move vi mode cursor + // Move vi mode cursor. let term = ctx.terminal_mut(); let scroll_lines = -(term.grid().num_lines().0 as isize); term.vi_mode_cursor = term.vi_mode_cursor.scroll(term, scroll_lines); @@ -201,7 +201,7 @@ impl<T: EventListener> Execute<T> for Action { ctx.scroll(Scroll::PageDown); }, Action::ScrollHalfPageUp => { - // Move vi mode cursor + // Move vi mode cursor. let term = ctx.terminal_mut(); let scroll_lines = term.grid().num_lines().0 as isize / 2; term.vi_mode_cursor = term.vi_mode_cursor.scroll(term, scroll_lines); @@ -209,7 +209,7 @@ impl<T: EventListener> Execute<T> for Action { ctx.scroll(Scroll::Lines(scroll_lines)); }, Action::ScrollHalfPageDown => { - // Move vi mode cursor + // Move vi mode cursor. let term = ctx.terminal_mut(); let scroll_lines = -(term.grid().num_lines().0 as isize / 2); term.vi_mode_cursor = term.vi_mode_cursor.scroll(term, scroll_lines); @@ -217,7 +217,7 @@ impl<T: EventListener> Execute<T> for Action { ctx.scroll(Scroll::Lines(scroll_lines)); }, Action::ScrollLineUp => { - // Move vi mode cursor + // Move vi mode cursor. let term = ctx.terminal(); if term.grid().display_offset() != term.grid().history_size() && term.vi_mode_cursor.point.line + 1 != term.grid().num_lines() @@ -228,7 +228,7 @@ impl<T: EventListener> Execute<T> for Action { ctx.scroll(Scroll::Lines(1)); }, Action::ScrollLineDown => { - // Move vi mode cursor + // Move vi mode cursor. if ctx.terminal().grid().display_offset() != 0 && ctx.terminal().vi_mode_cursor.point.line.0 != 0 { @@ -240,14 +240,14 @@ impl<T: EventListener> Execute<T> for Action { Action::ScrollToTop => { ctx.scroll(Scroll::Top); - // Move vi mode cursor + // Move vi mode cursor. ctx.terminal_mut().vi_mode_cursor.point.line = Line(0); ctx.terminal_mut().vi_motion(ViMotion::FirstOccupied); }, Action::ScrollToBottom => { ctx.scroll(Scroll::Bottom); - // Move vi mode cursor + // Move vi mode cursor. let term = ctx.terminal_mut(); term.vi_mode_cursor.point.line = term.grid().num_lines() - 1; term.vi_motion(ViMotion::FirstOccupied); @@ -314,7 +314,7 @@ impl<'a, T: EventListener, A: ActionContext<T>> Processor<'a, T, A> { let cell_changed = point.line != self.ctx.mouse().line || point.col != self.ctx.mouse().column; - // If the mouse hasn't changed cells, do nothing + // If the mouse hasn't changed cells, do nothing. if !cell_changed && self.ctx.mouse().cell_side == cell_side && self.ctx.mouse().inside_grid == inside_grid @@ -327,10 +327,10 @@ impl<'a, T: EventListener, A: ActionContext<T>> Processor<'a, T, A> { self.ctx.mouse_mut().line = point.line; self.ctx.mouse_mut().column = point.col; - // Don't launch URLs if mouse has moved + // Don't launch URLs if mouse has moved. self.ctx.mouse_mut().block_url_launcher = true; - // Update mouse state and check for URL change + // Update mouse state and check for URL change. let mouse_state = self.mouse_state(); self.update_url_state(&mouse_state); self.ctx.window_mut().set_mouse_cursor(mouse_state.into()); @@ -339,10 +339,10 @@ impl<'a, T: EventListener, A: ActionContext<T>> Processor<'a, T, A> { if self.ctx.mouse().left_button_state == ElementState::Pressed && (self.ctx.modifiers().shift() || !self.ctx.mouse_mode()) { - // Treat motion over message bar like motion over the last line + // Treat motion over message bar like motion over the last line. let line = min(point.line, last_term_line); - // Move vi mode cursor to mouse cursor position + // Move vi mode cursor to mouse cursor position. if self.ctx.terminal().mode().contains(TermMode::VI) { self.ctx.terminal_mut().vi_mode_cursor.point = point; } @@ -377,7 +377,7 @@ impl<'a, T: EventListener, A: ActionContext<T>> Processor<'a, T, A> { let end_of_grid = size_info.width - size_info.padding_x - additional_padding; if cell_x > half_cell_width - // Edge case when mouse leaves the window + // Edge case when mouse leaves the window. || x as f32 >= end_of_grid { Side::Right @@ -432,7 +432,7 @@ impl<'a, T: EventListener, A: ActionContext<T>> Processor<'a, T, A> { } fn mouse_report(&mut self, button: u8, state: ElementState) { - // Calculate modifiers value + // Calculate modifiers value. let mut mods = 0; let modifiers = self.ctx.modifiers(); if modifiers.shift() { @@ -445,7 +445,7 @@ impl<'a, T: EventListener, A: ActionContext<T>> Processor<'a, T, A> { mods += 16; } - // Report mouse events + // Report mouse events. if self.ctx.terminal().mode().contains(TermMode::SGR_MOUSE) { self.sgr_mouse_report(button + mods, state); } else if let ElementState::Released = state { @@ -456,7 +456,7 @@ impl<'a, T: EventListener, A: ActionContext<T>> Processor<'a, T, A> { } fn on_mouse_press(&mut self, button: MouseButton) { - // Handle mouse mode + // Handle mouse mode. if !self.ctx.modifiers().shift() && self.ctx.mouse_mode() { self.ctx.mouse_mut().click_state = ClickState::None; @@ -464,7 +464,7 @@ impl<'a, T: EventListener, A: ActionContext<T>> Processor<'a, T, A> { MouseButton::Left => 0, MouseButton::Middle => 1, MouseButton::Right => 2, - // Can't properly report more than three buttons. + // Can't properly report more than three buttons.. MouseButton::Other(_) => return, }; @@ -472,19 +472,19 @@ impl<'a, T: EventListener, A: ActionContext<T>> Processor<'a, T, A> { } else if button == MouseButton::Left { self.on_left_click(); } else { - // Do nothing when using buttons other than LMB + // Do nothing when using buttons other than LMB. self.ctx.mouse_mut().click_state = ClickState::None; } } /// Handle left click selection and vi mode cursor movement. fn on_left_click(&mut self) { - // Calculate time since the last click to handle double/triple clicks in normal mode + // Calculate time since the last click to handle double/triple clicks in normal mode. let now = Instant::now(); let elapsed = now - self.ctx.mouse().last_click_timestamp; self.ctx.mouse_mut().last_click_timestamp = now; - // Load mouse point, treating message bar and padding as closest cell + // Load mouse point, treating message bar and padding as closest cell. let mouse = self.ctx.mouse(); let mut point = self.ctx.size_info().pixels_to_coords(mouse.x, mouse.y); point.line = min(point.line, self.ctx.terminal().grid().num_lines() - 1); @@ -507,12 +507,12 @@ impl<'a, T: EventListener, A: ActionContext<T>> Processor<'a, T, A> { ClickState::TripleClick } _ => { - // Don't launch URLs if this click cleared the selection + // Don't launch URLs if this click cleared the selection. self.ctx.mouse_mut().block_url_launcher = !self.ctx.selection_is_empty(); self.ctx.clear_selection(); - // Start new empty selection + // Start new empty selection. if self.ctx.modifiers().ctrl() { self.ctx.start_selection(SelectionType::Block, point, side); } else { @@ -523,9 +523,9 @@ impl<'a, T: EventListener, A: ActionContext<T>> Processor<'a, T, A> { }, }; - // Move vi mode cursor to mouse position + // Move vi mode cursor to mouse position. if self.ctx.terminal().mode().contains(TermMode::VI) { - // Update Vi mode cursor position on click + // Update Vi mode cursor position on click. self.ctx.terminal_mut().vi_mode_cursor.point = point; } } @@ -536,7 +536,7 @@ impl<'a, T: EventListener, A: ActionContext<T>> Processor<'a, T, A> { MouseButton::Left => 0, MouseButton::Middle => 1, MouseButton::Right => 2, - // Can't properly report more than three buttons. + // Can't properly report more than three buttons.. MouseButton::Other(_) => return, }; self.mouse_report(code, ElementState::Released); @@ -557,7 +557,7 @@ impl<'a, T: EventListener, A: ActionContext<T>> Processor<'a, T, A> { MouseScrollDelta::PixelDelta(lpos) => { match phase { TouchPhase::Started => { - // Reset offset to zero + // Reset offset to zero. self.ctx.mouse_mut().scroll_px = 0.; }, TouchPhase::Moved => { @@ -613,18 +613,18 @@ impl<'a, T: EventListener, A: ActionContext<T>> Processor<'a, T, A> { let lines = self.ctx.mouse().scroll_px / height; - // Store absolute position of vi mode cursor + // Store absolute position of vi mode cursor. let term = self.ctx.terminal(); let absolute = term.visible_to_buffer(term.vi_mode_cursor.point); self.ctx.scroll(Scroll::Lines(lines as isize)); - // Try to restore vi mode cursor position, to keep it above its previous content + // Try to restore vi mode cursor position, to keep it above its previous content. let term = self.ctx.terminal_mut(); term.vi_mode_cursor.point = term.grid().clamp_buffer_to_visible(absolute); term.vi_mode_cursor.point.col = absolute.col; - // Update selection + // Update selection. if term.mode().contains(TermMode::VI) { let point = term.vi_mode_cursor.point; if !self.ctx.selection_is_empty() { @@ -653,12 +653,12 @@ impl<'a, T: EventListener, A: ActionContext<T>> Processor<'a, T, A> { _ => (), } - // Skip normal mouse events if the message bar has been clicked + // Skip normal mouse events if the message bar has been clicked. if self.message_close_at_cursor() && state == ElementState::Pressed { self.ctx.clear_selection(); self.ctx.pop_message(); - // Reset cursor when message bar height changed or all messages are gone + // Reset cursor when message bar height changed or all messages are gone. let size = self.ctx.size_info(); let current_lines = (size.lines() - self.ctx.terminal().grid().num_lines()).0; let new_lines = self.ctx.message().map(|m| m.text(&size).len()).unwrap_or(0); @@ -702,7 +702,7 @@ impl<'a, T: EventListener, A: ActionContext<T>> Processor<'a, T, A> { pub fn modifiers_input(&mut self, modifiers: ModifiersState) { *self.ctx.modifiers() = modifiers; - // Update mouse state and check for URL change + // Update mouse state and check for URL change. let mouse_state = self.mouse_state(); self.update_url_state(&mouse_state); self.ctx.window_mut().set_mouse_cursor(mouse_state.into()); @@ -762,16 +762,16 @@ impl<'a, T: EventListener, A: ActionContext<T>> Processor<'a, T, A> { }; if binding.is_triggered_by(*self.ctx.terminal().mode(), mods, &key) { - // Binding was triggered; run the action + // Binding was triggered; run the action. let binding = binding.clone(); binding.execute(&mut self.ctx); - // Don't suppress when there has been a `ReceiveChar` action + // Don't suppress when there has been a `ReceiveChar` action. *suppress_chars.get_or_insert(true) &= binding.action != Action::ReceiveChar; } } - // Don't suppress char if no bindings were triggered + // Don't suppress char if no bindings were triggered. *self.ctx.suppress_chars() = suppress_chars.unwrap_or(false); } @@ -787,7 +787,7 @@ impl<'a, T: EventListener, A: ActionContext<T>> Processor<'a, T, A> { for i in 0..self.ctx.config().ui_config.mouse_bindings.len() { let mut binding = self.ctx.config().ui_config.mouse_bindings[i].clone(); - // Require shift for all modifiers when mouse mode is active + // Require shift for all modifiers when mouse mode is active. if mouse_mode { binding.mods |= ModifiersState::SHIFT; } @@ -803,7 +803,7 @@ impl<'a, T: EventListener, A: ActionContext<T>> Processor<'a, T, A> { self.ctx.mouse().line >= self.ctx.terminal().grid().num_lines() } - /// Whether the point is over the message bar's close button + /// Whether the point is over the message bar's close button. fn message_close_at_cursor(&self) -> bool { let mouse = self.ctx.mouse(); mouse.inside_grid @@ -833,7 +833,7 @@ impl<'a, T: EventListener, A: ActionContext<T>> Processor<'a, T, A> { /// Location of the mouse cursor. fn mouse_state(&mut self) -> MouseState { - // Check message bar before URL to ignore URLs in the message bar + // Check message bar before URL to ignore URLs in the message bar. if self.message_close_at_cursor() { return MouseState::MessageBarButton; } else if self.message_at_cursor() { @@ -842,7 +842,7 @@ impl<'a, T: EventListener, A: ActionContext<T>> Processor<'a, T, A> { let mouse_mode = self.ctx.mouse_mode(); - // Check for URL at mouse cursor + // Check for URL at mouse cursor. let mods = *self.ctx.modifiers(); let highlighted_url = self.ctx.urls().highlighted( self.ctx.config(), @@ -856,7 +856,7 @@ impl<'a, T: EventListener, A: ActionContext<T>> Processor<'a, T, A> { return MouseState::Url(url); } - // Check mouse mode if location is not special + // Check mouse mode if location is not special. if !self.ctx.modifiers().shift() && mouse_mode { MouseState::Mouse } else { diff --git a/alacritty/src/logging.rs b/alacritty/src/logging.rs index 569135ec..defa4605 100644 --- a/alacritty/src/logging.rs +++ b/alacritty/src/logging.rs @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. // -//! Logging for alacritty. +//! Logging for Alacritty. //! //! The main executable is supposed to call `initialize()` exactly once during //! startup. All logging messages are written to stdout, given that their @@ -151,19 +151,19 @@ impl OnDemandLogFile { let mut path = env::temp_dir(); path.push(format!("Alacritty-{}.log", process::id())); - // Set log path as an environment variable + // Set log path as an environment variable. env::set_var(ALACRITTY_LOG_ENV, path.as_os_str()); OnDemandLogFile { path, file: None, created: Arc::new(AtomicBool::new(false)) } } fn file(&mut self) -> Result<&mut LineWriter<File>, io::Error> { - // Allow to recreate the file if it has been deleted at runtime + // Allow to recreate the file if it has been deleted at runtime. if self.file.is_some() && !self.path.as_path().exists() { self.file = None; } - // Create the file if it doesn't exist yet + // Create the file if it doesn't exist yet. if self.file.is_none() { let file = OpenOptions::new().append(true).create(true).open(&self.path); diff --git a/alacritty/src/main.rs b/alacritty/src/main.rs index 6bb9041c..6088f86a 100644 --- a/alacritty/src/main.rs +++ b/alacritty/src/main.rs @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. // -//! Alacritty - The GPU Enhanced Terminal +//! Alacritty - The GPU Enhanced Terminal. #![deny(clippy::all, clippy::if_not_else, clippy::enum_glob_use, clippy::wrong_pub_self_convention)] #![cfg_attr(feature = "nightly", feature(core_intrinsics))] #![cfg_attr(all(test, feature = "bench"), feature(test))] @@ -83,41 +83,41 @@ fn main() { AttachConsole(ATTACH_PARENT_PROCESS); } - // Load command line options + // Load command line options. let options = Options::new(); - // Setup glutin event loop + // Setup glutin event loop. let window_event_loop = GlutinEventLoop::<Event>::with_user_event(); - // Initialize the logger as soon as possible as to capture output from other subsystems + // Initialize the logger as soon as possible as to capture output from other subsystems. let log_file = logging::initialize(&options, window_event_loop.create_proxy()) .expect("Unable to initialize logger"); - // Load configuration file + // Load configuration file. let config_path = options.config_path().or_else(config::installed_config); let config = config_path.map(config::load_from).unwrap_or_else(Config::default); let config = options.into_config(config); - // Update the log level from config + // Update the log level from config. log::set_max_level(config.debug.log_level); - // Switch to home directory + // Switch to home directory. #[cfg(target_os = "macos")] env::set_current_dir(dirs::home_dir().unwrap()).unwrap(); - // Set locale + // Set locale. #[cfg(target_os = "macos")] locale::set_locale_environment(); - // Store if log file should be deleted before moving config + // Store if log file should be deleted before moving config. let persistent_logging = config.persistent_logging(); - // Run alacritty + // Run Alacritty. if let Err(err) = run(window_event_loop, config) { error!("Alacritty encountered an unrecoverable error:\n\n\t{}\n", err); std::process::exit(1); } - // Clean up logfile + // Clean up logfile. if let Some(log_file) = log_file { if !persistent_logging && fs::remove_file(&log_file).is_ok() { let _ = writeln!(io::stdout(), "Deleted log file at \"{}\"", log_file.display()); @@ -125,7 +125,7 @@ fn main() { } } -/// Run Alacritty +/// Run Alacritty. /// /// Creates a window, the terminal state, pty, I/O event loop, input processor, /// config change monitor, and runs the main display loop. @@ -137,25 +137,25 @@ fn run(window_event_loop: GlutinEventLoop<Event>, config: Config) -> Result<(), None => info!("No configuration file found"), } - // Set environment variables + // Set environment variables. tty::setup_env(&config); let event_proxy = EventProxy::new(window_event_loop.create_proxy()); - // Create a display + // Create a display. // // The display manages a window and can draw the terminal. let display = Display::new(&config, &window_event_loop)?; - info!("PTY Dimensions: {:?} x {:?}", display.size_info.lines(), display.size_info.cols()); + info!("pty dimensions: {:?} x {:?}", display.size_info.lines(), display.size_info.cols()); - // Create new native clipboard + // Create new native clipboard. #[cfg(not(any(target_os = "macos", windows)))] let clipboard = Clipboard::new(display.window.wayland_display()); #[cfg(any(target_os = "macos", windows))] let clipboard = Clipboard::new(); - // Create the terminal + // Create the terminal. // // This object contains all of the state about what's being displayed. It's // wrapped in a clonable mutex since both the I/O loop and display need to @@ -163,7 +163,7 @@ fn run(window_event_loop: GlutinEventLoop<Event>, config: Config) -> Result<(), let terminal = Term::new(&config, &display.size_info, clipboard, event_proxy.clone()); let terminal = Arc::new(FairMutex::new(terminal)); - // Create the pty + // Create the pty. // // The pty forks a process to run the shell on the slave side of the // pseudoterminal. A file descriptor for the master side is retained for @@ -173,7 +173,7 @@ fn run(window_event_loop: GlutinEventLoop<Event>, config: Config) -> Result<(), #[cfg(any(target_os = "macos", windows))] let pty = tty::new(&config, &display.size_info, None); - // Create the pseudoterminal I/O loop + // Create the pseudoterminal I/O loop. // // pty I/O is ran on another thread as to not occupy cycles used by the // renderer and input processing. Note that access to the terminal state is @@ -185,7 +185,7 @@ fn run(window_event_loop: GlutinEventLoop<Event>, config: Config) -> Result<(), // to be sent to the pty loop and ultimately written to the pty. let loop_tx = event_loop.channel(); - // Create a config monitor when config was loaded from path + // Create a config monitor when config was loaded from path. // // The monitor watches the config file for changes and reloads it. Pending // config changes are processed in the main loop. @@ -193,19 +193,19 @@ fn run(window_event_loop: GlutinEventLoop<Event>, config: Config) -> Result<(), config.config_path.as_ref().map(|path| Monitor::new(path, event_proxy.clone())); } - // Setup storage for message UI + // Setup storage for message UI. let message_buffer = MessageBuffer::new(); - // Event processor + // Event processor. let mut processor = Processor::new(event_loop::Notifier(loop_tx.clone()), message_buffer, config, display); - // Kick off the I/O thread + // Kick off the I/O thread. let io_thread = event_loop.spawn(); info!("Initialisation complete"); - // Start event loop and block until shutdown + // Start event loop and block until shutdown. processor.run(terminal, window_event_loop); // This explicit drop is needed for Windows, ConPTY backend. Otherwise a deadlock can occur. @@ -218,17 +218,17 @@ fn run(window_event_loop: GlutinEventLoop<Event>, config: Config) -> Result<(), // The fix is to ensure that processor is dropped first. That way, when io_thread (i.e. pty) // is dropped, it can ensure Conpty is dropped before the conout pipe in the pty drop order. // - // FIXME: Change PTY API to enforce the correct drop order with the typesystem. + // FIXME: Change pty API to enforce the correct drop order with the typesystem. drop(processor); - // Shutdown PTY parser event loop + // Shutdown pty parser event loop. loop_tx.send(Msg::Shutdown).expect("Error sending shutdown to pty event loop"); io_thread.join().expect("join io thread"); - // FIXME patch notify library to have a shutdown method + // FIXME patch notify library to have a shutdown method. // config_reloader.join().ok(); - // Without explicitly detaching the console cmd won't redraw it's prompt + // Without explicitly detaching the console cmd won't redraw it's prompt. #[cfg(windows)] unsafe { FreeConsole(); diff --git a/alacritty/src/renderer/mod.rs b/alacritty/src/renderer/mod.rs index f62e6f8d..f2638ad5 100644 --- a/alacritty/src/renderer/mod.rs +++ b/alacritty/src/renderer/mod.rs @@ -42,13 +42,13 @@ use std::fmt::{self, Display, Formatter}; pub mod rects; -// Shader paths for live reload +// Shader paths for live reload. static TEXT_SHADER_F_PATH: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/../res/text.f.glsl"); static TEXT_SHADER_V_PATH: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/../res/text.v.glsl"); static RECT_SHADER_F_PATH: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/../res/rect.f.glsl"); static RECT_SHADER_V_PATH: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/../res/rect.v.glsl"); -// Shader source which is used when live-shader-reload feature is disable +// Shader source which is used when live-shader-reload feature is disable. static TEXT_SHADER_F: &str = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/../res/text.f.glsl")); static TEXT_SHADER_V: &str = @@ -58,12 +58,12 @@ static RECT_SHADER_F: &str = static RECT_SHADER_V: &str = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/../res/rect.v.glsl")); -/// `LoadGlyph` allows for copying a rasterized glyph into graphics memory +/// `LoadGlyph` allows for copying a rasterized glyph into graphics memory. pub trait LoadGlyph { - /// Load the rasterized glyph into GPU memory + /// Load the rasterized glyph into GPU memory. fn load_glyph(&mut self, rasterized: &RasterizedGlyph) -> Glyph; - /// Clear any state accumulated from previous loaded glyphs + /// Clear any state accumulated from previous loaded glyphs. /// /// This can, for instance, be used to reset the texture Atlas. fn clear(&mut self); @@ -102,34 +102,34 @@ impl From<ShaderCreationError> for Error { } } -/// Text drawing program +/// Text drawing program. /// /// Uniforms are prefixed with "u", and vertex attributes are prefixed with "a". #[derive(Debug)] pub struct TextShaderProgram { - // Program id + /// Program id. id: GLuint, - /// projection scale and offset uniform + /// projection scale and offset uniform. u_projection: GLint, - /// Cell dimensions (pixels) + /// Cell dimensions (pixels). u_cell_dim: GLint, - /// Background pass flag + /// Background pass flag. /// - /// Rendering is split into two passes; 1 for backgrounds, and one for text + /// Rendering is split into two passes; 1 for backgrounds, and one for text. u_background: GLint, } -/// Rectangle drawing program +/// Rectangle drawing program. /// -/// Uniforms are prefixed with "u" +/// Uniforms are prefixed with "u". #[derive(Debug)] pub struct RectShaderProgram { - // Program id + /// Program id. id: GLuint, - /// Rectangle color + /// Rectangle color. u_color: GLint, } @@ -147,38 +147,39 @@ pub struct Glyph { uv_height: f32, } -/// Naïve glyph cache +/// Naïve glyph cache. /// /// Currently only keyed by `char`, and thus not possible to hold different /// representations of the same code point. pub struct GlyphCache { - /// Cache of buffered glyphs + /// Cache of buffered glyphs. cache: HashMap<GlyphKey, Glyph, BuildHasherDefault<FnvHasher>>, - /// Cache of buffered cursor glyphs + /// Cache of buffered cursor glyphs. cursor_cache: HashMap<CursorKey, Glyph, BuildHasherDefault<FnvHasher>>, - /// Rasterizer for loading new glyphs + /// Rasterizer for loading new glyphs. rasterizer: Rasterizer, - /// regular font + /// Regular font. font_key: FontKey, - /// bold font + /// Bold font. bold_key: FontKey, - /// italic font + /// Italic font. italic_key: FontKey, - /// bold italic font + /// Bold italic font. bold_italic_key: FontKey, - /// font size + /// Font size. font_size: font::Size, - /// glyph offset + /// Glyph offset. glyph_offset: Delta<i8>, + /// Font metrics. metrics: font::Metrics, } @@ -225,20 +226,20 @@ impl GlyphCache { } } - /// Computes font keys for (Regular, Bold, Italic, Bold Italic) + /// Computes font keys for (Regular, Bold, Italic, Bold Italic). fn compute_font_keys( font: &config::Font, rasterizer: &mut Rasterizer, ) -> Result<(FontKey, FontKey, FontKey, FontKey), font::Error> { let size = font.size; - // Load regular font + // Load regular font. let regular_desc = Self::make_desc(&font.normal(), font::Slant::Normal, font::Weight::Normal); let regular = rasterizer.load_font(®ular_desc, size)?; - // helper to load a description if it is not the regular_desc + // helper to load a description if it is not the regular_desc. let mut load_or_regular = |desc: FontDesc| { if desc == regular_desc { regular @@ -247,18 +248,18 @@ impl GlyphCache { } }; - // Load bold font + // Load bold font. let bold_desc = Self::make_desc(&font.bold(), font::Slant::Normal, font::Weight::Bold); let bold = load_or_regular(bold_desc); - // Load italic font + // Load italic font. let italic_desc = Self::make_desc(&font.italic(), font::Slant::Italic, font::Weight::Normal); let italic = load_or_regular(italic_desc); - // Load bold italic font + // Load bold italic font. let bold_italic_desc = Self::make_desc(&font.bold_italic(), font::Slant::Italic, font::Weight::Bold); @@ -314,10 +315,10 @@ impl GlyphCache { dpr: f64, loader: &mut L, ) -> Result<(), font::Error> { - // Update dpi scaling + // Update dpi scaling. self.rasterizer.update_dpr(dpr as f32); - // Recompute font keys + // Recompute font keys. let (regular, bold, italic, bold_italic) = Self::compute_font_keys(&font, &mut self.rasterizer)?; @@ -350,7 +351,7 @@ impl GlyphCache { self.load_glyphs_for_font(self.bold_italic_key, loader); } - // Calculate font metrics without access to a glyph cache + /// Calculate font metrics without access to a glyph cache. pub fn static_metrics(font: Font, dpr: f64) -> Result<font::Metrics, font::Error> { let mut rasterizer = font::Rasterizer::new(dpr as f32, font.use_thin_strokes())?; let regular_desc = @@ -379,7 +380,7 @@ impl GlyphCache { let padding_x = f64::from(config.window.padding.x) * dpr; let padding_y = f64::from(config.window.padding.y) * dpr; - // Calculate new size based on cols/lines specified in config + // Calculate new size based on cols/lines specified in config. let grid_width = cell_width as u32 * dimensions.columns_u32(); let grid_height = cell_height as u32 * dimensions.lines_u32(); @@ -393,26 +394,26 @@ impl GlyphCache { #[derive(Debug)] #[repr(C)] struct InstanceData { - // coords + // Coords. col: f32, row: f32, - // glyph offset + // Glyph offset. left: f32, top: f32, - // glyph scale + // Glyph scale. width: f32, height: f32, - // uv offset + // uv offset. uv_left: f32, uv_bot: f32, - // uv scale + // uv scale. uv_width: f32, uv_height: f32, - // color + // Color. r: f32, g: f32, b: f32, - // background color + // Background color. bg_r: f32, bg_g: f32, bg_b: f32, @@ -556,7 +557,7 @@ impl QuadRenderer { gl::BlendFunc(gl::SRC1_COLOR, gl::ONE_MINUS_SRC1_COLOR); gl::Enable(gl::MULTISAMPLE); - // Disable depth mask, as the renderer never uses depth tests + // Disable depth mask, as the renderer never uses depth tests. gl::DepthMask(gl::FALSE); gl::GenVertexArrays(1, &mut vao); @@ -587,7 +588,7 @@ impl QuadRenderer { ptr::null(), gl::STREAM_DRAW, ); - // coords + // Coords. gl::VertexAttribPointer( 0, 2, @@ -598,7 +599,7 @@ impl QuadRenderer { ); gl::EnableVertexAttribArray(0); gl::VertexAttribDivisor(0, 1); - // glyphoffset + // Glyph offset. gl::VertexAttribPointer( 1, 4, @@ -609,7 +610,7 @@ impl QuadRenderer { ); gl::EnableVertexAttribArray(1); gl::VertexAttribDivisor(1, 1); - // uv + // uv. gl::VertexAttribPointer( 2, 4, @@ -620,7 +621,7 @@ impl QuadRenderer { ); gl::EnableVertexAttribArray(2); gl::VertexAttribDivisor(2, 1); - // color + // Color. gl::VertexAttribPointer( 3, 3, @@ -631,7 +632,7 @@ impl QuadRenderer { ); gl::EnableVertexAttribArray(3); gl::VertexAttribDivisor(3, 1); - // color + // Background color. gl::VertexAttribPointer( 4, 4, @@ -643,7 +644,7 @@ impl QuadRenderer { gl::EnableVertexAttribArray(4); gl::VertexAttribDivisor(4, 1); - // Rectangle setup + // Rectangle setup. gl::GenVertexArrays(1, &mut rect_vao); gl::GenBuffers(1, &mut rect_vbo); gl::GenBuffers(1, &mut rect_ebo); @@ -657,7 +658,7 @@ impl QuadRenderer { gl::STATIC_DRAW, ); - // Cleanup + // Cleanup. gl::BindVertexArray(0); gl::BindBuffer(gl::ARRAY_BUFFER, 0); gl::BindBuffer(gl::ELEMENT_ARRAY_BUFFER, 0); @@ -715,24 +716,24 @@ impl QuadRenderer { Ok(renderer) } - // Draw all rectangles simultaneously to prevent excessive program swaps + /// Draw all rectangles simultaneously to prevent excessive program swaps. pub fn draw_rects(&mut self, props: &term::SizeInfo, rects: Vec<RenderRect>) { - // Swap to rectangle rendering program + // Swap to rectangle rendering program. unsafe { - // Swap program + // Swap program. gl::UseProgram(self.rect_program.id); - // Remove padding from viewport + // Remove padding from viewport. gl::Viewport(0, 0, props.width as i32, props.height as i32); - // Change blending strategy + // Change blending strategy. gl::BlendFuncSeparate(gl::SRC_ALPHA, gl::ONE_MINUS_SRC_ALPHA, gl::SRC_ALPHA, gl::ONE); - // Setup data and buffers + // Setup data and buffers. gl::BindVertexArray(self.rect_vao); gl::BindBuffer(gl::ARRAY_BUFFER, self.rect_vbo); - // Position + // Position. gl::VertexAttribPointer( 0, 2, @@ -744,17 +745,17 @@ impl QuadRenderer { gl::EnableVertexAttribArray(0); } - // Draw all the rects + // Draw all the rects. for rect in rects { self.render_rect(&rect, props); } - // Deactivate rectangle program again + // Deactivate rectangle program again. unsafe { - // Reset blending strategy + // Reset blending strategy. gl::BlendFunc(gl::SRC1_COLOR, gl::ONE_MINUS_SRC1_COLOR); - // Reset data and buffers + // Reset data and buffers. gl::BindBuffer(gl::ARRAY_BUFFER, 0); gl::BindVertexArray(0); @@ -764,7 +765,7 @@ impl QuadRenderer { let height = props.height as i32; gl::Viewport(padding_x, padding_y, width - 2 * padding_x, height - 2 * padding_y); - // Disable program + // Disable program. gl::UseProgram(0); } } @@ -773,7 +774,7 @@ impl QuadRenderer { where F: FnOnce(RenderApi<'_, C>) -> T, { - // Flush message queue + // Flush message queue. if let Ok(Msg::ShaderReload) = self.rx.try_recv() { self.reload_shaders(props); } @@ -855,7 +856,7 @@ impl QuadRenderer { } pub fn resize(&mut self, size: &SizeInfo) { - // viewport + // Viewport. unsafe { gl::Viewport( size.padding_x as i32, @@ -864,23 +865,23 @@ impl QuadRenderer { size.height as i32 - 2 * size.padding_y as i32, ); - // update projection + // Update projection. gl::UseProgram(self.program.id); self.program.update_projection(size.width, size.height, size.padding_x, size.padding_y); gl::UseProgram(0); } } - // Render a rectangle - // - // This requires the rectangle program to be activated + /// Render a rectangle. + /// + /// This requires the rectangle program to be activated. fn render_rect(&mut self, rect: &RenderRect, size: &term::SizeInfo) { - // Do nothing when alpha is fully transparent + // Do nothing when alpha is fully transparent. if rect.alpha == 0. { return; } - // Calculate rectangle position + // Calculate rectangle position. let center_x = size.width / 2.; let center_y = size.height / 2.; let x = (rect.x - center_x) / center_x; @@ -889,10 +890,10 @@ impl QuadRenderer { let height = rect.height / center_y; unsafe { - // Setup vertices + // Setup vertices. let vertices: [f32; 8] = [x + width, y, x + width, y - height, x, y - height, x, y]; - // Load vertex data into array buffer + // Load vertex data into array buffer. gl::BufferData( gl::ARRAY_BUFFER, (size_of::<f32>() * vertices.len()) as _, @@ -900,10 +901,10 @@ impl QuadRenderer { gl::STATIC_DRAW, ); - // Color + // Color. self.rect_program.set_color(rect.color, rect.alpha); - // Draw the rectangle + // Draw the rectangle. gl::DrawElements(gl::TRIANGLES, 6, gl::UNSIGNED_INT, ptr::null()); } } @@ -939,7 +940,7 @@ impl<'a, C> RenderApi<'a, C> { ); } - // Bind texture if necessary + // Bind texture if necessary. if *self.active_tex != self.batch.tex { unsafe { gl::BindTexture(gl::TEXTURE_2D, self.batch.tex); @@ -1006,14 +1007,14 @@ impl<'a, C> RenderApi<'a, C> { #[inline] fn add_render_item(&mut self, cell: RenderableCell, glyph: &Glyph) { - // Flush batch if tex changing + // Flush batch if tex changing. if !self.batch.is_empty() && self.batch.tex != glyph.tex_id { self.render_batch(); } self.batch.add_item(cell, glyph); - // Render batch and clear if it's full + // Render batch and clear if it's full. if self.batch.full() { self.render_batch(); } @@ -1022,7 +1023,7 @@ impl<'a, C> RenderApi<'a, C> { pub fn render_cell(&mut self, cell: RenderableCell, glyph_cache: &mut GlyphCache) { let chars = match cell.inner { RenderableCellContent::Cursor(cursor_key) => { - // Raw cell pixel buffers like cursors don't need to go through font lookup + // Raw cell pixel buffers like cursors don't need to go through font lookup. let metrics = glyph_cache.metrics; let glyph = glyph_cache.cursor_cache.entry(cursor_key).or_insert_with(|| { self.load_glyph(&cursor::get_cursor_glyph( @@ -1040,7 +1041,7 @@ impl<'a, C> RenderApi<'a, C> { RenderableCellContent::Chars(chars) => chars, }; - // Get font key for cell + // Get font key for cell. let font_key = match cell.flags & Flags::BOLD_ITALIC { Flags::BOLD_ITALIC => glyph_cache.bold_italic_key, Flags::ITALIC => glyph_cache.italic_key, @@ -1048,25 +1049,25 @@ impl<'a, C> RenderApi<'a, C> { _ => glyph_cache.font_key, }; - // Don't render text of HIDDEN cells + // Don't render text of HIDDEN cells. let mut chars = if cell.flags.contains(Flags::HIDDEN) { [' '; cell::MAX_ZEROWIDTH_CHARS + 1] } else { chars }; - // Render tabs as spaces in case the font doesn't support it + // Render tabs as spaces in case the font doesn't support it. if chars[0] == '\t' { chars[0] = ' '; } let mut glyph_key = GlyphKey { font_key, size: glyph_cache.font_size, c: chars[0] }; - // Add cell to batch + // Add cell to batch. let glyph = glyph_cache.get(glyph_key, self); self.add_render_item(cell, glyph); - // Render zero-width characters + // Render zero-width characters. for c in (&chars[1..]).iter().filter(|c| **c != ' ') { glyph_key.c = *c; let mut glyph = *glyph_cache.get(glyph_key, self); @@ -1083,7 +1084,7 @@ impl<'a, C> RenderApi<'a, C> { } } -/// Load a glyph into a texture atlas +/// Load a glyph into a texture atlas. /// /// If the current atlas is full, a new one will be created. #[inline] @@ -1216,12 +1217,12 @@ impl TextShaderProgram { } fn update_projection(&self, width: f32, height: f32, padding_x: f32, padding_y: f32) { - // Bounds check + // Bounds check. if (width as u32) < (2 * padding_x as u32) || (height as u32) < (2 * padding_y as u32) { return; } - // Compute scale and offset factors, from pixel to ndc space. Y is inverted + // Compute scale and offset factors, from pixel to ndc space. Y is inverted. // [0, width - 2 * padding_x] to [-1, 1] // [height - 2 * padding_y, 0] to [-1, 1] let scale_x = 2. / (width - 2. * padding_x); @@ -1276,7 +1277,7 @@ impl RectShaderProgram { gl::UseProgram(program); } - // get uniform locations + // get uniform locations. let u_color = unsafe { gl::GetUniformLocation(program, b"color\0".as_ptr() as *const _) }; let shader = Self { id: program, u_color }; @@ -1355,10 +1356,10 @@ fn create_shader( if success == GLint::from(gl::TRUE) { Ok(shader) } else { - // Read log + // Read log. let log = get_shader_info_log(shader); - // Cleanup + // Cleanup. unsafe { gl::DeleteShader(shader); } @@ -1368,60 +1369,60 @@ fn create_shader( } fn get_program_info_log(program: GLuint) -> String { - // Get expected log length + // Get expected log length. let mut max_length: GLint = 0; unsafe { gl::GetProgramiv(program, gl::INFO_LOG_LENGTH, &mut max_length); } - // Read the info log + // Read the info log. let mut actual_length: GLint = 0; let mut buf: Vec<u8> = Vec::with_capacity(max_length as usize); unsafe { gl::GetProgramInfoLog(program, max_length, &mut actual_length, buf.as_mut_ptr() as *mut _); } - // Build a string + // Build a string. unsafe { buf.set_len(actual_length as usize); } - // XXX should we expect opengl to return garbage? + // XXX should we expect OpenGL to return garbage? String::from_utf8(buf).unwrap() } fn get_shader_info_log(shader: GLuint) -> String { - // Get expected log length + // Get expected log length. let mut max_length: GLint = 0; unsafe { gl::GetShaderiv(shader, gl::INFO_LOG_LENGTH, &mut max_length); } - // Read the info log + // Read the info log. let mut actual_length: GLint = 0; let mut buf: Vec<u8> = Vec::with_capacity(max_length as usize); unsafe { gl::GetShaderInfoLog(shader, max_length, &mut actual_length, buf.as_mut_ptr() as *mut _); } - // Build a string + // Build a string. unsafe { buf.set_len(actual_length as usize); } - // XXX should we expect opengl to return garbage? + // XXX should we expect OpenGL to return garbage?. String::from_utf8(buf).unwrap() } #[derive(Debug)] pub enum ShaderCreationError { - /// Error reading file + /// Error reading file. Io(io::Error), - /// Error compiling shader + /// Error compiling shader. Compile(PathBuf, String), - /// Problem linking + /// Problem linking. Link(String), } @@ -1452,7 +1453,7 @@ impl From<io::Error> for ShaderCreationError { } } -/// Manages a single texture atlas +/// Manages a single texture atlas. /// /// The strategy for filling an atlas looks roughly like this: /// @@ -1472,36 +1473,36 @@ impl From<io::Error> for ShaderCreationError { /// ``` #[derive(Debug)] struct Atlas { - /// Texture id for this atlas + /// Texture id for this atlas. id: GLuint, - /// Width of atlas + /// Width of atlas. width: i32, - /// Height of atlas + /// Height of atlas. height: i32, - /// Left-most free pixel in a row. + /// Left-most free pixel in a row.. /// /// This is called the extent because it is the upper bound of used pixels /// in a row. row_extent: i32, - /// Baseline for glyphs in the current row + /// Baseline for glyphs in the current row. row_baseline: i32, - /// Tallest glyph in current row + /// Tallest glyph in current row. /// - /// This is used as the advance when end of row is reached + /// This is used as the advance when end of row is reached. row_tallest: i32, } -/// Error that can happen when inserting a texture to the Atlas +/// Error that can happen when inserting a texture to the Atlas. enum AtlasInsertError { - /// Texture atlas is full + /// Texture atlas is full. Full, - /// The glyph cannot fit within a single texture + /// The glyph cannot fit within a single texture. GlyphTooLarge, } @@ -1541,7 +1542,7 @@ impl Atlas { self.row_tallest = 0; } - /// Insert a RasterizedGlyph into the texture atlas + /// Insert a RasterizedGlyph into the texture atlas. pub fn insert( &mut self, glyph: &RasterizedGlyph, @@ -1551,21 +1552,21 @@ impl Atlas { return Err(AtlasInsertError::GlyphTooLarge); } - // If there's not enough room in current row, go onto next one + // If there's not enough room in current row, go onto next one. if !self.room_in_row(glyph) { self.advance_row()?; } - // If there's still not room, there's nothing that can be done here. + // If there's still not room, there's nothing that can be done here.. if !self.room_in_row(glyph) { return Err(AtlasInsertError::Full); } - // There appears to be room; load the glyph. + // There appears to be room; load the glyph.. Ok(self.insert_inner(glyph, active_tex)) } - /// Insert the glyph without checking for room + /// Insert the glyph without checking for room. /// /// Internal function for use once atlas has been checked for space. GL /// errors could still occur at this point if we were checking for them; @@ -1580,7 +1581,7 @@ impl Atlas { unsafe { gl::BindTexture(gl::TEXTURE_2D, self.id); - // Load data into OpenGL + // Load data into OpenGL. let (format, buf) = match &glyph.buf { BitmapBuffer::RGB(buf) => { colored = false; @@ -1608,13 +1609,13 @@ impl Atlas { *active_tex = 0; } - // Update Atlas state + // Update Atlas state. self.row_extent = offset_x + width; if height > self.row_tallest { self.row_tallest = height; } - // Generate UV coordinates + // Generate UV coordinates. let uv_bot = offset_y as f32 / self.height as f32; let uv_left = offset_x as f32 / self.width as f32; let uv_height = height as f32 / self.height as f32; @@ -1634,7 +1635,7 @@ impl Atlas { } } - /// Check if there's room in the current row for given glyph + /// Check if there's room in the current row for given glyph. fn room_in_row(&self, raw: &RasterizedGlyph) -> bool { let next_extent = self.row_extent + raw.width as i32; let enough_width = next_extent <= self.width; @@ -1643,7 +1644,7 @@ impl Atlas { enough_width && enough_height } - /// Mark current row as finished and prepare to insert into the next row + /// Mark current row as finished and prepare to insert into the next row. fn advance_row(&mut self) -> Result<(), AtlasInsertError> { let advance_to = self.row_baseline + self.row_tallest; if self.height - advance_to <= 0 { diff --git a/alacritty/src/renderer/rects.rs b/alacritty/src/renderer/rects.rs index 796abe6e..93ed9eab 100644 --- a/alacritty/src/renderer/rects.rs +++ b/alacritty/src/renderer/rects.rs @@ -80,7 +80,7 @@ impl RenderLine { _ => unimplemented!("Invalid flag for cell line drawing specified"), }; - // Make sure lines are always visible + // Make sure lines are always visible. height = height.max(1.); let line_bottom = (start.line.0 as f32 + 1.) * size.cell_height; @@ -124,19 +124,19 @@ impl RenderLines { continue; } - // Check if there's an active line + // Check if there's an active line. if let Some(line) = self.inner.get_mut(flag).and_then(|lines| lines.last_mut()) { if cell.fg == line.color && cell.column == line.end.col + 1 && cell.line == line.end.line { - // Update the length of the line + // Update the length of the line. line.end = cell.into(); continue; } } - // Start new line if there currently is none + // Start new line if there currently is none. let line = RenderLine { start: cell.into(), end: cell.into(), color: cell.fg }; match self.inner.get_mut(flag) { Some(lines) => lines.push(line), diff --git a/alacritty/src/url.rs b/alacritty/src/url.rs index fcdd477f..72452a9e 100644 --- a/alacritty/src/url.rs +++ b/alacritty/src/url.rs @@ -71,9 +71,9 @@ impl Urls { Self::default() } - // Update tracked URLs + /// Update tracked URLs. pub fn update(&mut self, num_cols: usize, cell: RenderableCell) { - // Convert cell to character + // Convert cell to character. let c = match cell.inner { RenderableCellContent::Chars(chars) => chars[0], RenderableCellContent::Cursor(_) => return, @@ -82,14 +82,14 @@ impl Urls { let point: Point = cell.into(); let end = point; - // Reset URL when empty cells have been skipped + // Reset URL when empty cells have been skipped. if point != Point::default() && Some(point.sub(num_cols, 1)) != self.last_point { self.reset(); } self.last_point = Some(end); - // Extend current state if a wide char spacer is encountered + // Extend current state if a wide char spacer is encountered. if cell.flags.contains(Flags::WIDE_CHAR_SPACER) { if let UrlLocation::Url(_, mut end_offset) = self.state { if end_offset != 0 { @@ -102,20 +102,20 @@ impl Urls { return; } - // Advance parser + // Advance parser. let last_state = mem::replace(&mut self.state, self.locator.advance(c)); match (self.state, last_state) { (UrlLocation::Url(_length, end_offset), UrlLocation::Scheme) => { - // Create empty URL + // Create empty URL. self.urls.push(Url { lines: Vec::new(), end_offset, num_cols }); - // Push schemes into URL + // Push schemes into URL. for scheme_cell in self.scheme_buffer.split_off(0) { let point = scheme_cell.into(); self.extend_url(point, point, scheme_cell.fg, end_offset); } - // Push the new cell into URL + // Push the new cell into URL. self.extend_url(point, end, cell.fg, end_offset); }, (UrlLocation::Url(_length, end_offset), UrlLocation::Url(..)) => { @@ -126,24 +126,24 @@ impl Urls { _ => (), } - // Reset at un-wrapped linebreak + // Reset at un-wrapped linebreak. if cell.column.0 + 1 == num_cols && !cell.flags.contains(Flags::WRAPLINE) { self.reset(); } } - // Extend the last URL + /// Extend the last URL. fn extend_url(&mut self, start: Point, end: Point, color: Rgb, end_offset: u16) { let url = self.urls.last_mut().unwrap(); - // If color changed, we need to insert a new line + // If color changed, we need to insert a new line. if url.lines.last().map(|last| last.color) == Some(color) { url.lines.last_mut().unwrap().end = end; } else { url.lines.push(RenderLine { color, start, end }); } - // Update excluded cells at the end of the URL + // Update excluded cells at the end of the URL. url.end_offset = end_offset; } @@ -156,13 +156,13 @@ impl Urls { mouse_mode: bool, selection: bool, ) -> Option<Url> { - // Require additional shift in mouse mode + // Require additional shift in mouse mode. let mut required_mods = config.ui_config.mouse.url.mods(); if mouse_mode { required_mods |= ModifiersState::SHIFT; } - // Make sure all prerequisites for highlighting are met + // Make sure all prerequisites for highlighting are met. if selection || !mouse.inside_grid || config.ui_config.mouse.url.launcher.is_none() diff --git a/alacritty/src/window.rs b/alacritty/src/window.rs index dfb8517d..155b2aa2 100644 --- a/alacritty/src/window.rs +++ b/alacritty/src/window.rs @@ -61,24 +61,24 @@ use wayland_client::{Attached, EventQueue, Proxy}; #[cfg(not(any(target_os = "macos", windows)))] use wayland_client::protocol::wl_surface::WlSurface; -// It's required to be in this directory due to the `windows.rc` file +// It's required to be in this directory due to the `windows.rc` file. #[cfg(not(any(target_os = "macos", windows)))] static WINDOW_ICON: &[u8] = include_bytes!("../../extra/windows/alacritty.ico"); -// This should match the definition of IDI_ICON from `windows.rc` +// This should match the definition of IDI_ICON from `windows.rc`. #[cfg(windows)] const IDI_ICON: WORD = 0x101; -/// Window errors +/// Window errors. #[derive(Debug)] pub enum Error { - /// Error creating the window + /// Error creating the window. ContextCreation(glutin::CreationError), - /// Error dealing with fonts + /// Error dealing with fonts. Font(font::Error), - /// Error manipulating the rendering context + /// Error manipulating the rendering context. Context(glutin::ContextError), } @@ -140,7 +140,7 @@ fn create_gl_window( .with_hardware_acceleration(None) .build_windowed(window, event_loop)?; - // Make the context current so OpenGL operations can run + // Make the context current so OpenGL operations can run. let windowed_context = unsafe { windowed_context.make_current().map_err(|(_, err)| err)? }; Ok(windowed_context) @@ -164,7 +164,7 @@ pub struct Window { } impl Window { - /// Create a new window + /// Create a new window. /// /// This creates a window and fully initializes a window. pub fn new( @@ -242,7 +242,7 @@ impl Window { self.window().set_visible(visibility); } - /// Set the window title + /// Set the window title. #[inline] pub fn set_title(&self, title: &str) { self.window().set_title(title); @@ -256,7 +256,7 @@ impl Window { } } - /// Set mouse cursor visible + /// Set mouse cursor visible. pub fn set_mouse_visible(&mut self, visible: bool) { if visible != self.mouse_visible { self.mouse_visible = visible; @@ -286,9 +286,9 @@ impl Window { .with_decorations(decorations) .with_maximized(window_config.startup_mode() == StartupMode::Maximized) .with_window_icon(icon.ok()) - // X11 + // X11. .with_class(class.instance.clone(), class.general.clone()) - // Wayland + // Wayland. .with_app_id(class.instance.clone()); if let Some(ref val) = window_config.gtk_theme_variant { @@ -378,7 +378,7 @@ impl Window { self.window().set_minimized(minimized); } - /// Toggle the window's fullscreen state + /// Toggle the window's fullscreen state. pub fn toggle_fullscreen(&mut self) { self.set_fullscreen(self.window().fullscreen().is_none()); } @@ -417,7 +417,7 @@ impl Window { self.window().set_wayland_theme(AlacrittyWaylandTheme::new(colors)); } - /// Adjust the IME editor position according to the new location of the cursor + /// Adjust the IME editor position according to the new location of the cursor. #[cfg(not(windows))] pub fn update_ime_position<T>(&mut self, terminal: &Term<T>, size_info: &SizeInfo) { let point = terminal.cursor().point; @@ -464,13 +464,13 @@ fn x_embed_window(window: &GlutinWindow, parent_id: c_ulong) { 2, ); - // Register new error handler + // Register new error handler. let old_handler = (xlib.XSetErrorHandler)(Some(xembed_error_handler)); - // Check for the existence of the target before attempting reparenting + // Check for the existence of the target before attempting reparenting. (xlib.XReparentWindow)(xlib_display as _, xlib_window as _, parent_id, 0, 0); - // Drain errors and restore original error handler + // Drain errors and restore original error handler. (xlib.XSync)(xlib_display as _, 0); (xlib.XSetErrorHandler)(old_handler); } |