This commit is contained in:
2026-10-30 23:11:51 +03:00
parent 55c3955897
commit 27385a3edb
11 changed files with 1898 additions and 63 deletions
+15 -2
View File
@@ -17,19 +17,32 @@ use std::path::{Path, PathBuf};
use mlua::{Lua, Table};
use crate::api::{AppApi, TabInfo};
use crate::api::{AppApi, DirEntryInfo, TabInfo};
use crate::constants::{STARTUP_SCRIPT, script_dir};
/// Вкладка превращается в Lua-таблицу `{ index = 0, title = "main.rs" }`.
/// Вкладка превращается в Lua-таблицу `{ index = 0, title = "main.rs", icon = "file" }`.
impl mlua::IntoLua for TabInfo {
fn into_lua(self, lua: &Lua) -> mlua::Result<mlua::Value> {
let tab = lua.create_table()?;
tab.set("index", self.index)?;
tab.set("title", self.title)?;
tab.set("icon", self.icon)?;
Ok(mlua::Value::Table(tab))
}
}
/// Элемент каталога превращается в Lua-таблицу
/// `{ id = "src/main.rs", name = "main.rs", is_dir = false }`.
impl mlua::IntoLua for DirEntryInfo {
fn into_lua(self, lua: &Lua) -> mlua::Result<mlua::Value> {
let entry = lua.create_table()?;
entry.set("id", self.id)?;
entry.set("name", self.name)?;
entry.set("is_dir", self.is_dir)?;
Ok(mlua::Value::Table(entry))
}
}
/// Движок Lua и состояние его глобального окружения.
pub struct ScriptEngine {
lua: Lua,