|
| teditor::editor::ops::DEF_CMD (Quit, "quit", "editor_ops", DEF_OP() { ed.requestQuitEventLoop();}) |
|
| teditor::editor::ops::DEF_CMD (HelpCommand, "help-command", "editor_ops", DEF_OP() { StringChoices sc(ed.getBuff().cmdNames());auto cmd=ed.prompt("Help for Cmd? ", nullptr, &sc);if(cmd.empty()) return;try { auto c=getCmd(cmd);auto url="https://teju85.github.io/teditor/"+c.second+".html#"+cmd;check_output(Option::get("browserCmd").getStr()+" '"+url+"'");} catch(const std::runtime_error &e) { CMBAR_MSG(ed, "Unknown command: %s!\n", cmd.c_str());} }) |
|
| teditor::editor::ops::DEF_CMD (ScratchBuffer, "scratch-buffer", "editor_ops", DEF_OP() { ed.createScratchBuff(true);}) |
|
| teditor::editor::ops::DEF_CMD (FindFileHistory, "find-file-history", "editor_ops", DEF_OP() { StringChoices sc(ed.fileHistoryToString());auto file=ed.prompt("Find File History: ", nullptr, &sc);if(file.empty()) return;auto fi=readFileInfo(file);ed.load(fi.first, fi.second);}) |
|
| teditor::editor::ops::DEF_CMD (VerticalSplit, "split-vertically", "editor_ops", DEF_OP() { auto status=ed.splitVertically();if(!status) MESSAGE(ed, "Window already split vertically");}) |
|
| teditor::editor::ops::DEF_CMD (ClearAllWindows, "clear-all-windows", "editor_ops", DEF_OP() { ed.clearAllWindows();}) |
|
| teditor::editor::ops::DEF_CMD (NextWindow, "next-window", "editor_ops", DEF_OP() { ed.incrementCurrWin();}) |
|
| teditor::editor::ops::DEF_CMD (FindFile, "find-file", "editor_ops", DEF_OP() { auto &buf=ed.getBuff();auto pwd=buf.pwd()+'/';FileChoices sc(DirCache::getDirContents(pwd));auto file=ed.prompt("Find File: ", nullptr, &sc, pwd);if(!file.empty()) ed.load(file, 0);}) |
|
| teditor::editor::ops::DEF_CMD (ShellCommand, "shell-command", "editor_ops", DEF_OP() { auto cmd=ed.prompt("Shell Command: ");if(!cmd.empty()) { auto res=check_output(cmd);MESSAGE(ed, "Shell Command: %s (exit-status=%d)\nOutput: %s\nError: %s\n", cmd.c_str(), res.status, res.output.c_str(), res.error.c_str());} }) |
|
| teditor::editor::ops::DEF_CMD (RunCommand, "run-command", "editor_ops", DEF_OP() { StringChoices sc(ed.getBuff().cmdNames());auto cmd=ed.prompt("Cmd: ", nullptr, &sc);if(cmd.empty()) return;try { ed.runCmd(cmd);} catch(const std::runtime_error &e) { CMBAR_MSG(ed, "Unknown command: %s! Reason: %s\n", cmd.c_str(), e.what());} }) |
|
| teditor::editor::ops::DEF_CMD (LaunchExplorer, "open-explorer", "editor_ops", DEF_OP() { check_output("cygstart "+ed.getBuff().pwd());}) |
|
| teditor::editor::ops::DEF_CMD (LaunchBrowser, "browser", "editor_ops", DEF_OP() { auto &buf=ed.getBuff();std::string url;if(buf.isRegionActive()) url=buf.regionAsStr()[0];check_output(Option::get("browserCmd").getStr()+" '"+url+"'");}) |
|
| teditor::editor::ops::DEF_CMD (BrowserSearch, "browser-search", "editor_ops", DEF_OP() { OptionMap opts;opts["duckduckgo"]="http://www.duckduckgo.com/?t=hb&ia=meanings&q=%s";opts["google"]="http://www.google.com/#q=%s";opts["maps"]="https://www.google.co.in/maps/search/%s";opts["nvsearch"]="https://nvsearch.nvidia.com/Pages/results.aspx?k=%s";opts["stock"]="https://duckduckgo.com/?q=%s&t=ffab&ia=stock";opts["youtube"]="https://www.youtube.com/results?search_query=%s";auto command=ed.promptEnum("Search:", opts);if(command.empty()) return;command=Option::get("browserCmd").getStr()+" '"+command+"'";auto query=ed.getBuff().regionAsStr();if(query.empty()) query=ed.prompt("Query: ");if(query.empty()) return;auto hexified=urlHexify(query);auto buf=format(command.c_str(), hexified.c_str());check_output(buf.c_str());}) |
|
| teditor::editor::ops::DEF_CMD (Download, "download-url", "editor_ops", DEF_OP() { auto url=ed.prompt("URL: ");if(url.empty()) return;auto file=ed.prompt("File: ");if(file.empty()) return;downloadUrl(url, file, Option::get("dnldProg").getStr(), Option::get("dnldProgOpts").getStr());}) |
|
| teditor::editor::ops::DEF_CMD (MakeDir, "mkdir", "editor_ops", DEF_OP() { auto res=ed.prompt("Dir name: ");if(!res.empty()) makeDir(res);}) |
|
| teditor::editor::ops::DEF_CMD (SwitchBuffer, "buffer-switch", "editor_ops", DEF_OP() { StringChoices sc(ed.buffNamesToString());auto buf=ed.prompt("Buffer: ", nullptr, &sc);if(!buf.empty()) ed.switchToBuff(buf);}) |
|
| teditor::editor::ops::DEF_CMD (GitBranch, "git-branch", "editor_ops", DEF_OP() { auto &buf=ed.getBuff();auto br=gitBranchName(buf.pwd());if(br.empty()) CMBAR(ed, "Not a git-repo!\n");else CMBAR(ed, "git-branch=%s\n", br.c_str());}) |
|
| teditor::editor::ops::DEF_CMD (IndentLine, "indent", "editor_ops", DEF_OP() { ed.getBuff().indent();}) |
|
| teditor::editor::ops::DEF_CMD (OrgNotesDir, "org-notes-dir", "editor_ops", DEF_OP() { ed.load(Option::get("orgNotesDir").getStr(), 0);}) |
|
| teditor::editor::ops::DEF_CMD (SongsDir, "songs-dir", "editor_ops", DEF_OP() { ed.load(Option::get("songsDir").getStr(), 0);}) |
|
| teditor::editor::ops::DEF_CMD (TaskManager, "task-manager", "editor_ops", DEF_OP() { std::string cmd="cygstart Taskmgr.exe";auto res=check_output(cmd);MESSAGE(ed, "Shell Command: %s (exit-status=%d)\nOutput: %s", cmd.c_str(), res.status, res.output.c_str());}) |
|
| teditor::editor::ops::DEF_CMD (DNSLookup, "dns", "editor_ops", DEF_OP() { std::string url=ed.prompt("URL: ");if(url.empty()) return;std::string res;try { res=dnsLookup(url);} catch(const std::runtime_error &e) { res=e.what();} catch(...) { res="Unknown exception occured!";} CMBAR_MSG(ed, "%s\n", res.c_str());}) |
|