mirror of
https://github.com/extrawurst/gitui.git
synced 2024-12-28 03:22:51 +03:00
make msgbox error msgs only for now
This commit is contained in:
parent
25c07a839c
commit
f03a1ac611
@ -56,7 +56,7 @@ impl App {
|
||||
do_quit: false,
|
||||
current_commands: Vec::new(),
|
||||
help: HelpComponent::new(&theme),
|
||||
msg: MsgComponent::default(),
|
||||
msg: MsgComponent::new(&theme),
|
||||
tab: 0,
|
||||
revlog: Revlog::new(&sender, &theme),
|
||||
status_tab: Status::new(&sender, &queue, &theme),
|
||||
@ -263,7 +263,7 @@ impl App {
|
||||
}
|
||||
}
|
||||
}
|
||||
InternalEvent::ShowMsg(msg) => {
|
||||
InternalEvent::ShowErrorMsg(msg) => {
|
||||
self.msg.show_msg(msg.as_str());
|
||||
flags.insert(NeedsUpdate::ALL);
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ impl CommitComponent {
|
||||
{
|
||||
error!("commit-msg hook error: {}", e);
|
||||
self.queue.borrow_mut().push_back(
|
||||
InternalEvent::ShowMsg(format!(
|
||||
InternalEvent::ShowErrorMsg(format!(
|
||||
"commit-msg hook error:\n{}",
|
||||
e
|
||||
)),
|
||||
@ -138,7 +138,7 @@ impl CommitComponent {
|
||||
if let Err(e) = sync::commit(CWD, &self.msg) {
|
||||
error!("commit error: {}", &e);
|
||||
self.queue.borrow_mut().push_back(
|
||||
InternalEvent::ShowMsg(format!(
|
||||
InternalEvent::ShowErrorMsg(format!(
|
||||
"commit failed:\n{}",
|
||||
&e
|
||||
)),
|
||||
@ -151,7 +151,7 @@ impl CommitComponent {
|
||||
{
|
||||
error!("post-commit hook error: {}", e);
|
||||
self.queue.borrow_mut().push_back(
|
||||
InternalEvent::ShowMsg(format!(
|
||||
InternalEvent::ShowErrorMsg(format!(
|
||||
"post-commit hook error:\n{}",
|
||||
e
|
||||
)),
|
||||
|
@ -2,36 +2,45 @@ use super::{
|
||||
visibility_blocking, CommandBlocking, CommandInfo, Component,
|
||||
DrawableComponent,
|
||||
};
|
||||
use crate::{components::dialog_paragraph, keys, strings, ui};
|
||||
use crate::{keys, strings, ui};
|
||||
use crossterm::event::Event;
|
||||
use std::borrow::Cow;
|
||||
use strings::commands;
|
||||
use tui::{
|
||||
backend::Backend,
|
||||
layout::Rect,
|
||||
widgets::{Clear, Text},
|
||||
layout::{Alignment, Rect},
|
||||
widgets::{Block, Borders, Clear, Paragraph, Text},
|
||||
Frame,
|
||||
};
|
||||
use ui::style::Theme;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct MsgComponent {
|
||||
msg: String,
|
||||
visible: bool,
|
||||
theme: Theme,
|
||||
}
|
||||
|
||||
impl DrawableComponent for MsgComponent {
|
||||
fn draw<B: Backend>(&mut self, f: &mut Frame<B>, _rect: Rect) {
|
||||
if self.visible {
|
||||
let txt = vec![Text::Raw(Cow::from(self.msg.as_str()))];
|
||||
|
||||
let area = ui::centered_rect_absolute(65, 25, f.size());
|
||||
f.render_widget(Clear, area);
|
||||
f.render_widget(
|
||||
dialog_paragraph(strings::MSG_TITLE, txt.iter())
|
||||
.wrap(true),
|
||||
area,
|
||||
);
|
||||
if !self.visible {
|
||||
return;
|
||||
}
|
||||
let txt = vec![Text::Raw(Cow::from(self.msg.as_str()))];
|
||||
|
||||
let area = ui::centered_rect_absolute(65, 25, f.size());
|
||||
f.render_widget(Clear, area);
|
||||
f.render_widget(
|
||||
Paragraph::new(txt.iter())
|
||||
.block(
|
||||
Block::default()
|
||||
.title(strings::MSG_TITLE_ERROR)
|
||||
.title_style(self.theme.text_danger())
|
||||
.borders(Borders::ALL),
|
||||
)
|
||||
.alignment(Alignment::Left)
|
||||
.wrap(true),
|
||||
area,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -78,6 +87,13 @@ impl Component for MsgComponent {
|
||||
}
|
||||
|
||||
impl MsgComponent {
|
||||
pub fn new(theme: &Theme) -> Self {
|
||||
Self {
|
||||
msg: String::new(),
|
||||
visible: false,
|
||||
theme: *theme,
|
||||
}
|
||||
}
|
||||
///
|
||||
pub fn show_msg(&mut self, msg: &str) {
|
||||
self.msg = msg.to_string();
|
||||
|
@ -30,7 +30,7 @@ pub enum InternalEvent {
|
||||
///
|
||||
AddHunk(u64),
|
||||
///
|
||||
ShowMsg(String),
|
||||
ShowErrorMsg(String),
|
||||
///
|
||||
Update(NeedsUpdate),
|
||||
///
|
||||
|
@ -8,7 +8,7 @@ pub static TAB_DIVIDER: &str = " | ";
|
||||
|
||||
pub static CMD_SPLITTER: &str = " ";
|
||||
|
||||
pub static MSG_TITLE: &str = "Info";
|
||||
pub static MSG_TITLE_ERROR: &str = "Error";
|
||||
pub static COMMIT_TITLE: &str = "Commit";
|
||||
pub static COMMIT_MSG: &str = "type commit message..";
|
||||
pub static RESET_TITLE: &str = "Reset";
|
||||
|
@ -139,7 +139,7 @@ impl Theme {
|
||||
}
|
||||
|
||||
pub fn text_danger(&self) -> Style {
|
||||
Style::default().fg(self.diff_file_removed)
|
||||
Style::default().fg(self.diff_line_delete)
|
||||
}
|
||||
|
||||
pub fn toolbar(&self, enabled: bool) -> Style {
|
||||
|
Loading…
Reference in New Issue
Block a user