Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
易企天创
zentaoatf
提交
3f6ab813
Z
zentaoatf
项目概览
易企天创
/
zentaoatf
大约 1 年 前同步成功
通知
11
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
3
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Z
zentaoatf
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
3
Issue
3
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
3f6ab813
编写于
7月 26, 2019
作者:
aaronchen2k2k
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
support Tab, Enter key; use Space key to toggle radio box
上级
5294dd80
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
76 addition
and
52 deletion
+76
-52
src/cui.go
src/cui.go
+33
-45
src/ui/labelWidget.go
src/ui/labelWidget.go
+9
-7
src/ui/panelWidget.go
src/ui/panelWidget.go
+34
-0
未找到文件。
src/cui.go
浏览文件 @
3f6ab813
...
...
@@ -24,13 +24,13 @@ const (
)
var
server
*
httptest
.
Server
var
importViews
[]
string
var
viewMap
map
[
string
]
[]
string
func
main
()
{
server
=
mock
.
Server
(
"case-from-prodoct.json"
)
defer
server
.
Close
()
importViews
=
make
([]
string
,
0
)
viewMap
=
map
[
string
][]
string
{
"root"
:
{},
"import"
:
{}}
g
,
err
:=
gocui
.
NewGui
(
gocui
.
OutputNormal
)
if
err
!=
nil
{
...
...
@@ -54,42 +54,29 @@ func main() {
func
layout
(
g
*
gocui
.
Gui
)
error
{
maxX
,
maxY
:=
g
.
Size
()
ui
.
NewLabelWidget
(
g
,
"qickbar"
,
0
,
0
,
leftWidth
,
""
)
qickbarView
:=
ui
.
NewLabelWidget
(
g
,
"qickbar"
,
0
,
0
,
leftWidth
,
""
)
viewMap
[
"root"
]
=
append
(
viewMap
[
"root"
],
qickbarView
.
Name
())
if
v
,
err
:=
g
.
SetView
(
"import"
,
3
,
0
,
14
,
2
);
err
!=
nil
{
v
.
Frame
=
false
fmt
.
Fprint
(
v
,
" Import "
)
}
if
v
,
err
:=
g
.
SetView
(
"switch"
,
19
,
0
,
31
,
2
);
err
!=
nil
{
v
.
Frame
=
false
fmt
.
Fprint
(
v
,
" Switch "
)
}
importView
:=
ui
.
NewLabelWidget
(
g
,
"import"
,
3
,
0
,
9
,
"Import"
)
viewMap
[
"root"
]
=
append
(
viewMap
[
"root"
],
importView
.
Name
())
importView
.
Frame
=
false
if
v
,
err
:=
g
.
SetView
(
"side"
,
0
,
2
,
leftWidth
,
maxY
-
1
);
err
!=
nil
{
if
err
!=
gocui
.
ErrUnknownView
{
return
err
}
v
.
Highlight
=
true
v
.
SelBgColor
=
gocui
.
ColorGreen
v
.
SelFgColor
=
gocui
.
ColorBlack
}
switchView
:=
ui
.
NewLabelWidget
(
g
,
"switch"
,
19
,
0
,
13
,
"Switch"
)
viewMap
[
"root"
]
=
append
(
viewMap
[
"root"
],
switchView
.
Name
())
switchView
.
Frame
=
false
if
v
,
err
:=
g
.
SetView
(
"main"
,
leftWidth
,
0
,
maxX
-
1
,
maxY
-
10
);
err
!=
nil
{
if
err
!=
gocui
.
ErrUnknownView
{
return
err
}
v
.
Wrap
=
true
}
sideView
:=
ui
.
NewPanelWidget
(
g
,
"side"
,
0
,
2
,
leftWidth
,
maxY
-
3
,
""
)
viewMap
[
"root"
]
=
append
(
viewMap
[
"root"
],
sideView
.
Name
())
if
v
,
err
:=
g
.
SetView
(
"cmd"
,
leftWidth
,
maxY
-
10
,
maxX
-
1
,
maxY
-
1
);
err
!=
nil
{
if
err
!=
gocui
.
ErrUnknownView
{
return
err
}
mainView
:=
ui
.
NewPanelWidget
(
g
,
"main"
,
leftWidth
,
0
,
maxX
-
1
-
leftWidth
,
maxY
-
10
,
""
)
viewMap
[
"root"
]
=
append
(
viewMap
[
"root"
],
mainView
.
Name
())
v
.
Editable
=
true
v
.
Wrap
=
true
v
.
Autoscroll
=
true
}
cmdView
:=
ui
.
NewPanelWidget
(
g
,
"cmd"
,
leftWidth
,
maxY
-
10
,
maxX
-
1
-
leftWidth
,
9
,
""
)
viewMap
[
"root"
]
=
append
(
viewMap
[
"root"
],
cmdView
.
Name
())
cmdView
.
Editable
=
true
cmdView
.
Wrap
=
true
cmdView
.
Autoscroll
=
true
ui
.
NewHelpWidget
(
g
)
...
...
@@ -173,7 +160,7 @@ func importProjectUi(g *gocui.Gui, v *gocui.View) error {
v
.
Frame
=
false
fmt
.
Fprint
(
v
,
"ZentaoUrl"
)
importViews
=
append
(
importViews
,
v
.
Name
())
viewMap
[
"import"
]
=
append
(
viewMap
[
"import"
]
,
v
.
Name
())
}
left
=
right
+
space
...
...
@@ -192,7 +179,7 @@ func importProjectUi(g *gocui.Gui, v *gocui.View) error {
return
err
}
importViews
=
append
(
importViews
,
v
.
Name
())
viewMap
[
"import"
]
=
append
(
viewMap
[
"import"
]
,
v
.
Name
())
}
left
=
slideX
+
2
...
...
@@ -200,7 +187,7 @@ func importProjectUi(g *gocui.Gui, v *gocui.View) error {
if
v
,
err
:=
g
.
SetView
(
"productLabel"
,
left
,
4
,
right
,
6
);
err
!=
nil
{
v
.
Frame
=
false
fmt
.
Fprint
(
v
,
"ProdoctId"
)
importViews
=
append
(
importViews
,
v
.
Name
())
viewMap
[
"import"
]
=
append
(
viewMap
[
"import"
]
,
v
.
Name
())
}
left
=
right
+
space
...
...
@@ -214,7 +201,7 @@ func importProjectUi(g *gocui.Gui, v *gocui.View) error {
v
.
Wrap
=
true
fmt
.
Fprint
(
v
,
"1"
)
importViews
=
append
(
importViews
,
v
.
Name
())
viewMap
[
"import"
]
=
append
(
viewMap
[
"import"
]
,
v
.
Name
())
}
left
=
right
+
space
...
...
@@ -222,7 +209,7 @@ func importProjectUi(g *gocui.Gui, v *gocui.View) error {
if
v
,
err
:=
g
.
SetView
(
"taskLabel"
,
left
,
4
,
right
,
6
);
err
!=
nil
{
v
.
Frame
=
false
fmt
.
Fprint
(
v
,
"or TaskId"
)
importViews
=
append
(
importViews
,
v
.
Name
())
viewMap
[
"import"
]
=
append
(
viewMap
[
"import"
]
,
v
.
Name
())
}
left
=
right
+
space
...
...
@@ -236,7 +223,7 @@ func importProjectUi(g *gocui.Gui, v *gocui.View) error {
v
.
Wrap
=
true
fmt
.
Fprint
(
v
,
"1"
)
importViews
=
append
(
importViews
,
v
.
Name
())
viewMap
[
"import"
]
=
append
(
viewMap
[
"import"
]
,
v
.
Name
())
}
left
=
slideX
+
2
...
...
@@ -244,7 +231,7 @@ func importProjectUi(g *gocui.Gui, v *gocui.View) error {
if
v
,
err
:=
g
.
SetView
(
"languageLabel"
,
left
,
7
,
right
,
9
);
err
!=
nil
{
v
.
Frame
=
false
fmt
.
Fprint
(
v
,
"Language"
)
importViews
=
append
(
importViews
,
v
.
Name
())
viewMap
[
"import"
]
=
append
(
viewMap
[
"import"
]
,
v
.
Name
())
}
left
=
right
+
space
...
...
@@ -258,7 +245,7 @@ func importProjectUi(g *gocui.Gui, v *gocui.View) error {
v
.
Wrap
=
true
fmt
.
Fprint
(
v
,
"python"
)
importViews
=
append
(
importViews
,
v
.
Name
())
viewMap
[
"import"
]
=
append
(
viewMap
[
"import"
]
,
v
.
Name
())
}
left
=
right
+
space
...
...
@@ -266,7 +253,7 @@ func importProjectUi(g *gocui.Gui, v *gocui.View) error {
if
v
,
err
:=
g
.
SetView
(
"singleFileLabel"
,
left
,
7
,
right
,
9
);
err
!=
nil
{
v
.
Frame
=
false
fmt
.
Fprint
(
v
,
"SingleFile"
)
importViews
=
append
(
importViews
,
v
.
Name
())
viewMap
[
"import"
]
=
append
(
viewMap
[
"import"
]
,
v
.
Name
())
}
left
=
right
+
space
...
...
@@ -275,13 +262,14 @@ func importProjectUi(g *gocui.Gui, v *gocui.View) error {
if
err
!=
gocui
.
ErrUnknownView
{
return
err
}
v
.
Frame
=
false
if
err
:=
g
.
SetKeybinding
(
"singleFileInput"
,
gocui
.
KeySpace
,
gocui
.
ModNone
,
changeSingleFile
);
err
!=
nil
{
return
err
}
fmt
.
Fprint
(
v
,
"[*]"
)
importViews
=
append
(
importViews
,
v
.
Name
())
viewMap
[
"import"
]
=
append
(
viewMap
[
"import"
]
,
v
.
Name
())
}
buttonX
:=
(
maxX
-
leftWidth
)
/
2
+
leftWidth
-
buttonWidth
...
...
@@ -301,7 +289,7 @@ func importProjectUi(g *gocui.Gui, v *gocui.View) error {
if
err
:=
g
.
SetKeybinding
(
"submitInput"
,
gocui
.
KeyEnter
,
gocui
.
ModNone
,
importProjectRequest
);
err
!=
nil
{
return
err
}
importViews
=
append
(
importViews
,
v
.
Name
())
viewMap
[
"import"
]
=
append
(
viewMap
[
"import"
]
,
v
.
Name
())
}
return
nil
...
...
@@ -370,7 +358,7 @@ func changeSingleFile(g *gocui.Gui, v *gocui.View) error {
}
func
toggleInput
(
g
*
gocui
.
Gui
,
v
*
gocui
.
View
)
error
{
nextView
:=
ui
.
GetNextView
(
v
.
Name
(),
importViews
)
nextView
:=
ui
.
GetNextView
(
v
.
Name
(),
viewMap
[
"import"
]
)
if
nextView
!=
""
{
_
,
err
:=
g
.
SetCurrentView
(
nextView
)
...
...
src/ui/labelWidget.go
浏览文件 @
3f6ab813
...
...
@@ -16,24 +16,26 @@ type LabelWidget struct {
label
string
}
func
NewLabelWidget
(
g
*
gocui
.
Gui
,
name
string
,
x
,
y
,
w
int
,
label
string
)
{
func
NewLabelWidget
(
g
*
gocui
.
Gui
,
name
string
,
x
,
y
,
w
int
,
label
string
)
*
gocui
.
View
{
widget
:=
LabelWidget
{
name
:
name
,
x
:
x
,
y
:
y
,
w
:
w
,
label
:
label
}
widget
.
Layout
(
g
)
v
,
_
:=
widget
.
Layout
(
g
)
return
v
}
func
NewLabelWidgetAutoWidth
(
g
*
gocui
.
Gui
,
name
string
,
x
,
y
int
,
label
string
)
{
func
NewLabelWidgetAutoWidth
(
g
*
gocui
.
Gui
,
name
string
,
x
,
y
int
,
label
string
)
*
gocui
.
View
{
widget
:=
&
LabelWidget
{
name
:
name
,
x
:
x
,
y
:
y
,
w
:
len
(
label
)
+
1
,
label
:
label
}
widget
.
Layout
(
g
)
v
,
_
:=
widget
.
Layout
(
g
)
return
v
}
func
(
w
*
LabelWidget
)
Layout
(
g
*
gocui
.
Gui
)
error
{
func
(
w
*
LabelWidget
)
Layout
(
g
*
gocui
.
Gui
)
(
*
gocui
.
View
,
error
)
{
v
,
err
:=
g
.
SetView
(
w
.
name
,
w
.
x
,
w
.
y
,
w
.
x
+
w
.
w
,
w
.
y
+
2
)
if
err
!=
nil
{
if
err
!=
gocui
.
ErrUnknownView
{
return
err
return
nil
,
err
}
fmt
.
Fprint
(
v
,
w
.
label
)
}
return
nil
return
v
,
nil
}
src/ui/panelWidget.go
0 → 100644
浏览文件 @
3f6ab813
package
ui
import
(
"fmt"
"github.com/jroimartin/gocui"
)
const
()
type
PanelWidget
struct
{
name
string
x
,
y
int
w
int
h
int
body
string
}
func
NewPanelWidget
(
g
*
gocui
.
Gui
,
name
string
,
x
,
y
,
w
,
h
int
,
body
string
)
*
gocui
.
View
{
widget
:=
PanelWidget
{
name
:
name
,
x
:
x
,
y
:
y
,
w
:
w
,
h
:
h
,
body
:
body
}
v
,
_
:=
widget
.
Layout
(
g
)
return
v
}
func
(
w
*
PanelWidget
)
Layout
(
g
*
gocui
.
Gui
)
(
*
gocui
.
View
,
error
)
{
v
,
err
:=
g
.
SetView
(
w
.
name
,
w
.
x
,
w
.
y
,
w
.
x
+
w
.
w
,
w
.
y
+
w
.
h
)
if
err
!=
nil
{
if
err
!=
gocui
.
ErrUnknownView
{
return
nil
,
err
}
fmt
.
Fprint
(
v
,
w
.
body
)
}
return
v
,
nil
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录