mirror of
https://github.com/gitui-org/gitui
synced 2026-05-24 09:28:21 +00:00
show branchname in commit mssage box (closes #529)
This commit is contained in:
parent
5cf9986df9
commit
e3bb51b277
4 changed files with 47 additions and 3 deletions
|
|
@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||

|

|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
- don't hide branch name while in commit dialog ([#529](https://github.com/extrawurst/gitui/issues/529))
|
||||||
- don't discard commit message without confirmation ([#530](https://github.com/extrawurst/gitui/issues/530))
|
- don't discard commit message without confirmation ([#530](https://github.com/extrawurst/gitui/issues/530))
|
||||||
- compilation broken on freebsd ([#461](https://github.com/extrawurst/gitui/issues/461))
|
- compilation broken on freebsd ([#461](https://github.com/extrawurst/gitui/issues/461))
|
||||||
- don’t fail if `user.name` is not set [[@cruessler](https://github.com/cruessler)] ([#79](https://github.com/extrawurst/gitui/issues/79)) ([#228](https://github.com/extrawurst/gitui/issues/228))
|
- don’t fail if `user.name` is not set [[@cruessler](https://github.com/cruessler)] ([#79](https://github.com/extrawurst/gitui/issues/79)) ([#228](https://github.com/extrawurst/gitui/issues/228))
|
||||||
|
|
|
||||||
|
|
@ -278,6 +278,7 @@ impl App {
|
||||||
pub fn update(&mut self) -> Result<()> {
|
pub fn update(&mut self) -> Result<()> {
|
||||||
log::trace!("update");
|
log::trace!("update");
|
||||||
|
|
||||||
|
self.commit.update()?;
|
||||||
self.status_tab.update()?;
|
self.status_tab.update()?;
|
||||||
self.revlog.update()?;
|
self.revlog.update()?;
|
||||||
self.stashing_tab.update()?;
|
self.stashing_tab.update()?;
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ use crate::{
|
||||||
};
|
};
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use asyncgit::{
|
use asyncgit::{
|
||||||
|
cached,
|
||||||
sync::{self, CommitId, HookResult},
|
sync::{self, CommitId, HookResult},
|
||||||
CWD,
|
CWD,
|
||||||
};
|
};
|
||||||
|
|
@ -21,13 +22,19 @@ use std::{
|
||||||
io::{Read, Write},
|
io::{Read, Write},
|
||||||
path::PathBuf,
|
path::PathBuf,
|
||||||
};
|
};
|
||||||
use tui::{backend::Backend, layout::Rect, Frame};
|
use tui::{
|
||||||
|
backend::Backend,
|
||||||
|
layout::{Alignment, Rect},
|
||||||
|
widgets::Paragraph,
|
||||||
|
Frame,
|
||||||
|
};
|
||||||
|
|
||||||
pub struct CommitComponent {
|
pub struct CommitComponent {
|
||||||
input: TextInputComponent,
|
input: TextInputComponent,
|
||||||
amend: Option<CommitId>,
|
amend: Option<CommitId>,
|
||||||
queue: Queue,
|
queue: Queue,
|
||||||
key_config: SharedKeyConfig,
|
key_config: SharedKeyConfig,
|
||||||
|
git_branch_name: cached::BranchName,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DrawableComponent for CommitComponent {
|
impl DrawableComponent for CommitComponent {
|
||||||
|
|
@ -36,7 +43,10 @@ impl DrawableComponent for CommitComponent {
|
||||||
f: &mut Frame<B>,
|
f: &mut Frame<B>,
|
||||||
rect: Rect,
|
rect: Rect,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
self.input.draw(f, rect)?;
|
if self.is_visible() {
|
||||||
|
self.input.draw(f, rect)?;
|
||||||
|
self.draw_branch_name(f);
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
@ -143,6 +153,29 @@ impl CommitComponent {
|
||||||
true,
|
true,
|
||||||
),
|
),
|
||||||
key_config,
|
key_config,
|
||||||
|
git_branch_name: cached::BranchName::new(CWD),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
pub fn update(&mut self) -> Result<()> {
|
||||||
|
self.git_branch_name.lookup().map(Some).unwrap_or(None);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn draw_branch_name<B: Backend>(&self, f: &mut Frame<B>) {
|
||||||
|
if let Some(name) = self.git_branch_name.last() {
|
||||||
|
let w = Paragraph::new(format!("{{{}}}", name))
|
||||||
|
.alignment(Alignment::Right);
|
||||||
|
|
||||||
|
let rect = {
|
||||||
|
let mut rect = self.input.get_area();
|
||||||
|
rect.height = 1;
|
||||||
|
rect.width = rect.width.saturating_sub(1);
|
||||||
|
rect
|
||||||
|
};
|
||||||
|
|
||||||
|
f.render_widget(w, rect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ use crate::{
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use crossterm::event::{Event, KeyCode, KeyModifiers};
|
use crossterm::event::{Event, KeyCode, KeyModifiers};
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use std::{collections::HashMap, ops::Range};
|
use std::{cell::Cell, collections::HashMap, ops::Range};
|
||||||
use tui::{
|
use tui::{
|
||||||
backend::Backend,
|
backend::Backend,
|
||||||
layout::{Alignment, Rect},
|
layout::{Alignment, Rect},
|
||||||
|
|
@ -39,6 +39,7 @@ pub struct TextInputComponent {
|
||||||
key_config: SharedKeyConfig,
|
key_config: SharedKeyConfig,
|
||||||
cursor_position: usize,
|
cursor_position: usize,
|
||||||
input_type: InputType,
|
input_type: InputType,
|
||||||
|
current_area: Cell<Rect>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TextInputComponent {
|
impl TextInputComponent {
|
||||||
|
|
@ -60,6 +61,7 @@ impl TextInputComponent {
|
||||||
default_msg: default_msg.to_string(),
|
default_msg: default_msg.to_string(),
|
||||||
cursor_position: 0,
|
cursor_position: 0,
|
||||||
input_type: InputType::Multiline,
|
input_type: InputType::Multiline,
|
||||||
|
current_area: Cell::new(Rect::default()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -82,6 +84,11 @@ impl TextInputComponent {
|
||||||
&self.msg
|
&self.msg
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// screen area (last time we got drawn)
|
||||||
|
pub fn get_area(&self) -> Rect {
|
||||||
|
self.current_area.get()
|
||||||
|
}
|
||||||
|
|
||||||
/// Move the cursor right one char.
|
/// Move the cursor right one char.
|
||||||
fn incr_cursor(&mut self) {
|
fn incr_cursor(&mut self) {
|
||||||
if let Some(pos) = self.next_char_position() {
|
if let Some(pos) = self.next_char_position() {
|
||||||
|
|
@ -298,6 +305,8 @@ impl DrawableComponent for TextInputComponent {
|
||||||
if self.show_char_count {
|
if self.show_char_count {
|
||||||
self.draw_char_count(f, area);
|
self.draw_char_count(f, area);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.current_area.set(area);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue