File: ui_gpsim.cc

package info (click to toggle)
gpsim 0.32.1-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 16,640 kB
  • sloc: cpp: 121,258; asm: 54,223; ansic: 13,576; python: 9,708; sh: 4,695; makefile: 1,566; lex: 1,139; yacc: 854; pascal: 511; perl: 93; awk: 44; xml: 41
file content (79 lines) | stat: -rw-r--r-- 1,263 bytes parent folder | download | duplicates (2)
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);
}