aboutsummaryrefslogtreecommitdiff
path: root/go-src/windows.go
diff options
context:
space:
mode:
Diffstat (limited to 'go-src/windows.go')
-rw-r--r--go-src/windows.go100
1 files changed, 97 insertions, 3 deletions
diff --git a/go-src/windows.go b/go-src/windows.go
index 73f8733..40f56fc 100644
--- a/go-src/windows.go
+++ b/go-src/windows.go
@@ -103,6 +103,7 @@ func chatsWindow(values ...string) {
nextWindow := handleInputActions(input, true,
inputAction{"C", createChatWindow, nil},
+ inputAction{"E", editChatsWindow, nil},
inputAction{"H", chatsWindow, []string{values[0], showHelp}},
)
@@ -140,6 +141,99 @@ func createChatWindow(values ...string) {
defer chatWindow(inputs[0])
}
+func editChatsWindow(values ...string) {
+ csi.ClearScreen()
+
+ initPaginatedValues(0, &values)
+
+ ui.NormalBox(true, editChatsNavTitle)
+
+ ownChats := getOwnChats()
+ ui.EmptyLines(pageSize + 3) // empty line + message lines + page number line + empty line
+
+ customLinesBelow := utils.If(values[1] == showHelp).Int(3, 2)
+
+ lastLine := -1
+ go routinePaginatedSubwindow(&ownChats,
+ func(s *[]string) { *s = getOwnChats() },
+ &lastLine,
+ len(values[0]),
+ customLinesBelow,
+ true,
+ )
+
+ if values[1] == showHelp {
+ ui.TextField(editChatsWindowHelpMsg)
+ }
+
+ input := ui.InputField(editChatsWindowSpec)
+
+ nextWindow := handleInputActions(input, true,
+ inputAction{"B", chatsWindow, nil},
+ inputAction{"H", editChatsWindow, []string{values[0], showHelp}},
+ )
+
+ if nextWindow == nil {
+ defer handleComplexInputActions(input,
+ ownChats,
+ " : ",
+ &values[0],
+ editChatsWindow,
+ values,
+ editChatWindow,
+ chatNameExists,
+ )
+ } else {
+ defer nextWindow()
+ }
+ lastLine = -2
+}
+
+func editChatWindow(values ...string) {
+ csi.ClearScreen()
+
+ currChat := getChat(values[0])
+
+ ui.NormalBox(true, editChatNavTitle)
+ ui.NumberedFields(
+ chatNameInName+" : "+currChat.Name,
+ chatDescInName+" : "+currChat.Description,
+ )
+
+ ui.EmptyLine()
+ if len(values) > 1 {
+ if values[1] == showHelp {
+ ui.TextField(editChatWindowHelpMsg)
+ }
+ }
+ input := ui.InputField(editChatWindowSpec)
+
+ nextWindow := handleInputActions(input, false,
+ inputAction{"B", editChatsWindow, nil},
+ inputAction{"H", editChatWindow, []string{values[0], showHelp}},
+ )
+
+ if nextWindow == nil {
+ forReturn := func(...string) {
+ defer editChatWindow(values...)
+ }
+ defer validatedMultiForm(input, forReturn,
+ multiFormProp{int(chatNameProp), editChatNameNavTitle,
+ formInput{newChatNameInName, chatNameSpec, stringValidChatName},
+ func(fvalues []string) bool { return currChat.UpdateName(fvalues[0], fvalues[1]) },
+ nil,
+ },
+ multiFormProp{int(chatDescriptionProp), editNameNavTitle,
+ formInput{newChatDescInName, chatDescSpec, stringValidChatDesc},
+ func(fvalues []string) bool { return currChat.UpdateDescription(fvalues[0], fvalues[1]) },
+ nil,
+ },
+ )
+ } else {
+ defer nextWindow()
+ }
+}
+
func chatWindow(values ...string) {
csi.ClearScreen()
@@ -339,13 +433,13 @@ func accountWindow(values ...string) {
defer validatedMultiForm(input, accountWindow,
multiFormProp{int(userPasswordProp), editPasswordNavTitle,
formInput{newPasswordInName, passwordSpec, stringValidPassword},
- func(values []string) bool { return loggedInUser.UpdatePassword(values[0], values[1]) },
+ func(fvalues []string) bool { return loggedInUser.UpdatePassword(fvalues[0], fvalues[1]) },
nil,
},
multiFormProp{int(userNameProp), editNameNavTitle,
formInput{newNameInName, nameSpec, stringValidName},
- func(values []string) bool { return loggedInUser.UpdateName(values[0], values[1]) },
- func(values []string) { loggedInUser.Name = values[1] },
+ func(fvalues []string) bool { return loggedInUser.UpdateName(fvalues[0], fvalues[1]) },
+ func(fvalues []string) { loggedInUser.Name = fvalues[1] },
},
)
} else {