-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Update crossterm, use more terminal features #13223
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ use crate::{ | |
}, | ||
}; | ||
|
||
use arc_swap::access::DynAccess; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think importing this as is can ruin some type inference for some instances of edit: Yeah, just cherry-picked this and did see this when I am |
||
use helix_core::{ | ||
diagnostic::NumberOrString, | ||
graphemes::{next_grapheme_boundary, prev_grapheme_boundary}, | ||
|
@@ -29,14 +30,15 @@ use helix_view::{ | |
graphics::{Color, CursorKind, Modifier, Rect, Style}, | ||
input::{KeyEvent, MouseButton, MouseEvent, MouseEventKind}, | ||
keyboard::{KeyCode, KeyModifiers}, | ||
Document, Editor, Theme, View, | ||
theme, Document, Editor, Theme, View, | ||
}; | ||
use std::{mem::take, num::NonZeroUsize, path::PathBuf, rc::Rc}; | ||
|
||
use tui::{buffer::Buffer as Surface, text::Span}; | ||
|
||
pub struct EditorView { | ||
pub keymaps: Keymaps, | ||
theme_config: Box<dyn DynAccess<Option<theme::Config>>>, | ||
on_next_key: Option<(OnKeyCallback, OnKeyCallbackKind)>, | ||
pseudo_pending: Vec<KeyEvent>, | ||
pub(crate) last_insert: (commands::MappableCommand, Vec<InsertEvent>), | ||
|
@@ -58,9 +60,13 @@ pub enum InsertEvent { | |
} | ||
|
||
impl EditorView { | ||
pub fn new(keymaps: Keymaps) -> Self { | ||
pub fn new( | ||
keymaps: Keymaps, | ||
theme_config: impl DynAccess<Option<theme::Config>> + 'static, | ||
) -> Self { | ||
Self { | ||
keymaps, | ||
theme_config: Box::new(theme_config), | ||
on_next_key: None, | ||
pseudo_pending: Vec::new(), | ||
last_insert: (commands::MappableCommand::normal_mode, Vec::new()), | ||
|
@@ -1535,6 +1541,18 @@ impl Component for EditorView { | |
self.terminal_focused = false; | ||
EventResult::Consumed(None) | ||
} | ||
Event::ThemeModeChanged(theme_mode) => { | ||
if let Some(theme_config) = self.theme_config.load().as_ref() { | ||
let theme_name = theme_config.choose(Some(*theme_mode)); | ||
match context.editor.theme_loader.load(theme_name) { | ||
Ok(theme) => context.editor.set_theme(theme), | ||
Err(err) => { | ||
log::warn!("failed to load theme `{}` - {}", theme_name, err); | ||
} | ||
} | ||
} | ||
EventResult::Consumed(None) | ||
} | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before merging this we should publish 0.1.0