Ejemplo n.º 1
0
void DocumentEditor::prevBookmark() {
	int line, index;
	getCursorPosition(&line, &index);

	line = markerFindPrevious(line-1, MARKER_BOOK_MASK);
	if (line >= 0) {
		setCursorPosition(line, 0);
		ensureLineVisible(line);
	} else {
		// check from end
		line = markerFindPrevious(lines(), MARKER_BOOK_MASK);
		if (line >= 0) {
			setCursorPosition(line, 0);
			ensureLineVisible(line);
		}
	}
}
Ejemplo n.º 2
0
void DocumentEditor::nextBookmark() {
	int line, index;
	getCursorPosition(&line, &index);

	line = markerFindNext(line+1, MARKER_BOOK_MASK);
	if (line >= 0) {
		setCursorPosition(line, 0);
		ensureLineVisible(line);
	} else {
		// check from start
		line = markerFindNext(0, MARKER_BOOK_MASK);
		if (line >= 0) {
			setCursorPosition(line, 0);
			ensureLineVisible(line);
		}
	}
}
Ejemplo n.º 3
0
bool DocumentEditor::navigateBookmark(int id_) {
	int line = markerLine(id_);
	if (line < 0)
		return false;

	setCursorPosition(line, 0);
	ensureLineVisible(line);

	return true;
}
Ejemplo n.º 4
0
/**
 * Update the arrow marker to point to the correct line and colour it depending
 * on the error state
 * @param lineno :: The line to place the marker at. A negative number will
 * clear all markers
 * @param error :: If true, the marker will turn red
 */
void ScriptEditor::updateProgressMarker(int lineno, bool error) {
    m_currentExecLine = lineno;
    if (error) {
        setMarkerBackgroundColor(g_error_colour, m_progressArrowKey);
    } else {
        setMarkerBackgroundColor(g_success_colour, m_progressArrowKey);
    }
    markerDeleteAll();
    // Check the lineno actually exists, -1 means delete
    if (lineno <= 0 || lineno > this->lines())
        return;

    ensureLineVisible(lineno);
    markerAdd(m_currentExecLine - 1, m_progressArrowKey);
}
Ejemplo n.º 5
0
void QScintillaWidget::setCursorPosition(int pLine, int pColumn)
{
    // Make sure that the line and column numbers make sense

    pLine = qMin(qMax(0, pLine), lines()-1);
    pColumn = qMin(qMax(0, pColumn), text(pLine).size()-1);

    // Make sure that the line is not within a folded block

    ensureLineVisible(pLine);

    // Center ourselves around the given line

    SendScintilla(SCI_LINESCROLL, 0, pLine-firstVisibleLine()-0.5*SendScintilla(SCI_LINESONSCREEN));

    // Set our cursor position

    QsciScintilla::setCursorPosition(pLine, pColumn);
}
Ejemplo n.º 6
0
QsciEditor::QsciEditor( QWidget *parent ) : QsciScintilla( parent ) {

	setFocus();

	/* Set tab width, and fonts */
	setTabWidth( 4 );
	setFont( QFont( "Envy Code R", 9 ) );
	setTabIndents( true );
	setIndentationsUseTabs( true );

	/* Set folding style */
	setFolding( QsciScintilla::BoxedTreeFoldStyle );

	/* Remove Horizontal Scrollbar, put a Vertical one */
	setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
	setVerticalScrollBarPolicy( Qt::ScrollBarAsNeeded );

	/* Whitespace, indentation markings, and eol */
	setIndentationGuides( false );
	setWhitespaceVisibility( WsInvisible );
	setEolMode( EolUnix );

	/* Create Margins */
	setMarginWidth( 0, QString( " %1 " ).arg( lines() ) );
	setMarginWidth( 1, " " );
	setMarginWidth( 2, 10 );
	setMarginsFont( QFont( "Envy Code R", 9 ) );
	setWrapMode( QsciScintilla::WrapWord );

	/* Current Line Visibility */
	ensureCursorVisible();
	setCaretLineVisible( true );
	setCaretLineBackgroundColor( QColor( "#555555" ) );
	setCaretForegroundColor( QColor( "#FAFFAF" ) );
	setCaretWidth( 2 );

	/* Selection Color */
	// setSelectionBackgroundColor( "#333964" );
	// setSelectionForegroundColor( "*" );

	/* Margin and folding margins background colors */
	setMarginsBackgroundColor( QColor( "#A0A0A0" ) );
	setFoldMarginColors( QColor( "#666666" ), Qt::black );

	/* Set the width of the line */
	setLineWidth( 144 );
	ensureLineVisible( true );

	/* Set the paper and pen color - Editor BG and FG color */
	setPaper( Qt::black );
	setColor( Qt::white );

	/* Brace coloring */
	setBraceMatching( QsciScintilla::SloppyBraceMatch );
	setUnmatchedBraceForegroundColor( Qt::red );
	setUnmatchedBraceBackgroundColor( Qt::black );
	setMatchedBraceForegroundColor( Qt::darkGreen );
	setMatchedBraceBackgroundColor( Qt::black );

	/* Multi-selection and typing */
	SendScintilla( SCI_SETADDITIONALSELECTIONTYPING, true );
	SendScintilla( SCI_SETMULTIPLESELECTION, true );
	SendScintilla( SCI_SETMULTIPASTE, true );

	/* Scroll beyond the last line */
	SendScintilla( SCI_SETENDATLASTLINE, false );

	/* Set the editor state as not modified */
	setModified( false );

	/* Auto Save Timer: 60 sec */
	autoSaveTimer = new QBasicTimer();

	/* Enable and Show Custom context Menu */
	setContextMenuPolicy( Qt::CustomContextMenu );

	/* Connections */
	setupActions();

	/* Default Lexer */
	setLexer( new QLexerDefault() );

    QsciScintilla::FoldStyle state = static_cast<QsciScintilla::FoldStyle>( ( !folding() ) * 5 );
    if ( !state )
        foldAll( false );
    setFolding( state );
};