void fwin_putchar(int c) { if (!windowed) { #ifdef __CYGWIN__ if (c == '\n') putchar('\r'); #endif putchar(c); return; } // Observe that since I am concerned (at least a bit) with performance // I buffer characters here so that the cost of inter-thread communication // is not suffered. But every other second (or so) the user-interface thread // will be worken up and will flush the buffer for me, so the user ought to // be given a tolerable experience/ int nxt = term->fwin_in + 1; if (nxt == FWIN_BUFFER_SIZE) nxt = 0; if (nxt == term->fwin_out || term->pauseFlags & PAUSE_PAUSE) fwin_ensure_screen(); // Note and BEWARE here that fwin_ensure_screen() can synchronize the // worker and interface threads and update fwin_in. Observe also that I // can generate a screen update if ^S has been hit. term->fwin_buffer[term->fwin_in] = c; nxt = term->fwin_in + 1; if (nxt == FWIN_BUFFER_SIZE) nxt = 0; term->fwin_in = nxt; FILE *f = term->logfile; if (f != NULL) putc(c, f); }
void fwin_showmath(const char *s) { if (!windowed) return; fwin_ensure_screen(); // get regular text up to date first. fwin_maths = s; LockMutex(term->pauseMutex); // here I have to do real inter-thread communication. if (delay_callback != NULL) (*delay_callback)(1); wake_up_terminal(FXTerminal::SHOW_MATH); // here I need to wait until the signal that I just sent has been received // and processed. regain_lockstep(); if (delay_callback != NULL) (*delay_callback)(0); UnlockMutex(term->pauseMutex); }
void flush_screen() { fwin_ensure_screen(); }