lineread 0.7.1-beta

Interactive terminal input reader
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//! Syntax highlighting functionality for the terminal interface

use std::ops::Range;

/// Represents a style to be applied to a text range.
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Style {
    /// A style using raw ANSI color codes
    AnsiColor(String),
    /// The default terminal style
    Default,
}

/// A trait for providing style information for a line of text.
pub trait Highlighter {
    /// Takes the current line buffer and returns a list of styled ranges.
    fn highlight(&self, line: &str) -> Vec<(Range<usize>, Style)>;
}