void QsciEditor::setAutoLexer() {

	QString sfx = QFileInfo( mFilePath ).suffix();
	QMimeType mimeType = mimeDb.mimeTypeForFile( mFilePath );

	if ( mimeType.name().contains( "python" ) )
		setLexer( new QLexerPython() );

	else if ( mimeType.name().contains( "html" ) )
		setLexer( new QsciLexerHTML() );

	else if ( mimeType.name().contains( "tex" ) )
		setLexer( new QsciLexerLaTeX() );

	else if ( mimeType.name().contains( "makefile" ) )
		setLexer( new QsciLexerMakefile() );

	else if ( mimeType.name().contains( "xml" ) )
		setLexer( new QsciLexerHTML() );

	else if ( mimeType.name().contains( "shell" ) )
		setLexer( new QsciLexerBash() );

	else if ( QStringList( QStringList() << "c" << "cc" << "cpp" << "h" << "hh" << "hpp" ).contains( sfx ) )
		setLexer( new QsciLexerCPP() );

	else
		setLexer( new QLexerDefault() );
};
Beispiel #2
0
void QgsCodeEditorHTML::setSciLexerHTML()
{
  QsciLexerHTML* lexer = new QsciLexerHTML( this );
  lexer->setDefaultFont( QFont( "Sans", 10 ) );

  setLexer( lexer );
}
Beispiel #3
0
bool MainWindow::saveAs() {
  if (tabWidget->count()) {
    QString fileName = QFileDialog::getSaveFileName(this, "Save - QSciTE", (openFiles.size() > 0 && !getCurFileObj()->path.isEmpty()) ? getCurFileObj()->path : lastDir);

    if (fileName.isEmpty()) {
      return false;
    }

    bool success = saveFile(fileName);
    if (success) {
      addRecentFile(fileName);
      getCurFileObj()->setPathName(fileName);
      setCurrentTabTitle();
      setWindowTitleForFile(getCurFileObj()->baseName);
      lastDir = getCurFileObj()->path;
      QsciteEditor * curDoc = getCurDoc();
      QsciLexer * newLexer = getLexerForDocument(fileName, curDoc->text());
      if (newLexer != NULL) {
/*
        QFont curFont = curDoc->font();
        setLexerFont(newLexer, curFont.family(), curFont.pointSize());
        newLexer->setParent(curDoc);
        curDoc->setLexer(newLexer);
        curDoc->recolor();
*/
        setLexer(newLexer);
      }
    }
    return success;
  }

  return false;
}
Beispiel #4
0
/**
 * Constructor
 * @param parent :: The parent widget (can be NULL)
 * @param codelexer :: define the syntax highlighting and code completion.
 * @param settingsGroup :: Used when saving settings to persistent store
 */
ScriptEditor::ScriptEditor(QWidget *parent, QsciLexer *codelexer, const QString & settingsGroup) :
  QsciScintilla(parent), m_filename(""), m_progressArrowKey(markerDefine(QsciScintilla::RightArrow)),
  m_currentExecLine(0), m_completer(NULL),m_previousKey(0),
  m_findDialog(new FindReplaceDialog(this)), m_settingsGroup(settingsGroup)
{
  // Older versions of QScintilla still use just CR as the line ending, which is pre-OSX.
  // New versions just use unix-style for everything but Windows.
#if defined(Q_OS_WIN)
  setEolMode(EolWindows);
#else
  setEolMode(EolUnix);
#endif

  //Syntax highlighting and code completion
  setLexer(codelexer);
  readSettings();

  setMarginLineNumbers(1,true);

  //Editor properties
  setAutoIndent(true);
  setFocusPolicy(Qt::StrongFocus);

  emit undoAvailable(isUndoAvailable());
  emit redoAvailable(isRedoAvailable());
}
Beispiel #5
0
void QgsCodeEditorCSS::setSciLexerCSS()
{
  QsciLexerCSS* lexer = new QsciLexerCSS( this );
  lexer->setDefaultFont( QFont( QStringLiteral( "Sans" ), 10 ) );

  setLexer( lexer );
}
Beispiel #6
0
bool pEditor::openFile( const QString& fileName, const QString& codec )
{
    /*if ( isModified() )
        return false;*/

    QApplication::setOverrideCursor( Qt::WaitCursor );
    
    // open file
    QFile f( fileName );
    if ( !f.open( QFile::ReadOnly ) )
    {
        MonkeyCore::messageManager()->appendMessage( tr( "Cannot read file %1:\n%2." ).arg( fileName ).arg( f.errorString() ) );
        QApplication::restoreOverrideCursor();
        return false;
    }

    // remember filename
    setProperty( "fileName", fileName );
    setProperty( "codec", codec );

    // set lexer and apis
    setLexer( pMonkeyStudio::lexerForFileName( fileName ) );

    // set properties
    pMonkeyStudio::setEditorProperties( this );

    // load file
    QTextCodec* c = QTextCodec::codecForName( codec.toUtf8() );
    QString datas = c->toUnicode( f.readAll() );
    setText( datas );
    setModified( false );

    // convert tabs if needed
    if ( pMonkeyStudio::convertTabsUponOpen() )
        convertTabs();
    
    //autodetect indent, if need
    if ( pMonkeyStudio::autoDetectIndent() )
    {
        autoDetectIndent ();
    }
    
    //autodetect eol, if need
    if ( pMonkeyStudio::autoDetectEol() )
    {
        autoDetectEol();
    }
    
    // make backup if needed
    if ( pMonkeyStudio::createBackupUponOpen() )
        makeBackup();

    // convert eol
    if ( pMonkeyStudio::autoEolConversion() )
        convertEols( eolMode() );
    
    QApplication::restoreOverrideCursor();
    
    return true;
}
Beispiel #7
0
void MdiChild::setCurrentFile(const QString &fileName)
{
    curFile = QFileInfo(fileName).canonicalFilePath();
    curFileDate = QFileInfo(fileName).lastModified();
    isUntitled = false;
    setModified(false);
    setWindowModified(false);
    setWindowTitle(userFriendlyCurrentFile() + "[*]");

    if ((curFile.contains(".vhd"))||(curFile.contains(".vhdl")))
    {
        if (!dynamic_cast<QsciLexerVHDL *>(lexer))
        {
            if (lexer)
                delete lexer;
            lexer=new QsciLexerVHDL();
        }
    }
    else //if ((curFile.contains(".sv"))||(curFile.contains(".svh")))
    {
        if (!dynamic_cast<QsciLexerSystemVerilog *>(lexer))
        {
            if (lexer)
                delete lexer;
            lexer = new QsciLexerSystemVerilog();
            lexer->setColor(QColor(200,0,0),QsciLexerSystemVerilog::KeywordUvmMacro);
        }
    }

    QVariant var=UVESettings::getInstance()->value(CONF_FONT,QVariant(DEFAULT_FONT));
    lexer->setFont(var.value<QFont>());
    setLexer(lexer);
}
Beispiel #8
0
void DocumentEditor::setLanguage(const QString &language_) {
	QsciLexer* l = lexer();
	//detach lexer from document before delete it
	setLexer(0);
	if(l != 0) {
		delete l;
		l = 0;
	}

	//set the new lexer
	l = LexerManager::getInstance().lexerFactory(language_, this);
	setLexer(l);

	//reload settings for lexer
	Settings settings;
	settings.applyToDocument(this);
}
Beispiel #9
0
bool SciDoc::saveAs(const QString& fileName, QString& error) {
	bool result = Document::saveAs(fileName, error);
	if ( result ) {
		QString lexName = LexerStorage::instance()->lexerName(this->fileName());
		setLexer(lexName);
	}
	return result;
}
Beispiel #10
0
void fileviewer::init(void)
{
	m_pushButtonPaste->setEnabled(false);
	m_pushButtonPrev->setEnabled(false);
	m_pushButtonNext->setEnabled(false);
	m_pushButtonTextShrink->setEnabled(false);
	m_pushButtonTextEnlarge->setEnabled(false);
	m_pushButtonGoToLine->setEnabled(false);
	m_pushButtonOpenInEditor->setEnabled(false);
	m_labelFilePath->clear();
	m_textEditSource->clear();
	m_textEditSource->setWrapMode(QsciScintilla::WrapNone);
	m_textEditSource->setReadOnly(true);
	m_markerhandle = m_textEditSource->markerDefine(QsciScintilla::Background);
	m_markerhandle2 = m_textEditSource->markerDefine(QsciScintilla::RightArrow);
	m_textEditSource->setMarginType(0, QsciScintilla::NumberMargin);
	m_textEditSource->setMarginType(1, QsciScintilla::SymbolMargin);
	m_textEditSource->setBraceMatching(QsciScintilla::SloppyBraceMatch);
	m_textEditSource->setAnnotationDisplay(QsciScintilla::AnnotationBoxed);
	setLexer(enHighlightCPP);
	createFontList(); 
	connect(m_textEditSource, SIGNAL(copyAvailable(bool)),
			this, SLOT(AbleToCopy(bool)));
	connect(m_pushButtonGoToLine, SIGNAL(clicked(bool)),
			this, SLOT(GoToLine_ButtonClick(bool)));
	connect(m_pushButtonPaste, SIGNAL(clicked(bool)),
			this, SLOT(Paste_ButtonClick(bool)));
	connect(m_pushButtonPrev, SIGNAL(clicked(bool)),
			this, SLOT(Prev_ButtonClick(bool)));
	connect(m_pushButtonNext, SIGNAL(clicked(bool)),
			this, SLOT(Next_ButtonClick(bool)));
	connect(m_pushButtonOpenInEditor, SIGNAL(clicked(bool)),
			this, SLOT(OpenInEditor_ButtonClick(bool)));
	connect(m_pushButtonTextShrink, SIGNAL(clicked(bool)),
			this, SLOT(TextShrink_ButtonClick(bool)));
	connect(m_pushButtonTextEnlarge, SIGNAL(clicked(bool)),
			this, SLOT(TextEnlarge_ButtonClick(bool)));
	connect(m_listWidgetFunc, SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)),
			this, SLOT(funcItemSelected(QListWidgetItem *, QListWidgetItem *)));
	connect(m_comboBoxFuncListSort, SIGNAL(currentIndexChanged(int)),
			this, SLOT(FuncListSort_indexChanged(int)));
	m_fileDataList.clear();
	setLexer();
}
Beispiel #11
0
BaseShell::BaseShell(core::connectionTypes type, bool showAutoCompl, QWidget* parent)
    : gui::FastoEditorShell(showAutoCompl, parent) {
  VERIFY(connect(this, &BaseShell::customContextMenuRequested, this, &BaseShell::showContextMenu));
  BaseQsciLexer* lex = nullptr;
#ifdef BUILD_WITH_REDIS
  if (type == core::REDIS) {
    lex = new redis::Lexer(this);
  }
#endif
#ifdef BUILD_WITH_MEMCACHED
  if (type == core::MEMCACHED) {
    lex = new memcached::Lexer(this);
  }
#endif
#ifdef BUILD_WITH_SSDB
  if (type == core::SSDB) {
    lex = new ssdb::Lexer(this);
  }
#endif
#ifdef BUILD_WITH_LEVELDB
  if (type == core::LEVELDB) {
    lex = new leveldb::Lexer(this);
  }
#endif
#ifdef BUILD_WITH_ROCKSDB
  if (type == core::ROCKSDB) {
    lex = new rocksdb::Lexer(this);
  }
#endif
#ifdef BUILD_WITH_UNQLITE
  if (type == core::UNQLITE) {
    lex = new unqlite::Lexer(this);
  }
#endif
#ifdef BUILD_WITH_LMDB
  if (type == core::LMDB) {
    lex = new lmdb::Lexer(this);
  }
#endif
#ifdef BUILD_WITH_UPSCALEDB
  if (type == core::UPSCALEDB) {
    lex = new upscaledb::Lexer(this);
  }
#endif
  registerImage(BaseQsciLexer::Command,
                gui::GuiFactory::instance().commandIcon(type).pixmap(image_size));

  if (!lex) {
    NOTREACHED();
    return;
  }

  setLexer(lex);
  lex->setFont(gui::GuiFactory::instance().font());
}
Beispiel #12
0
SqlEditorWidget::SqlEditorWidget(QWidget * parent)
    : QsciScintilla(parent),
      m_searchText(""),
      m_searchIndicator(9) // see QsciScintilla docs
{
    m_prefs = Preferences::instance();

    setMarginLineNumbers(0, true);
    setBraceMatching(SloppyBraceMatch);
    setAutoIndent(true);

    QsciLexerSQL * lexer = new QsciLexerSQL(this);

    QsciAPIs * api = new QsciAPIs(lexer);
    if (!api->load(":/api/sqlite.api"))
        qDebug("api is not loaded");
    else
    {
        api->prepare();
        lexer->setAPIs(api);
    }
    setAutoCompletionSource(QsciScintilla::AcsAll);
    setAutoCompletionCaseSensitivity(false);
    setAutoCompletionReplaceWord(true);

    setCaretLineVisible(m_prefs->activeHighlighting());
    setCaretLineBackgroundColor(m_prefs->activeHighlightColor());
    setUtf8(true);

    setFolding(QsciScintilla::BoxedFoldStyle);
    lexer->setFoldComments(true);
    lexer->setFoldCompact(false);

    setLexer(lexer);

    // search all occurrences
    // allow indicator painting *under* the text (but it makes editor slower a bit...)
    // It paints a colored box under the text for all occurrences of m_searchText.
    SendScintilla(QsciScintilla::SCI_SETTWOPHASEDRAW, 1);
    SendScintilla(QsciScintilla::SCI_INDICSETSTYLE, m_searchIndicator, QsciScintilla::INDIC_ROUNDBOX);
    // TODO/FIXME: make it configurable
    SendScintilla(QsciScintilla::SCI_INDICSETFORE, m_searchIndicator, QColor(255, 230, 90, 100));
    SendScintilla(QsciScintilla::SCI_INDICSETUNDER, m_searchIndicator, 1);
    // end of search all occurrences

    connect(this, SIGNAL(linesChanged()),
            this, SLOT(linesChanged()));
    connect(this, SIGNAL(cursorPositionChanged(int, int)),
            this, SLOT(cursorPositionChanged(int, int)));

    setCursorPosition(0, 0);
    linesChanged();
    prefsChanged();
}
Beispiel #13
0
void fileviewer::updateTextEdit(void)
{
	if (m_iter == m_fileDataList.end()) return;
	QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
	m_textEditSource->clear();

	QFile file(m_iter->filename);
	if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
	{
		QApplication::restoreOverrideCursor();
		return;
	}
	QTextStream in(&file);

	int lang = enHighlightCPP; // default

	QRegExp rx1("\\.py$", Qt::CaseInsensitive);
	int pos = rx1.indexIn(m_iter->filename);
	if (pos != -1) lang = enHighlightPython;

	QRegExp rx2("\\.java$", Qt::CaseInsensitive);
	pos = rx2.indexIn(m_iter->filename);
	if (pos != -1) lang = enHighlightJava;

	QRegExp rx3("\\.rb$", Qt::CaseInsensitive);
	pos = rx3.indexIn(m_iter->filename);
	if (pos != -1) lang = enHighlightRuby;

	QRegExp rx4("\\.js$", Qt::CaseInsensitive);
	pos = rx4.indexIn(m_iter->filename);
	if (pos != -1) lang = enHighlightJavascript;

	m_currentlang = lang;
	setLexer(lang);

	QString alltext;
	while (!in.atEnd())
	{
		alltext = in.readAll();
	}
	m_textEditSource->setText(alltext);
	m_textEditSource->setMarginWidth(0,  QString::number(m_textEditSource->lines() * 10));
	highlightLine(m_iter->linenum.toInt());
	updateFilePathLabel();
	m_pushButtonGoToLine->setEnabled(true);
	m_pushButtonOpenInEditor->setEnabled(true);
	m_pushButtonTextShrink->setEnabled(true);
	m_pushButtonTextEnlarge->setEnabled(true);
	m_listWidgetFunc->clear();
	if (m_iter->fileid < 0)	{emit requestFuncList_filename(m_iter->filename);}
	else {emit requestFuncList_fileid(m_iter->fileid);}
	QApplication::restoreOverrideCursor();
}
Beispiel #14
0
SourceEditor::SourceEditor(QWidget *parent) :
    QsciScintilla(parent)
{
    setLexer(new QsciLexerPerl(this)); // only Perl for now :(
    setAutoIndent(true);
    setMarginLineNumbers(NumberMargin, true);
    setMarginWidth(NumberMargin, "3 ");
    setBraceMatching(SloppyBraceMatch);
    setUtf8(true);

    m_marginWidth = 1;
    connect(this, SIGNAL(linesChanged()), this, SLOT(linesCountChanged()));
}
Beispiel #15
0
void SciDoc::setSyntax(const QString& lexName) {
//	LOGGER;

	if ( lexName.isEmpty() )
		return;

	QString oldSyntax = int_->syntax_;
	setLexer(lexName);
//	updateClone();

	// notify plugins
	emit syntaxChanged(oldSyntax);
}
Beispiel #16
0
void QgsCodeEditorSQL::setSciLexerSQL()
{
  QFont font = getMonospaceFont();

  QsciLexerSQL* sqlLexer = new QsciLexerSQL( this );
  sqlLexer->setDefaultFont( font );
  sqlLexer->setFont( font, -1 );
  font.setBold( true );
  sqlLexer->setFont( font, QsciLexerSQL::Keyword );
  sqlLexer->setColor( Qt::darkYellow, QsciLexerSQL::DoubleQuotedString ); // fields

  setLexer( sqlLexer );
}
void QgsCodeEditorHTML::setSciLexerHTML()
{
  QFont font = getMonospaceFont();
#ifdef Q_OS_MAC
  // The font size gotten from getMonospaceFont() is too small on Mac
  font.setPointSize( QLabel().font().pointSize() );
#endif

  QsciLexerHTML *lexer = new QsciLexerHTML( this );
  lexer->setDefaultFont( font );
  lexer->setFont( font, -1 );
  setLexer( lexer );
}
Beispiel #18
0
    SsdbShell::SsdbShell(bool showAutoCompl, QWidget* parent)
        : FastoEditorShell(common::convertFromString<QString>(SsdbLexer::version()), showAutoCompl, parent)
    {
        SsdbLexer* red = new SsdbLexer(this);

        registerImage(SsdbLexer::Command, GuiFactory::instance().commandIcon(SSDB).pixmap(QSize(64,64)));
        registerImage(SsdbLexer::HelpKeyword, GuiFactory::instance().messageBoxQuestionIcon().pixmap(QSize(64,64)));

        setLexer(red);
        setAllCommands(ALL_COMMANDS);

        VERIFY(connect(this, &SsdbShell::customContextMenuRequested, this, &SsdbShell::showContextMenu));
    }
Beispiel #19
0
void fileviewer::init(void)
{
	m_pushButtonPaste->setEnabled(false);
	m_pushButtonPrev->setEnabled(false);
	m_pushButtonNext->setEnabled(false);
	m_pushButtonTextShrink->setEnabled(false);
	m_pushButtonTextEnlarge->setEnabled(false);
	m_pushButtonGoToLine->setEnabled(false);
	m_pushButtonOpenInEditor->setEnabled(false);
	m_labelFilePath->clear();
	m_textEditSource->clear();
	m_textEditSource->setWrapMode(QsciScintilla::WrapNone);
	m_textEditSource->setReadOnly(true);
	m_markerhandle = m_textEditSource->markerDefine(QsciScintilla::RightArrow);
	m_textEditSource->setMarginType(0, QsciScintilla::NumberMargin);
	m_textEditSource->setMarginType(1, QsciScintilla::SymbolMargin);
	setLexer(enHighlightCPP);
	createFontList(); 
	connect(m_textEditSource, SIGNAL(copyAvailable(bool)),
			this, SLOT(AbleToCopy(bool)));
	connect(m_pushButtonGoToLine, SIGNAL(clicked(bool)),
			this, SLOT(GoToLine_ButtonClick(bool)));
	connect(m_pushButtonPaste, SIGNAL(clicked(bool)),
			this, SLOT(Paste_ButtonClick(bool)));
	connect(m_pushButtonPrev, SIGNAL(clicked(bool)),
			this, SLOT(Prev_ButtonClick(bool)));
	connect(m_pushButtonNext, SIGNAL(clicked(bool)),
			this, SLOT(Next_ButtonClick(bool)));
	connect(m_pushButtonOpenInEditor, SIGNAL(clicked(bool)),
			this, SLOT(OpenInEditor_ButtonClick(bool)));
	connect(m_pushButtonTextShrink, SIGNAL(clicked(bool)),
			this, SLOT(TextShrink_ButtonClick(bool)));
	connect(m_pushButtonTextEnlarge, SIGNAL(clicked(bool)),
			this, SLOT(TextEnlarge_ButtonClick(bool)));
	m_fileDataList.clear();
	setLexer();
}
Beispiel #20
0
bool codeEditor::open(QString name)
{
    QFile file;
    QFileInfo fileInfo;
    file.setFileName(name);
    fileInfo.setFile(file);

    if(file.open(QIODevice::ReadWrite|QIODevice::Text))
    {
        if(!read(&file))
            return false;

        file_path=name;

        name=fileInfo.suffix();
        if(name=="cpp"||name=="c")
            setLexer(new QsciLexerCPP);
        else if(name=="pas")
            setLexer(new QsciLexerPascal);
        return true;
    }

    return false;
}
void QgsCodeEditorExpression::initializeLexer()
{
  QFont font = getMonospaceFont();
#ifdef Q_OS_MAC
  // The font size gotten from getMonospaceFont() is too small on Mac
  font.setPointSize( QLabel().font().pointSize() );
#endif
  mSqlLexer = new QgsLexerExpression( this );
  mSqlLexer->setDefaultFont( font );
  mSqlLexer->setFont( font, -1 );
  font.setBold( true );
  mSqlLexer->setFont( font, QsciLexerSQL::Keyword );
  mSqlLexer->setColor( Qt::darkYellow, QsciLexerSQL::DoubleQuotedString ); // fields

  setLexer( mSqlLexer );
}
Beispiel #22
0
void QgsCodeEditorSQL::setSciLexerSQL()
{
  QFont font = getMonospaceFont();
#ifdef Q_OS_MAC
  // The font size gotten from getMonospaceFont() is too small on Mac
  font.setPointSize( QLabel().font().pointSize() );
#endif
  QsciLexerSQL* sqlLexer = new QgsCaseInsensitiveLexerSQL( this );
  sqlLexer->setDefaultFont( font );
  sqlLexer->setFont( font, -1 );
  font.setBold( true );
  sqlLexer->setFont( font, QsciLexerSQL::Keyword );
  sqlLexer->setColor( Qt::darkYellow, QsciLexerSQL::DoubleQuotedString ); // fields

  setLexer( sqlLexer );
}
Beispiel #23
0
Test4Window::Test4Window(const QString &sql)
    : Ui::Test4Window()
{
    Ui::Test4Window::setupUi(this);

    QToolBar *toolBar = QMainWindow::addToolBar("TB");
    toolBar->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed));
    toolBar->setFocusPolicy(Qt::NoFocus);

    pushButton = new QPushButton("Oracle", toolBar);
    pushButton->setFlat(true);
    toolBar->addWidget(pushButton);
    connect(pushButton, SIGNAL(released()), this, SLOT(setLexer()));

    QAction *oracle = new QAction("Oracle", this);
    QAction *mysql = new QAction("MySQL", this);
    oracle->setCheckable(true);
    oracle->setChecked(true);
    mysql->setCheckable(true);
    mysql->setChecked(false);
    QActionGroup* group = new QActionGroup(this);
    oracle->setActionGroup(group);
    mysql->setActionGroup(group);
    menuGrammar->addAction(oracle);
    menuGrammar->addAction(mysql);

    editorLeft = new toSqlText(this);
    leftVerticalLayout->addWidget(editorLeft);
    editorLeft->setText(sql);
    editorLeft->enableToolTips();

    editorRight = new toSqlText(this);
    editorRight->setHighlighter(toSqlText::Oracle);
    rightVerticalLayout->addWidget(editorRight);
    editorRight->setText(sql);
    editorRight->setMarginType(2, QsciScintilla::TextMarginRightJustified);
    editorRight->setMarginWidth(2, QString::fromLatin1("009"));
    editorRight->enableToolTips();

    connect(oracle, SIGNAL(triggered()), this, SLOT(setOracle()));
    connect(mysql, SIGNAL(triggered()), this, SLOT(setMySQL()));

    connect(actionLoad, SIGNAL(triggered()), this, SLOT(load()));
    connect(actionQuit, SIGNAL(triggered()), this, SLOT(close()));

    QMainWindow::show();
}
Beispiel #24
0
void MdiChild::newFile()
{
    static int sequenceNumber = 1;
    isUntitled = true;
    curFile = tr("document%1.sv").arg(sequenceNumber++);
    lexer=new QsciLexerSystemVerilog();

     QVariant var=UVESettings::getInstance()->value(CONF_FONT,DEFAULT_FONT);
     lexer->setFont(var.value<QFont>());

    setLexer(lexer);

    //setCurrentFile(curFile);
    curFileDate= QDateTime();
    setWindowTitle(curFile + "[*]");
    CONNECT(this, SIGNAL(textChanged()), this, SLOT(documentWasModified()));
}
Beispiel #25
0
DocumentEditor::DocumentEditor(DocumentEditor* document_, QWidget *parent_) : ScintillaExt(parent_), _watcher(document_->_watcher) {
	_notified = true;
	//codec
	setUtf8(true);
	_codec = document_->_codec;
	_bomMode = document_->_bomMode;
	_hasBom = document_->_hasBom;
	_charsetAutoDetect = document_->_charsetAutoDetect;

	//document info
	_autoDetectEol = document_->_autoDetectEol;
	_autoDetectIndent = document_->_autoDetectIndent;
	_isNew = document_->isNew();
	_fullPath = document_->getFullPath();

	setDocument(document_->document());

	_clone = document_;
	_isCloned = true;
	document_->_clone = this;
	document_->_isCloned = true;

	QsciLexer* l = document_->lexer();
	if(l != 0) {
		QString lexLang = l->language();
		QsciLexer* newLex = LexerManager::getInstance().lexerFactory(lexLang, this);
		if(newLex == 0) {
			//could not find the lexer
			newLex = LexerManager::getInstance().getAutoLexer(this);
		}
		setLexer(newLex);
	}

	//macro
	_macro = new QsciMacro(this);

	//load settings
	Settings settings;
	settings.applyToDocument(this);

	markerDefine(QPixmap(":/images/ledblue.png").scaled(40,16, Qt::KeepAspectRatio, Qt::SmoothTransformation), MARKER_BOOK);

	//connection
	connect(this, SIGNAL(marginClicked(int,int, Qt::KeyboardModifiers)), this, SLOT(toggleBookmark(int,int, Qt::KeyboardModifiers)));
}
Beispiel #26
0
/**
 * Constructor
 * @param parent :: The parent widget (can be NULL)
 * @param codelexer :: define the syntax highlighting and code completion.
 * @param settingsGroup :: Used when saving settings to persistent store
 */
ScriptEditor::ScriptEditor(QWidget *parent, QsciLexer *codelexer, const QString & settingsGroup) :
  QsciScintilla(parent), m_filename(""), m_progressArrowKey(markerDefine(QsciScintilla::RightArrow)),
  m_currentExecLine(0), m_completer(NULL),m_previousKey(0),
  m_findDialog(new FindReplaceDialog(this)), m_settingsGroup(settingsGroup)
{
  //Syntax highlighting and code completion
  setLexer(codelexer);
  readSettings();

  setMarginLineNumbers(1,true);

  //Editor properties
  setAutoIndent(true);
  setFocusPolicy(Qt::StrongFocus);

  emit undoAvailable(isUndoAvailable());
  emit redoAvailable(isRedoAvailable());
}
Beispiel #27
0
void chanEditorWidget::init(){
	m_action = new QAction(this);

	m_action->setCheckable(true);

	connect(m_action, SIGNAL(triggered()), this, SLOT(show()));
	connect(m_action, SIGNAL(triggered()), this, SLOT(setFocus()));

	connect(this, SIGNAL(textChanged()), this, SLOT(documentWasModified()));


	QsciLexerCPP* lexer = new QsciLexerCPP(this);

	setLexer(lexer);

	//设置边框行号
	setMarginLineNumbers(1, true);

	//精确的括号匹配
	setBraceMatching(QsciScintilla::BraceMatch::StrictBraceMatch);

	//设置折叠
	setFolding(QsciScintilla::FoldStyle::CircledTreeFoldStyle);

	//设置自动填充有效
	setAutoCompletionFillupsEnabled(true);

	//所有可能的来源
	setAutoCompletionSource(QsciScintilla::AcsAll);

	//补字符号
	setCaretLineVisible(true);

	setAutoIndent(true);

	setUtf8(true);

	setWhitespaceVisibility(QsciScintilla::WsVisible);

	setAttribute(Qt::WA_DeleteOnClose);
}
Beispiel #28
0
void fileviewer::fileViewSettings_Triggered(bool checked)
{
	cqDialogFileViewSettings cqdg((QWidget*)mw, this,
		m_fontlist, themes::getThemesList());
	m_fonttemp = m_textEditSourceFont.family();
	m_fontwidthtemp = (m_textEditSource->tabWidth());
	m_themetemp = m_theme;
	cqdg.setCurrentFontType(m_fonttemp);
	cqdg.setTabWidth(m_fontwidthtemp);
	cqdg.setCurrentTheme(m_themetemp);
	cqdg.setModal(true);
	cqdg.exec();
	if (cqdg.result() == QDialog::Accepted)
	{
		m_textEditSourceFont.setFamily(m_fonttemp);
		//m_lexer->setFont(m_textEditSourceFont);
		m_textEditSource->setTabWidth(m_fontwidthtemp);
		m_textEditSource->zoomTo(m_fontsize);
		m_theme = m_themetemp;
		m_themelast = "1234";
		setLexer();
	}
}
void Buffer::setLanguage(const Language *language) {
    if (m_language != language) {
        m_language = language;

        if (language) {
            setLexerLanguage(language->lexer().toLocal8Bit());
            for (int i = 0; i < language->keywords().size(); ++i) {
                setKeyWords(i, language->keywords().at(i).toLatin1());
            }
            setProperty("fold", "1");
            setProperty("fold.compact", "0");
        } else {
            setLexer(SCLEX_NULL);
            setKeyWords(0, "");
            setProperty("fold", "0");
        }

        Configuration *config = Configuration::instance();
        setColorScheme(ColorScheme::getColorScheme(config->colorScheme()));

        emit languageChanged(language);
    }
}
/**
 * Initializes the lexer.
 * @param script
 *      The script file.
 */
void SingleDocument::initLexer(QString script)
{
    (void)script;

    if(lexer() == 0)
    {
        setLexer(new QsciLexerJavaScript(this));
        QsciAPIs* apis = new QsciAPIs(lexer());
        (void)apis;


        setAutoCompletionSource(QsciScintilla::AcsAPIs);
        setAutoCompletionCaseSensitivity(true);
        setAutoCompletionThreshold(3);
        setAutoIndent(true);
        setIndentationWidth(4);
        setTabWidth(4);
        setMarginLineNumbers(0,true);
        setMarginType(0, QsciScintilla::NumberMargin);
        setMarginsForegroundColor(QColor(128, 128, 128));
       }

}