/
githubmirror
/
lapce
Обзор
Документация
Войти
/
githubmirror
/
lapce
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
v0.2.3
lapce-data/src/title.rs
75 строк
2 KB
Dongdong Zhou
decide color theme is light or dark
20 окт 2022, 22:57
20 окт 2022, 22:57
e416688
Код
Авторство
О чём код?
use std::sync::Arc; use druid::{Env, EventCtx, Point, WidgetId}; use lapce_core::{command::FocusCommand, mode::Mode}; use crate::{ command::{CommandExecuted, CommandKind, LapceCommand}, config::LapceConfig, keypress::KeyPressFocus, list::ListData, }; #[derive(Clone)] pub struct TitleData { pub widget_id: WidgetId, pub branches: BranchListData, } impl TitleData { pub fn new(config: Arc<LapceConfig>) -> TitleData { let widget_id = WidgetId::next(); TitleData { widget_id, branches: BranchListData::new(config, widget_id), } } } #[derive(Clone)] pub struct BranchListData { pub list: ListData<String, ()>, pub active: bool, /// The origin the list should appear at, this is updated whenever the /// branch list is opened in the titlebar pub origin: Point, } impl BranchListData { fn new(config: Arc<LapceConfig>, parent: WidgetId) -> Self { let list = ListData::new(config, parent, ()); BranchListData { list, active: false, origin: Point::ZERO, } } } impl KeyPressFocus for BranchListData { fn get_mode(&self) -> Mode { Mode::Insert } fn check_condition(&self, condition: &str) -> bool { matches!(condition, "list_focus" | "modal_focus") } fn run_command( &mut self, ctx: &mut EventCtx, command: &LapceCommand, _count: Option<usize>, _mods: druid::Modifiers, _env: &Env, ) -> CommandExecuted { if let CommandKind::Focus(FocusCommand::ModalClose) = command.kind { self.active = false; return CommandExecuted::Yes; } self.list.run_command(ctx, command) } fn receive_char(&mut self, _ctx: &mut EventCtx, _c: &str) { // Currently, this does not have any sort of input (such as for filtering) } }