MCPcopy Create free account
hub / github.com/Codeya-IDE/deepin-ide / updateLineNumberWidth

Method updateLineNumberWidth

src/plugins/codeeditor/gui/texteditor.cpp:841–863  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

839}
840
841void TextEditor::updateLineNumberWidth(bool isDynamicWidth)
842{
843 auto linesVisible = SendScintilla(SCI_LINESONSCREEN);
844 if (!linesVisible)
845 return;
846
847 int nbDigits = 0;
848 if (isDynamicWidth) {
849 auto firstVisibleLineVis = SendScintilla(SCI_GETFIRSTVISIBLELINE);
850 auto lastVisibleLineVis = linesVisible + firstVisibleLineVis + 1;
851 auto lastVisibleLineDoc = SendScintilla(SCI_DOCLINEFROMVISIBLE, lastVisibleLineVis);
852
853 nbDigits = EditorUtils::nbDigitsFromNbLines(lastVisibleLineDoc);
854 nbDigits = nbDigits < 4 ? 4 : nbDigits;
855 } else {
856 auto nbLines = SendScintilla(SCI_GETLINECOUNT);
857 nbDigits = EditorUtils::nbDigitsFromNbLines(nbLines);
858 nbDigits = nbDigits < 4 ? 4 : nbDigits;
859 }
860
861 auto pixelWidth = 6 + nbDigits * SendScintilla(SCI_TEXTWIDTH, STYLE_LINENUMBER, reinterpret_cast<intptr_t>("8"));
862 setMarginWidth(TextEditorPrivate::LineNumberMargin, static_cast<int>(pixelWidth));
863}
864
865void TextEditor::onScrollValueChanged(int value)
866{

Callers 4

createEditorMethod · 0.80
updateZoomValueMethod · 0.80
updateSettingsMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected