mirror of
https://gitlab.com/rnger/amath
synced 2025-10-06 02:49:59 +00:00
259 lines
5.6 KiB
Groff
259 lines
5.6 KiB
Groff
.TH "StandardConsole" 3 "Tue Jan 24 2017" "Version 1.6.2" "amath" \" -*- nroff -*-
|
|
.ad l
|
|
.nh
|
|
.SH NAME
|
|
StandardConsole \- Encapsulates the IO of a console using Standard C and termios\&.
|
|
|
|
.SH SYNOPSIS
|
|
.br
|
|
.PP
|
|
.PP
|
|
\fC#include <console_stdc\&.h>\fP
|
|
.PP
|
|
Inherits \fBConsoleBase\fP\&.
|
|
.SS "Public Member Functions"
|
|
|
|
.in +1c
|
|
.ti -1c
|
|
.RI "\fBStandardConsole\fP (const char *\fBprompt\fP, \fBCharValidator\fP *validator)"
|
|
.br
|
|
.ti -1c
|
|
.RI "virtual \fB~StandardConsole\fP ()"
|
|
.br
|
|
.ti -1c
|
|
.RI "virtual int \fBGetStackSize\fP ()"
|
|
.br
|
|
.ti -1c
|
|
.RI "virtual void \fBRun\fP ()"
|
|
.br
|
|
.ti -1c
|
|
.RI "virtual void \fBExit\fP ()"
|
|
.br
|
|
.ti -1c
|
|
.RI "virtual void \fBSetPrompt\fP (const char *string)"
|
|
.br
|
|
.ti -1c
|
|
.RI "virtual void \fBWriteString\fP (const char *string)"
|
|
.br
|
|
.in -1c
|
|
.SS "Private Member Functions"
|
|
|
|
.in +1c
|
|
.ti -1c
|
|
.RI "void \fBReadLine\fP ()"
|
|
.br
|
|
.ti -1c
|
|
.RI "void \fBWrite\fP (const char *string, unsigned int length)"
|
|
.br
|
|
.in -1c
|
|
.SS "Private Attributes"
|
|
|
|
.in +1c
|
|
.ti -1c
|
|
.RI "\fBAnsiConoleEngine\fP * \fBproc\fP"
|
|
.br
|
|
.ti -1c
|
|
.RI "const char * \fBline\fP"
|
|
.br
|
|
.ti -1c
|
|
.RI "\fBbool\fP \fBexit\fP"
|
|
.br
|
|
.in -1c
|
|
.SS "Additional Inherited Members"
|
|
.SH "Detailed Description"
|
|
.PP
|
|
Encapsulates the IO of a console using Standard C and termios\&.
|
|
.PP
|
|
Definition at line 45 of file console_stdc\&.h\&.
|
|
.SH "Constructor & Destructor Documentation"
|
|
.PP
|
|
.SS "StandardConsole::StandardConsole (const char * prompt, \fBCharValidator\fP * validator)"
|
|
|
|
.PP
|
|
Definition at line 34 of file console_stdc\&.cpp\&.
|
|
.PP
|
|
References AnsiConoleEngine::AnsiConoleEngine(), ConsoleBase::ConsoleBase(), and proc\&.
|
|
.PP
|
|
Referenced by StandardProgram::Initialize()\&.
|
|
.PP
|
|
.nf
|
|
34 :
|
|
35 ConsoleBase(prompt)
|
|
36 {
|
|
37 proc = new AnsiConoleEngine(prompt, validator);
|
|
38 }
|
|
.fi
|
|
.SS "StandardConsole::~StandardConsole ()\fC [virtual]\fP"
|
|
|
|
.PP
|
|
Definition at line 40 of file console_stdc\&.cpp\&.
|
|
.PP
|
|
References proc\&.
|
|
.PP
|
|
.nf
|
|
41 {
|
|
42 delete proc;
|
|
43 }
|
|
.fi
|
|
.SH "Member Function Documentation"
|
|
.PP
|
|
.SS "void StandardConsole::Exit ()\fC [virtual]\fP"
|
|
|
|
.PP
|
|
Implements \fBConsoleBase\fP\&.
|
|
.PP
|
|
Definition at line 66 of file console_stdc\&.cpp\&.
|
|
.PP
|
|
References exit\&.
|
|
.PP
|
|
.nf
|
|
67 {
|
|
68 exit = true;
|
|
69 }
|
|
.fi
|
|
.SS "int StandardConsole::GetStackSize ()\fC [virtual]\fP"
|
|
|
|
.PP
|
|
Implements \fBThreadBase\fP\&.
|
|
.PP
|
|
Definition at line 45 of file console_stdc\&.cpp\&.
|
|
.PP
|
|
.nf
|
|
46 {
|
|
47 return 100000;
|
|
48 }
|
|
.fi
|
|
.SS "void StandardConsole::ReadLine ()\fC [private]\fP"
|
|
|
|
.PP
|
|
Definition at line 71 of file console_stdc\&.cpp\&.
|
|
.PP
|
|
References AnsiConoleEngine::GetLine(), AnsiConoleEngine::InputDone(), line, proc, AnsiConoleEngine::ProcessChar(), AnsiConoleEngine::StartInput(), and WriteString()\&.
|
|
.PP
|
|
Referenced by Run()\&.
|
|
.PP
|
|
.nf
|
|
72 {
|
|
73 #ifdef UNIX
|
|
74 termios new_tio, old_tio;
|
|
75 tcgetattr(STDIN_FILENO, &old_tio);
|
|
76 new_tio = old_tio;
|
|
77 new_tio\&.c_lflag &=(~ICANON & ~ECHO);
|
|
78 tcsetattr(STDIN_FILENO, TCSANOW, &new_tio);
|
|
79 #endif
|
|
80
|
|
81 proc->StartInput();
|
|
82
|
|
83 while (!proc->InputDone()) {
|
|
84 unsigned char c = getchar();
|
|
85 //printf("%d ",c);
|
|
86 const char *out = proc->ProcessChar((char)c);
|
|
87 WriteString(out);
|
|
88 }
|
|
89
|
|
90 line = proc->GetLine();
|
|
91
|
|
92 #ifdef UNIX
|
|
93 tcsetattr(STDIN_FILENO, TCSANOW, &old_tio);
|
|
94 #endif
|
|
95 }
|
|
.fi
|
|
.SS "void StandardConsole::Run ()\fC [virtual]\fP"
|
|
|
|
.PP
|
|
Implements \fBThreadBase\fP\&.
|
|
.PP
|
|
Definition at line 50 of file console_stdc\&.cpp\&.
|
|
.PP
|
|
References Evaluator::Evaluate(), Evaluator::Evaluator(), exit, Evaluator::GetResult(), line, ConsoleBase::Prompt(), ReadLine(), ConsoleBase::StartMessage(), StrLen(), and Write()\&.
|
|
.PP
|
|
.nf
|
|
51 {
|
|
52 exit = false;
|
|
53 StartMessage();
|
|
54
|
|
55 while(!exit) {
|
|
56 Prompt();
|
|
57 ReadLine();
|
|
58 Evaluator *evaluator = new Evaluator(line);
|
|
59 evaluator->Evaluate();
|
|
60 const char *res = evaluator->GetResult();
|
|
61 Write(res, StrLen(res));
|
|
62 delete evaluator;
|
|
63 }
|
|
64 }
|
|
.fi
|
|
.SS "void StandardConsole::SetPrompt (const char * string)\fC [virtual]\fP"
|
|
|
|
.PP
|
|
Reimplemented from \fBConsoleBase\fP\&.
|
|
.PP
|
|
Definition at line 113 of file console_stdc\&.cpp\&.
|
|
.PP
|
|
References proc, ConsoleBase::SetPrompt(), and AnsiConoleEngine::SetPrompt()\&.
|
|
.PP
|
|
.nf
|
|
114 {
|
|
115 ConsoleBase::SetPrompt(string);
|
|
116 proc->SetPrompt(string);
|
|
117 }
|
|
.fi
|
|
.SS "void StandardConsole::Write (const char * string, unsigned int length)\fC [private]\fP"
|
|
|
|
.PP
|
|
Definition at line 102 of file console_stdc\&.cpp\&.
|
|
.PP
|
|
Referenced by Run(), and WriteString()\&.
|
|
.PP
|
|
.nf
|
|
103 {
|
|
104 unsigned int i = 0;
|
|
105 while(i < length && string[i] != 0) {
|
|
106 fputc(string[i], stdout);
|
|
107 i++;
|
|
108 }
|
|
109
|
|
110 fflush(stdout);
|
|
111 }
|
|
.fi
|
|
.SS "void StandardConsole::WriteString (const char * string)\fC [virtual]\fP"
|
|
|
|
.PP
|
|
Implements \fBConsoleBase\fP\&.
|
|
.PP
|
|
Definition at line 97 of file console_stdc\&.cpp\&.
|
|
.PP
|
|
References StrLen(), and Write()\&.
|
|
.PP
|
|
Referenced by ReadLine()\&.
|
|
.PP
|
|
.nf
|
|
98 {
|
|
99 Write(string, StrLen(string));
|
|
100 }
|
|
.fi
|
|
.SH "Member Data Documentation"
|
|
.PP
|
|
.SS "\fBbool\fP StandardConsole::exit\fC [private]\fP"
|
|
|
|
.PP
|
|
Definition at line 60 of file console_stdc\&.h\&.
|
|
.PP
|
|
Referenced by Exit(), and Run()\&.
|
|
.SS "const char* StandardConsole::line\fC [private]\fP"
|
|
|
|
.PP
|
|
Definition at line 59 of file console_stdc\&.h\&.
|
|
.PP
|
|
Referenced by ReadLine(), and Run()\&.
|
|
.SS "\fBAnsiConoleEngine\fP* StandardConsole::proc\fC [private]\fP"
|
|
|
|
.PP
|
|
Definition at line 58 of file console_stdc\&.h\&.
|
|
.PP
|
|
Referenced by ReadLine(), SetPrompt(), StandardConsole(), and ~StandardConsole()\&.
|
|
|
|
.SH "Author"
|
|
.PP
|
|
Generated automatically by Doxygen for amath from the source code\&.
|