Split rope implementation off into external lib "Ropey".
Ropey can be found at https://github.com/cessen/ropey
This commit is contained in:
parent
82e6fca1dd
commit
ada003b346
|
@ -8,6 +8,9 @@ authors = ["Nathan Vegdahl <cessen@cessen.com>"]
|
||||||
name = "led"
|
name = "led"
|
||||||
path = "src/main.rs"
|
path = "src/main.rs"
|
||||||
|
|
||||||
|
[dependencies.ropey]
|
||||||
|
git = "https://github.com/cessen/ropey.git"
|
||||||
|
|
||||||
[dependencies.sdl2]
|
[dependencies.sdl2]
|
||||||
git = "https://github.com/AngryLawyer/rust-sdl2.git"
|
git = "https://github.com/AngryLawyer/rust-sdl2.git"
|
||||||
|
|
||||||
|
|
|
@ -5,12 +5,11 @@ use std::old_path::Path;
|
||||||
use std::old_io::fs::File;
|
use std::old_io::fs::File;
|
||||||
use std::old_io::{IoResult, BufferedReader, BufferedWriter};
|
use std::old_io::{IoResult, BufferedReader, BufferedWriter};
|
||||||
|
|
||||||
pub use self::rope::{Rope, RopeSlice, RopeGraphemeIter, RopeLineIter};
|
use ropey::{Rope, RopeSlice, RopeGraphemeIter, RopeLineIter};
|
||||||
use self::undo_stack::{UndoStack};
|
use self::undo_stack::{UndoStack};
|
||||||
use self::undo_stack::Operation::*;
|
use self::undo_stack::Operation::*;
|
||||||
use string_utils::grapheme_count;
|
use string_utils::grapheme_count;
|
||||||
|
|
||||||
mod rope;
|
|
||||||
mod undo_stack;
|
mod undo_stack;
|
||||||
|
|
||||||
|
|
||||||
|
@ -39,7 +38,7 @@ impl Buffer {
|
||||||
|
|
||||||
pub fn new_from_str(s: &str) -> Buffer {
|
pub fn new_from_str(s: &str) -> Buffer {
|
||||||
Buffer {
|
Buffer {
|
||||||
text: Rope::new_from_str(s),
|
text: Rope::from_str(s),
|
||||||
file_path: None,
|
file_path: None,
|
||||||
undo_stack: UndoStack::new(),
|
undo_stack: UndoStack::new(),
|
||||||
}
|
}
|
||||||
|
@ -51,7 +50,7 @@ impl Buffer {
|
||||||
let string = f.read_to_string().unwrap();
|
let string = f.read_to_string().unwrap();
|
||||||
|
|
||||||
let buf = Buffer {
|
let buf = Buffer {
|
||||||
text: Rope::new_from_str(string.as_slice()),
|
text: Rope::from_str(string.as_slice()),
|
||||||
file_path: Some(path.clone()),
|
file_path: Some(path.clone()),
|
||||||
undo_stack: UndoStack::new(),
|
undo_stack: UndoStack::new(),
|
||||||
};
|
};
|
||||||
|
|
2590
src/buffer/rope.rs
2590
src/buffer/rope.rs
File diff suppressed because it is too large
Load Diff
|
@ -5,7 +5,7 @@ use formatter::LineFormatter;
|
||||||
use formatter::RoundingBehavior::*;
|
use formatter::RoundingBehavior::*;
|
||||||
use std::old_path::Path;
|
use std::old_path::Path;
|
||||||
use std::cmp::{min, max};
|
use std::cmp::{min, max};
|
||||||
use string_utils::{grapheme_count, LineEnding};
|
use string_utils::{grapheme_count, str_to_line_ending, LineEnding};
|
||||||
use utils::digit_count;
|
use utils::digit_count;
|
||||||
use self::cursor::CursorSet;
|
use self::cursor::CursorSet;
|
||||||
|
|
||||||
|
@ -102,7 +102,17 @@ impl<T: LineFormatter> Editor<T> {
|
||||||
// Collect statistics
|
// Collect statistics
|
||||||
let mut line_i: usize = 0;
|
let mut line_i: usize = 0;
|
||||||
for line in self.buffer.line_iter() {
|
for line in self.buffer.line_iter() {
|
||||||
match line.ending() {
|
// Get the line ending
|
||||||
|
let ending = if line.grapheme_count() > 0 {
|
||||||
|
let g = line.grapheme_at_index(line.grapheme_count() - 1);
|
||||||
|
str_to_line_ending(g)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
LineEnding::None
|
||||||
|
};
|
||||||
|
|
||||||
|
// Record which line ending it is
|
||||||
|
match ending {
|
||||||
LineEnding::None => {
|
LineEnding::None => {
|
||||||
},
|
},
|
||||||
LineEnding::CRLF => {
|
LineEnding::CRLF => {
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
#![feature(old_io)]
|
#![feature(old_io)]
|
||||||
#![feature(collections)]
|
#![feature(collections)]
|
||||||
#![feature(old_path)]
|
#![feature(old_path)]
|
||||||
#![feature(unicode)]
|
|
||||||
#![feature(test)]
|
#![feature(test)]
|
||||||
#![feature(std_misc)]
|
#![feature(std_misc)]
|
||||||
|
|
||||||
|
@ -11,6 +10,7 @@ extern crate rustbox;
|
||||||
extern crate docopt;
|
extern crate docopt;
|
||||||
extern crate "rustc-serialize" as rustc_serialize;
|
extern crate "rustc-serialize" as rustc_serialize;
|
||||||
extern crate encoding;
|
extern crate encoding;
|
||||||
|
extern crate ropey;
|
||||||
//extern crate freetype;
|
//extern crate freetype;
|
||||||
//extern crate sdl2;
|
//extern crate sdl2;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user