Files
RuneStone/src-tauri/src/lib.rs
T

119 lines
4.3 KiB
Rust

mod pty;
mod terminal_platform;
mod plugins;
mod plugin_sources;
mod workspace;
mod browser;
mod git;
mod completion;
mod settings;
mod spelling;
mod theme;
mod backgrounds;
use pty::PtyState;
use tauri::Manager;
use workspace::WorkspaceState;
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
tauri::Builder::default()
.plugin(tauri_plugin_opener::init())
.plugin(tauri_plugin_dialog::init())
.manage(WorkspaceState::new())
.manage(PtyState::new())
.manage(plugins::PluginState::default())
.manage(browser::BrowserState::default())
.manage(completion::CompletionState::default())
.manage(settings::SettingsState::default())
.invoke_handler(tauri::generate_handler![
backgrounds::backgrounds_choose_folder,
backgrounds::backgrounds_default_folder,
backgrounds::backgrounds_list,
backgrounds::backgrounds_read,
backgrounds::backgrounds_read_image_settings,
backgrounds::backgrounds_write_image_settings,
theme::theme_export,
spelling::spelling_menu_install,
spelling::spelling_suggestions,
spelling::spelling_menu_select,
spelling::spelling_menu_uninstall,
settings::settings_open_window,
completion::completion_request,
completion::completion_cancel,
browser::browser_request,
browser::browser_connect,
browser::browser_stop,
git::git_status,
git::git_diff,
git::git_stage,
git::git_unstage,
git::git_commit,
git::git_blame,
git::git_push,
git::git_pull,
git::git_graph,
git::git_commit_diff,
git::git_commit_details,
workspace::workspace_open,
workspace::workspace_open_window,
workspace::workspace_last_path,
workspace::workspace_recent,
workspace::workspace_new,
workspace::workspace_list,
workspace::workspace_list_markdown,
workspace::workspace_read,
workspace::workspace_read_bytes,
workspace::workspace_write,
workspace::workspace_create,
workspace::workspace_rename,
workspace::workspace_delete,
workspace::workspace_read_data_url,
workspace::workspace_write_bytes,
workspace::workspace_copy,
workspace::workspace_abs_path,
workspace::workspace_reveal,
workspace::workspace_open_terminal,
workspace::workspace_open_default,
workspace::workspace_search,
plugins::plugins_snapshot,
plugins::plugins_choose,
plugins::plugins_from_git,
plugins::plugins_cancel,
plugins::plugins_install,
plugins::plugins_set_enabled,
plugins::plugins_load,
plugins::plugins_release,
plugins::plugins_prepare_remove,
plugins::plugins_remove,
plugins::plugins_retry_remove,
plugins::plugins_reveal,
plugins::plugins_data,
plugins::plugins_asset,
pty::pty_open,
pty::pty_write,
pty::pty_resize,
pty::pty_close,
pty::pty_profiles,
pty::pty_new_window,
pty::pty_dictation,
])
.build(tauri::generate_context!())
.expect("error while building tauri application")
.run(|app, event| {
if let tauri::RunEvent::WindowEvent { label, event: tauri::WindowEvent::Destroyed, .. } = &event {
settings::close_owned_window(app, label);
spelling::close_window(app, label);
app.state::<PtyState>().close_window(label);
app.state::<completion::CompletionState>().close_window(label);
app.state::<browser::BrowserState>().close_window(label);
app.state::<plugins::PluginState>().close_window(label);
app.state::<WorkspaceState>().close_window(label);
}
if matches!(event, tauri::RunEvent::Exit) {
app.state::<PtyState>().close_all();
app.state::<browser::BrowserState>().close_all();
}
});
}