From d2846e1e4ec7c5201555e936e3f4d8af65b4d9c7 Mon Sep 17 00:00:00 2001 From: Shaun Reed Date: Tue, 20 Jan 2026 12:00:24 -0500 Subject: [PATCH] [tui] Set tab title to file name. Also update to use anyhow::Result in some places. --- src/gui.rs | 4 ++-- src/main.rs | 6 ++---- src/tui/app.rs | 12 ++++++++++-- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/gui.rs b/src/gui.rs index 62c6172..b80df58 100644 --- a/src/gui.rs +++ b/src/gui.rs @@ -1,10 +1,10 @@ +use anyhow::Result; use cxx_qt_lib::QString; -use std::error::Error; pub mod colors; pub mod filesystem; -pub fn run(root_path: std::path::PathBuf) -> Result<(), Box> { +pub fn run(root_path: std::path::PathBuf) -> Result<()> { println!("Starting the GUI editor at {:?}", root_path); use cxx_qt_lib::{QGuiApplication, QQmlApplicationEngine, QUrl}; diff --git a/src/main.rs b/src/main.rs index cc84b45..4fa7a06 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,4 @@ -// TODO: Header - -use std::error::Error; +use anyhow::Result; use std::process::{Command, Stdio}; use structopt::StructOpt; @@ -25,7 +23,7 @@ struct Cli { pub gui: bool, } -fn main() -> Result<(), Box> { +fn main() -> Result<()> { let args = Cli::from_args(); let root_path = match args.path { diff --git a/src/tui/app.rs b/src/tui/app.rs index 67b0bd5..cedb9f8 100644 --- a/src/tui/app.rs +++ b/src/tui/app.rs @@ -65,8 +65,16 @@ impl<'a> App<'a> { } fn draw_tabs(&self, area: Rect, buf: &mut Buffer) { - // TODO: Tabs should be opened from file explorer - Tabs::new(["file.md", "file.cpp"]) + // Determine the tab title from the current file (or use a fallback). + let title = self + .editor + .file_path + .as_ref() + .and_then(|p| p.file_name()) + .and_then(|s| s.to_str()) + .unwrap_or("Untitled"); + + Tabs::new(vec![title]) .divider(symbols::DOT) .block( Block::default()