void FastoScintilla::showOrHideLinesNumbers() { updateLineNumbersMarginWidth(); if (!lineNumberMarginWidth()) { setMarginWidth(0, lineNumberMarginWidth_); } else { setMarginWidth(0, 0); } }
void RoboScintilla::setLineNumbers(bool displayNumbers) { if (displayNumbers) { setMarginWidth(0, _lineNumberMarginWidth); } else { setMarginWidth(0, 0); } }
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 $$ //$ $$ //$ $$ //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*/ }
void SourceEditor::linesCountChanged() { int marginWidth = qCeil( qLn( lines() ) / qLn(10) + 0.000001 ); if (marginWidth != m_marginWidth) { m_marginWidth = marginWidth; setMarginWidth(NumberMargin, QString(marginWidth, '3') + ' '); } }
void pEditor::setLineNumbersMarginWidth( int i ) { int j = i; if ( i != 0 ) j++; setProperty( "LineNumbersMarginWidth", i ); setMarginWidth( 0, QString().fill( '0', j ) ); }
//----------------------------------------------- // Public slots //----------------------------------------------- /// Ensure the margin width is big enough to hold everything void ScriptEditor::padMargin() { const int minWidth = 38; int width = minWidth; int ntens = static_cast<int>(std::log10(static_cast<double>(lines()))); if (ntens > 1) { width += 5 * ntens; } setMarginWidth(1, width); }
Menu::Menu(const char* sName,Container* sParent,bool sManageChild) :RowColumn(sName,sParent,false) { /* Set default layout for menus: */ setMarginWidth(0.0f); /* Manage me: */ if(sManageChild) manageChild(); }
void QgsCodeEditor::setMarginVisible( bool margin ) { mMargin = margin; if ( margin ) { QFont marginFont( "Courier", 10 ); setMarginLineNumbers( 1, true ); setMarginsFont( marginFont ); setMarginWidth( 1, "00000" ); setMarginsForegroundColor( QColor( "#3E3EE3" ) ); setMarginsBackgroundColor( QColor( "#f9f9f9" ) ); } else { setMarginWidth( 0, 0 ); setMarginWidth( 1, 0 ); setMarginWidth( 2, 0 ); } }
void QgsCodeEditor::setMarginVisible( bool margin ) { mMargin = margin; if ( margin ) { QFont marginFont( QStringLiteral( "Courier" ), 10 ); setMarginLineNumbers( 1, true ); setMarginsFont( marginFont ); setMarginWidth( 1, QStringLiteral( "00000" ) ); setMarginsForegroundColor( QColor( 62, 62, 227 ) ); setMarginsBackgroundColor( QColor( 249, 249, 249 ) ); } else { setMarginWidth( 0, 0 ); setMarginWidth( 1, 0 ); setMarginWidth( 2, 0 ); } }
void RoboScintilla::updateLineNumbersMarginWidth() { int numberOfDigits = getNumberOfDigits(lines()); _lineNumberMarginWidth = numberOfDigits * _lineNumberDigitWidth + rowNumberWidth; // If line numbers margin already displayed, update its width if (lineNumberMarginWidth()) { setMarginWidth(0, _lineNumberMarginWidth); } }
void FastoScintilla::updateLineNumbersMarginWidth() { int numberOfDigits = getNumberOfDigits(lines()); int tw = textWidth(QsciScintilla::STYLE_LINENUMBER, "0"); lineNumberMarginWidth_ = numberOfDigits * tw + rowNumberWidth; // If line numbers margin already displayed, update its width if (lineNumberMarginWidth()) { setMarginWidth(0, lineNumberMarginWidth_); } }
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())); }
DropdownBox::DropdownBox(const char* sName,Container* sParent,bool sManageChild) :Label(sName,sParent,"",false), popup(0),items(0),isPopped(false), foundChild(0),armedChild(0), arrow(GlyphGadget::FANCY_ARROW_DOWN,GlyphGadget::IN,0.0f), numItems(0), selectedItem(-1) { const GLMotif::StyleSheet& ss=*getManager()->getStyleSheet(); /* Dropdown box defaults to raised border: */ setBorderType(Widget::RAISED); setBorderWidth(ss.buttonBorderWidth); /* Dropdown box defaults to some margin: */ setMarginWidth(ss.buttonMarginWidth); /* Set the arrow sizes: */ spacing=ss.buttonBorderWidth+2.0f*ss.buttonMarginWidth; arrow.setGlyphSize(ss.size*0.25f); arrow.setBevelSize(ss.size*0.25f); arrow.setGlyphColor(backgroundColor); popupExtrudeSize=ss.size*4.0f; /* Set the label insets: */ setInsets(0.0f,arrow.getPreferredBoxSize()+spacing); /* Create a pop-up containing the item labels: */ popup=new Popup("Popup",getManager()); popup->setBorderWidth(ss.buttonBorderWidth); popup->setBorderType(Widget::PLAIN); popup->setBorderColor(borderColor); popup->setBackgroundColor(backgroundColor); popup->setForegroundColor(foregroundColor); popup->setMarginWidth(0.0f); /* Create a container for the item labels: */ items=new RowColumn("Items",popup,false); items->setBorderWidth(0.0f); items->setOrientation(RowColumn::VERTICAL); items->setNumMinorWidgets(1); items->setMarginWidth(0.0f); items->setSpacing(ss.buttonBorderWidth); items->manageChild(); /* Manage me: */ if(sManageChild) manageChild(); }
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); }
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()))); }
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); }
Button::Button(const char* sName,Container* sParent,const char* sLabel,bool sManageChild) :Label(sName,sParent,sLabel,false), isArmed(false) { /* Get the style sheet: */ const StyleSheet* ss=getStyleSheet(); /* Button defaults to raised border: */ setBorderType(Widget::RAISED); setBorderWidth(ss->buttonBorderWidth); /* Button defaults to some margin: */ setMarginWidth(ss->buttonMarginWidth); /* Button defaults to centered text: */ setHAlignment(GLFont::Center); /* Set the armed background color: */ armedBackgroundColor=ss->buttonArmedBackgroundColor; /* Manage me: */ if(sManageChild) manageChild(); }
QSourceCodeWidget::QSourceCodeWidget( int _index, const char * fname, const char * srcTxt ) : QsciScintilla ( 0 ) { index = _index; long_name = QString(fname); short_name = QFileInfo(long_name).fileName(); QFont font(tr("Courier New")); font.setPointSize(8); setLexer(new QsciLexerCPP); lexer()->setFont(font); setText( QString(srcTxt) ); setReadOnly(true); setFolding(QsciScintilla::BoxedTreeFoldStyle); setMarginType(1,QsciScintilla::NumberMargin); setMarginWidth(1,30); setMarginSensitivity(1,true); current_marker=0; }
void SonicPiScintilla::showLineNumbers(){ setMarginLineNumbers(0, true); setMarginWidth(0, "1000"); SendScintilla(SCI_SHOWLINES); }
void SonicPiScintilla::hideLineNumbers(){ setMarginLineNumbers(0, false); setMarginWidth(0, "0"); SendScintilla(SCI_HIDELINES); }
void Editor::setEditorStyle (void) { //QFont font ("Consolas", 14, QFont::Normal, false); QFont font (config.editorFontName, config.editorFontSize, QFont::Normal, false); lblCursorPosition->setFont(font); QFontMetrics fontMetrics(font); //QColor backColor = QColor(22, 30, 32); TextStyle style; config.GetThemeStyle(config.themeName, "DEFAULT", style); QColor backColor = style.backColor;//QColor(config.editorColorName); setColor(backColor); QString css = "color:" + style.foreColor.name() + ";"; css += "background-color:" + style.backColor.name() + ";"; css += "border: 1px solid " + style.foreColor.name() + ";"; lblCursorPosition->setStyleSheet(css); // margin setMarginLineNumbers(100, true); setMarginsFont(font); config.GetThemeStyle(config.themeName, "MARGIN", style); setMarginsBackgroundColor(style.backColor);//QColor(24,32,34));//QColor(20,28,30)); setMarginsForegroundColor(style.foreColor); //QColor(42,50,52)); setMarginWidth(0, fontMetrics.width("00000") + 6); // General editor things setTabWidth(4); ensureCursorVisible(); setIndicatorForegroundColor (Qt::red, 1); // compile error/warning mark markerDefine(QsciScintilla::RightArrow, 1); setMarkerBackgroundColor(Qt::red, 1); markerDefine(QsciScintilla::Circle, 0); setMarkerBackgroundColor(Qt::red, 0); setMarkerForegroundColor(Qt::white, 0); // caret setCaretLineVisible(true); setCaretWidth(2); config.GetThemeStyle(config.themeName, "CARET", style); setCaretForegroundColor(style.foreColor);//QColor(220, 200, 200)); caretLineBackColor = style.backColor; setCaretLineBackgroundColor(caretLineBackColor);//QColor(24, 32, 34)); //setCaretLineBackgroundColor(QColor(255, 0, 0, 100)); //SendScintilla (SC_TECHNOLOGY_DIRECTWRITE, 1); //SendScintilla (SCI_SETBUFFEREDDRAW, 1); //SendScintilla (SCI_SETTWOPHASEDRAW, 1); //SendScintilla (SCI_SETFONTQUALITY, SC_EFF_QUALITY_NON_ANTIALIASED);//SC_EFF_QUALITY_DEFAULT); // matched and unmatched braces coloring if (config.highlightBraces) { setBraceMatching(QsciScintilla::SloppyBraceMatch); } else { setBraceMatching(QsciScintilla::NoBraceMatch); } setMatchedBraceBackgroundColor(backColor); setMatchedBraceForegroundColor(QColor(220, 220, 50)); setUnmatchedBraceBackgroundColor(QColor(0,0,0)); setUnmatchedBraceForegroundColor(QColor(255, 0, 0)); // selection config.GetThemeStyle(config.themeName, "SELECTION", style); setSelectionForegroundColor(style.foreColor);//QColor(150, 150, 150)); setSelectionBackgroundColor(style.backColor);//QColor(52, 60, 62)); // maim cpp styles setLexerStyle(-1, "DEFAULT");//QColor (120, 120, 120),backColor); //setLexerStyle(-1, Qt::red, Qt::blue); //setLexerStyle(QsciLexerCPP::Default, Qt::blue, Qt::yellow); setLexerStyle(QsciLexerCPP::Default, "DEFAULT"); //setLexerStyle(QsciLexerCPP::callSTYLE_CALLTIP, QColor (255,0,0), QColor(255,255,255)); setLexerStyle(QsciLexerCPP::Comment, "COMMENT"); setLexerStyle(QsciLexerCPP::CommentDoc, "COMMENT DOC"); setLexerStyle(QsciLexerCPP::CommentLine, "COMMENT LIN E DOC"); setLexerStyle(QsciLexerCPP::Number, "NUMBER"); setLexerStyle(QsciLexerCPP::Keyword, "KEYWORD"); setLexerStyle(QsciLexerCPP::DoubleQuotedString, "DOUBLE QUOTED STRING"); setLexerStyle(QsciLexerCPP::SingleQuotedString, "SINGLE QUOTED STRING"); setLexerStyle(QsciLexerCPP::PreProcessor, "PREPROCESSOR"); setLexerStyle(QsciLexerCPP::Operator, "OPERATOR"); setLexerStyle(QsciLexerCPP::Identifier, "IDENTIFIER"); setLexerStyle(QsciLexerCPP::UnclosedString, "UNCLOSED STRING"); // secondary styles setLexerStyle(QsciLexerCPP::UUID, "UUID"); setLexerStyle(QsciLexerCPP::VerbatimString, "VERBATIM STRING"); setLexerStyle(QsciLexerCPP::Regex, "REGEX"); setLexerStyle(QsciLexerCPP::CommentLineDoc, "COMMENT LINE DOC"); setLexerStyle(QsciLexerCPP::KeywordSet2, "KEYWORD SET 2"); setLexerStyle(QsciLexerCPP::CommentDocKeyword, "COMMENT DOC KEYWORD"); setLexerStyle(QsciLexerCPP::CommentDocKeywordError, "COMMENT DOC KEYWORD ERROR"); setLexerStyle(QsciLexerCPP::GlobalClass, "GLOBAL CLASS"); setLexerStyle(QsciLexerCPP::RawString, "DOUBLE QUOTED STRING"); setLexerStyle(QsciLexerCPP::TripleQuotedVerbatimString, "VERBATIM STRING"); setLexerStyle(QsciLexerCPP::HashQuotedString, "VERBATIM STRING"); setLexerStyle(QsciLexerCPP::PreProcessorComment, "PREPROCESSOR"); setLexerStyle(QsciLexerCPP::PreProcessorCommentLineDoc, "PREPROCESSOR"); }
void QsciEditor::resizeMargins() { setMarginWidth( 0, QString( " %1 " ).arg( lines() ) ); };
QsciEditor::QsciEditor( QWidget *parent ) : QsciScintilla( parent ) { setFocus(); /* Set tab width, and fonts */ setTabWidth( 4 ); setFont( QFont( "Envy Code R", 9 ) ); setTabIndents( true ); setIndentationsUseTabs( true ); /* Set folding style */ setFolding( QsciScintilla::BoxedTreeFoldStyle ); /* Remove Horizontal Scrollbar, put a Vertical one */ setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); setVerticalScrollBarPolicy( Qt::ScrollBarAsNeeded ); /* Whitespace, indentation markings, and eol */ setIndentationGuides( false ); setWhitespaceVisibility( WsInvisible ); setEolMode( EolUnix ); /* Create Margins */ setMarginWidth( 0, QString( " %1 " ).arg( lines() ) ); setMarginWidth( 1, " " ); setMarginWidth( 2, 10 ); setMarginsFont( QFont( "Envy Code R", 9 ) ); setWrapMode( QsciScintilla::WrapWord ); /* Current Line Visibility */ ensureCursorVisible(); setCaretLineVisible( true ); setCaretLineBackgroundColor( QColor( "#555555" ) ); setCaretForegroundColor( QColor( "#FAFFAF" ) ); setCaretWidth( 2 ); /* Selection Color */ // setSelectionBackgroundColor( "#333964" ); // setSelectionForegroundColor( "*" ); /* Margin and folding margins background colors */ setMarginsBackgroundColor( QColor( "#A0A0A0" ) ); setFoldMarginColors( QColor( "#666666" ), Qt::black ); /* Set the width of the line */ setLineWidth( 144 ); ensureLineVisible( true ); /* Set the paper and pen color - Editor BG and FG color */ setPaper( Qt::black ); setColor( Qt::white ); /* Brace coloring */ setBraceMatching( QsciScintilla::SloppyBraceMatch ); setUnmatchedBraceForegroundColor( Qt::red ); setUnmatchedBraceBackgroundColor( Qt::black ); setMatchedBraceForegroundColor( Qt::darkGreen ); setMatchedBraceBackgroundColor( Qt::black ); /* Multi-selection and typing */ SendScintilla( SCI_SETADDITIONALSELECTIONTYPING, true ); SendScintilla( SCI_SETMULTIPLESELECTION, true ); SendScintilla( SCI_SETMULTIPASTE, true ); /* Scroll beyond the last line */ SendScintilla( SCI_SETENDATLASTLINE, false ); /* Set the editor state as not modified */ setModified( false ); /* Auto Save Timer: 60 sec */ autoSaveTimer = new QBasicTimer(); /* Enable and Show Custom context Menu */ setContextMenuPolicy( Qt::CustomContextMenu ); /* Connections */ setupActions(); /* Default Lexer */ setLexer( new QLexerDefault() ); QsciScintilla::FoldStyle state = static_cast<QsciScintilla::FoldStyle>( ( !folding() ) * 5 ); if ( !state ) foldAll( false ); setFolding( state ); };
DropdownBox::DropdownBox(const char* sName,Container* sParent,const std::vector<std::string>& sItems,bool sManageChild) :Label(sName,sParent,sItems[0].c_str(),false), popup(0),items(0),isPopped(false), foundChild(0),armedChild(0), arrow(GlyphGadget::FANCY_ARROW_DOWN,GlyphGadget::IN,0.0f), numItems(sItems.size()), selectedItem(0) { const GLMotif::StyleSheet& ss=*getManager()->getStyleSheet(); /* Dropdown box defaults to raised border: */ setBorderType(Widget::RAISED); setBorderWidth(ss.buttonBorderWidth); /* Dropdown box defaults to some margin: */ setMarginWidth(ss.buttonMarginWidth); /* Set the arrow sizes: */ spacing=ss.buttonBorderWidth+2.0f*ss.buttonMarginWidth; arrow.setGlyphSize(ss.size*0.25f); arrow.setBevelSize(ss.size*0.25f); arrow.setGlyphColor(backgroundColor); popupExtrudeSize=ss.size*4.0f; /* Set the label insets: */ setInsets(0.0f,arrow.getPreferredBoxSize()+spacing); /* Create a pop-up containing the item labels: */ popup=new Popup("Popup",getManager()); popup->setBorderWidth(ss.buttonBorderWidth); popup->setBorderType(Widget::PLAIN); popup->setBorderColor(borderColor); popup->setBackgroundColor(backgroundColor); popup->setForegroundColor(foregroundColor); popup->setMarginWidth(0.0f); /* Create a container for the item labels: */ items=new RowColumn("Items",popup,false); items->setBorderWidth(0.0f); items->setOrientation(RowColumn::VERTICAL); items->setNumMinorWidgets(1); items->setMarginWidth(0.0f); items->setSpacing(ss.buttonBorderWidth); /* Create a button for each list item: */ for(int i=0;i<numItems;++i) { char itemButtonName[40]; snprintf(itemButtonName,sizeof(itemButtonName),"ItemButton%d",i); Button* button=new Button(itemButtonName,items,sItems[i].c_str()); button->setBorderType(Widget::PLAIN); button->setBorderWidth(0.0f); button->setHAlignment(GLFont::Left); button->getSelectCallbacks().add(itemSelectedCallbackWrapper,this); } items->manageChild(); /* Manage me: */ if(sManageChild) manageChild(); }
void SqlEditorWidget::linesChanged() { int x = QString::number(lines()).length() + 1; setMarginWidth(0, QString().fill('0', x)); }