Example #1
0
void ClearLog()
{
    for (logcount--; logcount >= 0; logcount--)
        free(logtext[truncated_logcount()]);
    logcount = 0;
    if (logwin)
        RedoText();
}
Example #2
0
/**
* Creates the log window if it's not already open.
**/
void MakeLogWindow(void)
{
    if(!logwin)
    {
        logwin = CreateDialog(fceu_hInstance, "MESSAGELOG" , 0, LogCon);
        RedoText(); // XXX jeblanchard Why didn't this work in WM_INITDIALOG?
    } else
    {
        ShowWindow(logwin, SW_SHOWNORMAL);
        SetForegroundWindow(logwin);
    }
}
Example #3
0
static BOOL CALLBACK LogCon(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) {
    DSMFix(uMsg);
    switch (uMsg) {
    case WM_INITDIALOG:
        logwin = hwndDlg;
        RedoText();
        break;
    case WM_COMMAND:
        if (HIWORD(wParam) == BN_CLICKED) {
            DestroyWindow(hwndDlg);
            logwin = 0;
        }
        break;
    }
    return 0;
}
Example #4
0
void AddLogText(char *text,int newline)
{
 int x;
 char *t;

 if(logcount>=64) free(logtext[logcount&63]);

 x=0;
 t=text;
 while(*t)
 {
  if(*t=='\n') x++;
  t++;
 }

 if(!(logtext[logcount&63]=malloc(strlen(text)+1+x+newline*2)))
  return;

 t=logtext[logcount&63];

 while(*text)
 {
  if(*text=='\n')
  {
   *t='\r';
   t++;
  }
  *t=*text;
  t++;
  text++;
 }
 if(newline)
 {
  *t='\r';
  t++;
  *t='\n';
  t++;
 }
 *t=0;
 logcount++;
 if(logwin)
  RedoText();
}
Example #5
0
/**
* Adds a textual log message to the message buffer.
*
* @param text Message to add.
* @param add_newline Either DO_ADD_NEWLINE or DONT_ADD_NEWLINE
**/
void AddLogText(const char *text, unsigned int add_newline)
{
    // Used to count the number of new line characters in text
    int number_of_newlines;

    // Used to iterate over the text
    const char *text_iterator_c;

    // Used to iterate over the message log created in this function
    char* msg_iterator;

    // Free a log message if more messages than necessary were logged.
    if(logcount >= MAXIMUM_NUMBER_OF_LOGS)
    {
        free(logtext[truncated_logcount()]);
    }

    number_of_newlines = 0;
    text_iterator_c = text;

    // Count the number of \n characters in the text
    while(*text_iterator_c)
    {
        if(*text_iterator_c == '\n')
        {
            number_of_newlines++;
        }

        text_iterator_c++;
    }

    unsigned int necessary_size = strlen(text) // len(text)
                                  + 1 // 0-byte
                                  + number_of_newlines // Space for additional \r characters
                                  + 2 * add_newline; // \r\n if a newline was requested

    //mbg merge 7/17/06 added cast
    logtext[truncated_logcount()] = (char*)malloc(necessary_size);

    // Apparently there's no memory left.
    if(!logtext[truncated_logcount()])
    {
        return;
    }

    msg_iterator = logtext[truncated_logcount()];

    // Copy the characters from text to the allocated buffer
    while(*text)
    {
        // Replace \n with \r\n
        if(*text == '\n')
        {
            *msg_iterator='\r';
            msg_iterator++;
        }

        *msg_iterator = *text;

        msg_iterator++;
        text++;
    }

    // Add a final newline if requested
    if (add_newline)
    {
        *msg_iterator = '\r';
        msg_iterator++;
        *msg_iterator = '\n';
        msg_iterator++;
    }

    // Terminating 0-byte
    *msg_iterator = 0;

    // also log the text into Trace Logger log if needed
    if (logging && (logging_options & LOG_MESSAGES))
    {
        OutputLogLine(strdup(logtext[truncated_logcount()]), add_newline != 0);
        log_old_emu_paused = false;		// force Trace Logger update
    }

    // Keep track of the added log
    logcount++;

    if(logwin)
    {
        RedoText();
    }
}