// --------------------------------------------------------------------- string smset() { string p=cmd.getid(); if (p.empty()) return smerror("sm set parameters not given"); string c=cmd.getid(); if (c.empty()) return smerror("sm set " + p + " parameters not given"); string q=cmd.getparms(); if (p=="inputlog") return smsetinputlog(c,q); if (p=="term") { if (c=="text") return smsettext(p,q); if (c=="xywh") return smsetxywh(p,q); return smerror("command applies only to an edit window: " + c); } Bedit *e; if (p=="edit") { if (note==0) return smerror("No active edit window"); e=(Bedit *)note->editPage(); } else if (p=="edit2") { if (note2==0) return smerror("No active edit2 window"); e=(Bedit *)note2->editPage(); } else return smerror("unrecognized sm command: set " + p); if (e==0 && (c=="scroll" || c=="select" || c=="text")) return smerror("no edit window for sm command: set " + c); if (c=="scroll") return smsetscroll(e,q); if (c=="select") return smsetselect(e,q); if (c=="text") return smsettext(p,q); if (c=="xywh") return smsetxywh(p,q); return smerror("unrecognized sm command: set " + p + " " + q); }
// --------------------------------------------------------------------- string smopen() { string c=cmd.getid(); string p=cmd.getparms(); if (c=="edit") term->vieweditor(); if (c=="edit2") { if (note==0) return smerror("no edit window open"); note->on_winotherAct_triggered(); } if (c=="edit" || c=="edit2") return ""; if (c!="tab") { return smerror("unrecognized sm command: open " + c); } term->vieweditor(); if (p.empty()) note->newtemp(); else { QString f=s2q(smgetscript(p)); if (!cfexist(f)) return smerror("file not found: " + q2s(f)); note->fileopen(f); } rc=-1; return i2s(note->editIndex()); }
// --------------------------------------------------------------------- string smreplace() { string c=cmd.getid(); string p=cmd.getparms(); if (note==0 || note->editIndex()<0) return smerror ("No active edit window"); if (c!="edit") return smerror("unrecognized sm command: replace " + c); if (p.empty()) return smerror("replace needs 2 parameters: edit filename"); QString f=s2q(smgetscript(p)); if (!cfexist(f)) return smerror("file not found: " + q2s(f)); note->filereplace(f); return""; }
// --------------------------------------------------------------------- string smclose() { string c=cmd.getid(); string p=cmd.getparms(); if (c=="tab") { if (note==0 || note->editIndex()<0) return smerror ("No active edit window"); int ndx=s2q(p).toInt(); if (ndx<0 || ndx>=note->count()) return smerror ("invalid tab index: " + p); note->tabclose(ndx); } else if (c=="edit") { if (note==0) return smerror ("No edit window"); note->close(); } else if (c=="edit2") { if (note2==0) return smerror ("No edit2 window"); note2->close(); } else return smerror ("unrecognized sm command parameters: " + p); return ""; }