mirror of
https://github.com/MichaelMure/git-bug.git
synced 2024-12-15 02:01:43 +03:00
termui: better padding for show bug
This commit is contained in:
parent
5675299c8d
commit
de76b6fa15
@ -31,6 +31,11 @@ func newShowBug(cache cache.RepoCacher) *showBug {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (sb *showBug) SetBug(bug cache.BugCacher) {
|
||||||
|
sb.bug = bug
|
||||||
|
sb.scroll = 0
|
||||||
|
}
|
||||||
|
|
||||||
func (sb *showBug) layout(g *gocui.Gui) error {
|
func (sb *showBug) layout(g *gocui.Gui) error {
|
||||||
maxX, maxY := g.Size()
|
maxX, maxY := g.Size()
|
||||||
|
|
||||||
@ -155,21 +160,21 @@ func (sb *showBug) renderMain(g *gocui.Gui, mainView *gocui.View) error {
|
|||||||
sb.childViews = nil
|
sb.childViews = nil
|
||||||
sb.selectableView = nil
|
sb.selectableView = nil
|
||||||
|
|
||||||
header := fmt.Sprintf("[ %s ] %s\n\n[ %s ] %s opened this bug on %s",
|
bugHeader := fmt.Sprintf("[ %s ] %s\n\n[ %s ] %s opened this bug on %s",
|
||||||
util.Cyan(snap.HumanId()),
|
util.Cyan(snap.HumanId()),
|
||||||
util.Bold(snap.Title),
|
util.Bold(snap.Title),
|
||||||
util.Yellow(snap.Status),
|
util.Yellow(snap.Status),
|
||||||
util.Magenta(snap.Author.Name),
|
util.Magenta(snap.Author.Name),
|
||||||
snap.CreatedAt.Format(timeLayout),
|
snap.CreatedAt.Format(timeLayout),
|
||||||
)
|
)
|
||||||
content, lines := util.TextWrap(header, maxX)
|
bugHeader, lines := util.TextWrap(bugHeader, maxX)
|
||||||
|
|
||||||
v, err := sb.createOpView(g, showBugHeaderView, x0, y0, maxX+1, lines, false)
|
v, err := sb.createOpView(g, showBugHeaderView, x0, y0, maxX+1, lines, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Fprint(v, content)
|
fmt.Fprint(v, bugHeader)
|
||||||
y0 += lines + 1
|
y0 += lines + 1
|
||||||
|
|
||||||
for i, op := range snap.Operations {
|
for i, op := range snap.Operations {
|
||||||
@ -182,7 +187,7 @@ func (sb *showBug) renderMain(g *gocui.Gui, mainView *gocui.View) error {
|
|||||||
|
|
||||||
case operations.CreateOperation:
|
case operations.CreateOperation:
|
||||||
create := op.(operations.CreateOperation)
|
create := op.(operations.CreateOperation)
|
||||||
content, lines := util.TextWrap(create.Message, maxX)
|
content, lines := util.TextWrapPadded(create.Message, maxX, 4)
|
||||||
|
|
||||||
v, err := sb.createOpView(g, viewName, x0, y0, maxX+1, lines, true)
|
v, err := sb.createOpView(g, viewName, x0, y0, maxX+1, lines, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -194,12 +199,13 @@ func (sb *showBug) renderMain(g *gocui.Gui, mainView *gocui.View) error {
|
|||||||
case operations.AddCommentOperation:
|
case operations.AddCommentOperation:
|
||||||
comment := op.(operations.AddCommentOperation)
|
comment := op.(operations.AddCommentOperation)
|
||||||
|
|
||||||
|
message, _ := util.TextWrapPadded(comment.Message, maxX, 4)
|
||||||
content := fmt.Sprintf("%s commented on %s\n\n%s",
|
content := fmt.Sprintf("%s commented on %s\n\n%s",
|
||||||
util.Magenta(comment.Author.Name),
|
util.Magenta(comment.Author.Name),
|
||||||
comment.Time().Format(timeLayout),
|
comment.Time().Format(timeLayout),
|
||||||
comment.Message,
|
message,
|
||||||
)
|
)
|
||||||
content, lines := util.TextWrapPadded(content, maxX, 6)
|
content, lines = util.TextWrap(content, maxX)
|
||||||
|
|
||||||
v, err := sb.createOpView(g, viewName, x0, y0, maxX+1, lines, true)
|
v, err := sb.createOpView(g, viewName, x0, y0, maxX+1, lines, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user