Exemple #1
0
void EditorCompletion::updateCompletionMap( Q3TextDocument *doc )
{
    bool strict = true;
    if ( doc != lastDoc )
	strict = false;
    lastDoc = doc;
    Q3TextParagraph *s = doc->firstParagraph();
    if ( !s->extraData() )
	s->setExtraData( new ParagData );
    while ( s ) {
	if ( s->length() == ( (ParagData*)s->extraData() )->lastLengthForCompletion ) {
	    s = s->next();
	    continue;
	}

	QChar c;
	QString buffer;
	for ( int i = 0; i < s->length(); ++i ) {
	    c = s->at( i )->c;
	    if ( c.isLetter() || c.isNumber() || c == '_' || c == '#' ) {
		buffer += c;
	    } else {
		addCompletionEntry( buffer, doc, strict );
		buffer = QString::null;
	    }
	}
	if ( !buffer.isEmpty() )
	    addCompletionEntry( buffer, doc, strict );

	( (ParagData*)s->extraData() )->lastLengthForCompletion = s->length();
	s = s->next();
    }
}
Q3TextParagraph *Q3TextDocument::paragAt(int i) const
{
    Q3TextParagraph* p = curParag;
    if (!p || p->paragId() > i)
        p = fParag;
    while (p && p->paragId() != i)
        p = p->next();
    ((Q3TextDocument*)this)->curParag = p;
    return p;
}
Exemple #3
0
void QSAEditor::doRecalc()
{
    document()->invalidate();
    Q3TextParagraph *p = document()->firstParagraph();
    while ( p ) {
	p->format();
	p = p->next();
    }
    ensureCursorVisible();
    repaintContents( false );
}
void Q3SyntaxHighlighter::rehighlight()
{
    Q3TextParagraph *s = edit->document()->firstParagraph();
    while (s) {
        s->invalidate(0);
        s->state = -1;
        s->needPreProcess = true;
        s = s->next();
    }
    edit->repaintContents();
}
Exemple #5
0
/*!  \property Q3MultiLineEdit::alignment
  \brief The editor's paragraph alignment

  Sets the alignment to flag, which must be Qt::AlignLeft,
  Qt::AlignHCenter, or \c Qt::AlignRight.

  If flag is an illegal flag, nothing happens.
*/
void Q3MultiLineEdit::setAlignment(Qt::Alignment flag)
{
    if (flag == Qt::AlignCenter)
        flag = Qt::AlignHCenter;
    if (flag != Qt::AlignLeft && flag != Qt::AlignRight && flag != Qt::AlignHCenter)
        return;
    Q3TextParagraph *p = document()->firstParagraph();
    while (p) {
        p->setAlignment(flag);
        p = p->next();
    }
}
Exemple #6
0
void QEditor::refresh()
{
	getDocument()->invalidate();
    Q3TextParagraph* p = getDocument()->firstParagraph();
    while( p ){
        p->format();
	p = p->next();
    }
    getDocument()->removeSelection( ParenMatcher::Match );
    getDocument()->removeSelection( ParenMatcher::Mismatch );
    ensureCursorVisible();
    repaintContents( false );
}
Exemple #7
0
void QSAEditor::expand( bool all /*else only functions*/ )
{
    Q3TextParagraph *p = document()->firstParagraph();
    while ( p ) {
	if ( ( (ParagData*)p->extraData() )->lineState == ParagData::FunctionStart ) {
	    if ( all ||
		 p->string()->toString().simplified().left(QString::fromLatin1("function").length() ) == QString::fromLatin1("function") ||
		 p->string()->toString().simplified().left(QString::fromLatin1("constructor").length() ) == QString::fromLatin1("constructor") ) {
		p = expandFunction( p, false );
		continue;
	    }
	}
	p = p->next();
    }
    doRecalc();
}