Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F131384
lib.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
lib.cpp
View Options
#include
<cstring>
#include
<map>
#include
<string>
#include
<vector>
#define FTS_FUZZY_MATCH_IMPLEMENTATION
#include
"./file_scanner.hpp"
#include
"./fts_fuzzy_match.hpp"
#include
"./match.hpp"
#include
"./sorter.hpp"
namespace
ivy
{
static
std
::
map
<
std
::
string
,
std
::
vector
<
std
::
string
>>
file_cache
;
};
// namespace ivy
extern
"C"
void
ivy_init
(
const
char
*
dir
)
{
auto
scanner
=
ivy
::
FileScanner
(
dir
);
ivy
::
file_cache
[
std
::
string
(
dir
)]
=
scanner
.
scan
();
}
extern
"C"
int
ivy_match
(
const
char
*
pattern
,
const
char
*
text
)
{
int
score
=
0
;
fts
::
fuzzy_match
(
pattern
,
text
,
score
);
return
score
;
}
extern
"C"
char
*
ivy_files
(
const
char
*
search
,
const
char
*
base_dir
)
{
if
(
!
ivy
::
file_cache
.
count
(
base_dir
))
{
auto
scanner
=
ivy
::
FileScanner
(
base_dir
);
ivy
::
file_cache
[
std
::
string
(
base_dir
)]
=
scanner
.
scan
();
}
auto
sorter
=
ivy
::
Sorter
(
search
);
// TODO(ade): Sort out how this memory is freed. I am assuming its in lua
// land via ffi
auto
*
s
=
new
std
::
string
();
for
(
ivy
::
Match
const
&
match
:
sorter
.
sort
(
ivy
::
file_cache
.
at
(
base_dir
)))
{
s
->
append
(
match
.
content
+
"
\n
"
);
}
return
s
->
data
();
}
File Metadata
Details
Attached
Mime Type
text/x-c++
Expires
Apr 6 2026, 5:44 PM (5 w, 5 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
15624
Default Alt Text
lib.cpp (1 KB)
Attached To
Mode
R1 ivy.nvim
Attached
Detach File
Event Timeline
Log In to Comment