Preserve current AVIF compression, local voice pipelines, practice workflows, UI API migration, locale updates, and packaging work. Native integration validation remains pending.
40 lines
1.2 KiB
Ziran
40 lines
1.2 KiB
Ziran
// todo.txt stores priority as a leading `(A)` through `(Z)` in the task text.
|
|
#import "vec"
|
|
#import "text_buffer"
|
|
|
|
ListsPriorityForTitle :: (title: string) -> s32 {
|
|
if title.count < 4 || title[0] != #char "(" || title[2] != #char ")" ||
|
|
title[3] != #char " " {
|
|
return 0
|
|
}
|
|
letter := title[1]
|
|
if letter < #char "A" || letter > #char "Z" { return 0 }
|
|
return cast(s32)(letter - #char "A") + 1
|
|
}
|
|
|
|
ListsTitleWithoutPriority :: (title: string) -> string {
|
|
if ListsPriorityForTitle(title) > 0 { return title[4:] }
|
|
return title
|
|
}
|
|
|
|
ListsTitleForPriority :: (title: string, priority: s32) -> string {
|
|
task := ListsTitleWithoutPriority(title)
|
|
if priority <= 0 || task.count == 0 { return ListsCopiedTitle(task) }
|
|
alphabet := "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
|
value: Vec(u8)
|
|
BuilderPrint(*value, "(%) %", alphabet[priority - 1:priority], task)
|
|
return BuilderFinish(value)
|
|
}
|
|
|
|
ListsTitlePriorityFits :: (title: string, priority: s32, limit: s32) -> bool {
|
|
length := ListsTitleWithoutPriority(title).count
|
|
if priority > 0 { return length + 4 <= limit }
|
|
return length <= limit
|
|
}
|
|
|
|
ListsCopiedTitle :: (value: string) -> string {
|
|
copy: Vec(u8)
|
|
BuilderPrint(*copy, "%", value)
|
|
return BuilderFinish(copy)
|
|
}
|