Tweaked code to avoid warnings from latest rustc compiler.
This commit is contained in:
parent
c6cfebdb75
commit
8701ebbba7
|
@ -117,7 +117,7 @@ impl Line {
|
|||
let mut le_size: usize = 0;
|
||||
let text_size = tl.text.len();
|
||||
if tl.text.len() >= 3 {
|
||||
match unsafe{mem::transmute::<&[u8], &str>(tl.text.slice_from(text_size-3))} {
|
||||
match unsafe{mem::transmute::<&[u8], &str>(&tl.text[(text_size-3)..])} {
|
||||
// LS
|
||||
"\u{2028}" => {
|
||||
tl.ending = LineEnding::LS;
|
||||
|
@ -135,7 +135,7 @@ impl Line {
|
|||
}
|
||||
|
||||
if le_size == 0 && tl.text.len() >= 2 {
|
||||
match unsafe{mem::transmute::<&[u8], &str>(tl.text.slice_from(text_size-2))} {
|
||||
match unsafe{mem::transmute::<&[u8], &str>(&tl.text[(text_size-2)..])} {
|
||||
// CRLF
|
||||
"\u{000D}\u{000A}" => {
|
||||
tl.ending = LineEnding::CRLF;
|
||||
|
@ -147,7 +147,7 @@ impl Line {
|
|||
}
|
||||
|
||||
if le_size == 0 && tl.text.len() >= 1 {
|
||||
match unsafe{mem::transmute::<&[u8], &str>(tl.text.slice_from(text_size-1))} {
|
||||
match unsafe{mem::transmute::<&[u8], &str>(&tl.text[(text_size-1)..])} {
|
||||
// LF
|
||||
"\u{000A}" => {
|
||||
tl.ending = LineEnding::LF;
|
||||
|
@ -230,7 +230,7 @@ impl Line {
|
|||
/// Returns an immutable string slice into the text block's memory
|
||||
pub fn as_str<'a>(&'a self) -> &'a str {
|
||||
unsafe {
|
||||
mem::transmute(self.text.as_slice())
|
||||
mem::transmute(&self.text[])
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -336,7 +336,7 @@ impl Line {
|
|||
let byte_pos = grapheme_pos_to_byte_pos(self.as_str(), pos);
|
||||
|
||||
// Copy the elements after the split index to the second line
|
||||
other.text.push_all(self.text.slice_from(byte_pos));
|
||||
other.text.push_all(&self.text[byte_pos..]);
|
||||
|
||||
// Truncate the first line
|
||||
self.text.truncate(byte_pos);
|
||||
|
@ -362,7 +362,7 @@ impl Line {
|
|||
|
||||
/// Returns an iterator over the graphemes of the line
|
||||
pub fn grapheme_iter_at_index<'a>(&'a self, index: usize) -> LineGraphemeIter<'a> {
|
||||
let temp: &str = unsafe{mem::transmute(self.text.as_slice())};
|
||||
let temp: &str = unsafe{mem::transmute(&self.text[])};
|
||||
|
||||
let mut iter = LineGraphemeIter {
|
||||
graphemes: temp.graphemes(true),
|
||||
|
|
|
@ -168,7 +168,7 @@ impl<T: LineFormatter> Buffer<T> {
|
|||
// 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.as_slice(), pos_to);
|
||||
self._insert_text(&s[], pos_to);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -219,19 +219,19 @@ impl<T: LineFormatter> Buffer<T> {
|
|||
if let Some(op) = self.undo_stack.prev() {
|
||||
match op {
|
||||
InsertText(ref s, p) => {
|
||||
let size = grapheme_count(s.as_slice());
|
||||
let size = grapheme_count(&s[]);
|
||||
self._remove_text(p, p+size);
|
||||
return Some(p);
|
||||
},
|
||||
|
||||
RemoveTextBefore(ref s, p) => {
|
||||
let size = grapheme_count(s.as_slice());
|
||||
self._insert_text(s.as_slice(), p);
|
||||
let size = grapheme_count(&s[]);
|
||||
self._insert_text(&s[], p);
|
||||
return Some(p+size);
|
||||
},
|
||||
|
||||
RemoveTextAfter(ref s, p) => {
|
||||
self._insert_text(s.as_slice(), p);
|
||||
self._insert_text(&s[], p);
|
||||
return Some(p);
|
||||
},
|
||||
|
||||
|
@ -257,13 +257,13 @@ impl<T: LineFormatter> Buffer<T> {
|
|||
if let Some(op) = self.undo_stack.next() {
|
||||
match op {
|
||||
InsertText(ref s, p) => {
|
||||
let size = grapheme_count(s.as_slice());
|
||||
self._insert_text(s.as_slice(), 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.as_slice());
|
||||
let size = grapheme_count(&s[]);
|
||||
self._remove_text(p, p+size);
|
||||
return Some(p);
|
||||
},
|
||||
|
@ -1498,7 +1498,7 @@ mod tests {
|
|||
|
||||
let s = buf.string_from_range(1, 12);
|
||||
|
||||
assert!(s.as_slice() == "i\nthere\npeo");
|
||||
assert!(&s[] == "i\nthere\npeo");
|
||||
}
|
||||
|
||||
|
||||
|
@ -1509,7 +1509,7 @@ mod tests {
|
|||
|
||||
let s = buf.string_from_range(0, 29);
|
||||
|
||||
assert!(s.as_slice() == "Hi\nthere\npeople\nof\nthe\nworld!");
|
||||
assert!(&s[] == "Hi\nthere\npeople\nof\nthe\nworld!");
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -357,7 +357,7 @@ impl BufferNode {
|
|||
for grapheme in text.grapheme_indices(true) {
|
||||
if is_line_ending(grapheme.1) {
|
||||
if g1 < g2 {
|
||||
self.insert_text_recursive(f, text.slice(b1, b2), pos + g1);
|
||||
self.insert_text_recursive(f, &text[b1..b2], pos + g1);
|
||||
}
|
||||
|
||||
g1 = g2;
|
||||
|
@ -376,7 +376,7 @@ impl BufferNode {
|
|||
}
|
||||
|
||||
if g1 < g2 {
|
||||
self.insert_text_recursive(f, text.slice(b1, b2), pos + g1);
|
||||
self.insert_text_recursive(f, &text[b1..b2], pos + g1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -159,7 +159,7 @@ impl<T: LineFormatter> Editor<T> {
|
|||
if space_blocks > (tab_blocks * 2) {
|
||||
let mut width = 0;
|
||||
let mut width_count = 0;
|
||||
for i in range(0, 9) {
|
||||
for i in 0us..9 {
|
||||
if space_histogram[i] > width_count {
|
||||
width = i;
|
||||
width_count = space_histogram[i];
|
||||
|
|
10
src/main.rs
10
src/main.rs
|
@ -1,4 +1,8 @@
|
|||
#![allow(unstable)]
|
||||
#![feature(core)]
|
||||
#![feature(io)]
|
||||
#![feature(collections)]
|
||||
#![feature(path)]
|
||||
#![feature(std_misc)]
|
||||
|
||||
extern crate rustbox;
|
||||
extern crate docopt;
|
||||
|
@ -56,7 +60,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.as_slice()))
|
||||
// Editor::new_from_file(GUILineFormatter::new(4), &Path::new(&s[]))
|
||||
// }
|
||||
// else {
|
||||
// Editor::new(GUILineFormatter::new(4))
|
||||
|
@ -71,7 +75,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.as_slice()))
|
||||
Editor::new_from_file(ConsoleLineFormatter::new(4), &Path::new(&s[]))
|
||||
}
|
||||
else {
|
||||
Editor::new(ConsoleLineFormatter::new(4))
|
||||
|
|
|
@ -170,7 +170,7 @@ impl TermUI {
|
|||
// Character
|
||||
0 => {
|
||||
if let Option::Some(c) = char::from_u32(character) {
|
||||
self.editor.insert_text_at_cursor(c.to_string().as_slice());
|
||||
self.editor.insert_text_at_cursor(&c.to_string()[]);
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -214,11 +214,11 @@ impl TermUI {
|
|||
// Draw the editor to screen
|
||||
self.rb.clear();
|
||||
self.draw_editor(&self.editor, (0, 0), (self.height-1, self.width-1));
|
||||
for i in range(0, self.width) {
|
||||
for i in 0..self.width {
|
||||
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.as_slice());
|
||||
self.rb.print(prefix.len() + 1, 0, rustbox::RB_NORMAL, foreground, background, &line[]);
|
||||
self.rb.present();
|
||||
|
||||
|
||||
|
@ -300,7 +300,7 @@ impl TermUI {
|
|||
let background = Color::Cyan;
|
||||
|
||||
// Fill in top row with info line color
|
||||
for i in range(c1.1, c2.1 + 1) {
|
||||
for i in c1.1..(c2.1 + 1) {
|
||||
self.rb.print(i, c1.0, rustbox::RB_NORMAL, foreground, background, " ");
|
||||
}
|
||||
|
||||
|
@ -308,7 +308,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.as_slice());
|
||||
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
|
||||
|
@ -320,7 +320,7 @@ impl TermUI {
|
|||
100
|
||||
};
|
||||
let pstring = format!("{}%", percentage);
|
||||
self.rb.print(c2.1 - pstring.len(), c1.0, rustbox::RB_NORMAL, foreground, background, pstring.as_slice());
|
||||
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.buffer.line_ending_type {
|
||||
|
@ -336,7 +336,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.as_slice());
|
||||
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);
|
||||
|
@ -387,7 +387,7 @@ impl TermUI {
|
|||
}
|
||||
}
|
||||
else if g == "\t" {
|
||||
for i in range(0, width) {
|
||||
for i in 0..width {
|
||||
let tpx = px as usize + i;
|
||||
if tpx <= c2.1 {
|
||||
self.rb.print(tpx as usize, py as usize, rustbox::RB_NORMAL, Color::White, Color::Black, " ");
|
||||
|
|
Loading…
Reference in New Issue
Block a user