void PluginKateHtmlTools::slipInHTMLtag (Kate::View & view, QString text) // PCP { // We must add a heavy elaborate HTML markup system. Not! QStringList list = QStringList::split (' ', text); QString marked = view.getDoc()->selection (); uint preDeleteLine = 0, preDeleteCol = 0; view.cursorPosition (&preDeleteLine, &preDeleteCol); if (marked.length() > 0) view.keyDelete (); uint line = 0, col = 0; view.cursorPosition (&line, &col); QString pre ("<" + text + ">"); QString post; if (list.count () > 0) post = "</" + list[0] + ">"; view.insertText (pre + marked + post); // all this muck to leave the cursor exactly where the user // put it... // Someday we will can all this (unless if it already // is canned and I didn't find it...) // The second part of the if disrespects the display bugs // when we try to reselect. TODO: fix those bugs, and we can // un-break this if... if (preDeleteLine == line && -1 == marked.find ('\n')) if (preDeleteLine == line && preDeleteCol == col) { view.setCursorPosition (line, col + pre.length () + marked.length () - 1); for (int x (marked.length()); x--;) view.shiftCursorLeft (); } else { view.setCursorPosition (line, col += pre.length ()); for (int x (marked.length()); x--;) view.shiftCursorRight (); } }
void KateFileList::slotViewChanged() { if(!viewManager->activeView()) return; Kate::View *view = viewManager->activeView(); uint dn = view->getDoc()->documentNumber(); QListViewItem *i = firstChild(); while(i) { if(((KateFileListItem *)i)->documentNumber() == dn) { break; } i = i->nextSibling(); } if(!i) return; KateFileListItem *item = (KateFileListItem *)i; setCurrentItem(item); // ### During load of file lists, all the loaded views gets active. // Do something to avoid shading them -- maybe not creating views, just // open the documents??? // int p = 0; // if ( m_viewHistory.count() ) // { // int p = m_viewHistory.findRef( item ); // only repaint items that needs it // } m_viewHistory.removeRef(item); m_viewHistory.prepend(item); for(uint i = 0; i < m_viewHistory.count(); i++) { m_viewHistory.at(i)->setViewHistPos(i + 1); repaintItem(m_viewHistory.at(i)); } }