| 1 | mod buffer; |
| 2 | mod editor; |
| 3 | mod fuss; |
| 4 | mod input; |
| 5 | mod lsp; |
| 6 | mod render; |
| 7 | mod syntax; |
| 8 | mod terminal; |
| 9 | mod util; |
| 10 | mod workspace; |
| 11 | |
| 12 | use anyhow::Result; |
| 13 | use editor::{Editor, WelcomeMenu}; |
| 14 | use render::Screen; |
| 15 | use std::env; |
| 16 | use workspace::recents_add_or_update; |
| 17 | |
| 18 | fn main() -> Result<()> { |
| 19 | let args: Vec<String> = env::args().collect(); |
| 20 | let filename = args.get(1).map(|s| s.as_str()); |
| 21 | |
| 22 | if let Some(path) = filename { |
| 23 | // File/directory provided - open directly |
| 24 | let mut editor = Editor::new()?; |
| 25 | editor.open(path)?; |
| 26 | |
| 27 | // Track this workspace in recents |
| 28 | let _ = recents_add_or_update(&editor.workspace_root()); |
| 29 | |
| 30 | editor.run() |
| 31 | } else { |
| 32 | // No arguments - show welcome menu |
| 33 | let mut screen = Screen::new()?; |
| 34 | screen.enter_raw_mode()?; |
| 35 | |
| 36 | match WelcomeMenu::run(&mut screen)? { |
| 37 | Some(workspace_path) => { |
| 38 | // Track this workspace in recents |
| 39 | let _ = recents_add_or_update(&workspace_path); |
| 40 | |
| 41 | // Create editor with selected workspace, reusing the screen |
| 42 | let mut editor = Editor::new_with_screen_and_workspace(screen, workspace_path)?; |
| 43 | editor.run() |
| 44 | } |
| 45 | None => { |
| 46 | // User quit from welcome menu |
| 47 | screen.leave_raw_mode()?; |
| 48 | Ok(()) |
| 49 | } |
| 50 | } |
| 51 | } |
| 52 | } |
| 53 |