rpgsheet

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit cedf8a2155851dec8d6dfd2b1396d0e919048191
parent bef731592abd14b92c61a6df35e314c84d090075
Author: Skylar Hill <stellarskylark@posteo.net>
Date:   Sun,  5 Jun 2022 00:38:17 -0500

Capitalize first word even if it's normally not capitalized

Diffstat:
Msrc/utils.nim | 15+++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/src/utils.nim b/src/utils.nim @@ -23,16 +23,19 @@ proc find*[T](list: seq[T], item: T): int = result = -1 proc fancyDisplay*(exp: string, maxLen: int): string = - result = + var working = exp + working = if maxLen == -1: exp else: exp[0..min(maxLen-1, exp.len-1)] - result = result.replace("_", " ") - result = result.replace("~", "-") - for word in result.split(" "): - if word notin noCap: - result = result.replace(word, word.capitalizeAscii) + working = working.replace("_", " ") + working = working.replace("~", "-") + var words = working.split(" ") + for i in 0..words.high: + if words[i] notin noCap or i == 0: + words[i] = words[i].capitalizeAscii + result = words.join(" ") proc deFancy*(display: string): string = result = display.replace(" ", "_")