Skip to content

Commit

Permalink
text within textarea is bugged to always be black until new cursive r…
Browse files Browse the repository at this point in the history
…elease
  • Loading branch information
Redhawk18 committed Sep 29, 2023
1 parent 6bd536f commit e04f0f3
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 4 deletions.
4 changes: 2 additions & 2 deletions tui/src/theme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub fn theme(siv: &Cursive) -> Theme {
theme.palette[PaletteColor::Background] = to_color(palette.background.default);
theme.palette[PaletteColor::Highlight] = to_color(palette.accent.default);
theme.palette[PaletteColor::HighlightInactive] = to_color(palette.secondary.default);
theme.palette[PaletteColor::HighlightText] = to_color(palette.background.default);
theme.palette[PaletteColor::HighlightText] = to_color(palette.text.default);
theme.palette[PaletteColor::Primary] = to_color(palette.text.default);
theme.palette[PaletteColor::Secondary] = to_color(palette.text.default);
theme.palette[PaletteColor::Shadow] = to_color(palette.text.default);
Expand All @@ -27,7 +27,7 @@ pub fn theme(siv: &Cursive) -> Theme {
theme
}

fn to_color(rgb: Rgb) -> Color {
pub fn to_color(rgb: Rgb) -> Color {
Color::Rgb(
(rgb.red * 255.0) as u8,
(rgb.green * 255.0) as u8,
Expand Down
2 changes: 2 additions & 0 deletions tui/src/views/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
mod menu_bar;
mod tab_bar;
mod text_area;

pub use menu_bar::menu_bar;
pub use tab_bar::tab_bar;
pub use text_area::text_area;
12 changes: 10 additions & 2 deletions tui/src/views/tab_bar.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
use cursive::{view::{Nameable, Resizable}, views::{TextView, TextArea, PaddedView}, Cursive};
use crate::views::text_area;

use cursive::{
view::{Nameable, Resizable},
views::{PaddedView, TextView},
Cursive,
};
use cursive_tabs::TabPanel;

pub fn tab_bar(siv: &mut Cursive) {
let panel = TabPanel::new()
.with_tab(TextView::new("This is the first view!").with_name("First"))
.with_tab(TextView::new("This is the second view!").with_name("Second"))
.with_tab(PaddedView::lrtb(1, 1, 1, 1, TextArea::new()).with_name("4"));
.with_tab(
PaddedView::lrtb(1, 1, 1, 1, text_area(siv.current_theme().clone())).with_name("4"),
);

siv.add_layer(panel.full_screen());
}
22 changes: 22 additions & 0 deletions tui/src/views/text_area.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
use crate::theme::to_color;

use blaze_core::colors::Palette;
use cursive::{
theme::{PaletteColor, Theme},
views::{TextArea, ThemedView},
};

pub fn text_area(theme: Theme) -> ThemedView<TextArea> {
ThemedView::new(custom_theme(theme), TextArea::new())
}

fn custom_theme(current_theme: Theme) -> Theme {
let mut theme = current_theme.clone();
let palette = Palette::new(false);

//theme.palette[PaletteColor::Secondary] = to_color(palette.secondary.default);
theme.palette[PaletteColor::Secondary] = to_color(palette.text.default); // TODO remove when cursive is 0.21
theme.palette[PaletteColor::View] = to_color(palette.text.default); //lib bug, the text should show up as white

theme
}

0 comments on commit e04f0f3

Please sign in to comment.