Updated to Rust 2018.

No functional changes.
This commit is contained in:
Nathan Vegdahl 2020-01-23 18:47:27 +09:00
parent 9cadb9bd8c
commit dab1c9ed1b
12 changed files with 69 additions and 48 deletions

View File

@ -8,6 +8,7 @@ name = "Led"
version = "0.0.2"
authors = ["Nathan Vegdahl <cessen@cessen.com>"]
license = "MIT"
edition = "2018"
[[bin]]
name = "led"

View File

@ -1,19 +1,22 @@
#![allow(dead_code)]
use std::fs::File;
use std::io;
use std::io::{BufReader, BufWriter, Write};
use std::path::{Path, PathBuf};
use self::undo_stack::Operation::*;
use self::undo_stack::UndoStack;
use ropey;
use ropey::{Rope, RopeSlice};
use string_utils::char_count;
use utils::{is_grapheme_boundary, next_grapheme_boundary, prev_grapheme_boundary, RopeGraphemes};
mod undo_stack;
use std::{
fs::File,
io::{self, BufReader, BufWriter, Write},
path::{Path, PathBuf},
};
use ropey::{self, Rope, RopeSlice};
use crate::{
string_utils::char_count,
utils::{is_grapheme_boundary, next_grapheme_boundary, prev_grapheme_boundary, RopeGraphemes},
};
use self::undo_stack::{Operation::*, UndoStack};
// =============================================================
// Buffer
// =============================================================

View File

@ -1,11 +1,12 @@
#![allow(dead_code)]
use std::cmp::Ordering;
use std::ops::{Index, IndexMut};
use std::slice::{Iter, IterMut};
use std::{
cmp::Ordering,
ops::{Index, IndexMut},
slice::{Iter, IterMut},
};
use buffer::Buffer;
use formatter::LineFormatter;
use crate::{buffer::Buffer, formatter::LineFormatter};
/// A text cursor. Also represents selections when range.0 != range.1.
///

View File

@ -1,17 +1,22 @@
#![allow(dead_code)]
use std::collections::HashMap;
mod cursor;
use std::{
cmp::{max, min},
collections::HashMap,
path::{Path, PathBuf},
};
use crate::{
buffer::Buffer,
formatter::LineFormatter,
formatter::RoundingBehavior::*,
string_utils::{char_count, rope_slice_to_line_ending, LineEnding},
utils::{digit_count, RopeGraphemes},
};
use self::cursor::CursorSet;
use buffer::Buffer;
use formatter::LineFormatter;
use formatter::RoundingBehavior::*;
use std::cmp::{max, min};
use std::path::{Path, PathBuf};
use string_utils::{char_count, rope_slice_to_line_ending, LineEnding};
use utils::{digit_count, RopeGraphemes};
mod cursor;
pub struct Editor<T: LineFormatter> {
pub buffer: Buffer,

View File

@ -1,9 +1,10 @@
#![allow(dead_code)]
use buffer::Buffer;
use ropey::RopeSlice;
use std::cmp::min;
use utils::RopeGraphemes;
use ropey::RopeSlice;
use crate::{buffer::Buffer, utils::RopeGraphemes};
// Maximum graphemes in a line before a soft line break is forced.
// This is necessary to prevent pathological formatting cases which

View File

@ -1,8 +1,9 @@
#![allow(dead_code)]
//! Misc helpful utility functions for TextBuffer related stuff.
use ropey::RopeSlice;
use std::iter::repeat;
use ropey::RopeSlice;
use unicode_segmentation::UnicodeSegmentation;
pub fn is_line_ending(text: &str) -> bool {

View File

@ -1,9 +1,12 @@
use std::cmp::max;
use formatter::{LineFormatter, RoundingBehavior};
use ropey::RopeSlice;
use string_utils::{rope_slice_is_line_ending, rope_slice_is_whitespace};
use utils::grapheme_width;
use crate::{
formatter::{LineFormatter, RoundingBehavior},
string_utils::{rope_slice_is_line_ending, rope_slice_is_whitespace},
utils::grapheme_width,
};
pub enum WrapType {
NoWrap,

View File

@ -1,5 +1,9 @@
#![allow(dead_code)]
pub mod formatter;
mod screen;
pub mod smallstring;
use std;
use std::cmp::min;
@ -7,17 +11,17 @@ use termion;
use termion::event::{Event, Key};
use termion::input::TermRead;
use self::formatter::ConsoleLineFormatter;
use editor::Editor;
use formatter::{block_index_and_offset, LineFormatter, LINE_BLOCK_LENGTH};
use string_utils::{line_ending_to_str, rope_slice_is_line_ending, LineEnding};
use utils::{digit_count, RopeGraphemes};
use crate::{
editor::Editor,
formatter::{block_index_and_offset, LineFormatter, LINE_BLOCK_LENGTH},
string_utils::{line_ending_to_str, rope_slice_is_line_ending, LineEnding},
utils::{digit_count, RopeGraphemes},
};
pub mod formatter;
mod screen;
pub mod smallstring;
use self::screen::{Color, Screen, Style};
use self::{
formatter::ConsoleLineFormatter,
screen::{Color, Screen, Style},
};
/// Generalized ui loop.
macro_rules! ui_loop {

View File

@ -3,7 +3,6 @@ use std::cell::RefCell;
use std::io;
use std::io::{BufWriter, Write};
use super::smallstring::SmallString;
use ropey::RopeSlice;
use termion;
use termion::color;
@ -11,7 +10,10 @@ use termion::raw::{IntoRawMode, RawTerminal};
use termion::screen::AlternateScreen;
use unicode_segmentation::UnicodeSegmentation;
use unicode_width::UnicodeWidthStr;
use utils::{grapheme_width, RopeGraphemes};
use crate::utils::{grapheme_width, RopeGraphemes};
use super::smallstring::SmallString;
pub(crate) struct Screen {
out: RefCell<AlternateScreen<RawTerminal<BufWriter<io::Stdout>>>>,

View File

@ -6,7 +6,6 @@ use std::ptr;
use std::str;
use ropey::RopeSlice;
use smallvec::SmallVec;
#[derive(Clone, Default)]

View File

@ -16,7 +16,7 @@ pub fn digit_count(mut n: u32, b: u32) -> u32 {
//=============================================================
pub fn grapheme_width(slice: &RopeSlice) -> usize {
use term_ui::smallstring::SmallString;
use crate::term_ui::smallstring::SmallString;
if let Some(text) = slice.as_str() {
return UnicodeWidthStr::width(text);
} else {

View File

@ -3,6 +3,7 @@ name = "backend"
version = "0.1.0"
authors = ["Nathan Vegdahl <cessen@cessen.com>"]
license = "MIT"
edition = "2018"
[lib]
name = "backend"