aboutsummaryrefslogtreecommitdiff
path: root/go-src/windows.go
diff options
context:
space:
mode:
authorSyndamia <kamen.d.mladenov@protonmail.com>2021-07-22 15:41:06 +0300
committerSyndamia <kamen.d.mladenov@protonmail.com>2021-07-22 15:41:06 +0300
commit8c758581a466f640201d044bf18a95882e1c86c3 (patch)
tree4868b36cc70f70318815e16f925f6d9f2a7c7243 /go-src/windows.go
parent33126a3f73209ac27a1926f92798cc53fa6f3e76 (diff)
downloadctfc-8c758581a466f640201d044bf18a95882e1c86c3.tar
ctfc-8c758581a466f640201d044bf18a95882e1c86c3.tar.gz
ctfc-8c758581a466f640201d044bf18a95882e1c86c3.zip
Implemented chats page number selection and fixed initPaginatiedValues function
Diffstat (limited to 'go-src/windows.go')
-rw-r--r--go-src/windows.go27
1 files changed, 22 insertions, 5 deletions
diff --git a/go-src/windows.go b/go-src/windows.go
index 3d9c919..afc4e77 100644
--- a/go-src/windows.go
+++ b/go-src/windows.go
@@ -5,6 +5,7 @@ import (
"strings"
"gitlab.com/Syndamia/ctfc/go-src/csi"
+ ctfcmath "gitlab.com/Syndamia/ctfc/go-src/ctfcMath"
"gitlab.com/Syndamia/ctfc/go-src/ui"
"gitlab.com/Syndamia/ctfc/go-src/utils"
)
@@ -81,7 +82,7 @@ func registerWindow(values ...string) {
func chatsWindow(values ...string) {
csi.ClearScreen()
- initPaginatedValues(0, values)
+ initPaginatedValues(0, &values)
ui.NormalBox(true, directMessagesNavTitle, accountNavTitle, logoutNavTitle)
@@ -112,10 +113,26 @@ func chatsWindow(values ...string) {
if handled == nil {
// If user input is number, navigate to chat of given number, else show error
- if chatI, err := strconv.Atoi(input); chatI >= 0 && chatI <= len(allChats) && err == nil {
- defer chatWindow(strings.Split(allChats[chatI-1], " : ")[0])
+ chatI, err := strconv.Atoi(input)
+ if chatI >= 0 && chatI <= len(allChats) && err == nil {
+ defer chatWindow(strings.Split(allChats[ctfcmath.MaxInt(len(allChats)-pageSize*len(values[0]), 0)+chatI-1], " : ")[0])
} else {
- defer showError(invalidCommand, chatsWindow)
+ switch input {
+ case ">":
+ // If possible, increment to the next page (adds a dot to the end of the string)
+ if len(values[0]) < totalPages(len(allChats)) {
+ values[0] += "."
+ }
+ case "<":
+ // If possible, decrement to the previous page (removes a dot from the string)
+ if len(values[0]) > 1 {
+ utils.StrShortenRight(&values[0], 1)
+ }
+ default:
+ defer showError(invalidCommand, chatsWindow)
+ }
+
+ defer chatsWindow(values...)
}
} else {
defer handled()
@@ -148,7 +165,7 @@ func chatWindow(values ...string) {
// We determine page number by length of a string
// This method should be faster than having to cast to int all the time
- initPaginatedValues(1, values)
+ initPaginatedValues(1, &values)
currChat := getChat(values[0])