[tui] Set tab title to file name.

Also update to use anyhow::Result in some places.
This commit is contained in:
Shaun Reed 2026-01-20 12:00:24 -05:00
parent bccc5a35e2
commit d2846e1e4e
3 changed files with 14 additions and 8 deletions

View File

@ -1,10 +1,10 @@
use anyhow::Result;
use cxx_qt_lib::QString; use cxx_qt_lib::QString;
use std::error::Error;
pub mod colors; pub mod colors;
pub mod filesystem; pub mod filesystem;
pub fn run(root_path: std::path::PathBuf) -> Result<(), Box<dyn Error>> { pub fn run(root_path: std::path::PathBuf) -> Result<()> {
println!("Starting the GUI editor at {:?}", root_path); println!("Starting the GUI editor at {:?}", root_path);
use cxx_qt_lib::{QGuiApplication, QQmlApplicationEngine, QUrl}; use cxx_qt_lib::{QGuiApplication, QQmlApplicationEngine, QUrl};

View File

@ -1,6 +1,4 @@
// TODO: Header use anyhow::Result;
use std::error::Error;
use std::process::{Command, Stdio}; use std::process::{Command, Stdio};
use structopt::StructOpt; use structopt::StructOpt;
@ -25,7 +23,7 @@ struct Cli {
pub gui: bool, pub gui: bool,
} }
fn main() -> Result<(), Box<dyn Error>> { fn main() -> Result<()> {
let args = Cli::from_args(); let args = Cli::from_args();
let root_path = match args.path { let root_path = match args.path {

View File

@ -65,8 +65,16 @@ impl<'a> App<'a> {
} }
fn draw_tabs(&self, area: Rect, buf: &mut Buffer) { fn draw_tabs(&self, area: Rect, buf: &mut Buffer) {
// TODO: Tabs should be opened from file explorer // Determine the tab title from the current file (or use a fallback).
Tabs::new(["file.md", "file.cpp"]) 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) .divider(symbols::DOT)
.block( .block(
Block::default() Block::default()