1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
|
#include "ui_gpsim.h"
///
/// CGpsimConsole
/// Connector between the gpsim console and the
/// console handler for the loaded modules.
//////////////////////////////////////////////////
CGpsimConsole::CGpsimConsole()
: m_pfOut(nullptr), m_pfIn(nullptr)
{
}
void CGpsimConsole::Printf(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
vfprintf(m_pfOut, fmt, ap);
va_end(ap);
}
void CGpsimConsole::VPrintf(const char *fmt, va_list argptr)
{
vfprintf(m_pfOut, fmt, argptr);
}
void CGpsimConsole::Puts(const char*s)
{
fputs(s, m_pfOut);
}
void CGpsimConsole::Putc(const char c)
{
fputc(c, m_pfOut);
}
const char *CGpsimConsole::Gets(char *s, int size)
{
return fgets(s, size, m_pfIn);
}
void CGpsimConsole::SetOut(FILE *pOut)
{
m_pfOut = pOut;
}
void CGpsimConsole::SetIn(FILE *pIn)
{
m_pfIn = pIn;
}
CGpsimConsole g_Console;
// From input.cc
class Macro;
void add_string_to_input_buffer(const char *s, Macro *m = nullptr);
void NotifyExitOnBreak(int /* iExitCode */ )
{
add_string_to_input_buffer("abort_gpsim_now\n");
}
void initialize_ConsoleUI()
{
g_Console.SetOut(stdout);
g_Console.SetIn(stdin);
GetUserInterface().SetConsole(&g_Console);
GetUserInterface().SetExitOnBreak(NotifyExitOnBreak);
}
|