teditor
1.8.0@@fee5e94
Terminal based editor written in C++
|
Functions | |
DEF_CMD (CommandUndo, "command-undo", "buffer_ops", DEF_OP() { if(!ed.getBuff().undo()) CMBAR_MSG(ed, "No further undo information\n");}) | |
DEF_CMD (CommandRedo, "command-redo", "buffer_ops", DEF_OP() { if(!ed.getBuff().redo()) CMBAR_MSG(ed, "No further redo information\n");}) | |
DEF_CMD (InsertChar, ".insert-char", "buffer_ops", DEF_OP() { auto &buf=ed.getBuff();if(buf.isRegionActive()) ed.runCmd(".backspace-char");auto c=(char) ed.getKey();buf.insert(c);}) | |
DEF_CMD (BackspaceChar, ".backspace-char", "buffer_ops", DEF_OP() { ed.getBuff().remove();}) | |
DEF_CMD (DeleteChar, ".delete-char", "buffer_ops", DEF_OP() { ed.getBuff().remove(true);}) | |
DEF_CMD (KillLine, "kill-line", "buffer_ops", DEF_OP() { auto del=ed.getBuff().killLine();ed.setClipboard(del);CMBAR_MSG(ed, "Line killed\n");}) | |
void | keepRemoveLines (Editor &ed, bool keep) |
DEF_CMD (KeepLines, "keep-lines", "buffer_ops", DEF_OP() { keepRemoveLines(ed, true);}) | |
DEF_CMD (RemoveLines, "remove-lines", "buffer_ops", DEF_OP() { keepRemoveLines(ed, false);}) | |
DEF_CMD (ShellToBuffer, "shell-to-buffer", "buffer_ops", DEF_OP() { auto &buf=ed.getBuff();if(buf.isRegionActive()) buf.remove();auto cmd=ed.prompt("Shell Command: ");if(cmd.empty()) return;MESSAGE(ed, "Shell Command: %s\n", cmd.c_str());auto res=check_output(cmd);if(res.output.empty()) return;buf.insert(res.output);MESSAGE(ed, "Exit Code: %d\nError: %s\n", res.status, res.error.c_str());}) | |
DEF_CMD (StartRegion, "start-region", "buffer_ops", DEF_OP() { auto &buf=ed.getBuff();if(!buf.isRegionActive()) { buf.startRegion();} else { buf.stopRegion();buf.startRegion();} }) | |
DEF_CMD (Cancel, "cancel", "buffer_ops", DEF_OP() { auto &buf=ed.getBuff();if(buf.isRegionActive()) buf.stopRegion();}) | |
DEF_CMD (PasteRegion, "paste-region", "buffer_ops", DEF_OP() { auto &buf=ed.getBuff();if(buf.isRegionActive()) buf.remove();auto copy=ed.clipboard();if(!copy.empty()) buf.insert(copy);}) | |
DEF_CMD (CopyRegion, "copy-region", "buffer_ops", DEF_OP() { auto &buf=ed.getBuff();if(!buf.isRegionActive()) { CMBAR_MSG(ed, "No selection to copy!\n");return;} auto cp=buf.regionAsStr();ed.setClipboard(cp);buf.stopRegion();CMBAR_MSG(ed, "Copy done\n");}) | |
DEF_CMD (CutRegion, "cut-region", "buffer_ops", DEF_OP() { auto &buf=ed.getBuff();if(!buf.isRegionActive()) { CMBAR_MSG(ed, "No selection to cut!\n");return;} auto del=buf.removeAndCopy();ed.setClipboard(del);CMBAR_MSG(ed, "Cut done\n");}) | |
DEF_CMD (DownloadBuffer, "download-to-buffer", "buffer_ops", DEF_OP() { auto &buf=ed.getBuff();if(buf.isRegionActive()) buf.remove();auto url=ed.prompt("URL: ");if(url.empty()) return;auto output=downloadUrlToString(url, Option::get("dnldProg").getStr(), Option::get("dnldProgOpts").getStr());if(output.empty()) return;buf.insert(output);}) | |
DEF_CMD (TextSearch, "search", "buffer_ops", DEF_OP() { auto &buf=ed.getBuff();auto pos=buf.getPoint();ISearch is(ed.getWindow(), Option::get("iCaseSearch").getBool());is.reset();auto ret=ed.prompt("Search: ", nullptr, &is);buf.gotoLine(!ret.empty()? is.getChoiceIdx() :pos.y, ed.getWindow().dim());}) | |
DEF_CMD (Save, "save-buffer", "buffer_ops", DEF_OP() { auto &buf=ed.getBuff();if(buf.isRO()) { CMBAR_MSG(ed, "save-buffer: Read Only Buffer!\n");return;} ed.saveBuffer(buf);}) | |
DEF_CMD (Pwd, "pwd", "buffer_ops", DEF_OP() { const auto &buf=ed.getBuff();CMBAR_MSG(ed, "Pwd: %s\n", buf.pwd().c_str());}) | |
DEF_CMD (Next, "next-buffer", "buffer_ops", DEF_OP() { ed.incrementCurrBuff();}) | |
DEF_CMD (Previous, "prev-buffer", "buffer_ops", DEF_OP() { ed.decrementCurrBuff();}) | |
DEF_CMD (KillThis, "kill-this-buffer", "buffer_ops", DEF_OP() { ed.killCurrBuff();}) | |
DEF_CMD (KillOthers, "kill-other-buffers", "buffer_ops", DEF_OP() { ed.killOtherBuffs();}) | |
DEF_CMD (Reload, "reload-buffer", "buffer_ops", DEF_OP() { auto &buf=ed.getBuff();if(!buf.isModified()||ed.promptYesNo("Buffer modified, still reload? ")) buf.reload();}) | |
teditor::buffer::ops::DEF_CMD | ( | BackspaceChar | , |
".backspace-char" | , | ||
"buffer_ops" | , | ||
DEF_OP() { ed.getBuff().remove();} | |||
) |
teditor::buffer::ops::DEF_CMD | ( | Cancel | , |
"cancel" | , | ||
"buffer_ops" | , | ||
DEF_OP() { auto &buf=ed.getBuff();if(buf.isRegionActive()) buf.stopRegion();} | |||
) |
teditor::buffer::ops::DEF_CMD | ( | CommandRedo | , |
"command-redo" | , | ||
"buffer_ops" | , | ||
DEF_OP() { if(!ed.getBuff().redo()) CMBAR_MSG(ed, "No further redo information\n");} | |||
) |
teditor::buffer::ops::DEF_CMD | ( | CommandUndo | , |
"command-undo" | , | ||
"buffer_ops" | , | ||
DEF_OP() { if(!ed.getBuff().undo()) CMBAR_MSG(ed, "No further undo information\n");} | |||
) |
teditor::buffer::ops::DEF_CMD | ( | CopyRegion | , |
"copy-region" | , | ||
"buffer_ops" | , | ||
DEF_OP() { auto &buf=ed.getBuff();if(!buf.isRegionActive()) { CMBAR_MSG(ed, "No selection to copy!\n");return;} auto cp=buf.regionAsStr();ed.setClipboard(cp);buf.stopRegion();CMBAR_MSG(ed, "Copy done\n");} | |||
) |
teditor::buffer::ops::DEF_CMD | ( | CutRegion | , |
"cut-region" | , | ||
"buffer_ops" | , | ||
DEF_OP() { auto &buf=ed.getBuff();if(!buf.isRegionActive()) { CMBAR_MSG(ed, "No selection to cut!\n");return;} auto del=buf.removeAndCopy();ed.setClipboard(del);CMBAR_MSG(ed, "Cut done\n");} | |||
) |
teditor::buffer::ops::DEF_CMD | ( | DeleteChar | , |
".delete-char" | , | ||
"buffer_ops" | , | ||
DEF_OP() { ed.getBuff().remove(true);} | |||
) |
teditor::buffer::ops::DEF_CMD | ( | DownloadBuffer | , |
"download-to-buffer" | , | ||
"buffer_ops" | , | ||
DEF_OP() { auto &buf=ed.getBuff();if(buf.isRegionActive()) buf.remove();auto url=ed.prompt("URL: ");if(url.empty()) return;auto output=downloadUrlToString(url, Option::get("dnldProg").getStr(), Option::get("dnldProgOpts").getStr());if(output.empty()) return;buf.insert(output);} | |||
) |
teditor::buffer::ops::DEF_CMD | ( | InsertChar | , |
".insert-char" | , | ||
"buffer_ops" | , | ||
DEF_OP() { auto &buf=ed.getBuff();if(buf.isRegionActive()) ed.runCmd(".backspace-char");auto c=(char) ed.getKey();buf.insert(c);} | |||
) |
teditor::buffer::ops::DEF_CMD | ( | KeepLines | , |
"keep-lines" | , | ||
"buffer_ops" | , | ||
DEF_OP() { keepRemoveLines(ed, true);} | |||
) |
teditor::buffer::ops::DEF_CMD | ( | KillLine | , |
"kill-line" | , | ||
"buffer_ops" | , | ||
DEF_OP() { auto del=ed.getBuff().killLine();ed.setClipboard(del);CMBAR_MSG(ed, "Line killed\n");} | |||
) |
teditor::buffer::ops::DEF_CMD | ( | KillOthers | , |
"kill-other-buffers" | , | ||
"buffer_ops" | , | ||
DEF_OP() { ed.killOtherBuffs();} | |||
) |
teditor::buffer::ops::DEF_CMD | ( | KillThis | , |
"kill-this-buffer" | , | ||
"buffer_ops" | , | ||
DEF_OP() { ed.killCurrBuff();} | |||
) |
teditor::buffer::ops::DEF_CMD | ( | Next | , |
"next-buffer" | , | ||
"buffer_ops" | , | ||
DEF_OP() { ed.incrementCurrBuff();} | |||
) |
teditor::buffer::ops::DEF_CMD | ( | PasteRegion | , |
"paste-region" | , | ||
"buffer_ops" | , | ||
DEF_OP() { auto &buf=ed.getBuff();if(buf.isRegionActive()) buf.remove();auto copy=ed.clipboard();if(!copy.empty()) buf.insert(copy);} | |||
) |
teditor::buffer::ops::DEF_CMD | ( | Previous | , |
"prev-buffer" | , | ||
"buffer_ops" | , | ||
DEF_OP() { ed.decrementCurrBuff();} | |||
) |
teditor::buffer::ops::DEF_CMD | ( | Pwd | , |
"pwd" | , | ||
"buffer_ops" | , | ||
DEF_OP() { const auto &buf=ed.getBuff();CMBAR_MSG(ed, "Pwd: %s\n", buf.pwd().c_str());} | |||
) |
teditor::buffer::ops::DEF_CMD | ( | Reload | , |
"reload-buffer" | , | ||
"buffer_ops" | , | ||
DEF_OP() { auto &buf=ed.getBuff();if(!buf.isModified()||ed.promptYesNo("Buffer modified, still reload? ")) buf.reload();} | |||
) |
teditor::buffer::ops::DEF_CMD | ( | RemoveLines | , |
"remove-lines" | , | ||
"buffer_ops" | , | ||
DEF_OP() { keepRemoveLines(ed, false);} | |||
) |
teditor::buffer::ops::DEF_CMD | ( | Save | , |
"save-buffer" | , | ||
"buffer_ops" | , | ||
DEF_OP() { auto &buf=ed.getBuff();if(buf.isRO()) { CMBAR_MSG(ed, "save-buffer: Read Only Buffer!\n");return;} ed.saveBuffer(buf);} | |||
) |
teditor::buffer::ops::DEF_CMD | ( | ShellToBuffer | , |
"shell-to-buffer" | , | ||
"buffer_ops" | , | ||
DEF_OP() { auto &buf=ed.getBuff();if(buf.isRegionActive()) buf.remove();auto cmd=ed.prompt("Shell Command: ");if(cmd.empty()) return;MESSAGE(ed, "Shell Command: %s\n", cmd.c_str());auto res=check_output(cmd);if(res.output.empty()) return;buf.insert(res.output);MESSAGE(ed, "Exit Code: %d\nError: %s\n", res.status, res.error.c_str());} | |||
) |
teditor::buffer::ops::DEF_CMD | ( | StartRegion | , |
"start-region" | , | ||
"buffer_ops" | , | ||
DEF_OP() { auto &buf=ed.getBuff();if(!buf.isRegionActive()) { buf.startRegion();} else { buf.stopRegion();buf.startRegion();} } | |||
) |
teditor::buffer::ops::DEF_CMD | ( | TextSearch | , |
"search" | , | ||
"buffer_ops" | , | ||
DEF_OP() { auto &buf=ed.getBuff();auto pos=buf.getPoint();ISearch is(ed.getWindow(), Option::get("iCaseSearch").getBool());is.reset();auto ret=ed.prompt("Search: ", nullptr, &is);buf.gotoLine(!ret.empty()? is.getChoiceIdx() :pos.y, ed.getWindow().dim());} | |||
) |
void teditor::buffer::ops::keepRemoveLines | ( | Editor & | ed, |
bool | keep | ||
) |