Browse Source

Update dependencies

Resolves #8.
master
Trevor Slocum 1 year ago
parent
commit
86bb8d9ff4
  1. 3
      CHANGELOG
  2. 97
      cmd/gmenu/gui.go
  3. 18
      cmd/gmenu/gui_list.go
  4. 3
      cmd/gtkmenu/gui.go
  5. 2
      cmd/gtkmenu/main.go
  6. 14
      go.mod
  7. 40
      go.sum

3
CHANGELOG

@ -1,3 +1,6 @@
0.3.1
- Update dependencies
0.3.0
- Migrate to code.rocketnine.space

97
cmd/gmenu/gui.go

@ -9,10 +9,10 @@ import (
)
var (
app *cview.Application
inputView *cview.InputField
entryList *optionsList
appDetailsView *cview.TextView
app *cview.Application
inputView *cview.InputField
entryList *cview.List
detailView *cview.TextView
closedTUI bool
)
@ -65,8 +65,6 @@ func (r *optionsList) Draw(screen tcell.Screen) {
}
tv := r.TextView
tv.SetBackgroundColor(tcell.ColorDefault)
tv.SetTextColor(tcell.ColorDefault)
tv.SetText(b.String())
tv.Highlight("gmenu")
tv.ScrollToBeginning()
@ -76,6 +74,13 @@ func (r *optionsList) Draw(screen tcell.Screen) {
func initTUI() (*cview.Application, error) {
app = cview.NewApplication()
// TODO this breaks highlighting the line
/*
cview.Styles.PrimitiveBackgroundColor = tcell.ColorDefault
cview.Styles.PrimaryTextColor = tcell.ColorDefault
cview.Styles.ScrollBarColor = tcell.ColorDefault
*/
inputView = cview.NewInputField()
inputView.SetLabel("")
inputView.SetFieldWidth(0)
@ -85,78 +90,41 @@ func initTUI() (*cview.Application, error) {
gmenu.SetInput(text)
})
entryList = newOptionsList(nil)
entryList = cview.NewList()
entryList.ShowSecondaryText(false)
entryList.SetHighlightFullLine(true)
grid := cview.NewGrid()
grid.SetBorders(false)
grid.SetRows(1, -1)
appDetailsView = cview.NewTextView()
appDetailsView.SetTextAlign(cview.AlignLeft)
appDetailsView.SetWrap(true)
appDetailsView.SetWordWrap(true)
appDetailsView.SetBackgroundColor(tcell.ColorDefault)
appDetailsView.SetTextColor(tcell.ColorDefault)
detailView = cview.NewTextView()
detailView.SetTextAlign(cview.AlignLeft)
detailView.SetWrap(true)
detailView.SetWordWrap(true)
if config.HideAppDetails {
grid.SetColumns(-1)
grid.AddItem(inputView, 0, 0, 1, 1, 0, 0, true)
grid.AddItem(entryList, 1, 0, 1, 1, 0, 0, false)
} else {
grid.SetColumns(-1, -1)
box := cview.NewBox()
box.SetVisible(false)
grid.SetColumns(-1, 1, -1)
grid.AddItem(inputView, 0, 0, 1, 2, 0, 0, true)
grid.AddItem(entryList, 1, 0, 1, 1, 0, 0, false)
grid.AddItem(appDetailsView, 1, 1, 1, 1, 0, 0, false)
grid.AddItem(box, 1, 1, 1, 1, 0, 0, false)
grid.AddItem(detailView, 1, 2, 1, 1, 0, 0, false)
}
app.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey {
defer app.QueueUpdateDraw(updateEntryInfo)
if event.Key() == tcell.KeyUp {
if entryList.origin > 0 && entryList.selected == entryList.origin {
entryList.origin--
}
if entryList.selected > 0 {
entryList.selected--
}
event = nil
} else if event.Key() == tcell.KeyDown {
if entryList.selected < len(entryList.options)-1 {
entryList.selected++
if entryList.selected > entryList.origin+entryList.shown-1 {
entryList.origin++
}
}
event = nil
} else if event.Key() == tcell.KeyPgUp {
if entryList.origin == 0 {
entryList.selected = 0
return nil
}
entryList.origin -= entryList.shown - 2
if entryList.origin < 0 {
entryList.origin = 0
}
entryList.selected = entryList.origin
return nil
} else if event.Key() == tcell.KeyPgDn {
numEntries := len(gmenu.FilteredEntries)
if entryList.origin >= numEntries-entryList.shown {
entryList.selected = numEntries - 1
return nil
}
entryList.origin += entryList.shown - 2
if entryList.origin > numEntries-entryList.shown {
entryList.origin = numEntries - entryList.shown
}
entryList.selected = entryList.origin
if event.Key() == tcell.KeyUp || event.Key() == tcell.KeyDown || event.Key() == tcell.KeyPgUp || event.Key() == tcell.KeyPgDn {
entryList.InputHandler()(event, func(p cview.Primitive) {
app.SetFocus(p)
})
return nil
} else if event.Key() == tcell.KeyEnter || event.Rune() == '\n' {
runInTerminal := event.Modifiers()&tcell.ModAlt > 0
@ -173,8 +141,15 @@ func initTUI() (*cview.Application, error) {
app.SetRoot(grid, true)
go gmenu.HandleInput(updateEntries)
updateEntries("")
go gmenu.HandleInput(func(input string) {
gmenu.FilterEntries()
app.QueueUpdateDraw(updateEntryInfo)
})
gmenu.SetInput("")
app.SetFocus(entryList)
return app, nil
}

18
cmd/gmenu/gui_list.go

@ -5,6 +5,7 @@ import (
"fmt"
"strings"
"code.rocketnine.space/tslocum/cview"
"code.rocketnine.space/tslocum/desktop"
"code.rocketnine.space/tslocum/gmenu/pkg/gmenu"
"github.com/kballard/go-shellquote"
@ -13,17 +14,18 @@ import (
func updateEntries(input string) {
gmenu.FilterEntries()
entryList.selected = 0
entryList.origin = 0
defer app.QueueUpdateDraw(updateEntryInfo)
entryList.Clear()
entryList.SetCurrentItem(0)
entryList.SetOffset(0, 0)
entryList.options = nil
for _, entry := range gmenu.FilteredEntries {
entryList.options = append(entryList.options, entry.Label)
entryList.AddItem(cview.NewListItem(entry.Label))
}
if input != "" {
entryList.options = append(entryList.options, input)
entryList.AddItem(cview.NewListItem(input))
}
app.QueueUpdateDraw(updateEntryInfo)
}
func selectedIndex() int {
@ -31,7 +33,7 @@ func selectedIndex() int {
return -1
}
return entryList.selected
return entryList.GetCurrentItemIndex()
}
func selectedEntry() *desktop.Entry {
@ -64,7 +66,7 @@ func updateEntryInfo() {
comLine = "Shell command"
}
appDetailsView.SetText(exLine + "\n\n" + comLine)
detailView.SetText(exLine + "\n\n" + comLine)
}
func listSelect(runInTerminal bool) error {

3
cmd/gtkmenu/gui.go

@ -19,9 +19,6 @@ func initWindow(application *gtk.Application) *gtk.ApplicationWindow {
w.Connect("destroy", func() {
os.Exit(0)
})
if err != nil {
log.Fatal("failed to create application window:", err)
}
w.SetTitle("gmenu")
w.SetDecorated(false)

2
cmd/gtkmenu/main.go

@ -83,7 +83,7 @@ func load() {
f := func() {
updateList(input)
}
glib.IdleAdd(f)
glib.IdleAddPriority(glib.PRIORITY_HIGH_IDLE, f)
})
loaded <- true

14
go.mod

@ -3,13 +3,11 @@ module code.rocketnine.space/tslocum/gmenu
go 1.12
require (
code.rocketnine.space/tslocum/cview v1.5.4
code.rocketnine.space/tslocum/desktop v0.1.5
github.com/gdamore/tcell/v2 v2.2.1-0.20210305060500-f4d402906fa3
github.com/gotk3/gotk3 v0.5.3-0.20210405165307-86f85cbecd0b
code.rocketnine.space/tslocum/cview v1.5.6
code.rocketnine.space/tslocum/desktop v0.1.6-0.20210710150012-8bd74b40a298
github.com/gdamore/tcell/v2 v2.3.11
github.com/gotk3/gotk3 v0.6.1-0.20210626103219-b183dad2e774
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51
github.com/lithammer/fuzzysearch v1.1.1
github.com/mattn/go-isatty v0.0.12
golang.org/x/sys v0.0.0-20210414055047-fe65e336abe0 // indirect
golang.org/x/term v0.0.0-20210406210042-72f3dc4e9b72 // indirect
github.com/lithammer/fuzzysearch v1.1.2
github.com/mattn/go-isatty v0.0.13
)

40
go.sum

@ -1,44 +1,42 @@
code.rocketnine.space/tslocum/cbind v0.1.5 h1:i6NkeLLNPNMS4NWNi3302Ay3zSU6MrqOT+yJskiodxE=
code.rocketnine.space/tslocum/cbind v0.1.5/go.mod h1:LtfqJTzM7qhg88nAvNhx+VnTjZ0SXBJtxBObbfBWo/M=
code.rocketnine.space/tslocum/cview v1.5.4 h1:zBUFAanViudrAw8ZCqNxaufqrYL6a7F1AkkIClXIzYo=
code.rocketnine.space/tslocum/cview v1.5.4/go.mod h1:JjgoZi3b528SaV923oQq14PGUCTE/g/6iggnDUxsChE=
code.rocketnine.space/tslocum/desktop v0.1.5 h1:GXZpPo8KH8M24Juu0F/UTfXgOnya0MAAnCQByBpFGz4=
code.rocketnine.space/tslocum/desktop v0.1.5/go.mod h1:6IwP59rJ44vga/frr123meFdpWU0xMZlTq8gcOhVKGI=
code.rocketnine.space/tslocum/cview v1.5.6 h1:W0HJFIIgly3LzYoTitZIIaYDDqW0u/qmA0B6jWzw6R0=
code.rocketnine.space/tslocum/cview v1.5.6/go.mod h1:RogJMObbKuGiP8+9WsFsHpPeQQqgkCXgvTLxh7IH5eE=
code.rocketnine.space/tslocum/desktop v0.1.6-0.20210710150012-8bd74b40a298 h1:tuG22JOMMVlMl+ofRGIJFCTwzs+CclO/XZh7qEPXnzk=
code.rocketnine.space/tslocum/desktop v0.1.6-0.20210710150012-8bd74b40a298/go.mod h1:6IwP59rJ44vga/frr123meFdpWU0xMZlTq8gcOhVKGI=
github.com/gdamore/encoding v1.0.0 h1:+7OoQ1Bc6eTm5niUzBa0Ctsh6JbMW6Ra+YNuAtDBdko=
github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg=
github.com/gdamore/tcell/v2 v2.2.0/go.mod h1:cTTuF84Dlj/RqmaCIV5p4w8uG1zWdk0SF6oBpwHp4fU=
github.com/gdamore/tcell/v2 v2.2.1-0.20210305060500-f4d402906fa3 h1:PqyGpJlv98ynqEPq5MMiT+hcUPPvIomSS0Rnmy5Tl9A=
github.com/gdamore/tcell/v2 v2.2.1-0.20210305060500-f4d402906fa3/go.mod h1:cTTuF84Dlj/RqmaCIV5p4w8uG1zWdk0SF6oBpwHp4fU=
github.com/gotk3/gotk3 v0.5.3-0.20210405165307-86f85cbecd0b h1:KXbrFonfNw1xdc2CeUWYPMir0wXr8ejQlKlClQxM1Lc=
github.com/gotk3/gotk3 v0.5.3-0.20210405165307-86f85cbecd0b/go.mod h1:/hqFpkNa9T3JgNAE2fLvCdov7c5bw//FHNZrZ3Uv9/Q=
github.com/gdamore/tcell/v2 v2.3.11 h1:ECO6WqHGbKZ3HrSL7bG/zArMCmLaNr5vcjjMVnLHpzc=
github.com/gdamore/tcell/v2 v2.3.11/go.mod h1:cTTuF84Dlj/RqmaCIV5p4w8uG1zWdk0SF6oBpwHp4fU=
github.com/gotk3/gotk3 v0.6.1-0.20210626103219-b183dad2e774 h1:IJZW/ruK8Z0nDlpJ4Qj4Ekm2mR39OR0/eFY1pVRaDbM=
github.com/gotk3/gotk3 v0.6.1-0.20210626103219-b183dad2e774/go.mod h1:/hqFpkNa9T3JgNAE2fLvCdov7c5bw//FHNZrZ3Uv9/Q=
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs=
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8=
github.com/lithammer/fuzzysearch v1.1.1 h1:8F9OAV2xPuYblToVohjanztdnPjbtA0MLgMvDKQ0Z08=
github.com/lithammer/fuzzysearch v1.1.1/go.mod h1:H2bng+w5gsR7NlfIJM8ElGZI0sX6C/9uzGqicVXGU6c=
github.com/lithammer/fuzzysearch v1.1.2 h1:ePUtm14xKxbpCxozcFbIDRtvANxnVnE+RKpJUqkr2gA=
github.com/lithammer/fuzzysearch v1.1.2/go.mod h1:v6tYW/9kpfV6LNcweXdSjQsfCku/1M/oObmSox1fzP8=
github.com/lucasb-eyer/go-colorful v1.0.3/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-isatty v0.0.13 h1:qdl+GuBjcsKKDco5BsxPJlId98mSWNKqYA+Co0SC1yA=
github.com/mattn/go-isatty v0.0.13/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-runewidth v0.0.10/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=
github.com/mattn/go-runewidth v0.0.12 h1:Y41i/hVW3Pgwr8gV+J23B9YEY0zxjptBuCWEaxmAOow=
github.com/mattn/go-runewidth v0.0.12/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=
github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU=
github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210309040221-94ec62e08169/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210331175145-43e1dd70ce54/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210414055047-fe65e336abe0 h1:g9s1Ppvvun/fI+BptTMj909BBIcGrzQ32k9FNlcevOE=
golang.org/x/sys v0.0.0-20210414055047-fe65e336abe0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c h1:F1jZWGFhYfh0Ci55sIpILtKKK8p3i2/krTr0H1rg74I=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210317153231-de623e64d2a6/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210406210042-72f3dc4e9b72 h1:VqE9gduFZ4dbR7XoL77lHFp0/DyDUBKSXK7CMFkVcV0=
golang.org/x/term v0.0.0-20210406210042-72f3dc4e9b72/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b h1:9zKuko04nR4gjZ4+DNjHqRlAJqbJETHwiNKDqTfOjfE=
golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=

Loading…
Cancel
Save