1mod cwd_aware;
2mod default;
3pub use cwd_aware::CwdAwareHinter;
4pub use default::DefaultHinter;
5
6use unicode_segmentation::UnicodeSegmentation;
7
8pub fn is_whitespace_str(s: &str) -> bool {
9 s.chars().all(char::is_whitespace)
10}
11
12pub fn get_first_token(string: &str) -> String {
13 let mut reached_content = false;
14 let result = string
15 .split_word_bounds()
16 .take_while(|word| match (is_whitespace_str(word), reached_content) {
17 (_, true) => false,
18 (true, false) => true,
19 (false, false) => {
20 reached_content = true;
21 true
22 }
23 })
24 .collect::<Vec<&str>>()
25 .join("")
26 .to_string();
27 result
28}
29
30use crate::History;
31pub trait Hinter: Send {
34 fn handle(
38 &mut self,
39 line: &str,
40 pos: usize,
41 history: &dyn History,
42 use_ansi_coloring: bool,
43 ) -> String;
44
45 fn complete_hint(&self) -> String;
47
48 fn next_hint_token(&self) -> String;
51}