mirror of
https://github.com/extrawurst/gitui.git
synced 2024-11-26 12:35:14 +03:00
command list concept
This commit is contained in:
parent
ecc3d10fdd
commit
1107d873d1
35
src/app.rs
35
src/app.rs
@ -4,7 +4,7 @@ use crate::{
|
|||||||
git_utils::{self, Diff, DiffLine, DiffLineType},
|
git_utils::{self, Diff, DiffLine, DiffLineType},
|
||||||
};
|
};
|
||||||
use crossterm::event::{Event, KeyCode, MouseEvent};
|
use crossterm::event::{Event, KeyCode, MouseEvent};
|
||||||
use std::{cmp, path::Path};
|
use std::{borrow::Cow, cmp, path::Path};
|
||||||
use tui::{
|
use tui::{
|
||||||
backend::Backend,
|
backend::Backend,
|
||||||
layout::{Alignment, Constraint, Direction, Layout, Rect},
|
layout::{Alignment, Constraint, Direction, Layout, Rect},
|
||||||
@ -63,9 +63,16 @@ impl App {
|
|||||||
|
|
||||||
///
|
///
|
||||||
pub fn draw<B: Backend>(&self, f: &mut Frame<B>) {
|
pub fn draw<B: Backend>(&self, f: &mut Frame<B>) {
|
||||||
let chunks_tabs = Layout::default()
|
let chunks_main = Layout::default()
|
||||||
.direction(Direction::Vertical)
|
.direction(Direction::Vertical)
|
||||||
.constraints([Constraint::Length(2), Constraint::Min(2)].as_ref())
|
.constraints(
|
||||||
|
[
|
||||||
|
Constraint::Length(2),
|
||||||
|
Constraint::Min(2),
|
||||||
|
Constraint::Length(1),
|
||||||
|
]
|
||||||
|
.as_ref(),
|
||||||
|
)
|
||||||
.split(f.size());
|
.split(f.size());
|
||||||
|
|
||||||
Tabs::default()
|
Tabs::default()
|
||||||
@ -74,12 +81,12 @@ impl App {
|
|||||||
.style(Style::default().fg(Color::White))
|
.style(Style::default().fg(Color::White))
|
||||||
.highlight_style(Style::default().fg(Color::Yellow))
|
.highlight_style(Style::default().fg(Color::Yellow))
|
||||||
.divider(" | ")
|
.divider(" | ")
|
||||||
.render(f, chunks_tabs[0]);
|
.render(f, chunks_main[0]);
|
||||||
|
|
||||||
let chunks = Layout::default()
|
let chunks = Layout::default()
|
||||||
.direction(Direction::Horizontal)
|
.direction(Direction::Horizontal)
|
||||||
.constraints([Constraint::Percentage(50), Constraint::Percentage(50)].as_ref())
|
.constraints([Constraint::Percentage(50), Constraint::Percentage(50)].as_ref())
|
||||||
.split(chunks_tabs[1]);
|
.split(chunks_main[1]);
|
||||||
|
|
||||||
let left_chunks = Layout::default()
|
let left_chunks = Layout::default()
|
||||||
.direction(Direction::Vertical)
|
.direction(Direction::Vertical)
|
||||||
@ -137,6 +144,24 @@ impl App {
|
|||||||
.scroll(self.offset)
|
.scroll(self.offset)
|
||||||
.render(f, chunks[1]);
|
.render(f, chunks[1]);
|
||||||
|
|
||||||
|
// commands
|
||||||
|
{
|
||||||
|
let t1 = Text::Styled(
|
||||||
|
Cow::from("Commit "),
|
||||||
|
Style::default().fg(Color::White).bg(Color::Blue),
|
||||||
|
);
|
||||||
|
let t2 = Text::Styled(
|
||||||
|
Cow::from("Help"),
|
||||||
|
Style::default()
|
||||||
|
.fg(Color::Red)
|
||||||
|
.bg(Color::Blue)
|
||||||
|
.modifier(Modifier::BOLD),
|
||||||
|
);
|
||||||
|
Paragraph::new(vec![t1, t2].iter())
|
||||||
|
.alignment(Alignment::Left)
|
||||||
|
.render(f, chunks_main[2]);
|
||||||
|
}
|
||||||
|
|
||||||
if self.show_popup {
|
if self.show_popup {
|
||||||
let txt = [Text::Raw(
|
let txt = [Text::Raw(
|
||||||
"test lorem ipsum dolorem test lorem ipsum dolorem"
|
"test lorem ipsum dolorem test lorem ipsum dolorem"
|
||||||
|
Loading…
Reference in New Issue
Block a user