diff options
author | bptato <nincsnevem662@gmail.com> | 2024-02-17 22:03:07 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2024-02-17 22:07:11 +0100 |
commit | 390772358cedc9ed541a27b3cac1f8d97beef0ef (patch) | |
tree | 621e56ad7b1b4957b1ba686a8902381ce270619c /src/bindings | |
parent | e98d0ad1dc51050eb17120f835847d55950c2a0b (diff) | |
download | chawan-390772358cedc9ed541a27b3cac1f8d97beef0ef.tar.gz |
regex: re-work compileSearchRegex
I've gotten tired of not being able to search for forward slashes. Now it works like in vim, and you can also set default ignore case in the config.
Diffstat (limited to 'src/bindings')
-rw-r--r-- | src/bindings/libregexp.nim | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/src/bindings/libregexp.nim b/src/bindings/libregexp.nim index 85e7c1ca..d4c10b42 100644 --- a/src/bindings/libregexp.nim +++ b/src/bindings/libregexp.nim @@ -1,10 +1,19 @@ -const - LRE_FLAG_GLOBAL* = 1 shl 0 - LRE_FLAG_IGNORECASE* = 1 shl 1 - LRE_FLAG_MULTILINE* = 1 shl 2 - LRE_FLAG_DOTALL* = 1 shl 3 - LRE_FLAG_UTF16* = 1 shl 4 - LRE_FLAG_STICKY* = 1 shl 5 +type + LREFlag* {.size: sizeof(cint).} = enum + LRE_FLAG_GLOBAL = "g" + LRE_FLAG_IGNORECASE = "i" + LRE_FLAG_MULTILINE = "m" + LRE_FLAG_DOTALL = "s" + LRE_FLAG_UTF16 = "u" + LRE_FLAG_STICKY = "y" + + LREFlags* = set[LREFlag] + +func toCInt*(flags: LREFlags): cint = + cast[cint](flags) + +func toLREFlags*(flags: cint): LREFlags = + cast[LREFlags](flags) {.passc: "-Ilib/".} |