From 280102869b57bbf34b3cb5af41c9c582af1bed42 Mon Sep 17 00:00:00 2001 From: Matt Mascarenhas Date: Sun, 11 Jun 2017 23:49:04 +0100 Subject: [PATCH] hmml_to_html.c: Deduplicate topics and add tooltip Also fix bug in filter menu navigation, in which the lastFocusedElement was not getting set after toggling a category via the keyboard --- hmml_to_html/hmml_to_html.c | 41 +++++++++++++++++++++++++++++++------ hmml_to_html/player.js | 36 ++++++++++++++++++++++++++++---- 2 files changed, 67 insertions(+), 10 deletions(-) diff --git a/hmml_to_html/hmml_to_html.c b/hmml_to_html/hmml_to_html.c index 5fae31a..3177292 100644 --- a/hmml_to_html/hmml_to_html.c +++ b/hmml_to_html/hmml_to_html.c @@ -305,7 +305,7 @@ StringsDifferL(char *A, char *B, int LengthofA) { ++i; } - if(!A[i] && LengthofA == i && B[i] == ' ') + if(!A[i] && LengthofA == i && (B[i] == ' ' || B[i] == '\"')) { return FALSE; } @@ -696,11 +696,40 @@ BuildCategories(buffer *AnnotationClass, buffer *Category, int *MarkerIndex, boo *HasCategory = TRUE; } - CopyStringToBuffer(Category, "
", - SanitisePunctuation(Marker)); + // NOTE(matt): Iterate through the Category->Location looking for "Marker", and bail if we find it + char *Ptr = Category->Location; + bool Found = FALSE; + while(*Ptr) + { + if(*Ptr == '\"') + { + ++Ptr; + if(!StringsDifferL(SanitisePunctuation(Marker), Ptr, StringLength(SanitisePunctuation(Marker)))) + { + Found = TRUE; + break; + } + else + { + while(*Ptr != '\"') + { + ++Ptr; + } + } + } + ++Ptr; + } + + if(Found == FALSE) + { + CopyStringToBuffer(Category, "
", + SanitisePunctuation(Marker), + SanitisePunctuation(Marker)); + + CopyStringToBuffer(AnnotationClass, " cat_%s", + SanitisePunctuation(Marker)); + } - CopyStringToBuffer(AnnotationClass, " cat_%s", - SanitisePunctuation(Marker)); ++*MarkerIndex; return; } @@ -1308,7 +1337,7 @@ main(int ArgC, char **Args) ClaimBuffer(MemoryArena, &ClaimedMemory, &AnnotationClass, "AnnotationClass", 256); ClaimBuffer(MemoryArena, &ClaimedMemory, &AnnotationData, "AnnotationData", 256); ClaimBuffer(MemoryArena, &ClaimedMemory, &Text, "Text", Kilobytes(4)); - ClaimBuffer(MemoryArena, &ClaimedMemory, &Category, "Category", 256); + ClaimBuffer(MemoryArena, &ClaimedMemory, &Category, "Category", 512); CopyStringToBuffer(&AnnotationHeader, "