aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-12-11 18:37:26 +0100
committerbptato <nincsnevem662@gmail.com>2024-12-11 19:40:26 +0100
commitd4c40ab5c1c1fe2df49f54d61632c1c979e63514 (patch)
treee1fcdc92d4559884c6bb22cf4d7c4b48d0e25039 /src/utils
parentf2454bf6ecd79f454c54b5ccd2cdcc513d232c4b (diff)
downloadchawan-d4c40ab5c1c1fe2df49f54d61632c1c979e63514.tar.gz
pager, mailcap: misc fixes, add prompt for global mailcap
In the past, Chawan would read global mailcap (/etc/mailcap, ...) too, but every now and then that would run entries that I didn't even know existed and definitely didn't intend to run. So I changed it to only use ~/.mailcap, but this meant users now had to add mailcap entries for every single mime type. At some point I also changed application/octet-stream to always save to disk, which is usually nice except when a text file is misrecognized as binary. Often times I just want to decide myself what to do. So now there are two layers. First, the global mailcap files (path as per RFC) prompt before executing. Then there is ~/.chawan/auto.mailcap (or ~/.config/chawan/auto.mailcap) which runs entries automatically. If you press shift before selecting an option in the prompt, the corresponding entry gets copied to auto.mailcap. It's also possible to type a new entry on the fly. Overall I think it's quite convenient. One unfortunate side effect is that existing users will have to migrate their entries to auto.mailcap, or redefine external.auto-mailcap to e.g. ~/.mailcap, but this seems acceptable.
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/twtstr.nim12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/utils/twtstr.nim b/src/utils/twtstr.nim
index 2734e5ce..5fe93507 100644
--- a/src/utils/twtstr.nim
+++ b/src/utils/twtstr.nim
@@ -217,16 +217,20 @@ func equalsIgnoreCase*(s1, s2: string): bool {.inline.} =
return s1.cmpIgnoreCase(s2) == 0
func startsWithIgnoreCase*(s1, s2: openArray[char]): bool =
- if s1.len < s2.len: return false
+ if s1.len < s2.len:
+ return false
for i in 0 ..< s2.len:
if s1[i].toLowerAscii() != s2[i].toLowerAscii():
return false
return true
func endsWithIgnoreCase*(s1, s2: openArray[char]): bool =
- if s1.len < s2.len: return false
- for i in countdown(s2.high, 0):
- if s1[i].toLowerAscii() != s2[i].toLowerAscii():
+ if s1.len < s2.len:
+ return false
+ let h1 = s1.high
+ let h2 = s2.high
+ for i in 0 ..< s2.len:
+ if s1[h1 - i].toLowerAscii() != s2[h2 - i].toLowerAscii():
return false
return true