aboutsummaryrefslogtreecommitdiff
path: root/go-src/windowsHelpers.go
diff options
context:
space:
mode:
authorSyndamia <kamen.d.mladenov@protonmail.com>2021-07-22 13:16:48 +0300
committerSyndamia <kamen.d.mladenov@protonmail.com>2021-07-22 13:16:48 +0300
commitffc2c1273183b488de9cc4fc282379c2a042bd6d (patch)
tree96be6929f43e8032976f976a991f9c56ae7cb971 /go-src/windowsHelpers.go
parent1f15111c6e44ea7e855fadc187a19234640e161c (diff)
downloadctfc-ffc2c1273183b488de9cc4fc282379c2a042bd6d.tar
ctfc-ffc2c1273183b488de9cc4fc282379c2a042bd6d.tar.gz
ctfc-ffc2c1273183b488de9cc4fc282379c2a042bd6d.zip
Improved printing multiple fields workflow, implemented routine pagination in chats window, implemented routine pagination supoprt for help line
Diffstat (limited to 'go-src/windowsHelpers.go')
-rw-r--r--go-src/windowsHelpers.go16
1 files changed, 10 insertions, 6 deletions
diff --git a/go-src/windowsHelpers.go b/go-src/windowsHelpers.go
index 909a673..fb530c1 100644
--- a/go-src/windowsHelpers.go
+++ b/go-src/windowsHelpers.go
@@ -22,8 +22,8 @@ func paginate(page int, messages ...string) []string {
// Must be run in a routine ( go routinePaginatedSubwindow(...) )
// There must be empty lines for the subwindow
-func routinePaginatedSubwindow(messages *[]string, updateMessages func(*[]string), lastLine *int, page int) {
- for *lastLine > -1 {
+func routinePaginatedSubwindow(messages *[]string, updateMessages func(*[]string), lastLine *int, page int, customLinesBelow int, numbered bool) {
+ for *lastLine > -2 {
// Update messages, if we've already shown the last message
if *lastLine == len(*messages)-1 {
updateMessages(messages)
@@ -33,17 +33,21 @@ func routinePaginatedSubwindow(messages *[]string, updateMessages func(*[]string
*lastLine = len(*messages) - 1
csi.SaveCursorPosition()
- csi.MoveCursorUpN(pageSize + 2) // +2 because of the input and pagination lines
+ csi.MoveCursorUpN(pageSize + 1 + customLinesBelow)
csi.MoveCursorToBeginningOfLine()
pageMessages := paginate(page, *messages...)
+
// Leaves empty lines at the top, if there aren't enough messages to fill a full page
+ // Works on the assumption that there are ui.EmptyLine(), where messages would be printed
for i := 0; i < pageSize-len(pageMessages); i++ {
csi.MoveCursorDown()
}
- for _, v := range pageMessages {
- csi.ClearLine()
- ui.TextField(v)
+
+ if numbered {
+ ui.NumberedFields(pageMessages...)
+ } else {
+ ui.TextFields(pageMessages...)
}
ui.PageField(page, totalPages(len(*messages)))