mirror of
https://github.com/extrawurst/gitui.git
synced 2024-11-23 03:32:30 +03:00
new popup paragraph helper
This commit is contained in:
parent
4caf8ddff9
commit
fa8070b1ba
@ -30,7 +30,7 @@ use tui::{
|
||||
backend::Backend,
|
||||
layout::Alignment,
|
||||
layout::Rect,
|
||||
widgets::{Block, Borders, Paragraph, Text},
|
||||
widgets::{Block, BorderType, Borders, Paragraph, Text},
|
||||
Frame,
|
||||
};
|
||||
|
||||
@ -165,3 +165,20 @@ where
|
||||
.block(Block::default().title(title).borders(Borders::ALL))
|
||||
.alignment(Alignment::Left)
|
||||
}
|
||||
|
||||
fn popup_paragraph<'a, 't, T>(
|
||||
title: &'a str,
|
||||
content: T,
|
||||
) -> Paragraph<'a, 't, T>
|
||||
where
|
||||
T: Iterator<Item = &'t Text<'t>>,
|
||||
{
|
||||
Paragraph::new(content)
|
||||
.block(
|
||||
Block::default()
|
||||
.title(title)
|
||||
.borders(Borders::ALL)
|
||||
.border_type(BorderType::Thick),
|
||||
)
|
||||
.alignment(Alignment::Left)
|
||||
}
|
||||
|
@ -1,9 +1,8 @@
|
||||
use super::{
|
||||
visibility_blocking, CommandBlocking, CommandInfo, Component,
|
||||
DrawableComponent,
|
||||
};
|
||||
use crate::{
|
||||
components::dialog_paragraph,
|
||||
components::{
|
||||
popup_paragraph, visibility_blocking, CommandBlocking,
|
||||
CommandInfo, Component, DrawableComponent,
|
||||
},
|
||||
queue::{Action, InternalEvent, Queue},
|
||||
strings, ui,
|
||||
ui::style::Theme,
|
||||
@ -43,10 +42,7 @@ impl DrawableComponent for ResetComponent {
|
||||
|
||||
let area = ui::centered_rect(30, 20, f.size());
|
||||
f.render_widget(Clear, area);
|
||||
f.render_widget(
|
||||
dialog_paragraph(title, txt.iter()),
|
||||
area,
|
||||
);
|
||||
f.render_widget(popup_paragraph(title, txt.iter()), area);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
@ -1,17 +1,20 @@
|
||||
use super::{
|
||||
visibility_blocking, CommandBlocking, CommandInfo, Component,
|
||||
DrawableComponent,
|
||||
use crate::{
|
||||
components::{
|
||||
popup_paragraph, visibility_blocking, CommandBlocking,
|
||||
CommandInfo, Component, DrawableComponent,
|
||||
},
|
||||
strings, ui,
|
||||
ui::style::Theme,
|
||||
};
|
||||
use crate::{strings, ui, ui::style::Theme};
|
||||
use anyhow::Result;
|
||||
use crossterm::event::{Event, KeyCode};
|
||||
use std::borrow::Cow;
|
||||
use strings::commands;
|
||||
use tui::{
|
||||
backend::Backend,
|
||||
layout::{Alignment, Rect},
|
||||
layout::Rect,
|
||||
style::Style,
|
||||
widgets::{Block, BorderType, Borders, Clear, Paragraph, Text},
|
||||
widgets::{Clear, Text},
|
||||
Frame,
|
||||
};
|
||||
|
||||
@ -73,14 +76,7 @@ impl DrawableComponent for TextInputComponent {
|
||||
let area = ui::centered_rect(60, 20, f.size());
|
||||
f.render_widget(Clear, area);
|
||||
f.render_widget(
|
||||
Paragraph::new(txt.iter())
|
||||
.block(
|
||||
Block::default()
|
||||
.title(self.title.as_str())
|
||||
.borders(Borders::ALL)
|
||||
.border_type(BorderType::Thick),
|
||||
)
|
||||
.alignment(Alignment::Left),
|
||||
popup_paragraph(self.title.as_str(), txt.iter()),
|
||||
area,
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user