mirror of
https://github.com/gitui-org/gitui
synced 2026-05-24 09:28:21 +00:00
share theme instead of copying it all over the place
This commit is contained in:
parent
79b8bdfae2
commit
b899751c2b
21 changed files with 107 additions and 86 deletions
38
src/app.rs
38
src/app.rs
|
|
@ -12,12 +12,13 @@ use crate::{
|
||||||
queue::{Action, InternalEvent, NeedsUpdate, Queue},
|
queue::{Action, InternalEvent, NeedsUpdate, Queue},
|
||||||
strings,
|
strings,
|
||||||
tabs::{Revlog, StashList, Stashing, Status},
|
tabs::{Revlog, StashList, Stashing, Status},
|
||||||
ui::style::Theme,
|
ui::style::{SharedTheme, Theme},
|
||||||
};
|
};
|
||||||
use anyhow::{anyhow, Result};
|
use anyhow::{anyhow, Result};
|
||||||
use asyncgit::{sync, AsyncNotification, CWD};
|
use asyncgit::{sync, AsyncNotification, CWD};
|
||||||
use crossbeam_channel::Sender;
|
use crossbeam_channel::Sender;
|
||||||
use crossterm::event::{Event, KeyEvent};
|
use crossterm::event::{Event, KeyEvent};
|
||||||
|
use std::rc::Rc;
|
||||||
use strings::{commands, order};
|
use strings::{commands, order};
|
||||||
use tui::{
|
use tui::{
|
||||||
backend::Backend,
|
backend::Backend,
|
||||||
|
|
@ -43,7 +44,7 @@ pub struct App {
|
||||||
stashing_tab: Stashing,
|
stashing_tab: Stashing,
|
||||||
stashlist_tab: StashList,
|
stashlist_tab: StashList,
|
||||||
queue: Queue,
|
queue: Queue,
|
||||||
theme: Theme,
|
theme: SharedTheme,
|
||||||
}
|
}
|
||||||
|
|
||||||
// public interface
|
// public interface
|
||||||
|
|
@ -52,27 +53,36 @@ impl App {
|
||||||
pub fn new(sender: &Sender<AsyncNotification>) -> Self {
|
pub fn new(sender: &Sender<AsyncNotification>) -> Self {
|
||||||
let queue = Queue::default();
|
let queue = Queue::default();
|
||||||
|
|
||||||
let theme = Theme::init();
|
let theme = Rc::new(Box::new(Theme::init()));
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
reset: ResetComponent::new(queue.clone(), &theme),
|
reset: ResetComponent::new(queue.clone(), theme.clone()),
|
||||||
commit: CommitComponent::new(queue.clone(), &theme),
|
commit: CommitComponent::new(
|
||||||
|
queue.clone(),
|
||||||
|
theme.clone(),
|
||||||
|
),
|
||||||
stashmsg_popup: StashMsgComponent::new(
|
stashmsg_popup: StashMsgComponent::new(
|
||||||
queue.clone(),
|
queue.clone(),
|
||||||
&theme,
|
theme.clone(),
|
||||||
),
|
),
|
||||||
inspect_commit_popup: InspectCommitComponent::new(
|
inspect_commit_popup: InspectCommitComponent::new(
|
||||||
&queue, sender, &theme,
|
&queue,
|
||||||
|
sender,
|
||||||
|
theme.clone(),
|
||||||
),
|
),
|
||||||
do_quit: false,
|
do_quit: false,
|
||||||
cmdbar: CommandBar::new(&theme),
|
cmdbar: CommandBar::new(theme.clone()),
|
||||||
help: HelpComponent::new(&theme),
|
help: HelpComponent::new(theme.clone()),
|
||||||
msg: MsgComponent::new(&theme),
|
msg: MsgComponent::new(theme.clone()),
|
||||||
tab: 0,
|
tab: 0,
|
||||||
revlog: Revlog::new(&queue, sender, &theme),
|
revlog: Revlog::new(&queue, sender, theme.clone()),
|
||||||
status_tab: Status::new(sender, &queue, &theme),
|
status_tab: Status::new(sender, &queue, theme.clone()),
|
||||||
stashing_tab: Stashing::new(sender, &queue, &theme),
|
stashing_tab: Stashing::new(
|
||||||
stashlist_tab: StashList::new(&queue, &theme),
|
sender,
|
||||||
|
&queue,
|
||||||
|
theme.clone(),
|
||||||
|
),
|
||||||
|
stashlist_tab: StashList::new(&queue, theme.clone()),
|
||||||
queue,
|
queue,
|
||||||
theme,
|
theme,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
use crate::{components::CommandInfo, strings, ui::style::Theme};
|
use crate::{
|
||||||
|
components::CommandInfo, strings, ui::style::SharedTheme,
|
||||||
|
};
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
use tui::{
|
use tui::{
|
||||||
backend::Backend,
|
backend::Backend,
|
||||||
|
|
@ -24,7 +26,7 @@ struct Command {
|
||||||
pub struct CommandBar {
|
pub struct CommandBar {
|
||||||
draw_list: Vec<DrawListEntry>,
|
draw_list: Vec<DrawListEntry>,
|
||||||
cmd_infos: Vec<CommandInfo>,
|
cmd_infos: Vec<CommandInfo>,
|
||||||
theme: Theme,
|
theme: SharedTheme,
|
||||||
lines: u16,
|
lines: u16,
|
||||||
width: u16,
|
width: u16,
|
||||||
expandable: bool,
|
expandable: bool,
|
||||||
|
|
@ -34,11 +36,11 @@ pub struct CommandBar {
|
||||||
const MORE_WIDTH: u16 = 11;
|
const MORE_WIDTH: u16 = 11;
|
||||||
|
|
||||||
impl CommandBar {
|
impl CommandBar {
|
||||||
pub const fn new(theme: &Theme) -> Self {
|
pub const fn new(theme: SharedTheme) -> Self {
|
||||||
Self {
|
Self {
|
||||||
draw_list: Vec::new(),
|
draw_list: Vec::new(),
|
||||||
cmd_infos: Vec::new(),
|
cmd_infos: Vec::new(),
|
||||||
theme: *theme,
|
theme,
|
||||||
lines: 0,
|
lines: 0,
|
||||||
width: 0,
|
width: 0,
|
||||||
expandable: false,
|
expandable: false,
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ use crate::{
|
||||||
keys,
|
keys,
|
||||||
queue::{Action, InternalEvent, NeedsUpdate, Queue, ResetItem},
|
queue::{Action, InternalEvent, NeedsUpdate, Queue, ResetItem},
|
||||||
strings,
|
strings,
|
||||||
ui::style::Theme,
|
ui::style::SharedTheme,
|
||||||
};
|
};
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use asyncgit::{sync, StatusItem, StatusItemType, CWD};
|
use asyncgit::{sync, StatusItem, StatusItemType, CWD};
|
||||||
|
|
@ -48,7 +48,7 @@ impl ChangesComponent {
|
||||||
focus: bool,
|
focus: bool,
|
||||||
is_working_dir: bool,
|
is_working_dir: bool,
|
||||||
queue: Queue,
|
queue: Queue,
|
||||||
theme: &Theme,
|
theme: SharedTheme,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
title: title.into(),
|
title: title.into(),
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ use crate::{
|
||||||
keys,
|
keys,
|
||||||
queue::{InternalEvent, NeedsUpdate, Queue},
|
queue::{InternalEvent, NeedsUpdate, Queue},
|
||||||
strings,
|
strings,
|
||||||
ui::style::Theme,
|
ui::style::SharedTheme,
|
||||||
};
|
};
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use asyncgit::{
|
use asyncgit::{
|
||||||
|
|
@ -107,7 +107,7 @@ impl Component for CommitComponent {
|
||||||
|
|
||||||
impl CommitComponent {
|
impl CommitComponent {
|
||||||
///
|
///
|
||||||
pub fn new(queue: Queue, theme: &Theme) -> Self {
|
pub fn new(queue: Queue, theme: SharedTheme) -> Self {
|
||||||
Self {
|
Self {
|
||||||
queue,
|
queue,
|
||||||
amend: None,
|
amend: None,
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ use crate::{
|
||||||
CommandInfo, Component, DrawableComponent,
|
CommandInfo, Component, DrawableComponent,
|
||||||
},
|
},
|
||||||
strings,
|
strings,
|
||||||
ui::style::Theme,
|
ui::style::SharedTheme,
|
||||||
};
|
};
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use asyncgit::{
|
use asyncgit::{
|
||||||
|
|
@ -25,16 +25,16 @@ use tui::{
|
||||||
pub struct DetailsComponent {
|
pub struct DetailsComponent {
|
||||||
data: Option<CommitDetails>,
|
data: Option<CommitDetails>,
|
||||||
tags: Vec<String>,
|
tags: Vec<String>,
|
||||||
theme: Theme,
|
theme: SharedTheme,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DetailsComponent {
|
impl DetailsComponent {
|
||||||
///
|
///
|
||||||
pub const fn new(theme: &Theme) -> Self {
|
pub const fn new(theme: SharedTheme) -> Self {
|
||||||
Self {
|
Self {
|
||||||
data: None,
|
data: None,
|
||||||
tags: Vec::new(),
|
tags: Vec::new(),
|
||||||
theme: *theme,
|
theme: theme,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,9 @@ use super::{
|
||||||
command_pump, event_pump, CommandBlocking, CommandInfo,
|
command_pump, event_pump, CommandBlocking, CommandInfo,
|
||||||
Component, DrawableComponent, FileTreeComponent,
|
Component, DrawableComponent, FileTreeComponent,
|
||||||
};
|
};
|
||||||
use crate::{accessors, queue::Queue, strings, ui::style::Theme};
|
use crate::{
|
||||||
|
accessors, queue::Queue, strings, ui::style::SharedTheme,
|
||||||
|
};
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use asyncgit::{
|
use asyncgit::{
|
||||||
sync::{CommitId, Tags},
|
sync::{CommitId, Tags},
|
||||||
|
|
@ -33,10 +35,10 @@ impl CommitDetailsComponent {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
queue: &Queue,
|
queue: &Queue,
|
||||||
sender: &Sender<AsyncNotification>,
|
sender: &Sender<AsyncNotification>,
|
||||||
theme: &Theme,
|
theme: SharedTheme,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
details: DetailsComponent::new(theme),
|
details: DetailsComponent::new(theme.clone()),
|
||||||
git_commit_files: AsyncCommitFiles::new(sender),
|
git_commit_files: AsyncCommitFiles::new(sender),
|
||||||
file_tree: FileTreeComponent::new(
|
file_tree: FileTreeComponent::new(
|
||||||
"",
|
"",
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ use crate::{
|
||||||
keys,
|
keys,
|
||||||
strings::commands,
|
strings::commands,
|
||||||
ui::calc_scroll_top,
|
ui::calc_scroll_top,
|
||||||
ui::style::Theme,
|
ui::style::{SharedTheme, Theme},
|
||||||
};
|
};
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use asyncgit::sync;
|
use asyncgit::sync;
|
||||||
|
|
@ -34,12 +34,12 @@ pub struct CommitList {
|
||||||
tags: Option<Tags>,
|
tags: Option<Tags>,
|
||||||
current_size: (u16, u16),
|
current_size: (u16, u16),
|
||||||
scroll_top: usize,
|
scroll_top: usize,
|
||||||
theme: Theme,
|
theme: SharedTheme,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CommitList {
|
impl CommitList {
|
||||||
///
|
///
|
||||||
pub fn new(title: &str, theme: &Theme) -> Self {
|
pub fn new(title: &str, theme: SharedTheme) -> Self {
|
||||||
Self {
|
Self {
|
||||||
items: ItemBatch::default(),
|
items: ItemBatch::default(),
|
||||||
selection: 0,
|
selection: 0,
|
||||||
|
|
@ -49,7 +49,7 @@ impl CommitList {
|
||||||
tags: None,
|
tags: None,
|
||||||
current_size: (0, 0),
|
current_size: (0, 0),
|
||||||
scroll_top: 0,
|
scroll_top: 0,
|
||||||
theme: *theme,
|
theme,
|
||||||
title: String::from(title),
|
title: String::from(title),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ use crate::{
|
||||||
keys,
|
keys,
|
||||||
queue::{Action, InternalEvent, NeedsUpdate, Queue, ResetItem},
|
queue::{Action, InternalEvent, NeedsUpdate, Queue, ResetItem},
|
||||||
strings,
|
strings,
|
||||||
ui::{calc_scroll_top, style::Theme},
|
ui::{calc_scroll_top, style::SharedTheme},
|
||||||
};
|
};
|
||||||
use asyncgit::{hash, sync, DiffLine, DiffLineType, FileDiff, CWD};
|
use asyncgit::{hash, sync, DiffLine, DiffLineType, FileDiff, CWD};
|
||||||
use crossterm::event::Event;
|
use crossterm::event::Event;
|
||||||
|
|
@ -37,12 +37,12 @@ pub struct DiffComponent {
|
||||||
current: Current,
|
current: Current,
|
||||||
scroll_top: usize,
|
scroll_top: usize,
|
||||||
queue: Option<Queue>,
|
queue: Option<Queue>,
|
||||||
theme: Theme,
|
theme: SharedTheme,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DiffComponent {
|
impl DiffComponent {
|
||||||
///
|
///
|
||||||
pub fn new(queue: Option<Queue>, theme: &Theme) -> Self {
|
pub fn new(queue: Option<Queue>, theme: SharedTheme) -> Self {
|
||||||
Self {
|
Self {
|
||||||
focused: false,
|
focused: false,
|
||||||
queue,
|
queue,
|
||||||
|
|
@ -52,7 +52,7 @@ impl DiffComponent {
|
||||||
current_size: (0, 0),
|
current_size: (0, 0),
|
||||||
selection: 0,
|
selection: 0,
|
||||||
scroll_top: 0,
|
scroll_top: 0,
|
||||||
theme: *theme,
|
theme: theme,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
///
|
///
|
||||||
|
|
@ -185,7 +185,7 @@ impl DiffComponent {
|
||||||
selection == line_cursor,
|
selection == line_cursor,
|
||||||
hunk_selected,
|
hunk_selected,
|
||||||
i == hunk_len as usize - 1,
|
i == hunk_len as usize - 1,
|
||||||
self.theme,
|
&self.theme,
|
||||||
);
|
);
|
||||||
lines_added += 1;
|
lines_added += 1;
|
||||||
}
|
}
|
||||||
|
|
@ -207,7 +207,7 @@ impl DiffComponent {
|
||||||
selected: bool,
|
selected: bool,
|
||||||
selected_hunk: bool,
|
selected_hunk: bool,
|
||||||
end_of_hunk: bool,
|
end_of_hunk: bool,
|
||||||
theme: Theme,
|
theme: &SharedTheme,
|
||||||
) {
|
) {
|
||||||
{
|
{
|
||||||
let style = theme.diff_hunk_marker(selected_hunk);
|
let style = theme.diff_hunk_marker(selected_hunk);
|
||||||
|
|
@ -506,7 +506,7 @@ mod tests {
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
Theme::default(),
|
&SharedTheme::default(),
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(text.len(), 2);
|
assert_eq!(text.len(), 2);
|
||||||
|
|
|
||||||
|
|
@ -10,9 +10,8 @@ use crate::{
|
||||||
keys,
|
keys,
|
||||||
queue::{InternalEvent, NeedsUpdate, Queue},
|
queue::{InternalEvent, NeedsUpdate, Queue},
|
||||||
strings, ui,
|
strings, ui,
|
||||||
ui::style::Theme,
|
ui::style::SharedTheme,
|
||||||
};
|
};
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use asyncgit::{hash, StatusItem, StatusItemType};
|
use asyncgit::{hash, StatusItem, StatusItemType};
|
||||||
use crossterm::event::Event;
|
use crossterm::event::Event;
|
||||||
|
|
@ -28,7 +27,7 @@ pub struct FileTreeComponent {
|
||||||
focused: bool,
|
focused: bool,
|
||||||
show_selection: bool,
|
show_selection: bool,
|
||||||
queue: Option<Queue>,
|
queue: Option<Queue>,
|
||||||
theme: Theme,
|
theme: SharedTheme,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FileTreeComponent {
|
impl FileTreeComponent {
|
||||||
|
|
@ -37,7 +36,7 @@ impl FileTreeComponent {
|
||||||
title: &str,
|
title: &str,
|
||||||
focus: bool,
|
focus: bool,
|
||||||
queue: Option<Queue>,
|
queue: Option<Queue>,
|
||||||
theme: &Theme,
|
theme: SharedTheme,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
title: title.to_string(),
|
title: title.to_string(),
|
||||||
|
|
@ -46,7 +45,7 @@ impl FileTreeComponent {
|
||||||
focused: focus,
|
focused: focus,
|
||||||
show_selection: focus,
|
show_selection: focus,
|
||||||
queue,
|
queue,
|
||||||
theme: *theme,
|
theme,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -133,7 +132,7 @@ impl FileTreeComponent {
|
||||||
item: &FileTreeItem,
|
item: &FileTreeItem,
|
||||||
width: u16,
|
width: u16,
|
||||||
selected: bool,
|
selected: bool,
|
||||||
theme: Theme,
|
theme: SharedTheme,
|
||||||
) -> Option<Text> {
|
) -> Option<Text> {
|
||||||
let indent_str = if item.info.indent == 0 {
|
let indent_str = if item.info.indent == 0 {
|
||||||
String::from("")
|
String::from("")
|
||||||
|
|
@ -243,7 +242,7 @@ impl DrawableComponent for FileTreeComponent {
|
||||||
.tree
|
.tree
|
||||||
.selection
|
.selection
|
||||||
.map_or(false, |e| e == idx),
|
.map_or(false, |e| e == idx),
|
||||||
self.theme,
|
self.theme.clone(),
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
@ -255,7 +254,7 @@ impl DrawableComponent for FileTreeComponent {
|
||||||
items,
|
items,
|
||||||
self.tree.selection.map(|idx| idx - selection_offset),
|
self.tree.selection.map(|idx| idx - selection_offset),
|
||||||
self.focused,
|
self.focused,
|
||||||
self.theme,
|
&self.theme,
|
||||||
);
|
);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ use super::{
|
||||||
visibility_blocking, CommandBlocking, CommandInfo, Component,
|
visibility_blocking, CommandBlocking, CommandInfo, Component,
|
||||||
DrawableComponent,
|
DrawableComponent,
|
||||||
};
|
};
|
||||||
use crate::{keys, strings, ui, ui::style::Theme, version::Version};
|
use crate::{keys, strings, ui, version::Version};
|
||||||
use asyncgit::hash;
|
use asyncgit::hash;
|
||||||
use crossterm::event::Event;
|
use crossterm::event::Event;
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
|
|
@ -17,13 +17,14 @@ use tui::{
|
||||||
};
|
};
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
|
use ui::style::SharedTheme;
|
||||||
|
|
||||||
///
|
///
|
||||||
pub struct HelpComponent {
|
pub struct HelpComponent {
|
||||||
cmds: Vec<CommandInfo>,
|
cmds: Vec<CommandInfo>,
|
||||||
visible: bool,
|
visible: bool,
|
||||||
selection: u16,
|
selection: u16,
|
||||||
theme: Theme,
|
theme: SharedTheme,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DrawableComponent for HelpComponent {
|
impl DrawableComponent for HelpComponent {
|
||||||
|
|
@ -158,12 +159,12 @@ impl Component for HelpComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HelpComponent {
|
impl HelpComponent {
|
||||||
pub const fn new(theme: &Theme) -> Self {
|
pub const fn new(theme: SharedTheme) -> Self {
|
||||||
Self {
|
Self {
|
||||||
cmds: vec![],
|
cmds: vec![],
|
||||||
visible: false,
|
visible: false,
|
||||||
selection: 0,
|
selection: 0,
|
||||||
theme: *theme,
|
theme,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
///
|
///
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ use super::{
|
||||||
DrawableComponent,
|
DrawableComponent,
|
||||||
};
|
};
|
||||||
use crate::{
|
use crate::{
|
||||||
accessors, keys, queue::Queue, strings, ui::style::Theme,
|
accessors, keys, queue::Queue, strings, ui::style::SharedTheme,
|
||||||
};
|
};
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use asyncgit::{
|
use asyncgit::{
|
||||||
|
|
@ -154,11 +154,13 @@ impl InspectCommitComponent {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
queue: &Queue,
|
queue: &Queue,
|
||||||
sender: &Sender<AsyncNotification>,
|
sender: &Sender<AsyncNotification>,
|
||||||
theme: &Theme,
|
theme: SharedTheme,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
details: CommitDetailsComponent::new(
|
details: CommitDetailsComponent::new(
|
||||||
queue, sender, theme,
|
queue,
|
||||||
|
sender,
|
||||||
|
theme.clone(),
|
||||||
),
|
),
|
||||||
diff: DiffComponent::new(None, theme),
|
diff: DiffComponent::new(None, theme),
|
||||||
commit_id: None,
|
commit_id: None,
|
||||||
|
|
|
||||||
|
|
@ -12,12 +12,12 @@ use tui::{
|
||||||
widgets::{Block, BorderType, Borders, Clear, Paragraph, Text},
|
widgets::{Block, BorderType, Borders, Clear, Paragraph, Text},
|
||||||
Frame,
|
Frame,
|
||||||
};
|
};
|
||||||
use ui::style::Theme;
|
use ui::style::SharedTheme;
|
||||||
|
|
||||||
pub struct MsgComponent {
|
pub struct MsgComponent {
|
||||||
msg: String,
|
msg: String,
|
||||||
visible: bool,
|
visible: bool,
|
||||||
theme: Theme,
|
theme: SharedTheme,
|
||||||
}
|
}
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
|
|
@ -97,11 +97,11 @@ impl Component for MsgComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MsgComponent {
|
impl MsgComponent {
|
||||||
pub const fn new(theme: &Theme) -> Self {
|
pub const fn new(theme: SharedTheme) -> Self {
|
||||||
Self {
|
Self {
|
||||||
msg: String::new(),
|
msg: String::new(),
|
||||||
visible: false,
|
visible: false,
|
||||||
theme: *theme,
|
theme,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
///
|
///
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ use crate::{
|
||||||
};
|
};
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use crossterm::event::{Event, KeyCode};
|
use crossterm::event::{Event, KeyCode};
|
||||||
use std::borrow::Cow;
|
use std::{borrow::Cow, rc::Rc};
|
||||||
use strings::commands;
|
use strings::commands;
|
||||||
use tui::{
|
use tui::{
|
||||||
backend::Backend,
|
backend::Backend,
|
||||||
|
|
@ -23,7 +23,7 @@ pub struct ResetComponent {
|
||||||
target: Option<Action>,
|
target: Option<Action>,
|
||||||
visible: bool,
|
visible: bool,
|
||||||
queue: Queue,
|
queue: Queue,
|
||||||
theme: Theme,
|
theme: Rc<Box<Theme>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DrawableComponent for ResetComponent {
|
impl DrawableComponent for ResetComponent {
|
||||||
|
|
@ -111,12 +111,12 @@ impl Component for ResetComponent {
|
||||||
|
|
||||||
impl ResetComponent {
|
impl ResetComponent {
|
||||||
///
|
///
|
||||||
pub fn new(queue: Queue, theme: &Theme) -> Self {
|
pub fn new(queue: Queue, theme: Rc<Box<Theme>>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
target: None,
|
target: None,
|
||||||
visible: false,
|
visible: false,
|
||||||
queue,
|
queue,
|
||||||
theme: *theme,
|
theme,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
///
|
///
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ use crate::{
|
||||||
queue::{InternalEvent, NeedsUpdate, Queue},
|
queue::{InternalEvent, NeedsUpdate, Queue},
|
||||||
strings,
|
strings,
|
||||||
tabs::StashingOptions,
|
tabs::StashingOptions,
|
||||||
ui::style::Theme,
|
ui::style::SharedTheme,
|
||||||
};
|
};
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use asyncgit::{sync, CWD};
|
use asyncgit::{sync, CWD};
|
||||||
|
|
@ -117,7 +117,7 @@ impl Component for StashMsgComponent {
|
||||||
|
|
||||||
impl StashMsgComponent {
|
impl StashMsgComponent {
|
||||||
///
|
///
|
||||||
pub fn new(queue: Queue, theme: &Theme) -> Self {
|
pub fn new(queue: Queue, theme: SharedTheme) -> Self {
|
||||||
Self {
|
Self {
|
||||||
options: StashingOptions::default(),
|
options: StashingOptions::default(),
|
||||||
queue,
|
queue,
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ use crate::{
|
||||||
CommandInfo, Component, DrawableComponent,
|
CommandInfo, Component, DrawableComponent,
|
||||||
},
|
},
|
||||||
strings, ui,
|
strings, ui,
|
||||||
ui::style::Theme,
|
|
||||||
};
|
};
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use crossterm::event::{Event, KeyCode, KeyModifiers};
|
use crossterm::event::{Event, KeyCode, KeyModifiers};
|
||||||
|
|
@ -16,6 +15,7 @@ use tui::{
|
||||||
widgets::{Clear, Text},
|
widgets::{Clear, Text},
|
||||||
Frame,
|
Frame,
|
||||||
};
|
};
|
||||||
|
use ui::style::SharedTheme;
|
||||||
|
|
||||||
/// primarily a subcomponet for user input of text (used in `CommitComponent`)
|
/// primarily a subcomponet for user input of text (used in `CommitComponent`)
|
||||||
pub struct TextInputComponent {
|
pub struct TextInputComponent {
|
||||||
|
|
@ -23,21 +23,21 @@ pub struct TextInputComponent {
|
||||||
default_msg: String,
|
default_msg: String,
|
||||||
msg: String,
|
msg: String,
|
||||||
visible: bool,
|
visible: bool,
|
||||||
theme: Theme,
|
theme: SharedTheme,
|
||||||
cursor_position: usize,
|
cursor_position: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TextInputComponent {
|
impl TextInputComponent {
|
||||||
///
|
///
|
||||||
pub fn new(
|
pub fn new(
|
||||||
theme: &Theme,
|
theme: SharedTheme,
|
||||||
title: &str,
|
title: &str,
|
||||||
default_msg: &str,
|
default_msg: &str,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
msg: String::default(),
|
msg: String::default(),
|
||||||
visible: false,
|
visible: false,
|
||||||
theme: *theme,
|
theme: theme,
|
||||||
title: title.to_string(),
|
title: title.to_string(),
|
||||||
default_msg: default_msg.to_string(),
|
default_msg: default_msg.to_string(),
|
||||||
cursor_position: 0,
|
cursor_position: 0,
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ use crate::{
|
||||||
keys,
|
keys,
|
||||||
queue::{InternalEvent, Queue},
|
queue::{InternalEvent, Queue},
|
||||||
strings,
|
strings,
|
||||||
ui::style::Theme,
|
ui::style::SharedTheme,
|
||||||
};
|
};
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use asyncgit::{sync, AsyncLog, AsyncNotification, FetchStatus, CWD};
|
use asyncgit::{sync, AsyncLog, AsyncNotification, FetchStatus, CWD};
|
||||||
|
|
@ -37,12 +37,14 @@ impl Revlog {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
queue: &Queue,
|
queue: &Queue,
|
||||||
sender: &Sender<AsyncNotification>,
|
sender: &Sender<AsyncNotification>,
|
||||||
theme: &Theme,
|
theme: SharedTheme,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
queue: queue.clone(),
|
queue: queue.clone(),
|
||||||
commit_details: CommitDetailsComponent::new(
|
commit_details: CommitDetailsComponent::new(
|
||||||
queue, sender, theme,
|
queue,
|
||||||
|
sender,
|
||||||
|
theme.clone(),
|
||||||
),
|
),
|
||||||
list: CommitList::new(strings::LOG_TITLE, theme),
|
list: CommitList::new(strings::LOG_TITLE, theme),
|
||||||
git_log: AsyncLog::new(sender),
|
git_log: AsyncLog::new(sender),
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ use crate::{
|
||||||
keys,
|
keys,
|
||||||
queue::{InternalEvent, Queue},
|
queue::{InternalEvent, Queue},
|
||||||
strings,
|
strings,
|
||||||
ui::style::Theme,
|
ui::style::SharedTheme,
|
||||||
};
|
};
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use asyncgit::{
|
use asyncgit::{
|
||||||
|
|
@ -34,7 +34,7 @@ pub struct Stashing {
|
||||||
index: FileTreeComponent,
|
index: FileTreeComponent,
|
||||||
visible: bool,
|
visible: bool,
|
||||||
options: StashingOptions,
|
options: StashingOptions,
|
||||||
theme: Theme,
|
theme: SharedTheme,
|
||||||
git_status: AsyncStatus,
|
git_status: AsyncStatus,
|
||||||
queue: Queue,
|
queue: Queue,
|
||||||
}
|
}
|
||||||
|
|
@ -46,21 +46,21 @@ impl Stashing {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
sender: &Sender<AsyncNotification>,
|
sender: &Sender<AsyncNotification>,
|
||||||
queue: &Queue,
|
queue: &Queue,
|
||||||
theme: &Theme,
|
theme: SharedTheme,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
index: FileTreeComponent::new(
|
index: FileTreeComponent::new(
|
||||||
strings::STASHING_FILES_TITLE,
|
strings::STASHING_FILES_TITLE,
|
||||||
true,
|
true,
|
||||||
Some(queue.clone()),
|
Some(queue.clone()),
|
||||||
theme,
|
theme.clone(),
|
||||||
),
|
),
|
||||||
visible: false,
|
visible: false,
|
||||||
options: StashingOptions {
|
options: StashingOptions {
|
||||||
keep_index: false,
|
keep_index: false,
|
||||||
stash_untracked: true,
|
stash_untracked: true,
|
||||||
},
|
},
|
||||||
theme: *theme,
|
theme,
|
||||||
git_status: AsyncStatus::new(sender.clone()),
|
git_status: AsyncStatus::new(sender.clone()),
|
||||||
queue: queue.clone(),
|
queue: queue.clone(),
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ use crate::{
|
||||||
keys,
|
keys,
|
||||||
queue::{Action, InternalEvent, Queue},
|
queue::{Action, InternalEvent, Queue},
|
||||||
strings,
|
strings,
|
||||||
ui::style::Theme,
|
ui::style::SharedTheme,
|
||||||
};
|
};
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use asyncgit::sync;
|
use asyncgit::sync;
|
||||||
|
|
@ -23,7 +23,7 @@ pub struct StashList {
|
||||||
|
|
||||||
impl StashList {
|
impl StashList {
|
||||||
///
|
///
|
||||||
pub fn new(queue: &Queue, theme: &Theme) -> Self {
|
pub fn new(queue: &Queue, theme: SharedTheme) -> Self {
|
||||||
Self {
|
Self {
|
||||||
visible: false,
|
visible: false,
|
||||||
list: CommitList::new(strings::STASHLIST_TITLE, theme),
|
list: CommitList::new(strings::STASHLIST_TITLE, theme),
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ use crate::{
|
||||||
keys,
|
keys,
|
||||||
queue::{InternalEvent, Queue, ResetItem},
|
queue::{InternalEvent, Queue, ResetItem},
|
||||||
strings,
|
strings,
|
||||||
ui::style::Theme,
|
ui::style::SharedTheme,
|
||||||
};
|
};
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use asyncgit::{
|
use asyncgit::{
|
||||||
|
|
@ -107,7 +107,7 @@ impl Status {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
sender: &Sender<AsyncNotification>,
|
sender: &Sender<AsyncNotification>,
|
||||||
queue: &Queue,
|
queue: &Queue,
|
||||||
theme: &Theme,
|
theme: SharedTheme,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
queue: queue.clone(),
|
queue: queue.clone(),
|
||||||
|
|
@ -119,14 +119,14 @@ impl Status {
|
||||||
true,
|
true,
|
||||||
true,
|
true,
|
||||||
queue.clone(),
|
queue.clone(),
|
||||||
theme,
|
theme.clone(),
|
||||||
),
|
),
|
||||||
index: ChangesComponent::new(
|
index: ChangesComponent::new(
|
||||||
strings::TITLE_INDEX,
|
strings::TITLE_INDEX,
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
queue.clone(),
|
queue.clone(),
|
||||||
theme,
|
theme.clone(),
|
||||||
),
|
),
|
||||||
diff: DiffComponent::new(Some(queue.clone()), theme),
|
diff: DiffComponent::new(Some(queue.clone()), theme),
|
||||||
git_diff: AsyncDiff::new(sender.clone()),
|
git_diff: AsyncDiff::new(sender.clone()),
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
mod scrolllist;
|
mod scrolllist;
|
||||||
pub mod style;
|
pub mod style;
|
||||||
use crate::ui::style::Theme;
|
|
||||||
use scrolllist::ScrollableList;
|
use scrolllist::ScrollableList;
|
||||||
|
use style::SharedTheme;
|
||||||
use tui::{
|
use tui::{
|
||||||
backend::Backend,
|
backend::Backend,
|
||||||
layout::{Constraint, Direction, Layout, Rect},
|
layout::{Constraint, Direction, Layout, Rect},
|
||||||
|
|
@ -76,7 +76,7 @@ pub fn draw_list<'b, B: Backend, L>(
|
||||||
items: L,
|
items: L,
|
||||||
select: Option<usize>,
|
select: Option<usize>,
|
||||||
selected: bool,
|
selected: bool,
|
||||||
theme: Theme,
|
theme: &SharedTheme,
|
||||||
) where
|
) where
|
||||||
L: Iterator<Item = Text<'b>>,
|
L: Iterator<Item = Text<'b>>,
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -10,10 +10,13 @@ use std::path::PathBuf;
|
||||||
use std::{
|
use std::{
|
||||||
fs::File,
|
fs::File,
|
||||||
io::{Read, Write},
|
io::{Read, Write},
|
||||||
|
rc::Rc,
|
||||||
};
|
};
|
||||||
use tui::style::{Color, Modifier, Style};
|
use tui::style::{Color, Modifier, Style};
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug, Clone, Copy)]
|
pub type SharedTheme = Rc<Box<Theme>>;
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
pub struct Theme {
|
pub struct Theme {
|
||||||
#[serde(with = "ColorDef")]
|
#[serde(with = "ColorDef")]
|
||||||
selected_tab: Color,
|
selected_tab: Color,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue