37 #include "lib/charbuf.h" 38 #include "main/evaluator.h" 43 #pragma GCC diagnostic ignored "-Wno-multichar" 46 #include <Application.h> 48 HaikuProgram::HaikuProgram()
49 : Program(), BApplication(
"application/x-vnd.amath")
56 HaikuProgram::~HaikuProgram()
58 if (Console !=
nullptr)
70 void HaikuProgram::Initialize(
int argc,
char **argv)
74 Console =
new HaikuWindow(Preferences->GetPrompt(), Language);
80 Console =
new TermiosConsole(Preferences->GetPrompt(), Language);
83 line =
new CharBuffer();
88 for (
int i = 1; i < argc; i++)
92 if (StrIsEqual(argv[i],
"noansi") || StrIsEqual(argv[i],
"--noansi"))
97 else if (StrIsEqual(argv[i],
"shell") || StrIsEqual(argv[i],
"--shell"))
109 len += StrLen(argv[i]) + 1;
110 line->EnsureSize(len);
111 line->Append(argv[i]);
118 line->DeleteLastChar();
122 void HaikuProgram::Start()
124 if(Console ==
nullptr || !Console->Open())
144 Evaluator *evaluator =
new Evaluator(line->GetString());
145 evaluator->Evaluate();
146 const char *res = evaluator->GetResult();
147 Console->WriteString(res);
148 Console->ResetConsole();