Skip to content

Commit

Permalink
Rename box to item
Browse files Browse the repository at this point in the history
  • Loading branch information
nakabonne committed Apr 29, 2020
1 parent 20161c5 commit d5e6821
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 44 deletions.
15 changes: 0 additions & 15 deletions pkg/gui/box/linters_box.go

This file was deleted.

15 changes: 0 additions & 15 deletions pkg/gui/box/targets_box.go

This file was deleted.

16 changes: 10 additions & 6 deletions pkg/gui/gui.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ package gui
import (
"github.com/rivo/tview"

"github.com/nakabonne/golintui/pkg/gui/box"
"github.com/nakabonne/golintui/pkg/gui/item"
)

type Gui struct {
application *tview.Application
pages *tview.Pages
}

func New() *Gui {
Expand All @@ -19,6 +20,7 @@ func New() *Gui {
func (g *Gui) Run() error {
g.initPrimitive()
if err := g.application.Run(); err != nil {
g.application.Stop()
return err
}
return nil
Expand All @@ -29,12 +31,14 @@ func (g *Gui) initPrimitive() {
SetRows(2, 0, 0).
SetColumns(0, 0).
SetBorders(true).
AddItem(box.NewInfoBox(), 0, 0, 1, 1, 0, 0, false)
AddItem(item.NewInfo(), 0, 0, 1, 1, 0, 0, false)

// Layout for screens wider than 100 cells.
grid.AddItem(box.NewLintersBox(), 1, 0, 1, 1, 0, 100, false).
AddItem(box.NewTargetsBox(), 2, 0, 1, 1, 0, 100, false).
AddItem(box.NewResultsBox(), 0, 1, 3, 1, 0, 100, false)
grid.AddItem(item.NewLinters(), 1, 0, 1, 1, 0, 100, true).
AddItem(item.NewSourceFiles(), 2, 0, 1, 1, 0, 100, false).
AddItem(item.NewResults(), 0, 1, 3, 1, 0, 100, false)

g.application.SetRoot(grid, true)
g.pages = tview.NewPages().
AddAndSwitchToPage("main", grid, true)
g.application.SetRoot(g.pages, true)
}
8 changes: 4 additions & 4 deletions pkg/gui/box/info_box.go → pkg/gui/item/info.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package box
package item

import "github.com/rivo/tview"

type InfoBox struct {
type Info struct {
*tview.TextView
}

func NewInfoBox() *InfoBox {
b := &InfoBox{
func NewInfo() *Info {
b := &Info{
TextView: tview.NewTextView(),
}
b.SetText("golangci-lint version: 1.25.0").
Expand Down
16 changes: 16 additions & 0 deletions pkg/gui/item/linters.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package item

import "github.com/rivo/tview"

type Linters struct {
*tview.Checkbox
}

func NewLinters() *Linters {
b := &Linters{
Checkbox: tview.NewCheckbox(),
}
b.SetLabel("golint").
SetBorder(true).SetTitle("Linters").SetTitleAlign(tview.AlignLeft)
return b
}
8 changes: 4 additions & 4 deletions pkg/gui/box/results_box.go → pkg/gui/item/results.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package box
package item

import "github.com/rivo/tview"

type ResultsBox struct {
type Results struct {
*tview.TreeView
}

func NewResultsBox() *ResultsBox {
b := &ResultsBox{
func NewResults() *Results {
b := &Results{
TreeView: tview.NewTreeView(),
}
b.SetBorder(true).SetTitle("Results").SetTitleAlign(tview.AlignLeft)
Expand Down
15 changes: 15 additions & 0 deletions pkg/gui/item/source_files.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package item

import "github.com/rivo/tview"

type SourceFiles struct {
*tview.TreeView
}

func NewSourceFiles() *SourceFiles {
b := &SourceFiles{
TreeView: tview.NewTreeView(),
}
b.SetBorder(true).SetTitle("Source Files").SetTitleAlign(tview.AlignLeft)
return b
}

0 comments on commit d5e6821

Please sign in to comment.