Comments (2)
I try the Example of button
package main
import (
"fmt"
"log""github.com/jroimartin/gocui"
)func main() {
g, err := gocui.NewGui(gocui.OutputNormal)
if err != nil {
log.Panicln(err)
}
defer g.Close()g.Cursor = true
g.Mouse = trueg.SetManagerFunc(layout2)
if err := keybindings(g); err != nil {
log.Panicln(err)
}if err := g.MainLoop(); err != nil && err != gocui.ErrQuit {
log.Panicln(err)
}
}func layout2(g *gocui.Gui) error {
if v, err := g.SetView("but1", 2, 2, 22, 7); err != nil {
if err != gocui.ErrUnknownView {
return err
}
v.Highlight = true
v.SelBgColor = gocui.ColorGreen
v.SelFgColor = gocui.ColorBlack
fmt.Fprintln(v, "Button 1 - line 1")
fmt.Fprintln(v, "Button 1 - line 2")
fmt.Fprintln(v, "Button 1 - line 3")
fmt.Fprintln(v, "Button 1 - line 4")
}
if v, err := g.SetView("but2", 24, 2, 44, 4); err != nil {
if err != gocui.ErrUnknownView {
return err
}
v.Highlight = true
v.SelBgColor = gocui.ColorGreen
v.SelFgColor = gocui.ColorBlack
fmt.Fprintln(v, "Button 2 - line 1")
}
return nil
}func keybindings(g *gocui.Gui) error {
if err := g.SetKeybinding("", gocui.KeyCtrlC, gocui.ModNone, quit2); err != nil {
return err
}
for _, n := range []string{"but1", "but2"} {
if err := g.SetKeybinding(n, gocui.MouseLeft, gocui.ModNone, showMsg); err != nil {
return err
}
}
if err := g.SetKeybinding("msg", gocui.MouseLeft, gocui.ModNone, delMsg); err != nil {
return err
}
return nil
}func quit2(g *gocui.Gui, v *gocui.View) error {
return gocui.ErrQuit
}func showMsg(g *gocui.Gui, v *gocui.View) error {
var l string
var err errorif _, err := g.SetCurrentView(v.Name()); err != nil {
return err
}_, cy := v.Cursor()
if l, err = v.Line(cy); err != nil {
l = ""
}maxX, maxY := g.Size()
if v, err := g.SetView("msg", maxX/2-10, maxY/2, maxX/2+10, maxY/2+2); err != nil {
if err != gocui.ErrUnknownView {
return err
}
fmt.Fprintln(v, l)
}
return nil
}func delMsg(g *gocui.Gui, v *gocui.View) error {
if err := g.DeleteView("msg"); err != nil {
return err
}
return nil
}
But nothing occurs
from gocui.
from gocui.
Related Issues (20)
- Wrong layout when Title uses a different encoding HOT 1
- True color support ? HOT 2
- Keybindings not working on FreeBSD HOT 3
- Examples does not support east asian windows? HOT 1
- Can you support run jar packet? HOT 1
- force update HOT 6
- Add a project that using gocui HOT 1
- Update Screenshot Example HOT 1
- Start printing at cursor position
- Add lazygit to the list of projects HOT 1
- Better tags support HOT 2
- how to read input
- Support ANSI code for hyperlinks
- Add Omnivore to projects list.
- Lazydocker is not listed HOT 2
- Extended ANSI color codes are not supported
- Is the library still actively maintained?
- Chinese Support HOT 2
- git-bug relies on gocui
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gocui.