9 #include "string_operations.h"
11 void convertToAbsoluteHighlight(
const GArray* tokens,
DiffPoint* indexHighlight) {
12 Token* firstToken = tokens_index(tokens, indexHighlight->start);
14 size_t start = token_position_of(indexHighlight->start, tokens);
17 if (indexHighlight->length > 0)
18 length += token_length(*firstToken);
20 for (
size_t j = indexHighlight->start + 1;
21 j < indexHighlight->
start + indexHighlight->length;
23 Token* currentToken = tokens_index(tokens, j);
24 length += token_length(*currentToken) + currentToken->removedBefore;
27 indexHighlight->start =
start;
28 indexHighlight->length = length;
31 void convertToAbsolutePositions(GArray* diffMatchInfo,
33 GArray* searchTokens) {
34 size_t len = diffMatchInfo->len;
35 for (
size_t i = 0; i < len; i++) {
38 convertToAbsoluteHighlight(textTokens, ¤t->text);
39 convertToAbsoluteHighlight(searchTokens, ¤t->search);
43 DiffPoint getFullHighlightFor(
const GArray* tokens,
size_t firstMatchedIndex,
size_t matchedCount) {
44 size_t matchStart = token_position_of(firstMatchedIndex, tokens);
48 size_t lastMatchedIndex = firstMatchedIndex + matchedCount - 1;
49 Token* lastMatchedToken = tokens_index(tokens, lastMatchedIndex);
50 size_t matchLength = token_position_of(lastMatchedIndex, tokens)
52 + token_length(*lastMatchedToken);
54 return (
DiffPoint){matchStart, matchLength};
start($application)
start the application Assumes application is restartable via /etc/init.d/<script>....