-
Notifications
You must be signed in to change notification settings - Fork 54
Feature/help #74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Feature/help #74
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
eaed590
Toggle help window in procs page
anihm136 278e705
Refactor to separate help message from widget
anihm136 01abbf9
Use ui.List instead of ui.Block
anihm136 7f15a77
Fix resizing of help widget
anihm136 bf401d8
Add keybindings for main and `proc -pid` pages
anihm136 b69ac3c
Add help widget to `proc -pid` page
anihm136 cac0555
Add help widget to main page
anihm136 d678a72
Fix escape keybinding to clear screen first
anihm136 bc03d60
Fix resizing issue
anihm136 e716fd1
Fix formatting error
anihm136 a570e65
Add scroll in help menu, fix render delay
anihm136 21b8449
Fix formatting and spacing issues
anihm136 4d1c6e9
Fix procGraphs rendering
anihm136 8458677
Remove unneccesary comment
anihm136 4c5f790
Use slice of strings instead of string
anihm136 9bd359d
Add kill keybind to help message
anihm136 0886a8c
Remove unused module
anihm136 b0fcd36
Re-add scroll in help menu
anihm136 aeefd61
Fix formatting issue
anihm136 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* | ||
Copyright © 2020 The PES Open Source Team pesos@pes.edu | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package help | ||
|
||
import ( | ||
ui "github.com/gizak/termui/v3" | ||
"github.com/gizak/termui/v3/widgets" | ||
) | ||
|
||
var KEYBINDS []string | ||
|
||
type HelpMenu struct { | ||
*widgets.List | ||
} | ||
|
||
func NewHelpMenu() *HelpMenu { | ||
return &HelpMenu{ | ||
List: widgets.NewList(), | ||
} | ||
} | ||
|
||
func (help *HelpMenu) Resize(termWidth, termHeight int) { | ||
textWidth := 50 | ||
for _, line := range KEYBINDS { | ||
if textWidth < len(line) { | ||
textWidth = len(line) + 2 | ||
} | ||
} | ||
textHeight := len(KEYBINDS) + 3 | ||
x := (termWidth - textWidth) / 2 | ||
y := (termHeight - textHeight) / 2 | ||
if x < 0 { | ||
x = 0 | ||
textWidth = termWidth | ||
} | ||
if y < 0 { | ||
y = 0 | ||
textHeight = termHeight | ||
} | ||
|
||
help.List.SetRect(x, y, textWidth+x, textHeight+y) | ||
} | ||
|
||
func (help *HelpMenu) Draw(buf *ui.Buffer) { | ||
help.List.Title = " Keybindings " | ||
|
||
help.List.Rows = KEYBINDS | ||
help.List.TextStyle = ui.NewStyle(ui.ColorYellow) | ||
help.List.WrapText = false | ||
help.List.Draw(buf) | ||
} | ||
|
||
func SelectHelpMenu(page string) { | ||
switch page { | ||
case "proc": | ||
KEYBINDS = PROC_KEYBINDS | ||
case "proc_pid": | ||
KEYBINDS = PROC_PID_KEYBINDS | ||
case "main": | ||
KEYBINDS = MAIN_KEYBINDS | ||
} | ||
} | ||
|
||
func maxInt(a int, b int) int { | ||
if a > b { | ||
return a | ||
AE88 } | ||
return b | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
Copyright © 2020 The PES Open Source Team pesos@pes.edu | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package help | ||
|
||
var PROC_KEYBINDS = []string{ | ||
"Quit: q or <C-c>", | ||
"", | ||
"Process navigation:", | ||
" - k and <Up>: up", | ||
" - j and <Down>: down", | ||
" - <C-u>: half page up", | ||
" - <C-d>: half page down", | ||
" - <C-b>: full page up", | ||
" - <C-f>: full page down", | ||
" - gg and <Home>: jump to top", | ||
" - G and <End>: jump to bottom", | ||
"", | ||
"Process actions:", | ||
" - K and <F9>: Kill process", | ||
} | ||
|
||
var MAIN_KEYBINDS = []string{ | ||
"Quit: q or <C-c>", | ||
} | ||
|
||
var PROC_PID_KEYBINDS = []string{ | ||
"Quit: q or <C-c>", | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.