Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Sampler
Commits
14aaab24
Commit
14aaab24
authored
6 years ago
by
sqshq
Browse files
Options
Download
Email Patches
Plain Diff
component selection enhancements
parent
8f2cf3ce
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
component/layout/layout.go
+17
-15
component/layout/layout.go
component/menu.go
+1
-1
component/menu.go
with
18 additions
and
16 deletions
+18
-16
component/layout/layout.go
+
17
-
15
View file @
14aaab24
...
...
@@ -232,35 +232,37 @@ func (l *Layout) moveSelection(direction string) {
previouslySelectedCornerPoint
=
component
.
GetRectLeftSideCenter
(
previouslySelected
.
GetRect
())
newlySelectedCornerPoint
=
component
.
GetRectRightSideCenter
(
l
.
getComponent
(
newlySelectedIndex
)
.
GetRect
())
currentCornerPoint
=
component
.
GetRectRightSideCenter
(
current
.
GetRect
())
if
currentCornerPoint
.
X
>
previouslySelectedCornerPoint
.
X
{
continue
}
case
console
.
KeyRight
:
previouslySelectedCornerPoint
=
component
.
GetRectRightSideCenter
(
previouslySelected
.
GetRect
())
newlySelectedCornerPoint
=
component
.
GetRectLeftSideCenter
(
l
.
getComponent
(
newlySelectedIndex
)
.
GetRect
())
currentCornerPoint
=
component
.
GetRectLeftSideCenter
(
current
.
GetRect
())
if
currentCornerPoint
.
X
<
previouslySelectedCornerPoint
.
X
{
continue
}
case
console
.
KeyUp
:
previouslySelectedCornerPoint
=
component
.
GetRectTopSideCenter
(
previouslySelected
.
GetRect
())
newlySelectedCornerPoint
=
component
.
GetRectBottomSideCenter
(
l
.
getComponent
(
newlySelectedIndex
)
.
GetRect
())
currentCornerPoint
=
component
.
GetRectBottomSideCenter
(
current
.
GetRect
())
if
currentCornerPoint
.
Y
>
previouslySelectedCornerPoint
.
Y
{
continue
}
case
console
.
KeyDown
:
previouslySelectedCornerPoint
=
component
.
GetRectBottomSideCenter
(
previouslySelected
.
GetRect
())
newlySelectedCornerPoint
=
component
.
GetRectTopSideCenter
(
l
.
getComponent
(
newlySelectedIndex
)
.
GetRect
())
currentCornerPoint
=
component
.
GetRectTopSideCenter
(
current
.
GetRect
())
if
currentCornerPoint
.
Y
<
previouslySelectedCornerPoint
.
Y
{
continue
}
}
if
component
.
GetDistance
(
previouslySelectedCornerPoint
,
currentCornerPoint
)
<
component
.
GetDistance
(
previouslySelectedCornerPoint
,
newlySelectedCornerPoint
)
{
newlySelectedIndex
=
i
switch
direction
{
case
console
.
KeyLeft
:
fallthrough
case
console
.
KeyRight
:
if
ui
.
AbsInt
(
currentCornerPoint
.
X
-
previouslySelectedCornerPoint
.
X
)
<=
ui
.
AbsInt
(
newlySelectedCornerPoint
.
X
-
previouslySelectedCornerPoint
.
X
)
{
if
ui
.
AbsInt
(
currentCornerPoint
.
Y
-
previouslySelectedCornerPoint
.
Y
)
<=
ui
.
AbsInt
(
newlySelectedCornerPoint
.
Y
-
previouslySelectedCornerPoint
.
Y
)
{
newlySelectedIndex
=
i
}
}
case
console
.
KeyUp
:
fallthrough
case
console
.
KeyDown
:
if
ui
.
AbsInt
(
currentCornerPoint
.
Y
-
previouslySelectedCornerPoint
.
Y
)
<=
ui
.
AbsInt
(
newlySelectedCornerPoint
.
Y
-
previouslySelectedCornerPoint
.
Y
)
{
if
ui
.
AbsInt
(
currentCornerPoint
.
X
-
previouslySelectedCornerPoint
.
X
)
<=
ui
.
AbsInt
(
newlySelectedCornerPoint
.
X
-
previouslySelectedCornerPoint
.
X
)
{
newlySelectedIndex
=
i
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
component/menu.go
+
1
-
1
View file @
14aaab24
...
...
@@ -122,7 +122,7 @@ func (m *Menu) Draw(buffer *ui.Buffer) {
func
(
m
*
Menu
)
renderHighlight
(
buffer
*
ui
.
Buffer
)
{
arrowsText
:=
"Use mouse or
arrows
for selection"
arrowsText
:=
"Use mouse or
keyboard
for selection"
optionsText
:=
"<ENTER> to view options"
resumeText
:=
"<ESC> to resume"
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help