📄 sc.cpp
字号:
/* * * * */#include <iostream>#include <cstdlib>#include <readline/readline.h>#include <readline/history.h>#include "sc.h"using namespace std;//////void DisplayBanner(){ cout << endl; cout << "SC " << SCVERSION << ", the shell calculator by SD" << endl; cout << endl;}//////bool GetReadline(string prompt, string & line){#ifdef USE_READLINE char *buf = readline(prompt.c_str()); if (buf == NULL) return false; line = string(buf); free(buf); return true;#else cout << prompt; getline(cin, line); return true;#endif}//////void InteractiveMode(Interpreter & sc){ string str; bool inLoop = true; DisplayBanner(); while (inLoop) { if (!GetReadline(sc.GetPrompt(), str)) { cout << endl; break; } try { inLoop = !sc.Execute(str); #ifdef USE_READLINE if (inLoop) add_history(str.c_str()); #endif } catch (Exception *ex) { cerr << ex->ToString() << endl; delete ex; }; sc.DisplayStack(10); }}//////void BatchMode(Interpreter & sc, int ncmd, char *cmd[]){ int i; string str; for (i=1;i<ncmd;i++) { str = string(cmd[i]); try { sc.Execute(str); } catch(Exception *ex) { cerr << ex->ToString() << endl; delete ex; } }}//////int main(int argc, char *argv[]){ Interpreter sc; srand48(long(time(NULL))); if (argc == 1) InteractiveMode(sc); else BatchMode(sc, argc, argv); if (sc.stack.Length() > 0) cout << sc.GetResult() << endl; return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -