1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
//! Defines styling metadata for keyword-based syntax highlighting in the REPL.
//!
//! The [`KeywordStyle`] struct provides a lightweight way to configure which
//! keywords should be visually emphasised and what foreground color they
//! should use when rendered in the terminal. It acts as the configuration
//! layer for components such as [`KeywordHighlighter`](crate::repl::highlighter::KeywordHighlighter).
//!
//! # Overview
//! A `KeywordStyle` contains:
//! - A list of `keywords` that will be highlighted when matched.
//! - A `foreground` color defining the ANSI terminal color used for those keywords.
//!
//! This type is designed to be cloned and reused across multiple REPL sessions
//! or components that require consistent visual behavior.
//!
//! # Example
//! ```no_run
//! use nu_ansi_term::Color;
//! use rusty_repl::KeywordStyle;
//!
//! // Define a keyword style highlighting "help" and "exit" in cyan
//! let style = KeywordStyle::new(vec!["help", "exit"], Color::Cyan);
//! ```
//!
//! This instance can then be passed into a [`KeywordHighlighter`](crate::repl::highlighter::KeywordHighlighter) or directly
//! into a REPL constructor that supports keyword highlighting.
//!
//! # Notes
//! - Keywords are matched exactly (case-sensitive).
//! - The `foreground` color uses `nu_ansi_term`’s color API for portability
//! across ANSI-compatible terminals.
use Color;
use Cow;
/// Represents a set of keywords and the style used to highlight them.
///
/// A [`KeywordStyle`] is typically used to configure components that perform
/// syntax highlighting or semantic colorisation within a REPL or command-line
/// environment.
///
/// # Fields
/// - `keywords`: A list of keywords to be highlighted.
/// - `foreground`: The foreground color used for those keywords.
///
/// # Cloning
/// `KeywordStyle` implements [`Clone`], allowing it to be easily shared
/// or reused across multiple REPL instances or components.