Skip to content

Commit

Permalink
feat(ui): Proof-of-concept for loading themes
Browse files Browse the repository at this point in the history
  • Loading branch information
Sigmanificient committed Jan 3, 2025
1 parent b30704b commit d8dd5c2
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions src/usecase/tui/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,23 @@ fn render_preview_block(model: &SelectCommandState, f: &mut Frame, chunk: ratatu

let lines = {
match (selecting_command, start_index_and_end_index, command_row_index) {
(Some(_), Some((start_index, _)), Some(command_row_index)) => {
(Some(cmd), Some((start_index, _)), Some(command_row_index)) => {
let ss = SyntaxSet::load_defaults_newlines();
// HACK: `ml` is specified intentionally because it highlights `Makefile` and `json` files in a good way.(No unnecessary background color)
// lua, hs: `-- .*` is highlighted (but URL is highlighted with background color))
// md: no background color, but highlighted words are not so many
let syntax = ss.find_syntax_by_extension("ml").unwrap();
let theme = &mut ThemeSet::load_defaults().themes["base16-ocean.dark"].clone();

let mut ts = ThemeSet::load_defaults();
ts.add_from_folder("./").unwrap();

use crate::model::runner_type::RunnerType;

let file_extension = match cmd.runner_type {
RunnerType::Make => "mk",
RunnerType::Just => "just",
RunnerType::JsPackageManager(_) => "json"
};

let theme = &mut ts.themes["OneHalfDark"].clone();
let syntax = ss.find_syntax_by_extension(file_extension)
.unwrap_or_else(|| ss.find_syntax_plain_text());

let mut lines = vec![];
for (index, line) in source_lines.iter().enumerate() {
Expand Down

0 comments on commit d8dd5c2

Please sign in to comment.