Skip to content

Commit

Permalink
Update to edition 2018
Browse files Browse the repository at this point in the history
  • Loading branch information
murarth committed Mar 17, 2019
1 parent 57dd049 commit 904e4b0
Show file tree
Hide file tree
Showing 16 changed files with 67 additions and 71 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ description = "Interactive terminal input reader"

authors = ["Murarth <[email protected]>"]
version = "0.5.4"
edition = "2018"

documentation = "https://docs.rs/linefeed/"
homepage = "https://github.com/murarth/linefeed"
Expand Down
2 changes: 1 addition & 1 deletion examples/demo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ fn split_first_word(s: &str) -> (&str, &str) {
let s = s.trim();

match s.find(|ch: char| ch.is_whitespace()) {
Some(pos) => (&s[..pos], s[pos..].trim_left()),
Some(pos) => (&s[..pos], s[pos..].trim_start()),
None => (s, "")
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use std::borrow::Cow::{self, Borrowed, Owned};
use std::fmt;

use chars::escape_sequence;
use crate::chars::escape_sequence;

macro_rules! define_commands {
( $( #[$meta:meta] $name:ident => $str:expr , )+ ) => {
Expand Down
4 changes: 2 additions & 2 deletions src/complete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use std::borrow::Cow::{self, Borrowed, Owned};
use std::fs::read_dir;
use std::path::{is_separator, MAIN_SEPARATOR};

use prompter::Prompter;
use terminal::Terminal;
use crate::prompter::Prompter;
use crate::terminal::Terminal;

/// Represents a single possible completion
#[derive(Clone, Debug)]
Expand Down
6 changes: 3 additions & 3 deletions src/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
use std::io;

use command::Category;
use prompter::Prompter;
use terminal::Terminal;
use crate::command::Category;
use crate::prompter::Prompter;
use crate::terminal::Terminal;

/// Implements custom functionality for a `Prompter` command
pub trait Function<Term: Terminal>: Send + Sync {
Expand Down
16 changes: 8 additions & 8 deletions src/inputrc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ use std::io::{stderr, Read, Write};
use std::path::Path;
use std::str::{Chars, Lines};

use chars::{ctrl, meta, parse_char_name};
use command::Command;
use crate::chars::{ctrl, meta, parse_char_name};
use crate::command::Command;

/// Parsed configuration directive
#[derive(Clone, Debug)]
Expand Down Expand Up @@ -344,26 +344,26 @@ impl<'a> Iterator for Tokens<'a> {

let tok = match ch {
':' => {
self.line = self.line[1..].trim_left();
self.line = self.line[1..].trim_start();
Token::Colon
}
'=' => {
self.line = self.line[1..].trim_left();
self.line = self.line[1..].trim_start();
Token::Equal
}
'$' => {
let (word, rest) = parse_word(&self.line[1..]);
self.line = rest.trim_left();
self.line = rest.trim_start();
Token::SpecialWord(word)
}
'"' => {
let (tok, rest) = parse_string(self.line);
self.line = rest.trim_left();
self.line = rest.trim_start();
tok
}
_ => {
let (word, rest) = parse_word(self.line);
self.line = rest.trim_left();
self.line = rest.trim_start();
Token::Word(word)
}
};
Expand Down Expand Up @@ -515,7 +515,7 @@ fn parse_word(s: &str) -> (&str, &str) {
#[cfg(test)]
mod test {
use super::{Directive, parse_text};
use command::Command;
use crate::command::Command;

fn one<T>(v: Vec<T>) -> T {
assert_eq!(v.len(), 1);
Expand Down
16 changes: 8 additions & 8 deletions src/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ use std::path::Path;
use std::sync::{Arc, Mutex, MutexGuard};
use std::time::Duration;

use command::Command;
use complete::{Completer};
use function::Function;
use inputrc::Directive;
use reader::{Read, Reader, ReadLock, ReadResult};
use terminal::{DefaultTerminal, Signal, Terminal};
use variables::Variable;
use writer::{Write, Writer, WriteLock};
use crate::command::Command;
use crate::complete::{Completer};
use crate::function::Function;
use crate::inputrc::Directive;
use crate::reader::{Read, Reader, ReadLock, ReadResult};
use crate::terminal::{DefaultTerminal, Signal, Terminal};
use crate::variables::Variable;
use crate::writer::{Write, Writer, WriteLock};

/// The main interface to input reading and other terminal operations
///
Expand Down
25 changes: 10 additions & 15 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,16 @@
#![deny(missing_docs)]

extern crate dirs;
extern crate mortal;

#[cfg(windows)] extern crate winapi;

#[cfg(test)] #[macro_use] extern crate assert_matches;

pub use command::Command;
pub use complete::{Completer, Completion, Suffix};
pub use function::Function;
pub use interface::Interface;
pub use prompter::Prompter;
pub use reader::{Reader, ReadResult};
pub use terminal::{DefaultTerminal, Signal, Terminal};
pub use writer::Writer;
pub use crate::command::Command;
pub use crate::complete::{Completer, Completion, Suffix};
pub use crate::function::Function;
pub use crate::interface::Interface;
pub use crate::prompter::Prompter;
pub use crate::reader::{Reader, ReadResult};
pub use crate::terminal::{DefaultTerminal, Signal, Terminal};
pub use crate::writer::Writer;

pub mod chars;
pub mod command;
Expand All @@ -70,8 +65,8 @@ mod sys;

#[cfg(test)]
mod test {
use interface::Interface;
use terminal::{DefaultTerminal, Terminal};
use crate::interface::Interface;
use crate::terminal::{DefaultTerminal, Terminal};

fn assert_has_traits<T: 'static + Send + Sync>() {}

Expand Down
4 changes: 2 additions & 2 deletions src/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::mem::replace;
use std::sync::{Arc, Mutex, MutexGuard};
use std::time::Duration;

use terminal::{
use crate::terminal::{
CursorMode, RawRead, SignalSet, Size,
Terminal, TerminalReader, TerminalWriter,
};
Expand Down Expand Up @@ -514,7 +514,7 @@ impl<'a> TerminalWriter<MemoryTerminal> for MemoryWriteGuard<'a> {
#[cfg(test)]
mod test {
use super::MemoryTerminal;
use terminal::Size;
use crate::terminal::Size;

fn assert_lines(mem: &MemoryTerminal, tests: &[&str]) {
let mut lines = mem.lines();
Expand Down
22 changes: 11 additions & 11 deletions src/prompter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@ use std::time::Instant;

use mortal::FindResult;

use chars::{is_ctrl, is_printable, DELETE, EOF};
use command::{Category, Command};
use complete::Completion;
use function::Function;
use reader::{BindingIter, InputState, ReadLock, ReadResult};
use table::{format_columns, Line, Table};
use terminal::{CursorMode, Signal, Size, Terminal};
use util::{
use crate::chars::{is_ctrl, is_printable, DELETE, EOF};
use crate::command::{Category, Command};
use crate::complete::Completion;
use crate::function::Function;
use crate::reader::{BindingIter, InputState, ReadLock, ReadResult};
use crate::table::{format_columns, Line, Table};
use crate::terminal::{CursorMode, Signal, Size, Terminal};
use crate::util::{
get_open_paren, find_matching_paren, first_word,
longest_common_prefix, repeat_char,
back_n_words, forward_n_words,
backward_char, forward_char, backward_word, forward_word,
word_start, word_end, RangeArgument,
};
use variables::VariableIter;
use writer::{
use crate::variables::VariableIter;
use crate::writer::{
BLINK_DURATION, display_str,
Digit, Display, HistoryIter, PromptType, Writer, WriteLock,
};
Expand Down Expand Up @@ -467,7 +467,7 @@ impl<'a, 'b: 'a, Term: 'b + Terminal> Prompter<'a, 'b, Term> {
}

fn execute_command(&mut self, cmd: Command, n: i32, ch: char) -> io::Result<()> {
use command::Command::*;
use crate::command::Command::*;

let mut category = cmd.category();

Expand Down
22 changes: 11 additions & 11 deletions src/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ use std::time::{Duration, Instant};

use mortal::SequenceMap;

use command::{Category, Command};
use complete::{Completer, Completion, DummyCompleter};
use function::Function;
use inputrc::{parse_file, Directive};
use interface::Interface;
use prompter::Prompter;
use sys::path::{env_init_file, system_init_file, user_init_file};
use terminal::{
use crate::command::{Category, Command};
use crate::complete::{Completer, Completion, DummyCompleter};
use crate::function::Function;
use crate::inputrc::{parse_file, Directive};
use crate::interface::Interface;
use crate::prompter::Prompter;
use crate::sys::path::{env_init_file, system_init_file, user_init_file};
use crate::terminal::{
RawRead, Signal, SignalSet, Size,
Terminal, TerminalReader,
};
use util::{first_char, match_name};
use variables::{Variable, Variables, VariableIter};
use crate::util::{first_char, match_name};
use crate::variables::{Variable, Variables, VariableIter};

/// Default set of string characters
pub const STRING_CHARS: &str = "\"'";
Expand Down Expand Up @@ -1062,7 +1062,7 @@ impl<'a> DoubleEndedIterator for BindingIter<'a> {
}

fn default_bindings() -> SequenceMap<Cow<'static, str>, Command> {
use command::Command::*;
use crate::command::Command::*;

SequenceMap::from(vec![
// Carriage return and line feed
Expand Down
2 changes: 1 addition & 1 deletion src/terminal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::io;
use std::time::Duration;

use mortal::{self, PrepareConfig, PrepareState, TerminalReadGuard, TerminalWriteGuard};
use sys;
use crate::sys;

pub use mortal::{CursorMode, Signal, SignalSet, Size};

Expand Down
2 changes: 1 addition & 1 deletion src/unix/terminal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::time::Duration;
use mortal::{Event, TerminalReadGuard};
use mortal::unix::TerminalExt;

use terminal::RawRead;
use crate::terminal::RawRead;

pub fn terminal_read(term: &mut TerminalReadGuard, buf: &mut Vec<u8>) -> io::Result<RawRead> {
let mut buffer = [0; 1024];
Expand Down
2 changes: 1 addition & 1 deletion src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::ops::{Range, RangeFrom, RangeFull, RangeTo};
use std::str::{from_utf8, from_utf8_unchecked};

pub fn filter_visible(s: &str) -> Cow<str> {
use reader::{START_INVISIBLE, END_INVISIBLE};
use crate::reader::{START_INVISIBLE, END_INVISIBLE};

if !s.contains(START_INVISIBLE) {
return Cow::Borrowed(s);
Expand Down
4 changes: 2 additions & 2 deletions src/windows/console.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ use winapi::um::wincon::{
};
use winapi::um::winuser;

use chars::DELETE;
use terminal::RawRead;
use crate::chars::DELETE;
use crate::terminal::RawRead;

// Generate some sequences for special characters.
// The basic ones align with common Unix terminals, so that they match up with
Expand Down
8 changes: 4 additions & 4 deletions src/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ use std::ops::{Deref, DerefMut, Range};
use std::sync::MutexGuard;
use std::time::{Duration, Instant};

use chars::{is_ctrl, unctrl, ESCAPE, RUBOUT};
use reader::{START_INVISIBLE, END_INVISIBLE};
use terminal::{CursorMode, Size, Terminal, TerminalWriter};
use util::{
use crate::chars::{is_ctrl, unctrl, ESCAPE, RUBOUT};
use crate::reader::{START_INVISIBLE, END_INVISIBLE};
use crate::terminal::{CursorMode, Size, Terminal, TerminalWriter};
use crate::util::{
backward_char, forward_char, backward_search_char, forward_search_char,
filter_visible, is_combining_mark, is_wide, RangeArgument,
};
Expand Down

0 comments on commit 904e4b0

Please sign in to comment.