feat(ui): add configurable role label display and syntax highlighting support
- Introduce `RoleLabelDisplay` enum (inline, above, none) and integrate it into UI rendering and message formatting. - Replace `show_role_labels` boolean with `role_label_mode` across config, formatter, session, and TUI components. - Add `syntax_highlighting` boolean to UI settings with default `false` and support in message rendering. - Update configuration schema version to 1.3.0 and provide deserialization handling for legacy boolean values. - Extend theme definitions with code block styling fields (background, border, text, keyword, string, comment) and default values in `Theme`. - Adjust related modules (`formatting.rs`, `ui.rs`, `session.rs`, `chat_app.rs`) to use the new settings and theme fields.
This commit is contained in:
@@ -1,19 +1,20 @@
|
||||
use crate::types::Message;
|
||||
use crate::ui::RoleLabelDisplay;
|
||||
|
||||
/// Formats messages for display across different clients.
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct MessageFormatter {
|
||||
wrap_width: usize,
|
||||
show_role_labels: bool,
|
||||
role_label_mode: RoleLabelDisplay,
|
||||
preserve_empty_lines: bool,
|
||||
}
|
||||
|
||||
impl MessageFormatter {
|
||||
/// Create a new formatter
|
||||
pub fn new(wrap_width: usize, show_role_labels: bool) -> Self {
|
||||
pub fn new(wrap_width: usize, role_label_mode: RoleLabelDisplay) -> Self {
|
||||
Self {
|
||||
wrap_width: wrap_width.max(20),
|
||||
show_role_labels,
|
||||
role_label_mode,
|
||||
preserve_empty_lines: false,
|
||||
}
|
||||
}
|
||||
@@ -29,9 +30,19 @@ impl MessageFormatter {
|
||||
self.wrap_width = width.max(20);
|
||||
}
|
||||
|
||||
/// Whether role labels should be shown alongside messages
|
||||
/// The configured role label layout preference.
|
||||
pub fn role_label_mode(&self) -> RoleLabelDisplay {
|
||||
self.role_label_mode
|
||||
}
|
||||
|
||||
/// Whether any role label should be shown alongside messages.
|
||||
pub fn show_role_labels(&self) -> bool {
|
||||
self.show_role_labels
|
||||
!matches!(self.role_label_mode, RoleLabelDisplay::None)
|
||||
}
|
||||
|
||||
/// Update the role label layout preference.
|
||||
pub fn set_role_label_mode(&mut self, mode: RoleLabelDisplay) {
|
||||
self.role_label_mode = mode;
|
||||
}
|
||||
|
||||
pub fn format_message(&self, message: &Message) -> Vec<String> {
|
||||
|
||||
Reference in New Issue
Block a user