Skip to content

Commit

Permalink
Finish merging with upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
melody-rs committed Mar 25, 2024
1 parent e3cd88b commit 4712322
Show file tree
Hide file tree
Showing 8 changed files with 193 additions and 193 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
129 changes: 0 additions & 129 deletions crates/config/src/terminal/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,126 +57,6 @@ impl Default for Config {
}
}

// pub struct ConfigUi {
// font_family: FontFamily,
// font_size: f32,
// }

// #[derive(PartialEq, Eq)]
// #[derive(strum::EnumIter, strum::Display)]
// enum FontFamily {
// Proportional,
// Monospace,
// Custom(String),
// }

// impl ConfigUi {
// pub fn new(config: &Config) -> Self {
// Self {
// font_family: match &config.font.family {
// egui::FontFamily::Monospace => FontFamily::Monospace,
// egui::FontFamily::Proportional => FontFamily::Proportional,
// egui::FontFamily::Name(n) => FontFamily::Custom(n.to_string()),
// },
// font_size: config.font.size,
// }
// }

// pub fn ui(&mut self, config: &mut Config, ui: &mut egui::Ui) {
// ui.horizontal(|ui| {
// ui.label("Initial terminal size:");

// egui::DragValue::new(&mut config.initial_size.0)
// .clamp_range(1..=999)
// .ui(ui);
// ui.label("column(s)");

// egui::DragValue::new(&mut config.initial_size.1)
// .clamp_range(1..=999)
// .ui(ui);
// ui.label("rows(s)");
// });

// ui.horizontal(|ui| {
// ui.label("Font family");
// luminol_components::EnumMenuButton::new(
// &mut self.font_family,
// "luminol_term_config_ui_font_family",
// )
// .ui(ui);

// let is_custom = matches!(self.font_family, FontFamily::Custom(_));
// ui.add_enabled_ui(is_custom, |ui| {
// let mut dummy_text = String::new(); // this doesn't allocate so this is fine, for display purposes

// let text = match &mut self.font_family {
// FontFamily::Custom(t) => t,
// _ => &mut dummy_text,
// };
// ui.text_edit_singleline(text);
// });

// ui.label("Font size");
// egui::DragValue::new(&mut self.font_size)
// .clamp_range(1..=80)
// .update_while_editing(false)
// .ui(ui);

// if ui.button("Apply").clicked() {
// config.font.family = match &self.font_family {
// FontFamily::Monospace => egui::FontFamily::Monospace,
// FontFamily::Proportional => egui::FontFamily::Proportional,
// FontFamily::Custom(name) => egui::FontFamily::Name(name.as_str().into()), // FIXME doesn't properly handle missing fonts
// };
// config.font.size = self.font_size;
// }
// });

// luminol_components::Field::new(
// "Cursor blinking",
// luminol_components::EnumComboBox::new(
// "luminol_term_config_ui_cursor_blinking",
// &mut config.cursor_blinking,
// )
// .max_width(12.),
// )
// .ui(ui);

// ui.add_space(6.);
// ui.label("Ui colors");
// ui.separator();

// ui.columns(2, |cols| {
// let [left, right] = cols else {
// unreachable!();
// };

// left.label("Cursor");
// let mut arr = color_to_rgb(config.theme.cursor_color);
// left.color_edit_button_srgb(&mut arr);
// config.theme.cursor_color = color_from_rgb(arr);

// right.label("Background");
// let mut arr = color_to_rgb(config.theme.background_color);
// right.color_edit_button_srgb(&mut arr);
// config.theme.background_color = color_from_rgb(arr);
// });

// ui.add_space(6.);
// ui.label("Pallette");

// for colors in config.theme.color_pallette.chunks_mut(8) {
// ui.horizontal(|ui| {
// for color in colors {
// let mut arr = color_to_rgb(*color);
// ui.color_edit_button_srgb(&mut arr);
// *color = color_from_rgb(arr);
// }
// });
// }
// }
// }

impl Config {
pub fn default_font() -> egui::FontId {
egui::FontId {
Expand All @@ -185,12 +65,3 @@ impl Config {
}
}
}

// fn color_to_rgb(color: egui::Color32) -> [u8; 3] {
// let [r, g, b, _] = color.to_array();
// [r, g, b]
// }

// fn color_from_rgb([r, g, b]: [u8; 3]) -> egui::Color32 {
// egui::Color32::from_rgb(r, g, b)
// }
20 changes: 20 additions & 0 deletions crates/proc-macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,23 @@ pub fn include_asset(input: TokenStream) -> TokenStream {
};
tokens.into()
}

#[proc_macro]
pub fn include_asset_str(input: TokenStream) -> TokenStream {
let path: syn::LitStr = syn::parse(input).expect("Not a string literal");
let path = path.value();

// asset path
let path = path.strip_prefix("assets/").unwrap_or(&path);

let assets_path = std::env::var("LUMINOL_ASSETS_PATH").expect("luminol asset path not present");
let assets_path = std::path::PathBuf::from(assets_path);

let asset_path = assets_path.join(path);
let asset_path_str = asset_path.to_string_lossy();

let tokens = quote::quote! {
include_str!(#asset_path_str)
};
tokens.into()
}
Loading

0 comments on commit 4712322

Please sign in to comment.