Updated to Rust 2018.
No functional changes.
This commit is contained in:
parent
9cadb9bd8c
commit
dab1c9ed1b
|
@ -8,6 +8,7 @@ name = "Led"
|
||||||
version = "0.0.2"
|
version = "0.0.2"
|
||||||
authors = ["Nathan Vegdahl <cessen@cessen.com>"]
|
authors = ["Nathan Vegdahl <cessen@cessen.com>"]
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "led"
|
name = "led"
|
||||||
|
|
|
@ -1,19 +1,22 @@
|
||||||
#![allow(dead_code)]
|
#![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;
|
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
|
// Buffer
|
||||||
// =============================================================
|
// =============================================================
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
|
|
||||||
use std::cmp::Ordering;
|
use std::{
|
||||||
use std::ops::{Index, IndexMut};
|
cmp::Ordering,
|
||||||
use std::slice::{Iter, IterMut};
|
ops::{Index, IndexMut},
|
||||||
|
slice::{Iter, IterMut},
|
||||||
|
};
|
||||||
|
|
||||||
use buffer::Buffer;
|
use crate::{buffer::Buffer, formatter::LineFormatter};
|
||||||
use formatter::LineFormatter;
|
|
||||||
|
|
||||||
/// A text cursor. Also represents selections when range.0 != range.1.
|
/// A text cursor. Also represents selections when range.0 != range.1.
|
||||||
///
|
///
|
||||||
|
|
|
@ -1,17 +1,22 @@
|
||||||
#![allow(dead_code)]
|
#![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 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 struct Editor<T: LineFormatter> {
|
||||||
pub buffer: Buffer,
|
pub buffer: Buffer,
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
|
|
||||||
use buffer::Buffer;
|
|
||||||
use ropey::RopeSlice;
|
|
||||||
use std::cmp::min;
|
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.
|
// Maximum graphemes in a line before a soft line break is forced.
|
||||||
// This is necessary to prevent pathological formatting cases which
|
// This is necessary to prevent pathological formatting cases which
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
//! Misc helpful utility functions for TextBuffer related stuff.
|
//! Misc helpful utility functions for TextBuffer related stuff.
|
||||||
|
|
||||||
use ropey::RopeSlice;
|
|
||||||
use std::iter::repeat;
|
use std::iter::repeat;
|
||||||
|
|
||||||
|
use ropey::RopeSlice;
|
||||||
use unicode_segmentation::UnicodeSegmentation;
|
use unicode_segmentation::UnicodeSegmentation;
|
||||||
|
|
||||||
pub fn is_line_ending(text: &str) -> bool {
|
pub fn is_line_ending(text: &str) -> bool {
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
use std::cmp::max;
|
use std::cmp::max;
|
||||||
|
|
||||||
use formatter::{LineFormatter, RoundingBehavior};
|
|
||||||
use ropey::RopeSlice;
|
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 {
|
pub enum WrapType {
|
||||||
NoWrap,
|
NoWrap,
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
|
|
||||||
|
pub mod formatter;
|
||||||
|
mod screen;
|
||||||
|
pub mod smallstring;
|
||||||
|
|
||||||
use std;
|
use std;
|
||||||
use std::cmp::min;
|
use std::cmp::min;
|
||||||
|
|
||||||
|
@ -7,17 +11,17 @@ use termion;
|
||||||
use termion::event::{Event, Key};
|
use termion::event::{Event, Key};
|
||||||
use termion::input::TermRead;
|
use termion::input::TermRead;
|
||||||
|
|
||||||
use self::formatter::ConsoleLineFormatter;
|
use crate::{
|
||||||
use editor::Editor;
|
editor::Editor,
|
||||||
use formatter::{block_index_and_offset, LineFormatter, LINE_BLOCK_LENGTH};
|
formatter::{block_index_and_offset, LineFormatter, LINE_BLOCK_LENGTH},
|
||||||
use string_utils::{line_ending_to_str, rope_slice_is_line_ending, LineEnding};
|
string_utils::{line_ending_to_str, rope_slice_is_line_ending, LineEnding},
|
||||||
use utils::{digit_count, RopeGraphemes};
|
utils::{digit_count, RopeGraphemes},
|
||||||
|
};
|
||||||
|
|
||||||
pub mod formatter;
|
use self::{
|
||||||
mod screen;
|
formatter::ConsoleLineFormatter,
|
||||||
pub mod smallstring;
|
screen::{Color, Screen, Style},
|
||||||
|
};
|
||||||
use self::screen::{Color, Screen, Style};
|
|
||||||
|
|
||||||
/// Generalized ui loop.
|
/// Generalized ui loop.
|
||||||
macro_rules! ui_loop {
|
macro_rules! ui_loop {
|
||||||
|
|
|
@ -3,7 +3,6 @@ use std::cell::RefCell;
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::io::{BufWriter, Write};
|
use std::io::{BufWriter, Write};
|
||||||
|
|
||||||
use super::smallstring::SmallString;
|
|
||||||
use ropey::RopeSlice;
|
use ropey::RopeSlice;
|
||||||
use termion;
|
use termion;
|
||||||
use termion::color;
|
use termion::color;
|
||||||
|
@ -11,7 +10,10 @@ use termion::raw::{IntoRawMode, RawTerminal};
|
||||||
use termion::screen::AlternateScreen;
|
use termion::screen::AlternateScreen;
|
||||||
use unicode_segmentation::UnicodeSegmentation;
|
use unicode_segmentation::UnicodeSegmentation;
|
||||||
use unicode_width::UnicodeWidthStr;
|
use unicode_width::UnicodeWidthStr;
|
||||||
use utils::{grapheme_width, RopeGraphemes};
|
|
||||||
|
use crate::utils::{grapheme_width, RopeGraphemes};
|
||||||
|
|
||||||
|
use super::smallstring::SmallString;
|
||||||
|
|
||||||
pub(crate) struct Screen {
|
pub(crate) struct Screen {
|
||||||
out: RefCell<AlternateScreen<RawTerminal<BufWriter<io::Stdout>>>>,
|
out: RefCell<AlternateScreen<RawTerminal<BufWriter<io::Stdout>>>>,
|
||||||
|
|
|
@ -6,7 +6,6 @@ use std::ptr;
|
||||||
use std::str;
|
use std::str;
|
||||||
|
|
||||||
use ropey::RopeSlice;
|
use ropey::RopeSlice;
|
||||||
|
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
|
|
||||||
#[derive(Clone, Default)]
|
#[derive(Clone, Default)]
|
||||||
|
|
|
@ -16,7 +16,7 @@ pub fn digit_count(mut n: u32, b: u32) -> u32 {
|
||||||
//=============================================================
|
//=============================================================
|
||||||
|
|
||||||
pub fn grapheme_width(slice: &RopeSlice) -> usize {
|
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() {
|
if let Some(text) = slice.as_str() {
|
||||||
return UnicodeWidthStr::width(text);
|
return UnicodeWidthStr::width(text);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -3,6 +3,7 @@ name = "backend"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["Nathan Vegdahl <cessen@cessen.com>"]
|
authors = ["Nathan Vegdahl <cessen@cessen.com>"]
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
name = "backend"
|
name = "backend"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user