diff --git a/appveyor.yml b/appveyor.yml index fd62518..36154b2 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -3,7 +3,7 @@ environment: PROJECT_NAME: rustfmt matrix: - TARGET: x86_64-pc-windows-gnu - RUST_VERSION: 1.18.0 + RUST_VERSION: 1.20.0 install: # - ps: Start-FileDownload "https://static.rust-lang.org/dist/channel-rust-stable" diff --git a/src/render/itemize.rs b/src/render/itemize.rs index 9a5d703..65203a2 100644 --- a/src/render/itemize.rs +++ b/src/render/itemize.rs @@ -1,11 +1,11 @@ use std::str::CharIndices; -pub struct ItemizeIterator <'a> { +pub struct ItemizeIterator<'a> { char_iter: CharIndices<'a>, line: &'a str, } -impl <'a> ItemizeIterator <'a> { +impl<'a> ItemizeIterator<'a> { pub fn new(line: &'a str) -> Self { ItemizeIterator { char_iter: line.char_indices(), @@ -14,7 +14,7 @@ impl <'a> ItemizeIterator <'a> { } } -impl <'a> Iterator for ItemizeIterator<'a> { +impl<'a> Iterator for ItemizeIterator<'a> { type Item = (usize, usize); fn next(&mut self) -> Option { @@ -26,7 +26,7 @@ impl <'a> Iterator for ItemizeIterator<'a> { if start_index.is_none() && !is_whitespace { start_index = Some(index); - } + } if start_index.is_some() && is_whitespace { break index; } diff --git a/src/render/mod.rs b/src/render/mod.rs index 6a25868..21e6416 100644 --- a/src/render/mod.rs +++ b/src/render/mod.rs @@ -81,12 +81,18 @@ pub fn render( // TODO: properly draw undercurl let sp = color_model.actual_cell_sp(cell); ctx.set_source_rgba(sp.0, sp.1, sp.2, 0.7); - ctx.set_dash(&[4.0, 2.0], 0.0); - ctx.set_line_width(underline_thickness); - ctx.move_to(line_x, line_y + underline_position); - ctx.line_to(line_x + char_width, line_y + underline_position); - ctx.stroke(); - ctx.set_dash(&[], 0.0); + ctx.show_error_underline( + line_x, + line_y + underline_position, + char_width, + underline_thickness * 5.0, + ); + //ctx.set_dash(&[4.0, 2.0], 0.0); + //ctx.set_line_width(underline_thickness); + //ctx.move_to(line_x, line_y + underline_position); + //ctx.line_to(line_x + char_width, line_y + underline_position); + //ctx.stroke(); + //ctx.set_dash(&[], 0.0); } else if cell.attrs.underline { ctx.set_source_rgb(fg.0, fg.1, fg.2); ctx.set_line_width(underline_thickness); diff --git a/src/sys/pango/item.rs b/src/sys/pango/item.rs index f7472b8..797cd74 100644 --- a/src/sys/pango/item.rs +++ b/src/sys/pango/item.rs @@ -41,8 +41,4 @@ impl Item { pub fn offset(&self) -> (usize, usize, usize) { (self.0.offset as usize, self.0.length as usize, self.0.num_chars as usize) } - - pub fn length(&self) -> i32 { - self.0.length - } } diff --git a/src/ui_model/line.rs b/src/ui_model/line.rs index 608d829..3f2b449 100644 --- a/src/ui_model/line.rs +++ b/src/ui_model/line.rs @@ -69,11 +69,10 @@ impl Line { fn set_cell_to_item(&mut self, new_item: &PangoItemPosition) -> bool { let start_item_idx = self.cell_to_item(new_item.start_cell); - let start_item_len = if start_item_idx >= 0 { + let start_item_cells_count = if start_item_idx >= 0 { self.item_line[start_item_idx as usize] .as_ref() - .map(|item| item.item.length()) - .unwrap_or(-1) + .map_or(-1, |item| item.cells_count as i32) } else { -1 }; @@ -84,7 +83,7 @@ impl Line { // in case different item length was in previous iteration // mark all item as dirty if start_item_idx != new_item.start_cell as i32 || - new_item.item.length() != start_item_len || start_item_idx == -1 || + new_item.cells_count() != start_item_cells_count || start_item_idx == -1 || end_item_idx == -1 { self.initialize_cell_item(new_item.start_cell, new_item.end_cell, new_item.item); @@ -237,6 +236,11 @@ impl<'a> PangoItemPosition<'a> { end_cell, } } + + #[inline] + fn cells_count(&self) -> i32 { + (self.end_cell - self.start_cell) as i32 + 1 + } } pub struct StyledLine {