mirror of
https://github.com/alacritty/alacritty.git
synced 2024-11-18 13:55:23 -05:00
Fix Rust 2018 edition idioms
This commit is contained in:
parent
926b92e864
commit
7ec36f2626
23 changed files with 78 additions and 109 deletions
10
build.rs
10
build.rs
|
@ -12,15 +12,13 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
extern crate embed_resource;
|
use embed_resource;
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
extern crate tempfile;
|
use tempfile;
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
extern crate reqwest;
|
use reqwest;
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
extern crate zip;
|
use zip;
|
||||||
|
|
||||||
extern crate gl_generator;
|
|
||||||
|
|
||||||
use gl_generator::{Api, Fallbacks, GlobalGenerator, Profile, Registry};
|
use gl_generator::{Api, Fallbacks, GlobalGenerator, Profile, Registry};
|
||||||
|
|
||||||
|
|
|
@ -112,7 +112,7 @@ struct ProcessorState {
|
||||||
///
|
///
|
||||||
/// Processor creates a Performer when running advance and passes the Performer
|
/// Processor creates a Performer when running advance and passes the Performer
|
||||||
/// to `vte::Parser`.
|
/// to `vte::Parser`.
|
||||||
struct Performer<'a, H: Handler + TermInfo + 'a, W: io::Write + 'a> {
|
struct Performer<'a, H: Handler + TermInfo, W: io::Write> {
|
||||||
_state: &'a mut ProcessorState,
|
_state: &'a mut ProcessorState,
|
||||||
handler: &'a mut H,
|
handler: &'a mut H,
|
||||||
writer: &'a mut W
|
writer: &'a mut W
|
||||||
|
@ -1225,7 +1225,7 @@ fn parse_color(attrs: &[i64], i: &mut usize) -> Option<Color> {
|
||||||
*i += 2;
|
*i += 2;
|
||||||
let idx = attrs[*i];
|
let idx = attrs[*i];
|
||||||
match idx {
|
match idx {
|
||||||
0 ... 255 => {
|
0 ..= 255 => {
|
||||||
Some(Color::Indexed(idx as u8))
|
Some(Color::Indexed(idx as u8))
|
||||||
},
|
},
|
||||||
_ => {
|
_ => {
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
extern crate log;
|
use ::log;
|
||||||
use clap::{Arg, App};
|
use clap::{Arg, App};
|
||||||
use crate::index::{Line, Column};
|
use crate::index::{Line, Column};
|
||||||
use crate::config::{Dimensions, Shell};
|
use crate::config::{Dimensions, Shell};
|
||||||
|
@ -186,11 +186,11 @@ impl Options {
|
||||||
self.dimensions
|
self.dimensions
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn command(&self) -> Option<&Shell> {
|
pub fn command(&self) -> Option<&Shell<'_>> {
|
||||||
self.command.as_ref()
|
self.command.as_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn config_path(&self) -> Option<Cow<Path>> {
|
pub fn config_path(&self) -> Option<Cow<'_, Path>> {
|
||||||
self.config.as_ref().map(|p| Cow::Borrowed(p.as_path()))
|
self.config.as_ref().map(|p| Cow::Borrowed(p.as_path()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -296,7 +296,7 @@ impl<'de> Deserialize<'de> for Decorations {
|
||||||
impl<'de> Visitor<'de> for DecorationsVisitor {
|
impl<'de> Visitor<'de> for DecorationsVisitor {
|
||||||
type Value = Decorations;
|
type Value = Decorations;
|
||||||
|
|
||||||
fn expecting(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn expecting(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
f.write_str("Some subset of full|transparent|buttonless|none")
|
f.write_str("Some subset of full|transparent|buttonless|none")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -709,7 +709,7 @@ impl<'a> de::Deserialize<'a> for ModsWrapper {
|
||||||
impl<'a> Visitor<'a> for ModsVisitor {
|
impl<'a> Visitor<'a> for ModsVisitor {
|
||||||
type Value = ModsWrapper;
|
type Value = ModsWrapper;
|
||||||
|
|
||||||
fn expecting(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn expecting(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
f.write_str("Some subset of Command|Shift|Super|Alt|Option|Control")
|
f.write_str("Some subset of Command|Shift|Super|Alt|Option|Control")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -752,7 +752,7 @@ impl<'a> de::Deserialize<'a> for ActionWrapper {
|
||||||
impl<'a> Visitor<'a> for ActionVisitor {
|
impl<'a> Visitor<'a> for ActionVisitor {
|
||||||
type Value = ActionWrapper;
|
type Value = ActionWrapper;
|
||||||
|
|
||||||
fn expecting(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn expecting(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
f.write_str("Paste, Copy, PasteSelection, IncreaseFontSize, DecreaseFontSize, \
|
f.write_str("Paste, Copy, PasteSelection, IncreaseFontSize, DecreaseFontSize, \
|
||||||
ResetFontSize, ScrollPageUp, ScrollPageDown, ScrollToTop, \
|
ResetFontSize, ScrollPageUp, ScrollPageDown, ScrollToTop, \
|
||||||
ScrollToBottom, ClearHistory, Hide, ClearLogNotice or Quit")
|
ScrollToBottom, ClearHistory, Hide, ClearLogNotice or Quit")
|
||||||
|
@ -827,7 +827,7 @@ impl<'a> de::Deserialize<'a> for ModeWrapper {
|
||||||
impl<'a> Visitor<'a> for ModeVisitor {
|
impl<'a> Visitor<'a> for ModeVisitor {
|
||||||
type Value = ModeWrapper;
|
type Value = ModeWrapper;
|
||||||
|
|
||||||
fn expecting(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn expecting(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
f.write_str("Combination of AppCursor | AppKeypad, possibly with negation (~)")
|
f.write_str("Combination of AppCursor | AppKeypad, possibly with negation (~)")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -873,7 +873,7 @@ impl<'a> de::Deserialize<'a> for MouseButton {
|
||||||
impl<'a> Visitor<'a> for MouseButtonVisitor {
|
impl<'a> Visitor<'a> for MouseButtonVisitor {
|
||||||
type Value = MouseButton;
|
type Value = MouseButton;
|
||||||
|
|
||||||
fn expecting(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn expecting(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
f.write_str("Left, Right, Middle, or a number")
|
f.write_str("Left, Right, Middle, or a number")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -967,7 +967,7 @@ impl<'a> de::Deserialize<'a> for RawBinding {
|
||||||
impl<'a> Visitor<'a> for FieldVisitor {
|
impl<'a> Visitor<'a> for FieldVisitor {
|
||||||
type Value = Field;
|
type Value = Field;
|
||||||
|
|
||||||
fn expecting(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn expecting(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
f.write_str("binding fields")
|
f.write_str("binding fields")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -995,7 +995,7 @@ impl<'a> de::Deserialize<'a> for RawBinding {
|
||||||
impl<'a> Visitor<'a> for RawBindingVisitor {
|
impl<'a> Visitor<'a> for RawBindingVisitor {
|
||||||
type Value = RawBinding;
|
type Value = RawBinding;
|
||||||
|
|
||||||
fn expecting(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn expecting(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
f.write_str("binding specification")
|
f.write_str("binding specification")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1357,7 +1357,7 @@ fn rgb_from_hex<'a, D>(deserializer: D) -> ::std::result::Result<Rgb, D::Error>
|
||||||
impl<'a> Visitor<'a> for RgbVisitor {
|
impl<'a> Visitor<'a> for RgbVisitor {
|
||||||
type Value = Rgb;
|
type Value = Rgb;
|
||||||
|
|
||||||
fn expecting(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn expecting(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
f.write_str("Hex colors spec like 'ffaabb'")
|
f.write_str("Hex colors spec like 'ffaabb'")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1416,7 +1416,7 @@ impl FromStr for Rgb {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ::std::error::Error for Error {
|
impl ::std::error::Error for Error {
|
||||||
fn cause(&self) -> Option<&::std::error::Error> {
|
fn cause(&self) -> Option<&dyn (::std::error::Error)> {
|
||||||
match *self {
|
match *self {
|
||||||
Error::NotFound | Error::Empty => None,
|
Error::NotFound | Error::Empty => None,
|
||||||
Error::ReadingEnvHome(ref err) => Some(err),
|
Error::ReadingEnvHome(ref err) => Some(err),
|
||||||
|
@ -1437,7 +1437,7 @@ impl ::std::error::Error for Error {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ::std::fmt::Display for Error {
|
impl ::std::fmt::Display for Error {
|
||||||
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
|
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
|
||||||
match *self {
|
match *self {
|
||||||
Error::NotFound | Error::Empty => write!(f, "{}", ::std::error::Error::description(self)),
|
Error::NotFound | Error::Empty => write!(f, "{}", ::std::error::Error::description(self)),
|
||||||
Error::ReadingEnvHome(ref err) => {
|
Error::ReadingEnvHome(ref err) => {
|
||||||
|
@ -1625,7 +1625,7 @@ impl Config {
|
||||||
.map(|p| p.as_path())
|
.map(|p| p.as_path())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn shell(&self) -> Option<&Shell> {
|
pub fn shell(&self) -> Option<&Shell<'_>> {
|
||||||
self.shell.as_ref()
|
self.shell.as_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1831,7 +1831,7 @@ impl DeserializeSize for Size {
|
||||||
{
|
{
|
||||||
type Value = f64;
|
type Value = f64;
|
||||||
|
|
||||||
fn expecting(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn expecting(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
f.write_str("f64 or u64")
|
f.write_str("f64 or u64")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ pub enum Error {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ::std::error::Error for Error {
|
impl ::std::error::Error for Error {
|
||||||
fn cause(&self) -> Option<&::std::error::Error> {
|
fn cause(&self) -> Option<&dyn (::std::error::Error)> {
|
||||||
match *self {
|
match *self {
|
||||||
Error::Window(ref err) => Some(err),
|
Error::Window(ref err) => Some(err),
|
||||||
Error::Font(ref err) => Some(err),
|
Error::Font(ref err) => Some(err),
|
||||||
|
@ -62,7 +62,7 @@ impl ::std::error::Error for Error {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ::std::fmt::Display for Error {
|
impl ::std::fmt::Display for Error {
|
||||||
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
|
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
|
||||||
match *self {
|
match *self {
|
||||||
Error::Window(ref err) => err.fmt(f),
|
Error::Window(ref err) => err.fmt(f),
|
||||||
Error::Font(ref err) => err.fmt(f),
|
Error::Font(ref err) => err.fmt(f),
|
||||||
|
@ -292,9 +292,9 @@ impl Display {
|
||||||
/// Process pending resize events
|
/// Process pending resize events
|
||||||
pub fn handle_resize(
|
pub fn handle_resize(
|
||||||
&mut self,
|
&mut self,
|
||||||
terminal: &mut MutexGuard<Term>,
|
terminal: &mut MutexGuard<'_, Term>,
|
||||||
config: &Config,
|
config: &Config,
|
||||||
items: &mut [&mut OnResize],
|
items: &mut [&mut dyn OnResize],
|
||||||
) {
|
) {
|
||||||
// Resize events new_size and are handled outside the poll_events
|
// Resize events new_size and are handled outside the poll_events
|
||||||
// iterator. This has the effect of coalescing multiple resize
|
// iterator. This has the effect of coalescing multiple resize
|
||||||
|
|
|
@ -34,7 +34,7 @@ pub trait Notify {
|
||||||
fn notify<B: Into<Cow<'static, [u8]>>>(&mut self, _: B);
|
fn notify<B: Into<Cow<'static, [u8]>>>(&mut self, _: B);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct ActionContext<'a, N: 'a> {
|
pub struct ActionContext<'a, N> {
|
||||||
pub notifier: &'a mut N,
|
pub notifier: &'a mut N,
|
||||||
pub terminal: &'a mut Term,
|
pub terminal: &'a mut Term,
|
||||||
pub size_info: &'a mut SizeInfo,
|
pub size_info: &'a mut SizeInfo,
|
||||||
|
@ -456,7 +456,7 @@ impl<N: Notify> Processor<N> {
|
||||||
{
|
{
|
||||||
// Ditto on lazy initialization for context and processor.
|
// Ditto on lazy initialization for context and processor.
|
||||||
let context;
|
let context;
|
||||||
let mut processor: input::Processor<ActionContext<N>>;
|
let mut processor: input::Processor<'_, ActionContext<'_, N>>;
|
||||||
|
|
||||||
let print_events = self.print_events;
|
let print_events = self.print_events;
|
||||||
|
|
||||||
|
|
|
@ -99,7 +99,7 @@ pub struct Grid<T> {
|
||||||
max_scroll_limit: usize,
|
max_scroll_limit: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct GridIterator<'a, T: 'a> {
|
pub struct GridIterator<'a, T> {
|
||||||
/// Immutable grid reference
|
/// Immutable grid reference
|
||||||
grid: &'a Grid<T>,
|
grid: &'a Grid<T>,
|
||||||
|
|
||||||
|
@ -411,7 +411,7 @@ impl<T> Grid<T> {
|
||||||
self.lines
|
self.lines
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn display_iter(&self) -> DisplayIter<T> {
|
pub fn display_iter(&self) -> DisplayIter<'_, T> {
|
||||||
DisplayIter::new(self)
|
DisplayIter::new(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -454,7 +454,7 @@ impl<T> Grid<T> {
|
||||||
self.raw.truncate();
|
self.raw.truncate();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn iter_from(&self, point: Point<usize>) -> GridIterator<T> {
|
pub fn iter_from(&self, point: Point<usize>) -> GridIterator<'_, T> {
|
||||||
GridIterator {
|
GridIterator {
|
||||||
grid: self,
|
grid: self,
|
||||||
cur: point,
|
cur: point,
|
||||||
|
@ -557,7 +557,7 @@ impl<'point, T> IndexMut<&'point Point> for Grid<T> {
|
||||||
/// A subset of lines in the grid
|
/// A subset of lines in the grid
|
||||||
///
|
///
|
||||||
/// May be constructed using Grid::region(..)
|
/// May be constructed using Grid::region(..)
|
||||||
pub struct Region<'a, T: 'a> {
|
pub struct Region<'a, T> {
|
||||||
start: Line,
|
start: Line,
|
||||||
end: Line,
|
end: Line,
|
||||||
raw: &'a Storage<T>,
|
raw: &'a Storage<T>,
|
||||||
|
@ -566,7 +566,7 @@ pub struct Region<'a, T: 'a> {
|
||||||
/// A mutable subset of lines in the grid
|
/// A mutable subset of lines in the grid
|
||||||
///
|
///
|
||||||
/// May be constructed using Grid::region_mut(..)
|
/// May be constructed using Grid::region_mut(..)
|
||||||
pub struct RegionMut<'a, T: 'a> {
|
pub struct RegionMut<'a, T> {
|
||||||
start: Line,
|
start: Line,
|
||||||
end: Line,
|
end: Line,
|
||||||
raw: &'a mut Storage<T>,
|
raw: &'a mut Storage<T>,
|
||||||
|
@ -585,14 +585,14 @@ impl<'a, T> RegionMut<'a, T> {
|
||||||
|
|
||||||
pub trait IndexRegion<I, T> {
|
pub trait IndexRegion<I, T> {
|
||||||
/// Get an immutable region of Self
|
/// Get an immutable region of Self
|
||||||
fn region(&self, _: I) -> Region<T>;
|
fn region(&self, _: I) -> Region<'_, T>;
|
||||||
|
|
||||||
/// Get a mutable region of Self
|
/// Get a mutable region of Self
|
||||||
fn region_mut(&mut self, _: I) -> RegionMut<T>;
|
fn region_mut(&mut self, _: I) -> RegionMut<'_, T>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> IndexRegion<Range<Line>, T> for Grid<T> {
|
impl<T> IndexRegion<Range<Line>, T> for Grid<T> {
|
||||||
fn region(&self, index: Range<Line>) -> Region<T> {
|
fn region(&self, index: Range<Line>) -> Region<'_, T> {
|
||||||
assert!(index.start < self.num_lines());
|
assert!(index.start < self.num_lines());
|
||||||
assert!(index.end <= self.num_lines());
|
assert!(index.end <= self.num_lines());
|
||||||
assert!(index.start <= index.end);
|
assert!(index.start <= index.end);
|
||||||
|
@ -602,7 +602,7 @@ impl<T> IndexRegion<Range<Line>, T> for Grid<T> {
|
||||||
raw: &self.raw
|
raw: &self.raw
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn region_mut(&mut self, index: Range<Line>) -> RegionMut<T> {
|
fn region_mut(&mut self, index: Range<Line>) -> RegionMut<'_, T> {
|
||||||
assert!(index.start < self.num_lines());
|
assert!(index.start < self.num_lines());
|
||||||
assert!(index.end <= self.num_lines());
|
assert!(index.end <= self.num_lines());
|
||||||
assert!(index.start <= index.end);
|
assert!(index.start <= index.end);
|
||||||
|
@ -615,7 +615,7 @@ impl<T> IndexRegion<Range<Line>, T> for Grid<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> IndexRegion<RangeTo<Line>, T> for Grid<T> {
|
impl<T> IndexRegion<RangeTo<Line>, T> for Grid<T> {
|
||||||
fn region(&self, index: RangeTo<Line>) -> Region<T> {
|
fn region(&self, index: RangeTo<Line>) -> Region<'_, T> {
|
||||||
assert!(index.end <= self.num_lines());
|
assert!(index.end <= self.num_lines());
|
||||||
Region {
|
Region {
|
||||||
start: Line(0),
|
start: Line(0),
|
||||||
|
@ -623,7 +623,7 @@ impl<T> IndexRegion<RangeTo<Line>, T> for Grid<T> {
|
||||||
raw: &self.raw
|
raw: &self.raw
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn region_mut(&mut self, index: RangeTo<Line>) -> RegionMut<T> {
|
fn region_mut(&mut self, index: RangeTo<Line>) -> RegionMut<'_, T> {
|
||||||
assert!(index.end <= self.num_lines());
|
assert!(index.end <= self.num_lines());
|
||||||
RegionMut {
|
RegionMut {
|
||||||
start: Line(0),
|
start: Line(0),
|
||||||
|
@ -634,7 +634,7 @@ impl<T> IndexRegion<RangeTo<Line>, T> for Grid<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> IndexRegion<RangeFrom<Line>, T> for Grid<T> {
|
impl<T> IndexRegion<RangeFrom<Line>, T> for Grid<T> {
|
||||||
fn region(&self, index: RangeFrom<Line>) -> Region<T> {
|
fn region(&self, index: RangeFrom<Line>) -> Region<'_, T> {
|
||||||
assert!(index.start < self.num_lines());
|
assert!(index.start < self.num_lines());
|
||||||
Region {
|
Region {
|
||||||
start: index.start,
|
start: index.start,
|
||||||
|
@ -642,7 +642,7 @@ impl<T> IndexRegion<RangeFrom<Line>, T> for Grid<T> {
|
||||||
raw: &self.raw
|
raw: &self.raw
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn region_mut(&mut self, index: RangeFrom<Line>) -> RegionMut<T> {
|
fn region_mut(&mut self, index: RangeFrom<Line>) -> RegionMut<'_, T> {
|
||||||
assert!(index.start < self.num_lines());
|
assert!(index.start < self.num_lines());
|
||||||
RegionMut {
|
RegionMut {
|
||||||
start: index.start,
|
start: index.start,
|
||||||
|
@ -653,7 +653,7 @@ impl<T> IndexRegion<RangeFrom<Line>, T> for Grid<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> IndexRegion<RangeFull, T> for Grid<T> {
|
impl<T> IndexRegion<RangeFull, T> for Grid<T> {
|
||||||
fn region(&self, _: RangeFull) -> Region<T> {
|
fn region(&self, _: RangeFull) -> Region<'_, T> {
|
||||||
Region {
|
Region {
|
||||||
start: Line(0),
|
start: Line(0),
|
||||||
end: self.num_lines(),
|
end: self.num_lines(),
|
||||||
|
@ -661,7 +661,7 @@ impl<T> IndexRegion<RangeFull, T> for Grid<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn region_mut(&mut self, _: RangeFull) -> RegionMut<T> {
|
fn region_mut(&mut self, _: RangeFull) -> RegionMut<'_, T> {
|
||||||
RegionMut {
|
RegionMut {
|
||||||
start: Line(0),
|
start: Line(0),
|
||||||
end: self.num_lines(),
|
end: self.num_lines(),
|
||||||
|
@ -670,13 +670,13 @@ impl<T> IndexRegion<RangeFull, T> for Grid<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct RegionIter<'a, T: 'a> {
|
pub struct RegionIter<'a, T> {
|
||||||
end: Line,
|
end: Line,
|
||||||
cur: Line,
|
cur: Line,
|
||||||
raw: &'a Storage<T>,
|
raw: &'a Storage<T>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct RegionIterMut<'a, T: 'a> {
|
pub struct RegionIterMut<'a, T> {
|
||||||
end: Line,
|
end: Line,
|
||||||
cur: Line,
|
cur: Line,
|
||||||
raw: &'a mut Storage<T>,
|
raw: &'a mut Storage<T>,
|
||||||
|
@ -741,7 +741,7 @@ impl<'a, T> Iterator for RegionIterMut<'a, T> {
|
||||||
// -------------------------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
/// Iterates over the visible area accounting for buffer transform
|
/// Iterates over the visible area accounting for buffer transform
|
||||||
pub struct DisplayIter<'a, T: 'a> {
|
pub struct DisplayIter<'a, T> {
|
||||||
grid: &'a Grid<T>,
|
grid: &'a Grid<T>,
|
||||||
offset: usize,
|
offset: usize,
|
||||||
limit: usize,
|
limit: usize,
|
||||||
|
|
|
@ -85,7 +85,7 @@ impl<T> Row<T> {
|
||||||
self.inner.len()
|
self.inner.len()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn iter(&self) -> slice::Iter<T> {
|
pub fn iter(&self) -> slice::Iter<'_, T> {
|
||||||
self.inner.iter()
|
self.inner.iter()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,7 +77,7 @@ impl From<Point> for Point<usize> {
|
||||||
pub struct Line(pub usize);
|
pub struct Line(pub usize);
|
||||||
|
|
||||||
impl fmt::Display for Line {
|
impl fmt::Display for Line {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
write!(f, "{}", self.0)
|
write!(f, "{}", self.0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,7 @@ impl fmt::Display for Line {
|
||||||
pub struct Column(pub usize);
|
pub struct Column(pub usize);
|
||||||
|
|
||||||
impl fmt::Display for Column {
|
impl fmt::Display for Column {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
write!(f, "{}", self.0)
|
write!(f, "{}", self.0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -101,7 +101,7 @@ impl fmt::Display for Column {
|
||||||
pub struct Linear(pub usize);
|
pub struct Linear(pub usize);
|
||||||
|
|
||||||
impl fmt::Display for Linear {
|
impl fmt::Display for Linear {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
write!(f, "Linear({})", self.0)
|
write!(f, "Linear({})", self.0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -939,7 +939,7 @@ mod tests {
|
||||||
processor.mouse_input(state, button, modifiers);
|
processor.mouse_input(state, button, modifiers);
|
||||||
};
|
};
|
||||||
|
|
||||||
assert!(match mouse.click_state {
|
assert!(match processor.ctx.mouse.click_state {
|
||||||
$end_state => processor.ctx.last_action == $last_action,
|
$end_state => processor.ctx.last_action == $last_action,
|
||||||
_ => false
|
_ => false
|
||||||
});
|
});
|
||||||
|
|
28
src/lib.rs
28
src/lib.rs
|
@ -23,10 +23,6 @@
|
||||||
#[macro_use] extern crate serde_derive;
|
#[macro_use] extern crate serde_derive;
|
||||||
#[macro_use] extern crate static_assertions;
|
#[macro_use] extern crate static_assertions;
|
||||||
|
|
||||||
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "dragonfly",
|
|
||||||
target_os = "openbsd"))]
|
|
||||||
extern crate x11_dl;
|
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
extern crate mio_named_pipes;
|
extern crate mio_named_pipes;
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
|
@ -42,30 +38,6 @@ extern crate image;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate objc;
|
extern crate objc;
|
||||||
|
|
||||||
extern crate arraydeque;
|
|
||||||
extern crate cgmath;
|
|
||||||
extern crate copypasta;
|
|
||||||
extern crate env_logger;
|
|
||||||
extern crate errno;
|
|
||||||
extern crate fnv;
|
|
||||||
extern crate font;
|
|
||||||
extern crate glutin;
|
|
||||||
extern crate libc;
|
|
||||||
extern crate mio;
|
|
||||||
extern crate mio_more;
|
|
||||||
extern crate notify;
|
|
||||||
extern crate parking_lot;
|
|
||||||
extern crate serde;
|
|
||||||
extern crate serde_json;
|
|
||||||
extern crate serde_yaml;
|
|
||||||
extern crate unicode_width;
|
|
||||||
extern crate vte;
|
|
||||||
extern crate xdg;
|
|
||||||
extern crate base64;
|
|
||||||
extern crate terminfo;
|
|
||||||
extern crate url;
|
|
||||||
extern crate time;
|
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
pub mod macros;
|
pub mod macros;
|
||||||
|
|
||||||
|
|
|
@ -120,11 +120,11 @@ impl Logger {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl log::Log for Logger {
|
impl log::Log for Logger {
|
||||||
fn enabled(&self, metadata: &log::Metadata) -> bool {
|
fn enabled(&self, metadata: &log::Metadata<'_>) -> bool {
|
||||||
metadata.level() <= self.level
|
metadata.level() <= self.level
|
||||||
}
|
}
|
||||||
|
|
||||||
fn log(&self, record: &log::Record) {
|
fn log(&self, record: &log::Record<'_>) {
|
||||||
if self.enabled(record.metadata()) && record.target().starts_with("alacritty") {
|
if self.enabled(record.metadata()) && record.target().starts_with("alacritty") {
|
||||||
let msg = format!(
|
let msg = format!(
|
||||||
"[{}] [{}] {}\n",
|
"[{}] [{}] {}\n",
|
||||||
|
|
|
@ -118,7 +118,7 @@ fn run(
|
||||||
mut config: Config,
|
mut config: Config,
|
||||||
options: &cli::Options,
|
options: &cli::Options,
|
||||||
mut logger_proxy: LoggerProxy,
|
mut logger_proxy: LoggerProxy,
|
||||||
) -> Result<(), Box<Error>> {
|
) -> Result<(), Box<dyn Error>> {
|
||||||
info!("Welcome to Alacritty.");
|
info!("Welcome to Alacritty.");
|
||||||
if let Some(config_path) = config.path() {
|
if let Some(config_path) = config.path() {
|
||||||
info!("Configuration loaded from {}", config_path.display());
|
info!("Configuration loaded from {}", config_path.display());
|
||||||
|
|
|
@ -86,7 +86,7 @@ impl Meter {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get a sampler
|
/// Get a sampler
|
||||||
pub fn sampler(&mut self) -> Sampler {
|
pub fn sampler(&mut self) -> Sampler<'_> {
|
||||||
Sampler::new(self)
|
Sampler::new(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,7 @@ pub enum Error {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ::std::error::Error for Error {
|
impl ::std::error::Error for Error {
|
||||||
fn cause(&self) -> Option<&::std::error::Error> {
|
fn cause(&self) -> Option<&dyn (::std::error::Error)> {
|
||||||
match *self {
|
match *self {
|
||||||
Error::ShaderCreation(ref err) => Some(err),
|
Error::ShaderCreation(ref err) => Some(err),
|
||||||
}
|
}
|
||||||
|
@ -79,7 +79,7 @@ impl ::std::error::Error for Error {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ::std::fmt::Display for Error {
|
impl ::std::fmt::Display for Error {
|
||||||
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
|
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
|
||||||
match *self {
|
match *self {
|
||||||
Error::ShaderCreation(ref err) => {
|
Error::ShaderCreation(ref err) => {
|
||||||
write!(f, "There was an error initializing the shaders: {}", err)
|
write!(f, "There was an error initializing the shaders: {}", err)
|
||||||
|
@ -660,7 +660,7 @@ impl QuadRenderer {
|
||||||
func: F,
|
func: F,
|
||||||
) -> T
|
) -> T
|
||||||
where
|
where
|
||||||
F: FnOnce(RenderApi) -> T,
|
F: FnOnce(RenderApi<'_>) -> T,
|
||||||
{
|
{
|
||||||
while let Ok(msg) = self.rx.try_recv() {
|
while let Ok(msg) = self.rx.try_recv() {
|
||||||
match msg {
|
match msg {
|
||||||
|
@ -704,7 +704,7 @@ impl QuadRenderer {
|
||||||
|
|
||||||
pub fn with_loader<F, T>(&mut self, func: F) -> T
|
pub fn with_loader<F, T>(&mut self, func: F) -> T
|
||||||
where
|
where
|
||||||
F: FnOnce(LoaderApi) -> T,
|
F: FnOnce(LoaderApi<'_>) -> T,
|
||||||
{
|
{
|
||||||
unsafe {
|
unsafe {
|
||||||
gl::ActiveTexture(gl::TEXTURE0);
|
gl::ActiveTexture(gl::TEXTURE0);
|
||||||
|
@ -897,7 +897,7 @@ impl<'a> RenderApi<'a> {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Add cell to batch
|
// Add cell to batch
|
||||||
let glyph = glyph_cache.get(glyph_key, self); // borrowck multiple mutable borrows
|
let glyph = glyph_cache.get(glyph_key, self);
|
||||||
self.add_render_item(&cell, glyph);
|
self.add_render_item(&cell, glyph);
|
||||||
|
|
||||||
// Render zero-width characters
|
// Render zero-width characters
|
||||||
|
@ -1288,7 +1288,7 @@ pub enum ShaderCreationError {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ::std::error::Error for ShaderCreationError {
|
impl ::std::error::Error for ShaderCreationError {
|
||||||
fn cause(&self) -> Option<&::std::error::Error> {
|
fn cause(&self) -> Option<&dyn (::std::error::Error)> {
|
||||||
match *self {
|
match *self {
|
||||||
ShaderCreationError::Io(ref err) => Some(err),
|
ShaderCreationError::Io(ref err) => Some(err),
|
||||||
_ => None,
|
_ => None,
|
||||||
|
@ -1305,7 +1305,7 @@ impl ::std::error::Error for ShaderCreationError {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ::std::fmt::Display for ShaderCreationError {
|
impl ::std::fmt::Display for ShaderCreationError {
|
||||||
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
|
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
|
||||||
match *self {
|
match *self {
|
||||||
ShaderCreationError::Io(ref err) => write!(f, "couldn't read shader: {}", err),
|
ShaderCreationError::Io(ref err) => write!(f, "couldn't read shader: {}", err),
|
||||||
ShaderCreationError::Compile(ref _path, ref s) => {
|
ShaderCreationError::Compile(ref _path, ref s) => {
|
||||||
|
|
|
@ -38,7 +38,7 @@ impl<T> FairMutex<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Lock the mutex
|
/// Lock the mutex
|
||||||
pub fn lock(&self) -> MutexGuard<T> {
|
pub fn lock(&self) -> MutexGuard<'_, T> {
|
||||||
// Must bind to a temporary or the lock will be freed before going
|
// Must bind to a temporary or the lock will be freed before going
|
||||||
// into data.lock()
|
// into data.lock()
|
||||||
let _next = self.next.lock();
|
let _next = self.next.lock();
|
||||||
|
|
|
@ -154,7 +154,7 @@ impl List {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Debug for List {
|
impl fmt::Debug for List {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
f.write_str("List[..]")
|
f.write_str("List[..]")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -391,9 +391,9 @@ impl<'a> RenderableCellsIter<'a> {
|
||||||
cell.flags & Flags::DIM_BOLD,
|
cell.flags & Flags::DIM_BOLD,
|
||||||
idx
|
idx
|
||||||
) {
|
) {
|
||||||
(true, self::cell::Flags::BOLD, 0...7) => idx as usize + 8,
|
(true, self::cell::Flags::BOLD, 0..=7) => idx as usize + 8,
|
||||||
(false, self::cell::Flags::DIM, 8...15) => idx as usize - 8,
|
(false, self::cell::Flags::DIM, 8..=15) => idx as usize - 8,
|
||||||
(false, self::cell::Flags::DIM, 0...7) => idx as usize + 260,
|
(false, self::cell::Flags::DIM, 0..=7) => idx as usize + 260,
|
||||||
_ => idx as usize,
|
_ => idx as usize,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1128,7 +1128,7 @@ impl Term {
|
||||||
&'b self,
|
&'b self,
|
||||||
config: &'b Config,
|
config: &'b Config,
|
||||||
window_focused: bool,
|
window_focused: bool,
|
||||||
) -> RenderableCellsIter {
|
) -> RenderableCellsIter<'_> {
|
||||||
let alt_screen = self.mode.contains(TermMode::ALT_SCREEN);
|
let alt_screen = self.mode.contains(TermMode::ALT_SCREEN);
|
||||||
let selection = self.grid.selection.as_ref()
|
let selection = self.grid.selection.as_ref()
|
||||||
.and_then(|s| s.to_span(self, alt_screen))
|
.and_then(|s| s.to_span(self, alt_screen))
|
||||||
|
@ -2068,7 +2068,7 @@ impl ansi::Handler for Term {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
extern crate serde_json;
|
use serde_json;
|
||||||
|
|
||||||
use super::{Cell, Term, SizeInfo};
|
use super::{Cell, Term, SizeInfo};
|
||||||
use crate::term::{cell, Search};
|
use crate::term::{cell, Search};
|
||||||
|
@ -2419,8 +2419,8 @@ mod benches {
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
use grid::Grid;
|
use crate::grid::Grid;
|
||||||
use config::Config;
|
use crate::config::Config;
|
||||||
|
|
||||||
use super::{SizeInfo, Term};
|
use super::{SizeInfo, Term};
|
||||||
use super::cell::Cell;
|
use super::cell::Cell;
|
||||||
|
|
|
@ -40,7 +40,7 @@ pub trait EventedReadWrite {
|
||||||
fn register(
|
fn register(
|
||||||
&mut self,
|
&mut self,
|
||||||
_: &mio::Poll,
|
_: &mio::Poll,
|
||||||
_: &mut Iterator<Item = &usize>,
|
_: &mut dyn Iterator<Item = &usize>,
|
||||||
_: mio::Ready,
|
_: mio::Ready,
|
||||||
_: mio::PollOpt,
|
_: mio::PollOpt,
|
||||||
) -> io::Result<()>;
|
) -> io::Result<()>;
|
||||||
|
|
|
@ -149,7 +149,7 @@ struct Passwd<'a> {
|
||||||
/// # Unsafety
|
/// # Unsafety
|
||||||
///
|
///
|
||||||
/// If `buf` is changed while `Passwd` is alive, bad thing will almost certainly happen.
|
/// If `buf` is changed while `Passwd` is alive, bad thing will almost certainly happen.
|
||||||
fn get_pw_entry(buf: &mut [i8; 1024]) -> Passwd {
|
fn get_pw_entry(buf: &mut [i8; 1024]) -> Passwd<'_> {
|
||||||
// Create zeroed passwd struct
|
// Create zeroed passwd struct
|
||||||
let mut entry: libc::passwd = unsafe { ::std::mem::uninitialized() };
|
let mut entry: libc::passwd = unsafe { ::std::mem::uninitialized() };
|
||||||
|
|
||||||
|
@ -329,7 +329,7 @@ impl EventedReadWrite for Pty {
|
||||||
fn register(
|
fn register(
|
||||||
&mut self,
|
&mut self,
|
||||||
poll: &mio::Poll,
|
poll: &mio::Poll,
|
||||||
token: &mut Iterator<Item = &usize>,
|
token: &mut dyn Iterator<Item = &usize>,
|
||||||
interest: mio::Ready,
|
interest: mio::Ready,
|
||||||
poll_opts: mio::PollOpt,
|
poll_opts: mio::PollOpt,
|
||||||
) -> io::Result<()> {
|
) -> io::Result<()> {
|
||||||
|
|
|
@ -50,13 +50,13 @@ pub mod fmt {
|
||||||
pub struct $s<T>(pub T);
|
pub struct $s<T>(pub T);
|
||||||
|
|
||||||
impl<T: fmt::Display> fmt::Display for $s<T> {
|
impl<T: fmt::Display> fmt::Display for $s<T> {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
write!(f, concat!("\x1b[", $color, "m{}\x1b[0m"), self.0)
|
write!(f, concat!("\x1b[", $color, "m{}\x1b[0m"), self.0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: fmt::Debug> fmt::Debug for $s<T> {
|
impl<T: fmt::Debug> fmt::Debug for $s<T> {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
write!(f, concat!("\x1b[", $color, "m{:?}\x1b[0m"), self.0)
|
write!(f, concat!("\x1b[", $color, "m{:?}\x1b[0m"), self.0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,7 +93,7 @@ pub struct DeviceProperties {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ::std::error::Error for Error {
|
impl ::std::error::Error for Error {
|
||||||
fn cause(&self) -> Option<&::std::error::Error> {
|
fn cause(&self) -> Option<&dyn (::std::error::Error)> {
|
||||||
match *self {
|
match *self {
|
||||||
Error::ContextCreation(ref err) => Some(err),
|
Error::ContextCreation(ref err) => Some(err),
|
||||||
Error::Context(ref err) => Some(err),
|
Error::Context(ref err) => Some(err),
|
||||||
|
@ -109,7 +109,7 @@ impl ::std::error::Error for Error {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Display for Error {
|
impl Display for Error {
|
||||||
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
|
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
|
||||||
match *self {
|
match *self {
|
||||||
Error::ContextCreation(ref err) => write!(f, "Error creating GL context; {}", err),
|
Error::ContextCreation(ref err) => write!(f, "Error creating GL context; {}", err),
|
||||||
Error::Context(ref err) => write!(f, "Error operating on render context; {}", err),
|
Error::Context(ref err) => write!(f, "Error operating on render context; {}", err),
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate serde_derive;
|
extern crate serde_derive;
|
||||||
extern crate serde_json as json;
|
use serde_json as json;
|
||||||
extern crate alacritty;
|
|
||||||
|
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::{self, Read};
|
use std::io::{self, Read};
|
||||||
|
|
Loading…
Reference in a new issue