prefer ratatui Stylized for constructing lines/spans (#3068)
no functional change, just simplifying ratatui styling and adding guidance in AGENTS.md for future.
This commit is contained in:
@@ -9,10 +9,8 @@ use ratatui::layout::Rect;
|
||||
use ratatui::prelude::Widget;
|
||||
use ratatui::style::Color;
|
||||
use ratatui::style::Modifier;
|
||||
use ratatui::style::Style;
|
||||
use ratatui::style::Stylize;
|
||||
use ratatui::text::Line;
|
||||
use ratatui::text::Span;
|
||||
use ratatui::widgets::Paragraph;
|
||||
use ratatui::widgets::WidgetRef;
|
||||
use ratatui::widgets::Wrap;
|
||||
@@ -41,30 +39,25 @@ impl WidgetRef for &TrustDirectoryWidget {
|
||||
fn render_ref(&self, area: Rect, buf: &mut Buffer) {
|
||||
let mut lines: Vec<Line> = vec![
|
||||
Line::from(vec![
|
||||
Span::raw("> "),
|
||||
Span::styled(
|
||||
"You are running Codex in ",
|
||||
Style::default().add_modifier(Modifier::BOLD),
|
||||
),
|
||||
Span::raw(self.cwd.to_string_lossy().to_string()),
|
||||
"> ".into(),
|
||||
"You are running Codex in ".bold(),
|
||||
self.cwd.to_string_lossy().to_string().into(),
|
||||
]),
|
||||
Line::from(""),
|
||||
"".into(),
|
||||
];
|
||||
|
||||
if self.is_git_repo {
|
||||
lines.push(Line::from(
|
||||
" Since this folder is version controlled, you may wish to allow Codex",
|
||||
));
|
||||
lines.push(Line::from(
|
||||
" to work in this folder without asking for approval.",
|
||||
));
|
||||
lines.push(
|
||||
" Since this folder is version controlled, you may wish to allow Codex".into(),
|
||||
);
|
||||
lines.push(" to work in this folder without asking for approval.".into());
|
||||
} else {
|
||||
lines.push(Line::from(
|
||||
" Since this folder is not version controlled, we recommend requiring",
|
||||
));
|
||||
lines.push(Line::from(" approval of all edits and commands."));
|
||||
lines.push(
|
||||
" Since this folder is not version controlled, we recommend requiring".into(),
|
||||
);
|
||||
lines.push(" approval of all edits and commands.".into());
|
||||
}
|
||||
lines.push(Line::from(""));
|
||||
lines.push("".into());
|
||||
|
||||
let create_option =
|
||||
|idx: usize, option: TrustDirectorySelection, text: &str| -> Line<'static> {
|
||||
@@ -99,10 +92,10 @@ impl WidgetRef for &TrustDirectoryWidget {
|
||||
"Require approval of edits and commands",
|
||||
));
|
||||
}
|
||||
lines.push(Line::from(""));
|
||||
lines.push("".into());
|
||||
if let Some(error) = &self.error {
|
||||
lines.push(Line::from(format!(" {error}")).fg(Color::Red));
|
||||
lines.push(Line::from(""));
|
||||
lines.push("".into());
|
||||
}
|
||||
// AE: Following styles.md, this should probably be Cyan because it's a user input tip.
|
||||
// But leaving this for a future cleanup.
|
||||
|
||||
Reference in New Issue
Block a user