Skip to content

Commit

Permalink
Remove info panel
Browse files Browse the repository at this point in the history
  • Loading branch information
nakabonne committed May 6, 2020
1 parent 444b255 commit f4345d5
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions pkg/gui/gui.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ type Gui struct {
lintersItem *item.Linters
sourceFilesItem *item.SourceFiles
resultsItem *item.Results
infoItem *item.Info
naviItem *item.Navi
//infoItem *item.Info
naviItem *item.Navi

runner *golangcilint.Runner
editor *editor.Editor
Expand All @@ -41,7 +41,6 @@ func New(logger *logrus.Entry, runner *golangcilint.Runner, command *editor.Edit
lintersItem: item.NewLinters(linters),
sourceFilesItem: item.NewSourceFiles("."),
resultsItem: item.NewResults(),
infoItem: item.NewInfo(runner.GetVersion()), // TODO: Run GetVersion() concurrency
naviItem: item.NewNavi(),
runner: runner,
logger: logger,
Expand All @@ -62,16 +61,15 @@ func (g *Gui) Run() error {
// initGrid sets a grid based layout as a root primitive for the application.
func (g *Gui) initGrid() {
grid := tview.NewGrid().
SetRows(1, 0, 1).
SetColumns(30, 40, 0, 0).
SetBorders(true).
AddItem(g.infoItem, 0, 0, 1, 2, 0, 0, false)
SetRows(0, 1).
SetColumns(30, 30, 0, 0).
SetBorders(true)

// Layout for screens wider than 100 cells.
grid.AddItem(g.lintersItem, 1, 0, 1, 1, 0, 100, true).
AddItem(g.sourceFilesItem, 1, 1, 1, 1, 0, 100, false).
AddItem(g.resultsItem, 0, 2, 2, 2, 0, 100, false).
AddItem(g.naviItem, 2, 0, 1, 4, 0, 0, false)
grid.AddItem(g.lintersItem, 0, 0, 1, 1, 0, 100, true).
AddItem(g.sourceFilesItem, 0, 1, 1, 1, 0, 100, false).
AddItem(g.resultsItem, 0, 2, 1, 2, 0, 100, false).
AddItem(g.naviItem, 1, 0, 1, 4, 0, 0, false)

g.naviItem.Update(g.lintersItem)

Expand Down Expand Up @@ -116,33 +114,36 @@ func (g *Gui) switchPage(prev, next string) {
// showWarn shows the given message as a modal.
// doneLabel param is used for the name of button to close.
func (g *Gui) showWarn(message, doneLabel string) {
g.showModal(message, doneLabel, 60, 150, tcell.ColorBlack)
g.showModal(message, doneLabel, func() { g.switchPage(modalPageName, mainPageName) }, tcell.ColorBlack, tcell.ColorBlack, tcell.ColorWhite)
}

// showLoading shows the given message as a modal.
// It doesn't provide any close buttons, instead it returns the function to close itself.
func (g *Gui) showLoading(message string) func() {
g.showModal(message, "", 2, 100, tcell.ColorBlack)
func (g *Gui) showLoading(message, doneLabel string) func() {
g.showModal(message, doneLabel, func() {}, tcell.ColorBlack, tcell.ColorWhite, tcell.ColorBlack)
close := func() {
g.switchPage(modalPageName, mainPageName)
}
return close
}

func (g *Gui) showModal(message, doneLabel string, rowWidth, colWidth int, backGroundColor tcell.Color) {
func (g *Gui) showModal(message, doneLabel string, doneFunc func(), backGroundColor, buttonTextColor, buttonBackGroundColor tcell.Color) {
modal := tview.NewModal().
SetText(message).
SetBackgroundColor(backGroundColor)
SetBackgroundColor(backGroundColor).
SetButtonBackgroundColor(buttonTextColor).
SetButtonTextColor(buttonBackGroundColor) // NOTE: The text color and background color are reversed, which is tview's issue.

if doneLabel != "" {
modal.AddButtons([]string{doneLabel}).
SetDoneFunc(func(buttonIndex int, buttonLabel string) {
if buttonLabel == doneLabel {
g.switchPage(modalPageName, mainPageName)
doneFunc()
}
})
}

colWidth, rowWidth := 1, 1
grid := tview.NewGrid().
SetColumns(0, colWidth, 0).
SetRows(0, rowWidth, 0).
Expand Down

0 comments on commit f4345d5

Please sign in to comment.