improvements, cursor got scuffed in form.rs
This commit is contained in:
@@ -9,7 +9,7 @@ use crate::client::colors::Theme;
|
|||||||
|
|
||||||
pub fn render_command_line(f: &mut Frame, area: Rect, input: &str, active: bool, theme: &Theme) {
|
pub fn render_command_line(f: &mut Frame, area: Rect, input: &str, active: bool, theme: &Theme) {
|
||||||
let prompt = if active {
|
let prompt = if active {
|
||||||
": (w = save, q = quit)"
|
":"
|
||||||
} else {
|
} else {
|
||||||
"Press ':' for commands (w = save, q = quit)"
|
"Press ':' for commands (w = save, q = quit)"
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ use ratatui::{
|
|||||||
widgets::{Paragraph, Block, Borders},
|
widgets::{Paragraph, Block, Borders},
|
||||||
layout::{Layout, Constraint, Direction, Rect, Margin},
|
layout::{Layout, Constraint, Direction, Rect, Margin},
|
||||||
style::Style,
|
style::Style,
|
||||||
text::{Line, Span},
|
text::{Line, Span, Text},
|
||||||
Frame,
|
Frame,
|
||||||
};
|
};
|
||||||
use crate::client::colors::Theme;
|
use crate::client::colors::Theme;
|
||||||
@@ -52,15 +52,33 @@ pub fn render_form(
|
|||||||
let label = Paragraph::new(Line::from(Span::styled(
|
let label = Paragraph::new(Line::from(Span::styled(
|
||||||
field.to_string(),
|
field.to_string(),
|
||||||
Style::default().fg(theme.fg),
|
Style::default().fg(theme.fg),
|
||||||
))); // Fixed: Added the missing closing parenthesis
|
)));
|
||||||
f.render_widget(label, row_chunks[0]);
|
f.render_widget(label, row_chunks[0]);
|
||||||
|
|
||||||
// Render the input on the right
|
// Render the input on the right
|
||||||
let input_paragraph = Paragraph::new(input.as_str()).style(if is_active {
|
let input_block = Block::default()
|
||||||
|
.borders(if is_active {
|
||||||
|
Borders::ALL // Add a border around the active field
|
||||||
|
} else {
|
||||||
|
Borders::NONE
|
||||||
|
})
|
||||||
|
.border_style(Style::default().fg(theme.accent)); // Use the accent color for the border
|
||||||
|
|
||||||
|
let input_paragraph = Paragraph::new(input.as_str())
|
||||||
|
.block(input_block)
|
||||||
|
.style(if is_active {
|
||||||
Style::default().fg(theme.highlight)
|
Style::default().fg(theme.highlight)
|
||||||
} else {
|
} else {
|
||||||
Style::default().fg(theme.fg)
|
Style::default().fg(theme.fg)
|
||||||
});
|
});
|
||||||
|
|
||||||
f.render_widget(input_paragraph, row_chunks[1]);
|
f.render_widget(input_paragraph, row_chunks[1]);
|
||||||
|
|
||||||
|
// Render the cursor in the active field
|
||||||
|
if is_active {
|
||||||
|
let cursor_x = row_chunks[1].x + input.len() as u16 + 1; // Calculate cursor position
|
||||||
|
let cursor_y = row_chunks[1].y;
|
||||||
|
f.set_cursor(cursor_x, cursor_y); // Set the cursor position
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user