Updated code to compile with the most recent Rust nightly.
This commit is contained in:
parent
ff6c763821
commit
2785c3821b
|
@ -1,5 +1,6 @@
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
|
|
||||||
|
use std::iter::repeat;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use std::str::Graphemes;
|
use std::str::Graphemes;
|
||||||
use string_utils::{grapheme_count, grapheme_pos_to_byte_pos, is_line_ending};
|
use string_utils::{grapheme_count, grapheme_pos_to_byte_pos, is_line_ending};
|
||||||
|
@ -346,7 +347,7 @@ impl Line {
|
||||||
let byte_pos = grapheme_pos_to_byte_pos(self.as_str(), pos);
|
let byte_pos = grapheme_pos_to_byte_pos(self.as_str(), pos);
|
||||||
|
|
||||||
// Grow data size
|
// Grow data size
|
||||||
self.text.grow(text.len(), 0);
|
self.text.extend(repeat(0).take(text.len()));
|
||||||
|
|
||||||
// Move old bytes forward
|
// Move old bytes forward
|
||||||
let mut from = self.text.len() - text.len();
|
let mut from = self.text.len() - text.len();
|
||||||
|
@ -380,7 +381,7 @@ impl Line {
|
||||||
let mut i = self.text.len();
|
let mut i = self.text.len();
|
||||||
|
|
||||||
// Grow data size
|
// Grow data size
|
||||||
self.text.grow(text.len(), 0);
|
self.text.extend(repeat(0).take(text.len()));
|
||||||
|
|
||||||
// Copy new bytes in
|
// Copy new bytes in
|
||||||
for g in text.graphemes(true) {
|
for g in text.graphemes(true) {
|
||||||
|
@ -440,7 +441,7 @@ impl Line {
|
||||||
let byte_pos = grapheme_pos_to_byte_pos(self.as_str(), pos);
|
let byte_pos = grapheme_pos_to_byte_pos(self.as_str(), pos);
|
||||||
|
|
||||||
// Copy the elements after the split index to the second line
|
// Copy the elements after the split index to the second line
|
||||||
other.text.push_all(self.text.slice_from_or_fail(&byte_pos));
|
other.text.push_all(self.text.slice_from(byte_pos));
|
||||||
|
|
||||||
// Truncate the first line
|
// Truncate the first line
|
||||||
self.text.truncate(byte_pos);
|
self.text.truncate(byte_pos);
|
||||||
|
@ -495,7 +496,7 @@ impl Line {
|
||||||
|
|
||||||
/// Represents one of the valid Unicode line endings.
|
/// Represents one of the valid Unicode line endings.
|
||||||
/// Also acts as an index into `LINE_ENDINGS`.
|
/// Also acts as an index into `LINE_ENDINGS`.
|
||||||
#[deriving(PartialEq, Copy)]
|
#[derive(PartialEq, Copy)]
|
||||||
pub enum LineEnding {
|
pub enum LineEnding {
|
||||||
None = 0, // No line ending
|
None = 0, // No line ending
|
||||||
CRLF = 1, // CarriageReturn followed by LineFeed
|
CRLF = 1, // CarriageReturn followed by LineFeed
|
||||||
|
@ -567,7 +568,7 @@ pub fn line_ending_to_str(ending: LineEnding) -> &'static str {
|
||||||
|
|
||||||
/// An array of string literals corresponding to the possible
|
/// An array of string literals corresponding to the possible
|
||||||
/// unicode line endings.
|
/// unicode line endings.
|
||||||
pub const LINE_ENDINGS: [&'static str, ..9] = ["",
|
pub const LINE_ENDINGS: [&'static str; 9] = ["",
|
||||||
"\u{000D}\u{000A}",
|
"\u{000D}\u{000A}",
|
||||||
"\u{000A}",
|
"\u{000A}",
|
||||||
"\u{000B}",
|
"\u{000B}",
|
||||||
|
@ -596,7 +597,9 @@ impl<'a> LineGraphemeIter<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Iterator<&'a str> for LineGraphemeIter<'a> {
|
impl<'a> Iterator for LineGraphemeIter<'a> {
|
||||||
|
type Item = &'a str;
|
||||||
|
|
||||||
fn next(&mut self) -> Option<&'a str> {
|
fn next(&mut self) -> Option<&'a str> {
|
||||||
if self.done {
|
if self.done {
|
||||||
return None;
|
return None;
|
||||||
|
@ -664,7 +667,9 @@ impl<'a> LineGraphemeVisIter<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Iterator<(&'a str, uint, uint)> for LineGraphemeVisIter<'a> {
|
impl<'a> Iterator for LineGraphemeVisIter<'a> {
|
||||||
|
type Item = (&'a str, uint, uint);
|
||||||
|
|
||||||
fn next(&mut self) -> Option<(&'a str, uint, uint)> {
|
fn next(&mut self) -> Option<(&'a str, uint, uint)> {
|
||||||
if let Some(g) = self.graphemes.next() {
|
if let Some(g) = self.graphemes.next() {
|
||||||
let pos = self.vis_pos;
|
let pos = self.vis_pos;
|
||||||
|
|
|
@ -253,7 +253,9 @@ impl<'a> BufferGraphemeIter<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
impl<'a> Iterator<&'a str> for BufferGraphemeIter<'a> {
|
impl<'a> Iterator for BufferGraphemeIter<'a> {
|
||||||
|
type Item = &'a str;
|
||||||
|
|
||||||
fn next(&mut self) -> Option<&'a str> {
|
fn next(&mut self) -> Option<&'a str> {
|
||||||
self.gi.next()
|
self.gi.next()
|
||||||
}
|
}
|
||||||
|
@ -265,7 +267,9 @@ pub struct BufferLineIter<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
impl<'a> Iterator<&'a Line> for BufferLineIter<'a> {
|
impl<'a> Iterator for BufferLineIter<'a> {
|
||||||
|
type Item = &'a Line;
|
||||||
|
|
||||||
fn next(&mut self) -> Option<&'a Line> {
|
fn next(&mut self) -> Option<&'a Line> {
|
||||||
self.li.next()
|
self.li.next()
|
||||||
}
|
}
|
||||||
|
|
|
@ -856,7 +856,9 @@ impl<'a> BufferNodeGraphemeIter<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
impl<'a> Iterator<&'a str> for BufferNodeGraphemeIter<'a> {
|
impl<'a> Iterator for BufferNodeGraphemeIter<'a> {
|
||||||
|
type Item = &'a str;
|
||||||
|
|
||||||
fn next(&mut self) -> Option<&'a str> {
|
fn next(&mut self) -> Option<&'a str> {
|
||||||
loop {
|
loop {
|
||||||
if let Option::Some(g) = self.cur_line.next() {
|
if let Option::Some(g) = self.cur_line.next() {
|
||||||
|
@ -884,7 +886,9 @@ pub struct BufferNodeLineIter<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
impl<'a> Iterator<&'a Line> for BufferNodeLineIter<'a> {
|
impl<'a> Iterator for BufferNodeLineIter<'a> {
|
||||||
|
type Item = &'a Line;
|
||||||
|
|
||||||
fn next(&mut self) -> Option<&'a Line> {
|
fn next(&mut self) -> Option<&'a Line> {
|
||||||
loop {
|
loop {
|
||||||
if let Option::Some(node) = self.node_stack.pop() {
|
if let Option::Some(node) = self.node_stack.pop() {
|
||||||
|
|
|
@ -93,7 +93,7 @@ impl Editor {
|
||||||
pub fn auto_detect_indentation_style(&mut self) {
|
pub fn auto_detect_indentation_style(&mut self) {
|
||||||
let mut tab_blocks: uint = 0;
|
let mut tab_blocks: uint = 0;
|
||||||
let mut space_blocks: uint = 0;
|
let mut space_blocks: uint = 0;
|
||||||
let mut space_histogram: [uint, ..9] = [0, 0, 0, 0, 0, 0, 0, 0, 0];
|
let mut space_histogram: [uint; 9] = [0, 0, 0, 0, 0, 0, 0, 0, 0];
|
||||||
|
|
||||||
let mut last_indent = (false, 0u); // (was_tabs, indent_count)
|
let mut last_indent = (false, 0u); // (was_tabs, indent_count)
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
#![feature(old_orphan_check)] // Temporary, get rid of this once the new orphan check works well
|
||||||
|
#![feature(associated_types)]
|
||||||
|
|
||||||
extern crate rustbox;
|
extern crate rustbox;
|
||||||
extern crate docopt;
|
extern crate docopt;
|
||||||
extern crate "rustc-serialize" as rustc_serialize;
|
extern crate "rustc-serialize" as rustc_serialize;
|
||||||
|
@ -27,7 +30,7 @@ Options:
|
||||||
|
|
||||||
|
|
||||||
// Struct for storing command-line arguments
|
// Struct for storing command-line arguments
|
||||||
#[deriving(RustcDecodable, Show)]
|
#[derive(RustcDecodable, Show)]
|
||||||
struct Args {
|
struct Args {
|
||||||
arg_file: Option<String>,
|
arg_file: Option<String>,
|
||||||
flag_help: bool,
|
flag_help: bool,
|
||||||
|
@ -42,10 +45,10 @@ fn main() {
|
||||||
|
|
||||||
// Load file, if specified
|
// Load file, if specified
|
||||||
let editor = if let Option::Some(s) = args.arg_file {
|
let editor = if let Option::Some(s) = args.arg_file {
|
||||||
Editor::new_from_file(&Path::new(s.as_slice()))
|
Editor::new_from_file(&Path::new(s.as_slice()))
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Editor::new()
|
Editor::new()
|
||||||
};
|
};
|
||||||
|
|
||||||
// Initialize and start UI
|
// Initialize and start UI
|
||||||
|
|
Loading…
Reference in New Issue
Block a user