mirror of https://github.com/lapce/lapce.git
open settings
This commit is contained in:
parent
0346f6d7f1
commit
fbbfe56a87
|
@ -965,6 +965,15 @@ dependencies = [
|
|||
"generic-array 0.14.4",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "directories"
|
||||
version = "4.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f51c5d4ddabd36886dd3e1438cb358cdcb0d7c499cb99cb4ac2e38e18b5cb210"
|
||||
dependencies = [
|
||||
"dirs-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dirs-next"
|
||||
version = "2.0.0"
|
||||
|
@ -975,6 +984,17 @@ dependencies = [
|
|||
"dirs-sys-next",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dirs-sys"
|
||||
version = "0.3.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "03d86534ed367a67548dc68113a0f5db55432fdfbb6e6f9d77704397d95d5780"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"redox_users",
|
||||
"winapi 0.3.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dirs-sys-next"
|
||||
version = "0.1.2"
|
||||
|
@ -2132,6 +2152,7 @@ dependencies = [
|
|||
"cc",
|
||||
"crossbeam-channel 0.5.1",
|
||||
"crossbeam-utils 0.8.5",
|
||||
"directories",
|
||||
"druid",
|
||||
"fuzzy-matcher",
|
||||
"fzyr",
|
||||
|
|
|
@ -5,6 +5,7 @@ authors = ["Dongdong Zhou <dzhou121@gmail.com>"]
|
|||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
directories = "4.0.1"
|
||||
tinyfiledialogs = "3.8.3"
|
||||
itertools = "0.10.1"
|
||||
unicode-width = "0.1.8"
|
||||
|
|
|
@ -203,6 +203,9 @@ pub enum LapceCommand {
|
|||
#[strum(serialize = "change_theme")]
|
||||
#[strum(message = "Change Theme")]
|
||||
ChangeTheme,
|
||||
#[strum(serialize = "open_settings")]
|
||||
#[strum(message = "Open Settings")]
|
||||
OpenSettings,
|
||||
#[strum(serialize = "join_lines")]
|
||||
JoinLines,
|
||||
#[strum(serialize = "search_whole_word_forward")]
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
use anyhow::{anyhow, Result};
|
||||
use crossbeam_channel::{bounded, unbounded, Receiver, Sender, TryRecvError};
|
||||
use crossbeam_utils::sync::WaitGroup;
|
||||
use directories::ProjectDirs;
|
||||
use druid::{
|
||||
piet::{PietText, Text},
|
||||
theme,
|
||||
|
@ -2640,6 +2641,19 @@ fn run_command(
|
|||
self.apply_completion_item(ctx, &item);
|
||||
}
|
||||
}
|
||||
LapceCommand::OpenSettings => {
|
||||
if let Some(proj_dirs) = ProjectDirs::from("", "", "Lapce") {
|
||||
std::fs::create_dir_all(proj_dirs.config_dir());
|
||||
let path = proj_dirs.config_dir().join("settings.toml");
|
||||
{
|
||||
std::fs::OpenOptions::new()
|
||||
.create_new(true)
|
||||
.write(true)
|
||||
.open(&path);
|
||||
}
|
||||
self.main_split.open_file(ctx, &path);
|
||||
}
|
||||
}
|
||||
LapceCommand::NormalMode => {
|
||||
let offset = match &self.editor.cursor.mode {
|
||||
CursorMode::Insert(selection) => {
|
||||
|
|
|
@ -89,6 +89,18 @@ pub struct LapceWorkspace {
|
|||
pub path: PathBuf,
|
||||
}
|
||||
|
||||
impl Default for LapceWorkspace {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
kind: LapceWorkspaceType::Local,
|
||||
path: directories::UserDirs::new()
|
||||
.unwrap()
|
||||
.home_dir()
|
||||
.to_path_buf(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Counter(AtomicU64);
|
||||
|
||||
impl Counter {
|
||||
|
|
|
@ -126,6 +126,15 @@ fn event(
|
|||
env: &Env,
|
||||
) {
|
||||
match event {
|
||||
Event::WindowConnected => {
|
||||
data.proxy.start(
|
||||
data.workspace
|
||||
.clone()
|
||||
.map(|w| (*w).clone())
|
||||
.unwrap_or(LapceWorkspace::default()),
|
||||
ctx.get_external_handle(),
|
||||
);
|
||||
}
|
||||
Event::MouseDown(mouse) => {
|
||||
if mouse.button.is_left() {
|
||||
if let Some(position) = self.bar_hit_test(data, mouse.pos) {
|
||||
|
|
|
@ -55,9 +55,6 @@ pub fn new_tab(
|
|||
data.theme.clone(),
|
||||
Some(ctx.get_external_handle()),
|
||||
);
|
||||
if let Some(workspace) = workspace {
|
||||
tab_data.set_workspace(workspace, ctx.get_external_handle());
|
||||
}
|
||||
let tab = LapceTabNew::new(&tab_data).lens(LapceTabLens(tab_id));
|
||||
data.tabs.insert(tab_id, tab_data);
|
||||
if replace_current {
|
||||
|
|
Loading…
Reference in New Issue