void CppEditorBrowser::showHelp( const QString &w ) { QString word( w ); if ( word[ 0 ] == 'Q' ) { if ( word[ (int)word.length() - 1 ] == '&' || word[ (int)word.length() - 1 ] == '*' ) word.remove( word.length() - 1, 1 ); word = word.lower() + ".html"; QStringList lst; lst << "assistant" << "-file" << word; QProcess proc( lst ); proc.start(); return; } if ( word.find( '(' ) != -1 ) { QString txt = "::" + word.left( word.find( '(' ) ); QTextDocument *doc = curEditor->document(); QTextParagraph *p = doc->firstParagraph(); while ( p ) { if ( p->string()->toString().find( txt ) != -1 ) { curEditor->setCursorPosition( p->paragId(), 0 ); return; } p = p->next(); } } QMainWindow *mw = ::qt_cast<QMainWindow*>(curEditor->topLevelWidget()); if ( mw ) mw->statusBar()->message( tr( "Nothing available for '%1'" ).arg( w ), 1500 ); }
void MarkerWidget::contextMenuEvent( QContextMenuEvent *e ) { QPopupMenu m( 0, "editor_breakpointsmenu" ); int toggleBreakPoint = 0; // int editBreakpoints = 0; QTextParagraph *p = ( (Editor*)viewManager->currentView() )->document()->firstParagraph(); int yOffset = ( (Editor*)viewManager->currentView() )->contentsY(); bool supports = ( (Editor*)viewManager->currentView() )->supportsBreakPoints(); while ( p && supports ) { if ( e->y() >= p->rect().y() - yOffset && e->y() <= p->rect().y() + p->rect().height() - yOffset ) { if ( ( (ParagData*)p->extraData() )->marker == ParagData::Breakpoint ) toggleBreakPoint = m.insertItem( tr( "Clear Breakpoint\tF9" ) ); else toggleBreakPoint = m.insertItem( tr( "Set Breakpoint\tF9" ) ); // editBreakpoints = m.insertItem( tr( "Edit Breakpoints..." ) ); m.insertSeparator(); break; } p = p->next(); } const int collapseAll = m.insertItem( tr( "Collapse All" ) ); const int expandAll = m.insertItem( tr( "Expand All" ) ); const int collapseFunctions = m.insertItem( tr( "Collapse all Functions" ) ); const int expandFunctions = m.insertItem( tr( "Expand all Functions" ) ); int res = m.exec( e->globalPos() ); if ( res == -1) return; if ( res == collapseAll ) { emit collapse( TRUE ); } else if ( res == collapseFunctions ) { emit collapse( FALSE ); } else if ( res == expandAll ) { emit expand( TRUE ); } else if ( res == expandFunctions ) { emit expand( FALSE ); } else if ( res == toggleBreakPoint ) { if ( ( (ParagData*)p->extraData() )->marker == ParagData::Breakpoint ) { ( (ParagData*)p->extraData() )->marker = ParagData::NoMarker; } else { bool ok; isBreakpointPossible( ok, ( (Editor*)viewManager->currentView() )->text(), p->paragId() ); if ( ok ) ( (ParagData*)p->extraData() )->marker = ParagData::Breakpoint; else emit showMessage( tr( "<font color=red>Can't set breakpoint here!</font>" ) ); } // } else if ( res == editBreakpoints ) { // emit editBreakPoints(); } doRepaint(); emit markersChanged(); }
QTextParagraph *QTextDocument::paragAt( int i ) const { QTextParagraph* p = curParag; if ( !p || p->paragId() > i ) p = fParag; while ( p && p->paragId() != i ) p = p->next(); ((QTextDocument*)this)->curParag = p; return p; }
void QSyntaxHighlighter::rehighlight() { QTextParagraph *s = edit->document()->firstParagraph(); while ( s ) { s->invalidate( 0 ); s->state = -1; s->needPreProcess = TRUE; s = s->next(); } edit->repaintContents( FALSE ); }
/*! \property QMultiLineEdit::alignment \brief The editor's paragraph alignment Sets the alignment to flag, which must be \c AlignLeft, \c AlignHCenter or \c AlignRight. If flag is an illegal flag nothing happens. \sa Qt::AlignmentFlags */ void QMultiLineEdit::setAlignment( int flag ) { if ( flag == AlignCenter ) flag = AlignHCenter; if ( flag != AlignLeft && flag != AlignRight && flag != AlignHCenter ) return; QTextParagraph *p = document()->firstParagraph(); while ( p ) { p->setAlignment( flag ); p = p->next(); } }
void EditorInterfaceImpl::scrollTo( const QString &txt, const QString & ) { if ( !viewManager || !viewManager->currentView() ) return; ( (CppEditor*)viewManager->currentView() )->sync(); QTextDocument *doc = ( (CppEditor*)viewManager->currentView() )->document(); QTextParagraph *p = doc->firstParagraph(); while ( p ) { if ( p->string()->toString().find( txt ) != -1 ) { ( (CppEditor*)viewManager->currentView() )->setCursorPosition( p->paragId() + 2, 0 ); break; } p = p->next(); } ( (CppEditor*)viewManager->currentView() )->setFocus(); }
void MarkerWidget::mousePressEvent( QMouseEvent *e ) { if ( e->button() != LeftButton ) return; bool supports = ( (Editor*)viewManager->currentView() )->supportsBreakPoints(); QTextParagraph *p = ( (Editor*)viewManager->currentView() )->document()->firstParagraph(); int yOffset = ( (Editor*)viewManager->currentView() )->contentsY(); while ( p ) { if ( e->y() >= p->rect().y() - yOffset && e->y() <= p->rect().y() + p->rect().height() - yOffset ) { QTextParagraphData *d = p->extraData(); if ( !d ) return; ParagData *data = (ParagData*)d; if ( supports && ( e->x() < width() - 15 ) ) { if ( data->marker == ParagData::Breakpoint ) { data->marker = ParagData::NoMarker; } else { bool ok = TRUE; isBreakpointPossible( ok, ( (Editor*)viewManager->currentView() )->text(), p->paragId() ); if ( ok ) data->marker = ParagData::Breakpoint; else emit showMessage( tr( "<font color=red>Can't set breakpoint here!</font>" ) ); } } else { if ( data->lineState == ParagData::FunctionStart ) { if ( data->functionOpen ) emit collapseFunction( p ); else emit expandFunction( p ); } } break; } p = p->next(); } doRepaint(); emit markersChanged(); }
void SyntaxHighlighter_HTML::process( QTextDocument *doc, QTextParagraph *string, int, bool invalidate ) { QTextFormat *formatStandard = format( Standard ); QTextFormat *formatKeyword = format( Keyword ); QTextFormat *formatAttribute = format( Attribute ); QTextFormat *formatAttribValue = format( AttribValue ); const int StateStandard = 0; const int StateTag = 1; const int StateAttribute = 2; const int StateAttribVal = 3; QString buffer = ""; int state = StateStandard; if ( string->prev() ) { if ( string->prev()->endState() == -1 ) process( doc, string->prev(), 0, FALSE ); state = string->prev()->endState(); } int i = 0; for ( ;; ) { QChar c = string->at( i )->c; if ( c == '<' ) { if ( state != StateStandard ) string->setFormat( i - buffer.length(), buffer.length(), formatStandard, FALSE ); buffer = c; state = StateTag; string->setFormat( i, 1, formatKeyword, FALSE ); } else if ( c == '>' && ( state != StateStandard ) ) { string->setFormat( i, 1, formatKeyword, FALSE ); buffer = ""; state = StateStandard; } else if ( c == ' ' && state == StateTag ) { buffer += c; string->setFormat( i, 1, formatStandard, FALSE ); state = StateAttribute; } else if ( c == '=' && state == StateAttribute ) { buffer += c; string->setFormat( i, 1, formatStandard, FALSE ); state = StateAttribute; } else if ( c == '\"' && state == StateAttribute ) { buffer += c; string->setFormat( i, 1, formatStandard, FALSE ); state = StateAttribVal; } else if ( c == '\"' && state == StateAttribVal ) { buffer += c; string->setFormat( i, 1, formatStandard, FALSE ); state = StateAttribute; } else if ( state == StateAttribute ) { buffer += c; string->setFormat( i, 1, formatAttribute, FALSE ); } else if ( state == StateAttribVal ) { buffer += c; string->setFormat( i, 1, formatAttribValue, FALSE ); } else if ( state == StateTag ) { string->setFormat( i, 1, formatKeyword, FALSE ); buffer += c; } else if ( state == StateStandard ) { string->setFormat( i, 1, formatStandard, FALSE ); } i++; if ( i >= string->length() ) break; } string->setEndState( state ); string->setFirstPreProcess( FALSE ); if ( invalidate && string->next() && !string->next()->firstPreProcess() && string->next()->endState() != -1 ) { QTextParagraph *p = string->next(); while ( p ) { if ( p->endState() == -1 ) return; p->setEndState( -1 ); p = p->next(); } } }
void QSASyntaxHighlighter::process( QTextDocument *doc, QTextParagraph *string, int, bool invalidate ) { // ### AbanQ if (this == 0) return; QTextFormat *formatStandard = format( Standard ); QTextFormat *formatComment = format( Comment ); QTextFormat *formatNumber = format( Number ); QTextFormat *formatString = format( String ); QTextFormat *formatType = format( Type ); QTextFormat *formatPreProcessor = format( PreProcessor ); QTextFormat *formatLabel = format( Label ); // states const int StateStandard = 0; const int StateCommentStart1 = 1; const int StateCCommentStart2 = 2; const int StateCppCommentStart2 = 3; const int StateCComment = 4; const int StateCppComment = 5; const int StateCCommentEnd1 = 6; const int StateCCommentEnd2 = 7; const int StateStringStart = 8; const int StateString = 9; const int StateStringEnd = 10; const int StateString2Start = 11; const int StateString2 = 12; const int StateString2End = 13; const int StateNumber = 14; const int StatePreProcessor = 15; // tokens const int InputAlpha = 0; const int InputNumber = 1; const int InputAsterix = 2; const int InputSlash = 3; const int InputParen = 4; const int InputSpace = 5; const int InputHash = 6; const int InputQuotation = 7; const int InputApostrophe = 8; const int InputSep = 9; static const uchar table[ 16 ][ 10 ] = { { StateStandard, StateNumber, StateStandard, StateCommentStart1, StateStandard, StateStandard, StatePreProcessor, StateStringStart, StateString2Start, StateStandard }, // StateStandard { StateStandard, StateNumber, StateCCommentStart2, StateCppCommentStart2, StateStandard, StateStandard, StatePreProcessor, StateStringStart, StateString2Start, StateStandard }, // StateCommentStart1 { StateCComment, StateCComment, StateCCommentEnd1, StateCComment, StateCComment, StateCComment, StateCComment, StateCComment, StateCComment, StateCComment }, // StateCCommentStart2 { StateCppComment, StateCppComment, StateCppComment, StateCppComment, StateCppComment, StateCppComment, StateCppComment, StateCppComment, StateCppComment, StateCppComment }, // CppCommentStart2 { StateCComment, StateCComment, StateCCommentEnd1, StateCComment, StateCComment, StateCComment, StateCComment, StateCComment, StateCComment, StateCComment }, // StateCComment { StateCppComment, StateCppComment, StateCppComment, StateCppComment, StateCppComment, StateCppComment, StateCppComment, StateCppComment, StateCppComment, StateCppComment }, // StateCppComment { StateCComment, StateCComment, StateCCommentEnd1, StateCCommentEnd2, StateCComment, StateCComment, StateCComment, StateCComment, StateCComment, StateCComment }, // StateCCommentEnd1 { StateStandard, StateNumber, StateStandard, StateCommentStart1, StateStandard, StateStandard, StatePreProcessor, StateStringStart, StateString2Start, StateStandard }, // StateCCommentEnd2 { StateString, StateString, StateString, StateString, StateString, StateString, StateString, StateStringEnd, StateString, StateString }, // StateStringStart { StateString, StateString, StateString, StateString, StateString, StateString, StateString, StateStringEnd, StateString, StateString }, // StateString { StateStandard, StateStandard, StateStandard, StateCommentStart1, StateStandard, StateStandard, StatePreProcessor, StateStringStart, StateString2Start, StateStandard }, // StateStringEnd { StateString2, StateString2, StateString2, StateString2, StateString2, StateString2, StateString2, StateString2, StateString2End, StateString2 }, // StateString2Start { StateString2, StateString2, StateString2, StateString2, StateString2, StateString2, StateString2, StateString2, StateString2End, StateString2 }, // StateString2 { StateStandard, StateStandard, StateStandard, StateCommentStart1, StateStandard, StateStandard, StatePreProcessor, StateStringStart, StateString2Start, StateStandard }, // StateString2End { StateNumber, StateNumber, StateStandard, StateCommentStart1, StateStandard, StateStandard, StatePreProcessor, StateStringStart, StateString2Start, StateStandard }, // StateNumber { StatePreProcessor, StateStandard, StateStandard, StateCommentStart1, StateStandard, StateStandard, StatePreProcessor, StateStringStart, StateString2Start, StateStandard } // StatePreProcessor }; QString buffer; int state = StateStandard; if ( string->prev() ) { if ( string->prev()->endState() == -1 ) process( doc, string->prev(), 0, FALSE ); state = string->prev()->endState(); } int input = -1; int i = 0; bool lastWasBackSlash = FALSE; bool makeLastStandard = FALSE; ParagData *paragData = (ParagData*)string->extraData(); if ( paragData ) paragData->parenList.clear(); else paragData = new ParagData; string->setExtraData( paragData ); static QString alphabeth = QString::fromLatin1("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"); static QString mathChars = QString::fromLatin1("xXeE"); static QString numbers = QString::fromLatin1("0123456789"); bool questionMark = FALSE; bool resetLineState = TRUE; QChar lastChar; QString firstWord; while ( TRUE ) { QChar c = string->at( i )->c; if ( lastWasBackSlash ) { input = InputSep; } else { switch ( c.latin1() ) { case '*': input = InputAsterix; break; case '/': input = InputSlash; break; case '(': case '[': case '{': input = InputParen; if ( state == StateStandard || state == StateNumber || state == StatePreProcessor || state == StateCCommentEnd2 || state == StateCCommentEnd1 || state == StateString2End || state == StateStringEnd ) paragData->parenList << Paren( Paren::Open, c, i ); break; case ')': case ']': case '}': input = InputParen; if ( state == StateStandard || state == StateNumber || state == StatePreProcessor || state == StateCCommentEnd2 || state == StateCCommentEnd1 || state == StateString2End || state == StateStringEnd ) { paragData->parenList << Paren( Paren::Closed, c, i ); if ( c == '}' ) { if ( checkFunctionEnd( string, i ) ) resetLineState = FALSE; } } break; case '#': input = InputHash; break; case '"': input = InputQuotation; break; case '\'': input = InputApostrophe; break; case ' ': input = InputSpace; if ( firstWord == QString::fromLatin1("function") || firstWord == QString::fromLatin1("constructor") || firstWord == QString::fromLatin1("class")/* || firstWord == "if" || firstWord == "for" || firstWord == "while" || firstWord == "else"*/ ) { paragData->lineState = ParagData::FunctionStart; resetLineState = FALSE; } break; case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case '0': if ( alphabeth.find( lastChar ) != -1 && ( mathChars.find( lastChar ) == -1 || numbers.find( string->at( i - 1 )->c ) == -1 ) ) { input = InputAlpha; } else { if ( input == InputAlpha && numbers.find( lastChar ) != -1 ) input = InputAlpha; else input = InputNumber; } break; case ':': { input = InputAlpha; QChar nextChar = ' '; if ( i < string->length() - 1 ) nextChar = string->at( i + 1 )->c; if ( state == StateStandard && !questionMark && lastChar != ':' && nextChar != ':' && lastChar.isLetter() ) { for ( int j = 0; j < i; ++j ) { if ( string->at( j )->format() == formatStandard ) string->setFormat( j, 1, formatLabel, FALSE ); } } break; } default: { if ( c != '\t' ) firstWord += c; QString s = firstWord.simplifyWhiteSpace(); if ( s == QString::fromLatin1("private") || s == QString::fromLatin1("protected") || s == QString::fromLatin1("public") || s == QString::fromLatin1("static") ) firstWord = ""; if ( !questionMark && c == '?' ) questionMark = TRUE; if ( c.isLetter() || c == '_' ) input = InputAlpha; else input = InputSep; } break; } } lastWasBackSlash = !lastWasBackSlash && c == '\\'; if ( input == InputAlpha ) buffer += c; state = table[ state ][ input ]; switch ( state ) { case StateStandard: { int len = buffer.length(); string->setFormat( i, 1, formatStandard, FALSE ); if ( makeLastStandard ) string->setFormat( i - 1, 1, formatStandard, FALSE ); makeLastStandard = FALSE; if ( buffer.length() > 0 && input != InputAlpha ) { if ( buffer == QString::fromLatin1("true") || buffer == QString::fromLatin1("false") || buffer == QString::fromLatin1("NaN") || buffer == QString::fromLatin1("Infinity") || buffer == QString::fromLatin1("undefined") ) { string->setFormat( i - buffer.length(), buffer.length(), formatType, FALSE ); } else { QMap<int, QMap<QString, int > >::Iterator it = wordMap->find( len ); if ( it != wordMap->end() ) { QMap<QString, int >::Iterator it2 = ( *it ).find( buffer ); if ( it2 != ( *it ).end() ) string->setFormat( i - buffer.length(), buffer.length(), format( ( *it2 ) ), FALSE ); } } buffer = QString::null; } } break; case StateCommentStart1: if ( makeLastStandard ) string->setFormat( i - 1, 1, formatStandard, FALSE ); makeLastStandard = TRUE; buffer = QString::null; break; case StateCCommentStart2: string->setFormat( i - 1, 2, formatComment, FALSE ); makeLastStandard = FALSE; buffer = QString::null; break; case StateCppCommentStart2: string->setFormat( i - 1, 2, formatComment, FALSE ); makeLastStandard = FALSE; buffer = QString::null; break; case StateCComment: if ( makeLastStandard ) string->setFormat( i - 1, 1, formatStandard, FALSE ); makeLastStandard = FALSE; string->setFormat( i, 1, formatComment, FALSE ); buffer = QString::null; break; case StateCppComment: if ( makeLastStandard ) string->setFormat( i - 1, 1, formatStandard, FALSE ); makeLastStandard = FALSE; string->setFormat( i, 1, formatComment, FALSE ); buffer = QString::null; break; case StateCCommentEnd1: if ( makeLastStandard ) string->setFormat( i - 1, 1, formatStandard, FALSE ); makeLastStandard = FALSE; string->setFormat( i, 1, formatComment, FALSE ); buffer = QString::null; break; case StateCCommentEnd2: if ( makeLastStandard ) string->setFormat( i - 1, 1, formatStandard, FALSE ); makeLastStandard = FALSE; string->setFormat( i, 1, formatComment, FALSE ); buffer = QString::null; break; case StateStringStart: if ( makeLastStandard ) string->setFormat( i - 1, 1, formatStandard, FALSE ); makeLastStandard = FALSE; string->setFormat( i, 1, formatStandard, FALSE ); buffer = QString::null; break; case StateString: if ( makeLastStandard ) string->setFormat( i - 1, 1, formatStandard, FALSE ); makeLastStandard = FALSE; string->setFormat( i, 1, formatString, FALSE ); buffer = QString::null; break; case StateStringEnd: if ( makeLastStandard ) string->setFormat( i - 1, 1, formatStandard, FALSE ); makeLastStandard = FALSE; string->setFormat( i, 1, formatStandard, FALSE ); buffer = QString::null; break; case StateString2Start: if ( makeLastStandard ) string->setFormat( i - 1, 1, formatStandard, FALSE ); makeLastStandard = FALSE; string->setFormat( i, 1, formatStandard, FALSE ); buffer = QString::null; break; case StateString2: if ( makeLastStandard ) string->setFormat( i - 1, 1, formatStandard, FALSE ); makeLastStandard = FALSE; string->setFormat( i, 1, formatString, FALSE ); buffer = QString::null; break; case StateString2End: if ( makeLastStandard ) string->setFormat( i - 1, 1, formatStandard, FALSE ); makeLastStandard = FALSE; string->setFormat( i, 1, formatStandard, FALSE ); buffer = QString::null; break; case StateNumber: if ( makeLastStandard ) string->setFormat( i - 1, 1, formatStandard, FALSE ); makeLastStandard = FALSE; string->setFormat( i, 1, formatNumber, FALSE ); buffer = QString::null; break; case StatePreProcessor: if ( makeLastStandard ) string->setFormat( i - 1, 1, formatStandard, FALSE ); makeLastStandard = FALSE; string->setFormat( i, 1, formatPreProcessor, FALSE ); buffer = QString::null; break; } lastChar = c; i++; if ( i >= string->length() ) break; } if ( resetLineState ) paragData->lineState = ParagData::InFunction; string->setExtraData( paragData ); int oldEndState = string->endState(); if ( state == StateCComment || state == StateCCommentEnd1 ) { string->setEndState( StateCComment ); } else if ( state == StateString ) { string->setEndState( StateString ); } else if ( state == StateString2 ) { string->setEndState( StateString2 ); } else { string->setEndState( StateStandard ); } string->setFirstPreProcess( FALSE ); QTextParagraph *p = string->next(); if ( (!!oldEndState || !!string->endState()) && oldEndState != string->endState() && invalidate && p && !p->firstPreProcess() && p->endState() != -1 ) { while ( p ) { if ( p->endState() == -1 ) return; p->setEndState( -1 ); p = p->next(); } } }
bool ParenMatcher::checkOpenParen( QTextCursor *cursor ) { if ( !cursor->paragraph()->extraData() ) return FALSE; ParenList parenList = ( (ParagData*)cursor->paragraph()->extraData() )->parenList; Paren openParen, closedParen; QTextParagraph *closedParenParag = cursor->paragraph(); int i = 0; int ignore = 0; bool foundOpen = FALSE; QChar c = cursor->paragraph()->at( cursor->index() )->c; for (;;) { if ( !foundOpen ) { if ( i >= (int)parenList.count() ) goto bye; openParen = parenList[ i ]; if ( openParen.pos != cursor->index() ) { ++i; continue; } else { foundOpen = TRUE; ++i; } } if ( i >= (int)parenList.count() ) { for (;;) { closedParenParag = closedParenParag->next(); if ( !closedParenParag ) goto bye; if ( closedParenParag->extraData() && ( (ParagData*)closedParenParag->extraData() )->parenList.count() > 0 ) { parenList = ( (ParagData*)closedParenParag->extraData() )->parenList; break; } } i = 0; } closedParen = parenList[ i ]; if ( closedParen.type == Paren::Open ) { ignore++; ++i; continue; } else { if ( ignore > 0 ) { ignore--; ++i; continue; } int id = Match; if ( c == '{' && closedParen.chr != '}' || c == '(' && closedParen.chr != ')' || c == '[' && closedParen.chr != ']' ) id = Mismatch; cursor->document()->setSelectionStart( id, *cursor ); int tidx = cursor->index(); QTextParagraph *tstring = cursor->paragraph(); cursor->setParagraph( closedParenParag ); cursor->setIndex( closedParen.pos + 1 ); cursor->document()->setSelectionEnd( id, *cursor ); cursor->setParagraph( tstring ); cursor->setIndex( tidx ); return TRUE; } } bye: return FALSE; }
bool ParenMatcher::checkClosedParen( QTextCursor *cursor ) { if ( !cursor->paragraph()->extraData() ) return FALSE; ParenList parenList = ( (ParagData*)cursor->paragraph()->extraData() )->parenList; Paren openParen, closedParen; QTextParagraph *openParenParag = cursor->paragraph(); int i = (int)parenList.count() - 1; int ignore = 0; bool foundClosed = FALSE; QChar c = cursor->paragraph()->at( cursor->index() - 1 )->c; for (;;) { if ( !foundClosed ) { if ( i < 0 ) goto bye; closedParen = parenList[ i ]; if ( closedParen.pos != cursor->index() - 1 ) { --i; continue; } else { foundClosed = TRUE; --i; } } if ( i < 0 ) { for (;;) { openParenParag = openParenParag->prev(); if ( !openParenParag ) goto bye; if ( openParenParag->extraData() && ( (ParagData*)openParenParag->extraData() )->parenList.count() > 0 ) { parenList = ( (ParagData*)openParenParag->extraData() )->parenList; break; } } i = (int)parenList.count() - 1; } openParen = parenList[ i ]; if ( openParen.type == Paren::Closed ) { ignore++; --i; continue; } else { if ( ignore > 0 ) { ignore--; --i; continue; } int id = Match; if ( c == '}' && openParen.chr != '{' || c == ')' && openParen.chr != '(' || c == ']' && openParen.chr != '[' ) id = Mismatch; cursor->document()->setSelectionStart( id, *cursor ); int tidx = cursor->index(); QTextParagraph *tstring = cursor->paragraph(); cursor->setParagraph( openParenParag ); cursor->setIndex( openParen.pos ); cursor->document()->setSelectionEnd( id, *cursor ); cursor->setParagraph( tstring ); cursor->setIndex( tidx ); return TRUE; } } bye: return FALSE; }
void MarkerWidget::paintEvent( QPaintEvent * ) { buffer.fill( backgroundColor() ); QTextParagraph *p = ( (Editor*)viewManager->currentView() )->document()->firstParagraph(); QPainter painter( &buffer ); int yOffset = ( (Editor*)viewManager->currentView() )->contentsY(); while ( p ) { if ( !p->isVisible() ) { p = p->next(); continue; } if ( p->rect().y() + p->rect().height() - yOffset < 0 ) { p = p->next(); continue; } if ( p->rect().y() - yOffset > height() ) break; if ( !((p->paragId() + 1) % 10) ) { painter.save(); painter.setPen( colorGroup().dark() ); painter.drawText( 0, p->rect().y() - yOffset, width() - 20, p->rect().height(), Qt::AlignRight | Qt::AlignTop, QString::number( p->paragId() + 1 ) ); painter.restore(); } ParagData *paragData = (ParagData*)p->extraData(); if ( paragData ) { switch ( paragData->marker ) { case ParagData::Error: painter.drawPixmap( 3, p->rect().y() + ( p->rect().height() - errorPixmap->height() ) / 2 - yOffset, *errorPixmap ); break; case ParagData::Breakpoint: painter.drawPixmap( 3, p->rect().y() + ( p->rect().height() - breakpointPixmap->height() ) / 2 - yOffset, *breakpointPixmap ); break; default: break; } switch ( paragData->lineState ) { case ParagData::FunctionStart: painter.setPen( colorGroup().foreground() ); painter.setBrush( colorGroup().base() ); painter.drawLine( width() - 11, p->rect().y() - yOffset, width() - 11, p->rect().y() + p->rect().height() - yOffset ); painter.drawRect( width() - 15, p->rect().y() + ( p->rect().height() - 9 ) / 2 - yOffset, 9, 9 ); painter.drawLine( width() - 13, p->rect().y() + ( p->rect().height() - 9 ) / 2 - yOffset + 4, width() - 9, p->rect().y() + ( p->rect().height() - 9 ) / 2 - yOffset + 4 ); if ( !paragData->functionOpen ) painter.drawLine( width() - 11, p->rect().y() + ( p->rect().height() - 9 ) / 2 - yOffset + 2, width() - 11, p->rect().y() + ( p->rect().height() - 9 ) / 2 - yOffset + 6 ); break; case ParagData::InFunction: painter.setPen( colorGroup().foreground() ); painter.drawLine( width() - 11, p->rect().y() - yOffset, width() - 11, p->rect().y() + p->rect().height() - yOffset ); break; case ParagData::FunctionEnd: painter.setPen( colorGroup().foreground() ); painter.drawLine( width() - 11, p->rect().y() - yOffset, width() - 11, p->rect().y() + p->rect().height() - yOffset ); painter.drawLine( width() - 11, p->rect().y() + p->rect().height() - yOffset, width() - 7, p->rect().y() + p->rect().height() - yOffset ); break; default: break; } if ( paragData->step ) painter.drawPixmap( 3, p->rect().y() + ( p->rect().height() - stepPixmap->height() ) / 2 - yOffset, *stepPixmap ); if ( paragData->stackFrame ) painter.drawPixmap( 3, p->rect().y() + ( p->rect().height() - stackFrame->height() ) / 2 - yOffset, *stackFrame ); } p = p->next(); } painter.end(); bitBlt( this, 0, 0, &buffer ); }