Skip to content

Commit

Permalink
Merge pull request #107 from coloursofnoise/fix-examples
Browse files Browse the repository at this point in the history
Fix bugs in _examples/
  • Loading branch information
mjarkk authored Dec 3, 2021
2 parents f8e8c10 + c12d2bc commit 5799ff9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
6 changes: 6 additions & 0 deletions _examples/dynamic.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ func initKeybindings(g *gocui.Gui) error {
}); err != nil {
return err
}
if err := g.SetKeybinding("", gocui.KeyBackspace, gocui.ModNone,
func(g *gocui.Gui, v *gocui.View) error {
return delView(g)
}); err != nil {
return err
}
if err := g.SetKeybinding("", gocui.KeyBackspace2, gocui.ModNone,
func(g *gocui.Gui, v *gocui.View) error {
return delView(g)
Expand Down
2 changes: 1 addition & 1 deletion _examples/mouse.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func main() {
}
defer g.Close()

g.Cursor = true
g.Cursor = false
g.Mouse = true

g.SetManagerFunc(layout)
Expand Down
6 changes: 3 additions & 3 deletions _examples/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func (t *Table) Layout(g *gocui.Gui) error {
width, height := view.Size()
hOffset := 0
for cid, column := range t.Columns {
size := int(float32(width) * column.Size)
size := int(float32(width+1) * column.Size)

view.SetWritePos(hOffset, 0)
view.WriteString(column.Title)
Expand All @@ -53,7 +53,7 @@ func (t *Table) Layout(g *gocui.Gui) error {
view.SetWritePos(hOffset, rid+1)
view.WriteString(t.Data[cid][rid])
}
view.SetWritePos(hOffset+size-3, rid)
view.SetWritePos(hOffset+size-1, rid)
view.WriteRunes([]rune{'│'})
}

Expand All @@ -70,7 +70,7 @@ func main() {
}
defer g.Close()

table := NewTable("t", 1, 2, 80, 10)
table := NewTable("t", 0, 2, 80, 10)
table.Columns = []Column{
{"Column1", 0.25},
{"Column2", 0.25},
Expand Down

0 comments on commit 5799ff9

Please sign in to comment.