19 #include "highlight.h" 20 #include "string_operations.h" 22 void convertToAbsoluteHighlight(
const GArray* tokens,
DiffPoint* indexHighlight) {
23 Token* firstToken = tokens_index(tokens, indexHighlight->start);
25 size_t start = token_position_of(indexHighlight->start, tokens);
28 if (indexHighlight->length > 0)
29 length += token_length(*firstToken);
31 for (
size_t j = indexHighlight->start + 1;
32 j < indexHighlight->start + indexHighlight->length;
34 Token* currentToken = tokens_index(tokens, j);
35 length += token_length(*currentToken) + currentToken->removedBefore;
38 indexHighlight->start =
start;
39 indexHighlight->length = length;
42 void convertToAbsolutePositions(GArray* diffMatchInfo,
44 GArray* searchTokens) {
45 size_t len = diffMatchInfo->len;
46 for (
size_t i = 0; i < len; i++) {
49 convertToAbsoluteHighlight(textTokens, ¤t->text);
50 convertToAbsoluteHighlight(searchTokens, ¤t->search);
54 DiffPoint getFullHighlightFor(
const GArray* tokens,
size_t firstMatchedIndex,
size_t matchedCount) {
55 size_t matchStart = token_position_of(firstMatchedIndex, tokens);
59 size_t lastMatchedIndex = firstMatchedIndex + matchedCount - 1;
60 Token* lastMatchedToken = tokens_index(tokens, lastMatchedIndex);
61 size_t matchLength = token_position_of(lastMatchedIndex, tokens)
63 + token_length(*lastMatchedToken);
65 return (
DiffPoint){matchStart, matchLength};
start($application)
start the application Assumes application is restartable via /etc/init.d/<script>. The application passed in should match the script name in /etc/init.d