(&self, ctx: &TokenHighlighter, _file: &str, src: &str, span: Span, _row: &FindData, color: bool)
| 174 | } |
| 175 | |
| 176 | fn render_text(&self, ctx: &TokenHighlighter, _file: &str, src: &str, span: Span, _row: &FindData, color: bool) { |
| 177 | let (line, col) = span.line_and_column(src); |
| 178 | let (start, end) = line_bounds(src, span.start().into()); |
| 179 | |
| 180 | if color { |
| 181 | print!("{}:{}:", green(line + 1), green(col + 1)); |
| 182 | let line_text = &src[start..end]; |
| 183 | let line_lexer = Lexer::new(&CssAtomSet::ATOMS, line_text); |
| 184 | let mut line_output = String::new(); |
| 185 | let mut cursor_stream = AnsiHighlightCursorStream::new(&mut line_output, ctx, DefaultAnsiTheme); |
| 186 | for cursor in line_lexer { |
| 187 | let global_offset = SourceOffset(cursor.offset().0 + start as u32); |
| 188 | let global_cursor = Cursor::new(global_offset, cursor.token()); |
| 189 | let sc = SourceCursor::from(global_cursor, cursor.str_slice(line_text)); |
| 190 | cursor_stream.append(sc); |
| 191 | } |
| 192 | println!("{}", line_output); |
| 193 | } else { |
| 194 | println!("{}:{}:{}", line + 1, col + 1, &src[start..end]); |
| 195 | } |
| 196 | } |
| 197 | } |
no test coverage detected