* Implement initial structs from spec * kdl configuration unmarshalling * typo text styling * remove is_selected toggle * incorporate new status bar ui into theming * improve test coverage of config behavior * tab bar correction * correct also compact bar * remove spacing between table columns * refactor table styling * use text_unselected.emphasis_1 for keygroup sep * fix tab bar more text * repair field flattening for theme * remove extra styling KDL node * update tests * updated selected text conversion * padding for header bar * minor corrections for existing themes * background handling * compact bar corrections * properly handle opaque method to activate background * update newer plugins to use styling struct * correct omission of selected state * fix: bold typeface for text elements * fix: fg -> white for list_unselected conversion * fix: emphasis and opacity handling for nested_list * correct stylings in the session-manager * fix emphases translation for table component * correct emphasis for run instructions * correct frame_highlight translation for old themes * provide missing implementation of frame_highlight * fencepost emphasis color names * Set a pseudo-None for frame_unselected in old theme conversion * correct alternating bg for simplified-ui * update snapshots * fix inner text padding and errorneous snapshots * suppress warning about deprecated usage of palette * remove unused import * feat(plugins): API to change floating pane coordinates (#3958) * basic functionality through the cli * added to plugin api * add display area and viewport size to TabInfo * fix tests and add new one * some cleanups * refactor: extract pane_id parsing logic * style(fmt): rustfmt * docs(changelog): floating pane coordinate chagne API * fix(tiled-panes): opening panes from the cli (#3963) * feat(plugins): add `PastedText` Event (#3962) * working with text paste * handle utf8 conversion error * feat(plugins): add PastedText Event * docs(changelog): plugins pasted text event * black for table opaque background * properly apply opacity to table * correct padding for explicit width ribbons * feat(plugins): Allow opening panes near plugin (#3966) * added command + terminal variants * added editor variant * style(fmt): rustfmt * docs(changelog): plugin apis to open panes near plugin * feat(plugins): send info about $EDITOR and $SHELL (#3971) * feat(plugins): send info about $EDITOR and $SHELL * fix(e2e): snapshot update * docs(changelog): plugin editor and shell info * fix(floating-panes): when changing coordinates, if a pane is not floating - make it floating (#3972) * fix(panes): when changing floating pane coordinates, if the pane is not floating, float it * style(fmt): rustfmt * docs(changelog): floating pane coordinate fix * fix(break-pane): strip logical position when inserting pane to new tab (#3973) * docs(changelog): logical position fix * Optional frame_unselected theme * fixture with correct width to account for arrow padding * update snapshot and rustfmt --------- Co-authored-by: Aram Drevekenin <aram@poor.dev>
92 lines
3.3 KiB
Rust
92 lines
3.3 KiB
Rust
use crate::{Screen, WIDTH_BREAKPOINTS};
|
|
use zellij_tile::prelude::*;
|
|
|
|
pub fn top_tab_menu(cols: usize, current_screen: &Screen, colors: &Styling) {
|
|
let background = colors.text_unselected.background;
|
|
let bg_color = match background {
|
|
PaletteColor::Rgb((r, g, b)) => format!("\u{1b}[48;2;{};{};{}m\u{1b}[0K", r, g, b),
|
|
PaletteColor::EightBit(color) => format!("\u{1b}[48;5;{}m\u{1b}[0K", color),
|
|
};
|
|
let first_ribbon_text_long = "Rebind leader keys";
|
|
let second_ribbon_text_long = "Change mode behavior";
|
|
let first_ribbon_text_short = "Rebind keys";
|
|
let second_ribbon_text_short = "Mode behavior";
|
|
let (first_ribbon_is_selected, second_ribbon_is_selected) = match current_screen {
|
|
Screen::RebindLeaders(_) => (true, false),
|
|
Screen::Presets(_) => (false, true),
|
|
};
|
|
let (first_ribbon_text, second_ribbon_text, starting_positions) = if cols
|
|
>= first_ribbon_text_long.chars().count() + second_ribbon_text_long.chars().count() + 14
|
|
{
|
|
(first_ribbon_text_long, second_ribbon_text_long, (6, 28))
|
|
} else {
|
|
(first_ribbon_text_short, second_ribbon_text_short, (6, 21))
|
|
};
|
|
let mut first_ribbon = Text::new(first_ribbon_text);
|
|
let mut second_ribbon = Text::new(second_ribbon_text);
|
|
if first_ribbon_is_selected {
|
|
first_ribbon = first_ribbon.selected();
|
|
}
|
|
if second_ribbon_is_selected {
|
|
second_ribbon = second_ribbon.selected();
|
|
}
|
|
let switch_key = Text::new("<TAB>").color_range(3, ..).opaque();
|
|
print_text_with_coordinates(switch_key, 0, 0, None, None);
|
|
print!("\u{1b}[{};{}H{}", 0, starting_positions.0, bg_color);
|
|
print_ribbon_with_coordinates(first_ribbon, starting_positions.0, 0, None, None);
|
|
print_ribbon_with_coordinates(second_ribbon, starting_positions.1, 0, None, None);
|
|
}
|
|
|
|
pub fn back_to_presets() {
|
|
let esc = Text::new("<ESC>").color_range(3, ..);
|
|
let first_ribbon = Text::new("Back to Presets");
|
|
print_text_with_coordinates(esc, 0, 0, None, None);
|
|
print_ribbon_with_coordinates(first_ribbon, 6, 0, None, None);
|
|
}
|
|
|
|
pub fn info_line(
|
|
rows: usize,
|
|
cols: usize,
|
|
ui_size: usize,
|
|
notification: &Option<String>,
|
|
warning_text: &Option<String>,
|
|
widths: Option<(usize, usize, usize)>,
|
|
) {
|
|
let top_coordinates = if rows > 14 {
|
|
(rows.saturating_sub(ui_size) / 2) + 14
|
|
} else {
|
|
(rows.saturating_sub(ui_size) / 2) + 10
|
|
};
|
|
let left_padding = if let Some(widths) = widths {
|
|
if cols >= widths.0 {
|
|
cols.saturating_sub(widths.0) / 2
|
|
} else if cols >= widths.1 {
|
|
cols.saturating_sub(widths.1) / 2
|
|
} else {
|
|
cols.saturating_sub(widths.2) / 2
|
|
}
|
|
} else {
|
|
if cols >= WIDTH_BREAKPOINTS.0 {
|
|
cols.saturating_sub(WIDTH_BREAKPOINTS.0) / 2
|
|
} else {
|
|
cols.saturating_sub(WIDTH_BREAKPOINTS.1) / 2
|
|
}
|
|
};
|
|
if let Some(notification) = ¬ification {
|
|
print_text_with_coordinates(
|
|
Text::new(notification).color_range(3, ..),
|
|
left_padding,
|
|
top_coordinates,
|
|
None,
|
|
None,
|
|
);
|
|
} else if let Some(warning_text) = warning_text {
|
|
print_text_with_coordinates(
|
|
Text::new(warning_text).color_range(3, ..),
|
|
left_padding,
|
|
top_coordinates,
|
|
None,
|
|
None,
|
|
);
|
|
}
|
|
}
|