MCPcopy Create free account
hub / github.com/SpartanJ/eepp / copyLineToBuffer

Method copyLineToBuffer

src/eepp/ui/doc/syntaxhighlighter.cpp:194–238  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

192}
193
194void SyntaxHighlighter::copyLineToBuffer( const size_t& index,
195 std::vector<SyntaxTokenPosition>& buffer,
196 bool mustTokenize ) {
197 static std::vector<SyntaxTokenPosition> noHighlightVector = {
198 { SyntaxStyleTypes::Normal, 0, 0 } };
199 if ( mDoc->getSyntaxDefinition().getPatterns().empty() ) {
200 noHighlightVector[0].len = mDoc->getLineLength( index );
201 buffer = noHighlightVector;
202 return;
203 }
204
205 {
206 Lock l( mLinesMutex );
207 auto it = mLines.find( index );
208 bool needsTokenize =
209 it == mLines.end() ||
210 ( index < mDoc->linesCount() && mDoc->getLineHash( index ) != it->second.hash );
211 if ( !needsTokenize ) {
212 mMaxWantedLine = eemax<Int64>( mMaxWantedLine, index );
213 buffer = it->second.tokens;
214 return;
215 }
216 }
217
218 if ( !mustTokenize ) {
219 noHighlightVector[0].len = mDoc->getLineLength( index );
220 buffer = noHighlightVector;
221 return;
222 }
223
224 SyntaxState prevState;
225 if ( index > 0 ) {
226 Lock l( mLinesMutex );
227 auto prevIt = mLines.find( index - 1 );
228 if ( prevIt != mLines.end() )
229 prevState = prevIt->second.state;
230 }
231 auto tokenizedLine = tokenizeLine( index, prevState );
232
233 Lock l( mLinesMutex );
234 mLines[index] = std::move( tokenizedLine );
235 mTokenizerLines[index] = mLines[index];
236 mMaxWantedLine = eemax<Int64>( mMaxWantedLine, index );
237 buffer = mLines[index].tokens;
238}
239
240Int64 SyntaxHighlighter::getFirstInvalidLine() const {
241 return mFirstInvalidLine;

Callers 2

drawLineTextMethod · 0.80
drawMinimapMethod · 0.80

Calls 6

getLineLengthMethod · 0.80
linesCountMethod · 0.80
getLineHashMethod · 0.80
emptyMethod · 0.45
findMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected