MCPcopy Create free account
hub / github.com/ProgerXP/Notepad2e / IsFunction

Function IsFunction

scintilla/lexers/LexPowerPro.cxx:100–129  ·  view source on GitHub ↗

returns true if there is a function to highlight used to highlight in 'function ' note: sample line (without quotes): "\tfunction asdf() currentPos will be the position of 'a'

Source from the content-addressed store, hash-verified

98// sample line (without quotes): "\tfunction asdf()
99// currentPos will be the position of 'a'
100static bool IsFunction(Accessor &styler, unsigned int currentPos) {
101
102 const char function[10] = "function "; //10 includes \0
103 unsigned int numberOfCharacters = sizeof(function) - 1;
104 unsigned int position = currentPos - numberOfCharacters;
105
106 //compare each character with the letters in the function array
107 //return false if ALL don't match
108 for (unsigned int i = 0; i < numberOfCharacters; i++) {
109 char c = styler.SafeGetCharAt(position++);
110 if (c != function[i])
111 return false;
112 }
113
114 //make sure that there are only spaces (or tabs) between the beginning
115 //of the line and the function declaration
116 position = currentPos - numberOfCharacters - 1; //-1 to move to char before 'function'
117 for (unsigned int j = 0; j < 16; j++) { //check up to 16 preceeding characters
118 char c = styler.SafeGetCharAt(position--, '\0'); //if can't read char, return NUL (past beginning of document)
119 if (c <= 0) //reached beginning of document
120 return true;
121 if (c > 0 && IsLineEndChar(c))
122 return true;
123 else if (c > 0 && !IsASpaceOrTab(c))
124 return false;
125 }
126
127 //fall-through
128 return false;
129}
130
131static void ColourisePowerProDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[],
132 Accessor &styler, bool caseSensitive) {

Callers 1

ColourisePowerProDocFunction · 0.85

Calls 3

IsASpaceOrTabFunction · 0.85
SafeGetCharAtMethod · 0.80
IsLineEndCharFunction · 0.70

Tested by

no test coverage detected