aboutsummaryrefslogtreecommitdiff
path: root/ui
diff options
context:
space:
mode:
authorVidhu Kant Sharma <vidhukant@vidhukant.xyz>2022-07-03 22:57:06 +0530
committerVidhu Kant Sharma <vidhukant@vidhukant.xyz>2022-07-03 22:57:06 +0530
commitbd0da056a9f4c1246ad5a980b1c824b7382478cf (patch)
tree3aedc5be2f841f8492b176cc77dcc95087caeede /ui
parent8494b2933908d54d0c64ca08d877efe4e3d8d7b3 (diff)
dynamically handling prompt length, search length, offset, etc
Diffstat (limited to 'ui')
-rw-r--r--ui/actions.go10
-rw-r--r--ui/episodes.go4
-rw-r--r--ui/search.go8
-rw-r--r--ui/ui.go21
4 files changed, 27 insertions, 16 deletions
diff --git a/ui/actions.go b/ui/actions.go
index b6bbf16..7831fe4 100644
--- a/ui/actions.go
+++ b/ui/actions.go
@@ -41,9 +41,6 @@ type MangaAction struct {
}
func AnimeActionMenu(animeIsAdded bool) func(a.Anime) {
- // TODO: load promptLength from config
- promptLength := 5
-
options := []AnimeAction {
{"Set Status", "Set status for an anime (watching, dropped, etc)", AnimeStatusMenu},
{"Set Episodes", "Set number of episodes watched", EpisodeInput},
@@ -83,7 +80,7 @@ func AnimeActionMenu(animeIsAdded bool) func(a.Anime) {
Items: options,
Templates: template,
Searcher: searcher,
- Size: promptLength,
+ Size: PromptLength,
}
res, _, err := prompt.Run()
@@ -96,9 +93,6 @@ func AnimeActionMenu(animeIsAdded bool) func(a.Anime) {
}
func MangaActionMenu(mangaIsAdded bool) func(m.Manga) {
- // TODO: load promptLength from config
- promptLength := 5
-
options := []MangaAction {
{"Set Status", "Set status for a manga (reading, dropped, etc)", MangaStatusMenu},
{"Set Chapters", "Set number of chapters read", ChapterInput},
@@ -138,7 +132,7 @@ func MangaActionMenu(mangaIsAdded bool) func(m.Manga) {
Items: options,
Templates: template,
Searcher: searcher,
- Size: promptLength,
+ Size: PromptLength,
}
res, _, err := prompt.Run()
diff --git a/ui/episodes.go b/ui/episodes.go
index 3b5bbe8..f8ad28a 100644
--- a/ui/episodes.go
+++ b/ui/episodes.go
@@ -31,11 +31,11 @@ import (
// very short name I know
func CreateEpisodeUpdateConfirmationMessage(title string, prevEpNum, epNum int) string {
- return fmt.Sprintf("\x1b[35m%s\x1b[0m Episodes Updated :: \x1b[1;33m%d\x1b[0m -> \x1b[1;36m%d\x1b[0m", title, prevEpNum, epNum)
+ return fmt.Sprintf("\x1b[35m%s\x1b[0m Episodes Watched :: \x1b[1;33m%d\x1b[0m -> \x1b[1;36m%d\x1b[0m", title, prevEpNum, epNum)
}
func CreateChapterUpdateConfirmationMessage(title string, prevChNum, chNum int) string {
- return fmt.Sprintf("\x1b[35m%s\x1b[0m Chapters Updated :: \x1b[1;33m%d\x1b[0m -> \x1b[1;36m%d\x1b[0m", title, prevChNum, chNum)
+ return fmt.Sprintf("\x1b[35m%s\x1b[0m Chapters Read :: \x1b[1;33m%d\x1b[0m -> \x1b[1;36m%d\x1b[0m", title, prevChNum, chNum)
}
func EpisodeInput(anime a.Anime) {
diff --git a/ui/search.go b/ui/search.go
index c62006a..7ea045a 100644
--- a/ui/search.go
+++ b/ui/search.go
@@ -30,8 +30,6 @@ import (
// only search animes probably only now
func AnimeSearch(label, searchString string) a.Anime {
- // TODO: load promptLength from config
- promptLength := 5
animes := mal.SearchAnime(searchString)
template := &p.SelectTemplates {
@@ -57,7 +55,7 @@ More Details To Be Added Later
Items: animes,
Templates: template,
Searcher: searcher,
- Size: promptLength,
+ Size: PromptLength,
}
animeIndex, _, err := prompt.Run()
@@ -70,8 +68,6 @@ More Details To Be Added Later
}
func MangaSearch(label, searchString string) m.Manga {
- // TODO: load promptLength from config
- promptLength := 5
mangas := mal.SearchManga(searchString)
template := &p.SelectTemplates {
@@ -97,7 +93,7 @@ More Details To Be Added Later
Items: mangas,
Templates: template,
Searcher: searcher,
- Size: promptLength,
+ Size: PromptLength,
}
mangaIndex, _, err := prompt.Run()
diff --git a/ui/ui.go b/ui/ui.go
new file mode 100644
index 0000000..74bf0f3
--- /dev/null
+++ b/ui/ui.go
@@ -0,0 +1,21 @@
+/*
+macli - Unofficial CLI-Based MyAnimeList Client
+Copyright © 2022 Vidhu Kant Sharma <vidhukant@vidhukant.xyz>
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+package ui
+
+var PromptLength int