aboutsummaryrefslogtreecommitdiff
path: root/src/ansi.rs
diff options
context:
space:
mode:
authorJoe Wilm <joe@jwilm.com>2016-07-03 21:12:43 -0700
committerJoe Wilm <joe@jwilm.com>2016-07-03 21:12:43 -0700
commit8a4f14188e83dd47901503c3d530e85874ba0a30 (patch)
tree359ddc6679149a1d39ac12a005a538795e7d720e /src/ansi.rs
parent6639e6f24fab269f23392b11e566ef0a29ca163b (diff)
downloadalacritty-8a4f14188e83dd47901503c3d530e85874ba0a30.tar.gz
alacritty-8a4f14188e83dd47901503c3d530e85874ba0a30.zip
Make ansi::TermInfo strongly typed
The rows function has been renamed to lines, and it now returns `Line`. The cols function correspondingly returns `Column`.
Diffstat (limited to 'src/ansi.rs')
-rw-r--r--src/ansi.rs24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/ansi.rs b/src/ansi.rs
index 5d4d9e4c..ae4261a9 100644
--- a/src/ansi.rs
+++ b/src/ansi.rs
@@ -30,6 +30,7 @@
//! aren't necessary for everyday terminal usage. If you feel like something that's not supported
//! should be, feel free to add it. Please try not to become overzealous and adding support for
//! sequences only used by folks trapped in 1988.
+use index::{Column, Line};
use ::Rgb;
@@ -41,8 +42,8 @@ pub enum Escape {
/// Trait that provides properties of terminal
pub trait TermInfo {
- fn rows(&self) -> usize;
- fn cols(&self) -> usize;
+ fn lines(&self) -> Line;
+ fn cols(&self) -> Column;
}
pub const CSI_ATTR_MAX: usize = 16;
@@ -399,12 +400,12 @@ impl Handler for DebugHandler {
}
impl TermInfo for DebugHandler {
- fn rows(&self) -> usize {
- 24
+ fn lines(&self) -> Line {
+ Line(24)
}
- fn cols(&self) -> usize {
- 80
+ fn cols(&self) -> Column {
+ Column(80)
}
}
@@ -746,7 +747,7 @@ impl Parser {
unknown!();
}
let top = arg_or_default!(args[0], 1);
- let bottom = arg_or_default!(args[1], handler.rows() as i64);
+ let bottom = arg_or_default!(args[1], *handler.lines() as i64);
handler.set_scrolling_region(top - 1, bottom - 1);
},
@@ -1104,6 +1105,7 @@ impl Default for State {
#[cfg(test)]
mod tests {
use std::io::{Cursor, Read};
+ use index::{Line, Column};
use super::{Parser, Handler, Attr, DebugHandler, TermInfo};
use ::Rgb;
@@ -1119,12 +1121,12 @@ mod tests {
}
impl TermInfo for AttrHandler {
- fn rows(&self) -> usize {
- 24
+ fn lines(&self) -> Line {
+ Line(24)
}
- fn cols(&self) -> usize {
- 80
+ fn cols(&self) -> Column {
+ Column(80)
}
}