mirror of https://github.com/lapce/lapce.git
add logo
This commit is contained in:
parent
a2ebb9239e
commit
8a6f29ac6b
|
@ -3226,7 +3226,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "piet-wgpu"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/lapce/piet-wgpu#21971bbecaf728e53a44343a13eb3d715c3999e2"
|
||||
source = "git+https://github.com/lapce/piet-wgpu#c640e5ce74bff2d72834c7a111b061a0cc74da9f"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"font-kit",
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
include_str!("../../defaults/light-theme.toml");
|
||||
const default_dark_theme: &'static str =
|
||||
include_str!("../../defaults/dark-theme.toml");
|
||||
pub const LOGO: &'static str = include_str!("../../extra/images/logo.svg");
|
||||
|
||||
pub struct LapceTheme {}
|
||||
|
||||
|
|
|
@ -3,13 +3,13 @@
|
|||
CommandTarget, LapceCommandNew, LapceWorkbenchCommand, LAPCE_NEW_COMMAND,
|
||||
};
|
||||
use crate::completion::{CompletionData, CompletionStatus, Snippet};
|
||||
use crate::config::{Config, LapceTheme};
|
||||
use crate::config::{Config, LapceTheme, LOGO};
|
||||
use crate::data::{
|
||||
EditorContent, EditorDiagnostic, EditorKind, EditorType, LapceEditorData,
|
||||
LapceMainSplitData, LapceTabData, RegisterData,
|
||||
};
|
||||
use crate::find::Find;
|
||||
use crate::keypress::KeyPressFocus;
|
||||
use crate::keypress::{KeyMap, KeyPressFocus};
|
||||
use crate::proxy::LapceProxy;
|
||||
use crate::scroll::LapceIdentityWrapper;
|
||||
use crate::signature::SignatureState;
|
||||
|
@ -45,6 +45,7 @@
|
|||
use bit_vec::BitVec;
|
||||
use crossbeam_channel::{self, bounded};
|
||||
use druid::kurbo::BezPath;
|
||||
use druid::piet::Svg;
|
||||
use druid::widget::{LensWrap, WidgetWrapper};
|
||||
use druid::{
|
||||
kurbo::Line, piet::PietText, theme, widget::Flex, widget::IdentityWrapper,
|
||||
|
@ -54,7 +55,7 @@
|
|||
RenderContext, Size, Target, TextLayout, UpdateCtx, Vec2, Widget, WidgetExt,
|
||||
WidgetId, WidgetPod, WindowId,
|
||||
};
|
||||
use druid::{menu, Application, ExtEventSink, FileDialogOptions, Menu};
|
||||
use druid::{menu, Application, ExtEventSink, FileDialogOptions, Menu, Modifiers};
|
||||
use druid::{
|
||||
piet::{
|
||||
PietTextLayout, Text, TextAttribute, TextLayout as TextLayoutTrait,
|
||||
|
@ -3675,7 +3676,7 @@ fn paint(&mut self, ctx: &mut PaintCtx, data: &LapceTabData, env: &Env) {
|
|||
pub struct LapceEditor {
|
||||
view_id: WidgetId,
|
||||
placeholder: Option<String>,
|
||||
commands: Vec<(LapceCommandNew, PietTextLayout, Rect)>,
|
||||
commands: Vec<(LapceCommandNew, PietTextLayout, Rect, PietTextLayout)>,
|
||||
}
|
||||
|
||||
impl LapceEditor {
|
||||
|
@ -3702,7 +3703,7 @@ fn event(
|
|||
EditorContent::None => {
|
||||
ctx.set_handled();
|
||||
let mut on_command = false;
|
||||
for (_, _, rect) in &self.commands {
|
||||
for (_, _, rect, _) in &self.commands {
|
||||
if rect.contains(mouse_event.pos) {
|
||||
on_command = true;
|
||||
break;
|
||||
|
@ -3784,7 +3785,7 @@ fn event(
|
|||
Event::MouseDown(mouse_event) => match &editor.content {
|
||||
EditorContent::None => {
|
||||
ctx.set_handled();
|
||||
for (cmd, _, rect) in &self.commands {
|
||||
for (cmd, _, rect, _) in &self.commands {
|
||||
if rect.contains(mouse_event.pos) {
|
||||
ctx.submit_command(Command::new(
|
||||
LAPCE_NEW_COMMAND,
|
||||
|
@ -3990,10 +3991,10 @@ fn layout(
|
|||
}
|
||||
LapceEditorViewContent::None => {
|
||||
let size = bc.max();
|
||||
let origin = Point::new(size.width / 2.0, size.height / 2.0);
|
||||
let origin = Point::new(size.width / 2.0, size.height / 2.0 + 40.0);
|
||||
let line_height = 30.0;
|
||||
|
||||
self.commands = empty_editor_commands()
|
||||
self.commands = empty_editor_commands(data.workspace.is_some())
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(|(i, cmd)| {
|
||||
|
@ -4013,7 +4014,49 @@ fn layout(
|
|||
let point = origin
|
||||
- (text_layout.size().width, -line_height * i as f64);
|
||||
let rect = text_layout.size().to_rect().with_origin(point);
|
||||
(cmd.clone(), text_layout, rect)
|
||||
let mut key = None;
|
||||
for (_, keymaps) in data.keypress.keymaps.iter() {
|
||||
for keymap in keymaps {
|
||||
if keymap.command == cmd.cmd {
|
||||
let mut keymap_str = "".to_string();
|
||||
for (mods, key) in &keymap.key {
|
||||
if keymap_str != "" {
|
||||
keymap_str += " "
|
||||
}
|
||||
if mods.ctrl() {
|
||||
keymap_str += "Ctrl+";
|
||||
}
|
||||
if mods.shift() {
|
||||
keymap_str += "Shift+";
|
||||
}
|
||||
if mods.alt() {
|
||||
keymap_str += "Alt+";
|
||||
}
|
||||
if mods.meta() {
|
||||
keymap_str += "Meta+";
|
||||
}
|
||||
keymap_str += &key.to_string();
|
||||
}
|
||||
key = Some(keymap_str);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if key.is_some() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
let key_text_layout = ctx
|
||||
.text()
|
||||
.new_text_layout(key.unwrap_or("Unbound".to_string()))
|
||||
.font(FontFamily::SYSTEM_UI, 14.0)
|
||||
.text_color(
|
||||
data.config
|
||||
.get_color_unchecked(LapceTheme::EDITOR_DIM)
|
||||
.clone(),
|
||||
)
|
||||
.build()
|
||||
.unwrap();
|
||||
(cmd.clone(), text_layout, rect, key_text_layout)
|
||||
})
|
||||
.collect();
|
||||
|
||||
|
@ -4029,8 +4072,33 @@ fn paint(&mut self, ctx: &mut PaintCtx, data: &LapceTabData, env: &Env) {
|
|||
data.paint_content(ctx, is_focused, self.placeholder.as_ref());
|
||||
}
|
||||
LapceEditorViewContent::None => {
|
||||
for (cmd, text, rect) in &self.commands {
|
||||
let svg = Svg::from_str(LOGO).unwrap();
|
||||
let size = ctx.size();
|
||||
let svg_size = 100.0;
|
||||
let rect = Size::ZERO
|
||||
.to_rect()
|
||||
.with_origin(
|
||||
Point::new(size.width / 2.0, size.height / 2.0)
|
||||
+ (0.0, -svg_size),
|
||||
)
|
||||
.inflate(svg_size, svg_size);
|
||||
ctx.draw_svg(
|
||||
&svg,
|
||||
rect,
|
||||
Some(
|
||||
&data
|
||||
.config
|
||||
.get_color_unchecked(LapceTheme::EDITOR_DIM)
|
||||
.clone()
|
||||
.with_alpha(0.5),
|
||||
),
|
||||
);
|
||||
for (cmd, text, rect, keymap) in &self.commands {
|
||||
ctx.draw_text(text, rect.origin());
|
||||
ctx.draw_text(
|
||||
keymap,
|
||||
rect.origin() + (20.0 + rect.width(), 0.0),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4207,22 +4275,37 @@ fn paint_wave_line(
|
|||
ctx.stroke(path, color, 1.4);
|
||||
}
|
||||
|
||||
fn empty_editor_commands() -> Vec<LapceCommandNew> {
|
||||
vec![
|
||||
LapceCommandNew {
|
||||
cmd: LapceWorkbenchCommand::PaletteCommand.to_string(),
|
||||
palette_desc: Some("Show All Commands".to_string()),
|
||||
target: CommandTarget::Workbench,
|
||||
},
|
||||
LapceCommandNew {
|
||||
cmd: LapceWorkbenchCommand::OpenFolder.to_string(),
|
||||
palette_desc: Some("Open Folder".to_string()),
|
||||
target: CommandTarget::Workbench,
|
||||
},
|
||||
LapceCommandNew {
|
||||
cmd: LapceWorkbenchCommand::PaletteWorkspace.to_string(),
|
||||
palette_desc: Some("Open Recent".to_string()),
|
||||
target: CommandTarget::Workbench,
|
||||
},
|
||||
]
|
||||
fn empty_editor_commands(has_workspace: bool) -> Vec<LapceCommandNew> {
|
||||
if !has_workspace {
|
||||
vec![
|
||||
LapceCommandNew {
|
||||
cmd: LapceWorkbenchCommand::PaletteCommand.to_string(),
|
||||
palette_desc: Some("Show All Commands".to_string()),
|
||||
target: CommandTarget::Workbench,
|
||||
},
|
||||
LapceCommandNew {
|
||||
cmd: LapceWorkbenchCommand::OpenFolder.to_string(),
|
||||
palette_desc: Some("Open Folder".to_string()),
|
||||
target: CommandTarget::Workbench,
|
||||
},
|
||||
LapceCommandNew {
|
||||
cmd: LapceWorkbenchCommand::PaletteWorkspace.to_string(),
|
||||
palette_desc: Some("Open Recent".to_string()),
|
||||
target: CommandTarget::Workbench,
|
||||
},
|
||||
]
|
||||
} else {
|
||||
vec![
|
||||
LapceCommandNew {
|
||||
cmd: LapceWorkbenchCommand::PaletteCommand.to_string(),
|
||||
palette_desc: Some("Show All Commands".to_string()),
|
||||
target: CommandTarget::Workbench,
|
||||
},
|
||||
LapceCommandNew {
|
||||
cmd: LapceWorkbenchCommand::Palette.to_string(),
|
||||
palette_desc: Some("Go To File".to_string()),
|
||||
target: CommandTarget::Workbench,
|
||||
},
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,7 +67,8 @@ fn run_command(
|
|||
#[derive(Clone, Debug)]
|
||||
pub struct KeyPressData {
|
||||
pending_keypress: Vec<KeyPress>,
|
||||
keymaps: im::HashMap<Vec<(Modifiers, druid::keyboard_types::Code)>, Vec<KeyMap>>,
|
||||
pub keymaps:
|
||||
Arc<IndexMap<Vec<(Modifiers, druid::keyboard_types::Code)>, Vec<KeyMap>>>,
|
||||
pub commands: Arc<IndexMap<String, LapceCommandNew>>,
|
||||
count: Option<usize>,
|
||||
}
|
||||
|
@ -76,7 +77,7 @@ impl KeyPressData {
|
|||
pub fn new() -> Self {
|
||||
Self {
|
||||
pending_keypress: Vec::new(),
|
||||
keymaps: Self::get_keymaps().unwrap_or(im::HashMap::new()),
|
||||
keymaps: Arc::new(Self::get_keymaps().unwrap_or(IndexMap::new())),
|
||||
commands: Arc::new(lapce_internal_commands()),
|
||||
count: None,
|
||||
}
|
||||
|
@ -84,7 +85,7 @@ pub fn new() -> Self {
|
|||
|
||||
pub fn update_keymaps(&mut self) {
|
||||
if let Ok(new_keymaps) = Self::get_keymaps() {
|
||||
self.keymaps = new_keymaps;
|
||||
self.keymaps = Arc::new(new_keymaps);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -317,19 +318,18 @@ fn check_condition<T: KeyPressFocus>(&self, condition: &str, check: &T) -> bool
|
|||
|
||||
fn keymaps_from_str(
|
||||
s: &str,
|
||||
) -> Result<
|
||||
im::HashMap<Vec<(Modifiers, druid::keyboard_types::Code)>, Vec<KeyMap>>,
|
||||
> {
|
||||
) -> Result<IndexMap<Vec<(Modifiers, druid::keyboard_types::Code)>, Vec<KeyMap>>>
|
||||
{
|
||||
let toml_keymaps: toml::Value = toml::from_str(s)?;
|
||||
let toml_keymaps = toml_keymaps
|
||||
.get("keymaps")
|
||||
.and_then(|v| v.as_array())
|
||||
.ok_or(anyhow!("no keymaps"))?;
|
||||
|
||||
let mut keymaps: im::HashMap<
|
||||
let mut keymaps: IndexMap<
|
||||
Vec<(Modifiers, druid::keyboard_types::Code)>,
|
||||
Vec<KeyMap>,
|
||||
> = im::HashMap::new();
|
||||
> = IndexMap::new();
|
||||
for toml_keymap in toml_keymaps {
|
||||
if let Ok(keymap) = Self::get_keymap(toml_keymap) {
|
||||
for i in 1..keymap.key.len() + 1 {
|
||||
|
@ -347,9 +347,9 @@ fn keymaps_from_str(
|
|||
Ok(keymaps)
|
||||
}
|
||||
|
||||
fn get_keymaps() -> Result<
|
||||
im::HashMap<Vec<(Modifiers, druid::keyboard_types::Code)>, Vec<KeyMap>>,
|
||||
> {
|
||||
fn get_keymaps(
|
||||
) -> Result<IndexMap<Vec<(Modifiers, druid::keyboard_types::Code)>, Vec<KeyMap>>>
|
||||
{
|
||||
let mut keymaps_str = if std::env::consts::OS == "macos" {
|
||||
default_keymaps_macos
|
||||
} else if std::env::consts::OS == "linux" {
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
<svg version="1.1" id="svg2" width="2880" height="2880" viewBox="0 0 2880 2880" xmlns="http://www.w3.org/2000/svg">
|
||||
<defs id="defs6"></defs>
|
||||
<g id="g10" transform="matrix(4.511777, 0, 0, -4.511777, -3433.283203, 6312.723633)" style="filter: none;">
|
||||
<g id="g12" transform="scale(0.1)">
|
||||
<path d="m 8680.16,13575.4 -567.42,327.6 c 0,-2068.7 -0.01,-4137.33 -0.01,-6205.98 551.01,318.11 1102.02,636.24 1653.02,954.37 V 9306.6 L 8680.16,8679.83 c 0,1631.87 0.02,3263.67 0,4895.57 z M 9768.37,9981 v 2310.9 c 861.33,-497.3 1722.73,-994.6 2584.03,-1491.9 -672.2,-388.1 -1344.4,-776.2 -2016.6,-1164.29 V 8980.5 c 861.3,497.3 1722.7,994.6 2584,1491.9 l 567.5,327.6 -567.5,327.6 c -1050.5,606.5 -2100.9,1213 -3151.43,1819.5 l -2.62,1.5 -567.43,327.6 c 0,-1208.1 0.01,-2416.2 0.01,-3624.32 z m 1447.33,835.6 -879.9,508.1 v -1016.1 z" style="fill:#1a1a1a;fill-opacity:1;fill-rule:evenodd;stroke:none" id="path14"></path>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 944 B |
Loading…
Reference in New Issue