mirror of https://github.com/lapce/lapce.git
toggle modal editing
This commit is contained in:
parent
d9057685c2
commit
19c0201190
|
@ -74,6 +74,14 @@ pub fn lapce_internal_commands() -> IndexMap<String, LapceCommandNew> {
|
|||
|
||||
#[derive(Display, EnumString, EnumIter, Clone, PartialEq, Debug, EnumMessage)]
|
||||
pub enum LapceWorkbenchCommand {
|
||||
#[strum(serialize = "enable_modal_editing")]
|
||||
#[strum(message = "Enable Modal Editing")]
|
||||
EnableModal,
|
||||
|
||||
#[strum(serialize = "disable_modal_editing")]
|
||||
#[strum(message = "Disable Modal Editing")]
|
||||
DisableModal,
|
||||
|
||||
#[strum(serialize = "open_folder")]
|
||||
#[strum(message = "Open Folder")]
|
||||
OpenFolder,
|
||||
|
|
|
@ -120,7 +120,7 @@ pub fn settings_file() -> Option<PathBuf> {
|
|||
.map(|d| d.config_dir().join("settings.toml"))
|
||||
}
|
||||
|
||||
pub fn update_file(key: &str, value: &str) -> Option<()> {
|
||||
pub fn update_file(key: &str, value: toml::Value) -> Option<()> {
|
||||
let path = Config::settings_file()?;
|
||||
let content = std::fs::read(&path).ok()?;
|
||||
let mut toml_value: toml::Value = toml::from_slice(&content)
|
||||
|
@ -131,8 +131,7 @@ pub fn update_file(key: &str, value: &str) -> Option<()> {
|
|||
let n = parts.len();
|
||||
for (i, key) in parts.into_iter().enumerate() {
|
||||
if i == n - 1 {
|
||||
table
|
||||
.insert(key.to_string(), toml::Value::String(value.to_string()));
|
||||
table.insert(key.to_string(), value.clone());
|
||||
} else {
|
||||
if !table.contains_key(key) {
|
||||
table.insert(
|
||||
|
@ -151,7 +150,10 @@ pub fn update_file(key: &str, value: &str) -> Option<()> {
|
|||
pub fn set_theme(&mut self, theme: &str, preview: bool) -> Option<()> {
|
||||
self.lapce.color_theme = theme.to_string();
|
||||
if !preview {
|
||||
Config::update_file("lapce.color-theme", theme)?;
|
||||
Config::update_file(
|
||||
"lapce.color-theme",
|
||||
toml::Value::String(theme.to_string()),
|
||||
)?;
|
||||
}
|
||||
None
|
||||
}
|
||||
|
|
|
@ -531,6 +531,16 @@ pub fn run_workbench_command(
|
|||
}
|
||||
});
|
||||
}
|
||||
LapceWorkbenchCommand::EnableModal => {
|
||||
let config = Arc::make_mut(&mut self.config);
|
||||
config.lapce.modal = true;
|
||||
Config::update_file("lapce.modal", toml::Value::Boolean(true));
|
||||
}
|
||||
LapceWorkbenchCommand::DisableModal => {
|
||||
let config = Arc::make_mut(&mut self.config);
|
||||
config.lapce.modal = false;
|
||||
Config::update_file("lapce.modal", toml::Value::Boolean(false));
|
||||
}
|
||||
LapceWorkbenchCommand::ChangeTheme => {
|
||||
ctx.submit_command(Command::new(
|
||||
LAPCE_UI_COMMAND,
|
||||
|
|
Loading…
Reference in New Issue