Пример #1
0
void ScriptEditorWidget::updateOptions()
{
	QPalette p = palette();
	p.setColor(QPalette::Base,g_clrBackground);
	p.setColor(QPalette::Text,g_clrNormalText);
	setPalette(p);
	setFont(g_fntNormal);
	setTextColor(g_clrNormalText);
	disableSyntaxHighlighter();
	enableSyntaxHighlighter();

	p = ((ScriptEditorImplementation*)m_pParent)->findLineEdit()->palette();
	p.setColor(foregroundRole(),g_clrFind);
	((ScriptEditorImplementation*)m_pParent)->findLineEdit()->setPalette(p);

	//set cursor custom width
	if (KVI_OPTION_BOOL(KviOption_boolEnableCustomCursorWidth))
	{
		setCursorWidth(KVI_OPTION_UINT(KviOption_uintCustomCursorWidth));
	} else {
#if defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW)
		int iCursorWidth = 1;
		SystemParametersInfo(SPI_GETCARETWIDTH, 0, &iCursorWidth, 0);
		setCursorWidth(iCursorWidth);
#endif //COMPILE_ON_WINDOWS || COMPILE_ON_MINGW
	}
}
Пример #2
0
MdiChild::MdiChild()
{
	_document = new Document(this);
	docLayout = new PlainTextDocumentLayout(_document);
	_document->setDocumentLayout(docLayout);
	setDocument(_document);
	syntaxHightlighter = new SyntaxHighlighter(_document);
	syntaxHightlighter->setDocument(_document);
	setAttribute(Qt::WA_DeleteOnClose);
	setWindowIcon(QIcon::fromTheme("text-x-generic"));
	isUntitled = true;
	autoindent = true;
	snipples=NULL;
	snipplesActivateOk=NULL;
	replaceTabsBySpacesOk = NULL;
	//setTabStopWidth(20);
	setCursorWidth(3);
	connect(document(), SIGNAL(contentsChanged()),
		this, SLOT(documentContentsChanged()));
	connect(document(), SIGNAL(modificationChanged(bool)),
		this, SLOT(documentWasModified()));
	connect(document(), SIGNAL(fileNameChanged(QString)),
		this, SLOT(setCurrentFile(QString)));
	connect(docLayout, SIGNAL(docChanged(int, int, int)), this, SLOT(documentChanged(int, int, int)));
}
Пример #3
0
CodeEditor::CodeEditor(Config* config, QWidget* parent)
    : QPlainTextEdit(parent), config(config)
{
    highlighter = new Highlighter(config, this); // тормоз

    extraArea = new QWidget(this);
    extraArea->setCursor(Qt::PointingHandCursor);
    extraArea->setAutoFillBackground(true);
    extraArea->installEventFilter(this);

    completer = new QCompleter(config->keywordsSorted, this);
    completer->setWidget(this);
    completer->setCompletionMode(QCompleter::PopupCompletion);
    completer->setWrapAround(false);

    setLineWrapMode(QPlainTextEdit::NoWrap);
    setCursorWidth(2);
    blockCountChanged(0);
    setMouseTracking(true);

    reconfig();

    // не допускаем проваливание на последнем свернутом блоке
    connect(this,       SIGNAL(cursorPositionChanged()),       SLOT(ensureCursorVisible()));
    connect(this,       SIGNAL(blockCountChanged(int)),        SLOT(blockCountChanged(int)));
    connect(document(), SIGNAL(contentsChange(int, int, int)), SLOT(contentsChange(int, int, int)));
    connect(completer,  SIGNAL(activated(const QString&)),     SLOT(insertCompletion(const QString&)));
    connect(config,     SIGNAL(reread(int)),                   SLOT(reconfig(int)));
    connect(this,       SIGNAL(updateRequest(QRect, int)), extraArea, SLOT(update()));
}
Пример #4
0
int QTextControl::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QObject::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 38)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 38;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< QString*>(_v) = toHtml(); break;
        case 1: *reinterpret_cast< bool*>(_v) = overwriteMode(); break;
        case 2: *reinterpret_cast< bool*>(_v) = acceptRichText(); break;
        case 3: *reinterpret_cast< int*>(_v) = cursorWidth(); break;
        case 4: *reinterpret_cast< Qt::TextInteractionFlags*>(_v) = textInteractionFlags(); break;
        case 5: *reinterpret_cast< bool*>(_v) = openExternalLinks(); break;
        case 6: *reinterpret_cast< bool*>(_v) = ignoreUnusedNavigationEvents(); break;
        }
        _id -= 7;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setHtml(*reinterpret_cast< QString*>(_v)); break;
        case 1: setOverwriteMode(*reinterpret_cast< bool*>(_v)); break;
        case 2: setAcceptRichText(*reinterpret_cast< bool*>(_v)); break;
        case 3: setCursorWidth(*reinterpret_cast< int*>(_v)); break;
        case 4: setTextInteractionFlags(*reinterpret_cast< Qt::TextInteractionFlags*>(_v)); break;
        case 5: setOpenExternalLinks(*reinterpret_cast< bool*>(_v)); break;
        case 6: setIgnoreUnusedNavigationEvents(*reinterpret_cast< bool*>(_v)); break;
        }
        _id -= 7;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 7;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
Пример #5
0
void Console::updateSettings() {
    /* set colors */
    setStyleSheet(
        "QPlainTextEdit {"
        "background-color: " +
        SettingsManager::termBackground().name() +
        ";"
        "color: " +
        SettingsManager::termForeground().name() +
        ";"
        "}");

    /* set font */
    QFont font = SettingsManager::font();
    setFont(font);

    /* set the cursor to be a block */
    QFontMetrics fm(font);
    setCursorWidth(fm.averageCharWidth());
}
Пример #6
0
SyntaxTextEditor::SyntaxTextEditor(QWidget *parent) :
        QPlainTextEdit(parent),editCompleter(0)
{
    setAttribute(Qt::WA_DeleteOnClose);
    setLineWrapMode(QPlainTextEdit::NoWrap);

    isUntitled = true;
    editorArea = new SyntaxTextEditorArea(this);
    connect(this, SIGNAL(blockCountChanged(int)), this, SLOT(updateAreaWidth(int)));
    connect(this, SIGNAL(updateRequest(QRect,int)), this, SLOT(updateEditorArea(QRect,int)));
    connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(highlightCurrentLine()));

    setCursorWidth(2);

    updateAreaWidth(0);
    highlightCurrentLine();
    this->autoBlock = true;
    this->autoIndent = true;
    this->autoWord = false;
}
Пример #7
0
TabTerminal::TabTerminal(QWidget * parent) :
	QTextEdit(parent),
	_userPrompt(QString("<span style=\"color: #00FF00;\">sand6$</span> ")),
	_locked(false),
	_historySkip(false)
{
	document()->setMaximumBlockCount(1000);
	setStyleSheet("color: #ddd; background: black;");
	QFont font("Monospace");
	font.setFamily("Terminus");
	font.setStyleHint(QFont::TypeWriter);
	//font.setPointSize(12);
	setFont(font);
	QFontMetrics fm(font);
	setCursorWidth(fm.averageCharWidth());
	_historyUp.clear();
	_historyDown.clear();
	setLineWrapMode(WidgetWidth);
	insertHtml("<span style=\"color: #996600;\">*** Welcome to puzzleSEQ Terminal ***</span><br>");
	insertHtml(_userPrompt);
}
int QPlainTextDocumentLayout::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QAbstractTextDocumentLayout::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;

#ifndef QT_NO_PROPERTIES
    if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0:
            *reinterpret_cast< int*>(_v) = cursorWidth();
            break;
        }
        _id -= 1;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0:
            setCursorWidth(*reinterpret_cast< int*>(_v));
            break;
        }
        _id -= 1;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 1;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 1;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 1;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 1;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 1;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 1;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
Пример #9
0
WChatLog::WChatLog(QWidget * pwParent, ITreeItemChatLogEvents * pContactOrGroup) : WTextBrowser(pwParent)
	{
	Assert(pContactOrGroup != NULL);
	m_pContactOrGroup = pContactOrGroup;
	m_fDisplayAllMessages = FALSE;
	m_tsMidnightNext = d_ts_zNA;
	setMinimumSize(10, 50);
	setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
	setTextInteractionFlags((textInteractionFlags() & ~Qt::TextEditable) | Qt::LinksAccessibleByMouse);
	setUndoRedoEnabled(false);		// setMaximumBlockCount
	setCursorWidth(0);
	//document()->setDefaultStyleSheet("p {text-indent:-10px; margin-left:10px; margin-top:5; margin-bottom:0; white-space:pre-wrap;}");
	document()->setDefaultStyleSheet(
		"a."d_szClassForChatLog_ButtonHtml " { color: black; background-color: silver; text-decoration: none; font-weight: bold } "
		"a."d_szClassForChatLog_HyperlinkDisabled " { color: gray; text-decoration: none; } "

		"a.ha { color: navy; text-decoration: none; } "	// Active Hyperlink (displayed in the normal blue color)
		".d { color: green } "
		//"a.hb { padding: 6px; margin-left:10px; background-color: silver; border-style: outset; border-width: 2px; border-radius: 10px; border-color: black; } "
		//"a.hb:hover { background-color: rgb(224, 0, 0); border-style: inset; }");
		);

	/*
	QTextCursor oTextCursor = textCursor();
	//oTextCursor.select(QTextCursor::Document);
	//oTextCursor.setBlockFormat(QTextBlockFormat());
	oTextCursor.insertBlock();
	m_oTextBlockComposing = oTextCursor.block();

	CArrayPtrEvents arraypEvents;
	pContactOrGroup->Vault_GetEventsForChatLog(OUT &arraypEvents);
	ChatLog_EventsDisplay(IN arraypEvents);
	*/
	ChatLog_EventsRepopulate();

	setOpenLinks(false);	// Prevent the chat history to automatically open the hyperlinks
	connect(this, SIGNAL(highlighted(QUrl)), this, SLOT(SL_HyperlinkMouseHovering(QUrl)));
	connect(this, SIGNAL(anchorClicked(QUrl)), this, SLOT(SL_HyperlinkClicked(QUrl)));
	}
Пример #10
0
Editor::Editor(QWidget* parent)
    : QPlainTextEdit(parent)
{
    m_evaluator = Evaluator::instance();
    m_currentHistoryIndex = 0;
    m_isAutoCompletionEnabled = true;
    m_completion = new EditorCompletion(this);
    m_constantCompletion = 0;
    m_completionTimer = new QTimer(this);
    m_isAutoCalcEnabled = true;
    m_highlighter = new SyntaxHighlighter(this);
    m_autoCalcTimer = new QTimer(this);
    m_autoCalcSelTimer = new QTimer(this);
    m_matchingTimer = new QTimer(this);
    m_isAnsAvailable = false;
    m_shouldPaintCustomCursor = true;

    setViewportMargins(0, 0, 0, 0);
    setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
    setTabChangesFocus(true);
    setWordWrapMode(QTextOption::NoWrap);
    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setCursorWidth(0);

    connect(m_autoCalcTimer, SIGNAL(timeout()), SLOT(autoCalc()));
    connect(m_autoCalcSelTimer, SIGNAL(timeout()), SLOT(autoCalcSelection()));
    connect(m_completion, SIGNAL(selectedCompletion(const QString&)), SLOT(autoComplete(const QString&)));
    connect(m_completionTimer, SIGNAL(timeout()), SLOT(triggerAutoComplete()));
    connect(m_matchingTimer, SIGNAL(timeout()), SLOT(doMatchingPar()));
    connect(this, SIGNAL(selectionChanged()), SLOT(startSelAutoCalcTimer()));
    connect(this, SIGNAL(textChanged()), SLOT(checkAutoCalc()));
    connect(this, SIGNAL(textChanged()), SLOT(checkAutoComplete()));
    connect(this, SIGNAL(textChanged()), SLOT(checkMatching()));

    adjustSize();
    setFixedHeight(sizeHint().height());
}
Пример #11
0
TextEdit::TextEdit( QWidget *parent ) : QTextEdit(parent)
{
	setGeometry(498,80,100,21);
	
	QPalette palette = this->palette();
	palette.setColor(QPalette::Active, QPalette::Text, QColor(0, 165, 200));
	palette.setColor(QPalette::Active, QPalette::Base, Qt::transparent);
	setPalette(palette);
	
   	setFrameStyle(QFrame::NoFrame);
	setReadOnly(true);
	
#ifdef Q_OS_UNIX
 	setCurrentFont( QFont("Sans Serif", 7) );
#endif
	
#ifdef Q_OS_WIN
	setCurrentFont( QFont("Sans Serif", 9) );
#endif	
	
	setCursorWidth(0);
	setAlignment( Qt::AlignCenter );
	setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
}
Пример #12
0
void MyTextEdit::keyReleaseEvent(QKeyEvent *e)
{

    if(e->key()==Qt::Key_Return||e->key()==Qt::Key_Enter||e->key()==Qt::Key_Backspace||e->key()==Qt::Key_Tab)
    {
        QTextCursor *cur = new QTextCursor;
        *cur = this->textCursor();
        if(cur->position()>1)
        {
            if ((e->key() == Qt::Key_Return) || (e->key() == Qt::Key_Enter))
            {
                int indent_ = 0;
                QString txt = toPlainText();
                if(txt[cur->position()-2]==':')
                {
                    indent_+=4;
                }
                QString line;
                int i = cur->position()-2;
                while(txt[i]!='\n')
                {
                    line.insert(0,txt[i]);
                    i--;
                    if(i<0)
                        break;
                }
                for(i = 0; i<line.length();i++)
                {
                    if(line[i]!=' ')
                        break;
                    indent_++;
                }
                for(i = 0; i<indent_/4; i++)
                {
                    cur->insertText("    ");
                }
                return;
            }
        }
        if(e->key() == Qt::Key_Tab)
        {

            if(cur->selectionStart()==cur->selectionEnd())
                cur->insertText("    ");
            else
            {
                QString txt = toPlainText();
                QTextCursor* c = new QTextCursor(*cur);
                c->setPosition(cur->selectionStart());
                qDebug()<<c->position();
                int index = cur->selectionStart();
                int count = 0;
                while(index>0&&txt[index]!=QChar::ParagraphSeparator&&txt[index]!='\n')
                {
                    index--;
                    count++;
                }
                c->setPosition(index);
                qDebug()<<c->position();
                c->movePosition(QTextCursor::Right,QTextCursor::KeepAnchor, count+cur->selectedText().size());
                count+=cur->selectedText().size();
                int count2 = 0;

                while(c->selectionEnd()<txt.size()&&txt[c->selectionEnd()]!=QChar::ParagraphSeparator&&txt[c->selectionEnd()]!='\n')
                {
                    count++;
                    if(!c->movePosition(QTextCursor::Right,QTextCursor::KeepAnchor,1))
                    {
                        break;
                    }
                }
                QString t = c->selectedText();
                qDebug()<<t;
                if(t[0]!=QChar::ParagraphSeparator&&t[0]!='\n')
                {
                    count2+=4;
                    t.insert(0,"    ");
                }
                for(int i = 0; i < t.size(); i++)
                {
                    if(t[i]=='\n'||t[i]==QChar::ParagraphSeparator)
                    {
                        t.insert(i+1,"    ");
                        i+=4;
                        count2 +=4;
                    }
                }

                c->insertText(t);
                cur->setPosition(index);
                qDebug()<<cur->selectionStart()<<cur->selectionEnd();
                cur->movePosition(QTextCursor::Right,QTextCursor::KeepAnchor,count2+count);
                this->setTextCursor(*cur);
            }
        }

        if(e->key()==Qt::Key_Backspace)
        {
            bool spaces = true;
            int counter = 0;
            *cur = this->textCursor();
            QString text = this->toPlainText();
            if(cur->position()>0&&text[cur->position()-1]!=' ')
            {
                cur->deletePreviousChar();
                return;
            }
            text = toPlainText();
            *cur = textCursor();
            for(int k = cur->position();;k--)
            {
                if(k==0||text[k-1]=='\n')
                    break;
                counter++;
                if(text[k-1]!=' ')
                {
                    spaces = false;
                    break;
                }
            }
            if(spaces&&counter>3)
            {
                for(int k = 0; k<4; k++)
                    cur->deletePreviousChar();

            }
            else if(spaces)
                cur->deletePreviousChar();
            else
                cur->deletePreviousChar();

        }
    }
    else
    {
        return;
    }
    setCursorWidth(1);
}
int QPlainTextEdit::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QAbstractScrollArea::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 25)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 25;
    }
#ifndef QT_NO_PROPERTIES
    else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0:
            *reinterpret_cast< bool*>(_v) = tabChangesFocus();
            break;
        case 1:
            *reinterpret_cast< QString*>(_v) = documentTitle();
            break;
        case 2:
            *reinterpret_cast< bool*>(_v) = isUndoRedoEnabled();
            break;
        case 3:
            *reinterpret_cast< LineWrapMode*>(_v) = lineWrapMode();
            break;
        case 4:
            *reinterpret_cast< bool*>(_v) = isReadOnly();
            break;
        case 5:
            *reinterpret_cast< QString*>(_v) = toPlainText();
            break;
        case 6:
            *reinterpret_cast< bool*>(_v) = overwriteMode();
            break;
        case 7:
            *reinterpret_cast< int*>(_v) = tabStopWidth();
            break;
        case 8:
            *reinterpret_cast< int*>(_v) = cursorWidth();
            break;
        case 9:
            *reinterpret_cast< Qt::TextInteractionFlags*>(_v) = textInteractionFlags();
            break;
        case 10:
            *reinterpret_cast< int*>(_v) = blockCount();
            break;
        case 11:
            *reinterpret_cast< int*>(_v) = maximumBlockCount();
            break;
        case 12:
            *reinterpret_cast< bool*>(_v) = backgroundVisible();
            break;
        case 13:
            *reinterpret_cast< bool*>(_v) = centerOnScroll();
            break;
        }
        _id -= 14;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0:
            setTabChangesFocus(*reinterpret_cast< bool*>(_v));
            break;
        case 1:
            setDocumentTitle(*reinterpret_cast< QString*>(_v));
            break;
        case 2:
            setUndoRedoEnabled(*reinterpret_cast< bool*>(_v));
            break;
        case 3:
            setLineWrapMode(*reinterpret_cast< LineWrapMode*>(_v));
            break;
        case 4:
            setReadOnly(*reinterpret_cast< bool*>(_v));
            break;
        case 5:
            setPlainText(*reinterpret_cast< QString*>(_v));
            break;
        case 6:
            setOverwriteMode(*reinterpret_cast< bool*>(_v));
            break;
        case 7:
            setTabStopWidth(*reinterpret_cast< int*>(_v));
            break;
        case 8:
            setCursorWidth(*reinterpret_cast< int*>(_v));
            break;
        case 9:
            setTextInteractionFlags(*reinterpret_cast< Qt::TextInteractionFlags*>(_v));
            break;
        case 11:
            setMaximumBlockCount(*reinterpret_cast< int*>(_v));
            break;
        case 12:
            setBackgroundVisible(*reinterpret_cast< bool*>(_v));
            break;
        case 13:
            setCenterOnScroll(*reinterpret_cast< bool*>(_v));
            break;
        }
        _id -= 14;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 14;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 14;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 14;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 14;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 14;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 14;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
Пример #14
0
MarkdownEditor::MarkdownEditor
(
    TextDocument* textDocument,
    MarkdownHighlighter* highlighter,
    QWidget* parent
)
    : QPlainTextEdit(parent),
        textDocument(textDocument),
        highlighter(highlighter),
        dictionary(DictionaryManager::instance().requestDictionary()),
        mouseButtonDown(false)
{
    setDocument(textDocument);
    setAcceptDrops(true);

    preferredLayout = new QGridLayout();
    preferredLayout->setSpacing(0);
    preferredLayout->setMargin(0);
    preferredLayout->setContentsMargins(0, 0, 0, 0);
    preferredLayout->addWidget(this, 0, 0);

    blockquoteRegex.setPattern("^ {0,3}(>\\s*)+");
    numberedListRegex.setPattern("^\\s*([0-9]+)[.)]\\s+");
    bulletListRegex.setPattern("^\\s*[+*-]\\s+");
    taskListRegex.setPattern("^\\s*[-] \\[([x ])\\]\\s+");

    this->setWordWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere);
    setCursorWidth(2);
    setCenterOnScroll(true);
    ensureCursorVisible();
    spellCheckEnabled = false;
    installEventFilter(this);
    viewport()->installEventFilter(this);
    wordCount = 0;
    lastBlockCount = 1;
    focusMode = FocusModeDisabled;
    insertSpacesForTabs = false;
    setTabulationWidth(4);
    editorWidth = EditorWidthMedium;

    markupPairs.insert('"', '"');
    markupPairs.insert('\'', '\'');
    markupPairs.insert('(', ')');
    markupPairs.insert('[', ']');
    markupPairs.insert('{', '}');
    markupPairs.insert('*', '*');
    markupPairs.insert('_', '_');
    markupPairs.insert('`', '`');
    markupPairs.insert('<', '>');

    connect(this->document(), SIGNAL(contentsChange(int,int,int)), this, SLOT(onTextChanged(int,int,int)));
    connect(this->document(), SIGNAL(blockCountChanged(int)), this, SLOT(onBlockCountChanged(int)));
    connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(onCursorPositionChanged()));
    connect(this, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));

    addWordToDictionaryAction = new QAction(tr("Add word to dictionary"), this);
    checkSpellingAction = new QAction(tr("Check spelling..."), this);

    typingPausedSignalSent = true;
    typingHasPaused = true;

    typingTimer = new QTimer(this);
    connect
    (
        typingTimer,
        SIGNAL(timeout()),
        this,
        SLOT(checkIfTypingPaused())
    );
    typingTimer->start(1000);

    setColorScheme
    (
        QColor(Qt::black),
        QColor(Qt::white),
        QColor(Qt::black),
        QColor(Qt::blue),
        QColor(Qt::red)
    );

    fadeEffect = new GraphicsFadeEffect(this);
    fadeEffect->setFadeHeight(this->fontMetrics().height());
    viewport()->setGraphicsEffect(fadeEffect);
}