|
@@ -74,7 +74,8 @@ void harry_idle_event(int fd) {
|
|
|
};
|
|
|
const int total_user_phrases = sizeof(user_phrases) / sizeof(char *);
|
|
|
|
|
|
- static LastSeen last_seen_harry_event(2);
|
|
|
+ // I'd like to use total_possible, but ... it isn't possible. (NNY)
|
|
|
+ static LastSeen last_seen_harry_event(LastSeen::best_guess(total_phrases));
|
|
|
|
|
|
int total_possible =
|
|
|
have_userinfo ? total_phrases + total_user_phrases : total_phrases;
|
|
@@ -112,9 +113,11 @@ void harry_idle_event(int fd) {
|
|
|
buffer << "^CS^S2^C" << std::setfill('0') << std::setw(2) << color
|
|
|
<< phrases[r] << "^P2^CR^D" << std::setw(2) << strlen(phrases[r]);
|
|
|
*/
|
|
|
- buffer << "^CS^S2^C" << std::setfill('0') << std::setw(2) << color
|
|
|
- << selected << "^P" << pause << "^CR^D" << std::setw(2)
|
|
|
- << selected.size();
|
|
|
+ buffer << TRIGGER "CS" TRIGGER "S2" TRIGGER "C" << std::setfill('0')
|
|
|
+ << std::setw(2) << color << selected
|
|
|
+ // Reset SPEED and RENDER
|
|
|
+ << TRIGGER "S0" TRIGGER "R0" TRIGGER "P" << pause
|
|
|
+ << TRIGGER "CR" TRIGGER "D" << std::setw(2) << selected.size();
|
|
|
|
|
|
std::string str = buffer.str();
|
|
|
ZF_LOGD("harry_event: render(%d, \"%s\")", fd, str.c_str());
|
|
@@ -165,12 +168,12 @@ int mangle_clrscr(std::string &buffer, std::string &work, size_t pos) {
|
|
|
{owl, sizeof(owl) / sizeof(char *), 0, 70}
|
|
|
|
|
|
};
|
|
|
-
|
|
|
- static LastSeen last_files(2);
|
|
|
+ const int total_images = sizeof(images) / sizeof(image);
|
|
|
+ static LastSeen last_files(LastSeen::best_guess(total_images));
|
|
|
int r;
|
|
|
|
|
|
do {
|
|
|
- r = randint((sizeof(images) / sizeof(image)));
|
|
|
+ r = randint(total_images);
|
|
|
} while (last_files.seen_before(r));
|
|
|
|
|
|
std::string fgoto;
|
|
@@ -181,8 +184,8 @@ int mangle_clrscr(std::string &buffer, std::string &work, size_t pos) {
|
|
|
x = randint(79 - images[r].width) + 1;
|
|
|
y = randint(24 - images[r].size) + 1;
|
|
|
|
|
|
- display << "^CS^f" << std::setfill('0') << std::setw(2) << x
|
|
|
- << std::setw(2) << y << "\x1b[1;1H";
|
|
|
+ display << TRIGGER "CS" TRIGGER "f" << std::setfill('0') << std::setw(2)
|
|
|
+ << x << std::setw(2) << y << "\x1b[1;1H";
|
|
|
fgoto = display.str();
|
|
|
// reset display
|
|
|
display.str(std::string());
|
|
@@ -190,9 +193,9 @@ int mangle_clrscr(std::string &buffer, std::string &work, size_t pos) {
|
|
|
} else {
|
|
|
if (images[r].lines == specter) {
|
|
|
// specter!
|
|
|
- fgoto.assign("^S1^CS^F");
|
|
|
+ fgoto.assign(TRIGGER "S1" TRIGGER "CS" TRIGGER "F");
|
|
|
} else
|
|
|
- fgoto.assign("^CS^F");
|
|
|
+ fgoto.assign(TRIGGER "CS" TRIGGER "F");
|
|
|
}
|
|
|
|
|
|
needs_cls = images[r].cls;
|
|
@@ -208,7 +211,8 @@ int mangle_clrscr(std::string &buffer, std::string &work, size_t pos) {
|
|
|
// Ok, yes, there's no filename being sent. :P
|
|
|
render_image(images[r].lines, images[r].size);
|
|
|
|
|
|
- display << (needs_cls ? "\x1b[2J" : "") << fgoto << "^S0^CR^P3";
|
|
|
+ display << (needs_cls ? "\x1b[2J" : "") << fgoto
|
|
|
+ << TRIGGER "S0" TRIGGER "CR" TRIGGER "P3";
|
|
|
|
|
|
std::string display_output = display.str();
|
|
|
|
|
@@ -226,19 +230,21 @@ int mangle_clrscr(std::string &buffer, std::string &work, size_t pos) {
|
|
|
std::ostringstream display;
|
|
|
|
|
|
const char *phrasing[] = {
|
|
|
- "^R1Haha^P1ha^P1ha", "Poof!", "Got U", "Anyone there?",
|
|
|
- "^R1Knock, ^P1Knock",
|
|
|
+ TRIGGER "R1Haha" TRIGGER "P1ha" TRIGGER "P1ha", "Poof!", "Got U",
|
|
|
+ "Anyone there?", TRIGGER "R1Knock, " TRIGGER "P1Knock",
|
|
|
/*
|
|
|
This picks random color and position -- then
|
|
|
homes cursor and changes to another color. (This can be seen.)
|
|
|
*/
|
|
|
- "^G0101^C07^S9Segmentation fault (core dumped)^P2"};
|
|
|
- static LastSeen last_phrasing(2);
|
|
|
+ TRIGGER "G0101" TRIGGER "C07" TRIGGER
|
|
|
+ "S9Segmentation fault (core dumped)" TRIGGER "P2"};
|
|
|
+ const int max_phrases = sizeof(phrasing) / sizeof(char *);
|
|
|
+ static LastSeen last_phrasing(LastSeen::best_guess(max_phrases));
|
|
|
|
|
|
ZF_LOGI("mangle(ANSI_CLS)");
|
|
|
|
|
|
do {
|
|
|
- r = randint(sizeof(phrasing) / sizeof(char *));
|
|
|
+ r = randint(max_phrases);
|
|
|
} while (last_phrasing.seen_before(r));
|
|
|
|
|
|
int color = randint(14) + 1;
|
|
@@ -259,13 +265,18 @@ int mangle_clrscr(std::string &buffer, std::string &work, size_t pos) {
|
|
|
HOME, CLS, HOME, ... Not sure what others do there. We'll see.
|
|
|
*/
|
|
|
|
|
|
- if (strncmp(phrasing[r], "^G", 2) == 0) {
|
|
|
- display << "^CS^S3^P1" << phrasing[r] << "^S0^R0^CR^P1^G0101";
|
|
|
+ if (strncmp(phrasing[r], TRIGGER "G", 2) == 0) {
|
|
|
+ display << TRIGGER "CS" TRIGGER "S3" TRIGGER "P1" << phrasing[r]
|
|
|
+ << TRIGGER "S0" TRIGGER "R0" TRIGGER "CR" TRIGGER "P1" TRIGGER
|
|
|
+ "G0101";
|
|
|
// This starts with a GOTO, so don't use our random position
|
|
|
} else {
|
|
|
- display << "^CS^G" << std::setw(2) << std::setfill('0') << x
|
|
|
- << std::setw(2) << y << "^S3^C" << std::setw(2) << color
|
|
|
- << "^P1" << phrasing[r] << "^S0^R0^CR^P1^G0101";
|
|
|
+ display << TRIGGER "CS" TRIGGER "G" << std::setw(2)
|
|
|
+ << std::setfill('0') << x << std::setw(2) << y
|
|
|
+ << TRIGGER "S3" TRIGGER "C" << std::setw(2) << color
|
|
|
+ << TRIGGER "P1" << phrasing[r]
|
|
|
+ << TRIGGER "S0" TRIGGER "R0" TRIGGER "CR" TRIGGER "P1" TRIGGER
|
|
|
+ "G0101";
|
|
|
};
|
|
|
|
|
|
std::string display_output = display.str();
|