Skip to content
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

Add live preview to theme picker #1798

Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
94a377f
Add theme picker with live preview
jharrilim Mar 12, 2022
753131e
Add live theme preview to :theme command
jharrilim Mar 12, 2022
b0c4f7c
cargo fmt
jharrilim Mar 12, 2022
6bfde21
Fix clippy warnings
jharrilim Mar 12, 2022
1481093
Remove picker variant
jharrilim Mar 13, 2022
fe5ec9e
Remove unused import
jharrilim Mar 13, 2022
2d96be2
Cleanup
jharrilim Mar 15, 2022
c638d0b
Change current_theme to last_theme
jharrilim Mar 15, 2022
dcb09e0
Fix accidental comment flash deletion
jharrilim Mar 15, 2022
3c1638b
Merge branch 'master' into feat/add-theme-picker-with-live-preview-jh…
jharrilim Mar 18, 2022
8dfd840
Merge branch 'master' into feat/add-theme-picker-with-live-preview-jh…
jharrilim Jun 18, 2022
0178162
Typo
jharrilim Jun 18, 2022
5f85522
Remove theme cache
jharrilim Jun 18, 2022
97ed0d6
Add some comments
jharrilim Jun 18, 2022
01467e3
Refactor some theme handling
jharrilim Jun 18, 2022
b782d07
Remove unnecessary renames
jharrilim Jun 19, 2022
3e9b33e
Constrain last_theme theme preview lifecycle
jharrilim Jun 19, 2022
a05186f
Switch to bitflag implementation
jharrilim Jun 19, 2022
a83069e
Better handling of last_theme
jharrilim Jun 20, 2022
89ec841
Sort theme names
jharrilim Jun 20, 2022
1d1c8cc
Better memory juggling
jharrilim Jun 20, 2022
0af7ed6
Missed a branch
jharrilim Jun 20, 2022
a8514d0
Remove name from theme, switch bitand to &
jharrilim Jun 22, 2022
1961ac5
Merge branch 'master' into feat/add-theme-picker-with-live-preview-jh…
jharrilim Jun 22, 2022
860665b
cargo fmt
jharrilim Jun 22, 2022
5eb1d41
Update helix-view/src/editor.rs
jharrilim Jun 24, 2022
5a313c9
Switch boolean to enum
jharrilim Jun 26, 2022
bc3a1de
Merge branch 'feat/add-theme-picker-with-live-preview-jharrilim' of g…
jharrilim Jun 26, 2022
670f0b8
Remove bitflag impl
jharrilim Jul 2, 2022
b81aedf
cargo fmt
jharrilim Jul 2, 2022
8f6991f
Remove un-needed type arg
jharrilim Jul 2, 2022
251d61a
cargo fmt
jharrilim Jul 2, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 21 additions & 14 deletions helix-term/src/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,26 +67,24 @@ impl Application {
std::sync::Arc::new(theme::Loader::new(&conf_dir, &helix_loader::runtime_dir()));

let true_color = config.editor.true_color || crate::true_color();
let theme = config
.theme
.as_ref()
.and_then(|theme| {
theme_loader
.load(theme)

let theme = match config.theme.as_ref() {
Some(theme_name) => {
match theme_loader
.load(theme_name)
.map_err(|e| {
log::warn!("failed to load theme `{}` - {}", theme, e);
log::warn!("failed to load theme `{}` - {}", theme_name, e);
e
})
.ok()
.filter(|theme| (true_color || theme.is_16_color()))
})
.unwrap_or_else(|| {
if true_color {
theme_loader.default()
} else {
theme_loader.base16_default()
{
Some(theme) => theme,
None => Application::default_theme(theme_loader.clone(), true_color),
}
});
}
None => Application::default_theme(theme_loader.clone(), true_color),
};
jharrilim marked this conversation as resolved.
Show resolved Hide resolved

let syn_loader_conf = user_syntax_loader().unwrap_or_else(|err| {
eprintln!("Bad language config: {}", err);
Expand All @@ -103,6 +101,7 @@ impl Application {
theme_loader.clone(),
syn_loader.clone(),
config.editor.clone(),
theme.name.clone(),
);

let editor_view = Box::new(ui::EditorView::new(std::mem::take(&mut config.keys)));
Expand Down Expand Up @@ -183,6 +182,14 @@ impl Application {
Ok(app)
}

fn default_theme(theme_loader: Arc<theme::Loader>, true_color: bool) -> theme::Theme {
if true_color {
theme_loader.default()
} else {
theme_loader.base16_default()
}
}

fn render(&mut self) {
let mut cx = crate::compositor::Context {
editor: &mut self.editor,
Expand Down
Loading