Files
LLS/include/Status.h
T
alejo 6cb5a8611f Task sorting
- Time: Wait tasks sort by when the wait ends, earliest first. Limit reset tasks sort by when their wait ended, so the one that has been ready longest comes first. The time is kept when a wait expires, which is what makes the second sort possible.
- Order: I put time before account for these two statuses, so the full order is status, then time, then account, then name. Other statuses still go status, account, name. If you'd rather have account before time, swap the two checks in taskLess in Display.cpp.
- Manual limit reset: a task you set to limit-reset by hand has no wait time, so it sorts first among limit resets.

Account status: an account takes the most taken level among its tasks.
- Busy: it has a Testing, Limit reset or Wait task. The TASKS column lists those tasks.
- Taken: it has a Prompt task and nothing Busy. The TASKS column lists the Prompt tasks.
- Free: it only has Done, Frozen or Uploading tasks, or no tasks. The TASKS column shows

 Changes to be committed:
	modified:   README.md
	modified:   include/Display.h
	modified:   include/Status.h
	modified:   src/Completer.cpp
	modified:   src/Display.cpp
	modified:   src/Repl.cpp
	modified:   src/Status.cpp
2026-10-18 21:50:24 -03:00

43 lines
1.6 KiB
C++

#pragma once
#include <ctime>
#include <optional>
#include <string>
#include <vector>
// Prompt: free to accept prompts.
// LimitReset: computed - a Wait whose time has passed (can also be set by hand).
enum class StatusKind { Prompt, LimitReset, Testing, Wait, Uploading, Frozen, Done };
struct Status {
StatusKind kind = StatusKind::Prompt;
std::time_t waitUntil = 0; // when the wait ends; set for Wait, and kept on the computed LimitReset
};
namespace StatusUtil {
Status make(StatusKind kind);
// User input such as "testing" or "wait 16:30". A wait time that has already
// passed today is taken to mean tomorrow.
std::optional<Status> parse(const std::string& text, std::time_t now);
// Database representation, e.g. "testing" or "wait 2026-10-17T16:30".
std::string serialize(const Status& status);
std::optional<Status> deserialize(const std::string& text);
// The status shown to the user: an expired wait becomes LimitReset.
Status effective(const Status& status, std::time_t now);
std::string label(const Status& status); // "Prompt", "Limit reset", "Wait 16:30", ...
std::string kindName(StatusKind kind); // lowercase token: "prompt", "limit-reset", ...
std::vector<StatusKind> allKinds();
// Accepts "limit-reset", "limit_reset", "limitreset", "reset"; "available" is an
// old name for "prompt".
std::optional<StatusKind> kindFromName(const std::string& name);
int rank(StatusKind kind); // task sort priority, lowest first
bool isBusy(StatusKind kind); // keeps its account Busy: Testing, Limit reset, Wait
bool isTaken(StatusKind kind); // keeps its account Taken: Prompt
} // namespace StatusUtil