|
@@ -70,548 +70,6 @@ void init_harry() {
|
|
|
|
|
|
// char words[] = "[a-zA-Z]+( [a-zA-Z]+)+";
|
|
|
|
|
|
-/**
|
|
|
- * random_activate()
|
|
|
- *
|
|
|
- * Is a weight (1-10),
|
|
|
- * tests if random number is < weight * 10.
|
|
|
- *
|
|
|
- * So random_activate(9) happens more frequently
|
|
|
- * then random_activate(8) or lower.
|
|
|
- *
|
|
|
- * This probably needs to be fixed.
|
|
|
- * We need a better randint(RANGE) code.
|
|
|
- */
|
|
|
-int random_activate(int w) {
|
|
|
- int r = randint(100);
|
|
|
- if (r <= (w * 10)) {
|
|
|
- return 1;
|
|
|
- };
|
|
|
- return 0;
|
|
|
-}
|
|
|
-
|
|
|
-#ifdef UNWANTED
|
|
|
-
|
|
|
-/*
|
|
|
- word_state(): // deprecated
|
|
|
-
|
|
|
- -1 only lower
|
|
|
- +1 only upper
|
|
|
- 0 mixed
|
|
|
-*/
|
|
|
-int word_state(const char *buffer, int len) {
|
|
|
- int p;
|
|
|
- int upper = 0;
|
|
|
- int lower = 0;
|
|
|
- int ret;
|
|
|
- float pct;
|
|
|
-
|
|
|
- for (p = 0; p < len; p++) {
|
|
|
- char c = buffer[p];
|
|
|
- if (isalpha(c)) {
|
|
|
- if (isupper(c)) {
|
|
|
- upper++;
|
|
|
- };
|
|
|
- if (islower(c)) {
|
|
|
- lower++;
|
|
|
- };
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if (upper == lower) {
|
|
|
- return 0;
|
|
|
- }
|
|
|
-
|
|
|
- if (upper > lower) {
|
|
|
- ret = 1;
|
|
|
- pct = ((float)lower / (float)upper) * 100.0;
|
|
|
- } else {
|
|
|
- ret = -1;
|
|
|
- pct = ((float)upper / (float)lower) * 100.0;
|
|
|
- }
|
|
|
-
|
|
|
- // ZF_LOGD("So far %d with %f %%", ret, pct);
|
|
|
-
|
|
|
- if (pct < 40.0) {
|
|
|
- return ret;
|
|
|
- }
|
|
|
- return 0;
|
|
|
-}
|
|
|
-
|
|
|
-/*
|
|
|
-Given a buffer and length, mangle away.
|
|
|
-
|
|
|
-toupper, tolower, flipper
|
|
|
- */
|
|
|
-int word_mangler(char *buffer, int len) {
|
|
|
- int p;
|
|
|
- int count = 0;
|
|
|
- int state;
|
|
|
-
|
|
|
- // state = word_state(buffer, len);
|
|
|
- // ZF_LOGD("word_state(%.*s) %d", len, buffer, state);
|
|
|
- state = randrange(-1, 1);
|
|
|
-
|
|
|
- // TODO: Transposer
|
|
|
-
|
|
|
- for (p = 0; p < len; p++) {
|
|
|
- char c = buffer[p];
|
|
|
-
|
|
|
- if (randint(len) == p) {
|
|
|
- break;
|
|
|
- }
|
|
|
- switch (state) {
|
|
|
- case -1:
|
|
|
- // upper
|
|
|
- if (islower(c)) {
|
|
|
- count++;
|
|
|
- buffer[p] = toupper(c);
|
|
|
- }
|
|
|
- break;
|
|
|
- case 1:
|
|
|
- // lower
|
|
|
- if (isupper(c)) {
|
|
|
- count++;
|
|
|
- buffer[p] = tolower(c);
|
|
|
- }
|
|
|
- break;
|
|
|
- case 0:
|
|
|
- // flipper
|
|
|
- if (islower(c)) {
|
|
|
- count++;
|
|
|
- buffer[p] = toupper(c);
|
|
|
- } else {
|
|
|
- if (isupper(c)) {
|
|
|
- count++;
|
|
|
- buffer[p] = tolower(c);
|
|
|
- }
|
|
|
- }
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- return count;
|
|
|
-}
|
|
|
-
|
|
|
-int word_wrangler(char *buffer, int len) {
|
|
|
- int p;
|
|
|
- int count;
|
|
|
- int state;
|
|
|
-
|
|
|
- // state = word_state(buffer, len);
|
|
|
- // ZF_LOGD("word_state(%.*s) %d", len, buffer, state);
|
|
|
- if (len < 5) {
|
|
|
- return 0;
|
|
|
- }
|
|
|
-
|
|
|
- p = randint(len - 4) + 2;
|
|
|
-
|
|
|
- for (count = 0; count < 4; count++) {
|
|
|
- if (!isalpha(buffer[p + count]))
|
|
|
- break;
|
|
|
- }
|
|
|
-
|
|
|
- ZF_LOGV_MEM(buffer, len, "wrangler %d len %d:", p, count);
|
|
|
-
|
|
|
- if (count >= 2) {
|
|
|
- for (int x = 0; x < count / 2; x++) {
|
|
|
- char ch = buffer[p + x];
|
|
|
- buffer[p + x] = buffer[p + count - 1 - x];
|
|
|
- buffer[p + count - 1 - x] = ch;
|
|
|
- }
|
|
|
- ZF_LOGV_MEM(buffer, len, "word now:");
|
|
|
- return 1;
|
|
|
- } else
|
|
|
- return 0;
|
|
|
-}
|
|
|
-
|
|
|
-int buffer_insert(char *buffer, int len, int max_length, int pos,
|
|
|
- const char *insert) {
|
|
|
- if (len + strlen(insert) > max_length) {
|
|
|
- ZF_LOGD("buffer_insert failed [%s]", repr(insert));
|
|
|
- return 0;
|
|
|
- }
|
|
|
- memmove(buffer + pos + strlen(insert), buffer + pos, len - pos);
|
|
|
- strncpy(buffer + pos, insert, strlen(insert));
|
|
|
- return 1;
|
|
|
-}
|
|
|
-
|
|
|
-/*
|
|
|
- * The buffer that we've been given is much larger now.
|
|
|
- *
|
|
|
- * We can no longer mangle or insert into the given buffer.
|
|
|
- * Why? Because we don't know what is behind it now!
|
|
|
- */
|
|
|
-int mangle(int fd, const char *buffer, int len) {
|
|
|
- int x, i;
|
|
|
- int need_render = 0; // changing word case around doesn't need the render
|
|
|
- int mangled = 0;
|
|
|
- int mangled_chars = 0;
|
|
|
- char play[BSIZE * 2]; // The main buffer to send.
|
|
|
- const char *cp;
|
|
|
-
|
|
|
- // Make a copy of buffer, since it can no longer be changed
|
|
|
- // inserted into.
|
|
|
-
|
|
|
- memcpy(play, buffer, len);
|
|
|
-
|
|
|
- // NEVER reference buffer from this point on!
|
|
|
-
|
|
|
- char work[BSIZE * 2]; // The mess with buffer.
|
|
|
-
|
|
|
- /*
|
|
|
- We use the work buffer to blank out the ANSI
|
|
|
- before trying to locate words. (So we don't
|
|
|
- grab part of the ANSI codes and mangle those!)
|
|
|
- */
|
|
|
-
|
|
|
- // Use terminal - clean out ANSI
|
|
|
-
|
|
|
- // ZF_LOGI("mangle:");
|
|
|
- ZF_LOGI_MEM(play, len, "Mangle (%u bytes):", len);
|
|
|
-
|
|
|
- // strcpy(work, buffer);
|
|
|
-
|
|
|
- /*
|
|
|
- NOTE: We copy the buffer, so we can clear out ANSI codes, etc.
|
|
|
- Otherwise we might mess some ANSI up in the manglying
|
|
|
- process.
|
|
|
- */
|
|
|
-
|
|
|
- /*
|
|
|
- Is there a way to track -- what I've inserted, and make it exempt from
|
|
|
- other modifications / mangler, wrangler?
|
|
|
- */
|
|
|
-
|
|
|
- /*
|
|
|
- (random) Look for ANSI CLS and:
|
|
|
-
|
|
|
- display random spooky texts around, with delays ... then CLS.
|
|
|
-
|
|
|
- display ANSI graphic file, with delays ... then CLS
|
|
|
- */
|
|
|
- const char *ANSI_CLS = "\x1b[2J";
|
|
|
- cp = strnstr(play, len, ANSI_CLS); // strstr(buffer, ANSI_CLS);
|
|
|
-
|
|
|
- if (cp != NULL) {
|
|
|
- static int ANSI_CLS_count = 0; // count the number we've seen
|
|
|
- ZF_LOGI("seen: ANSI_CLS");
|
|
|
- ANSI_CLS_count++;
|
|
|
-
|
|
|
- // Don't activate on the very first CLS. Too soon, don't screw up the ANSI
|
|
|
- // detection.
|
|
|
- if (ANSI_CLS_count > 1) {
|
|
|
- // Ok, figure out the restore color, just in case
|
|
|
- struct console_details temp_console;
|
|
|
- // Make exact copy of our current console state.
|
|
|
- memcpy(&temp_console, &console, sizeof(console));
|
|
|
- // Play the buffer into the console
|
|
|
- console_receive(&temp_console, play, cp - play);
|
|
|
- char restore_color[30]; // ansi color
|
|
|
- strcpy(restore_color, color_restore(&temp_console));
|
|
|
-
|
|
|
- if (random_activate(3)) {
|
|
|
- char display[100] = "";
|
|
|
- int slen;
|
|
|
- int needs_cls = 0;
|
|
|
-
|
|
|
- struct image {
|
|
|
- const char **lines;
|
|
|
- int size;
|
|
|
- int cls;
|
|
|
- int width; // height = size
|
|
|
- } images[] = {{ghost, sizeof(ghost) / sizeof(char *), 1, 0},
|
|
|
- {ghead, sizeof(ghead) / sizeof(char *), 1, 0},
|
|
|
- {wolf, sizeof(wolf) / sizeof(char *), 1, 0},
|
|
|
- {panther, sizeof(panther) / sizeof(char *), 1, 0},
|
|
|
- {bat, sizeof(bat) / sizeof(char *), 1, 0},
|
|
|
- {icu, sizeof(icu) / sizeof(char *), 0, 20},
|
|
|
- {skull, sizeof(skull) / sizeof(char *), 0, 19},
|
|
|
- {skullblink, sizeof(skullblink) / sizeof(char *), 0, 19}};
|
|
|
-
|
|
|
- static LastSeen last_files(2);
|
|
|
- int r;
|
|
|
-
|
|
|
- do {
|
|
|
- r = randint((sizeof(images) / sizeof(image)));
|
|
|
- } while (last_files.seen_before(r));
|
|
|
-
|
|
|
- char fgoto[32];
|
|
|
-
|
|
|
- if (!images[r].cls) {
|
|
|
- int x = 0, y = 0;
|
|
|
-
|
|
|
- x = randint(79 - images[r].width) + 1;
|
|
|
- y = randint(24 - images[r].size) + 1;
|
|
|
-
|
|
|
- int slen;
|
|
|
- // render image, home cursor
|
|
|
- slen = snprintf(fgoto, sizeof(fgoto), "^f%02d%02d\x1b[1;1H", x, y);
|
|
|
- if (slen >= sizeof(fgoto)) {
|
|
|
- ZF_LOGE("snprintf %d > size %d", slen, (int)sizeof(fgoto));
|
|
|
- fgoto[0] = 0;
|
|
|
- }
|
|
|
- } else {
|
|
|
- strcpy(fgoto, "^F");
|
|
|
- }
|
|
|
-
|
|
|
- // (2); // (sizeof(possibles) / sizeof(file_need)) - 1);
|
|
|
- needs_cls = images[r].cls;
|
|
|
-
|
|
|
- // I get what's happening. Mystic moves cursor to home, CLS, cursor
|
|
|
- // home. When we get here, we're ALWAYS at the top of the screen...
|
|
|
- // Hence our bat isn't displayed at the end of the screen.
|
|
|
-
|
|
|
- // This is before the actual CLS, so we CLS before displaying our files.
|
|
|
- // I tried a ^P2 before doing this .. but I'd rather have the picture up
|
|
|
- // right away I think.
|
|
|
-
|
|
|
- // Ok, yes, there's no filename being sent. :P
|
|
|
- render_image(images[r].lines, images[r].size);
|
|
|
-
|
|
|
- slen = snprintf(display, sizeof(display), "%s%s%s^P3",
|
|
|
- needs_cls ? "\x1b[2J" : "", fgoto, restore_color);
|
|
|
- if (slen >= sizeof(display)) {
|
|
|
- ZF_LOGE("snprintf %d > size %d", slen, (int)sizeof(display));
|
|
|
- display[0] = 0;
|
|
|
- }
|
|
|
- ZF_LOGI("mangle(ANSI_CLS): %d file inserted %s", r, repr(display));
|
|
|
-
|
|
|
- // Move the buffer so there's room for the display string.
|
|
|
- if (buffer_insert(play, len, sizeof(play), cp - play, display)) {
|
|
|
- len += strlen(display);
|
|
|
- // if (string_insert(buffer, 1024, cp - buffer, display)) {
|
|
|
-
|
|
|
- ZF_LOGI_MEM(play, len, "mangle(ANSI_CLS) (%u bytes):", len);
|
|
|
- // ZF_LOGI("mangle(ANSI_CLS):");
|
|
|
- // ZF_LOGI_REPR(buffer);
|
|
|
- // ZF_LOGI("mangle(ANSI_CLS): [%s]", repr(buffer));
|
|
|
- need_render = 1;
|
|
|
-
|
|
|
- /*
|
|
|
- Copy the new buffer over, but hide our "render" code
|
|
|
- from the remaining mangler steps.
|
|
|
- */
|
|
|
- memcpy(work, play, len);
|
|
|
- // strcpy(work, buffer);
|
|
|
- i = cp - play;
|
|
|
- // find offset into "buffer"
|
|
|
- // apply to work.
|
|
|
- memset(work + i, ' ', strlen(display));
|
|
|
-
|
|
|
- } else {
|
|
|
- ZF_LOGD("insert failed [%s].", repr(display));
|
|
|
- }
|
|
|
- } else {
|
|
|
- if (random_activate(4)) {
|
|
|
- int r;
|
|
|
- char display[100] = "";
|
|
|
- int slen;
|
|
|
-
|
|
|
- /*
|
|
|
- Interesting note here:
|
|
|
- "Anyone there" qualifies as a valid WORDS regex match.
|
|
|
- It is possible that it can get mangled/wrangled!
|
|
|
- */
|
|
|
- const char *phrasing[] = {
|
|
|
- "^R1Haha^P1ha^P1ha", "Poof!", "Got U", "Anyone there?",
|
|
|
- "^R1Knock, ^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);
|
|
|
-
|
|
|
- ZF_LOGI("mangle(ANSI_CLS)");
|
|
|
- // sprintf( display, "^P2...");
|
|
|
- // This string actually screws up ANSI detection (takes too long)
|
|
|
- // strcpy(display, "^P2^S501234567890^P1abcdef^P2g^P3h^P4i^S0^P2");
|
|
|
-
|
|
|
- // strcpy(display, "^P2^S301234^P15^S0^P2");
|
|
|
-
|
|
|
- // Add in random text, plus color!
|
|
|
- do {
|
|
|
- r = randint(sizeof(phrasing) / sizeof(char *));
|
|
|
- } while (last_phrasing.seen_before(r));
|
|
|
-
|
|
|
- int color = random() % 15 + 1;
|
|
|
- int x = random() % 30 + 1;
|
|
|
- int y = random() % 15 + 1;
|
|
|
-
|
|
|
- /*
|
|
|
- Don't have it pause there before moving the cursor.
|
|
|
-
|
|
|
- Move the cursor, get the color changed, THEN pause.
|
|
|
- Then act all crazy.
|
|
|
-
|
|
|
- NOTE: Make sure if you use any ^R Render effects, turn them off
|
|
|
- before trying to display the restore_color. :P ^R0 Also, make
|
|
|
- sure you re-home the cursor ^G0101 because that's where they are
|
|
|
- expecting the cursor to be! (At least it's how Mystic does it.)
|
|
|
-
|
|
|
- HOME, CLS, HOME, ... Not sure what others do there. We'll see.
|
|
|
- */
|
|
|
-
|
|
|
- slen = snprintf(display, sizeof(display),
|
|
|
- "^G%02d%02d^S3^C%02d^P1%s^S0^R0%s^P1^G0101", x, y,
|
|
|
- color, phrasing[r], restore_color);
|
|
|
- if (slen >= sizeof(display)) {
|
|
|
- ZF_LOGE("snprintf %d > size %d (Phrase: %d, %s)", slen,
|
|
|
- (int)sizeof(display), r, phrasing[r]);
|
|
|
- display[0] = 0;
|
|
|
- }
|
|
|
-
|
|
|
- // sprintf(display, "^P1^S3^C%02d%s^S0^R0%s^P1", color, phrasing[r],
|
|
|
- // restore_color);
|
|
|
- // Added debug statement so we can identify what was sent... color,
|
|
|
- // number picked and what that is
|
|
|
- ZF_LOGD("mangle(ANSI_CLS): Inserted color=%02d r=%d phrase='%s'",
|
|
|
- color, r, phrasing[r]);
|
|
|
- ZF_LOGI_MEM(play, len, "mangle(ANSI_CLS) :");
|
|
|
-
|
|
|
- // Move the buffer so there's room for the display string.
|
|
|
- if (buffer_insert(play, len, sizeof(play), cp - play, display)) {
|
|
|
- len += strlen(display);
|
|
|
-
|
|
|
- // if (string_insert(buffer, BSIZE * 4, cp - buffer, display)) {
|
|
|
- ZF_LOGI_MEM(play, len, "mangle(ANSI_CLS) + :");
|
|
|
- // ZF_LOGI("mangle(ANSI_CLS):");
|
|
|
- // ZF_LOGI_REPR(buffer);
|
|
|
- need_render = 1;
|
|
|
-
|
|
|
- /*
|
|
|
- Copy the new buffer over, but hide our "render" code
|
|
|
- from the remaining mangler steps.
|
|
|
- */
|
|
|
- memcpy(work, play, len);
|
|
|
- // strcpy(work, buffer);
|
|
|
- i = cp - play;
|
|
|
- // find offset into "buffer"
|
|
|
- // apply to work.
|
|
|
- memset(work + i, ' ', strlen(display));
|
|
|
-
|
|
|
- } else {
|
|
|
- ZF_LOGD("insert failed [%s].", repr(display));
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- memcpy(work, play, len);
|
|
|
-
|
|
|
- // strcpy(work, buffer); // sure.
|
|
|
-
|
|
|
- // NOTE: This is NOT aware of my ^TRIGGERS, so they will show up
|
|
|
- // as valid things to mangle in work. (Keep this in mind).
|
|
|
-
|
|
|
- const char replace_with = ' ';
|
|
|
- for (x = 0; x < len; x++) {
|
|
|
- termchar tc = console_char(&console, play[x]);
|
|
|
- int ansi = tc.in_ansi;
|
|
|
-
|
|
|
- if (ansi) {
|
|
|
- work[x] = replace_with;
|
|
|
- if (tc.ansi != START) {
|
|
|
- ZF_LOGD("ANSI type %d at %d", tc.ansi, x);
|
|
|
- }
|
|
|
- }
|
|
|
- // fixup "work" so it's a valid C string
|
|
|
- if (buffer[x] == 0) {
|
|
|
- work[x] = replace_with;
|
|
|
- }
|
|
|
- }
|
|
|
- // fixup "work" buffer so it's a valid c string
|
|
|
- // (required for regex to work.)
|
|
|
- work[len] = 0;
|
|
|
-
|
|
|
- ZF_LOGV_MEM(work, len, "Work now:");
|
|
|
-
|
|
|
- /*
|
|
|
- (random) Locate words (in work), and possibly flip them around.
|
|
|
- Transpose words. Transpose case. Transpose letters.
|
|
|
-
|
|
|
- Ok, what would be interesting, is if we could find
|
|
|
- W\x1[0;34mORDS with color changes in them, and work with them.
|
|
|
- without screwing up the color changes, of course. :P
|
|
|
-
|
|
|
- Example:
|
|
|
-
|
|
|
- Y\x1b[0;1mes \x1b[0;1;34m\x1b[0;1;34;44m N\x1b[0;1;44mo
|
|
|
- Yes No
|
|
|
- ^ This would be a job for a crazy regex.
|
|
|
-
|
|
|
- I'd have to map the characters to positions in the buffer. :S
|
|
|
- I'd want mangle and wrangle to work.
|
|
|
-
|
|
|
- The Message menu -- doesn't hardly get mangled at all (at least on
|
|
|
- my test site). Because all of the color changes break up the
|
|
|
- words in the menu.
|
|
|
- */
|
|
|
- x = rx_match(&WORDS, work);
|
|
|
- ZF_LOGD("found %d word groups", x);
|
|
|
-
|
|
|
- if (x > 0) {
|
|
|
- for (i = 0; i < x; i++) {
|
|
|
-
|
|
|
- // Yes! Be random!
|
|
|
- if (random_activate(8)) {
|
|
|
- int c = word_mangler(play + rxmatch[i].rm_so,
|
|
|
- rxmatch[i].rm_eo - rxmatch[i].rm_so);
|
|
|
- if (c) {
|
|
|
- mangled++;
|
|
|
- mangled_chars += c;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if (random_activate(4)) {
|
|
|
- word_wrangler(play + rxmatch[i].rm_so,
|
|
|
- rxmatch[i].rm_eo - rxmatch[i].rm_so);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /*
|
|
|
- (random) Locate single words, and transpose words.
|
|
|
- Transpose letters.
|
|
|
- */
|
|
|
-
|
|
|
- /*
|
|
|
- (random) Display up to certain point. Delay.
|
|
|
- Print some characters slowly. Delay.
|
|
|
- */
|
|
|
-
|
|
|
- if (mangled)
|
|
|
- ZF_LOGI("Mangled %d word, %d chars (render %d)", mangled, mangled_chars,
|
|
|
- need_render);
|
|
|
-
|
|
|
- if (need_render) {
|
|
|
- ZF_LOGD_MEM(play, len, "Ready to render:");
|
|
|
- // ZF_LOGD("HH %d : (%d) %s", need_render, (int)strlen(buffer),
|
|
|
- // repr(buffer));
|
|
|
- }
|
|
|
-
|
|
|
- if (need_render) {
|
|
|
- render(fd, play, len);
|
|
|
- } else {
|
|
|
- write(fd, play, len);
|
|
|
- };
|
|
|
- return need_render && mangled;
|
|
|
-}
|
|
|
-
|
|
|
-int harry_happens(time_t *last_event, int wakeup) {
|
|
|
- time_t now = time(NULL);
|
|
|
- int elapsed = now - *last_event;
|
|
|
-
|
|
|
- if (elapsed > wakeup) {
|
|
|
- // Ok! It's been too long since we've done something.
|
|
|
- *last_event = now;
|
|
|
- return 1;
|
|
|
- }
|
|
|
- return 0;
|
|
|
-}
|
|
|
-#endif // UNWANTED
|
|
|
-
|
|
|
int mangle_clrscr(std::string &buffer, std::string &work, size_t pos) {
|
|
|
static int ANSI_CLS_count = 0;
|
|
|
ZF_LOGI("seen: ANSI_CLS");
|
|
@@ -776,7 +234,7 @@ int mangle_clrscr(std::string &buffer, std::string &work, size_t pos) {
|
|
|
|
|
|
int mangle(int fd, std::string &buffer) {
|
|
|
// a simple default for now.
|
|
|
- ZF_LOGI_MEM(buffer.data(), buffer.size(), "mangle(%d): %lu bytes", fd,
|
|
|
+ ZF_LOGV_MEM(buffer.data(), buffer.size(), "mangle(%d): %lu bytes", fd,
|
|
|
buffer.size());
|
|
|
|
|
|
int need_render = 0;
|
|
@@ -818,7 +276,7 @@ int mangle(int fd, std::string &buffer) {
|
|
|
if (tc.in_ansi) {
|
|
|
if (tc.ansi != START) {
|
|
|
// Ok, this is something. What is it?
|
|
|
- ZF_LOGD("ANSI type %d at %lu", tc.ansi, stri);
|
|
|
+ // ZF_LOGV("ANSI type %d at %lu", tc.ansi, stri);
|
|
|
switch (tc.ansi) {
|
|
|
case CURSOR:
|
|
|
case CLEAR:
|
|
@@ -829,6 +287,7 @@ int mangle(int fd, std::string &buffer) {
|
|
|
case COLOR:
|
|
|
// text.append(1, ' ');
|
|
|
// text_offsets.push_back(-1);
|
|
|
+ // color changes show as nothing in the text string.
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
@@ -843,9 +302,9 @@ int mangle(int fd, std::string &buffer) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- ZF_LOGD_MEM(buffer.data(), buffer.size(), "Buffer:");
|
|
|
- ZF_LOGD_MEM(work.data(), work.size(), "Work:");
|
|
|
- ZF_LOGD_MEM(text.data(), text.size(), "Text Buffer:");
|
|
|
+ ZF_LOGV_MEM(buffer.data(), buffer.size(), "Buffer:");
|
|
|
+ ZF_LOGV_MEM(work.data(), work.size(), "Work:");
|
|
|
+ ZF_LOGV_MEM(text.data(), text.size(), "Text Buffer:");
|
|
|
|
|
|
// Output vector contents
|
|
|
std::ostringstream oss;
|
|
@@ -858,7 +317,7 @@ int mangle(int fd, std::string &buffer) {
|
|
|
oss << *it;
|
|
|
if (comma == 30) {
|
|
|
std::string temp_output = oss.str();
|
|
|
- ZF_LOGD("Vector: %s", temp_output.c_str());
|
|
|
+ ZF_LOGV("Vector: %s", temp_output.c_str());
|
|
|
// reset ostringstream
|
|
|
oss.str(std::string());
|
|
|
oss.clear();
|
|
@@ -866,7 +325,7 @@ int mangle(int fd, std::string &buffer) {
|
|
|
}
|
|
|
}
|
|
|
std::string vector_output = oss.str();
|
|
|
- ZF_LOGD("Vector: %s", vector_output.c_str());
|
|
|
+ ZF_LOGV("Vector: %s", vector_output.c_str());
|
|
|
|
|
|
// reset oss (if we need it)
|
|
|
oss.str(std::string());
|
|
@@ -876,6 +335,7 @@ int mangle(int fd, std::string &buffer) {
|
|
|
{
|
|
|
ZF_LOGD("CharMan");
|
|
|
CharMan cm(buffer, work, text, text_offsets);
|
|
|
+ ZF_LOGD("CharMan %d, %d chars", cm.mangle_count, cm.mangle_chars);
|
|
|
};
|
|
|
|
|
|
if (need_render) {
|