about summary refs log tree commit diff stats
path: root/src/bindings/libregexp.nim
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2022-07-22 19:52:31 +0200
committerbptato <nincsnevem662@gmail.com>2022-07-22 19:52:31 +0200
commit6f7bcc54ab03bc31be309352c73fd8d8153f9c91 (patch)
treedc4fd8a80ccc8a5a8f7c5a567fcbf80c3e66eccb /src/bindings/libregexp.nim
parentc69a8ab7576e2053afc5dfcee5c7152a07c31230 (diff)
downloadchawan-6f7bcc54ab03bc31be309352c73fd8d8153f9c91.tar.gz
Add search function
Uses libregexp from QuickJS. Incremental search is quite hacky for now,
but overall it seems to work OK.
Diffstat (limited to 'src/bindings/libregexp.nim')
-rw-r--r--src/bindings/libregexp.nim19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/bindings/libregexp.nim b/src/bindings/libregexp.nim
new file mode 100644
index 00000000..1b84400e
--- /dev/null
+++ b/src/bindings/libregexp.nim
@@ -0,0 +1,19 @@
+const lreheader = "bindings/libregexp.h"
+
+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
+
+proc lre_compile*(plen: ptr cint, error_msg: cstring, error_msg_size: cint,
+                  buf: cstring, buf_len: csize_t, re_flags: cint,
+                  opaque: pointer): ptr uint8 {.importc: "lre_compile", header: lreheader.}
+
+proc lre_exec*(capture: ptr ptr uint8, bc_buf: ptr uint8, cbuf: ptr uint8,
+               cindex: cint, clen: cint, cbuf_type: cint,
+               opaque: pointer): cint {.importc: "lre_exec", header: lreheader.}
+
+proc lre_get_capture_count*(bc_buf: ptr uint8): cint {.importc: "lre_get_capture_count", header: lreheader.}