| 839 | } |
| 840 | |
| 841 | void 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 | |
| 865 | void TextEditor::onScrollValueChanged(int value) |
| 866 | { |
no outgoing calls
no test coverage detected