Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementation of scrollback #657

Closed
wants to merge 99 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
99 commits
Select commit Hold shift + click to select a range
4461cd5
Added `num` and `owned_slice`, updated `index::Line` and added `index…
top-webmaster Jul 10, 2017
02269f7
Wrapped the `unlikely` intrinsic with a safe function
top-webmaster Jul 10, 2017
43a1414
Switched to git repository for the `owned_slice` crate.
top-webmaster Jul 10, 2017
9afa6c6
Implement core scrollback functions
top-webmaster Jul 10, 2017
aa4666d
Fix cursor rendering
top-webmaster Jul 11, 2017
0140e7b
Improved `move_visible_region_` functions
top-webmaster Jul 11, 2017
d0be4bf
Implement a really naive version of mouse scrolling
top-webmaster Jul 11, 2017
fdc2705
Removed some debugging `println!` statements
top-webmaster Jul 11, 2017
f74f55a
Beginning to fix tests
top-webmaster Jul 11, 2017
fb64bab
Fixed bug when scrolling by more than 1 line at a time.
top-webmaster Jul 12, 2017
7c028d1
Added support for PixelDelta scrolling
top-webmaster Jul 12, 2017
a3dfe5d
Changed `scroll_back_amount` to `visible_region_start`.
top-webmaster Jul 14, 2017
1fe01ce
Improved escape sequence handling etc..
top-webmaster Jul 15, 2017
e1e8943
Fixed crashes on resizing, nicer resizing behaviour.
top-webmaster Jul 28, 2017
24ca618
Removed superfluous print statements
top-webmaster Jul 29, 2017
4da641e
Added `PageUp` and `PageDown` commands
top-webmaster Aug 29, 2017
e62eaed
Fixed a forgotten conflict from the rebase
top-webmaster Aug 29, 2017
d636b4d
Fix most of the failing test
tbodt Aug 29, 2017
27d7245
Added config for scrollback (enabled and max_lines)
top-webmaster Sep 2, 2017
feda7b8
Added config defaults to 'alacritty_macos.yml' too
top-webmaster Sep 2, 2017
9977f00
Made `AbsoluteLine` references stay constant even when lines are popp…
top-webmaster Sep 23, 2017
bb54364
Fixed selections
top-webmaster Sep 23, 2017
6c5039e
Fixed compilation of unit tests
top-webmaster Sep 24, 2017
aafe8c2
Clipped selections when they move off the end of the buffer
top-webmaster Sep 29, 2017
9a24729
Added `num` and `owned_slice`, updated `index::Line` and added `index…
top-webmaster Jul 10, 2017
a81a7f2
Wrapped the `unlikely` intrinsic with a safe function
top-webmaster Jul 10, 2017
2fe8764
Switched to git repository for the `owned_slice` crate.
top-webmaster Jul 10, 2017
0321592
Implement core scrollback functions
top-webmaster Jul 10, 2017
4b22494
Fix cursor rendering
top-webmaster Jul 11, 2017
8ae8812
Improved `move_visible_region_` functions
top-webmaster Jul 11, 2017
0899f03
Implement a really naive version of mouse scrolling
top-webmaster Jul 11, 2017
641e808
Removed some debugging `println!` statements
top-webmaster Jul 11, 2017
86db980
Beginning to fix tests
top-webmaster Jul 11, 2017
0394c70
Fixed bug when scrolling by more than 1 line at a time.
top-webmaster Jul 12, 2017
2f198cb
Added support for PixelDelta scrolling
top-webmaster Jul 12, 2017
0147e44
Changed `scroll_back_amount` to `visible_region_start`.
top-webmaster Jul 14, 2017
3720b90
Improved escape sequence handling etc..
top-webmaster Jul 15, 2017
a3516fc
Fixed crashes on resizing, nicer resizing behaviour.
top-webmaster Jul 28, 2017
b48a38c
Removed superfluous print statements
top-webmaster Jul 29, 2017
3f0196e
Added `PageUp` and `PageDown` commands
top-webmaster Aug 29, 2017
de925d9
Fix most of the failing test
tbodt Aug 29, 2017
9c0de27
Added config for scrollback (enabled and max_lines)
top-webmaster Sep 2, 2017
b8a9f8b
Added config defaults to 'alacritty_macos.yml' too
top-webmaster Sep 2, 2017
2797a3f
Made `AbsoluteLine` references stay constant even when lines are popp…
top-webmaster Sep 23, 2017
0198dc4
Fixed selections
top-webmaster Sep 23, 2017
e206ddb
Fixed compilation of unit tests
top-webmaster Sep 24, 2017
04a3bf2
Clipped selections when they move off the end of the buffer
top-webmaster Sep 29, 2017
7820a36
Fix merge conflicts
chrisduerr Dec 11, 2017
f1a514b
Fix existing ref tests
chrisduerr Dec 12, 2017
bad5a5d
Merge branch 'master' into scrollback
chrisduerr Dec 12, 2017
7a15800
Added `num` and `owned_slice`, updated `index::Line` and added `index…
top-webmaster Jul 10, 2017
a1b59f6
Wrapped the `unlikely` intrinsic with a safe function
top-webmaster Jul 10, 2017
7628cfd
Switched to git repository for the `owned_slice` crate.
top-webmaster Jul 10, 2017
fc3a220
Implement core scrollback functions
top-webmaster Jul 10, 2017
2a57b38
Fix cursor rendering
top-webmaster Jul 11, 2017
2c1807e
Improved `move_visible_region_` functions
top-webmaster Jul 11, 2017
f030716
Implement a really naive version of mouse scrolling
top-webmaster Jul 11, 2017
fe55038
Removed some debugging `println!` statements
top-webmaster Jul 11, 2017
1878304
Beginning to fix tests
top-webmaster Jul 11, 2017
87c3b12
Fixed bug when scrolling by more than 1 line at a time.
top-webmaster Jul 12, 2017
606f5fc
Added support for PixelDelta scrolling
top-webmaster Jul 12, 2017
2dbc8cb
Changed `scroll_back_amount` to `visible_region_start`.
top-webmaster Jul 14, 2017
c53535e
Improved escape sequence handling etc..
top-webmaster Jul 15, 2017
69a4341
Fixed crashes on resizing, nicer resizing behaviour.
top-webmaster Jul 28, 2017
a91eb2d
Removed superfluous print statements
top-webmaster Jul 29, 2017
b047c78
Added `PageUp` and `PageDown` commands
top-webmaster Aug 29, 2017
266250c
Fix most of the failing test
tbodt Aug 29, 2017
6292ee4
Added config for scrollback (enabled and max_lines)
top-webmaster Sep 2, 2017
b174196
Added config defaults to 'alacritty_macos.yml' too
top-webmaster Sep 2, 2017
2bcc5c0
Made `AbsoluteLine` references stay constant even when lines are popp…
top-webmaster Sep 23, 2017
9358d29
Fixed selections
top-webmaster Sep 23, 2017
8949b41
Fixed compilation of unit tests
top-webmaster Sep 24, 2017
c9ae0b4
Clipped selections when they move off the end of the buffer
top-webmaster Sep 29, 2017
3302dc5
Updated Cargo.lock to match chrisdeurr's fork
top-webmaster Dec 13, 2017
af853b4
Merge branch 'master' into scrollback
chrisduerr Dec 13, 2017
8562562
Merge branch 'master' into scrollback
chrisduerr Dec 13, 2017
7fa91b7
Remove DPI and duplicate methods
chrisduerr Dec 13, 2017
f5f9dff
Merge branch 'master' into master
top-webmaster Dec 14, 2017
578038b
Disable scrollback in the alternate buffer
chrisduerr Dec 14, 2017
cb1ef5a
Update Cargo.lock file
chrisduerr Dec 14, 2017
22e1937
Reset `current_scrollback` to true after unfullscreening
top-webmaster Dec 15, 2017
c4d55b2
Merge branch 'chrisduerr-scrollback' + reset fix
top-webmaster Dec 15, 2017
45bdf24
Add additional scrollback tests
chrisduerr Dec 15, 2017
9946706
Merge pull request #6 from chrisduerr/scrollback
top-webmaster Dec 16, 2017
c2f720d
Fix ref tests
chrisduerr Dec 16, 2017
c9c11b2
Improve old test detection
chrisduerr Dec 16, 2017
547cc5f
Redo alternate_screen_buffer_exit test
chrisduerr Dec 16, 2017
991d906
Removed extraneous `trace!` call
top-webmaster Dec 17, 2017
abc38a0
Start editing tests manually
chrisduerr Dec 17, 2017
89d9097
Add scrollback to existing ref-tests
chrisduerr Dec 17, 2017
a46cbf0
Merge pull request #7 from chrisduerr/scrollback
top-webmaster Dec 18, 2017
0ae3f55
Remove unnecessary public statement
chrisduerr Dec 18, 2017
5d0f994
Fixed resizing when scrollback is disabled, renamed some functions
top-webmaster Dec 20, 2017
56deb00
Added import
top-webmaster Dec 20, 2017
6836308
Fixed infinite loop inside `grow_lines`, removed extraneous scrollbac…
top-webmaster Dec 20, 2017
f14a8d8
Remove unnecessary public statement
chrisduerr Dec 18, 2017
5b531b8
Fix failing ref tests
chrisduerr Dec 20, 2017
e27ee58
Merge branch 'scrollback' of github.com:chrisduerr/alacritty into scr…
chrisduerr Dec 20, 2017
a0b55ca
Merge pull request #9 from chrisduerr/scrollback
top-webmaster Dec 21, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
756 changes: 437 additions & 319 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@ log = "0.3.8"
clap = "2"
fnv = "1"
unicode-width = "0.1.4"
arraydeque = "0.2.3"
arraydeque = "0.2"
glutin = "0.9.2"
clippy = { version = "*", optional = true }
env_logger = "0.4"
owned_slice = { git = "https://github.com/neon64/owned-slice" }
num = "0.1.37"

[target.'cfg(any(target_os = "linux", target_os = "freebsd", target_os="dragonfly", target_os="openbsd"))'.dependencies]
x11-dl = "2"
Expand Down
25 changes: 17 additions & 8 deletions alacritty.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ dimensions:
columns: 80
lines: 24

# Scrollback buffer
scrollback:
enabled: true
max_lines: 10000

# Adds this many blank pixels of padding around the window
# Units are physical pixels; this is not DPI aware.
# (change requires restart)
Expand Down Expand Up @@ -261,20 +266,24 @@ live_config_reload: true
key_bindings:
- { key: V, mods: Control|Shift, action: Paste }
- { key: C, mods: Control|Shift, action: Copy }
- { key: Q, mods: Command, action: Quit }
- { key: W, mods: Command, action: Quit }
- { key: Insert, mods: Shift, action: PasteSelection }
- { key: Key0, mods: Control, action: ResetFontSize }
- { key: Equals, mods: Control, action: IncreaseFontSize }
- { key: Subtract, mods: Control, action: DecreaseFontSize }
- { key: Q, mods: Command, action: Quit }
- { key: W, mods: Command, action: Quit }
- { key: Insert, mods: Shift, action: PasteSelection }
- { key: Key0, mods: Control, action: ResetFontSize }
- { key: Equals, mods: Control, action: IncreaseFontSize }
- { key: Subtract, mods: Control, action: DecreaseFontSize }
- { key: Up, mods: Control|Shift, action: ScrollUp }
- { key: Down, mods: Control|Shift, action: ScrollDown }
- { key: PageUp, mods: Shift, action: PageUp }
- { key: PageDown, mods: Shift, action: PageDown }
- { key: Home, chars: "\x1bOH", mode: AppCursor }
- { key: Home, chars: "\x1b[H", mode: ~AppCursor }
- { key: End, chars: "\x1bOF", mode: AppCursor }
- { key: End, chars: "\x1b[F", mode: ~AppCursor }
- { key: PageUp, mods: Shift, chars: "\x1b[5;2~" }
- { key: PageUp, mods: Control, chars: "\x1b[5;5~" }
#- { key: PageUp, mods: Control, chars: "\x1b[5;5~" }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you mean to comment out the Shift line, not the Control one.

- { key: PageUp, chars: "\x1b[5~" }
- { key: PageDown, mods: Shift, chars: "\x1b[6;2~" }
#- { key: PageDown, mods: Shift, chars: "\x1b[6;2~" }
- { key: PageDown, mods: Control, chars: "\x1b[6;5~" }
- { key: PageDown, chars: "\x1b[6~" }
- { key: Tab, mods: Shift, chars: "\x1b[Z" }
Expand Down
5 changes: 5 additions & 0 deletions alacritty_macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ dimensions:
columns: 80
lines: 24

# Scrollback buffer
scrollback:
enabled: true
max_lines: 10000

# Adds this many blank pixels of padding around the window
# Units are physical pixels; this is not DPI aware.
# (change requires restart)
Expand Down
40 changes: 38 additions & 2 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use notify::{Watcher, watcher, DebouncedEvent, RecursiveMode};
use glutin::ModifiersState;

use input::{Action, Binding, MouseBinding, KeyBinding};
use index::{Line, Column};
use index::{AbsoluteLine, Line, Column};
use ansi::CursorStyle;

use util::fmt::Yellow;
Expand Down Expand Up @@ -220,6 +220,10 @@ pub struct Config {
#[serde(default)]
dimensions: Dimensions,

/// Maximum size of the scrollback buffer
#[serde(default)]
scrollback: Scrollback,

/// Pixel padding
#[serde(default="default_padding")]
padding: Delta,
Expand Down Expand Up @@ -320,6 +324,7 @@ impl Default for Config {
Config {
draw_bold_text_with_bright_colors: true,
dimensions: Default::default(),
scrollback: Default::default(),
font: Default::default(),
render_timer: Default::default(),
custom_cursor_colors: false,
Expand All @@ -341,6 +346,25 @@ impl Default for Config {
}
}

#[derive(Copy, Clone, Debug, Deserialize)]
pub struct Scrollback {
pub enabled: bool,
#[serde(default="default_max_scrollback_lines")]
pub max_lines: AbsoluteLine
}

impl Default for Scrollback {
fn default() -> Scrollback {
Scrollback {
enabled: true,
max_lines: default_max_scrollback_lines()
}
}
}
fn default_max_scrollback_lines() -> AbsoluteLine {
AbsoluteLine(10000)
}

/// Newtype for implementing deserialize on glutin Mods
///
/// Our deserialize impl wouldn't be covered by a derive(Deserialize); see the
Expand Down Expand Up @@ -406,7 +430,7 @@ 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, or Quit")
f.write_str("Paste, Copy, PasteSelection, IncreaseFontSize, DecreaseFontSize, ResetFontSize, Quit, ScrollUp, ScrollDown, PageUp or PageDown")
}

fn visit_str<E>(self, value: &str) -> ::std::result::Result<ActionWrapper, E>
Expand All @@ -420,6 +444,10 @@ impl<'a> de::Deserialize<'a> for ActionWrapper {
"DecreaseFontSize" => Action::DecreaseFontSize,
"ResetFontSize" => Action::ResetFontSize,
"Quit" => Action::Quit,
"ScrollUp" => Action::ScrollUp,
"ScrollDown" => Action::ScrollDown,
"PageUp" => Action::PageUp,
"PageDown" => Action::PageDown,
_ => return Err(E::invalid_value(Unexpected::Str(value), &self)),
}))
}
Expand Down Expand Up @@ -1105,6 +1133,14 @@ impl Config {
self.background_opacity
}

pub fn scrollback(&self) -> Scrollback {
self.scrollback
}

pub fn disable_scrollback(&mut self) {
self.scrollback.enabled = false;
}

pub fn key_bindings(&self) -> &[KeyBinding] {
&self.key_bindings[..]
}
Expand Down
33 changes: 28 additions & 5 deletions src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use copypasta::{Clipboard, Load, Store};
use config::{self, Config};
use cli::Options;
use display::OnResize;
use index::{Line, Column, Side, Point};
use index::{Line, AbsoluteLine, Column, Side, Point, AbsolutePoint};
use input::{self, MouseBinding, KeyBinding};
use selection::Selection;
use sync::FairMutex;
Expand Down Expand Up @@ -76,7 +76,7 @@ impl<'a, N: Notify + 'a> input::ActionContext for ActionContext<'a, N> {
self.selection_modified = true;
}

fn update_selection(&mut self, point: Point, side: Side) {
fn update_selection(&mut self, point: AbsolutePoint, side: Side) {
self.selection_modified = true;
// Update selection if one exists
if let &mut Some(ref mut selection) = self.selection {
Expand All @@ -88,17 +88,17 @@ impl<'a, N: Notify + 'a> input::ActionContext for ActionContext<'a, N> {
self.simple_selection(point, side);
}

fn simple_selection(&mut self, point: Point, side: Side) {
fn simple_selection(&mut self, point: AbsolutePoint, side: Side) {
*self.selection = Some(Selection::simple(point, side));
self.selection_modified = true;
}

fn semantic_selection(&mut self, point: Point) {
fn semantic_selection(&mut self, point: AbsolutePoint) {
*self.selection = Some(Selection::semantic(point, self.terminal as &Term));
self.selection_modified = true;
}

fn line_selection(&mut self, point: Point) {
fn line_selection(&mut self, point: AbsolutePoint) {
*self.selection = Some(Selection::lines(point));
self.selection_modified = true;
}
Expand All @@ -115,6 +115,13 @@ impl<'a, N: Notify + 'a> input::ActionContext for ActionContext<'a, N> {
self.terminal.reset_font_size();
}

fn visible_to_absolute(&self, point: Point) -> AbsolutePoint {
AbsolutePoint {
line: self.terminal.grid().visible_to_absolute_line(point.line),
col: point.col
}
}

#[inline]
fn mouse_mut(&mut self) -> &mut Mouse {
self.mouse
Expand All @@ -134,6 +141,20 @@ impl<'a, N: Notify + 'a> input::ActionContext for ActionContext<'a, N> {
fn last_modifiers(&mut self) -> &mut ModifiersState {
&mut self.last_modifiers
}

fn move_visible_region_up(&mut self, lines: AbsoluteLine) {
self.terminal.move_visible_region_up(lines);
}

#[inline]
fn move_visible_region_down(&mut self, lines: AbsoluteLine) {
self.terminal.move_visible_region_down(lines);
}

#[inline]
fn jump_to_bottom(&mut self) {
self.terminal.move_visible_region_to_bottom();
}
}

pub enum ClickState {
Expand All @@ -151,6 +172,7 @@ pub struct Mouse {
pub last_click_timestamp: Instant,
pub click_state: ClickState,
pub scroll_px: i32,
pub scroll_line: f32,
pub line: Line,
pub column: Column,
pub cell_side: Side,
Expand All @@ -166,6 +188,7 @@ impl Default for Mouse {
left_button_state: ElementState::Released,
click_state: ClickState::None,
scroll_px: 0,
scroll_line: 0.0,
line: Line(0),
column: Column(0),
cell_side: Side::Left,
Expand Down
Loading