Skip to content

Commit a1e48b2

Browse files
replace std/re with tinyre
removes pcre dependency
1 parent fc7f3db commit a1e48b2

5 files changed

Lines changed: 26 additions & 11 deletions

File tree

flake.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
lockFile = ./lock.json;
2222

23-
buildInputs = with pkgs; [ termbox pcre ];
23+
buildInputs = with pkgs; [ termbox ];
2424
};
2525

2626
defaultPackage = packages.nimmm;

lock.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,18 @@
3535
"sha256": "06b9ylqbjcxgm9mjfzljbi8gr9sbajykcqpcxgyqymynqyhxmqjn",
3636
"srcDir": "src",
3737
"url": "https://github.com/shoyu777/wcwidth-nim/archive/86f8db1a883f6a64e590a56aed81e788389b7196.tar.gz"
38+
},
39+
{
40+
"method": "fetchzip",
41+
"packages": [
42+
"tinyre"
43+
],
44+
"path": "/nix/store/w556rbsnv2fxb229av2iq180ri9x0d9j-source",
45+
"ref": "1.6.0",
46+
"rev": "77469f58916369bc3863194cabb05238577fb257",
47+
"sha256": "18wjz5yqzr1dz6286p2w02fk2xjr54l477g90bz4pskjcqrqnjbv",
48+
"srcDir": "",
49+
"url": "https://github.com/khchen/tinyre/archive/77469f58916369bc3863194cabb05238577fb257.tar.gz"
3850
}
3951
]
4052
}

nimmm.nimble

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ requires "nim >= 1.4.4"
1414
requires "nimbox >= 0.1.0"
1515
requires "lscolors >= 1.0.0"
1616
requires "wcwidth >= 0.1.3"
17+
requires "tinyre"

src/nimmm.nim

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import std/[os, sets, parseopt, sequtils, algorithm, strutils,
2-
options, re, segfaults, selectors, dirs, paths, strformat, exitprocs]
2+
options, segfaults, selectors, dirs, paths, strformat, exitprocs]
33

44
import posix, posix/inotify
55

66
import lscolors
77

8+
import tinyre
9+
810
import core, scan, draw, external, nimboxext, keymap, readline
911

1012
const
@@ -34,22 +36,22 @@ proc safeSetCurDir(s: var State, path: Path) =
3436
s.currentDirWatcher = s.inotifyHandle.inotifyAddWatch(os.getCurrentDir(),
3537
inotifyMask)
3638

37-
proc visible(entry: DirEntry, showHidden: bool, regex: Option[Regex]): bool =
39+
proc visible(entry: DirEntry, showHidden: bool, regex: Option[Re]): bool =
3840
let
3941
notHidden = showHidden or not isHidden(entry.path)
4042
matchesRe = if regex.isSome: extractFilename(entry.path).contains(
4143
regex.get) else: true
4244
matchesRe and notHidden
4345

44-
proc compileRegex(searchQuery: string): Option[Regex] =
46+
proc compileRegex(searchQuery: string): Option[Re] =
4547
if searchQuery != "":
4648
try:
47-
let compiled = re(searchQuery, flags = {reStudy, reIgnoreCase})
49+
let compiled = re(searchQuery, flags = {reIgnoreCase})
4850
some(compiled)
49-
except RegexError:
50-
none(Regex)
51+
except ValueError:
52+
none(Re)
5153
else:
52-
none(Regex)
54+
none(Re)
5355

5456
proc refresh(s: var State) =
5557
let

0 commit comments

Comments
 (0)