提交 23380589 编写于 作者: aaronchen2k2k's avatar aaronchen2k2k

support Tab, Enter key; use Space key to toggle radio box

上级 7de1ef41
......@@ -10,7 +10,6 @@ import (
"github.com/jroimartin/gocui"
"log"
"net/http/httptest"
"strconv"
"strings"
"time"
)
......@@ -55,14 +54,8 @@ func main() {
func layout(g *gocui.Gui) error {
maxX, maxY := g.Size()
if v, err := g.SetView("qickbar", 0, 0, leftWidth, 2); err != nil {
if err != gocui.ErrUnknownView {
return err
}
v.Highlight = true
v.SelBgColor = gocui.ColorGreen
v.SelFgColor = gocui.ColorBlack
}
ui.NewLabelWidget(g, "qickbar", 0, 0, leftWidth, "")
if v, err := g.SetView("import", 3, 0, 14, 2); err != nil {
v.Frame = false
fmt.Fprint(v, " Import ")
......@@ -325,10 +318,7 @@ func importProjectRequest(g *gocui.Gui, v *gocui.View) error {
taskId := strings.TrimSpace(taskView.Buffer())
language := strings.TrimSpace(languageView.Buffer())
singleFileStr := strings.TrimSpace(singleFileView.Buffer())
singleFile, e := strconv.ParseBool(singleFileStr)
if e != nil {
singleFile = true
}
singleFile := ui.ParseRadioVal(singleFileStr)
params := make(map[string]string)
if productCode != "" {
......
......@@ -16,8 +16,14 @@ type LabelWidget struct {
label string
}
func NewLabelWidget(name string, x, y int, label string) *LabelWidget {
return &LabelWidget{name: name, x: x, y: y, w: len(label) + 1, label: label}
func NewLabelWidget(g *gocui.Gui, name string, x, y, w int, label string) {
widget := LabelWidget{name: name, x: x, y: y, w: w, label: label}
widget.Layout(g)
}
func NewLabelWidgetAutoWidth(g *gocui.Gui, name string, x, y int, label string) {
widget := &LabelWidget{name: name, x: x, y: y, w: len(label) + 1, label: label}
widget.Layout(g)
}
func (w *LabelWidget) Layout(g *gocui.Gui) error {
......@@ -26,6 +32,7 @@ func (w *LabelWidget) Layout(g *gocui.Gui) error {
if err != gocui.ErrUnknownView {
return err
}
fmt.Fprint(v, w.label)
}
return nil
......
......@@ -62,3 +62,11 @@ func statusSet(v *gocui.View) error {
return nil
}
func ParseRadioVal(val string) bool {
if val == "[*]" {
return true
}
return false
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册