aboutsummaryrefslogtreecommitdiff
path: root/alacritty/src/display
diff options
context:
space:
mode:
Diffstat (limited to 'alacritty/src/display')
-rw-r--r--alacritty/src/display/content.rs29
-rw-r--r--alacritty/src/display/hint.rs6
-rw-r--r--alacritty/src/display/mod.rs108
-rw-r--r--alacritty/src/display/window.rs8
4 files changed, 75 insertions, 76 deletions
diff --git a/alacritty/src/display/content.rs b/alacritty/src/display/content.rs
index db73a73b..72d79f7e 100644
--- a/alacritty/src/display/content.rs
+++ b/alacritty/src/display/content.rs
@@ -4,7 +4,6 @@ use std::mem;
use std::ops::{Deref, DerefMut, RangeInclusive};
use alacritty_terminal::ansi::{Color, CursorShape, NamedColor};
-use alacritty_terminal::config::Config;
use alacritty_terminal::event::EventListener;
use alacritty_terminal::grid::{Dimensions, Indexed};
use alacritty_terminal::index::{Column, Direction, Line, Point};
@@ -13,7 +12,7 @@ use alacritty_terminal::term::color::{CellRgb, Rgb};
use alacritty_terminal::term::search::{Match, RegexIter, RegexSearch};
use alacritty_terminal::term::{RenderableContent as TerminalContent, Term, TermMode};
-use crate::config::ui_config::UiConfig;
+use crate::config::UiConfig;
use crate::display::color::{List, DIM_FACTOR};
use crate::display::hint::HintState;
use crate::display::{self, Display, MAX_SEARCH_LINES};
@@ -32,14 +31,14 @@ pub struct RenderableContent<'a> {
cursor_point: Point<usize>,
search: Option<Regex<'a>>,
hint: Option<Hint<'a>>,
- config: &'a Config<UiConfig>,
+ config: &'a UiConfig,
colors: &'a List,
focused_match: Option<&'a Match>,
}
impl<'a> RenderableContent<'a> {
pub fn new<T: EventListener>(
- config: &'a Config<UiConfig>,
+ config: &'a UiConfig,
display: &'a mut Display,
term: &'a Term<T>,
search_state: &'a SearchState,
@@ -54,7 +53,7 @@ impl<'a> RenderableContent<'a> {
|| search_state.regex().is_some()
{
CursorShape::Hidden
- } else if !term.is_focused && config.cursor.unfocused_hollow {
+ } else if !term.is_focused && config.terminal_config.cursor.unfocused_hollow {
CursorShape::HollowBlock
} else {
terminal_content.cursor.shape
@@ -113,9 +112,9 @@ impl<'a> RenderableContent<'a> {
// Cursor colors.
let color = if self.terminal_content.mode.contains(TermMode::VI) {
- self.config.ui_config.colors.vi_mode_cursor
+ self.config.colors.vi_mode_cursor
} else {
- self.config.ui_config.colors.cursor
+ self.config.colors.cursor
};
let cursor_color =
self.terminal_content.colors[NamedColor::Cursor].map_or(color.background, CellRgb::Rgb);
@@ -131,8 +130,8 @@ impl<'a> RenderableContent<'a> {
// Invert cursor color with insufficient contrast to prevent invisible cursors.
if insufficient_contrast {
- cursor_color = self.config.ui_config.colors.primary.foreground;
- text_color = self.config.ui_config.colors.primary.background;
+ cursor_color = self.config.colors.primary.foreground;
+ text_color = self.config.colors.primary.background;
}
Some(RenderableCursor {
@@ -204,7 +203,7 @@ impl RenderableCell {
mem::swap(&mut fg, &mut bg);
1.0
} else {
- Self::compute_bg_alpha(&content.config.ui_config, cell.bg)
+ Self::compute_bg_alpha(content.config, cell.bg)
};
let is_selected = content.terminal_content.selection.map_or(false, |selection| {
@@ -217,7 +216,7 @@ impl RenderableCell {
let display_offset = content.terminal_content.display_offset;
let viewport_start = Point::new(Line(-(display_offset as i32)), Column(0));
- let colors = &content.config.ui_config.colors;
+ let colors = &content.config.colors;
let mut character = cell.c;
if let Some((c, is_first)) =
@@ -293,18 +292,18 @@ impl RenderableCell {
/// Get the RGB color from a cell's foreground color.
fn compute_fg_rgb(content: &mut RenderableContent<'_>, fg: Color, flags: Flags) -> Rgb {
- let ui_config = &content.config.ui_config;
+ let config = &content.config;
match fg {
Color::Spec(rgb) => match flags & Flags::DIM {
Flags::DIM => rgb * DIM_FACTOR,
_ => rgb,
},
Color::Named(ansi) => {
- match (ui_config.draw_bold_text_with_bright_colors, flags & Flags::DIM_BOLD) {
+ match (config.draw_bold_text_with_bright_colors, flags & Flags::DIM_BOLD) {
// If no bright foreground is set, treat it like the BOLD flag doesn't exist.
(_, Flags::DIM_BOLD)
if ansi == NamedColor::Foreground
- && ui_config.colors.primary.bright_foreground.is_none() =>
+ && config.colors.primary.bright_foreground.is_none() =>
{
content.color(NamedColor::DimForeground as usize)
},
@@ -320,7 +319,7 @@ impl RenderableCell {
},
Color::Indexed(idx) => {
let idx = match (
- ui_config.draw_bold_text_with_bright_colors,
+ config.draw_bold_text_with_bright_colors,
flags & Flags::DIM_BOLD,
idx,
) {
diff --git a/alacritty/src/display/hint.rs b/alacritty/src/display/hint.rs
index 2157a058..c318fc09 100644
--- a/alacritty/src/display/hint.rs
+++ b/alacritty/src/display/hint.rs
@@ -8,7 +8,7 @@ use alacritty_terminal::term::search::{Match, RegexIter, RegexSearch};
use alacritty_terminal::term::{Term, TermMode};
use crate::config::ui_config::{Hint, HintAction};
-use crate::config::Config;
+use crate::config::UiConfig;
use crate::display::content::RegexMatches;
use crate::display::MAX_SEARCH_LINES;
@@ -242,13 +242,13 @@ impl HintLabels {
/// Check if there is a hint highlighted at the specified point.
pub fn highlighted_at<T>(
term: &Term<T>,
- config: &Config,
+ config: &UiConfig,
point: Point,
mouse_mods: ModifiersState,
) -> Option<HintMatch> {
let mouse_mode = term.mode().intersects(TermMode::MOUSE_MODE);
- config.ui_config.hints.enabled.iter().find_map(|hint| {
+ config.hints.enabled.iter().find_map(|hint| {
// Check if all required modifiers are pressed.
let highlight = hint.mouse.map_or(false, |mouse| {
mouse.enabled
diff --git a/alacritty/src/display/mod.rs b/alacritty/src/display/mod.rs
index a942a88d..5cd59711 100644
--- a/alacritty/src/display/mod.rs
+++ b/alacritty/src/display/mod.rs
@@ -35,7 +35,7 @@ use crate::config::font::Font;
use crate::config::window::Dimensions;
#[cfg(not(windows))]
use crate::config::window::StartupMode;
-use crate::config::Config;
+use crate::config::UiConfig;
use crate::display::bell::VisualBell;
use crate::display::color::List;
use crate::display::content::RenderableContent;
@@ -202,7 +202,7 @@ pub struct Display {
impl Display {
pub fn new<E>(
- config: &Config,
+ config: &UiConfig,
event_loop: &EventLoopWindowTarget<E>,
#[cfg(all(feature = "wayland", not(any(target_os = "macos", windows))))]
wayland_event_queue: Option<&EventQueue>,
@@ -221,11 +221,11 @@ impl Display {
};
// Guess the target window dimensions.
- let metrics = GlyphCache::static_metrics(config.ui_config.font.clone(), estimated_dpr)?;
+ let metrics = GlyphCache::static_metrics(config.font.clone(), estimated_dpr)?;
let (cell_width, cell_height) = compute_cell_size(config, &metrics);
// Guess the target window size if the user has specified the number of lines/columns.
- let dimensions = config.ui_config.window.dimensions();
+ let dimensions = config.window.dimensions();
let estimated_size = dimensions.map(|dimensions| {
window_size(config, dimensions, cell_width, cell_height, estimated_dpr)
});
@@ -261,7 +261,7 @@ impl Display {
}
}
- let padding = config.ui_config.window.padding(window.dpr);
+ let padding = config.window.padding(window.dpr);
let viewport_size = window.inner_size();
// Create new size with at least one column and row.
@@ -272,7 +272,7 @@ impl Display {
cell_height,
padding.0,
padding.1,
- config.ui_config.window.dynamic_padding && dimensions.is_none(),
+ config.window.dynamic_padding && dimensions.is_none(),
);
info!("Cell size: {} x {}", cell_width, cell_height);
@@ -283,25 +283,25 @@ impl Display {
renderer.resize(&size_info);
// Clear screen.
- let background_color = config.ui_config.colors.primary.background;
- renderer.with_api(&config.ui_config, &size_info, |api| {
+ let background_color = config.colors.primary.background;
+ renderer.with_api(config, &size_info, |api| {
api.clear(background_color);
});
// Set subpixel anti-aliasing.
#[cfg(target_os = "macos")]
- crossfont::set_font_smoothing(config.ui_config.font.use_thin_strokes);
+ crossfont::set_font_smoothing(config.font.use_thin_strokes);
// Disable shadows for transparent windows on macOS.
#[cfg(target_os = "macos")]
- window.set_has_shadow(config.ui_config.window_opacity() >= 1.0);
+ window.set_has_shadow(config.window_opacity() >= 1.0);
// On Wayland we can safely ignore this call, since the window isn't visible until you
// actually draw something into it and commit those changes.
#[cfg(not(any(target_os = "macos", windows)))]
if is_x11 {
window.swap_buffers();
- renderer.with_api(&config.ui_config, &size_info, |api| {
+ renderer.with_api(config, &size_info, |api| {
api.finish();
});
}
@@ -312,13 +312,13 @@ impl Display {
//
// TODO: replace `set_position` with `with_position` once available.
// Upstream issue: https://github.com/rust-windowing/winit/issues/806.
- if let Some(position) = config.ui_config.window.position {
+ if let Some(position) = config.window.position {
window.set_outer_position(PhysicalPosition::from((position.x, position.y)));
}
#[allow(clippy::single_match)]
#[cfg(not(windows))]
- match config.ui_config.window.startup_mode {
+ match config.window.startup_mode {
#[cfg(target_os = "macos")]
StartupMode::SimpleFullscreen => window.set_simple_fullscreen(true),
#[cfg(not(target_os = "macos"))]
@@ -326,7 +326,7 @@ impl Display {
_ => (),
}
- let hint_state = HintState::new(config.ui_config.hints.alphabet());
+ let hint_state = HintState::new(config.hints.alphabet());
Ok(Self {
window,
@@ -340,8 +340,8 @@ impl Display {
#[cfg(not(any(target_os = "macos", windows)))]
is_x11,
cursor_hidden: false,
- visual_bell: VisualBell::from(&config.ui_config.bell),
- colors: List::from(&config.ui_config.colors),
+ visual_bell: VisualBell::from(&config.bell),
+ colors: List::from(&config.colors),
pending_update: Default::default(),
})
}
@@ -349,10 +349,10 @@ impl Display {
fn new_glyph_cache(
dpr: f64,
renderer: &mut QuadRenderer,
- config: &Config,
+ config: &UiConfig,
) -> Result<(GlyphCache, f32, f32), Error> {
- let font = config.ui_config.font.clone();
- let rasterizer = Rasterizer::new(dpr as f32, config.ui_config.font.use_thin_strokes)?;
+ let font = config.font.clone();
+ let rasterizer = Rasterizer::new(dpr as f32, config.font.use_thin_strokes)?;
// Initialize glyph cache.
let glyph_cache = {
@@ -380,7 +380,7 @@ impl Display {
/// Update font size and cell dimensions.
///
/// This will return a tuple of the cell width and height.
- fn update_glyph_cache(&mut self, config: &Config, font: &Font) -> (f32, f32) {
+ fn update_glyph_cache(&mut self, config: &UiConfig, font: &Font) -> (f32, f32) {
let cache = &mut self.glyph_cache;
let dpr = self.window.dpr;
@@ -407,7 +407,7 @@ impl Display {
pty_resize_handle: &mut dyn OnResize,
message_buffer: &MessageBuffer,
search_active: bool,
- config: &Config,
+ config: &UiConfig,
) where
T: EventListener,
{
@@ -436,7 +436,7 @@ impl Display {
height = dimensions.height as f32;
}
- let padding = config.ui_config.window.padding(self.window.dpr);
+ let padding = config.window.padding(self.window.dpr);
self.size_info = SizeInfo::new(
width,
@@ -445,7 +445,7 @@ impl Display {
cell_height,
padding.0,
padding.1,
- config.ui_config.window.dynamic_padding,
+ config.window.dynamic_padding,
);
// Update number of column/lines in the viewport.
@@ -478,7 +478,7 @@ impl Display {
&mut self,
terminal: MutexGuard<'_, Term<T>>,
message_buffer: &MessageBuffer,
- config: &Config,
+ config: &UiConfig,
search_state: &SearchState,
) {
// Collect renderable content before the terminal is dropped.
@@ -505,7 +505,7 @@ impl Display {
// Make sure this window's OpenGL context is active.
self.window.make_current();
- self.renderer.with_api(&config.ui_config, &size_info, |api| {
+ self.renderer.with_api(config, &size_info, |api| {
api.clear(background_color);
});
@@ -522,7 +522,7 @@ impl Display {
let glyph_cache = &mut self.glyph_cache;
let highlighted_hint = &self.highlighted_hint;
let vi_highlighted_hint = &self.vi_highlighted_hint;
- self.renderer.with_api(&config.ui_config, &size_info, |mut api| {
+ self.renderer.with_api(config, &size_info, |mut api| {
// Iterate over all non-empty cells in the grid.
for mut cell in grid_cells {
// Underline hints hovered by mouse or vi mode cursor.
@@ -559,7 +559,7 @@ impl Display {
// Push the cursor rects for rendering.
if let Some(cursor) = cursor {
- for rect in cursor.rects(&size_info, config.cursor.thickness()) {
+ for rect in cursor.rects(&size_info, config.terminal_config.cursor.thickness()) {
rects.push(rect);
}
}
@@ -572,7 +572,7 @@ impl Display {
0.,
size_info.width(),
size_info.height(),
- config.ui_config.bell.color,
+ config.bell.color,
visual_bell_intensity as f32,
);
rects.push(visual_bell_rect);
@@ -587,8 +587,8 @@ impl Display {
let y = size_info.cell_height().mul_add(start_line as f32, size_info.padding_y());
let bg = match message.ty() {
- MessageType::Error => config.ui_config.colors.normal.red,
- MessageType::Warning => config.ui_config.colors.normal.yellow,
+ MessageType::Error => config.colors.normal.red,
+ MessageType::Warning => config.colors.normal.yellow,
};
let message_bar_rect =
@@ -602,10 +602,10 @@ impl Display {
// Relay messages to the user.
let glyph_cache = &mut self.glyph_cache;
- let fg = config.ui_config.colors.primary.background;
+ let fg = config.colors.primary.background;
for (i, message_text) in text.iter().enumerate() {
let point = Point::new(start_line + i, Column(0));
- self.renderer.with_api(&config.ui_config, &size_info, |mut api| {
+ self.renderer.with_api(config, &size_info, |mut api| {
api.render_string(glyph_cache, point, fg, bg, message_text);
});
}
@@ -651,16 +651,16 @@ impl Display {
// On X11 `swap_buffers` does not block for vsync. However the next OpenGl command
// will block to synchronize (this is `glClear` in Alacritty), which causes a
// permanent one frame delay.
- self.renderer.with_api(&config.ui_config, &size_info, |api| {
+ self.renderer.with_api(config, &size_info, |api| {
api.finish();
});
}
}
/// Update to a new configuration.
- pub fn update_config(&mut self, config: &Config) {
- self.visual_bell.update_config(&config.ui_config.bell);
- self.colors = List::from(&config.ui_config.colors);
+ pub fn update_config(&mut self, config: &UiConfig) {
+ self.visual_bell.update_config(&config.bell);
+ self.colors = List::from(&config.colors);
}
/// Update the mouse/vi mode cursor hint highlighting.
@@ -669,7 +669,7 @@ impl Display {
pub fn update_highlighted_hints<T>(
&mut self,
term: &Term<T>,
- config: &Config,
+ config: &UiConfig,
mouse: &Mouse,
modifiers: ModifiersState,
) -> bool {
@@ -744,7 +744,7 @@ impl Display {
}
/// Draw current search regex.
- fn draw_search(&mut self, config: &Config, size_info: &SizeInfo, text: &str) {
+ fn draw_search(&mut self, config: &UiConfig, size_info: &SizeInfo, text: &str) {
let glyph_cache = &mut self.glyph_cache;
let num_cols = size_info.columns();
@@ -752,17 +752,17 @@ impl Display {
let text = format!("{:<1$}", text, num_cols);
let point = Point::new(size_info.screen_lines(), Column(0));
- let fg = config.ui_config.colors.search_bar_foreground();
- let bg = config.ui_config.colors.search_bar_background();
+ let fg = config.colors.search_bar_foreground();
+ let bg = config.colors.search_bar_background();
- self.renderer.with_api(&config.ui_config, size_info, |mut api| {
+ self.renderer.with_api(config, size_info, |mut api| {
api.render_string(glyph_cache, point, fg, bg, &text);
});
}
/// Draw render timer.
- fn draw_render_timer(&mut self, config: &Config, size_info: &SizeInfo) {
- if !config.ui_config.debug.render_timer {
+ fn draw_render_timer(&mut self, config: &UiConfig, size_info: &SizeInfo) {
+ if !config.debug.render_timer {
return;
}
@@ -770,10 +770,10 @@ impl Display {
let timing = format!("{:.3} usec", self.meter.average());
let point = Point::new(size_info.screen_lines().saturating_sub(2), Column(0));
- let fg = config.ui_config.colors.primary.background;
- let bg = config.ui_config.colors.normal.red;
+ let fg = config.colors.primary.background;
+ let bg = config.colors.normal.red;
- self.renderer.with_api(&config.ui_config, size_info, |mut api| {
+ self.renderer.with_api(config, size_info, |mut api| {
api.render_string(glyph_cache, point, fg, bg, &timing);
});
}
@@ -781,7 +781,7 @@ impl Display {
/// Draw an indicator for the position of a line in history.
fn draw_line_indicator(
&mut self,
- config: &Config,
+ config: &UiConfig,
size_info: &SizeInfo,
total_lines: usize,
obstructed_column: Option<Column>,
@@ -789,14 +789,14 @@ impl Display {
) {
let text = format!("[{}/{}]", line, total_lines - 1);
let column = Column(size_info.columns().saturating_sub(text.len()));
- let colors = &config.ui_config.colors;
+ let colors = &config.colors;
let fg = colors.line_indicator.foreground.unwrap_or(colors.primary.background);
let bg = colors.line_indicator.background.unwrap_or(colors.primary.foreground);
// Do not render anything if it would obscure the vi mode cursor.
if obstructed_column.map_or(true, |obstructed_column| obstructed_column < column) {
let glyph_cache = &mut self.glyph_cache;
- self.renderer.with_api(&config.ui_config, size_info, |mut api| {
+ self.renderer.with_api(config, size_info, |mut api| {
api.render_string(glyph_cache, Point::new(0, column), fg, bg, &text);
});
}
@@ -847,9 +847,9 @@ pub fn viewport_to_point(display_offset: usize, point: Point<usize>) -> Point {
///
/// This will return a tuple of the cell width and height.
#[inline]
-fn compute_cell_size(config: &Config, metrics: &crossfont::Metrics) -> (f32, f32) {
- let offset_x = f64::from(config.ui_config.font.offset.x);
- let offset_y = f64::from(config.ui_config.font.offset.y);
+fn compute_cell_size(config: &UiConfig, metrics: &crossfont::Metrics) -> (f32, f32) {
+ let offset_x = f64::from(config.font.offset.x);
+ let offset_y = f64::from(config.font.offset.y);
(
(metrics.average_advance + offset_x).floor().max(1.) as f32,
(metrics.line_height + offset_y).floor().max(1.) as f32,
@@ -858,13 +858,13 @@ fn compute_cell_size(config: &Config, metrics: &crossfont::Metrics) -> (f32, f32
/// Calculate the size of the window given padding, terminal dimensions and cell size.
fn window_size(
- config: &Config,
+ config: &UiConfig,
dimensions: Dimensions,
cell_width: f32,
cell_height: f32,
dpr: f64,
) -> PhysicalSize<u32> {
- let padding = config.ui_config.window.padding(dpr);
+ let padding = config.window.padding(dpr);
let grid_width = cell_width * dimensions.columns.0.max(MIN_COLUMNS) as f32;
let grid_height = cell_height * dimensions.lines.max(MIN_SCREEN_LINES) as f32;
diff --git a/alacritty/src/display/window.rs b/alacritty/src/display/window.rs
index 16932dc4..feeb6fb2 100644
--- a/alacritty/src/display/window.rs
+++ b/alacritty/src/display/window.rs
@@ -54,7 +54,7 @@ use alacritty_terminal::index::Point;
use alacritty_terminal::term::SizeInfo;
use crate::config::window::{Decorations, WindowConfig};
-use crate::config::Config;
+use crate::config::UiConfig;
use crate::gl;
/// Window icon for `_NET_WM_ICON` property.
@@ -172,12 +172,12 @@ impl Window {
/// This creates a window and fully initializes a window.
pub fn new<E>(
event_loop: &EventLoopWindowTarget<E>,
- config: &Config,
+ config: &UiConfig,
size: Option<PhysicalSize<u32>>,
#[cfg(all(feature = "wayland", not(any(target_os = "macos", windows))))]
wayland_event_queue: Option<&EventQueue>,
) -> Result<Window> {
- let window_config = &config.ui_config.window;
+ let window_config = &config.window;
let window_builder = Window::get_platform_window(&window_config.title, window_config);
// Check if we're running Wayland to disable vsync.
@@ -210,7 +210,7 @@ impl Window {
#[cfg(all(feature = "wayland", not(any(target_os = "macos", windows))))]
let wayland_surface = if is_wayland {
// Apply client side decorations theme.
- let theme = AlacrittyWaylandTheme::new(&config.ui_config.colors);
+ let theme = AlacrittyWaylandTheme::new(&config.colors);
windowed_context.window().set_wayland_theme(theme);
// Attach surface to Alacritty's internal wayland queue to handle frame callbacks.