aboutsummaryrefslogtreecommitdiff
path: root/src/renderer
diff options
context:
space:
mode:
authorChristian Duerr <chrisduerr@users.noreply.github.com>2019-02-07 22:36:45 +0000
committerGitHub <noreply@github.com>2019-02-07 22:36:45 +0000
commit35efb4619c4b7a77b3c30de763856bc4441e236e (patch)
tree99aa70b58f97bd57c2a654e3177eae0ea0b572fa /src/renderer
parente561ae373393e919cf3dbbf123a98e0aad215dbc (diff)
downloadr-alacritty-35efb4619c4b7a77b3c30de763856bc4441e236e.tar.gz
r-alacritty-35efb4619c4b7a77b3c30de763856bc4441e236e.tar.bz2
r-alacritty-35efb4619c4b7a77b3c30de763856bc4441e236e.zip
Dynamically resize terminal for errors/warnings
The warning and error messages now don't overwrite other terminal content anymore but instead resize the terminal to make sure that text can always be read. Instead of just showing that there is a new error and pointing to the log, errors will now be displayed fully in multiple lines of text, assuming that there is enough space left in the terminal. Explicit mouse click handling has also been added to the message bar, which made it possible to add a simple `close` button in the form of `[X]`. Alacritty's log file location is now stored in the `$ALACRITTY_LOG` environment variable which the shell inherits automatically. Previously there were some issues with the log file only being deleted when certain methods for closing Alacritty were used (like typing `exit`). This has been reworked and now Ctrl+D, exit and signals should all work properly. Before the config is reloaded, all current messages are now dropped. This should help with multiple terminals all getting clogged up at the same time when the config is broken. When one message is removed, all other duplicate messages are automatically removed too.
Diffstat (limited to 'src/renderer')
-rw-r--r--src/renderer/mod.rs29
-rw-r--r--src/renderer/rects.rs (renamed from src/renderer/lines.rs)30
2 files changed, 32 insertions, 27 deletions
diff --git a/src/renderer/mod.rs b/src/renderer/mod.rs
index e96d35a5..9a33410f 100644
--- a/src/renderer/mod.rs
+++ b/src/renderer/mod.rs
@@ -29,12 +29,12 @@ use notify::{watcher, DebouncedEvent, RecursiveMode, Watcher};
use crate::gl::types::*;
use crate::gl;
use crate::index::{Column, Line, RangeInclusive};
-use crate::Rgb;
+use crate::term::color::Rgb;
use crate::config::{self, Config, Delta};
use crate::term::{self, cell, RenderableCell};
-use crate::renderer::lines::Lines;
+use crate::renderer::rects::{Rect, Rects};
-pub mod lines;
+pub mod rects;
// Shader paths for live reload
static TEXT_SHADER_F_PATH: &'static str = concat!(env!("CARGO_MANIFEST_DIR"), "/res/text.f.glsl");
@@ -668,7 +668,7 @@ impl QuadRenderer {
config: &Config,
props: &term::SizeInfo,
visual_bell_intensity: f64,
- cell_line_rects: Lines,
+ cell_line_rects: Rects,
) {
// Swap to rectangle rendering program
unsafe {
@@ -866,20 +866,6 @@ impl QuadRenderer {
}
}
-#[derive(Debug, Copy, Clone)]
-pub struct Rect<T> {
- x: T,
- y: T,
- width: T,
- height: T,
-}
-
-impl<T> Rect<T> {
- pub fn new(x: T, y: T, width: T, height: T) -> Self {
- Rect { x, y, width, height }
- }
-}
-
impl<'a> RenderApi<'a> {
pub fn clear(&self, color: Rgb) {
let alpha = self.config.background_opacity().get();
@@ -941,8 +927,9 @@ impl<'a> RenderApi<'a> {
string: &str,
line: Line,
glyph_cache: &mut GlyphCache,
- color: Rgb
+ color: Option<Rgb>
) {
+ let bg_alpha = color.map(|_| 1.0).unwrap_or(0.0);
let col = Column(0);
let cells = string
@@ -956,10 +943,10 @@ impl<'a> RenderApi<'a> {
chars[0] = c;
chars
},
- bg: color,
+ bg: color.unwrap_or(Rgb { r: 0, g: 0, b: 0}),
fg: Rgb { r: 0, g: 0, b: 0 },
flags: cell::Flags::empty(),
- bg_alpha: 1.0,
+ bg_alpha,
})
.collect::<Vec<_>>();
diff --git a/src/renderer/lines.rs b/src/renderer/rects.rs
index 3c250caf..e066c365 100644
--- a/src/renderer/lines.rs
+++ b/src/renderer/rects.rs
@@ -13,14 +13,27 @@
// limitations under the License.
use std::collections::HashMap;
-use crate::renderer::Rect;
use crate::term::cell::Flags;
use crate::term::{RenderableCell, SizeInfo};
-use crate::Rgb;
+use crate::term::color::Rgb;
use font::Metrics;
-/// Lines for underline and strikeout.
-pub struct Lines<'a> {
+#[derive(Debug, Copy, Clone)]
+pub struct Rect<T> {
+ pub x: T,
+ pub y: T,
+ pub width: T,
+ pub height: T,
+}
+
+impl<T> Rect<T> {
+ pub fn new(x: T, y: T, width: T, height: T) -> Self {
+ Rect { x, y, width, height }
+ }
+}
+
+/// Rects for underline, strikeout and more.
+pub struct Rects<'a> {
inner: Vec<(Rect<f32>, Rgb)>,
last_starts: HashMap<Flags, Option<RenderableCell>>,
last_cell: Option<RenderableCell>,
@@ -28,7 +41,7 @@ pub struct Lines<'a> {
size: &'a SizeInfo,
}
-impl<'a> Lines<'a> {
+impl<'a> Rects<'a> {
pub fn new(metrics: &'a Metrics, size: &'a SizeInfo) -> Self {
let mut last_starts = HashMap::new();
last_starts.insert(Flags::UNDERLINE, None);
@@ -43,7 +56,7 @@ impl<'a> Lines<'a> {
}
}
- /// Convert the stored lines to rectangles for the renderer.
+ /// Convert the stored rects to rectangles for the renderer.
pub fn rects(mut self) -> Vec<(Rect<f32>, Rgb)> {
// If there's still a line pending, draw it until the last cell
for (flag, start_cell) in self.last_starts.iter_mut() {
@@ -107,6 +120,11 @@ impl<'a> Lines<'a> {
self.last_cell = Some(*cell);
}
+
+ // Add a rectangle
+ pub fn push(&mut self, rect: Rect<f32>, color: Rgb) {
+ self.inner.push((rect, color));
+ }
}
/// Create a rectangle that starts on the left of `start` and ends on the right