fixed ui and themes for tree view + neovim plugin wrapper
All checks were successful
Version Check / check-version (pull_request) Successful in 4s

This commit is contained in:
2026-03-17 12:23:10 +01:00
parent 0ce858da5c
commit 7aa45974a7
14 changed files with 696 additions and 323 deletions

View File

@@ -1,4 +1,4 @@
use crate::format::EnvVar;
use crate::format::ConfigItem;
use tui_input::Input;
/// Represents the current operating mode of the application.
@@ -14,7 +14,7 @@ pub enum Mode {
/// The core application state, holding all configuration variables and UI status.
pub struct App {
/// The list of configuration variables being edited.
pub vars: Vec<EnvVar>,
pub vars: Vec<ConfigItem>,
/// Index of the currently selected variable in the list.
pub selected: usize,
/// The current interaction mode (Normal or Insert).
@@ -31,8 +31,8 @@ pub struct App {
impl App {
/// Initializes a new application instance with the provided variables.
pub fn new(vars: Vec<EnvVar>) -> Self {
let initial_input = vars.get(0).map(|v| v.value.clone()).unwrap_or_default();
pub fn new(vars: Vec<ConfigItem>) -> Self {
let initial_input = vars.get(0).and_then(|v| v.value.clone()).unwrap_or_default();
Self {
vars,
selected: 0,
@@ -78,6 +78,22 @@ impl App {
}
}
/// Jumps to the top of the list.
pub fn jump_top(&mut self) {
if !self.vars.is_empty() {
self.selected = 0;
self.sync_input_with_selected();
}
}
/// Jumps to the bottom of the list.
pub fn jump_bottom(&mut self) {
if !self.vars.is_empty() {
self.selected = self.vars.len() - 1;
self.sync_input_with_selected();
}
}
/// Jumps to the next variable that matches the search query.
pub fn jump_next_match(&mut self) {
let indices = self.matching_indices();
@@ -118,21 +134,29 @@ impl App {
/// Updates the input buffer to reflect the value of the currently selected variable.
pub fn sync_input_with_selected(&mut self) {
if let Some(var) = self.vars.get(self.selected) {
self.input = Input::new(var.value.clone());
let val = var.value.clone().unwrap_or_default();
self.input = Input::new(val);
}
}
/// Commits the current text in the input buffer back to the selected variable's value.
pub fn commit_input(&mut self) {
if let Some(var) = self.vars.get_mut(self.selected) {
var.value = self.input.value().to_string();
if !var.is_group {
var.value = Some(self.input.value().to_string());
var.status = crate::format::ItemStatus::Modified;
}
}
}
/// Transitions the application into Insert Mode.
pub fn enter_insert(&mut self) {
self.mode = Mode::Insert;
self.status_message = None;
if let Some(var) = self.vars.get(self.selected) {
if !var.is_group {
self.mode = Mode::Insert;
self.status_message = None;
}
}
}
/// Commits the current input and transitions the application into Normal Mode.