diff --git a/NEWS.md b/NEWS.md index ca0ed84f..e4fcce41 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,4 +2,5 @@ Version 0.2 - enhancement: paint color editor use system palette's disabled group color - fix: add watch not work when there's no editor openned; - enhancement: rainbow parenthesis - - enhancement: run executable with parameters \ No newline at end of file + - enhancement: run executable with parameters + - add: widget for function tips \ No newline at end of file diff --git a/RedPandaIDE/RedPandaIDE.pro b/RedPandaIDE/RedPandaIDE.pro index 90eafd4a..7db73e97 100644 --- a/RedPandaIDE/RedPandaIDE.pro +++ b/RedPandaIDE/RedPandaIDE.pro @@ -99,6 +99,7 @@ SOURCES += \ widgets/consolewidget.cpp \ widgets/custommakefileinfodialog.cpp \ widgets/filepropertiesdialog.cpp \ + widgets/functiontipwidget.cpp \ widgets/headercompletionpopup.cpp \ widgets/issuestable.cpp \ widgets/newprojectdialog.cpp \ @@ -196,6 +197,7 @@ HEADERS += \ widgets/consolewidget.h \ widgets/custommakefileinfodialog.h \ widgets/filepropertiesdialog.h \ + widgets/functiontipwidget.h \ widgets/headercompletionpopup.h \ widgets/issuestable.h \ widgets/newprojectdialog.h \ diff --git a/RedPandaIDE/editor.cpp b/RedPandaIDE/editor.cpp index 273dbe78..ee804a66 100644 --- a/RedPandaIDE/editor.cpp +++ b/RedPandaIDE/editor.cpp @@ -377,7 +377,7 @@ void Editor::undoSymbolCompletion(int pos) return; if (!pSettings->editor().removeSymbolPairs()) return; - if (!GetHighlighterAttriAtRowCol(caretXY(), Token, tokenFinished, tokenType, Attr)) + if (!getHighlighterAttriAtRowCol(caretXY(), Token, tokenFinished, tokenType, Attr)) return; if ((tokenType == SynHighlighterTokenType::Comment) && (!tokenFinished)) return ; @@ -412,7 +412,7 @@ void Editor::undoSymbolCompletion(int pos) (pSettings->editor().completeBrace() && (DeletedChar == '{') && (NextChar == '}')) || (pSettings->editor().completeSingleQuote() && (DeletedChar == '\'') && (NextChar == '\'')) || (pSettings->editor().completeDoubleQuote() && (DeletedChar == '\"') && (NextChar == '\"'))) { - CommandProcessor(SynEditorCommand::ecDeleteChar); + commandProcessor(SynEditorCommand::ecDeleteChar); } } @@ -730,7 +730,7 @@ bool Editor::event(QEvent *event) int line ; if (reason == TipType::Error) { pError = getSyntaxIssueAtPosition(p); - } else if (PointToLine(helpEvent->pos(),line)) { + } else if (pointToLine(helpEvent->pos(),line)) { //it's on gutter //see if its error; PSyntaxIssueList issues = getSyntaxIssuesAtLine(line); @@ -750,7 +750,7 @@ bool Editor::event(QEvent *event) s = lines()->getString(p.Line - 1); isIncludeLine = mParser->isIncludeLine(s); if (!isIncludeLine) - s = WordAtRowCol(p); + s = wordAtRowCol(p); break; case TipType::Identifier: if (pMainWindow->debugger()->executing()) @@ -866,7 +866,7 @@ void Editor::mouseReleaseEvent(QMouseEvent *event) && (event->button() == Qt::LeftButton)) { BufferCoord p; - if (PointToCharLine(event->pos(),p)) { + if (pointToCharLine(event->pos(),p)) { QString s = lines()->getString(p.Line - 1); if (mParser->isIncludeLine(s)) { QString filename = mParser->getHeaderFileName(mFilename,s); @@ -988,7 +988,7 @@ void Editor::addSyntaxIssues(int line, int startChar, int endChar, CompileIssueT start = 1; token = lines()->getString(line-1); } else if (endChar < 1) { - if (!GetHighlighterAttriAtRowColEx(p,token,tokenType,tokenKind,start,attr)) + if (!getHighlighterAttriAtRowColEx(p,token,tokenType,tokenKind,start,attr)) return; } else { start = startChar; @@ -1123,8 +1123,8 @@ void Editor::onStatusChanged(SynStatusChanges changes) BufferCoord wordBegin,wordEnd,bb,be; bb = blockBegin(); be = blockEnd(); - wordBegin = WordStartEx(bb); - wordEnd = WordEndEx(be); + wordBegin = wordStartEx(bb); + wordEnd = wordEndEx(be); if (wordBegin.Line == bb.Line && wordBegin.Char == bb.Char && wordEnd.Line == be.Line @@ -1277,7 +1277,7 @@ bool Editor::handleSymbolCompletion(QChar key) QString Token; bool tokenFinished; SynHighlighterTokenType tokenType; - if (GetHighlighterAttriAtRowCol(HighlightPos, Token, tokenFinished, tokenType,Attr)) { + if (getHighlighterAttriAtRowCol(HighlightPos, Token, tokenFinished, tokenType,Attr)) { if ((tokenType == SynHighlighterTokenType::Comment) && (!tokenFinished)) return false; if ((tokenType == SynHighlighterTokenType::String) && (!tokenFinished) @@ -1362,9 +1362,9 @@ bool Editor::handleParentheseCompletion() QuoteStatus status = getQuoteStatus(); if (status == QuoteStatus::RawString || status == QuoteStatus::NotQuote) { beginUpdate(); - CommandProcessor(SynEditorCommand::ecChar,'('); + commandProcessor(SynEditorCommand::ecChar,'('); BufferCoord oldCaret = caretXY(); - CommandProcessor(SynEditorCommand::ecChar,')'); + commandProcessor(SynEditorCommand::ecChar,')'); setCaretXY(oldCaret); endUpdate(); return true; @@ -1400,9 +1400,9 @@ bool Editor::handleBracketCompletion() // QuoteStatus status = getQuoteStatus(); // if (status == QuoteStatus::RawString || status == QuoteStatus::NotQuote) { beginUpdate(); - CommandProcessor(SynEditorCommand::ecChar,'['); + commandProcessor(SynEditorCommand::ecChar,'['); BufferCoord oldCaret = caretXY(); - CommandProcessor(SynEditorCommand::ecChar,']'); + commandProcessor(SynEditorCommand::ecChar,']'); setCaretXY(oldCaret); endUpdate(); return true; @@ -1425,10 +1425,10 @@ bool Editor::handleMultilineCommentCompletion() { if (((caretX() > 1) && (caretX()-1 < lineText().length())) && (lineText()[caretX() - 1] == '/')) { beginUpdate(); - CommandProcessor(SynEditorCommand::ecChar,'*'); + commandProcessor(SynEditorCommand::ecChar,'*'); BufferCoord oldCaret = caretXY(); - CommandProcessor(SynEditorCommand::ecChar,'*'); - CommandProcessor(SynEditorCommand::ecChar,'/'); + commandProcessor(SynEditorCommand::ecChar,'*'); + commandProcessor(SynEditorCommand::ecChar,'/'); setCaretXY(oldCaret); endUpdate(); return true; @@ -1445,9 +1445,9 @@ bool Editor::handleBraceCompletion() i--; } beginUpdate(); - CommandProcessor(SynEditorCommand::ecChar,'{'); + commandProcessor(SynEditorCommand::ecChar,'{'); BufferCoord oldCaret = caretXY(); - CommandProcessor(SynEditorCommand::ecChar,'}'); + commandProcessor(SynEditorCommand::ecChar,'}'); if ( ( (s.startsWith("struct") || s.startsWith("class") @@ -1458,7 +1458,7 @@ bool Editor::handleBraceCompletion() || s.startsWith("enum") ) && !s.contains(';') ) || s.endsWith('=')) { - CommandProcessor(SynEditorCommand::ecChar,';'); + commandProcessor(SynEditorCommand::ecChar,';'); } setCaretXY(oldCaret); endUpdate(); @@ -1473,7 +1473,7 @@ bool Editor::handleBraceSkip() if (pos.Line != 0) { bool oldInsertMode = insertMode(); setInsertMode(false); //set mode to overwrite - CommandProcessor(SynEditorCommand::ecChar,'}'); + commandProcessor(SynEditorCommand::ecChar,'}'); setInsertMode(oldInsertMode); // setCaretXY( BufferCoord{caretX() + 1, caretY()}); // skip over return true; @@ -1495,9 +1495,9 @@ bool Editor::handleSingleQuoteCompletion() if (ch == 0 || highlighter()->isWordBreakChar(ch) || highlighter()->isSpaceChar(ch)) { // insert '' beginUpdate(); - CommandProcessor(SynEditorCommand::ecChar,'\''); + commandProcessor(SynEditorCommand::ecChar,'\''); BufferCoord oldCaret = caretXY(); - CommandProcessor(SynEditorCommand::ecChar,'\''); + commandProcessor(SynEditorCommand::ecChar,'\''); setCaretXY(oldCaret); endUpdate(); return true; @@ -1521,9 +1521,9 @@ bool Editor::handleDoubleQuoteCompletion() if ((ch == 0) || highlighter()->isWordBreakChar(ch) || highlighter()->isSpaceChar(ch)) { // insert "" beginUpdate(); - CommandProcessor(SynEditorCommand::ecChar,'"'); + commandProcessor(SynEditorCommand::ecChar,'"'); BufferCoord oldCaret = caretXY(); - CommandProcessor(SynEditorCommand::ecChar,'"'); + commandProcessor(SynEditorCommand::ecChar,'"'); setCaretXY(oldCaret); endUpdate(); return true; @@ -1541,9 +1541,9 @@ bool Editor::handleGlobalIncludeCompletion() if (!s.startsWith("include")) //it's not #include return false; beginUpdate(); - CommandProcessor(SynEditorCommand::ecChar,'<'); + commandProcessor(SynEditorCommand::ecChar,'<'); BufferCoord oldCaret = caretXY(); - CommandProcessor(SynEditorCommand::ecChar,'>'); + commandProcessor(SynEditorCommand::ecChar,'>'); setCaretXY(oldCaret); endUpdate(); return true; @@ -1753,7 +1753,7 @@ void Editor::showCompletion(bool autoComplete) bool tokenFinished; SynHighlighterTokenType tokenType; BufferCoord pBeginPos, pEndPos; - if (GetHighlighterAttriAtRowCol( + if (getHighlighterAttriAtRowCol( BufferCoord{caretX() - 1, caretY()}, s, tokenFinished,tokenType, attr)) { if (tokenType == SynHighlighterTokenType::PreprocessDirective) {//Preprocessor @@ -1777,7 +1777,7 @@ void Editor::showCompletion(bool autoComplete) } // Position it at the top of the next line - QPoint p = RowColumnToPixels(displayXY()); + QPoint p = rowColumnToPixels(displayXY()); p+=QPoint(0,textHeight()+2); mCompletionPopup->move(mapToGlobal(p)); @@ -1830,7 +1830,7 @@ void Editor::showHeaderCompletion(bool autoComplete) return; // Position it at the top of the next line - QPoint p = RowColumnToPixels(displayXY()); + QPoint p = rowColumnToPixels(displayXY()); p.setY(p.y() + textHeight() + 2); mHeaderCompletionPopup->move(mapToGlobal(p)); @@ -1931,8 +1931,8 @@ void Editor::completionInsert(bool appendFunc) QString funcAddOn = ""; // delete the part of the word that's already been typed ... - BufferCoord p = WordEnd(); - setBlockBegin(WordStart()); + BufferCoord p = wordEnd(); + setBlockBegin(wordStart()); setBlockEnd(p); // if we are inserting a function, @@ -2125,7 +2125,7 @@ bool Editor::onHeaderCompletionKeyPressed(QKeyEvent *event) Editor::TipType Editor::getTipType(QPoint point, BufferCoord& pos) { // Only allow in the text area... - if (PointToCharLine(point, pos)) { + if (pointToCharLine(point, pos)) { if (!pMainWindow->debugger()->executing() && getSyntaxIssueAtPosition(pos)) { return TipType::Error; @@ -2135,12 +2135,12 @@ Editor::TipType Editor::getTipType(QPoint point, BufferCoord& pos) QString s; // Only allow hand tips in highlighted areas - if (GetHighlighterAttriAtRowCol(pos,s,attr)) { + if (getHighlighterAttriAtRowCol(pos,s,attr)) { // Only allow Identifiers, Preprocessor directives, and selection if (attr) { if (selAvail()) { // do not allow when dragging selection - if (IsPointInSelection(pos)) + if (isPointInSelection(pos)) return TipType::Selection; } else if (attr->name() == SYNS_AttrIdentifier) return TipType::Identifier; diff --git a/RedPandaIDE/mainwindow.cpp b/RedPandaIDE/mainwindow.cpp index 6927347c..3959d8c9 100644 --- a/RedPandaIDE/mainwindow.cpp +++ b/RedPandaIDE/mainwindow.cpp @@ -1735,7 +1735,7 @@ void MainWindow::onEditorContextMenu(const QPoint &pos) QMenu menu(this); BufferCoord p; mEditorContextMenuPos = pos; - if (editor->GetPositionOfMouse(p)) { + if (editor->getPositionOfMouse(p)) { //mouse on editing area menu.addAction(ui->actionCompile_Run); menu.addAction(ui->actionDebug); @@ -1769,7 +1769,7 @@ void MainWindow::onEditorContextMenu(const QPoint &pos) } else { //mouse on gutter int line; - if (!editor->GetLineOfMouse(line)) + if (!editor->getLineOfMouse(line)) line=-1; menu.addAction(ui->actionToggle_Breakpoint); menu.addAction(ui->actionBreakpoint_property); @@ -2657,7 +2657,7 @@ void MainWindow::on_actionAdd_Watch_triggered() if (e->selAvail()) { s = e->selText(); } else { - s = e->WordAtCursor(); + s = e->wordAtCursor(); } } bool isOk; @@ -2757,7 +2757,7 @@ void MainWindow::on_actionFind_triggered() if (mSearchDialog==nullptr) { mSearchDialog = new SearchDialog(this); } - QString s = e->WordAtCursor(); + QString s = e->wordAtCursor(); mSearchDialog->find(s); } @@ -2768,7 +2768,7 @@ void MainWindow::on_actionFind_in_files_triggered() } Editor *e = mEditorList->getEditor(); if (e) { - QString s = e->WordAtCursor(); + QString s = e->wordAtCursor(); mSearchDialog->findInFiles(s); } else { mSearchDialog->findInFiles(""); @@ -2783,7 +2783,7 @@ void MainWindow::on_actionReplace_triggered() if (mSearchDialog==nullptr) { mSearchDialog = new SearchDialog(this); } - QString s = e->WordAtCursor(); + QString s = e->wordAtCursor(); mSearchDialog->replace(s,s); } @@ -2977,7 +2977,7 @@ void MainWindow::on_actionToggle_Breakpoint_triggered() { Editor * editor = mEditorList->getEditor(); int line; - if (editor && editor->PointToLine(mEditorContextMenuPos,line)) + if (editor && editor->pointToLine(mEditorContextMenuPos,line)) editor->toggleBreakpoint(line); } @@ -3001,7 +3001,7 @@ void MainWindow::on_actionBreakpoint_property_triggered() { Editor * editor = mEditorList->getEditor(); int line; - if (editor && editor->PointToLine(mEditorContextMenuPos,line)) { + if (editor && editor->pointToLine(mEditorContextMenuPos,line)) { if (editor->hasBreakpoint(line)) editor->modifyBreakpointProperty(line); } @@ -3013,7 +3013,7 @@ void MainWindow::on_actionGoto_Declaration_triggered() { Editor * editor = mEditorList->getEditor(); BufferCoord pos; - if (editor && editor->PointToCharLine(mEditorContextMenuPos,pos)) { + if (editor && editor->pointToCharLine(mEditorContextMenuPos,pos)) { editor->gotoDeclaration(pos); } } @@ -3023,7 +3023,7 @@ void MainWindow::on_actionGoto_Definition_triggered() { Editor * editor = mEditorList->getEditor(); BufferCoord pos; - if (editor && editor->PointToCharLine(mEditorContextMenuPos,pos)) { + if (editor && editor->pointToCharLine(mEditorContextMenuPos,pos)) { editor->gotoDefinition(pos); } } @@ -3033,7 +3033,7 @@ void MainWindow::on_actionFind_references_triggered() { Editor * editor = mEditorList->getEditor(); BufferCoord pos; - if (editor && editor->PointToCharLine(mEditorContextMenuPos,pos)) { + if (editor && editor->pointToCharLine(mEditorContextMenuPos,pos)) { CppRefacter refactor; refactor.findOccurence(editor,pos); ui->tabMessages->setCurrentWidget(ui->tabSearch); diff --git a/RedPandaIDE/qsynedit/SynEdit.cpp b/RedPandaIDE/qsynedit/SynEdit.cpp index ed7de843..ec778f1a 100644 --- a/RedPandaIDE/qsynedit/SynEdit.cpp +++ b/RedPandaIDE/qsynedit/SynEdit.cpp @@ -326,14 +326,14 @@ int SynEdit::maxScrollWidth() const return std::max(mLines->lengthOfLongestLine()-mCharsInWindow+1, 1); } -bool SynEdit::GetHighlighterAttriAtRowCol(const BufferCoord &XY, QString &Token, PSynHighlighterAttribute &Attri) +bool SynEdit::getHighlighterAttriAtRowCol(const BufferCoord &XY, QString &Token, PSynHighlighterAttribute &Attri) { SynHighlighterTokenType TmpType; int TmpKind, TmpStart; - return GetHighlighterAttriAtRowColEx(XY, Token, TmpType, TmpKind,TmpStart, Attri); + return getHighlighterAttriAtRowColEx(XY, Token, TmpType, TmpKind,TmpStart, Attri); } -bool SynEdit::GetHighlighterAttriAtRowCol(const BufferCoord &XY, QString &Token, bool &tokenFinished, SynHighlighterTokenType &TokenType, PSynHighlighterAttribute &Attri) +bool SynEdit::getHighlighterAttriAtRowCol(const BufferCoord &XY, QString &Token, bool &tokenFinished, SynHighlighterTokenType &TokenType, PSynHighlighterAttribute &Attri) { int PosX, PosY, endPos, Start; QString Line; @@ -374,7 +374,7 @@ bool SynEdit::GetHighlighterAttriAtRowCol(const BufferCoord &XY, QString &Token, return false; } -bool SynEdit::GetHighlighterAttriAtRowColEx(const BufferCoord &XY, QString &Token, SynHighlighterTokenType &TokenType, SynTokenKind &TokenKind, int &Start, PSynHighlighterAttribute &Attri) +bool SynEdit::getHighlighterAttriAtRowColEx(const BufferCoord &XY, QString &Token, SynHighlighterTokenType &TokenType, SynTokenKind &TokenKind, int &Start, PSynHighlighterAttribute &Attri) { int PosX, PosY, endPos; QString Line; @@ -468,7 +468,7 @@ BufferCoord SynEdit::getMatchingBracketEx(BufferCoord APoint) p.Char = PosX; p.Line = PosY; if ((Test == BracketInc) || (Test == BracketDec)) { - if (GetHighlighterAttriAtRowCol(p, vDummy, attr)) + if (getHighlighterAttriAtRowCol(p, vDummy, attr)) isCommentOrStringOrChar = (attr == mHighlighter->stringAttribute()) || (attr == mHighlighter->commentAttribute()) || @@ -503,7 +503,7 @@ BufferCoord SynEdit::getMatchingBracketEx(BufferCoord APoint) p.Char = PosX; p.Line = PosY; if ((Test == BracketInc) || (Test == BracketDec)) { - if (GetHighlighterAttriAtRowCol(p, vDummy, attr)) + if (getHighlighterAttriAtRowCol(p, vDummy, attr)) isCommentOrStringOrChar = (attr == mHighlighter->stringAttribute()) || (attr == mHighlighter->commentAttribute()) || @@ -537,21 +537,21 @@ BufferCoord SynEdit::getMatchingBracketEx(BufferCoord APoint) return BufferCoord{0,0}; } -bool SynEdit::GetPositionOfMouse(BufferCoord &aPos) +bool SynEdit::getPositionOfMouse(BufferCoord &aPos) { QPoint point = QCursor::pos(); point = mapFromGlobal(point); - return PointToCharLine(point,aPos); + return pointToCharLine(point,aPos); } -bool SynEdit::GetLineOfMouse(int &line) +bool SynEdit::getLineOfMouse(int &line) { QPoint point = QCursor::pos(); point = mapFromGlobal(point); - return PointToLine(point,line); + return pointToLine(point,line); } -bool SynEdit::PointToCharLine(const QPoint &point, BufferCoord &coord) +bool SynEdit::pointToCharLine(const QPoint &point, BufferCoord &coord) { // Make sure it fits within the SynEdit bounds (and on the gutter) if ((point.x() < gutterWidth() + clientLeft()) @@ -565,7 +565,7 @@ bool SynEdit::PointToCharLine(const QPoint &point, BufferCoord &coord) return true; } -bool SynEdit::PointToLine(const QPoint &point, int &line) +bool SynEdit::pointToLine(const QPoint &point, int &line) { // Make sure it fits within the SynEdit bounds if ((point.x() < clientLeft()) @@ -661,7 +661,7 @@ DisplayCoord SynEdit::pixelsToRowColumn(int aX, int aY) const }; } -QPoint SynEdit::RowColumnToPixels(const DisplayCoord &coord) const +QPoint SynEdit::rowColumnToPixels(const DisplayCoord &coord) const { QPoint result; result.setX((coord.Column - 1) * mCharWidth + textOffset()); @@ -705,6 +705,84 @@ BufferCoord SynEdit::displayToBufferPos(const DisplayCoord &p) const return Result; } +NormalizedBufferCoord SynEdit::moveBufferPos(const BufferCoord &p, int delta) const +{ + return normalizeBufferPos(p.Char+delta,p.Line); + + +} + +NormalizedBufferCoord SynEdit::moveBufferPos(const NormalizedBufferCoord &p, int delta) const +{ + return normalizeBufferPos(p.Char+delta,p.Line); +} + +NormalizedBufferCoord SynEdit::normalizeBufferPos(const BufferCoord &p) const +{ + return normalizeBufferPos(p.Char,p.Line); +} + +NormalizedBufferCoord SynEdit::normalizeBufferPos(int aChar, int aLine) const +{ + if (mLines->count()==0) { + return NormalizedBufferCoord{0,0}; + } + int line = aLine-1; + int lineCount = mLines->count(); + if (line>=lineCount) { + return NormalizedBufferCoord{ + mLines->getString(lineCount-1).length()+1 + ,lineCount}; + } + if (line<0) { + return NormalizedBufferCoord{0,0}; + } + if (aChar<1) { + while (true) { + line--; + if (line < 0) { + return NormalizedBufferCoord{0,0}; + } + QString s =mLines->getString(line); + int len = s.length(); + aChar+=len+1; + if (aChar>=1) { + return NormalizedBufferCoord{aChar,line+1}; + } + } + } + while (true) { + QString s =mLines->getString(line); + int len = s.length(); + if (aChar<=len+1 ) { + return NormalizedBufferCoord{aChar,line+1}; + } + if (line == lineCount-1) { + return NormalizedBufferCoord{1,lineCount+1}; + } + aChar -= len+1; + line++; + } +} + +QChar SynEdit::charAtNormalizedBufferPos(const NormalizedBufferCoord &p) const +{ + if (p.Line < 1) { + return QChar('\0'); + } + if (p.Line > mLines->count()) { + return QChar('\0'); + } + if (p.Char == 0) { + return QChar('\n'); + } + QString s = mLines->getString(p.Line-1); + if (p.Char > p.Line+1) { + return QChar('\n'); + } + return s[p.Char-1]; +} + int SynEdit::leftSpaces(const QString &line) const { int result = 0; @@ -971,12 +1049,12 @@ bool SynEdit::selAvail() const ((mBlockBegin.Line != mBlockEnd.Line) && (mActiveSelectionMode != SynSelectionMode::smColumn)); } -QString SynEdit::WordAtCursor() +QString SynEdit::wordAtCursor() { - return WordAtRowCol(caretXY()); + return wordAtRowCol(caretXY()); } -QString SynEdit::WordAtRowCol(const BufferCoord &XY) +QString SynEdit::wordAtRowCol(const BufferCoord &XY) { if ((XY.Line >= 1) && (XY.Line <= mLines->count())) { QString line = mLines->getString(XY.Line - 1); @@ -1056,7 +1134,7 @@ void SynEdit::clearUndo() mRedoList->Clear(); } -BufferCoord SynEdit::GetPreviousLeftBracket(int x, int y) +BufferCoord SynEdit::getPreviousLeftBracket(int x, int y) { QChar Test; QString vDummy; @@ -1088,7 +1166,7 @@ BufferCoord SynEdit::GetPreviousLeftBracket(int x, int y) p.Char = PosX; p.Line = PosY; if (Test=='{' || Test == '}') { - if (GetHighlighterAttriAtRowCol(p, vDummy, attr)) { + if (getHighlighterAttriAtRowCol(p, vDummy, attr)) { isCommentOrStringOrChar = (attr == mHighlighter->stringAttribute()) || (attr == mHighlighter->commentAttribute()) || @@ -1143,7 +1221,7 @@ void SynEdit::hideCaret() } } -bool SynEdit::IsPointInSelection(const BufferCoord &Value) const +bool SynEdit::isPointInSelection(const BufferCoord &Value) const { BufferCoord ptBegin = blockBegin(); BufferCoord ptEnd = blockEnd(); @@ -1165,12 +1243,12 @@ bool SynEdit::IsPointInSelection(const BufferCoord &Value) const return false; } -BufferCoord SynEdit::NextWordPos() +BufferCoord SynEdit::nextWordPos() { - return NextWordPosEx(caretXY()); + return nextWordPosEx(caretXY()); } -BufferCoord SynEdit::NextWordPosEx(const BufferCoord &XY) +BufferCoord SynEdit::nextWordPosEx(const BufferCoord &XY) { int CX = XY.Char; int CY = XY.Line; @@ -1211,12 +1289,12 @@ BufferCoord SynEdit::NextWordPosEx(const BufferCoord &XY) return BufferCoord{CX,CY}; } -BufferCoord SynEdit::WordStart() +BufferCoord SynEdit::wordStart() { - return WordStartEx(caretXY()); + return wordStartEx(caretXY()); } -BufferCoord SynEdit::WordStartEx(const BufferCoord &XY) +BufferCoord SynEdit::wordStartEx(const BufferCoord &XY) { int CX = XY.Char; int CY = XY.Line; @@ -1232,12 +1310,12 @@ BufferCoord SynEdit::WordStartEx(const BufferCoord &XY) return BufferCoord{CX,CY}; } -BufferCoord SynEdit::WordEnd() +BufferCoord SynEdit::wordEnd() { - return WordEndEx(caretXY()); + return wordEndEx(caretXY()); } -BufferCoord SynEdit::WordEndEx(const BufferCoord &XY) +BufferCoord SynEdit::wordEndEx(const BufferCoord &XY) { int CX = XY.Char; int CY = XY.Line; @@ -1254,12 +1332,12 @@ BufferCoord SynEdit::WordEndEx(const BufferCoord &XY) return BufferCoord{CX,CY}; } -BufferCoord SynEdit::PrevWordPos() +BufferCoord SynEdit::prevWordPos() { - return PrevWordPosEx(caretXY()); + return prevWordPosEx(caretXY()); } -BufferCoord SynEdit::PrevWordPosEx(const BufferCoord &XY) +BufferCoord SynEdit::prevWordPosEx(const BufferCoord &XY) { int CX = XY.Char; int CY = XY.Line; @@ -1295,12 +1373,12 @@ BufferCoord SynEdit::PrevWordPosEx(const BufferCoord &XY) return BufferCoord{CX,CY}; } -void SynEdit::SetSelWord() +void SynEdit::setSelWord() { - SetWordBlock(caretXY()); + setWordBlock(caretXY()); } -void SynEdit::SetWordBlock(BufferCoord Value) +void SynEdit::setWordBlock(BufferCoord Value) { // if (mOptions.testFlag(eoScrollPastEol)) // Value.Char = @@ -1314,8 +1392,8 @@ void SynEdit::SetWordBlock(BufferCoord Value) return; } - BufferCoord v_WordStart = WordStartEx(Value); - BufferCoord v_WordEnd = WordEndEx(Value); + BufferCoord v_WordStart = wordStartEx(Value); + BufferCoord v_WordEnd = wordEndEx(Value); if ((v_WordStart.Line == v_WordEnd.Line) && (v_WordStart.Char < v_WordEnd.Char)) setCaretAndSelection(v_WordEnd, v_WordStart, v_WordEnd); } @@ -1488,7 +1566,7 @@ void SynEdit::doDeleteLastChar() }); // try if (selAvail()) { - SetSelectedTextEmpty(); + setSelectedTextEmpty(); return; } QString Temp = lineText(); @@ -1575,7 +1653,7 @@ void SynEdit::doDeleteLastChar() helper = Temp.mid(newCaretX - 1, mCaretX - newCaretX); Temp.remove(newCaretX-1,mCaretX - newCaretX); // } - ProperSetLine(mCaretY - 1, Temp); + properSetLine(mCaretY - 1, Temp); setCaretX(newCaretX); updateLastCaretX(); mStateFlags.setFlag(SynStateFlag::sfCaretChanged); @@ -1588,7 +1666,7 @@ void SynEdit::doDeleteLastChar() // vTabTrim := CharIndex2CaretPos(CaretX, TabWidth, Temp); helper = Temp[mCaretX-1]; Temp.remove(mCaretX-1,1); - ProperSetLine(mCaretY - 1, Temp); + properSetLine(mCaretY - 1, Temp); } } if ((Caret.Char != mCaretX) || (Caret.Line != mCaretY)) { @@ -1604,7 +1682,7 @@ void SynEdit::doDeleteCurrentChar() if (!mReadOnly) { doOnPaintTransient(SynTransientType::ttBefore); if (selAvail()) - SetSelectedTextEmpty(); + setSelectedTextEmpty(); else { // Call UpdateLastCaretX. Even though the caret doesn't move, the // current caret position should "stick" whenever text is modified. @@ -1617,11 +1695,11 @@ void SynEdit::doDeleteCurrentChar() Caret.Char = mCaretX + 1; Caret.Line = mCaretY; Temp.remove(mCaretX-1, 1); - ProperSetLine(mCaretY - 1, Temp); + properSetLine(mCaretY - 1, Temp); } else { // join line with the line after if (mCaretY < mLines->count()) { - ProperSetLine(mCaretY - 1, Temp + mLines->getString(mCaretY)); + properSetLine(mCaretY - 1, Temp + mLines->getString(mCaretY)); Caret.Char = 1; Caret.Line = mCaretY + 1; helper = lineBreak(); @@ -1646,32 +1724,32 @@ void SynEdit::doDeleteWord() if (mReadOnly) return; - BufferCoord start = WordStart(); - BufferCoord end = WordEnd(); - DeleteFromTo(start,end); + BufferCoord start = wordStart(); + BufferCoord end = wordEnd(); + deleteFromTo(start,end); } void SynEdit::doDeleteToEOL() { if (mReadOnly) return; - DeleteFromTo(caretXY(),BufferCoord{lineText().length()+1,mCaretY}); + deleteFromTo(caretXY(),BufferCoord{lineText().length()+1,mCaretY}); } void SynEdit::doDeleteLastWord() { if (mReadOnly) return; - BufferCoord start = PrevWordPos(); - BufferCoord end = WordEndEx(start); - DeleteFromTo(start,end); + BufferCoord start = prevWordPos(); + BufferCoord end = wordEndEx(start); + deleteFromTo(start,end); } void SynEdit::doDeleteFromBOL() { if (mReadOnly) return; - DeleteFromTo(BufferCoord{1,mCaretY},caretXY()); + deleteFromTo(BufferCoord{1,mCaretY},caretXY()); } void SynEdit::doDeleteLine() @@ -1833,7 +1911,7 @@ void SynEdit::insertLine(bool moveCaret) helper = selText(); BufferCoord iUndoBegin = mBlockBegin; BufferCoord iUndoEnd = mBlockEnd; - SetSelTextPrimitive(""); + setSelTextPrimitive(""); mUndoList->AddChange(SynChangeReason::crDelete, iUndoBegin, iUndoEnd, helper, mActiveSelectionMode); } @@ -1863,11 +1941,11 @@ void SynEdit::insertLine(bool moveCaret) int indentSpacesOfLeftLineText = leftSpaces(leftLineText); int indentSpaces = indentSpacesOfLeftLineText; bool notInComment=true; - ProperSetLine(mCaretY-1,leftLineText); + properSetLine(mCaretY-1,leftLineText); if (mOptions.testFlag(eoAutoIndent)) { rightLineText=TrimLeft(rightLineText); } - if (GetHighlighterAttriAtRowCol(BufferCoord{leftLineText.length(), mCaretY}, + if (getHighlighterAttriAtRowCol(BufferCoord{leftLineText.length(), mCaretY}, leftLineText, Attr)) { notInComment = (Attr != mHighlighter->commentAttribute()); } @@ -1917,7 +1995,7 @@ void SynEdit::insertLine(bool moveCaret) QString Temp4=GetLeftSpacing(SpaceCount2,true); if (SpaceCount2 > 0) { } - if (mOptions.testFlag(eoAddIndent) && GetHighlighterAttriAtRowCol(BufferCoord{Temp.length(), mCaretY}, + if (mOptions.testFlag(eoAddIndent) && getHighlighterAttriAtRowCol(BufferCoord{Temp.length(), mCaretY}, Temp, Attr)) { // only add indent to source files if (Attr != mHighlighter->commentAttribute()) { // and outside of comments Temp = Temp.trimmed(); @@ -1962,7 +2040,7 @@ void SynEdit::insertLine(bool moveCaret) void SynEdit::doTabKey() { // Provide Visual Studio like block indenting - if (mOptions.testFlag(eoTabIndent) && CanDoBlockIndent()) { + if (mOptions.testFlag(eoTabIndent) && canDoBlockIndent()) { doBlockIndent(); return; } @@ -1978,7 +2056,7 @@ void SynEdit::doTabKey() mBlockEnd, selText(), mActiveSelectionMode); - SetSelTextPrimitive(""); + setSelTextPrimitive(""); } BufferCoord StartOfBlock = caretXY(); QString Spaces; @@ -1993,7 +2071,7 @@ void SynEdit::doTabKey() NewCaretX = mCaretX + 1; } - SetSelTextPrimitive(Spaces); + setSelTextPrimitive(Spaces); // Undo is already handled in SetSelText when SelectionMode is Column if (mActiveSelectionMode != SynSelectionMode::smColumn) { mUndoList->AddChange(SynChangeReason::crInsert, StartOfBlock, @@ -2010,7 +2088,7 @@ void SynEdit::doTabKey() void SynEdit::doShiftTabKey() { // Provide Visual Studio like block indenting - if (mOptions.testFlag(eoTabIndent) && CanDoBlockIndent()) { + if (mOptions.testFlag(eoTabIndent) && canDoBlockIndent()) { doBlockUnindent(); return; } @@ -2050,7 +2128,7 @@ void SynEdit::doShiftTabKey() setBlockEnd(caretXY()); QString OldSelText = selText(); - SetSelTextPrimitive(""); + setSelTextPrimitive(""); mUndoList->AddChange( SynChangeReason::crSilentDelete, BufferCoord{NewX, mCaretY}, @@ -2060,7 +2138,7 @@ void SynEdit::doShiftTabKey() } -bool SynEdit::CanDoBlockIndent() +bool SynEdit::canDoBlockIndent() { BufferCoord BB; BufferCoord BE; @@ -2304,7 +2382,7 @@ void SynEdit::doAddChar(QChar AChar) QString temp = mLines->getString(oldCaretY-1).mid(0,oldCaretX-1); // and the first nonblank char is this new } if (temp.trimmed().isEmpty()) { - BufferCoord MatchBracketPos = GetPreviousLeftBracket(oldCaretX, oldCaretY); + BufferCoord MatchBracketPos = getPreviousLeftBracket(oldCaretX, oldCaretY); if (MatchBracketPos.Line > 0) { int i = 0; QString matchline = mLines->getString(MatchBracketPos.Line-1); @@ -2418,7 +2496,7 @@ void SynEdit::doPasteFromClipboard() BufferCoord vEndOfBlock = blockEnd(); mBlockBegin = vStartOfBlock; mBlockEnd = vEndOfBlock; - SetSelTextPrimitive(clipboard->text()); + setSelTextPrimitive(clipboard->text()); if (mActiveSelectionMode != SynSelectionMode::smColumn) { mUndoList->AddChange( SynChangeReason::crPaste, @@ -2583,7 +2661,7 @@ void SynEdit::insertBlock(const BufferCoord &BB, const BufferCoord &BE, const QS { setCaretAndSelection(BB, BB, BE); setActiveSelectionMode(SynSelectionMode::smColumn); - SetSelTextPrimitiveEx(SynSelectionMode::smColumn, ChangeStr, AddToUndoList); + setSelTextPrimitiveEx(SynSelectionMode::smColumn, ChangeStr, AddToUndoList); setStatusChanged(SynStatusChange::scSelection); } @@ -2655,7 +2733,7 @@ void SynEdit::updateCaret() { mStateFlags.setFlag(SynStateFlag::sfCaretChanged,false); DisplayCoord coord = displayXY(); - QPoint caretPos = RowColumnToPixels(coord); + QPoint caretPos = rowColumnToPixels(coord); int caretWidth=mCharWidth; //qDebug()<<"caret"<count() && mCaretX <= mLines->getString(mCaretY-1).length()) { @@ -3282,7 +3360,7 @@ void SynEdit::onSizeOrFontChanged(bool bFont) void SynEdit::onChanged() { - emit Changed(); + emit changed(); } void SynEdit::onScrolled(int) @@ -3610,7 +3688,7 @@ void SynEdit::doUndoItem() Item->changeStartPos(), Item->changeEndPos()); QString TmpStr = selText(); - SetSelTextPrimitiveEx( + setSelTextPrimitiveEx( Item->changeSelMode(), Item->changeStr(), false); @@ -3648,7 +3726,7 @@ void SynEdit::doUndoItem() mLines->add(""); } setCaretXY(TmpPos); - SetSelTextPrimitiveEx( + setSelTextPrimitiveEx( Item->changeSelMode(), Item->changeStr(), false); @@ -3683,7 +3761,7 @@ void SynEdit::doUndoItem() QString TmpStr = mLines->getString(mCaretY - 1); if ( (mCaretX > TmpStr.length() + 1) && (leftSpaces(Item->changeStr()) == 0)) TmpStr = TmpStr + QString(mCaretX - 1 - TmpStr.length(), ' '); - ProperSetLine(mCaretY - 1, TmpStr + Item->changeStr()); + properSetLine(mCaretY - 1, TmpStr + Item->changeStr()); mLines->deleteAt(mCaretY); doLinesDeleted(mCaretY, 1); } @@ -3852,7 +3930,7 @@ void SynEdit::doRedoItem() Item->changeStartPos(), Item->changeStartPos(), Item->changeStartPos()); - SetSelTextPrimitiveEx(Item->changeSelMode(), Item->changeStr(), false); + setSelTextPrimitiveEx(Item->changeSelMode(), Item->changeStr(), false); internalSetCaretXY(Item->changeEndPos()); mUndoList->AddChange(Item->changeReason(), Item->changeStartPos(), @@ -3870,7 +3948,7 @@ void SynEdit::doRedoItem() setCaretAndSelection(Item->changeStartPos(), Item->changeStartPos(), Item->changeEndPos()); QString TempString = selText(); - SetSelTextPrimitiveEx(Item->changeSelMode(), + setSelTextPrimitiveEx(Item->changeSelMode(), Item->changeStr(),false); mUndoList->AddChange(Item->changeReason(), Item->changeStartPos(), Item->changeEndPos(), TempString, Item->changeSelMode()); @@ -3882,7 +3960,7 @@ void SynEdit::doRedoItem() setCaretAndSelection(Item->changeStartPos(), Item->changeStartPos(), Item->changeEndPos()); QString TempString = selText(); - SetSelTextPrimitiveEx(Item->changeSelMode(), Item->changeStr(),false); + setSelTextPrimitiveEx(Item->changeSelMode(), Item->changeStr(),false); mUndoList->AddChange(Item->changeReason(), Item->changeStartPos(), Item->changeEndPos(),TempString, Item->changeSelMode()); @@ -3892,7 +3970,7 @@ void SynEdit::doRedoItem() case SynChangeReason::crLineBreak: { BufferCoord CaretPt = Item->changeStartPos(); setCaretAndSelection(CaretPt, CaretPt, CaretPt); - CommandProcessor(SynEditorCommand::ecLineBreak); + commandProcessor(SynEditorCommand::ecLineBreak); break; } case SynChangeReason::crIndent: @@ -4066,12 +4144,12 @@ void SynEdit::setUseCodeFolding(bool value) } } -SynEditCodeFolding &SynEdit::codeFolding() +SynEditCodeFolding &SynEdit::codeFolding() const { return mCodeFolding; } -QString SynEdit::lineText() +QString SynEdit::lineText() const { if (mCaretY >= 1 && mCaretY <= mLines->count()) return mLines->getString(mCaretY - 1); @@ -4118,7 +4196,7 @@ bool SynEdit::empty() return mLines->empty(); } -void SynEdit::CommandProcessor(SynEditorCommand Command, QChar AChar, void *pData) +void SynEdit::commandProcessor(SynEditorCommand Command, QChar AChar, void *pData) { // first the program event handler gets a chance to process the command onProcessCommand(Command, AChar, pData); @@ -4127,7 +4205,7 @@ void SynEdit::CommandProcessor(SynEditorCommand Command, QChar AChar, void *pDat onCommandProcessed(Command, AChar, pData); } -void SynEdit::MoveCaretHorz(int DX, bool isSelection) +void SynEdit::moveCaretHorz(int DX, bool isSelection) { BufferCoord ptO = caretXY(); BufferCoord ptDst = ptO; @@ -4151,10 +4229,10 @@ void SynEdit::MoveCaretHorz(int DX, bool isSelection) ptDst.Char = std::min(ptDst.Char, nLineLen + 1); } // set caret and block begin / end - MoveCaretAndSelection(mBlockBegin, ptDst, isSelection); + moveCaretAndSelection(mBlockBegin, ptDst, isSelection); } -void SynEdit::MoveCaretVert(int DY, bool isSelection) +void SynEdit::moveCaretVert(int DY, bool isSelection) { DisplayCoord ptO = displayXY(); DisplayCoord ptDst = ptO; @@ -4178,7 +4256,7 @@ void SynEdit::MoveCaretVert(int DY, bool isSelection) // set caret and block begin / end incPaintLock(); - MoveCaretAndSelection(mBlockBegin, vDstLineChar, isSelection); + moveCaretAndSelection(mBlockBegin, vDstLineChar, isSelection); decPaintLock(); // Set fMBCSStepAside and restore fLastCaretX after moving caret, since @@ -4188,7 +4266,7 @@ void SynEdit::MoveCaretVert(int DY, bool isSelection) mLastCaretColumn = SaveLastCaretX; } -void SynEdit::MoveCaretAndSelection(const BufferCoord &ptBefore, const BufferCoord &ptAfter, bool isSelection) +void SynEdit::moveCaretAndSelection(const BufferCoord &ptBefore, const BufferCoord &ptAfter, bool isSelection) { if (mOptions.testFlag(SynEditorOption::eoGroupUndo) && mUndoList->CanUndo()) mUndoList->AddGroupBreak(); @@ -4204,7 +4282,7 @@ void SynEdit::MoveCaretAndSelection(const BufferCoord &ptBefore, const BufferCoo decPaintLock(); } -void SynEdit::MoveCaretToLineStart(bool isSelection) +void SynEdit::moveCaretToLineStart(bool isSelection) { int newX; // home key enhancement @@ -4225,10 +4303,10 @@ void SynEdit::MoveCaretToLineStart(bool isSelection) newX = 1; } else newX = 1; - MoveCaretAndSelection(caretXY(), BufferCoord{newX, mCaretY}, isSelection); + moveCaretAndSelection(caretXY(), BufferCoord{newX, mCaretY}, isSelection); } -void SynEdit::MoveCaretToLineEnd(bool isSelection) +void SynEdit::moveCaretToLineEnd(bool isSelection) { int vNewX; if (mOptions.testFlag(SynEditorOption::eoEnhanceEndKey)) { @@ -4246,15 +4324,15 @@ void SynEdit::MoveCaretToLineEnd(bool isSelection) } else vNewX = lineText().length() + 1; - MoveCaretAndSelection(caretXY(), BufferCoord{vNewX, mCaretY}, isSelection); + moveCaretAndSelection(caretXY(), BufferCoord{vNewX, mCaretY}, isSelection); } -void SynEdit::SetSelectedTextEmpty() +void SynEdit::setSelectedTextEmpty() { BufferCoord vUndoBegin = mBlockBegin; BufferCoord vUndoEnd = mBlockEnd; QString vSelText = selText(); - SetSelTextPrimitive(""); + setSelTextPrimitive(""); if ((vUndoBegin.Line < vUndoEnd.Line) || ( (vUndoBegin.Line == vUndoEnd.Line) && (vUndoBegin.Char < vUndoEnd.Char))) { mUndoList->AddChange(SynChangeReason::crDelete, vUndoBegin, vUndoEnd, vSelText, @@ -4265,12 +4343,12 @@ void SynEdit::SetSelectedTextEmpty() } } -void SynEdit::SetSelTextPrimitive(const QString &aValue) +void SynEdit::setSelTextPrimitive(const QString &aValue) { - SetSelTextPrimitiveEx(mActiveSelectionMode, aValue, true); + setSelTextPrimitiveEx(mActiveSelectionMode, aValue, true); } -void SynEdit::SetSelTextPrimitiveEx(SynSelectionMode PasteMode, const QString &Value, bool AddToUndoList) +void SynEdit::setSelTextPrimitiveEx(SynSelectionMode PasteMode, const QString &Value, bool AddToUndoList) { incPaintLock(); mLines->beginUpdate(); @@ -4281,11 +4359,11 @@ void SynEdit::SetSelTextPrimitiveEx(SynSelectionMode PasteMode, const QString &V BufferCoord BB = blockBegin(); BufferCoord BE = blockEnd(); if (selAvail()) { - DeleteSelection(BB,BE); + deleteSelection(BB,BE); internalSetCaretXY(BB); } if (!Value.isEmpty()) { - InsertText(Value,PasteMode,AddToUndoList); + insertText(Value,PasteMode,AddToUndoList); } if (mCaretY < 1) internalSetCaretY(1); @@ -4307,7 +4385,7 @@ void SynEdit::setSelText(const QString &Value) BufferCoord EndOfBlock = blockEnd(); mBlockBegin = StartOfBlock; mBlockEnd = EndOfBlock; - SetSelTextPrimitive(Value); + setSelTextPrimitive(Value); if (!Value.isEmpty() && (mActiveSelectionMode !=SynSelectionMode::smColumn)) mUndoList->AddChange( SynChangeReason::crInsert, @@ -4511,7 +4589,7 @@ void SynEdit::doLinesInserted(int firstLine, int count) // end; } -void SynEdit::ProperSetLine(int ALine, const QString &ALineText) +void SynEdit::properSetLine(int ALine, const QString &ALineText) { if (mOptions.testFlag(eoTrimTrailingSpaces)) mLines->putString(ALine,TrimRight(ALineText)); @@ -4519,7 +4597,7 @@ void SynEdit::ProperSetLine(int ALine, const QString &ALineText) mLines->putString(ALine,ALineText); } -void SynEdit::DeleteSelection(const BufferCoord &BB, const BufferCoord &BE) +void SynEdit::deleteSelection(const BufferCoord &BB, const BufferCoord &BE) { bool UpdateMarks = false; int MarkOffset = 0; @@ -4533,7 +4611,7 @@ void SynEdit::DeleteSelection(const BufferCoord &BB, const BufferCoord &BE) + mLines->getString(BE.Line - 1).mid(BE.Char-1); // Delete all lines in the selection range. mLines->deleteLines(BB.Line, BE.Line - BB.Line); - ProperSetLine(BB.Line-1,TempString); + properSetLine(BB.Line-1,TempString); UpdateMarks = true; internalSetCaretXY(BB); } @@ -4552,7 +4630,7 @@ void SynEdit::DeleteSelection(const BufferCoord &BB, const BufferCoord &BE) int r = columnToChar(i,ColTo-1); QString s = mLines->getString(i); s.remove(l-1,r-l); - ProperSetLine(i,s); + properSetLine(i,s); } // Lines never get deleted completely, so keep caret at end. internalSetCaretXY(BB); @@ -4578,7 +4656,7 @@ void SynEdit::DeleteSelection(const BufferCoord &BB, const BufferCoord &BE) doLinesDeleted(BB.Line, BE.Line - BB.Line + MarkOffset); } -void SynEdit::InsertText(const QString &Value, SynSelectionMode PasteMode,bool AddToUndoList) +void SynEdit::insertText(const QString &Value, SynSelectionMode PasteMode,bool AddToUndoList) { if (Value.isEmpty()) return; @@ -4588,13 +4666,13 @@ void SynEdit::InsertText(const QString &Value, SynSelectionMode PasteMode,bool A int InsertedLines = 0; switch(PasteMode){ case SynSelectionMode::smNormal: - InsertedLines = InsertTextByNormalMode(Value); + InsertedLines = insertTextByNormalMode(Value); break; case SynSelectionMode::smColumn: - InsertedLines = InsertTextByColumnMode(Value,AddToUndoList); + InsertedLines = insertTextByColumnMode(Value,AddToUndoList); break; case SynSelectionMode::smLine: - InsertedLines = InsertTextByLineMode(Value); + InsertedLines = insertTextByLineMode(Value); break; } // We delete selected based on the current selection mode, but paste @@ -4608,7 +4686,7 @@ void SynEdit::InsertText(const QString &Value, SynSelectionMode PasteMode,bool A ensureCursorPosVisible(); } -int SynEdit::InsertTextByNormalMode(const QString &Value) +int SynEdit::insertTextByNormalMode(const QString &Value) { QString sLeftSide; QString sRightSide; @@ -4636,11 +4714,11 @@ int SynEdit::InsertTextByNormalMode(const QString &Value) P = GetEOL(Value,Start); if (PInsertLines(mCaretY, CountLines(Value,P)); } else { Str = sLeftSide + Value + sRightSide; - ProperSetLine(mCaretY - 1, Str); + properSetLine(mCaretY - 1, Str); } // step2: insert remaining lines of Value while (P < Value.length()) { @@ -4663,7 +4741,7 @@ int SynEdit::InsertTextByNormalMode(const QString &Value) Str += sRightSide; } Str = GetLeftSpacing(SpaceCount, true)+Str; - ProperSetLine(mCaretY - 1, Str); + properSetLine(mCaretY - 1, Str); Result++; } bChangeScroll = !mOptions.testFlag(eoScrollPastEol); @@ -4679,7 +4757,7 @@ int SynEdit::InsertTextByNormalMode(const QString &Value) return Result; } -int SynEdit::InsertTextByColumnMode(const QString &Value, bool AddToUndoList) +int SynEdit::insertTextByColumnMode(const QString &Value, bool AddToUndoList) { QString Str; QString TempString; @@ -4719,7 +4797,7 @@ int SynEdit::InsertTextByColumnMode(const QString &Value, bool AddToUndoList) TempString.insert(insertPos-1,Str); } } - ProperSetLine(mCaretY - 1, TempString); + properSetLine(mCaretY - 1, TempString); // Add undo change here from PasteFromClipboard if (AddToUndoList) { mUndoList->AddChange(SynChangeReason::crPaste, BufferCoord{mCaretX, mCaretY}, @@ -4740,7 +4818,7 @@ int SynEdit::InsertTextByColumnMode(const QString &Value, bool AddToUndoList) return Result; } -int SynEdit::InsertTextByLineMode(const QString &Value) +int SynEdit::insertTextByLineMode(const QString &Value) { int Start; int P; @@ -4760,7 +4838,7 @@ int SynEdit::InsertTextByLineMode(const QString &Value) mLines->Insert(mCaretY - 1, ""); Result++; } - ProperSetLine(mCaretY - 1, Str); + properSetLine(mCaretY - 1, Str); mCaretY++; mStatusChanges.setFlag(SynStatusChange::scCaretY); if (PAddChange(SynChangeReason::crSilentDeleteAfterCursor, start, end, helper, SynSelectionMode::smNormal); internalSetCaretXY(start); @@ -4841,36 +4919,36 @@ void SynEdit::ExecuteCommand(SynEditorCommand Command, QChar AChar, void *pData) //horizontal caret movement or selection case SynEditorCommand::ecLeft: case SynEditorCommand::ecSelLeft: - MoveCaretHorz(-1, Command == SynEditorCommand::ecSelLeft); + moveCaretHorz(-1, Command == SynEditorCommand::ecSelLeft); break; case SynEditorCommand::ecRight: case SynEditorCommand::ecSelRight: - MoveCaretHorz(1, Command == SynEditorCommand::ecSelRight); + moveCaretHorz(1, Command == SynEditorCommand::ecSelRight); break; case SynEditorCommand::ecPageLeft: case SynEditorCommand::ecSelPageLeft: - MoveCaretHorz(-mCharsInWindow, Command == SynEditorCommand::ecSelPageLeft); + moveCaretHorz(-mCharsInWindow, Command == SynEditorCommand::ecSelPageLeft); break; case SynEditorCommand::ecPageRight: case SynEditorCommand::ecSelPageRight: - MoveCaretHorz(mCharsInWindow, Command == SynEditorCommand::ecSelPageRight); + moveCaretHorz(mCharsInWindow, Command == SynEditorCommand::ecSelPageRight); break; case SynEditorCommand::ecLineStart: case SynEditorCommand::ecSelLineStart: - MoveCaretToLineStart(Command == SynEditorCommand::ecSelLineStart); + moveCaretToLineStart(Command == SynEditorCommand::ecSelLineStart); break; case SynEditorCommand::ecLineEnd: case SynEditorCommand::ecSelLineEnd: - MoveCaretToLineEnd(Command == SynEditorCommand::ecSelLineEnd); + moveCaretToLineEnd(Command == SynEditorCommand::ecSelLineEnd); break; // vertical caret movement or selection case SynEditorCommand::ecUp: case SynEditorCommand::ecSelUp: - MoveCaretVert(-1, Command == SynEditorCommand::ecSelUp); + moveCaretVert(-1, Command == SynEditorCommand::ecSelUp); break; case SynEditorCommand::ecDown: case SynEditorCommand::ecSelDown: - MoveCaretVert(1, Command == SynEditorCommand::ecSelDown); + moveCaretVert(1, Command == SynEditorCommand::ecSelDown); break; case SynEditorCommand::ecPageUp: case SynEditorCommand::ecSelPageUp: @@ -4888,49 +4966,49 @@ void SynEdit::ExecuteCommand(SynEditorCommand Command, QChar AChar, void *pData) if (Command == SynEditorCommand::ecPageUp || Command == SynEditorCommand::ecSelPageUp) { counter = -counter; } - MoveCaretVert(counter, Command == SynEditorCommand::ecSelPageUp || Command == SynEditorCommand::ecSelPageDown); + moveCaretVert(counter, Command == SynEditorCommand::ecSelPageUp || Command == SynEditorCommand::ecSelPageDown); break; } case SynEditorCommand::ecPageTop: case SynEditorCommand::ecSelPageTop: - MoveCaretVert(mTopLine-mCaretY, Command == SynEditorCommand::ecSelPageTop); + moveCaretVert(mTopLine-mCaretY, Command == SynEditorCommand::ecSelPageTop); break; case SynEditorCommand::ecPageBottom: case SynEditorCommand::ecSelPageBottom: - MoveCaretVert(mTopLine+mLinesInWindow-1-mCaretY, Command == SynEditorCommand::ecSelPageBottom); + moveCaretVert(mTopLine+mLinesInWindow-1-mCaretY, Command == SynEditorCommand::ecSelPageBottom); break; case SynEditorCommand::ecEditorTop: case SynEditorCommand::ecSelEditorTop: - MoveCaretVert(1-mCaretY, Command == SynEditorCommand::ecSelEditorTop); + moveCaretVert(1-mCaretY, Command == SynEditorCommand::ecSelEditorTop); break; case SynEditorCommand::ecEditorBottom: case SynEditorCommand::ecSelEditorBottom: if (!mLines->empty()) - MoveCaretVert(mLines->count()-mCaretY, Command == SynEditorCommand::ecSelEditorBottom); + moveCaretVert(mLines->count()-mCaretY, Command == SynEditorCommand::ecSelEditorBottom); break; // goto special line / column position case SynEditorCommand::ecGotoXY: case SynEditorCommand::ecSelGotoXY: if (pData) - MoveCaretAndSelection(caretXY(), *((BufferCoord *)(pData)), Command == SynEditorCommand::ecSelGotoXY); + moveCaretAndSelection(caretXY(), *((BufferCoord *)(pData)), Command == SynEditorCommand::ecSelGotoXY); break; // word selection case SynEditorCommand::ecWordLeft: case SynEditorCommand::ecSelWordLeft: { - BufferCoord CaretNew = PrevWordPos(); - MoveCaretAndSelection(caretXY(), CaretNew, Command == SynEditorCommand::ecSelWordLeft); + BufferCoord CaretNew = prevWordPos(); + moveCaretAndSelection(caretXY(), CaretNew, Command == SynEditorCommand::ecSelWordLeft); break; } case SynEditorCommand::ecWordRight: case SynEditorCommand::ecSelWordRight: { - BufferCoord CaretNew = NextWordPos(); - MoveCaretAndSelection(caretXY(), CaretNew, Command == SynEditorCommand::ecSelWordRight); + BufferCoord CaretNew = nextWordPos(); + moveCaretAndSelection(caretXY(), CaretNew, Command == SynEditorCommand::ecSelWordRight); break; } case SynEditorCommand::ecSelWord: - SetSelWord(); + setSelWord(); break; case SynEditorCommand::ecSelectAll: doSelectAll(); @@ -5282,7 +5360,7 @@ void SynEdit::paintEvent(QPaintEvent *event) //Get the invalidated rect. QRect rcClip = event->rect(); DisplayCoord coord = displayXY(); - QPoint caretPos = RowColumnToPixels(coord); + QPoint caretPos = rowColumnToPixels(coord); int caretWidth=mCharWidth; if (mCaretY <= mLines->count() && mCaretX <= mLines->getString(mCaretY-1).length()) { caretWidth = charColumns(mLines->getString(mCaretY-1)[mCaretX-1])*mCharWidth; @@ -5393,12 +5471,12 @@ void SynEdit::keyPressEvent(QKeyEvent *event) { SynEditorCommand cmd=TranslateKeyCode(event->key(),event->modifiers()); if (cmd!=SynEditorCommand::ecNone) { - CommandProcessor(cmd,QChar(),nullptr); + commandProcessor(cmd,QChar(),nullptr); event->accept(); } else if (!event->text().isEmpty()) { QChar c = event->text().at(0); if (c=='\t' || c.isPrint()) { - CommandProcessor(SynEditorCommand::ecChar,c,nullptr); + commandProcessor(SynEditorCommand::ecChar,c,nullptr); event->accept(); } } @@ -5424,7 +5502,7 @@ void SynEdit::mousePressEvent(QMouseEvent *event) if (button == Qt::RightButton) { if (mOptions.testFlag(eoRightMouseMovesCursor) && - ( (selAvail() && ! IsPointInSelection(displayToBufferPos(pixelsToRowColumn(X, Y)))) + ( (selAvail() && ! isPointInSelection(displayToBufferPos(pixelsToRowColumn(X, Y)))) || ! selAvail())) { invalidateSelection(); mBlockEnd=mBlockBegin; @@ -5449,7 +5527,7 @@ void SynEdit::mousePressEvent(QMouseEvent *event) //if mousedown occurred in selected block begin drag operation mStateFlags.setFlag(SynStateFlag::sfWaitForDragging,false); if (bWasSel && mOptions.testFlag(eoDragDropEditing) && (X >= mGutterWidth + 2) - && (mSelectionMode == SynSelectionMode::smNormal) && IsPointInSelection(displayToBufferPos(pixelsToRowColumn(X, Y))) ) { + && (mSelectionMode == SynSelectionMode::smNormal) && isPointInSelection(displayToBufferPos(pixelsToRowColumn(X, Y))) ) { bStartDrag = true; } if (bStartDrag) { @@ -5540,7 +5618,7 @@ void SynEdit::mouseDoubleClickEvent(QMouseEvent *event) QPoint ptMouse = event->pos(); if (ptMouse.x() >= mGutterWidth + 2) { if (!mOptions.testFlag(eoNoSelection)) - SetWordBlock(caretXY()); + setWordBlock(caretXY()); mStateFlags.setFlag(SynStateFlag::sfDblClicked); //MouseCapture := FALSE; } @@ -5550,7 +5628,7 @@ void SynEdit::inputMethodEvent(QInputMethodEvent *event) { QString s = event->commitString(); if (!s.isEmpty()) { - CommandProcessor(SynEditorCommand::ecImeStr,QChar(),&s); + commandProcessor(SynEditorCommand::ecImeStr,QChar(),&s); // for (QChar ch:s) { // CommandProcessor(SynEditorCommand::ecChar,ch); // } diff --git a/RedPandaIDE/qsynedit/SynEdit.h b/RedPandaIDE/qsynedit/SynEdit.h index 583ccbaf..649653c7 100644 --- a/RedPandaIDE/qsynedit/SynEdit.h +++ b/RedPandaIDE/qsynedit/SynEdit.h @@ -162,9 +162,17 @@ public: void invalidateGutterLines(int FirstLine, int LastLine); DisplayCoord pixelsToNearestRowColumn(int aX, int aY) const; DisplayCoord pixelsToRowColumn(int aX, int aY) const; - QPoint RowColumnToPixels(const DisplayCoord& coord) const; + QPoint rowColumnToPixels(const DisplayCoord& coord) const; DisplayCoord bufferToDisplayPos(const BufferCoord& p) const; BufferCoord displayToBufferPos(const DisplayCoord& p) const; + + + NormalizedBufferCoord moveBufferPos(const BufferCoord&p, int delta) const; + NormalizedBufferCoord moveBufferPos(const NormalizedBufferCoord &p, int delta) const; + NormalizedBufferCoord normalizeBufferPos(const BufferCoord& p) const; + NormalizedBufferCoord normalizeBufferPos(int aChar, int aLine) const; + QChar charAtNormalizedBufferPos(const NormalizedBufferCoord& p) const; + int leftSpaces(const QString& line) const; QString GetLeftSpacing(int charCount,bool wantTabs) const; int charToColumn(int aLine, int aChar) const; @@ -185,21 +193,21 @@ public: void lockPainter(); void unlockPainter(); bool selAvail() const; - QString WordAtCursor(); - QString WordAtRowCol(const BufferCoord& XY); + QString wordAtCursor(); + QString wordAtRowCol(const BufferCoord& XY); int charColumns(QChar ch) const; double dpiFactor() const; - bool IsPointInSelection(const BufferCoord& Value) const; - BufferCoord NextWordPos(); - BufferCoord NextWordPosEx(const BufferCoord& XY); - BufferCoord WordStart(); - BufferCoord WordStartEx(const BufferCoord& XY); - BufferCoord WordEnd(); - BufferCoord WordEndEx(const BufferCoord& XY); - BufferCoord PrevWordPos(); - BufferCoord PrevWordPosEx(const BufferCoord& XY); - void CommandProcessor(SynEditorCommand Command, QChar AChar = QChar(), void * pData = nullptr); + bool isPointInSelection(const BufferCoord& Value) const; + BufferCoord nextWordPos(); + BufferCoord nextWordPosEx(const BufferCoord& XY); + BufferCoord wordStart(); + BufferCoord wordStartEx(const BufferCoord& XY); + BufferCoord wordEnd(); + BufferCoord wordEndEx(const BufferCoord& XY); + BufferCoord prevWordPos(); + BufferCoord prevWordPosEx(const BufferCoord& XY); + void commandProcessor(SynEditorCommand Command, QChar AChar = QChar(), void * pData = nullptr); //Caret void showCaret(); void hideCaret(); @@ -223,37 +231,37 @@ public: int maxScrollWidth() const; int maxScrollHeight() const; - bool GetHighlighterAttriAtRowCol(const BufferCoord& XY, QString& Token, + bool getHighlighterAttriAtRowCol(const BufferCoord& XY, QString& Token, PSynHighlighterAttribute& Attri); - bool GetHighlighterAttriAtRowCol(const BufferCoord& XY, QString& Token, + bool getHighlighterAttriAtRowCol(const BufferCoord& XY, QString& Token, bool& tokenFinished, SynHighlighterTokenType& TokenType, PSynHighlighterAttribute& Attri); - bool GetHighlighterAttriAtRowColEx(const BufferCoord& XY, QString& Token, + bool getHighlighterAttriAtRowColEx(const BufferCoord& XY, QString& Token, SynHighlighterTokenType& TokenType, SynTokenKind &TokenKind, int &Start, PSynHighlighterAttribute& Attri); //Commands - virtual void cutToClipboard() { CommandProcessor(SynEditorCommand::ecCut);} - virtual void copyToClipboard() { CommandProcessor(SynEditorCommand::ecCopy);} - virtual void pasteFromClipboard() { CommandProcessor(SynEditorCommand::ecPaste);} - virtual void undo() { CommandProcessor(SynEditorCommand::ecUndo);} - virtual void redo() { CommandProcessor(SynEditorCommand::ecRedo);} - virtual void zoomIn() { CommandProcessor(SynEditorCommand::ecZoomIn);} - virtual void zoomOut() { CommandProcessor(SynEditorCommand::ecZoomOut);} - virtual void selectAll() { CommandProcessor(SynEditorCommand::ecSelectAll);} - virtual void tab() { CommandProcessor(SynEditorCommand::ecTab);} - virtual void untab() { CommandProcessor(SynEditorCommand::ecShiftTab);} - virtual void toggleComment() { CommandProcessor(SynEditorCommand::ecToggleComment);} + virtual void cutToClipboard() { commandProcessor(SynEditorCommand::ecCut);} + virtual void copyToClipboard() { commandProcessor(SynEditorCommand::ecCopy);} + virtual void pasteFromClipboard() { commandProcessor(SynEditorCommand::ecPaste);} + virtual void undo() { commandProcessor(SynEditorCommand::ecUndo);} + virtual void redo() { commandProcessor(SynEditorCommand::ecRedo);} + virtual void zoomIn() { commandProcessor(SynEditorCommand::ecZoomIn);} + virtual void zoomOut() { commandProcessor(SynEditorCommand::ecZoomOut);} + virtual void selectAll() { commandProcessor(SynEditorCommand::ecSelectAll);} + virtual void tab() { commandProcessor(SynEditorCommand::ecTab);} + virtual void untab() { commandProcessor(SynEditorCommand::ecShiftTab);} + virtual void toggleComment() { commandProcessor(SynEditorCommand::ecToggleComment);} virtual void beginUpdate(); virtual void endUpdate(); virtual BufferCoord getMatchingBracket(); virtual BufferCoord getMatchingBracketEx(BufferCoord APoint); - bool GetPositionOfMouse(BufferCoord& aPos); - bool GetLineOfMouse(int& line); - bool PointToCharLine(const QPoint& point, BufferCoord& coord); - bool PointToLine(const QPoint& point, int& line); + bool getPositionOfMouse(BufferCoord& aPos); + bool getLineOfMouse(int& line); + bool pointToCharLine(const QPoint& point, BufferCoord& coord); + bool pointToLine(const QPoint& point, int& line); bool isIdentChar(const QChar& ch); void setRainbowAttrs(const PSynHighlighterAttribute &attr0, @@ -293,9 +301,9 @@ public: bool useCodeFolding() const; void setUseCodeFolding(bool value); - SynEditCodeFolding & codeFolding(); + SynEditCodeFolding & codeFolding() const; - QString lineText(); + QString lineText() const; void setLineText(const QString s); PSynEditStringList lines() const; @@ -366,25 +374,25 @@ signals: void linesDeleted(int FirstLine, int Count); void linesInserted(int FirstLine, int Count); - void Changed(); + void changed(); - void ChainUndoAdded(); - void ChainRedoAdded(); - void ChainLinesChanging(); - void ChainLinesChanged(); - void ChainListCleared(); +// void chainUndoAdded(); +// void chainRedoAdded(); +// void chainLinesChanging(); +// void chainLinesChanged(); +// void chainListCleared(); - void ChainListDeleted(int Index, int Count); - void ChainListInserted(int Index, int Count); - void ChainListPutted(int Index, int Count); +// void chainListDeleted(int Index, int Count); +// void chainListInserted(int Index, int Count); +// void chainListPutted(int Index, int Count); - void FilesDropped(int X,int Y, const QStringList& AFiles); +// void filesDropped(int X,int Y, const QStringList& AFiles); void gutterClicked(Qt::MouseButton button, int x, int y, int line); - void ImeInputed(const QString& s); +// void imeInputed(const QString& s); - void contextHelp(const QString& word); +// void contextHelp(const QString& word); - void scrolled(SynScrollBarKind ScrollBar); +// void scrolled(SynScrollBarKind ScrollBar); void statusChanged(SynStatusChanges changes); void fontChanged(); @@ -466,34 +474,34 @@ private: * @param DX * @param SelectionCommand */ - void MoveCaretHorz(int DX, bool isSelection); - void MoveCaretVert(int DY, bool isSelection); - void MoveCaretAndSelection(const BufferCoord& ptBefore, const BufferCoord& ptAfter, + void moveCaretHorz(int DX, bool isSelection); + void moveCaretVert(int DY, bool isSelection); + void moveCaretAndSelection(const BufferCoord& ptBefore, const BufferCoord& ptAfter, bool isSelection); - void MoveCaretToLineStart(bool isSelection); - void MoveCaretToLineEnd(bool isSelection); - void SetSelectedTextEmpty(); - void SetSelTextPrimitive(const QString& aValue); - void SetSelTextPrimitiveEx(SynSelectionMode PasteMode, + void moveCaretToLineStart(bool isSelection); + void moveCaretToLineEnd(bool isSelection); + void setSelectedTextEmpty(); + void setSelTextPrimitive(const QString& aValue); + void setSelTextPrimitiveEx(SynSelectionMode PasteMode, const QString& Value, bool AddToUndoList); void doLinesDeleted(int FirstLine, int Count); void doLinesInserted(int FirstLine, int Count); - void ProperSetLine(int ALine, const QString& ALineText); - void DeleteSelection(const BufferCoord& BB, const BufferCoord& BE); - void InsertText(const QString& Value, SynSelectionMode PasteMode,bool AddToUndoList); - int InsertTextByNormalMode(const QString& Value); - int InsertTextByColumnMode(const QString& Value,bool AddToUndoList); - int InsertTextByLineMode(const QString& Value); - void DeleteFromTo(const BufferCoord& start, const BufferCoord& end); - void SetSelWord(); - void SetWordBlock(BufferCoord Value); + void properSetLine(int ALine, const QString& ALineText); + void deleteSelection(const BufferCoord& BB, const BufferCoord& BE); + void insertText(const QString& Value, SynSelectionMode PasteMode,bool AddToUndoList); + int insertTextByNormalMode(const QString& Value); + int insertTextByColumnMode(const QString& Value,bool AddToUndoList); + int insertTextByLineMode(const QString& Value); + void deleteFromTo(const BufferCoord& start, const BufferCoord& end); + void setSelWord(); + void setWordBlock(BufferCoord Value); void processGutterClick(QMouseEvent* event); void clearUndo(); - BufferCoord GetPreviousLeftBracket(int x,int y); - bool CanDoBlockIndent(); + BufferCoord getPreviousLeftBracket(int x,int y); + bool canDoBlockIndent(); //Commands void doDeleteLastChar(); diff --git a/RedPandaIDE/qsynedit/Types.h b/RedPandaIDE/qsynedit/Types.h index 87aa8c02..e8ae0a88 100644 --- a/RedPandaIDE/qsynedit/Types.h +++ b/RedPandaIDE/qsynedit/Types.h @@ -12,6 +12,17 @@ struct BufferCoord { int Line; }; +/** + * Nomalized buffer posistion: + * (0,0) means at the start of the file ('\0') + * (1,count of lines+1) means at the end of the file ('\0') + * (length of the line+1, line) means at the line break of the line ('\n') + */ +struct NormalizedBufferCoord { + int Char; + int Line; +}; + struct DisplayCoord { int Column; int Row; diff --git a/RedPandaIDE/qsynedit/highlighter/cpp.cpp b/RedPandaIDE/qsynedit/highlighter/cpp.cpp index 1defddf3..8b108850 100644 --- a/RedPandaIDE/qsynedit/highlighter/cpp.cpp +++ b/RedPandaIDE/qsynedit/highlighter/cpp.cpp @@ -279,7 +279,7 @@ void SynEditCppHighlighter::ansiCppProc() if ( isSpaceChar(mLine[mRun]) ) { mRange.spaceState = mRange.state; mRange.state = RangeState::rsSpace; - break; + return; } mRun+=1; } diff --git a/RedPandaIDE/widgets/filepropertiesdialog.cpp b/RedPandaIDE/widgets/filepropertiesdialog.cpp index a433bd40..985cbbf8 100644 --- a/RedPandaIDE/widgets/filepropertiesdialog.cpp +++ b/RedPandaIDE/widgets/filepropertiesdialog.cpp @@ -41,7 +41,7 @@ void FilePropertiesDialog::calcFile(Editor *editor, j++; QString token; PSynHighlighterAttribute attr; - if (editor->GetHighlighterAttriAtRowCol(BufferCoord{j+1,i+1}, + if (editor->getHighlighterAttriAtRowCol(BufferCoord{j+1,i+1}, token,attr)) { // if it is preprocessor... if (attr->name() == SYNS_AttrPreprocessor) { diff --git a/RedPandaIDE/widgets/functiontipwidget.cpp b/RedPandaIDE/widgets/functiontipwidget.cpp new file mode 100644 index 00000000..31c76407 --- /dev/null +++ b/RedPandaIDE/widgets/functiontipwidget.cpp @@ -0,0 +1,13 @@ +#include "functiontipwidget.h" + +#include + +FunctionTipWidget::FunctionTipWidget(QWidget *parent) : QWidget(parent) +{ + setWindowFlags(Qt::ToolTip); + + mLabel = new QLabel(this); + mLabel->setText("Test"); + this->setLayout(new QHBoxLayout()); + this->layout()->addWidget(mLabel); +} diff --git a/RedPandaIDE/widgets/functiontipwidget.h b/RedPandaIDE/widgets/functiontipwidget.h new file mode 100644 index 00000000..3c8f3237 --- /dev/null +++ b/RedPandaIDE/widgets/functiontipwidget.h @@ -0,0 +1,20 @@ +#ifndef FUNCTIONTIPWIDGET_H +#define FUNCTIONTIPWIDGET_H + +#include +#include + +class Editor; +class FunctionTipWidget : public QWidget +{ + Q_OBJECT +public: + explicit FunctionTipWidget(QWidget *parent = nullptr); + +signals: +private: + QLabel* mLabel; + +}; + +#endif // FUNCTIONTIPWIDGET_H