Docs index filtering
parent
471aaaacf9
commit
b7992c47ae
|
@ -220,6 +220,7 @@ api_parse_source__structure(Arena *arena, String_Const_u8 source_name, String_Co
|
|||
String_Const_u8 name = {};
|
||||
List_String_Const_u8 member_list = {};
|
||||
Token *token = api_parse__token_pos(token_it);
|
||||
(void)token;
|
||||
if (api_parse__match_identifier(token_it, source, &name)){
|
||||
if (api_parse__match(token_it, TokenCppKind_Semicolon)){
|
||||
result = true;
|
||||
|
@ -254,6 +255,7 @@ api_parse_source__structure(Arena *arena, String_Const_u8 source_name, String_Co
|
|||
}
|
||||
if (result){
|
||||
Token *token_end = api_parse__token_pos(token_it);
|
||||
(void)token_end;
|
||||
// TODO(allen):
|
||||
String_Const_u8 definition = {};
|
||||
String_Const_u8 location = api_parse_location(arena, source_name, source, name.str);
|
||||
|
|
|
@ -38,6 +38,7 @@ char html_header[] = R"HTMLFOO(
|
|||
<head>
|
||||
<link rel='shortcut icon' type='image/x-icon' href='4coder_icon.ico' />
|
||||
<link href="https://fonts.googleapis.com/css?family=Inconsolata:700&display=swap" rel="stylesheet">
|
||||
<script src="../search.js"></script>
|
||||
<title>%.*s</title>
|
||||
<style>
|
||||
body {
|
||||
|
@ -179,6 +180,21 @@ background: #181818;
|
|||
height: 20em;
|
||||
}
|
||||
|
||||
.docs_menu {
|
||||
list-style-type:none;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.filter_box {
|
||||
border: 1px solid #90B080;
|
||||
font-size: 1.5em;
|
||||
color: #90B080;
|
||||
background: none;
|
||||
text-align: justify;
|
||||
font-family: 'Inconsolata', monospace;
|
||||
width: 15em;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
</head>
|
||||
|
@ -426,6 +442,9 @@ render_doc_cluster_to_html(Arena *scratch, Doc_Cluster *cluster,
|
|||
fprintf(file_index, "<div class=\"small_spacer\"></div>\n");
|
||||
fprintf(file_index, "<h1>%.*s Index</h1>\n", string_expand(cluster->title));
|
||||
fprintf(file_index, "<div class=\"spacer\"></div>\n");
|
||||
fprintf(file_index, "<input class=\"filter_box\" type=\"text\" id=\"search_input\" onkeyup=\"SearchKeyUp(event)\" onkeydown=\"SearchKeyDown(event)\""
|
||||
"placeholder=\"Filter...\" title=\"Filter...\">");
|
||||
fprintf(file_index, "<div class=\"spacer\"></div>\n");
|
||||
|
||||
Doc_Page **ptrs = push_array(scratch, Doc_Page*, cluster->page_count);
|
||||
i32 counter = 0;
|
||||
|
@ -438,14 +457,17 @@ render_doc_cluster_to_html(Arena *scratch, Doc_Cluster *cluster,
|
|||
|
||||
sort_doc_page_array(ptrs, 0, counter);
|
||||
|
||||
fprintf(file_index, "<div class=\"normal\">");
|
||||
|
||||
fprintf(file_index, "<ul class=\"docs_menu\" id=\"docs_menu\">\n");
|
||||
for (i32 i = 0; i < counter; i += 1){
|
||||
Doc_Page *node = ptrs[i];
|
||||
fprintf(file_index, "<div class=\"normal\">");
|
||||
fprintf(file_index, "<a href=\"%.*s.html\">%.*s</a>",
|
||||
fprintf(file_index, "<li><a href=\"%.*s.html\">%.*s</a></li>",
|
||||
string_expand(node->name),
|
||||
string_expand(node->name));
|
||||
fprintf(file_index, "</div>\n");
|
||||
}
|
||||
fprintf(file_index, "</ul>\n");
|
||||
fprintf(file_index, "</div>\n");
|
||||
|
||||
fprintf(file_index, html_footer);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,71 @@
|
|||
const menu_id = "docs_menu";
|
||||
const filter_id = "search_input";
|
||||
|
||||
function StringMatch4coderFuzzy(a, b)
|
||||
{
|
||||
let match = true;
|
||||
let b_upper = b.toUpperCase();
|
||||
let a_substrings = a.toUpperCase().split(/[ _*]+/);
|
||||
let minimum_index = 0;
|
||||
|
||||
for(let i = 0; i < a_substrings.length; ++i)
|
||||
{
|
||||
if(a_substrings[i].length > 0)
|
||||
{
|
||||
let index_of_substring = b_upper.indexOf(a_substrings[i], minimum_index);
|
||||
if(index_of_substring < 0 || index_of_substring < minimum_index)
|
||||
{
|
||||
match = false;
|
||||
break;
|
||||
}
|
||||
minimum_index = index_of_substring + a_substrings[i].length - 1;
|
||||
}
|
||||
}
|
||||
|
||||
return match;
|
||||
}
|
||||
|
||||
function SearchKeyDown(event)
|
||||
{
|
||||
if(event.keyCode == 13)
|
||||
{
|
||||
let ul = document.getElementById(menu_id);
|
||||
let li = ul.getElementsByTagName("li");
|
||||
|
||||
for (let i = 0; i < li.length; i++)
|
||||
{
|
||||
if(li[i].style.display == "")
|
||||
{
|
||||
window.location.href = li[i].getElementsByTagName("a")[0];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function SearchKeyUp(event)
|
||||
{
|
||||
let ul = document.getElementById(menu_id);
|
||||
let li = ul.getElementsByTagName("li");
|
||||
let input = document.getElementById(filter_id);
|
||||
let filter = input.value.toUpperCase();
|
||||
for(let i = 0; i < li.length; i++)
|
||||
{
|
||||
if(filter.length > 0)
|
||||
{
|
||||
let a = li[i].getElementsByTagName("a")[0];
|
||||
if(StringMatch4coderFuzzy(filter, a.innerHTML))
|
||||
{
|
||||
li[i].style.display = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
li[i].style.display = "none";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
li[i].style.display = "";
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue