#include "caretlist.h" #include CaretList::CaretList(QObject* parent): QObject(parent), mIndex(-1), mPauseAdd(false) { } void CaretList::addCaret(Editor *editor, int line, int aChar) { if (mPauseAdd) return; for (int i=mList.count()-1;i>mIndex;i--) { removeCaret(i); } PEditorCaret caret = std::make_shared(); caret->editor = editor; caret->line = line; caret->aChar = aChar; mList.append(caret); mIndex++; //qDebug()<<"add caret:"<0; } bool CaretList::hasNext() const { //qDebug()<<"has next:"<=0) return mList[mIndex]; return PEditorCaret(); } void CaretList::removeEditor(const Editor *editor) { for (int i = mList.count()-1;i>=0;i--) { if (mList[i]->editor == editor) removeCaret(i); } } void CaretList::reset() { mList.clear(); mIndex = -1; } void CaretList::pause() { mPauseAdd = true; } void CaretList::unPause() { mPauseAdd = false; } void CaretList::linesDeleted(const Editor *editor, int firstLine, int count) { //qDebug()<<"deleted:"<=0;i--) { if (mList[i]->editor == editor && mList[i]->line>=firstLine) { if (mList[i]->line < (firstLine+count)) removeCaret(i); else mList[i]->line-=count; } } } void CaretList::linesInserted(const Editor *editor, int firstLine, int count) { //qDebug()<<"inserted:"<editor == editor && caret->line >= firstLine) caret->line+=count; } } void CaretList::removeCaret(int index) { if (index<0 || index>=mList.count()) return; mList.removeAt(index); if (mIndex>=index) mIndex--; }