hmml_to_html.c: Sort filter [#21]
This works, but fails to take into account the "written text" of media
This commit is contained in:
parent
4ec635831a
commit
f4352572b9
|
@ -5,9 +5,7 @@ ctime -end ${0%.*}.ctm
|
||||||
exit
|
exit
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define DEBUG 1
|
#define DEBUG 0
|
||||||
|
|
||||||
// TODO(matt): Fully investigate the ClaimedMemory situation
|
|
||||||
|
|
||||||
typedef unsigned int bool;
|
typedef unsigned int bool;
|
||||||
|
|
||||||
|
@ -367,19 +365,22 @@ BuildReference(ref_info *ReferencesArray, int RefIdentifier, int UniqueRefs, HMM
|
||||||
|
|
||||||
char *CategoryMedium[][3] =
|
char *CategoryMedium[][3] =
|
||||||
{
|
{
|
||||||
// category icon written name
|
// medium icon written name
|
||||||
{ "authored", "🗪", "Chat Comment"}, // TODO(matt): Conditionally handle Chat vs Guest Comments
|
{ "authored", "🗪", "Chat Comment"}, // TODO(matt): Conditionally handle Chat vs Guest Comments
|
||||||
{ "blackboard", "🖌", "Blackboard"},
|
{ "blackboard", "🖌", "Blackboard"},
|
||||||
{ "owl", "🦉", "Owl of Shame"},
|
{ "default", "🖮", "Programming"}, // TODO(matt): Potentially make this configurable per project
|
||||||
{ "default", "🖮", "Programming"}, // TODO(matt): Potentially make this configurable per project
|
{ "experience", "🍷", "Experience"},
|
||||||
{ "rant", "💢", "Rant"},
|
{ "owl", "🦉", "Owl of Shame"},
|
||||||
{ "research", "📖", "Research"},
|
{ "rant", "💢", "Rant"},
|
||||||
{ "run", "🏃", "In-Game"} // TODO(matt): Potentially make this configurable per project
|
{ "research", "📖", "Research"},
|
||||||
|
{ "run", "🏃", "In-Game"}, // TODO(matt): Potentially make this configurable per project
|
||||||
|
{ "trivia", "🎲", "Trivia"},
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
BuildFilter(category_info *CategoriesArray, int *UniqueCategories, char *Marker)
|
BuildFilter(category_info *CategoriesArray, int *UniqueCategories, char *Marker)
|
||||||
{
|
{
|
||||||
|
int Offset = 0;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for(i = 0; i < *UniqueCategories; ++i)
|
for(i = 0; i < *UniqueCategories; ++i)
|
||||||
{
|
{
|
||||||
|
@ -387,28 +388,52 @@ BuildFilter(category_info *CategoriesArray, int *UniqueCategories, char *Marker)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if((Offset = StringsDiffer(Marker, CategoriesArray[i].Category)) < 0)
|
||||||
|
{
|
||||||
|
int j;
|
||||||
|
for(j = *UniqueCategories; j > i; --j)
|
||||||
|
{
|
||||||
|
CopyString(CategoriesArray[j].Category, CategoriesArray[j-1].Category);
|
||||||
|
CategoriesArray[j].IsMedium = CategoriesArray[j-1].IsMedium;
|
||||||
|
}
|
||||||
|
|
||||||
|
CopyString(CategoriesArray[j].Category, Marker);
|
||||||
|
CategoriesArray[j].IsMedium = FALSE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// This really ought to sort by the Alternative Text
|
||||||
|
|
||||||
|
if(i == *UniqueCategories)
|
||||||
|
{
|
||||||
|
CopyString(CategoriesArray[i].Category, Marker);
|
||||||
}
|
}
|
||||||
|
|
||||||
++*UniqueCategories;
|
++*UniqueCategories;
|
||||||
CopyString(CategoriesArray[i].Category, Marker);
|
|
||||||
for(int j = 0; j < ArrayCount(CategoryMedium); ++j)
|
for(int k = 0; k < ArrayCount(CategoryMedium); ++k)
|
||||||
{
|
{
|
||||||
if(!StringsDiffer(CategoryMedium[j][0], Marker))
|
if(!StringsDiffer(CategoryMedium[k][0], Marker))
|
||||||
{
|
{
|
||||||
CategoriesArray[i].IsMedium = TRUE;
|
CategoriesArray[i].IsMedium = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// TODO(matt): Sort the CategoriesArray
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
BuildCategories(buffer *AnnotationClass, buffer *Category, int *MarkerIndex, bool *HasCategory, char *Marker)
|
BuildCategories(buffer *AnnotationClass, buffer *Category, int *MarkerIndex, bool *HasCategory, bool *HasMedium, char *Marker)
|
||||||
{
|
{
|
||||||
|
// NOTE(matt): This guy could also sort, so that the dots appear in a consistent order in the annotations
|
||||||
|
// If so, the Category buffer would have to only contain the category names and no more until collation time
|
||||||
|
// BuildCategories() would have to parse the Category.Location out to an array, sort that array and write it back in
|
||||||
|
// The code in the "annotation loop" would then have to write both the head and tail of the category stuff
|
||||||
for(int i = 0; i < ArrayCount(CategoryMedium); ++i)
|
for(int i = 0; i < ArrayCount(CategoryMedium); ++i)
|
||||||
{
|
{
|
||||||
if(!StringsDiffer(CategoryMedium[i][0], Marker))
|
if(!StringsDiffer(CategoryMedium[i][0], Marker))
|
||||||
{
|
{
|
||||||
CopyStringToBuffer(AnnotationClass, " %s", SanitisePunctuation(Marker));
|
CopyStringToBuffer(AnnotationClass, " %s", SanitisePunctuation(Marker));
|
||||||
|
*HasMedium = TRUE;
|
||||||
++*MarkerIndex;
|
++*MarkerIndex;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -996,6 +1021,7 @@ main(int ArgC, char **Args)
|
||||||
#endif
|
#endif
|
||||||
HMML_Annotation *Anno = HMML.annotations + AnnotationIndex;
|
HMML_Annotation *Anno = HMML.annotations + AnnotationIndex;
|
||||||
bool HasCategory = FALSE;
|
bool HasCategory = FALSE;
|
||||||
|
bool HasMedium = FALSE;
|
||||||
bool HasQuote = FALSE;
|
bool HasQuote = FALSE;
|
||||||
bool HasReference = FALSE;
|
bool HasReference = FALSE;
|
||||||
|
|
||||||
|
@ -1079,7 +1105,7 @@ Readable);
|
||||||
HasFilterMenu = TRUE;
|
HasFilterMenu = TRUE;
|
||||||
}
|
}
|
||||||
BuildFilter(CategoriesArray, &UniqueCategories, Anno->markers[MarkerIndex].marker);
|
BuildFilter(CategoriesArray, &UniqueCategories, Anno->markers[MarkerIndex].marker);
|
||||||
BuildCategories(&AnnotationClass, &Category, &MarkerIndex, &HasCategory, Anno->markers[MarkerIndex].marker);
|
BuildCategories(&AnnotationClass, &Category, &MarkerIndex, &HasCategory, &HasMedium, Anno->markers[MarkerIndex].marker);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1278,7 +1304,13 @@ Anno->time);
|
||||||
{
|
{
|
||||||
BuildFilter(CategoriesArray, &UniqueCategories, Anno->markers[MarkerIndex].marker);
|
BuildFilter(CategoriesArray, &UniqueCategories, Anno->markers[MarkerIndex].marker);
|
||||||
}
|
}
|
||||||
BuildCategories(&AnnotationClass, &Category, &MarkerIndex, &HasCategory, Anno->markers[MarkerIndex].marker);
|
BuildCategories(&AnnotationClass, &Category, &MarkerIndex, &HasCategory, &HasMedium, Anno->markers[MarkerIndex].marker);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!HasMedium)
|
||||||
|
{
|
||||||
|
BuildFilter(CategoriesArray, &UniqueCategories, "default");
|
||||||
|
BuildCategories(&AnnotationClass, &Category, &MarkerIndex, &HasCategory, &HasMedium, "default");
|
||||||
}
|
}
|
||||||
|
|
||||||
CopyStringToBuffer(&AnnotationClass, "\"");
|
CopyStringToBuffer(&AnnotationClass, "\"");
|
||||||
|
@ -1296,21 +1328,13 @@ Anno->time);
|
||||||
" <div class=\"content\"><span class=\"timecode\">%s</span>",
|
" <div class=\"content\"><span class=\"timecode\">%s</span>",
|
||||||
Anno->time);
|
Anno->time);
|
||||||
|
|
||||||
#if 0
|
|
||||||
// TODO(matt): Handle special-cases, i.e. default media, and possibly other things
|
|
||||||
if(!HasCategory)
|
|
||||||
{
|
|
||||||
BuildFilter(CategoriesArray, &UniqueCategories, "default");
|
|
||||||
BuildCategories(&AnnotationClass, &Category, &MarkerIndex, &HasCategory, "default");
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if(HasCategory)
|
if(HasCategory)
|
||||||
{
|
{
|
||||||
CopyStringToBuffer(&Category, "</span>");
|
CopyStringToBuffer(&Category, "</span>");
|
||||||
CopyBuffer(&Text, &Category);
|
CopyBuffer(&Text, &Category);
|
||||||
}
|
}
|
||||||
|
// NOTE(matt): This feels a bit janky...
|
||||||
*Text.Ptr = '\0';
|
*Text.Ptr = '\0';
|
||||||
|
|
||||||
CopyBuffer(&Annotation, &Text);
|
CopyBuffer(&Annotation, &Text);
|
||||||
|
|
Loading…
Reference in New Issue