summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoe Wilm <jwilm@users.noreply.github.com>2018-09-17 08:15:20 -0700
committerGitHub <noreply@github.com>2018-09-17 08:15:20 -0700
commitcff58e9d683c44a34f37e628c7faaea4410ada74 (patch)
treee051a942190247faeab42757dd6a5f08db5a7cca
parent865727c062810e29fa33b5c04bb05510e7da3ddf (diff)
parent054e38e98d8f150b99b50fec9f679c3d23875a0a (diff)
Merge pull request #1147 from jwilm/scrollbackv0.2.0
Scrollback
-rw-r--r--CHANGELOG.md34
-rw-r--r--Cargo.lock2
-rw-r--r--Cargo.toml2
-rw-r--r--README.md6
-rw-r--r--alacritty.man3
-rw-r--r--alacritty.yml46
-rw-r--r--alacritty_macos.yml48
-rw-r--r--assets/osx/Alacritty.app/Contents/Info.plist2
-rwxr-xr-xscripts/migrate_ref_tests.rb34
-rw-r--r--snap/snapcraft.yaml4
-rw-r--r--src/config.rs114
-rw-r--r--src/display.rs5
-rw-r--r--src/event.rs89
-rw-r--r--src/event_loop.rs15
-rw-r--r--src/grid.rs724
-rw-r--r--src/grid/mod.rs780
-rw-r--r--src/grid/row.rs202
-rw-r--r--src/grid/storage.rs651
-rw-r--r--src/grid/tests.rs141
-rw-r--r--src/index.rs8
-rw-r--r--src/input.rs172
-rw-r--r--src/main.rs2
-rw-r--r--src/renderer/mod.rs16
-rw-r--r--src/selection.rs308
-rw-r--r--src/term/mod.rs484
-rw-r--r--tests/ref.rs49
-rw-r--r--tests/ref/csi_rep/grid.json2
-rw-r--r--tests/ref/fish_cc/grid.json2
-rw-r--r--tests/ref/grid_reset/alacritty.recording102
-rw-r--r--tests/ref/grid_reset/config.json1
-rw-r--r--tests/ref/grid_reset/grid.json1
-rw-r--r--tests/ref/grid_reset/size.json1
-rw-r--r--tests/ref/history/alacritty.recording101
-rw-r--r--tests/ref/history/config.json1
-rw-r--r--tests/ref/history/grid.json1
-rw-r--r--tests/ref/history/size.json1
-rw-r--r--tests/ref/indexed_256_colors/grid.json2
-rw-r--r--tests/ref/issue_855/grid.json2
-rw-r--r--tests/ref/ll/grid.json2
-rw-r--r--tests/ref/newline_with_cursor_beyond_scroll_region/grid.json2
-rw-r--r--tests/ref/tab_rendering/grid.json2
-rw-r--r--tests/ref/tmux_git_log/grid.json2
-rw-r--r--tests/ref/tmux_htop/grid.json2
-rw-r--r--tests/ref/vim_24bitcolors_bce/grid.json2
-rw-r--r--tests/ref/vim_large_window_scroll/grid.json2
-rw-r--r--tests/ref/vim_simple_edit/grid.json2
-rw-r--r--tests/ref/vttest_cursor_movement_1/grid.json2
-rw-r--r--tests/ref/vttest_insert/grid.json2
-rw-r--r--tests/ref/vttest_origin_mode_1/grid.json2
-rw-r--r--tests/ref/vttest_origin_mode_2/grid.json2
-rw-r--r--tests/ref/vttest_scroll/grid.json2
-rw-r--r--tests/ref/vttest_tab_clear_set/grid.json2
-rw-r--r--tests/ref/zsh_tab_completion/grid.json2
53 files changed, 2875 insertions, 1313 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 00000000..031a3b90
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,34 @@
+# Changelog
+All notable changes to this project will be documented in this file.
+
+The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
+and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
+
+## [Unreleased]
+
+## Version 0.2.0
+
+### Added
+
+- Add a scrollback history buffer (10_000 lines by default)
+- CHANGELOG has been added for documenting relevant user-facing changes
+- Add `ClearHistory` key binding action and the `Erase Saved Lines` control sequence
+- When growing the window height, Alacritty will now try to load additional lines out of the
+ scrollback history
+- Support the dim foreground color (`echo -e '\033[2mDimmed Text'`)
+- Add support for the LCD-V pixel mode (vertical screens)
+- Pressing enter on the numpad should now insert a newline
+- The mouse bindings now support keyboard modifiers (shift/ctrl/alt/super)
+- Add support for the bright foreground color
+
+### Changed
+
+- Multiple key/mouse bindings for a single key will now all be executed instead of picking one and
+ ignoring the rest
+- Improve text scrolling performance (affects applications like `yes`, not scrolling the history)
+
+### Fixed
+
+- Clear the visible region when the RIS escape sequence (`echo -ne '\033c'`) is received
+- Prevent logger from crashing Alacritty when stdout/stderr is not available
+- Fix a crash when sending the IL escape sequence with a large number of lines
diff --git a/Cargo.lock b/Cargo.lock
index e6a5b7bb..e91321b2 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -8,7 +8,7 @@ dependencies = [
[[package]]
name = "alacritty"
-version = "0.1.0"
+version = "0.2.0"
dependencies = [
"arraydeque 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
"base64 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)",
diff --git a/Cargo.toml b/Cargo.toml
index df237669..bba25503 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "alacritty"
-version = "0.1.0"
+version = "0.2.0"
authors = ["Joe Wilm <joe@jwilm.com>"]
license = "Apache-2.0"
build = "build.rs"
diff --git a/README.md b/README.md
index 3afabc8f..fce41160 100644
--- a/README.md
+++ b/README.md
@@ -385,12 +385,6 @@ Just Works.
It sounds like you deleted some key bindings from your config file. Please
reference the default config file to restore them.
-- **_Why doesn't it support scrollback?_**
-
- Alacritty's original purpose was to provide a better experience when using
- [tmux] which already handled scrollback. The scope of this project has since
- expanded, and [scrollback will eventually be added](https://github.com/jwilm/alacritty/issues/124).
-
## IRC
Alacritty discussion can be found in `#alacritty` on freenode.
diff --git a/alacritty.man b/alacritty.man
index 31ea2ba9..cff766ce 100644
--- a/alacritty.man
+++ b/alacritty.man
@@ -1,5 +1,4 @@
-.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.5.
-.TH ALACRITTY "1" "March 2018" "alacritty 0.1.0" "User Commands"
+.TH ALACRITTY "1" "August 2018" "alacritty 0.2.0" "User Commands"
.SH NAME
alacritty \- a cross-platform, gpu-accelerated terminal emulator
.SH "SYNOPSIS"
diff --git a/alacritty.yml b/alacritty.yml
index be350be9..af4535d5 100644
--- a/alacritty.yml
+++ b/alacritty.yml
@@ -33,6 +33,29 @@ window:
# Setting this to false will result in window without borders and title bar.
decorations: true
+scrolling:
+ # How many lines of scrollback to keep,
+ # '0' will disable scrolling.
+ history: 10000
+
+ # Number of lines the viewport will move for every line
+ # scrolled when scrollback is enabled (history > 0).
+ multiplier: 3
+
+ # Faux Scrolling
+ #
+ # The `faux_multiplier` setting controls the number
+ # of lines the terminal should scroll when the alternate
+ # screen buffer is active. This is used to allow mouse
+ # scrolling for applications like `man`.
+ #
+ # To disable this completely, set `faux_multiplier` to 0.
+ faux_multiplier: 3
+
+ # Automatically scroll to the bottom when new text is written
+ # to the terminal.
+ auto_scroll: false
+
# Display tabs using this many cells (changes require restart)
tabspaces: 8
@@ -221,16 +244,6 @@ mouse:
double_click: { threshold: 300 }
triple_click: { threshold: 300 }
- # Faux Scrollback
- #
- # The `faux_scrollback_lines` setting controls the number
- # of lines the terminal should scroll when the alternate
- # screen buffer is active. This is used to allow mouse
- # scrolling for applications like `man`.
- #
- # To disable this completely, set `faux_scrollback_lines` to 0.
- faux_scrollback_lines: 1
-
selection:
semantic_escape_chars: ",│`|:\"' ()[]{}<>"
@@ -290,7 +303,18 @@ live_config_reload: true
# around them.
#
# Either an `action`, `chars`, or `command` field must be present.
-# `action` must be one of `Paste`, `PasteSelection`, `Copy`, or `Quit`.
+# `action` must be one of the following:
+# - `Paste`
+# - `PasteSelection`
+# - `Copy`
+# - `IncreaseFontSize`
+# - `DecreaseFontSize`
+# - `ResetFontSize`
+# - `ScrollPageUp`
+# - `ScrollPageDown`
+# - `ScrollToTop`
+# - `ScrollToBottom`
+# - `Quit`
# `chars` writes the specified string every time that binding is activated.
# These should generally be escape sequences, but they can be configured to
# send arbitrary strings of bytes.
diff --git a/alacritty_macos.yml b/alacritty_macos.yml
index e3e57b86..05173e6a 100644
--- a/alacritty_macos.yml
+++ b/alacritty_macos.yml
@@ -31,6 +31,29 @@ window:
# Setting this to false will result in window without borders and title bar.
decorations: true
+scrolling:
+ # How many lines of scrollback to keep,
+ # '0' will disable scrolling.
+ history: 10000
+
+ # Number of lines the viewport will move for every line
+ # scrolled when scrollback is enabled (history > 0).
+ multiplier: 3
+
+ # Faux Scrolling
+ #
+ # The `faux_multiplier` setting controls the number
+ # of lines the terminal should scroll when the alternate
+ # screen buffer is active. This is used to allow mouse
+ # scrolling for applications like `man`.
+ #
+ # To disable this completely, set `faux_multiplier` to 0.
+ faux_multiplier: 3
+
+ # Automatically scroll to the bottom when new text is written
+ # to the terminal.
+ auto_scroll: false
+
# Display tabs using this many cells (changes require restart)
tabspaces: 8
@@ -200,16 +223,6 @@ mouse:
double_click: { threshold: 300 }
triple_click: { threshold: 300 }
- # Faux Scrollback
- #
- # The `faux_scrollback_lines` setting controls the number
- # of lines the terminal should scroll when the alternate
- # screen buffer is active. This is used to allow mouse
- # scrolling for applications like `man`.
- #
- # To disable this completely, set `faux_scrollback_lines` to 0.
- faux_scrollback_lines: 1
-
selection:
semantic_escape_chars: ",│`|:\"' ()[]{}<>"
@@ -269,7 +282,18 @@ live_config_reload: true
# around them.
#
# Either an `action`, `chars`, or `command` field must be present.
-# `action` must be one of `Paste`, `PasteSelection`, `Copy`, or `Quit`.
+# `action` must be one of the following:
+# - `Paste`
+# - `PasteSelection`
+# - `Copy`
+# - `IncreaseFontSize`
+# - `DecreaseFontSize`
+# - `ResetFontSize`
+# - `ScrollPageUp`
+# - `ScrollPageDown`
+# - `ScrollToTop`
+# - `ScrollToBottom`
+# - `Quit`
# `chars` writes the specified string every time that binding is activated.
# These should generally be escape sequences, but they can be configured to
# send arbitrary strings of bytes.
@@ -291,6 +315,8 @@ key_bindings:
- { key: Key0, mods: Command, action: ResetFontSize }
- { key: Equals, mods: Command, action: IncreaseFontSize }
- { key: Minus, mods: Command, action: DecreaseFontSize }
+ - { key: K, mods: Command, action: ClearHistory }
+ - { key: K, mods: Command, chars: "\x0c" }
- { key: PageUp, mods: Shift, chars: "\x1b[5;2~" }
- { key: PageUp, mods: Control, chars: "\x1b[5;5~" }
- { key: PageUp, chars: "\x1b[5~" }
diff --git a/assets/osx/Alacritty.app/Contents/Info.plist b/assets/osx/Alacritty.app/Contents/Info.plist
index 3aa2f703..2792d9cd 100644
--- a/assets/osx/Alacritty.app/Contents/Info.plist
+++ b/assets/osx/Alacritty.app/Contents/Info.plist
@@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
- <string>0.1.0</string>
+ <string>0.2.0</string>
<key>CFBundleSupportedPlatforms</key>
<array>
<string>MacOSX</string>
diff --git a/scripts/migrate_ref_tests.rb b/scripts/migrate_ref_tests.rb
new file mode 100755
index 00000000..5ed02893
--- /dev/null
+++ b/scripts/migrate_ref_tests.rb
@@ -0,0 +1,34 @@
+#!/usr/bin/env ruby
+
+require 'json'
+
+Dir.glob('./tests/ref/**/grid.json').each do |path|
+ puts "Migrating #{path}"
+
+ # Read contents
+ s = File.open(path) { |f| f.read }
+
+ # Parse
+ grid = JSON.parse(s)
+
+ # Normalize Storage serialization
+ if grid['raw'].is_a? Array
+ grid['raw'] = {
+ 'inner' => grid['raw'][0],
+ 'zero' => grid['raw'][1],
+ 'visible_lines' => grid['raw'][2]
+ }
+ end
+
+ # Migrate Row serialization
+ grid['raw']['inner'].map! do |row|
+ if row.is_a? Hash
+ row
+ else
+ { inner: row, occ: row.length }
+ end
+ end
+
+ # Write updated grid
+ File.open(path, 'w') { |f| f << JSON.generate(grid) }
+end
diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml
index 42bb1035..64594a9c 100644
--- a/snap/snapcraft.yaml
+++ b/snap/snapcraft.yaml
@@ -1,5 +1,5 @@
name: alacritty # you probably want to 'snapcraft register <name>'
-version: '0.1.0' # just for humans, typically '1.2+git' or '1.3.2'
+version: '0.2.0' # just for humans, typically '1.2+git' or '1.3.2'
summary: Modern, GPU accelerated terminal emulator # 79 char long summary
description: |
Modern, GPU accelerated terminal emulator
@@ -19,4 +19,4 @@ parts:
apps:
alacritty:
command: env XDG_RUNTIME_DIR= XDG_CONFIG_HOME=$SNAP_USER_DATA XDG_DATA_DIRS=$SNAP_DATA PATH=$SNAP/bin:$PATH SNAP= alacritty
- desktop: Alacritty.desktop \ No newline at end of file
+ desktop: Alacritty.desktop
diff --git a/src/config.rs b/src/config.rs
index b50e3243..f4da671c 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -83,26 +83,9 @@ pub struct Mouse {
#[serde(default, deserialize_with = "failure_default")]
pub triple_click: ClickHandler,
- /// up/down arrows sent when scrolling in alt screen buffer
- #[serde(deserialize_with = "deserialize_faux_scrollback_lines")]
- #[serde(default="default_faux_scrollback_lines")]
- pub faux_scrollback_lines: usize,
-}
-
-fn default_faux_scrollback_lines() -> usize {
- 1
-}
-
-fn deserialize_faux_scrollback_lines<'a, D>(deserializer: D) -> ::std::result::Result<usize, D::Error>
- where D: de::Deserializer<'a>
-{
- match usize::deserialize(deserializer) {
- Ok(lines) => Ok(lines),
- Err(err) => {
- eprintln!("problem with config: {}; Using default value", err);
- Ok(default_faux_scrollback_lines())
- },
- }
+ // TODO: DEPRECATED
+ #[serde(default)]
+ pub faux_scrollback_lines: Option<usize>,
}
impl Default for Mouse {
@@ -114,7 +97,7 @@ impl Default for Mouse {
triple_click: ClickHandler {
threshold: Duration::from_millis(300),
},
- faux_scrollback_lines: 1,
+ faux_scrollback_lines: None,
}
}
}
@@ -401,6 +384,10 @@ pub struct Config {
/// Number of spaces in one tab
#[serde(default="default_tabspaces", deserialize_with = "deserialize_tabspaces")]
tabspaces: usize,
+
+ /// How much scrolling history to keep
+ #[serde(default, deserialize_with="failure_default")]
+ scrolling: Scrolling,
}
fn failure_default_vec<'a, D, T>(deserializer: D) -> ::std::result::Result<Vec<T>, D::Error>
@@ -484,6 +471,66 @@ impl Default for Config {
}
}
+/// Struct for scrolling related settings
+#[derive(Copy, Clone, Debug, Deserialize)]
+pub struct Scrolling {
+ #[serde(deserialize_with="deserialize_scrolling_history")]
+ #[serde(default="default_scrolling_history")]
+ pub history: u32,
+ #[serde(deserialize_with="deserialize_scrolling_multiplier")]
+ #[serde(default="default_scrolling_multiplier")]
+ pub multiplier: u8,
+ #[serde(deserialize_with="deserialize_scrolling_multiplier")]
+ #[serde(default="default_scrolling_multiplier")]
+ pub faux_multiplier: u8,
+ #[serde(default, deserialize_with="failure_default")]
+ pub auto_scroll: bool,
+}
+
+fn default_scrolling_history() -> u32 {
+ 10_000
+}
+
+// Default for normal and faux scrolling
+fn default_scrolling_multiplier() -> u8 {
+ 3
+}
+
+impl Default for Scrolling {
+ fn default() -> Self {
+ Self {
+ history: default_scrolling_history(),
+ multiplier: default_scrolling_multiplier(),
+ faux_multiplier: default_scrolling_multiplier(),
+ auto_scroll: false,
+ }
+ }
+}
+
+fn deserialize_scrolling_history<'a, D>(deserializer: D) -> ::std::result::Result<u32, D::Error>
+ where D: de::Deserializer<'a>
+{
+ match u32::deserialize(deserializer) {
+ Ok(lines) => Ok(lines),
+ Err(err) => {
+ eprintln!("problem with config: {}; Using default value", err);
+ Ok(default_scrolling_history())
+ },
+ }
+}
+
+fn deserialize_scrolling_multiplier<'a, D>(deserializer: D) -> ::std::result::Result<u8, D::Error>
+ where D: de::Deserializer<'a>
+{
+ match u8::deserialize(deserializer) {
+ Ok(lines) => Ok(lines),
+ Err(err) => {
+ eprintln!("problem with config: {}; Using default value", err);
+ Ok(default_scrolling_multiplier())
+ },
+ }
+}
+
/// Newtype for implementing deserialize on glutin Mods
///
/// Our deserialize impl wouldn't be covered by a derive(Deserialize); see the
@@ -549,7 +596,9 @@ impl<'a> de::Deserialize<'a> for ActionWrapper {
type Value = ActionWrapper;
fn expecting(&self, f: &mut fmt::Formatter) -> fmt::Result {
- f.write_str("Paste, Copy, PasteSelection, IncreaseFontSize, DecreaseFontSize, ResetFontSize, Hide, or Quit")
+ f.write_str("Paste, Copy, PasteSelection, IncreaseFontSize, DecreaseFontSize, \
+ ResetFontSize, ScrollPageUp, ScrollPageDown, ScrollToTop, \
+ ScrollToBottom, ClearHistory, Hide, or Quit")
}
fn visit_str<E>(self, value: &str) -> ::std::result::Result<ActionWrapper, E>
@@ -562,6 +611,11 @@ impl<'a> de::Deserialize<'a> for ActionWrapper {
"IncreaseFontSize" => Action::IncreaseFontSize,
"DecreaseFontSize" => Action::DecreaseFontSize,
"ResetFontSize" => Action::ResetFontSize,
+ "ScrollPageUp" => Action::ScrollPageUp,
+ "ScrollPageDown" => Action::ScrollPageDown,
+ "ScrollToTop" => Action::ScrollToTop,
+ "ScrollToBottom" => Action::ScrollToBottom,
+ "ClearHistory" => Action::ClearHistory,
"Hide" => Action::Hide,
"Quit" => Action::Quit,
_ => return Err(E::invalid_value(Unexpected::Str(value), &self)),
@@ -1407,6 +1461,17 @@ impl Config {
self.dynamic_title
}
+ /// Scrolling settings
+ #[inline]
+ pub fn scrolling(&self) -> Scrolling {
+ self.scrolling
+ }
+
+ // Update the history size, used in ref tests
+ pub fn set_history(&mut self, history: u32) {
+ self.scrolling.history = history;
+ }
+
pub fn load_from<P: Into<PathBuf>>(path: P) -> Result<Config> {
let path = path.into();
let raw = Config::read_file(path.as_path())?;
@@ -1447,6 +1512,11 @@ impl Config {
eprintln!("{}", fmt::Yellow("Config `padding` is deprecated. \
Please use `window.padding` instead."));
}
+
+ if self.mouse.faux_scrollback_lines.is_some() {
+ println!("{}", fmt::Yellow("Config `mouse.faux_scrollback_lines` is deprecated. \
+ Please use `mouse.faux_scrolling_lines` instead."));
+ }
}
}
diff --git a/src/display.rs b/src/display.rs
index e0453f72..4c3ffed1 100644
--- a/src/display.rs
+++ b/src/display.rs
@@ -24,7 +24,6 @@ use config::Config;
use font::{self, Rasterize};
use meter::Meter;
use renderer::{self, GlyphCache, QuadRenderer};
-use selection::Selection;
use term::{Term, SizeInfo};
use window::{self, Size, Pixels, Window, SetInnerSize};
@@ -326,7 +325,7 @@ impl Display {
/// A reference to Term whose state is being drawn must be provided.
///
/// This call may block if vsync is enabled
- pub fn draw(&mut self, mut terminal: MutexGuard<Term>, config: &Config, selection: Option<&Selection>) {
+ pub fn draw(&mut self, mut terminal: MutexGuard<Term>, config: &Config) {
// Clear dirty flag
terminal.dirty = !terminal.visual_bell.completed();
@@ -374,7 +373,7 @@ impl Display {
// Draw the grid
api.render_cells(
- terminal.renderable_cells(config, selection, window_focused),
+ terminal.renderable_cells(config, window_focused),
glyph_cache,
);
});
diff --git a/src/event.rs b/src/event.rs
index 7e8a955c..589f1a42 100644
--- a/src/event.rs
+++ b/src/event.rs
@@ -10,6 +10,8 @@ use parking_lot::MutexGuard;
use glutin::{self, ModifiersState, Event, ElementState};
use copypasta::{Clipboard, Load, Store};
+use ansi::{Handler, ClearMode};
+use grid::Scroll;
use config::{self, Config};
use cli::Options;
use display::OnResize;
@@ -33,10 +35,8 @@ pub trait Notify {
pub struct ActionContext<'a, N: 'a> {
pub notifier: &'a mut N,
pub terminal: &'a mut Term,
- pub selection: &'a mut Option<Selection>,
pub size_info: &'a SizeInfo,
pub mouse: &'a mut Mouse,
- pub selection_modified: bool,
pub received_count: &'a mut usize,
pub suppress_chars: &'a mut bool,
pub last_modifiers: &'a mut ModifiersState,
@@ -56,51 +56,61 @@ impl<'a, N: Notify + 'a> input::ActionContext for ActionContext<'a, N> {
*self.size_info
}
+ fn scroll(&mut self, scroll: Scroll) {
+ self.terminal.scroll_display(scroll);
+ }
+
+ fn clear_history(&mut self) {
+ self.terminal.clear_screen(ClearMode::Saved);
+ }
+
fn copy_selection(&self, bu