Exemplo n.º 1
0
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;
}
Exemplo n.º 2
0
void QSAEditor::doRecalc()
{
    document()->invalidate();
    Q3TextParagraph *p = document()->firstParagraph();
    while ( p ) {
	p->format();
	p = p->next();
    }
    ensureCursorVisible();
    repaintContents( false );
}
Exemplo n.º 3
0
void Q3SyntaxHighlighter::rehighlight()
{
    Q3TextParagraph *s = edit->document()->firstParagraph();
    while (s) {
        s->invalidate(0);
        s->state = -1;
        s->needPreProcess = true;
        s = s->next();
    }
    edit->repaintContents();
}
Exemplo n.º 4
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();
    }
}
Exemplo n.º 5
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 );
}
Exemplo n.º 6
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();
}
Exemplo n.º 7
0
bool EditorCompletion::doObjectCompletion()
{
    searchString = "";
    QString object;
    int i = curEditor->textCursor()->index();
    i--;
    Q3TextParagraph *p = curEditor->textCursor()->paragraph();
    for (;;) {
	if ( i < 0 )
	    break;
	if ( p->at( i )->c == ' ' || p->at( i )->c == '\t' )
	    break;
	object.prepend( p->at( i )->c );
	i--;
    }

    if (object.isEmpty())
	return false;

    if ( object[ (int)object.length() - 1 ] == '-' )
	object.remove( object.length() - 1, 1 );

    return doObjectCompletion( object );
}
Exemplo n.º 8
0
void CompletionItem::setupParagraph() {
    if ( !parag ) {
	Q3TextFormatter *formatter;
	formatter = new Q3TextFormatterBreakWords;
	formatter->setWrapEnabled( false );
	parag = new Q3TextParagraph( 0 );
	parag->setTabStops( listBox()->fontMetrics().width( QString::fromLatin1("propertyXXXX") ) );
	parag->pseudoDocument()->pFormatter = formatter;
	parag->insert( 0, " " + type + ( type.isEmpty() ? " " : "\t" ) + prefix +
		       Q3ListBoxItem::text() + postfix + postfix2 );
	bool selCol = isSelected() && listBox()->palette().highlightedText() != listBox()->palette().text();
	QColor sc = selCol ? listBox()->palette().highlightedText().color() : getColor( type );
	Q3TextFormat *f1 = parag->formatCollection()->format( listBox()->font(), sc );
	Q3TextFormat *f3 = parag->formatCollection()->format( listBox()->font(), isSelected() ?
							     listBox()->palette().highlightedText().color() :
							     listBox()->palette().text().color() );
	QFont f( listBox()->font() );
	f.setBold( true );
	Q3TextFormat *f2 =
	    parag->formatCollection()->format( f, isSelected() ? listBox()->palette().highlightedText().color() :
					       listBox()->palette().text().color() );
	parag->setFormat( 1, type.length() + 1, f1 );
	parag->setFormat( type.length() + 2, prefix.length() + Q3ListBoxItem::text().length(), f2 );
	if ( !postfix.isEmpty() )
	    parag->setFormat( type.length() + 2 + prefix.length() + Q3ListBoxItem::text().length(),
			      postfix.length(), f3 );
	parag->setFormat( type.length() + 2 + prefix.length() + Q3ListBoxItem::text().length() + postfix.length(),
			  postfix2.length(), f3 );
	f1->removeRef();
	f2->removeRef();
	f3->removeRef();
	parag->format();
    }
}
Exemplo n.º 9
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();
    }
}