#![allow(dead_code)]
use colored::Color;
use fuzzy_matcher::skim::SkimMatcherV2;
use once_cell::sync::OnceCell;
mod color;
mod core;
mod draw;
mod keymap;
mod mode;
mod query;
mod term;
#[allow(unused_macros)]
#[macro_use]
mod macros;
pub struct Item<T>
where
T: Send + Sync,
{
pub alias: String,
pub value: T,
pub(crate) score: Option<i64>,
pub(crate) matched_indices: Option<Vec<usize>>,
}
enum Mode {
Normal,
Query,
}
pub struct Menu<T>
where
T: Send + Sync,
{
is_pipe: bool,
enable_print_result: bool,
colorscheme: ColorScheme,
title: Option<String>,
item_list: Vec<Item<T>>,
mode: Mode,
cursor_abs_pos: (u16, u16),
max_row: u16,
selection_idx: u16,
selected: bool,
fuzzy_matcher: OnceCell<SkimMatcherV2>,
query: String,
matched_item_indices: Vec<usize>,
insert_idx: usize,
scroll_offset: u16,
max_height_percent: f32,
show_end_tag: bool,
rayon_pool: OnceCell<rayon::ThreadPool>,
}
#[derive(Clone, Copy)]
pub enum FontShape {
Italic = 1,
Bold = 1 << 1,
Underline = 1 << 2,
ItalicBold = 1 | 1 << 1,
ItalicUnderline = 1 | 1 << 2,
BoldUnderline = 1 << 1 | 1 << 2,
ItalicBoldUnderline = 1 | 1 << 1 | 1 << 2,
}
#[derive(Default, Clone, Copy)]
pub struct FontStyle {
shape: Option<FontShape>,
fg_color: Option<Color>,
bg_color: Option<Color>,
fg_color_256: Option<(u8, u8, u8)>,
bg_color_256: Option<(u8, u8, u8)>,
}
#[derive(Clone, Copy)]
pub struct ColorScheme {
title: FontStyle,
query: FontStyle,
items: FontStyle,
matched: FontStyle,
chosen_ln: FontStyle,
more_tag: FontStyle,
}