MCPcopy Create free account
hub / github.com/KDE/kdevelop / highlightBlock

Method highlightBlock

plugins/git/gitmessagehighlighter.cpp:40–101  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

38}
39
40void GitMessageHighlighter::highlightBlock(const QString& text)
41{
42 int blockState = previousBlockState();
43 if (blockState < DetailedMessage)
44 ++blockState;
45 const int textLength = text.length();
46 int startPos = 0;
47 int endPos = 0;
48 while (startPos < textLength)
49 {
50 // Switch block state for multiline blocks
51 if (startPos != 0 && blockState < DetailedMessage)
52 ++blockState;
53 endPos = text.indexOf(QLatin1Char('\n'), startPos);
54 if (endPos < 0)
55 endPos = textLength;
56 const int lineLength = endPos - startPos;
57
58 Highlighter::highlightBlock( text );
59 switch (blockState)
60 {
61 case Summary:
62 if (lineLength > summarySoftLimit)
63 {
64 applyErrorFormat(this,
65 lineLength <= summaryHardLimit,
66 i18n("Try to keep summary length below %1 characters.", summarySoftLimit),
67 startPos, endPos
68 );
69 } else {
70 for(int i=startPos; i<endPos; i++) {
71 QTextCharFormat f = format(i);
72 f.setFontWeight(QFont::Bold);
73 setFormat(i, 1, f);
74 }
75 }
76 break;
77 case SummarySeparator:
78 if (lineLength != 0)
79 {
80 applyErrorFormat(this,
81 false,
82 i18n("Separate summary from details with one empty line."),
83 startPos, endPos
84 );
85 }
86 break;
87 default:
88 if (lineLength > lineLenLimit)
89 {
90 applyErrorFormat(this,
91 false,
92 i18n("Try to keep line length below %1 characters.", lineLenLimit),
93 startPos+lineLenLimit, endPos
94 );
95 }
96 break;
97 }

Callers

nothing calls this directly

Calls 3

formatFunction · 0.85
lengthMethod · 0.45
indexOfMethod · 0.45

Tested by

no test coverage detected