From fae15ebc84bed558618e5b2ee95989921d82fc0a Mon Sep 17 00:00:00 2001 From: Aaron Chen <462826@qq.com> Date: Fri, 16 Aug 2019 15:30:42 +0800 Subject: [PATCH] add textarea input for bug steps for user edit --- src/action/gen.go | 170 +------------------- src/atf.go | 2 +- src/service/script/assert.go | 2 +- src/service/script/generator.go | 180 ++++++++++++++++++++++ src/service/script/{script.go => lang.go} | 4 +- src/service/testing/check.go | 2 +- src/service/testing/suite.go | 14 -- src/ui/page/pageImport.go | 6 +- src/ui/page/pageReportBug.go | 16 +- src/ui/page/pageSwitch.go | 2 +- src/ui/page/pageTestResult.go | 8 +- src/ui/uiUtils.go | 31 ++-- src/ui/widget/widgetSelect.go | 4 +- src/ui/widget/widgetText.go | 2 +- 14 files changed, 217 insertions(+), 226 deletions(-) create mode 100644 src/service/script/generator.go rename src/service/script/{script.go => lang.go} (92%) delete mode 100644 src/service/testing/suite.go diff --git a/src/action/gen.go b/src/action/gen.go index 94686c0c..61e993bc 100644 --- a/src/action/gen.go +++ b/src/action/gen.go @@ -4,22 +4,16 @@ import ( "fmt" "github.com/easysoft/zentaoatf/src/model" "github.com/easysoft/zentaoatf/src/service/script" - testingService "github.com/easysoft/zentaoatf/src/service/testing" zentaoService "github.com/easysoft/zentaoatf/src/service/zentao" "github.com/easysoft/zentaoatf/src/utils/common" "github.com/easysoft/zentaoatf/src/utils/config" constant "github.com/easysoft/zentaoatf/src/utils/const" "github.com/easysoft/zentaoatf/src/utils/date" - "github.com/easysoft/zentaoatf/src/utils/file" - "github.com/easysoft/zentaoatf/src/utils/vari" - zentaoUtils "github.com/easysoft/zentaoatf/src/utils/zentao" - "os" "strconv" - "strings" "time" ) -func GenFromCmd(url string, entityType string, entityVal string, langType string, singleFile bool, +func GenerateScriptFromCmd(url string, entityType string, entityVal string, langType string, singleFile bool, account string, password string) { params := make(map[string]string) @@ -47,7 +41,7 @@ func GenFromCmd(url string, entityType string, entityVal string, langType string } if testcases != nil { - count, err := Generate(testcases, langType, singleFile, account, password) + count, err := scriptService.Generate(testcases, langType, singleFile, account, password) if err == nil { configUtils.SaveConfig("", url, params["entityType"], params["entityVal"], productId, projectId, langType, singleFile, @@ -60,163 +54,3 @@ func GenFromCmd(url string, entityType string, entityVal string, langType string } } } - -func Generate(testcases []model.TestCase, langType string, singleFile bool, - account string, password string) (int, error) { - - casePaths := make([]string, 0) - for _, cs := range testcases { - DealwithTestCase(cs, langType, singleFile, &casePaths) - } - - testingService.GenSuite(casePaths) - - return len(testcases), nil -} - -func DealwithTestCase(cs model.TestCase, langType string, singleFile bool, casePaths *[]string) { - LangMap := scriptService.GetLangMap() - langs := "" - if LangMap[langType] == nil { - i := 0 - for lang, _ := range LangMap { - if i > 0 { - langs += ", " - } - langs += lang - i++ - } - fmt.Printf("only support languages %s \n", langs) - os.Exit(1) - } - - caseId := cs.Id - caseInTaskId := cs.IdInTask - taskId := cs.TaskId - if caseInTaskId == "" { - caseInTaskId = "0" - } - caseTitle := cs.Title - - scriptFile := fmt.Sprintf(constant.ScriptDir+"tc-%s.%s", caseId, LangMap[langType]["extName"]) - if fileUtils.FileExist(scriptFile) { - scriptFile = fmt.Sprintf(constant.ScriptDir+"tc-%s.%s", - caseId+"-"+dateUtils.DateTimeStrLong(time.Now()), LangMap[langType]["extName"]) - } - - fileUtils.MkDirIfNeeded(vari.Prefer.WorkDir + constant.ScriptDir) - *casePaths = append(*casePaths, scriptFile) - scriptFullPath := vari.Prefer.WorkDir + scriptFile - - steps := make([]string, 0) - expects := make([]string, 0) - srcCode := make([]string, 0) - - steps = append(steps, "@开头的为含验证点的步骤") - - temp := fmt.Sprintf("\n%sCODE: 此处编写操作步骤代码\n", LangMap[langType]["commentsTag"]) - srcCode = append(srcCode, temp) - - readme := zentaoUtils.ReadResData("res/template/readme.tpl") + "\n" - - StepWidth := 20 - stepDisplayMaxWidth := 0 - ComputerTestStepWidth(cs.StepArr, &stepDisplayMaxWidth, StepWidth) - - for _, ts := range cs.StepArr { - DealwithTestStep(ts, langType, StepWidth, &steps, &expects, &srcCode) - } - - var expectsTxt string - if singleFile { - expectsTxt = strings.Join(expects, "\n") - } else { - expectFile := zentaoUtils.ScriptToExpectName(scriptFullPath) - - expectsTxt = "@file\n" - fileUtils.WriteFile(expectFile, strings.Join(expects, "\n")) - } - - path := fmt.Sprintf("res%stemplate%s", string(os.PathSeparator), string(os.PathSeparator)) - template := zentaoUtils.ReadResData(path + langType + ".tpl") - - content := fmt.Sprintf(template, - caseId, caseInTaskId, taskId, caseTitle, - strings.Join(steps, "\n"), expectsTxt, - readme, - strings.Join(srcCode, "\n")) - - //fmt.Println(content) - - fileUtils.WriteFile(scriptFullPath, content) -} - -func ComputerTestStepWidth(steps []model.TestStep, stepSDisplayMaxWidth *int, stepWidth int) { - for _, ts := range steps { - length := len(ts.Id) - if length > *stepSDisplayMaxWidth { - *stepSDisplayMaxWidth = length - } - } - *stepSDisplayMaxWidth += stepWidth // prefix space and @step -} - -func DealwithTestStep(ts model.TestStep, langType string, stepWidth int, - steps *[]string, expects *[]string, srcCode *[]string) { - LangMap := scriptService.GetLangMap() - - isGroup := ts.Type == "group" - isCheckPoint := ts.Expect != "" - - stepId := ts.Id - stepTitle := ts.Desc - stepExpect := ts.Expect - stepParent := ts.Parent - - // 处理steps - preFixSpace := 3 - if stepParent != "" && stepParent != "0" { - preFixSpace = 6 - } - - var stepType string - if isGroup { - stepType = "group" - } else { - stepType = "step" - } - - stepIdent := stepType + stepId - if isCheckPoint { - stepIdent = "@" + stepIdent - } - - postFixSpace := stepWidth - preFixSpace - len(stepIdent) - - stepLine := fmt.Sprintf("%*s", preFixSpace, " ") + stepIdent - stepLine += fmt.Sprintf("%*s", postFixSpace, " ") - stepLine += stepTitle - - *steps = append(*steps, stepLine) - - // 处理expects - if isCheckPoint { - expectsLine := "" - - expectsLine = "# " + stepIdent + " \n" - expectsLine += "CODE: " + "期望结果, 可以有多行\n" - - *expects = append(*expects, expectsLine) - } - - // 处理srcCode - if isCheckPoint { - codeLine := LangMap[langType]["printGrammar"] - - codeLine += fmt.Sprintf(" %s %s: %s\n", LangMap[langType]["commentsTag"], stepIdent, stepExpect) - - codeLine += LangMap[langType]["commentsTag"] + "CODE: 输出验证点实际结果\n" - - *srcCode = append(*srcCode, codeLine) - } -} diff --git a/src/atf.go b/src/atf.go index 96c2c987..b0682ee1 100644 --- a/src/atf.go +++ b/src/atf.go @@ -111,7 +111,7 @@ func main() { genSet.Usage() os.Exit(1) } else { - action.GenFromCmd(zentaoUrl, entityType, entityVal, langType, singleFile, account, password) + action.GenerateScriptFromCmd(zentaoUrl, entityType, entityVal, langType, singleFile, account, password) } } case "list": diff --git a/src/service/script/assert.go b/src/service/script/assert.go index f9f57ab2..81253c56 100644 --- a/src/service/script/assert.go +++ b/src/service/script/assert.go @@ -9,7 +9,7 @@ import ( func LoadTestAssets() ([]string, []string) { config := config2.ReadCurrConfig() - ext := GetLangMap()[config.LangType]["extName"] + ext := GetSupportedScriptLang()[config.LangType]["extName"] caseFiles := make([]string, 0) suitesFiles := make([]string, 0) diff --git a/src/service/script/generator.go b/src/service/script/generator.go new file mode 100644 index 00000000..f1b92ced --- /dev/null +++ b/src/service/script/generator.go @@ -0,0 +1,180 @@ +package scriptService + +import ( + "fmt" + "github.com/easysoft/zentaoatf/src/model" + constant "github.com/easysoft/zentaoatf/src/utils/const" + dateUtils "github.com/easysoft/zentaoatf/src/utils/date" + fileUtils "github.com/easysoft/zentaoatf/src/utils/file" + "github.com/easysoft/zentaoatf/src/utils/vari" + zentaoUtils "github.com/easysoft/zentaoatf/src/utils/zentao" + "os" + "strings" + "time" +) + +func Generate(testcases []model.TestCase, langType string, singleFile bool, + account string, password string) (int, error) { + + casePaths := make([]string, 0) + for _, cs := range testcases { + GenerateTestCaseScrrpt(cs, langType, singleFile, &casePaths) + } + + GenSuite(casePaths) + + return len(testcases), nil +} + +func GenerateTestCaseScrrpt(cs model.TestCase, langType string, singleFile bool, casePaths *[]string) { + LangMap := GetSupportedScriptLang() + langs := "" + if LangMap[langType] == nil { + i := 0 + for lang, _ := range LangMap { + if i > 0 { + langs += ", " + } + langs += lang + i++ + } + fmt.Printf("only support languages %s \n", langs) + os.Exit(1) + } + + caseId := cs.Id + caseInTaskId := cs.IdInTask + taskId := cs.TaskId + if caseInTaskId == "" { + caseInTaskId = "0" + } + caseTitle := cs.Title + + scriptFile := fmt.Sprintf(constant.ScriptDir+"tc-%s.%s", caseId, LangMap[langType]["extName"]) + if fileUtils.FileExist(scriptFile) { + scriptFile = fmt.Sprintf(constant.ScriptDir+"tc-%s.%s", + caseId+"-"+dateUtils.DateTimeStrLong(time.Now()), LangMap[langType]["extName"]) + } + + fileUtils.MkDirIfNeeded(vari.Prefer.WorkDir + constant.ScriptDir) + *casePaths = append(*casePaths, scriptFile) + scriptFullPath := vari.Prefer.WorkDir + scriptFile + + steps := make([]string, 0) + expects := make([]string, 0) + srcCode := make([]string, 0) + + steps = append(steps, "@开头的为含验证点的步骤") + + temp := fmt.Sprintf("\n%sCODE: 此处编写操作步骤代码\n", LangMap[langType]["commentsTag"]) + srcCode = append(srcCode, temp) + + readme := zentaoUtils.ReadResData("res/template/readme.tpl") + "\n" + + StepWidth := 20 + stepDisplayMaxWidth := 0 + computerTestStepWidth(cs.StepArr, &stepDisplayMaxWidth, StepWidth) + + for _, ts := range cs.StepArr { + GenerateTestStepScript(ts, langType, StepWidth, &steps, &expects, &srcCode) + } + + var expectsTxt string + if singleFile { + expectsTxt = strings.Join(expects, "\n") + } else { + expectFile := zentaoUtils.ScriptToExpectName(scriptFullPath) + + expectsTxt = "@file\n" + fileUtils.WriteFile(expectFile, strings.Join(expects, "\n")) + } + + path := fmt.Sprintf("res%stemplate%s", string(os.PathSeparator), string(os.PathSeparator)) + template := zentaoUtils.ReadResData(path + langType + ".tpl") + + content := fmt.Sprintf(template, + caseId, caseInTaskId, taskId, caseTitle, + strings.Join(steps, "\n"), expectsTxt, + readme, + strings.Join(srcCode, "\n")) + + //fmt.Println(content) + + fileUtils.WriteFile(scriptFullPath, content) +} + +func GenerateTestStepScript(ts model.TestStep, langType string, stepWidth int, + steps *[]string, expects *[]string, srcCode *[]string) { + LangMap := GetSupportedScriptLang() + + isGroup := ts.Type == "group" + isCheckPoint := ts.Expect != "" + + stepId := ts.Id + stepTitle := ts.Desc + stepExpect := ts.Expect + stepParent := ts.Parent + + // 处理steps + preFixSpace := 3 + if stepParent != "" && stepParent != "0" { + preFixSpace = 6 + } + + var stepType string + if isGroup { + stepType = "group" + } else { + stepType = "step" + } + + stepIdent := stepType + stepId + if isCheckPoint { + stepIdent = "@" + stepIdent + } + + postFixSpace := stepWidth - preFixSpace - len(stepIdent) + + stepLine := fmt.Sprintf("%*s", preFixSpace, " ") + stepIdent + stepLine += fmt.Sprintf("%*s", postFixSpace, " ") + stepLine += stepTitle + + *steps = append(*steps, stepLine) + + // 处理expects + if isCheckPoint { + expectsLine := "" + + expectsLine = "# " + stepIdent + " \n" + expectsLine += "CODE: " + "期望结果, 可以有多行\n" + + *expects = append(*expects, expectsLine) + } + + // 处理srcCode + if isCheckPoint { + codeLine := LangMap[langType]["printGrammar"] + + codeLine += fmt.Sprintf(" %s %s: %s\n", LangMap[langType]["commentsTag"], stepIdent, stepExpect) + + codeLine += LangMap[langType]["commentsTag"] + "CODE: 输出验证点实际结果\n" + + *srcCode = append(*srcCode, codeLine) + } +} + +func GenSuite(cases []string) { + str := strings.Join(cases, "\n") + + fileUtils.WriteFile(vari.Prefer.WorkDir+constant.ScriptDir+"all."+constant.SuiteExt, str) +} + +func computerTestStepWidth(steps []model.TestStep, stepSDisplayMaxWidth *int, stepWidth int) { + for _, ts := range steps { + length := len(ts.Id) + if length > *stepSDisplayMaxWidth { + *stepSDisplayMaxWidth = length + } + } + *stepSDisplayMaxWidth += stepWidth // prefix space and @step +} diff --git a/src/service/script/script.go b/src/service/script/lang.go similarity index 92% rename from src/service/script/script.go rename to src/service/script/lang.go index 9883303c..67fc833c 100644 --- a/src/service/script/script.go +++ b/src/service/script/lang.go @@ -4,7 +4,7 @@ import "sync" var LangMap map[string]map[string]string -func GetLangMap() map[string]map[string]string { +func GetSupportedScriptLang() map[string]map[string]string { var once sync.Once once.Do(func() { LangMap = map[string]map[string]string{ @@ -55,5 +55,5 @@ func GetLangMap() map[string]map[string]string { } func init() { - GetLangMap() + GetSupportedScriptLang() } diff --git a/src/service/testing/check.go b/src/service/testing/check.go index 724cb362..9c0e4d74 100644 --- a/src/service/testing/check.go +++ b/src/service/testing/check.go @@ -3,7 +3,7 @@ package testingService import ( "github.com/easysoft/zentaoatf/src/model" "github.com/easysoft/zentaoatf/src/utils/const" - i118Utils "github.com/easysoft/zentaoatf/src/utils/i118" + "github.com/easysoft/zentaoatf/src/utils/i118" "github.com/easysoft/zentaoatf/src/utils/log" "github.com/easysoft/zentaoatf/src/utils/string" zentaoUtils "github.com/easysoft/zentaoatf/src/utils/zentao" diff --git a/src/service/testing/suite.go b/src/service/testing/suite.go deleted file mode 100644 index 693f3ece..00000000 --- a/src/service/testing/suite.go +++ /dev/null @@ -1,14 +0,0 @@ -package testingService - -import ( - constant "github.com/easysoft/zentaoatf/src/utils/const" - "github.com/easysoft/zentaoatf/src/utils/file" - "github.com/easysoft/zentaoatf/src/utils/vari" - "strings" -) - -func GenSuite(cases []string) { - str := strings.Join(cases, "\n") - - fileUtils.WriteFile(vari.Prefer.WorkDir+constant.ScriptDir+"all."+constant.SuiteExt, str) -} diff --git a/src/ui/page/pageImport.go b/src/ui/page/pageImport.go index 0d507887..10a491a8 100644 --- a/src/ui/page/pageImport.go +++ b/src/ui/page/pageImport.go @@ -2,8 +2,8 @@ package page import ( "fmt" - "github.com/easysoft/zentaoatf/src/action" "github.com/easysoft/zentaoatf/src/model" + scriptService "github.com/easysoft/zentaoatf/src/service/script" zentaoService "github.com/easysoft/zentaoatf/src/service/zentao" "github.com/easysoft/zentaoatf/src/ui" "github.com/easysoft/zentaoatf/src/ui/widget" @@ -104,7 +104,7 @@ func InitImportPage() error { submitInput := widget.NewButtonWidgetAutoWidth("submitInput", buttonX, 13, "Submit", ImportRequest) ui.ViewMap["import"] = append(ui.ViewMap["import"], submitInput.Name()) - ui.KeyBindsInput(ui.ViewMap["import"]) + ui.AddEventForInputWidgets(ui.ViewMap["import"]) return nil } @@ -162,7 +162,7 @@ func ImportRequest(g *gocui.Gui, v *gocui.View) error { cases = zentaoService.ListCaseByTask(url, taskId) } - count, err := action.Generate(cases, language, singleFile, account, password) + count, err := scriptService.Generate(cases, language, singleFile, account, password) if err == nil { configUtils.SaveConfig("", url, params["entityType"], params["entityVal"], productIdInt, projectId, language, singleFile, diff --git a/src/ui/page/pageReportBug.go b/src/ui/page/pageReportBug.go index b81bf324..d7b5cd96 100644 --- a/src/ui/page/pageReportBug.go +++ b/src/ui/page/pageReportBug.go @@ -51,7 +51,7 @@ func InitReportBugPage() error { // steps left = right + ui.Space stepsWidth := pageWidth - left - ui.Space + x - stepsInput := widget.NewTextWidgetWithHeight("stepsInput", left, y, stepsWidth, pageHeight-2, bug.Steps) + stepsInput := widget.NewTextareaWidget("stepsInput", left, y, stepsWidth, pageHeight-2, bug.Steps) stepsInput.Title = "Steps" ui.ViewMap["reportBug"] = append(ui.ViewMap["reportBug"], stepsInput.Name()) @@ -114,7 +114,7 @@ func InitReportBugPage() error { buttonX+11, y, "Cancel", cancelReportBug) ui.ViewMap["reportBug"] = append(ui.ViewMap["reportBug"], cancelReportBugInput.Name()) - ui.KeyBindsInput(ui.ViewMap["reportBug"]) + ui.AddEventForInputWidgets(ui.ViewMap["reportBug"]) return nil } @@ -131,11 +131,11 @@ func reportBug(g *gocui.Gui, v *gocui.View) error { title := strings.TrimSpace(titleView.Buffer()) stepsStr := strings.TrimSpace(stepsView.Buffer()) - moduleStr := strings.TrimSpace(ui.GetSelectedLineVal(moduleView)) - typeStr := strings.TrimSpace(ui.GetSelectedLineVal(typeView)) - versionStr := strings.TrimSpace(ui.GetSelectedLineVal(versionView)) - severityStr := strings.TrimSpace(ui.GetSelectedLineVal(severityView)) - priorityStr := strings.TrimSpace(ui.GetSelectedLineVal(priorityView)) + moduleStr := strings.TrimSpace(ui.GetSelectedRowVal(moduleView)) + typeStr := strings.TrimSpace(ui.GetSelectedRowVal(typeView)) + versionStr := strings.TrimSpace(ui.GetSelectedRowVal(versionView)) + severityStr := strings.TrimSpace(ui.GetSelectedRowVal(severityView)) + priorityStr := strings.TrimSpace(ui.GetSelectedRowVal(priorityView)) if title == "" { v, _ := vari.Cui.View("reportBugMsg") @@ -166,7 +166,7 @@ func bugSelectFieldCheckEvent(filedValMap map[string]int) func(g *gocui.Gui, v * g.SetCurrentView(name) - //line, _ := GetSelectedLine(v, ".*") + //line, _ := GetSelectedRow(v, ".*") //line = strings.TrimSpace(line) // //zentaoUtils.SetBugField(name, line, filedValMap) diff --git a/src/ui/page/pageSwitch.go b/src/ui/page/pageSwitch.go index b8504734..38729501 100644 --- a/src/ui/page/pageSwitch.go +++ b/src/ui/page/pageSwitch.go @@ -38,7 +38,7 @@ func InitSwitchPage() error { submitInput := widget.NewButtonWidgetAutoWidth("submitInput", buttonX, 4, "Switch", SwitchWorkDir) ui.ViewMap["switch"] = append(ui.ViewMap["switch"], submitInput.Name()) - ui.KeyBindsInput(ui.ViewMap["switch"]) + ui.AddEventForInputWidgets(ui.ViewMap["switch"]) return nil } diff --git a/src/ui/page/pageTestResult.go b/src/ui/page/pageTestResult.go index eabc0049..c584dfe3 100644 --- a/src/ui/page/pageTestResult.go +++ b/src/ui/page/pageTestResult.go @@ -40,8 +40,8 @@ func showRun(g *gocui.Gui, v *gocui.View) error { ui.SupportScroll("panelCaseList") ui.SupportScroll("panelCaseResult") - ui.SupportLineHighlight("panelResultList") - ui.SupportLineHighlight("panelCaseList") + ui.SupportRowHighlight("panelResultList") + ui.SupportRowHighlight("panelCaseList") ui.AddLineSelectedEvent("panelResultList", selectResultEvent) ui.AddLineSelectedEvent("panelCaseList", selectCaseEvent) @@ -61,7 +61,7 @@ func selectResultEvent(g *gocui.Gui, v *gocui.View) error { v.Highlight = true - line, _ := ui.GetSelectedLine(v, ".*") + line := ui.GetSelectedRowVal(v) vari.CurrResultDate = line content := make([]string, 0) @@ -90,7 +90,7 @@ func selectResultEvent(g *gocui.Gui, v *gocui.View) error { func selectCaseEvent(g *gocui.Gui, v *gocui.View) error { v.Highlight = true - caseLine, _ := ui.GetSelectedLine(v, ".*") + caseLine := ui.GetSelectedRowVal(v) caseIdStr := strings.Split(caseLine, "-")[0] caseId, _ := strconv.Atoi(caseIdStr) vari.CurrCaseId = caseId diff --git a/src/ui/uiUtils.go b/src/ui/uiUtils.go index a5dcf680..af12d4c8 100644 --- a/src/ui/uiUtils.go +++ b/src/ui/uiUtils.go @@ -12,15 +12,14 @@ const ( Space = 2 ) -func KeyBindsInput(arr []string) { +func AddEventForInputWidgets(arr []string) { for _, v := range arr { - if IsInput(v) { - AddEventForInputWidth(v) + if isInput(v) { + vari.Cui.SetKeybinding(v, gocui.MouseLeft, gocui.ModNone, SetCurrView(v)) } } } - -func IsInput(v string) bool { +func isInput(v string) bool { return strings.Index(v, "Input") > -1 } @@ -95,7 +94,7 @@ func scrollAction(v *gocui.View, dy int, isSelectWidget bool) error { return nil } -func SupportLineHighlight(name string) error { +func SupportRowHighlight(name string) error { v, _ := vari.Cui.View(name) v.Wrap = true @@ -123,13 +122,6 @@ func SetCurrView(name string) func(g *gocui.Gui, v *gocui.View) error { } } -func AddEventForInputWidth(name string) error { - if err := vari.Cui.SetKeybinding(name, gocui.MouseLeft, gocui.ModNone, SetCurrView(name)); err != nil { - return err - } - return nil -} - func HighlightTab(view string, views []string) { for _, name := range views { v, _ := vari.Cui.View(name) @@ -146,7 +138,12 @@ func HighlightTab(view string, views []string) { } } -func GetSelectedLine(v *gocui.View, reg string) (string, error) { +func GetSelectedRowVal(v *gocui.View) string { + line, _ := getSelectedRow(v, ".*") + + return line +} +func getSelectedRow(v *gocui.View, reg string) (string, error) { var line string var err error @@ -164,9 +161,3 @@ func GetSelectedLine(v *gocui.View, reg string) (string, error) { return line, nil } - -func GetSelectedLineVal(v *gocui.View) string { - line, _ := GetSelectedLine(v, ".*") - - return line -} diff --git a/src/ui/widget/widgetSelect.go b/src/ui/widget/widgetSelect.go index 20057405..e59cac6a 100644 --- a/src/ui/widget/widgetSelect.go +++ b/src/ui/widget/widgetSelect.go @@ -49,7 +49,7 @@ func (w *SelectWidget) Layout() (*gocui.View, error) { v, _ := vari.Cui.SetView(w.name, w.x, w.y, w.x+w.w, w.y+w.h) v.Highlight = true ui.SupportScroll(w.name) - ui.SupportLineHighlight(w.name) + ui.SupportRowHighlight(w.name) v.Title = w.title @@ -62,7 +62,7 @@ func (w *SelectWidget) Layout() (*gocui.View, error) { _, height := v.Size() for true { - line, _ := ui.GetSelectedLine(v, ".*") + line := ui.GetSelectedRowVal(v) if w.defaultt != "" { if line == w.defaultt { break diff --git a/src/ui/widget/widgetText.go b/src/ui/widget/widgetText.go index 4b5cfd1f..cf7082bd 100644 --- a/src/ui/widget/widgetText.go +++ b/src/ui/widget/widgetText.go @@ -27,7 +27,7 @@ func NewTextWidget(name string, x, y, w int, text string) *gocui.View { return v } -func NewTextWidgetWithHeight(name string, x, y, w, h int, text string) *gocui.View { +func NewTextareaWidget(name string, x, y, w, h int, text string) *gocui.View { widget := TextWidget{name: name, x: x, y: y, w: w, h: h, text: text} v, _ := widget.Layout() return v -- GitLab