Пример #1
0
OCamlSource::OCamlSource()
{
    _from_user_loaded = true;
    lineSearchArea = new OCamlSourceSearch( this );
    lineSearchArea->hide();
    lineSearchArea->setEnabled(false);

    connect( lineSearchArea, SIGNAL( textChanged( const QString & ) ), this, SLOT( searchTextChanged( const QString & ) ) );
    connect( lineSearchArea, SIGNAL( returnPressed() ), this, SLOT( nextTextSearch() ) );

    lineNumberArea = new OCamlSourceLineNumberArea( this );
    connect( this, SIGNAL( blockCountChanged( int ) ), this, SLOT( updateLineNumberAreaWidth( int ) ) );
    connect( this, SIGNAL( updateRequest( QRect, int ) ), this, SLOT( updateLineNumberArea( QRect, int ) ) );

    updateLineNumberAreaWidth( 0 );

    setAttribute( Qt::WA_DeleteOnClose );
    highlighter = new OCamlSourceHighlighter( this->document() );
    _start_char = 0;
    _end_char = 0;
    _after = false;
    setReadOnly( true );
    QFont font( "Monospace" );
    font.setStyleHint( QFont::TypeWriter );
    setFont( font );
    timer_index = 0;
    markCurrentLocationTimer = new QTimer();
    connect ( markCurrentLocationTimer , SIGNAL( timeout() ), this , SLOT( markCurrentLocation() ) );
    markCurrentLocationTimer->setSingleShot( true );
    file_watch_p = NULL;
}
Пример #2
0
SqlTextEdit::SqlTextEdit(QWidget* parent) :
    QPlainTextEdit(parent), m_defaultCompleterModel(0)
{
    // basic auto completer for sqliteedit
    m_Completer = new QCompleter(this);
    m_Completer->setCaseSensitivity(Qt::CaseInsensitive);
    m_Completer->setCompletionMode(QCompleter::PopupCompletion);
    m_Completer->setWrapAround(false);
    m_Completer->setWidget(this);

    // Set font
    QFont font("Monospace");
    font.setStyleHint(QFont::TypeWriter);
    font.setPointSize(PreferencesDialog::getSettingsValue("editor", "fontsize").toInt());
    setFont(font);

    QFontMetrics fm(font);
    setTabStopWidth(fm.width(" ") * PreferencesDialog::getSettingsValue("editor", "tabsize").toInt());

    // Create syntax highlighter
    m_syntaxHighlighter = new SQLiteSyntaxHighlighter(document());

    // Create line number area
    lineNumberArea = new LineNumberArea(this);

    connect(this, SIGNAL(blockCountChanged(int)), this, SLOT(updateLineNumberAreaWidth()));
    connect(this, SIGNAL(updateRequest(QRect,int)), this, SLOT(updateLineNumberArea(QRect,int)));
    connect(m_Completer, SIGNAL(activated(QString)), this, SLOT(insertCompletion(QString)));
    connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(highlightCurrentLine()));

    highlightCurrentLine();
    updateLineNumberAreaWidth();
}
Пример #3
0
//-----------------------------------------------------------------------------
void TextEdit::updateLineNumberArea()
{
	/* When the signal is emitted, the sliderPosition has been adjusted according to the action,
	 * but the value has not yet been propagated (meaning the valueChanged() signal was not yet emitted),
	 * and the visual display has not been updated. In slots connected to this signal you can thus safely
	 * adjust any action by calling setSliderPosition() yourself, based on both the action and the
	 * slider's value. */
	// Make sure the sliderPosition triggers one last time the valueChanged() signal with the actual value !!!!
	verticalScrollBar()->setSliderPosition(verticalScrollBar()->sliderPosition());

	// Since "QTextEdit" does not have an "updateRequest(...)" signal, we chose
	// to grab the imformations from "sliderPosition()" and "contentsRect()".
	// See the necessary connections used (Class constructor implementation part).

	QRect rect =  contentsRect();
	lineNumberArea->update(0, rect.y(), lineNumberArea->width(), rect.height());
	updateLineNumberAreaWidth(0);
	//----------
	int dy = verticalScrollBar()->sliderPosition();
	if (dy > -1) {
		lineNumberArea->scroll(0, dy);
	}

	// Addjust slider to alway see the number of the currently being edited line...
	int first_block_id = getFirstVisibleBlockId();
	if (first_block_id == 0 || textCursor().block().blockNumber() == first_block_id-1)
		verticalScrollBar()->setSliderPosition(dy-document()->documentMargin());
}
Пример #4
0
GenericTextEditorDocument::GenericTextEditorDocument(QWidget *parent) : QPlainTextEdit(parent), 
mCodec(0), mCompleter(0), mDocName(""), mFilePath(""), mTextModified(false), mFile(0), mIsOfsFile(false),
mInitialDisplay(true), mCloseEvtAlreadyProcessed(false)
{
    QSettings settings;

    QFont fnt = font();
    fnt.setFamily("Courier New");
    fnt.setPointSize(settings.value("preferences/fontSize").toUInt());
    setFont(fnt);   

    QPlainTextEdit::LineWrapMode mode;

    if(settings.value("preferences/lineWrapping").toBool())
        mode = QPlainTextEdit::WidgetWidth;
    else
        mode = QPlainTextEdit::NoWrap;

    setLineWrapMode(mode);
    setAttribute(Qt::WA_DeleteOnClose);

    QFontMetrics fm(fnt);
    setTabStopWidth(fm.width("abcd"));
    mLineNumberArea = new LineNumberArea(this);

    connect(this,       SIGNAL(blockCountChanged(int)),             this, SLOT(updateLineNumberAreaWidth(int)));
    connect(this,       SIGNAL(updateRequest(const QRect &, int)),  this, SLOT(updateLineNumberArea(const QRect &, int)));
    connect(this,       SIGNAL(cursorPositionChanged()),            this, SLOT(highlightCurrentLine()));

    updateLineNumberAreaWidth(0);
    highlightCurrentLine();
}
Пример #5
0
CodeArea::CodeArea(QWidget *parent)
    :QPlainTextEdit(parent)
    ,highlighter(this->document())
{
    QFont font;
    font.setFamily("Courier");
    font.setFixedPitch(true);
    font.setPointSize(10);
    font.insertSubstitution("	","    ");
    setFont(font);
    setWordWrapMode(QTextOption::NoWrap);

    lineNumberArea = new LineNumberArea(this);
    connect(this, SIGNAL(blockCountChanged(int)), this, SLOT(updateLineNumberAreaWidth(int)));
    connect(this, SIGNAL(updateRequest(QRect,int)), this, SLOT(updateLineNumberArea(QRect,int)));
    connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(highlightCurrentLine()));

    updateLineNumberAreaWidth(0);
    highlightCurrentLine();
    mCompleter = new QCompleter(this);
    mCompleter->setModel(new QStringListModel(mWordList, mCompleter));
    mCompleter->setModelSorting(QCompleter::CaseSensitivelySortedModel);
    mCompleter->setCaseSensitivity(Qt::CaseSensitive);
    mCompleter->setWrapAround(false);

    mCompleter->setWidget(this);
    mCompleter->setCompletionMode(QCompleter::PopupCompletion);
    mCompleter->setCaseSensitivity(Qt::CaseInsensitive);
    QObject::connect(mCompleter, SIGNAL(activated(QString)),
                  this, SLOT(insertCompletion(QString)));

    connect(this,SIGNAL(textChanged()), this, SLOT(onTextChange()));
}
Пример #6
0
/**
 * @brief CodeEditor::CodeEditor Create empty code editor.
 * @param parent Get parent of this object.
 * @param path Path of opened file.
 * @param type Type of opened shader.
 */
CodeEditor::CodeEditor(QWidget *parent, QString path, InfoManager::SHADERTYPE type) :
    QPlainTextEdit(parent)
{
    lineNumberArea = new LineNumberArea(this);
    oldBlockNumber = 0;

    customConnect();

    updateLineNumberAreaWidth(0);
    highlightCurrentLine();

    pathSet = true;
    filePath = path;
    //textModif = false;

    // set shader type
    sType = type;

    // set syntax highlighter
    highlight = new Highlighter(this);
    highlight->setDocument(document());

    // read the file
    readFile();

    setDefaultSettings();
    createRegExps();
}
Пример #7
0
TextEditor::TextEditor(QWidget *parent) : QPlainTextEdit(parent)
{
    lineNumberArea = new LineNumberArea(this);

    connect(this, SIGNAL(blockCountChanged(int)), this, SLOT(updateLineNumberAreaWidth(int)));
    connect(this, SIGNAL(updateRequest(QRect,int)), this, SLOT(updateLineNumberArea(QRect,int)));
    connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(highlightCurrentLine()));

    updateLineNumberAreaWidth(0);
    highlightCurrentLine();

    QFont font("consolas",9);
    const int tabStop = 4;  // 4 characters
    QFontMetrics metrics(font);
    setTabStopWidth(tabStop * metrics.width(' '));
    setFont(font);
    setLineWrapMode(QPlainTextEdit::NoWrap);

    m_highlighter = new Highlighter(document());

    m_autoUpdate = false;
    m_timer = new QTimer();
    m_timer->setSingleShot(true);
    m_timer->setInterval(1000);
    connect(m_timer, SIGNAL(timeout()), this, SLOT(updateShader()));
    connect(this, SIGNAL(textChanged()), this, SLOT(resetTimer()));
}
Пример #8
0
CCodeEditor::CCodeEditor(QWidget *parent)
	: QPlainTextEdit(parent) {
	lineNumberArea = new CCodeEditor_LineNumberArea(this);
	m_foldArea = new CCodeEditor_FoldArea( this );

	connect(this, SIGNAL(blockCountChanged(int)), this, SLOT(updateLineNumberAreaWidth(int)));

	connect(this, SIGNAL(updateRequest(const QRect &, int)), this, SLOT(updateLineNumberArea(const QRect &, int)));

	connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(highlightCurrentLine()));

	updateLineNumberAreaWidth(0);
	highlightCurrentLine();

	setFont( QFont( "Courier New" , 11 ) );

	CFileSyntaxHighlighter* s = new CFileSyntaxHighlighter( this->document() );
        s->loadFromFile( "kuka_syntax.xml" );

        // This second loading fail and cause to lost of first
        // syntax file ( TODO )
        /*s = new CFileSyntaxHighlighter( this->document() );
        s->loadFromFile( SYNTAX_SYSTEMFILE );*/

	m_ownerDocument = NULL;
        m_oldBlockCount = 0;
}
Пример #9
0
void LogViewer::init()
{
    setAcceptDrops(true);
    setReadOnly(true);
    setTabWidth(4);
    setLineWrapMode(QPlainTextEdit::NoWrap);
    setTextInteractionFlags(Qt::TextSelectableByKeyboard | Qt::TextSelectableByMouse);

    QPalette palette;
    palette.setColor(QPalette::Inactive, QPalette::Highlight, palette.color(QPalette::Active, QPalette::Highlight));
    palette.setColor(QPalette::Inactive, QPalette::HighlightedText, palette.color(QPalette::Active, QPalette::HighlightedText));
    setPalette(palette);

    // Read settings.
    setFont(INIMANAGER()->font());
    setForegroundColor(INIMANAGER()->foregroundColor());
    setBackgroundColor(INIMANAGER()->backgroundColor());
    setCustomBackgroundColor(INIMANAGER()->customBackgroundColor());
    setCurrentLineFgColor(INIMANAGER()->currentLineFgColor());
    setCurrentLineBgColor(INIMANAGER()->currentLineBgColor());

    connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(drawCurrentLine()));
    connect(this, SIGNAL(blockCountChanged(int)), this, SLOT(blockCountChanged(int)));
    connect(this, SIGNAL(selectionChanged()), this, SLOT(selectionChanged()));

    // Line Number.
    updateLineNumberAreaWidth(0);
    connect(this, SIGNAL(blockCountChanged(int)), this, SLOT(updateLineNumberAreaWidth(int)));
    connect(this, SIGNAL(updateRequest(QRect,int)), this, SLOT(updateLineNumberArea(QRect,int)));

    // Keyword Highlighter.
    connect(m_keywordHighlighter, SIGNAL(modelCreated(QStandardItemModel*)), this, SLOT(modelCreated(QStandardItemModel*)));
    connect(m_keywordHighlighter, SIGNAL(chartLoaded(QPixmap*)), this, SLOT(chartLoaded(QPixmap*)));
}
Пример #10
0
void CSVWorld::ScriptEdit::showLineNum(bool show)
{
    if(show!=mShowLineNum)
    {
        mShowLineNum = show;
        updateLineNumberAreaWidth(0);
    }
}
Пример #11
0
//! Reimplementation of QPlainTextEdit::setPlainText method.
//! Makes sure we dont update if the passed text is same.
//! @param text the string to set.
void ModelicaEditor::setPlainText(const QString &text)
{
    if (text != toPlainText())
    {
        QPlainTextEdit::setPlainText(text);
        updateLineNumberAreaWidth(0);
    }
}
Пример #12
0
//! Constructor
ModelicaEditor::ModelicaEditor(ProjectTab *pParent)
    : QPlainTextEdit(pParent)
{
    mpParentProjectTab = pParent;
    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
    setTabStopWidth(Helper::tabWidth);
    setObjectName("ModelicaEditor");
    document()->setDocumentMargin(2);
    setLineWrapMode(QPlainTextEdit::NoWrap);
    // depending on the project tab readonly state set the text view readonly state
    setReadOnly(mpParentProjectTab->isReadOnly());
    connect(this, SIGNAL(focusOut()), mpParentProjectTab, SLOT(modelicaEditorTextChanged()));
    connect(this, SIGNAL(textChanged()), SLOT(hasChanged()));

    mpFindWidget = new QWidget;
    mpFindWidget->setContentsMargins(0, 0, 0, 0);
    mpFindWidget->hide();

    mpSearchLabelImage = new QLabel;
    mpSearchLabelImage->setPixmap(QPixmap(":/Resources/icons/search.png"));
    mpSearchLabel = new QLabel(Helper::search);
    mpSearchTextBox = new QLineEdit;
    connect(mpSearchTextBox, SIGNAL(textChanged(QString)), SLOT(updateButtons()));
    connect(mpSearchTextBox, SIGNAL(returnPressed()), SLOT(findNextText()));

    mpPreviuosButton = new QToolButton;
    mpPreviuosButton->setAutoRaise(true);
    mpPreviuosButton->setText(tr("Previous"));
    mpPreviuosButton->setIcon(QIcon(":/Resources/icons/previous.png"));
    mpPreviuosButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
    connect(mpPreviuosButton, SIGNAL(clicked()), SLOT(findPreviuosText()));

    mpNextButton = new QToolButton;
    mpNextButton->setAutoRaise(true);
    mpNextButton->setText(tr("Next"));
    mpNextButton->setIcon(QIcon(":/Resources/icons/next.png"));
    mpNextButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
    connect(mpNextButton, SIGNAL(clicked()), SLOT(findNextText()));

    mpMatchCaseCheckBox = new QCheckBox(tr("Match case"));
    mpMatchWholeWordCheckBox = new QCheckBox(tr("Match whole word"));

    mpCloseButton = new QToolButton;
    mpCloseButton->setAutoRaise(true);
    mpCloseButton->setIcon(QIcon(":/Resources/icons/exit.png"));
    connect(mpCloseButton, SIGNAL(clicked()), SLOT(hideFindWidget()));

    mpLineNumberArea = new LineNumberArea(this);
    connect(this, SIGNAL(blockCountChanged(int)), this, SLOT(updateLineNumberAreaWidth(int)));
    connect(this, SIGNAL(updateRequest(QRect,int)), this, SLOT(updateLineNumberArea(QRect,int)));
    connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(highlightCurrentLine()));

    updateLineNumberAreaWidth(0);
    highlightCurrentLine();
    // make previous and next buttons disabled for first time
    updateButtons();
}
Пример #13
0
CCodeEditor::CCodeEditor(QWidget *parent) : QPlainTextEdit(parent)
{
	m_lineNumberArea = new CLineNumberArea(this);

	connect(this, SIGNAL(blockCountChanged(int)), this, SLOT(updateLineNumberAreaWidth(int)));
	connect(this, SIGNAL(updateRequest(QRect,int)), this, SLOT(updateLineNumberArea(QRect,int)));

	updateLineNumberAreaWidth(0);
}
Пример #14
0
//![constructor]
//class constructor which also connects functions to buttons and instantiates the lineNumberArea class
CodeEditor::CodeEditor(QWidget *parent) : QPlainTextEdit(parent)
{
    lineNumberArea = new LineNumberArea(this);
    connect(this, SIGNAL(blockCountChanged(int)), this, SLOT(updateLineNumberAreaWidth(int)));
    connect(this, SIGNAL(updateRequest(QRect,int)), this, SLOT(updateLineNumberArea(QRect,int)));
    connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(highlightCurrentLine()));
    updateLineNumberAreaWidth(0);
    highlightCurrentLine();
}
Пример #15
0
PgxEditor::PgxEditor(Database *database, QString editor_name)
{
    ++editor_widow_id;
    this->database = database;
    this->editor_name = editor_name;
    createActions();
    breakpointArea = new BreakPointArea(this);
    lineNumberArea = new LineNumberArea(this);
    setStyleSheet("QPlainTextEdit{background-color: white; font: bold 14px 'Courier New';}");
    highlighter = new Highlighter(document());

    toolbar = new QToolBar;
    toolbar->setIconSize(QSize(36,36));
    toolbar->setObjectName("pgxeditor");
    toolbar->setMovable(false);
    toolbar->addAction(newpgxeditor_action);
    toolbar->addAction(cut_action);
    toolbar->addAction(copy_action);
    toolbar->addAction(paste_action);
    if(!editor_name.isEmpty()) {
        toolbar->addSeparator();
        toolbar->addAction(save_action);
        toolbar->addSeparator();
        toolbar->addAction(execute_action);
    }
    toolbar->addSeparator();
    toolbar->addAction(selected_execute_action);
    toolbar->addAction(wrap_action);
    toolbar->addAction(find_action);

    pgxeditor_mainwin = new PgxEditorMainWindow;
    pgxeditor_mainwin->addToolBar(toolbar);
    pgxeditor_mainwin->setCentralWidget(this);
    pgxeditor_mainwin->setAttribute(Qt::WA_DeleteOnClose);

    find_bar = new QLineEdit;
    find_bar->setPlaceholderText(tr("Find"));
    find_bar->setVisible(false);
    pgxeditor_mainwin->statusBar()->setSizeGripEnabled(false);
    pgxeditor_mainwin->statusBar()->addPermanentWidget(casesensitivity_button, 0);
    pgxeditor_mainwin->statusBar()->addPermanentWidget(wholeword_button, 0);
    pgxeditor_mainwin->statusBar()->addPermanentWidget(backwards_button, 0);
    pgxeditor_mainwin->statusBar()->addPermanentWidget(find_bar);
    replace_bar = new QLineEdit;
    replace_bar->setPlaceholderText(tr("Replace"));
    replace_bar->setVisible(false);
    pgxeditor_mainwin->statusBar()->addPermanentWidget(replace_bar);

    connect(find_bar, SIGNAL(returnPressed()), this, SLOT(findText()));
    connect(replace_bar, SIGNAL(returnPressed()), this, SLOT(replaceText()));
    connect(this, SIGNAL(blockCountChanged(int)), this, SLOT(updateLineNumberAreaWidth(int)));
    connect(this, SIGNAL(updateRequest(QRect,int)), this, SLOT(updateLineNumberArea(QRect,int)));
    connect(this, SIGNAL(selectionChanged()), this, SLOT(selectionChangedSlot()));
    connect(this, SIGNAL(textChanged()), this, SLOT(textChangedSlot()));
    connect(pgxeditor_mainwin, SIGNAL(pgxeditorClosing()), this, SLOT(pgxeditorClosing()));
    updateLineNumberAreaWidth(0);
}
Пример #16
0
 void CodeEditor::updateLineNumberArea(const QRect &rect, int dy) {
     if (dy)
         lineNumberArea->scroll(0, dy);
     else
         lineNumberArea->update(0, rect.y(), lineNumberArea->width(), rect.height());

     if (rect.contains(viewport()->rect()))
         updateLineNumberAreaWidth(0);
 }
Пример #17
0
void BaseEditor::disableDisplayLineNumber()
{
    displayLineNumber = false;
    disconnect(this, SIGNAL(updateRequest(QRect,int)),
               this, SLOT(updateLineNumberArea(QRect,int)));
    disconnect(this, SIGNAL(blockCountChanged(int)),
               this, SLOT(updateLineNumberAreaWidth(int)));
    updateLineNumberAreaWidth(0);
    lineNumberArea->setVisible(false);
}
Пример #18
0
void MyTextEdit::updateLineNumberArea(const QRect &rect, int dy)
{
	if (dy)
		m_lineNumbers->scroll(0, dy);
	else
		m_lineNumbers->update(0, rect.y(), m_lineNumbers->width(), rect.height());

	if (rect.contains(viewport()->rect()))
		updateLineNumberAreaWidth(0);
}
Пример #19
0
//-----------------------------------------------------------------------------------------
void GenericTextEditorDocument::updateLineNumberArea(const QRect &rect, int dy)
{
    if(dy)
        mLineNumberArea->scroll(0, dy);
    else
        mLineNumberArea->update(0, rect.y(), mLineNumberArea->width(), rect.height());

    if (rect.contains(viewport()->rect()))
        updateLineNumberAreaWidth(0);
}
Пример #20
0
void CSVWorld::ScriptEdit::updateLineNumberArea(const QRect &rect, int dy)
{
    if (dy)
        mLineNumberArea->scroll(0, dy);
    else
        mLineNumberArea->update(0, rect.y(), mLineNumberArea->width(), rect.height());

    if (rect.contains(viewport()->rect()))
        updateLineNumberAreaWidth(0);
}
Пример #21
0
void MLScriptEditor::updateLineNumberArea( const QRect & r, int dy)
{
	if (dy)
		narea->scroll(0, dy);
	else
		narea->update(0, r.y(), narea->width(), r.height());

	if (r.contains(viewport()->rect()))
		updateLineNumberAreaWidth(0);
}
Пример #22
0
//-------------------------------------------------------------------------
CodeEditor::CodeEditor(QWidget *parent) : QPlainTextEdit(parent)
{
    lineNumberArea = new LineNumberArea(this);

    connect(this, SIGNAL(blockCountChanged(int)), this, SLOT(updateLineNumberAreaWidth(int)));
    connect(this, SIGNAL(updateRequest(const QRect &, int)), this, SLOT(updateLineNumberArea(const QRect &, int)));

    updateLineNumberAreaWidth(0);
	setTabStopWidth (20);
}
Пример #23
0
CodeEditor::CodeEditor(QWidget *parent) : QPlainTextEdit(parent){
    lineNumberArea = new LineNumberArea(this);

    findDialog_ = new FindDialog(this);
    findDialog_->setModal(false);
    findDialog_->setTextEdit(this);

    findReplaceDialog_ = new FindReplaceDialog(this);
    findReplaceDialog_->setModal(false);
    findReplaceDialog_->setTextEdit(this);

    qtScriptReservedWords_<<"break"<<"case"<<"catch"<<"continue"<<"debugger"<<"default"<<"delete"<<"do"<<"else"<<"finally"<<\
    "for"<<"function"<<"if"<<"in"<<"instanceof"<<"new"<<"return"<<"switch"<<"this"<<"throw"<<"try"<<\
    "typeof"<<"var"<<"void"<<"while"<<"with";

    syntaxHighlighter_ = new ScriptSyntaxHighlighter(this->document());

    s = Global::guiSettings(this);
    s->beginGroup("CodeEditor");
    QFont font = s->value("font",this->font()).value<QFont>();
    this->setFont(font);
    s->endGroup();

    findAction = new QAction("Find...",this);
    connect(findAction, SIGNAL(triggered()), this, SLOT(findDialog()));
    findAction->setShortcut(tr("Ctrl+F"));
    addAction(findAction);

    findReplaceAction = new QAction("Replace...",this);
    connect(findReplaceAction, SIGNAL(triggered()), this, SLOT(findReplaceDialog()));
    findReplaceAction->setShortcut(tr("Ctrl+R"));
    addAction(findReplaceAction);

    beautifyAction = new QAction("Beautify javascript code",this);
    connect(beautifyAction, SIGNAL(triggered()), this, SLOT(beautify()));
    beautifyAction->setShortcut(tr("Ctrl+B"));
    addAction(beautifyAction);


    connect(this, SIGNAL(blockCountChanged(int)), this, SLOT(updateLineNumberAreaWidth(int)));
    connect(this, SIGNAL(updateRequest(QRect,int)), this, SLOT(updateLineNumberArea(QRect,int)));
    connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(highlightCurrentLine()));

    updateLineNumberAreaWidth(0);
    highlightCurrentLine();

    completer_ = new QCompleter(this);
    completer_->setModel(modelFromStringList(qtScriptReservedWords_));
    completer_->setModelSorting(QCompleter::CaseInsensitivelySortedModel);
    completer_->setCaseSensitivity(Qt::CaseInsensitive);
    completer_->setWrapAround(false);
    this->setCompleter(completer_);

}
Пример #24
0
void ScriptEditBox::updateLineNumberArea(const QRect& rect, int deltaY) {
    if (deltaY) {
        _scriptLineNumberArea->scroll(0, deltaY);
    } else {
        _scriptLineNumberArea->update(0, rect.y(), _scriptLineNumberArea->width(), rect.height());
    }

    if (rect.contains(viewport()->rect())) {
        updateLineNumberAreaWidth(0);
    }
}
Пример #25
0
void CodeEditor::updateLineNumberArea(const QRect &rect, int dy)
{
    if (dy)
        lineNumberArea->scroll(0, dy);
    else
        lineNumberArea->update(0, rect.y(), lineNumberArea->width(), rect.height());
        //indirectly invokes CodeEditor::lineNumberAreaPaintEvent() throw virtual LineNumberArea::paintEvent()

    if (rect.contains(viewport()->rect())) //viewport - visible part of widget
        updateLineNumberAreaWidth(0);
}
Пример #26
0
CodeEditor::CodeEditor(QWidget *parent) : QPlainTextEdit(parent),
    defaultSelectionColor(QColor(240,230,140).lighter(130)),backGroundColor(Qt::white),lineAreaBGColor(240,248,255) {
     lineNumberArea = new LineNumberArea(this);

     connect(this, SIGNAL(blockCountChanged(int)), this, SLOT(updateLineNumberAreaWidth(int)));
     connect(this, SIGNAL(updateRequest(QRect,int)), this, SLOT(updateLineNumberArea(QRect,int)));
     connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(highlightCurrentLine()));

     updateLineNumberAreaWidth(0);
     highlightCurrentLine();
 }
Пример #27
0
ScriptEditBox::ScriptEditBox(QWidget* parent) :
    QPlainTextEdit(parent)
{
    _scriptLineNumberArea = new ScriptLineNumberArea(this);

    connect(this, &ScriptEditBox::blockCountChanged, this, &ScriptEditBox::updateLineNumberAreaWidth);
    connect(this, &ScriptEditBox::updateRequest, this, &ScriptEditBox::updateLineNumberArea);
    connect(this, &ScriptEditBox::cursorPositionChanged, this, &ScriptEditBox::highlightCurrentLine);

    updateLineNumberAreaWidth(0);
    highlightCurrentLine();
}
Пример #28
0
//-----------------------------------------------------------------------------
TextEdit::TextEdit(QWidget *parent) : QTextEdit(parent)
{
	c=0;
	connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(highlight()));
	// Line numbers
	lineNumberArea = new LineNumberArea(this);
	connect(document(), SIGNAL(blockCountChanged(int)), this, SLOT(updateLineNumberAreaWidth(int)));
	connect(document(), SIGNAL(blockCountChanged(int)), this, SLOT(updateLineNumberArea(int)));
	connect(verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(updateLineNumberArea(int)));
	connect(this, SIGNAL(textChanged()), this, SLOT(updateLineNumberArea()));
	connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(updateLineNumberArea()));
	updateLineNumberAreaWidth(0);
}
Пример #29
0
CodeEditor::CodeEditor(QWidget *parent) : QPlainTextEdit(parent)
{
    lineNumberArea = new LineNumberArea(this);
    setFont(QFont("Ubuntu Mono"));

    connect(this, SIGNAL(blockCountChanged(int)), this, SLOT(updateLineNumberAreaWidth(int)));
    connect(this, SIGNAL(updateRequest(QRect,int)), this, SLOT(updateLineNumberArea(QRect,int)));
    connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(highlightCurrentLine()));

    updateLineNumberAreaWidth(0);
    highlightCurrentLine();
    sh = new SLHSyntaxHighlighter(this->document());
}
Пример #30
0
CodeEditor::CodeEditor(QWidget *parent) : QPlainTextEdit(parent)
{
    this->setWordWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere);

    lineNumberArea = new LineNumberArea(this);

    connect(this, SIGNAL(blockCountChanged(int)), this, SLOT(updateLineNumberAreaWidth(int)));
    connect(this, SIGNAL(updateRequest(QRect,int)), this, SLOT(updateLineNumberArea(QRect,int)));
    connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(highlightCurrentLine()));

    updateLineNumberAreaWidth(0);
    highlightCurrentLine();
}