MCPcopy Create free account
hub / github.com/Duet3D/RepRapFirmware / ParseMenuLine

Method ParseMenuLine

src/Display/Menu.cpp:232–448  ·  view source on GitHub ↗

Parse a line in a menu layout file returning any error message, or nullptr if there was no error. Leading whitespace has already been skipped.

Source from the content-addressed store, hash-verified

230// Parse a line in a menu layout file returning any error message, or nullptr if there was no error.
231// Leading whitespace has already been skipped.
232const char *_ecv_array _ecv_null Menu::ParseMenuLine(char *_ecv_array const commandWord) noexcept
233{
234 errorColumn = 0;
235
236 // Check for blank or comment line
237 if (*commandWord == ';' || *commandWord == 0)
238 {
239 return nullptr;
240 }
241
242 // Find the first word
243 char *_ecv_array args = commandWord;
244 while (isalpha(*args))
245 {
246 ++args;
247 }
248 if (args == commandWord || (*args != ' ' && *args != '\t' && *args != 0))
249 {
250 errorColumn = (args - commandWord) + 1;
251 return "Bad command";
252 }
253
254 if (*args != 0)
255 {
256 *args = 0; // null terminate the command word
257 ++args;
258 }
259
260 // Parse the arguments
261 const char *_ecv_array _ecv_null strVis = nullptr;
262 MenuItem::Visibility xVis = MenuItem::AlwaysVisible;
263 unsigned int decimals = 0;
264 unsigned int nparam = 0;
265 const char *_ecv_array _ecv_null strNparam = nullptr;
266 unsigned int width = 0;
267 unsigned int alignment = 0;
268 const char *_ecv_array text = "*";
269 const char *_ecv_array fname = "main";
270 const char *_ecv_array dirpath = "";
271 const char *_ecv_array _ecv_null action = nullptr;
272
273 while (*args != 0 && *args != ';')
274 {
275 char ch;
276 switch (ch = (char)toupper(*args++))
277 {
278 case ' ':
279 case '\t':
280 break;
281
282 case 'R':
283 row = StrToU32(args, &args) + rowOffset;
284 break;
285
286 case 'C':
287 column = StrToU32(args, &args) + currentMargin;
288 break;
289

Callers

nothing calls this directly

Calls 3

GetWidthMethod · 0.80
GetNumFontsMethod · 0.45
GetFontHeightMethod · 0.45

Tested by

no test coverage detected