Updated code for latest rustc.
This commit is contained in:
parent
d3cd1c4b05
commit
82e6fca1dd
|
@ -194,7 +194,7 @@ impl Buffer {
|
|||
// manipulates the node tree.
|
||||
let s = self.string_from_range(pos_a, pos_b);
|
||||
self._remove_text(pos_a, pos_b);
|
||||
self._insert_text(&s[], pos_to);
|
||||
self._insert_text(&s[..], pos_to);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -257,19 +257,19 @@ impl Buffer {
|
|||
if let Some(op) = self.undo_stack.prev() {
|
||||
match op {
|
||||
InsertText(ref s, p) => {
|
||||
let size = grapheme_count(&s[]);
|
||||
let size = grapheme_count(&s[..]);
|
||||
self._remove_text(p, p+size);
|
||||
return Some(p);
|
||||
},
|
||||
|
||||
RemoveTextBefore(ref s, p) => {
|
||||
let size = grapheme_count(&s[]);
|
||||
self._insert_text(&s[], p);
|
||||
let size = grapheme_count(&s[..]);
|
||||
self._insert_text(&s[..], p);
|
||||
return Some(p+size);
|
||||
},
|
||||
|
||||
RemoveTextAfter(ref s, p) => {
|
||||
self._insert_text(&s[], p);
|
||||
self._insert_text(&s[..], p);
|
||||
return Some(p);
|
||||
},
|
||||
|
||||
|
@ -295,13 +295,13 @@ impl Buffer {
|
|||
if let Some(op) = self.undo_stack.next() {
|
||||
match op {
|
||||
InsertText(ref s, p) => {
|
||||
let size = grapheme_count(&s[]);
|
||||
self._insert_text(&s[], p);
|
||||
let size = grapheme_count(&s[..]);
|
||||
self._insert_text(&s[..], p);
|
||||
return Some(p+size);
|
||||
},
|
||||
|
||||
RemoveTextBefore(ref s, p) | RemoveTextAfter(ref s, p) => {
|
||||
let size = grapheme_count(&s[]);
|
||||
let size = grapheme_count(&s[..]);
|
||||
self._remove_text(p, p+size);
|
||||
return Some(p);
|
||||
},
|
||||
|
@ -1505,7 +1505,7 @@ mod tests {
|
|||
|
||||
let s = buf.string_from_range(1, 12);
|
||||
|
||||
assert!(&s[] == "i\nthere\npeo");
|
||||
assert!(&s[..] == "i\nthere\npeo");
|
||||
}
|
||||
|
||||
|
||||
|
@ -1516,7 +1516,7 @@ mod tests {
|
|||
|
||||
let s = buf.string_from_range(0, 29);
|
||||
|
||||
assert!(&s[] == "Hi\nthere\npeople\nof\nthe\nworld!");
|
||||
assert!(&s[..] == "Hi\nthere\npeople\nof\nthe\nworld!");
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use std::collections::DList;
|
||||
use std::collections::LinkedList;
|
||||
|
||||
|
||||
/// A text editing operation
|
||||
|
@ -14,15 +14,15 @@ pub enum Operation {
|
|||
|
||||
/// An undo/redo stack of text editing operations
|
||||
pub struct UndoStack {
|
||||
stack_a: DList<Operation>,
|
||||
stack_b: DList<Operation>,
|
||||
stack_a: LinkedList<Operation>,
|
||||
stack_b: LinkedList<Operation>,
|
||||
}
|
||||
|
||||
impl UndoStack {
|
||||
pub fn new() -> UndoStack {
|
||||
UndoStack {
|
||||
stack_a: DList::new(),
|
||||
stack_b: DList::new(),
|
||||
stack_a: LinkedList::new(),
|
||||
stack_b: LinkedList::new(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -141,7 +141,7 @@ impl<T: LineFormatter> Editor<T> {
|
|||
// Analyze stats and make a determination
|
||||
let mut lei = 0;
|
||||
let mut le_count = 0;
|
||||
for i in 0us..8 {
|
||||
for i in 0usize..8 {
|
||||
if line_ending_histogram[i] >= le_count {
|
||||
lei = i;
|
||||
le_count = line_ending_histogram[i];
|
||||
|
@ -170,7 +170,7 @@ impl<T: LineFormatter> Editor<T> {
|
|||
let mut space_blocks: usize = 0;
|
||||
let mut space_histogram: [usize; 9] = [0, 0, 0, 0, 0, 0, 0, 0, 0];
|
||||
|
||||
let mut last_indent = (false, 0us); // (was_tabs, indent_count)
|
||||
let mut last_indent = (false, 0usize); // (was_tabs, indent_count)
|
||||
|
||||
// Collect statistics
|
||||
let mut line_i: usize = 0;
|
||||
|
@ -244,7 +244,7 @@ impl<T: LineFormatter> Editor<T> {
|
|||
if space_blocks > (tab_blocks * 2) {
|
||||
let mut width = 0;
|
||||
let mut width_count = 0;
|
||||
for i in 0us..9 {
|
||||
for i in 0usize..9 {
|
||||
if space_histogram[i] > width_count {
|
||||
width = i;
|
||||
width_count = space_histogram[i];
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#![feature(core)]
|
||||
#![feature(io)]
|
||||
#![feature(old_io)]
|
||||
#![feature(collections)]
|
||||
#![feature(path)]
|
||||
#![feature(old_path)]
|
||||
#![feature(unicode)]
|
||||
#![feature(test)]
|
||||
#![feature(std_misc)]
|
||||
|
@ -65,7 +65,7 @@ fn main() {
|
|||
if args.flag_gui {
|
||||
// // Load file, if specified
|
||||
// let editor = if let Option::Some(s) = args.arg_file {
|
||||
// Editor::new_from_file(GUILineFormatter::new(4), &Path::new(&s[]))
|
||||
// Editor::new_from_file(GUILineFormatter::new(4), &Path::new(&s[..]))
|
||||
// }
|
||||
// else {
|
||||
// Editor::new(GUILineFormatter::new(4))
|
||||
|
@ -80,7 +80,7 @@ fn main() {
|
|||
else {
|
||||
// Load file, if specified
|
||||
let editor = if let Option::Some(s) = args.arg_file {
|
||||
Editor::new_from_file(ConsoleLineFormatter::new(4), &Path::new(&s[]))
|
||||
Editor::new_from_file(ConsoleLineFormatter::new(4), &Path::new(&s[..]))
|
||||
}
|
||||
else {
|
||||
Editor::new(ConsoleLineFormatter::new(4))
|
||||
|
|
|
@ -5,6 +5,8 @@ use rustbox::Color;
|
|||
use editor::Editor;
|
||||
use formatter::{LineFormatter, LINE_BLOCK_LENGTH, block_index_and_offset};
|
||||
use std::char;
|
||||
use std::old_io::stdio;
|
||||
use std::default::Default;
|
||||
use std::time::duration::Duration;
|
||||
use string_utils::{is_line_ending, line_ending_to_str, LineEnding};
|
||||
use utils::digit_count;
|
||||
|
@ -43,7 +45,10 @@ pub struct TermUI {
|
|||
|
||||
impl TermUI {
|
||||
pub fn new() -> TermUI {
|
||||
let rb = match rustbox::RustBox::init(&[Some(rustbox::InitOption::BufferStderr)]) {
|
||||
let rb = match rustbox::RustBox::init(rustbox::InitOptions {
|
||||
buffer_stderr: stdio::stderr_raw().isatty(),
|
||||
..Default::default()
|
||||
}) {
|
||||
Ok(rbox) => rbox,
|
||||
Err(_) => panic!("Could not create Rustbox instance."),
|
||||
};
|
||||
|
@ -61,7 +66,10 @@ impl TermUI {
|
|||
}
|
||||
|
||||
pub fn new_from_editor(ed: Editor<ConsoleLineFormatter>) -> TermUI {
|
||||
let rb = match rustbox::RustBox::init(&[Some(rustbox::InitOption::BufferStderr)]) {
|
||||
let rb = match rustbox::RustBox::init(rustbox::InitOptions {
|
||||
buffer_stderr: stdio::stderr_raw().isatty(),
|
||||
..Default::default()
|
||||
}) {
|
||||
Ok(rbox) => rbox,
|
||||
Err(_) => panic!("Could not create Rustbox instance."),
|
||||
};
|
||||
|
@ -174,7 +182,7 @@ impl TermUI {
|
|||
// Character
|
||||
0 => {
|
||||
if let Option::Some(c) = char::from_u32(character) {
|
||||
self.editor.insert_text_at_cursor(&c.to_string()[]);
|
||||
self.editor.insert_text_at_cursor(&c.to_string()[..]);
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -228,7 +236,7 @@ impl TermUI {
|
|||
self.rb.print(i, 0, rustbox::RB_NORMAL, foreground, background, " ");
|
||||
}
|
||||
self.rb.print(1, 0, rustbox::RB_NORMAL, foreground, background, prefix);
|
||||
self.rb.print(prefix.len() + 1, 0, rustbox::RB_NORMAL, foreground, background, &line[]);
|
||||
self.rb.print(prefix.len() + 1, 0, rustbox::RB_NORMAL, foreground, background, &line[..]);
|
||||
self.rb.present();
|
||||
|
||||
|
||||
|
@ -318,7 +326,7 @@ impl TermUI {
|
|||
let filename = editor.file_path.display();
|
||||
let dirty_char = if editor.dirty {"*"} else {""};
|
||||
let name = format!("{}{}", filename, dirty_char);
|
||||
self.rb.print(c1.1 + 1, c1.0, rustbox::RB_NORMAL, foreground, background, &name[]);
|
||||
self.rb.print(c1.1 + 1, c1.0, rustbox::RB_NORMAL, foreground, background, &name[..]);
|
||||
|
||||
// Percentage position in document
|
||||
// TODO: use view instead of cursor for calculation if there is more
|
||||
|
@ -330,7 +338,7 @@ impl TermUI {
|
|||
100
|
||||
};
|
||||
let pstring = format!("{}%", percentage);
|
||||
self.rb.print(c2.1 - pstring.len(), c1.0, rustbox::RB_NORMAL, foreground, background, &pstring[]);
|
||||
self.rb.print(c2.1 - pstring.len(), c1.0, rustbox::RB_NORMAL, foreground, background, &pstring[..]);
|
||||
|
||||
// Text encoding info and tab style
|
||||
let nl = match editor.line_ending_type {
|
||||
|
@ -346,7 +354,7 @@ impl TermUI {
|
|||
};
|
||||
let soft_tabs_str = if editor.soft_tabs {"spaces"} else {"tabs"};
|
||||
let info_line = format!("UTF8:{} {}:{}", nl, soft_tabs_str, editor.soft_tab_width as usize);
|
||||
self.rb.print(c2.1 - 30, c1.0, rustbox::RB_NORMAL, foreground, background, &info_line[]);
|
||||
self.rb.print(c2.1 - 30, c1.0, rustbox::RB_NORMAL, foreground, background, &info_line[..]);
|
||||
|
||||
// Draw main text editing area
|
||||
self.draw_editor_text(editor, (c1.0 + 1, c1.1), c2);
|
||||
|
|
Loading…
Reference in New Issue
Block a user