Silencing some rustc warnings.
This commit is contained in:
parent
26965417f3
commit
e9462e4400
|
@ -217,10 +217,9 @@ impl Line {
|
|||
|
||||
|
||||
pub fn grapheme_at_index<'a>(&'a self, index: usize) -> &'a str {
|
||||
let mut iter = self.grapheme_iter();
|
||||
let mut i = 0;
|
||||
|
||||
for g in iter {
|
||||
for g in self.grapheme_iter() {
|
||||
if i == index {
|
||||
return g;
|
||||
}
|
||||
|
|
|
@ -399,11 +399,10 @@ impl Buffer {
|
|||
|
||||
let mut s = String::with_capacity(pos_b - pos_a);
|
||||
|
||||
let mut iter = self.grapheme_iter_at_index(pos_a);
|
||||
let mut i = 0;
|
||||
let i_end = pos_b - pos_a;
|
||||
|
||||
for g in iter {
|
||||
for g in self.grapheme_iter_at_index(pos_a) {
|
||||
if i == i_end {
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -5,12 +5,12 @@ use std::old_path::Path;
|
|||
use buffer::line::{line_ending_to_str};
|
||||
use buffer::Buffer as TextBuffer;
|
||||
|
||||
|
||||
pub fn save_buffer_to_file(tb: &TextBuffer, path: &Path) -> IoResult<()> {
|
||||
// TODO: make save atomic
|
||||
let mut iter = tb.line_iter();
|
||||
let mut f = BufferedWriter::new(try!(File::create(path)));
|
||||
|
||||
for l in iter {
|
||||
for l in tb.line_iter() {
|
||||
let _ = f.write_str(l.as_str());
|
||||
let _ = f.write_str(line_ending_to_str(l.ending));
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
use buffer::line::Line;
|
||||
use buffer::Buffer;
|
||||
use std::cmp::max;
|
||||
|
||||
#[derive(Copy, PartialEq)]
|
||||
pub enum RoundingBehavior {
|
||||
|
@ -40,7 +39,7 @@ pub trait LineFormatter {
|
|||
fn index_offset_vertical_v2d(&self, buf: &Buffer, index: usize, offset: isize, rounding: (RoundingBehavior, RoundingBehavior)) -> usize {
|
||||
// TODO: handle rounding modes
|
||||
// TODO: do this with bidirectional line iterator
|
||||
let (mut line_i, mut col_i) = buf.index_to_line_col(index);
|
||||
let (mut line_i, col_i) = buf.index_to_line_col(index);
|
||||
let (mut y, x) = self.index_to_v2d(buf.get_line(line_i), col_i);
|
||||
let mut new_y = y as isize + offset;
|
||||
|
||||
|
@ -48,7 +47,7 @@ pub trait LineFormatter {
|
|||
let mut line;
|
||||
loop {
|
||||
line = buf.get_line(line_i);
|
||||
let (mut h, _) = self.dimensions(line);
|
||||
let (h, _) = self.dimensions(line);
|
||||
|
||||
if new_y >= 0 && new_y < h as isize {
|
||||
y = new_y as usize;
|
||||
|
@ -90,7 +89,7 @@ pub trait LineFormatter {
|
|||
let (line_i, col_i) = buf.index_to_line_col(index);
|
||||
let line = buf.get_line(line_i);
|
||||
|
||||
let (v, h) = self.index_to_v2d(line, col_i);
|
||||
let (v, _) = self.index_to_v2d(line, col_i);
|
||||
let new_col_i = self.v2d_to_index(line, (v, horizontal), (RoundingBehavior::Floor, rounding));
|
||||
|
||||
return (index + new_col_i) - col_i;
|
||||
|
|
|
@ -70,13 +70,11 @@ impl LineFormatter for ConsoleLineFormatter {
|
|||
}
|
||||
|
||||
|
||||
fn v2d_to_index(&self, line: &Line, v2d: (usize, usize), rounding: (RoundingBehavior, RoundingBehavior)) -> usize {
|
||||
fn v2d_to_index(&self, line: &Line, v2d: (usize, usize), _: (RoundingBehavior, RoundingBehavior)) -> usize {
|
||||
// TODO: handle rounding modes
|
||||
let mut i = 0;
|
||||
let mut pos = (0, 0);
|
||||
|
||||
for (_, _pos, _) in self.iter(line) {
|
||||
pos = _pos;
|
||||
for (_, pos, _) in self.iter(line) {
|
||||
if pos.0 > v2d.0 {
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -362,13 +362,11 @@ impl TermUI {
|
|||
let mut screen_line = c1.0 as isize - vis_line_offset as isize;
|
||||
let screen_col = c1.1 as isize;
|
||||
|
||||
let mut line_iter = editor.buffer.line_iter_at_index(starting_line);
|
||||
for line in line_iter {
|
||||
let mut g_iter = editor.formatter.iter(line);
|
||||
for line in editor.buffer.line_iter_at_index(starting_line) {
|
||||
|
||||
// Loop through the graphemes of the line and print them to
|
||||
// the screen.
|
||||
for (g, (pos_y, pos_x), width) in g_iter {
|
||||
for (g, (pos_y, pos_x), width) in editor.formatter.iter(line) {
|
||||
// Calculate the cell coordinates at which to draw the grapheme
|
||||
let px = pos_x as isize + screen_col - editor.view_pos.1 as isize;
|
||||
let py = pos_y as isize + screen_line;
|
||||
|
|
Loading…
Reference in New Issue
Block a user