feat(tui): rename tabs, add profile rename, fix editor spawning
This commit is contained in:
1 parent
df3d6b24c2
commit
ecc2b2bb23
4 files changed
+186
-31
No files matched your search
@@ -220,7 +220,7 @@ pub fn render(frame: &mut Frame, area: Rect, focused: FocusedArea, state: &mut A
|
||||
};
|
||||
|
||||
let mut block = Block::default()
|
||||
.title(styled_title("Account", true))
|
||||
.title(styled_title("Accounts", true))
|
||||
.borders(Borders::ALL)
|
||||
.border_type(BorderType::Rounded)
|
||||
.border_style(Style::default().fg(color));
|
||||
|
||||
+99
-17
@@ -1,41 +1,123 @@
|
||||
use ratatui::{
|
||||
layout::Rect,
|
||||
style::Style,
|
||||
widgets::{Block, BorderType, Borders},
|
||||
style::{Modifier, Style},
|
||||
text::{Line, Span},
|
||||
widgets::{Block, BorderType, Borders, Paragraph},
|
||||
Frame,
|
||||
};
|
||||
|
||||
use crate::instance::models::InstanceConfig;
|
||||
use crate::tui::layout::FocusedArea;
|
||||
use crate::tui::theme::THEME;
|
||||
|
||||
use super::styled_title;
|
||||
|
||||
pub fn render(frame: &mut Frame, area: Rect, focused: FocusedArea) {
|
||||
let color = if focused == FocusedArea::Details {
|
||||
pub fn render(
|
||||
frame: &mut Frame,
|
||||
area: Rect,
|
||||
focused: FocusedArea,
|
||||
instance: Option<&InstanceConfig>,
|
||||
_instances_dir: &std::path::Path,
|
||||
) {
|
||||
let color = if focused == FocusedArea::Settings {
|
||||
THEME.colors.border_focused
|
||||
} else {
|
||||
THEME.colors.border_unfocused
|
||||
};
|
||||
|
||||
let mut block = Block::default()
|
||||
.title(styled_title("Details", true))
|
||||
.title(styled_title("Settings", true))
|
||||
.borders(Borders::ALL)
|
||||
.border_type(BorderType::Rounded)
|
||||
.border_style(Style::default().fg(color));
|
||||
|
||||
let lines = super::popups::keybind_lines_wrapped(
|
||||
&[
|
||||
("P", " profiles"),
|
||||
("C", " content"),
|
||||
("A", " account"),
|
||||
("S", " logs"),
|
||||
("q", " quit"),
|
||||
],
|
||||
area.width.saturating_sub(2),
|
||||
);
|
||||
for line in lines {
|
||||
block = block.title_bottom(line);
|
||||
if focused == FocusedArea::Settings {
|
||||
let lines = super::popups::keybind_lines_wrapped(
|
||||
&[("e", " edit instance"), ("g", " edit global")],
|
||||
area.width.saturating_sub(2),
|
||||
);
|
||||
for line in lines {
|
||||
block = block.title_bottom(line);
|
||||
}
|
||||
}
|
||||
|
||||
let inner = block.inner(area);
|
||||
frame.render_widget(block, area);
|
||||
|
||||
let Some(inst) = instance else {
|
||||
frame.render_widget(
|
||||
Paragraph::new("No instance selected.")
|
||||
.style(Style::default().fg(THEME.colors.text_idle)),
|
||||
inner,
|
||||
);
|
||||
return;
|
||||
};
|
||||
|
||||
let label_style = Style::default().fg(THEME.colors.text_idle);
|
||||
let value_style = Style::default()
|
||||
.fg(THEME.colors.foreground)
|
||||
.add_modifier(Modifier::BOLD);
|
||||
let dim_style = Style::default().fg(THEME.colors.border_unfocused);
|
||||
|
||||
let memory_min = inst.memory_min.as_deref().unwrap_or("512M");
|
||||
let memory_max = inst.memory_max.as_deref().unwrap_or("2G");
|
||||
let java_path = inst.java_path.as_deref().unwrap_or("system");
|
||||
let jvm_args = if inst.jvm_args.is_empty() {
|
||||
"none".to_string()
|
||||
} else {
|
||||
inst.jvm_args.join(" ")
|
||||
};
|
||||
let resolution = inst
|
||||
.resolution
|
||||
.map(|(w, h)| format!("{}x{}", w, h))
|
||||
.unwrap_or_else(|| "default".to_string());
|
||||
|
||||
let lines = vec![
|
||||
Line::from(vec![
|
||||
Span::styled("Memory ", label_style),
|
||||
Span::styled(format!("{memory_min} - {memory_max}"), value_style),
|
||||
]),
|
||||
Line::from(vec![
|
||||
Span::styled("Java ", label_style),
|
||||
Span::styled(java_path, value_style),
|
||||
]),
|
||||
Line::from(vec![
|
||||
Span::styled("JVM ", label_style),
|
||||
Span::styled(jvm_args, dim_style),
|
||||
]),
|
||||
Line::from(vec![
|
||||
Span::styled("Display ", label_style),
|
||||
Span::styled(resolution, value_style),
|
||||
]),
|
||||
];
|
||||
|
||||
frame.render_widget(Paragraph::new(lines), inner);
|
||||
}
|
||||
|
||||
pub enum SettingsAction {
|
||||
None,
|
||||
EditInstance(std::path::PathBuf),
|
||||
EditGlobal(std::path::PathBuf),
|
||||
}
|
||||
|
||||
pub fn handle_key(
|
||||
key_event: &crossterm::event::KeyEvent,
|
||||
instance: Option<&InstanceConfig>,
|
||||
instances_dir: &std::path::Path,
|
||||
) -> SettingsAction {
|
||||
match key_event.code {
|
||||
crossterm::event::KeyCode::Char('e') => {
|
||||
if let Some(inst) = instance {
|
||||
let path = instances_dir.join(&inst.name).join("instance.json");
|
||||
SettingsAction::EditInstance(path)
|
||||
} else {
|
||||
SettingsAction::None
|
||||
}
|
||||
}
|
||||
crossterm::event::KeyCode::Char('g') => {
|
||||
let path = crate::config::get_config_path().join("config.toml");
|
||||
SettingsAction::EditGlobal(path)
|
||||
}
|
||||
_ => SettingsAction::None,
|
||||
}
|
||||
}
|
||||
@@ -19,14 +19,14 @@ pub fn render(
|
||||
focused: FocusedArea,
|
||||
throbber_state: &mut ThrobberState,
|
||||
) {
|
||||
let border_color = if focused == FocusedArea::Status {
|
||||
let border_color = if focused == FocusedArea::Overview {
|
||||
THEME.colors.border_focused
|
||||
} else {
|
||||
THEME.colors.border_unfocused
|
||||
};
|
||||
|
||||
let block = Block::default()
|
||||
.title(styled_title("Status", true))
|
||||
.title(styled_title("Overview", true))
|
||||
.borders(Borders::ALL)
|
||||
.border_type(BorderType::Rounded)
|
||||
.border_style(Style::default().fg(border_color));
|
||||
|
||||
Reference in new issue
Block a user