示例#1
0
void codeEditor::init()
{
    setAutoIndent(true);
    setAutoCompletionFillupsEnabled(true);

    file_path.clear();
}
示例#2
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());
}
ScintillaEditor::ScintillaEditor(QWidget* parent) : QsciScintilla(parent) {
/* -setup editor and configurations */
    //set and display line numbers; margin '1' is the default line number maring
    setMarginWidth(1, 55);
    setMarginLineNumbers(1, true);

    //create the lexer manager
    lexerManager = new SyntaxHighlightManager(this);

    //set editor properties/settings
    setAutoIndent(true);
    setTabWidth(4);
    setMarginsBackgroundColor( LeptonConfig::mainSettings->getValueAsColor("editor_theme", "margins_background") );
    setMarginsForegroundColor( LeptonConfig::mainSettings->getValueAsColor("editor_theme", "margins_foreground") );
    setWhitespaceVisibility( LeptonConfig::mainSettings->getWhiteSpaceVisibility() );
    setWhitespaceForegroundColor( LeptonConfig::mainSettings->getValueAsColor("editor_theme", "whitespace_color") );
    setCaretForegroundColor( LeptonConfig::mainSettings->getValueAsColor("editor_theme", "caret_color") );
    setCallTipsHighlightColor( LeptonConfig::mainSettings->getValueAsColor("editor_theme", "highlight_color") );
    setSelectionBackgroundColor( LeptonConfig::mainSettings->getValueAsColor("editor_theme", "selection_background") );
    setSelectionForegroundColor( LeptonConfig::mainSettings->getValueAsColor("editor_theme", "selection_foreground") );
    setIndentationsUseTabs(false);  //use spaces instead of tabs for indentation

    //*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
    //$ Stub code used to test Scintilla features                          $$
    //$                                                                    $$

    //$                                                                    $$
    //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*/
}
示例#4
0
void CodeEditor::setupEditor()
{

    setIndentationsUseTabs(false);
    setIndentationWidth(4);
    setWrapIndentMode(WrapIndentSame);
    setAutoIndent(true);
}
示例#5
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();
}
示例#6
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()));
}
示例#7
0
MdiChild::MdiChild()
{
    setAttribute(Qt::WA_DeleteOnClose);
    isUntitled = true;
    forceClose = false;
    saveAndClose = false;
    lexer = 0;

    setAutoIndent(true);
    setMarginLineNumbers(1,true);
    setFolding(QsciScintilla::BoxedFoldStyle);
    setMarginType(1, QsciScintilla::NumberMargin);
    setMarginWidth(1,"00000");
    setAutoCompletionSource(QsciScintilla::AcsDocument);
    setAutoCompletionThreshold(2);
}
示例#8
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());
}
示例#9
0
// Parse VIM modeline
FXbool Modeline::parseVimModeline(const FXchar* s){
  FXbool set=false;
  FXbool yes=true;
  FXString key;
  FXString val;
  while(*s!='\0' && !(*s==':' && set)){
    while(*s==':' || *s=='\t' || *s==' ') s++;
    if(*s=='\0') break;
    if(*s=='s' && *(s+1)=='e' && *(s+1)==' '){ s+=3; set=true; }
    else if(*s=='s' && *(s+1)=='e' && *(s+2)=='t' && *(s+3)==' '){ s+=4; set=true; }
    yes=true;
    if(*s=='n' && *(s+1)=='o'){ s+=2; yes=false; }
    key=FXString::null;
    val=FXString::null;
    while(*s!='\0' && *s!=':' && *s!='=' && *s!='\t' && *s!=' '){
      key+=*s++;
      }
    if(*s=='='){
      s++;
      while(*s!='\0' && *s!=':' && *s!='\t' && *s!=' '){
        val+=*s++;
        }
      }
    if(key=="ft" || key=="filetype"){
      setLanguage(val);
      }
    else if(key=="et" || key=="expandtab"){
      setTabMode(yes);
      }
    else if(key=="wrap"){
      setWrapMode(yes);
      }
    else if(key=="ai"){
      setAutoIndent(yes);
      }
    else if(key=="ts" || key=="tabstop"){
      setTabWidth(val.toInt());
      }
    else if(key=="textwidth"){
      setWrapWidth(val.toInt());
      }
    }
  return true;
  }
    RoboScintilla::RoboScintilla(QWidget *parent) : QsciScintilla(parent),
        _ignoreEnterKey(false),
        _ignoreTabKey(false),
        _lineNumberDigitWidth(0),
        _lineNumberMarginWidth(0)
    {
        setAutoIndent(true);
        setIndentationsUseTabs(false);
        setIndentationWidth(indentationWidth);
        setUtf8(true);
        setMarginWidth(1, 0);
        setCaretForegroundColor(caretForegroundColor);
        setMatchedBraceForegroundColor(matchedBraceForegroundColor); //1AB0A6
        setMatchedBraceBackgroundColor(marginsBackgroundColor);
        setContentsMargins(0, 0, 0, 0);
        setViewportMargins(3, 3, 3, 3);
        QFont ourFont = GuiRegistry::instance().font();
        setMarginsFont(ourFont);
        setMarginLineNumbers(0, true);
        setMarginsBackgroundColor(QColor(53, 56, 58));
        setMarginsForegroundColor(QColor(173, 176, 178));

        SendScintilla(QsciScintilla::SCI_STYLESETFONT, 1, ourFont.family().data());
        SendScintilla(QsciScintilla::SCI_SETHSCROLLBAR, 0);

        setWrapMode((QsciScintilla::WrapMode)QsciScintilla::SC_WRAP_NONE);
        setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); 
        setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); 

        // Cache width of one digit
#ifdef Q_OS_WIN
        _lineNumberDigitWidth = rowNumberWidth;
#else
        _lineNumberDigitWidth = textWidth(STYLE_LINENUMBER, "0");
#endif
        updateLineNumbersMarginWidth();

        setLineNumbers(AppRegistry::instance().settingsManager()->lineNumbers());
        setUtf8(true);
        VERIFY(connect(this, SIGNAL(linesChanged()), this, SLOT(updateLineNumbersMarginWidth())));
    }
示例#11
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);
}
示例#12
0
// Parse Adie modelines
FXbool Modeline::parseAdieModeline(const FXchar* s){
  FXString key;
  FXString val;
  while(*s!='\0' && *s!=':'){
    key=FXString::null;
    val=FXString::null;
    while(*s=='\t' || *s==' ') s++;
    if(*s=='\0') break;
    while(*s!='\0' && *s!=':' && *s!='=' && *s!='\t' && *s!=' '){
      key+=*s++;
      }
    while(*s=='\t' || *s==' ') s++;
    if(*s=='\0') break;
    if(*s!='=') continue;
    s++;
    while(*s=='\t' || *s==' ') s++;
    if(*s=='\0') break;
    while(*s!='\0' && *s!=':' && *s!='\t' && *s!=' '){
      val+=*s++;
      }
    if(key=="la"){
      setLanguage(val);
      }
    else if(key=="ts"){
      setTabWidth(val.toInt());
      }
    else if(key=="ww"){
      setWrapWidth(val.toInt());
      }
    else if(key=="et"){
      setTabMode(val!="0");
      }
    else if(key=="wr"){
      setWrapMode(val!="0");
      }
    else if(key=="ai"){
      setAutoIndent(val!="0");
      }
    }
  return true;
  }
示例#13
0
void QgsCodeEditor::setSciWidget()
{
  setUtf8( true );
  setCaretLineVisible( true );
  setCaretLineBackgroundColor( QColor( "#fcf3ed" ) );

  setBraceMatching( QsciScintilla::SloppyBraceMatch );
  setMatchedBraceBackgroundColor( QColor( "#b7f907" ) );
  // whether margin will be shown
  setMarginVisible( mMargin );
  // whether margin will be shown
  setFoldingVisible( mFolding );
  // indentation
  setAutoIndent( true );
  setIndentationWidth( 4 );
  setTabIndents( true );
  setBackspaceUnindents( true );
  setTabWidth( 4 );
  // autocomplete
  setAutoCompletionThreshold( 2 );
  setAutoCompletionSource( QsciScintilla::AcsAPIs );
}
示例#14
0
FastoScintilla::FastoScintilla(QWidget* parent)
    : QsciScintilla(parent), lineNumberMarginWidth_(0), showAutoCompletion_(false) {
  setAutoIndent(true);
  setIndentationsUseTabs(false);
  setIndentationWidth(indentationWidth);
  setUtf8(true);
  setMarginWidth(1, 0);

  setCaretForegroundColor(caretForegroundColor);

  setMatchedBraceForegroundColor(matchedBraceForegroundColor);
  setMatchedBraceBackgroundColor(matchedBraceBackgroundColor);

  setSelectionBackgroundColor(selectionBackgroundColor);
  setSelectionForegroundColor(selectionForegroundColor);

  setContentsMargins(0, 0, 0, 0);
  setViewportMargins(3, 3, 3, 3);
  setMarginLineNumbers(0, true);

  // Margins colors
  // line numbers margin
  setMarginsBackgroundColor(marginsBackgroundColor);
  setMarginsForegroundColor(marginsForegroundColor);

  SendScintilla(QsciScintilla::SCI_SETHSCROLLBAR, 0);

  setWrapMode(QsciScintilla::WrapNone);
  setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);

  VERIFY(connect(this, &FastoScintilla::linesChanged, this,
                 &FastoScintilla::updateLineNumbersMarginWidth));

  setAutoCompletionThreshold(1);
  setAutoCompletionCaseSensitivity(false);
  setAutoCompletionSource(QsciScintilla::AcsNone);
}
/**
 * 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));
       }

}
示例#16
0
void CellDocument::setAutoIndent2(bool b)
{
    emit setAutoIndent(b);
    autoIndent = b;
}
示例#17
0
文件: global.cpp 项目: HeeroYui/edn
void globals::ParameterGlobalsGui::onCallbackIndentation(const bool& _value) {
	setAutoIndent(_value);
}
示例#18
0
Editor::Editor(QWidget *parent)
	: QsciScintilla(parent)
{
	// identify this widget as a code editor
	// WindoweIconText is used only for windows widgets. 
	// So, it's free for us to use it here
	setWindowIconText("editor");
	//setEolMode(QsciScintilla::EolUnix);

	lexer = new QsciLexerCPP;
	this->setLexer(lexer);
	this->setUtf8(true);
	//setAutoCompletionThreshold(0);
	
	api = new QsciAPIs(lexer);
	api->prepare();

	LoadStyleSheet(this, "style_code_editor.css");
	
    setAutoCompletionThreshold(3);
    setAutoCompletionSource(QsciScintilla::AcsAll);

	context= new QMenu(this);		
	LoadStyleSheet(context, "style_menu.css");
	actionHelpWithThis = context->addAction("Help with this code");
	connect(actionHelpWithThis, SIGNAL(triggered()), this, SLOT(HelpWithThis()));
	context->addSeparator();
	
	QAction * action = context->addAction("Undo");
	action->setShortcut(tr("Ctrl+Z"));
	connect(action, SIGNAL(triggered()), this, SLOT(MenuUndo()));
	
	action = context->addAction("Redo");
	action->setShortcut(tr("Ctrl+Y"));
	connect(action, SIGNAL(triggered()), this, SLOT(MenuRedo()));
	
	context->addSeparator();
	
	action = context->addAction("Cut");
	action->setShortcut(tr("Ctrl+X"));
	connect(action, SIGNAL(triggered()), this, SLOT(MenuCut()));

	action = context->addAction("Copy");
	action->setShortcut(tr("Ctrl+C"));
	connect(action, SIGNAL(triggered()), this, SLOT(MenuCopy()));

	action = context->addAction("Paste");
	action->setShortcut(tr("Ctrl+V"));
	connect(action, SIGNAL(triggered()), this, SLOT(MenuPaste()));

	/*action = context->addAction("Delete");
	connect(action, SIGNAL(triggered()), this, SLOT(MenuDelete()));
	*/

	context->addSeparator();
	
	action = context->addAction("Select all");
	action->setShortcut(tr("Ctrl+A"));
	connect(action, SIGNAL(triggered()), this, SLOT(MenuSelectAll()));
		
	setContextMenuPolicy(Qt::CustomContextMenu);
	connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this,SLOT(ShowEditorMenu(const QPoint )));		
	connect(this, SIGNAL(cursorPositionChanged(int, int)), this, SLOT(onCursorPositionChanged(int, int)));
	
	lblCursorPosition = new QLabel(this);
	LoadStyleSheet(lblCursorPosition, "style_cursorpos.css");
	lblCursorPosition->setVisible(true);

	QVBoxLayout * vl = new QVBoxLayout(this);	
	//QVBoxLayout * vl2 = new QVBoxLayout(this);	
	
	
	int scrollbarw = qApp->style()->pixelMetric(QStyle::PM_ScrollBarExtent);


	QHBoxLayout * hl = new QHBoxLayout(this);		
	hl->addSpacerItem(new QSpacerItem(0,0, QSizePolicy::Expanding, QSizePolicy::Fixed));
	hl->addWidget(lblCursorPosition);
	hl->addSpacerItem(new QSpacerItem (scrollbarw,0, QSizePolicy::Fixed, QSizePolicy::Fixed));
	vl->addLayout(hl);
	vl->addSpacerItem(new QSpacerItem(0,0, QSizePolicy::Fixed,QSizePolicy::Expanding ));
	
	lastModifiedTime = QDateTime::currentDateTime();

	setAutoIndent(true);

	setEditorStyle();
}