MCPcopy Create free account
hub / github.com/AutoHotkey/AutoHotkey-v1.0 / LogToText

Method LogToText

Source/script.cpp:11379–11413  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11377
11378
11379char *Line::LogToText(char *aBuf, size_t aBufSize)
11380// Static method:
11381// Translates sLog into its text equivalent, putting the result into aBuf and
11382// returning the position in aBuf of its new string terminator.
11383{
11384 if (!aBuf || aBufSize < 256) return NULL;
11385 char *aBuf_orig = aBuf;
11386 //snprintf(aBuf, BUF_SPACE_REMAINING, "Deref buffer size: %u\n\n", sDerefBufSize);
11387 //aBuf += strlen(aBuf);
11388 snprintf(aBuf, BUF_SPACE_REMAINING, "Script lines most recently executed (oldest first). Press [F5] to refresh.\r\n"
11389 "The seconds elapsed between a line and the one after it is in parens to the right (if not 0).\r\n"
11390 "The bottommost line's elapsed time is the number of seconds since it executed.\r\n\r\n");
11391 aBuf += strlen(aBuf);
11392 // Start at the oldest and continue up through the newest:
11393 int i, line_index;
11394 DWORD elapsed;
11395 size_t space_remaining;
11396 for (i = 0, line_index = sLogNext; i < LINE_LOG_SIZE; ++i, ++line_index)
11397 {
11398 if (line_index >= LINE_LOG_SIZE) // wrap around
11399 line_index = 0;
11400 if (sLog[line_index] == NULL)
11401 continue;
11402 if (i + 1 < LINE_LOG_SIZE) // There are still more lines to be processed
11403 elapsed = sLogTick[line_index + 1 >= LINE_LOG_SIZE ? 0 : line_index + 1] - sLogTick[line_index];
11404 else // This is the line, so compare it's time against the current time instead.
11405 elapsed = GetTickCount() - sLogTick[line_index];
11406 space_remaining = BUF_SPACE_REMAINING; // Resolve macro only once for performance.
11407 // Truncate really huge lines so that the Edit control's size is less likely to be exceeded:
11408 aBuf = sLog[line_index]->ToText(aBuf, space_remaining < 500 ? space_remaining : 500, true, elapsed);
11409 }
11410 snprintf(aBuf, BUF_SPACE_REMAINING, "\r\nPress [F5] to refresh.");
11411 aBuf += strlen(aBuf);
11412 return aBuf;
11413}
11414
11415
11416

Callers

nothing calls this directly

Calls 2

snprintfFunction · 0.85
ToTextMethod · 0.45

Tested by

no test coverage detected