void TSC_source::cmd_paste() { QString str; StrChar ch; if (!pasteclipboard(str)) return; if (G_issel()) cmd_cutselblock(); undo_begin(); QString istr; for (int i=0; i<str.G_length(); i++) { ch=str[i]; if ((ch!=10)&&(ch!=13)) istr+=ch; if (ch==10) { if (istr.G_length()>0) { insertstring(istr); istr.clear(); } cmd_insertline(false); } } if (istr.G_length()>0) { insertstring(istr); istr.clear(); } undo_end(); }
void TSC_source::cmd_insertline(bool autoindent, bool backup) { if (!G_canmodify()) return; if ((cursor_linenr<0)||(cursor_linenr>=G_linecount())) return; if (autoindent&&backup) undo_begin(); if (backup) addundo(new TSC_source_undoaction_insertline(this)); QString strl=*lines[cursor_linenr]; strl.substring(0,cursor_colnr-1); QString strr=*lines[cursor_linenr]; strr.substring(cursor_colnr,strr.G_length()); *lines[cursor_linenr]=strl; lines.insertbefore(cursor_linenr+1,new QString(strr)); cursor_linenr++;cursor_colnr=0; if (autoindent) { QString indent; for (int i=0; (i<G_line(cursor_linenr-1)->G_length())&&(G_line(cursor_linenr-1)->G_char(i)==' '); i++) indent+=' '; if (indent.G_length()>0) insertstring(indent,backup); } if (autoindent&&backup) undo_end(); modified=true; }
bool T3DControl_Edit::UI_OnKeyDown(UINT ch, bool shiftpressed, bool controlpressed) { if (ch==VK_BACK) { QString str; content->tostring(str,0); str.substring(0,str.G_length()-2); content->fromstring(str); Set_wasmodified(); return true; } return false; }
void TSC_source::cmd_tab(bool invert, bool backup) { QString str; int selline1,selcol1,selline2,selcol2; if (!G_sel(selline1,selcol1,selline2,selcol2)) { //try to indent int linenr=G_cursor_linenr(); if ((linenr<0)||(linenr>=G_linecount())) return; int colnr=G_cursor_colnr(); if ((colnr<G_line(linenr)->G_length())) return; if (backup) undo_begin(); (*lines[linenr])+=_qstr(" "); if (backup) addundo(new TSC_source_undoaction_insertstring(this,_qstr(" "))); cursor_colnr+=3; if (backup) undo_end(); modified=true; return; } //shift group block if (backup) undo_begin(); int ct1=selline1; int ct2=selline2; if (selcol2<0) ct2=selline2-1; for (int i=ct1; i<=ct2; i++) { if (!invert) { cursor_linenr=i;cursor_colnr=0; str=_qstr(" "); str+=*lines[cursor_linenr]; if (backup) addundo(new TSC_source_undoaction_insertstring(this,_qstr(" "))); *lines[cursor_linenr]=str; } else { cursor_linenr=i;cursor_colnr=0; str=*lines[cursor_linenr]; if (str.G_char(0)==' ') { str.substring(1,str.G_length()-1); if (backup) addundo(new TSC_source_undoaction_del(this,1)); *lines[cursor_linenr]=str; } } } if (backup) undo_end(); modified=true; }
void TxtTabular::parsefrom(StrPtr icols, StrPtr icontent) { QString cols=icols; colaligns.reset(); while (qstrlen(cols)>0) { bool processed=false; if ((!processed)&&(cols[0]=='|')) { vertlineleftfrom.add(colaligns.G_count()); cols.substring(1,cols.G_length()); processed=true; } if ((!processed)&&(cols[0]=='l')) { colaligns.add(-1); fixedcolsizes.add(-1); cols.substring(1,cols.G_length()); processed=true; } if ((!processed)&&(cols[0]=='c')) { colaligns.add(0); fixedcolsizes.add(-1); cols.substring(1,cols.G_length()); processed=true; } if ((!processed)&&(cols[0]=='r')) { colaligns.add(+1); fixedcolsizes.add(-1); cols.substring(1,cols.G_length()); processed=true; } if ((!processed)&&(cols[0]=='p')) { cols.substring(1,cols.G_length()); QString substr; colaligns.add(-1); getargument(cols,substr,true); fixedcolsizes.add(ConvertSize(substr,fnt)); processed=true; } } colcount=colaligns.G_count(); QString content;content=icontent; while (content.G_length()>0) { QString linetxt; content.splitstring(_qstr("\\\\"),linetxt); eatstartspaces(linetxt); if (trykeyword(linetxt,_qstr("\\hline"))) { horlinetopof.add(lines.G_count()); eatstartspaces(linetxt); } if (linetxt.G_length()>0) { TabularLine *line=new TabularLine;lines.add(line); int curcolnr=0; while (linetxt.G_length()>0) { QString celltxt; linetxt.splitstring(_qstr("&"),celltxt); eatstartspaces(celltxt);eatendspaces(celltxt); TabularCell *cell=new TabularCell(env,fnt); cell->colnr_start=curcolnr;cell->colnr_end=curcolnr; if (trykeyword(celltxt,_qstr("\\multicolumn"))) { QString arg_num,arg_align,arg_content; getargument(celltxt,arg_num,true); getargument(celltxt,arg_align,true); getargument(celltxt,arg_content,true); if (arg_align[0]=='l') cell->align=-1; if (arg_align[0]=='c') cell->align= 0; if (arg_align[0]=='r') cell->align=+1; cell->colnr_end=cell->colnr_start+qstr2int(arg_num)-1; celltxt=arg_content; } cell->parsefrom(celltxt); line->cells.add(cell); curcolnr++; if (curcolnr>colcount) colcount=curcolnr; } } } }