GoDocument::GoDocument() { setId(Constants::GOEDITOR_ID); setSyntaxHighlighter(new GoHighlighter); setIndenter(new GoIndenter); //setCompletionAssistProvider(new GoCompletionAssistProvider); // TODO: Doesn't work. Why? m_completionAssistProvider = new GoCompletionAssistProvider; }
CPPEditorDocument::CPPEditorDocument() { setId(CppEditor::Constants::CPPEDITOR_ID); connect(this, SIGNAL(tabSettingsChanged()), this, SLOT(invalidateFormatterCache())); connect(this, SIGNAL(mimeTypeChanged()), this, SLOT(onMimeTypeChanged())); setSyntaxHighlighter(new CppHighlighter); onMimeTypeChanged(); }
TextEditWidget::TextEditWidget( QWidget* parentWidget, QToolBar* toolbar ) : QFrame( parentWidget ) , m_highlighter( NULL ) { QVBoxLayout* mainLayout = new QVBoxLayout( this ); mainLayout->setMargin( 0 ); mainLayout->setSpacing( 1 ); setLayout( mainLayout ); // add our own stuff to the specified toolbar if ( toolbar ) { QString iconsDir = ResourcesManager::getInstance().getFilesystem().getShortcut( "editorIcons" ).c_str(); // add edition-related actions m_toggleSelectionHighlightAction = toolbar->addAction( QIcon( iconsDir + "highlightSelection.png" ), tr( "Highlight selection" ) ); toolbar->addSeparator(); } // create the main text editor are that will become a host to a list of lines and the text editor QFrame* textEditFrame = new QFrame( this ); { mainLayout->addWidget( textEditFrame, 1 ); QHBoxLayout* textEditLayout = new QHBoxLayout( textEditFrame ); textEditLayout->setMargin( 0 ); textEditLayout->setSpacing( 1 ); textEditFrame->setLayout( textEditLayout ); // setup the lines list widget { m_lineNumbers = new LinesWidget( textEditFrame ); textEditLayout->addWidget( m_lineNumbers, 0, Qt::AlignLeft ); } // setup the text editor widget { m_editor = new CodeEditorWidget( textEditFrame ); textEditLayout->addWidget( m_editor, 1 ); m_editor->setLineWrapMode( QPlainTextEdit::NoWrap ); connect( m_editor->document(), SIGNAL( contentsChange( int, int, int ) ), this, SLOT( onTextChanged( int, int, int ) ) ); connect( m_editor, SIGNAL( cursorPositionChanged() ), this, SLOT( onTextCursorMoved() ) ); connect( m_editor, SIGNAL( selectionChanged() ), this, SLOT( onSelectionChanged() ) ); connect( m_editor, SIGNAL( updateRequest( QRect, int ) ), m_lineNumbers, SLOT( updateArea( QRect, int ) ) ); // make sure we synchronize the scrollbars between the lines list and the editor QScrollBar* editorScrollBar = m_editor->verticalScrollBar(); connect( editorScrollBar, SIGNAL( valueChanged( int ) ), this, SLOT( documentScrolled( int ) ) ); // setup the syntax highlighter setSyntaxHighlighter( new TextSyntaxHighlighter() ); } // inform the line numbers widget about the editor m_lineNumbers->setTextEditor( m_editor ); } // add a status bar underneath the main editor are m_statusBar = new QLabel( this ); mainLayout->addWidget( m_statusBar, 0, Qt::AlignBottom ); }
ProFileDocument::ProFileDocument() { setId(Constants::PROFILE_EDITOR_ID); setMimeType(QLatin1String(Constants::PROFILE_MIMETYPE)); setSyntaxHighlighter(new ProFileHighlighter); }