NumeRe v1.1.4
NumeRe: Framework für Numerische Rechnungen
calltipprovider.cpp
Go to the documentation of this file.
1/*****************************************************************************
2 NumeRe: Framework fuer Numerische Rechnungen
3 Copyright (C) 2022 Erik Haenel et al.
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17******************************************************************************/
18
19#include "calltipprovider.hpp"
20#include "language.hpp"
21#include "../utils/tools.hpp"
22#include "../../kernel.hpp"
23
24
25#include <fstream>
26
27extern Language _lang;
28
29namespace NumeRe
30{
41 static CallTip realignLangString(std::string sLine)
42 {
43 size_t lastpos = std::string::npos;
44
45 for (size_t i = 0; i < sLine.length(); i++)
46 {
47 size_t pos;
48
49 if (sLine[i] == '(' && (pos = getMatchingParenthesis(StringView(sLine, i))) != std::string::npos)
50 i += getMatchingParenthesis(StringView(sLine, i));
51
52 if (sLine[i] == ' ')
53 {
54 lastpos = i;
55 break;
56 }
57 }
58
59 if (lastpos == std::string::npos)
60 return {sLine, "", 0, sLine.length()};
61
62 CallTip _cTip;
63
64 _cTip.sDefinition = sLine.substr(0, sLine.find("- "));
66
67 if (sLine.find("- ") != std::string::npos)
68 _cTip.sDocumentation = sLine.substr(sLine.find("- ")+2);
69
70 _cTip.nStart = 0;
71 _cTip.nEnd = lastpos;
72
73 // Find the first non-whitespace character
74 size_t firstpos = _cTip.sDefinition.find_first_not_of(' ', lastpos);
75
76 if (firstpos == std::string::npos)
77 return _cTip;
78
79 // Insert separation characters between syntax element
80 // and return values for functions
81 if (_cTip.sDefinition.find(')') < lastpos || _cTip.sDefinition.find('.') < lastpos)
82 _cTip.sDefinition.replace(lastpos, firstpos - lastpos, " -> ");
83 else if (firstpos - lastpos > 2)
84 _cTip.sDefinition.erase(lastpos, firstpos - lastpos - 1);
85
86 return _cTip;
87 }
88
89
103 static void AppendToDocumentation(CallTip& _cTip, const std::string& sNewDocLine)
104 {
105 static bool bBeginEnd = false;
106
107 if (sNewDocLine.find_first_not_of(" \t") == std::string::npos)
108 {
109 if (_cTip.sDocumentation.length())
110 _cTip.sDocumentation += "\n ";
111
112 return;
113 }
114
115 // Handle some special TeX commands and rudimentary lists
116 if (sNewDocLine.find("\\begin{") != std::string::npos && sNewDocLine.find("\\end{") == std::string::npos)
117 {
118 if (_cTip.sDocumentation.length() && _cTip.sDocumentation[_cTip.sDocumentation.length()-1] != '\n')
119 _cTip.sDocumentation += "\n ";
120
121 bBeginEnd = true;
122 }
123 else if (sNewDocLine.find("\\begin{") == std::string::npos && sNewDocLine.find("\\end{") != std::string::npos)
124 {
125 if (_cTip.sDocumentation.length() && _cTip.sDocumentation[_cTip.sDocumentation.length()-1] != '\n')
126 _cTip.sDocumentation += "\n ";
127
128 bBeginEnd = false;
129 }
130 else if ((sNewDocLine.length()
131 && (sNewDocLine.substr(sNewDocLine.find_first_not_of(" \t"), 2) == "- "
132 || sNewDocLine.substr(sNewDocLine.find_first_not_of(" \t"), 7) == "\\param "
133 || sNewDocLine.substr(sNewDocLine.find_first_not_of(" \t"), 8) == "\\remark ")) || bBeginEnd)
134 {
135 if (_cTip.sDocumentation.length() && _cTip.sDocumentation[_cTip.sDocumentation.length()-1] != '\n')
136 _cTip.sDocumentation += "\n ";
137 }
138 else
139 {
140 if (_cTip.sDocumentation.length() && _cTip.sDocumentation[_cTip.sDocumentation.length()-1] != ' ')
141 _cTip.sDocumentation += " ";
142 }
143
144 _cTip.sDocumentation += sNewDocLine.substr(sNewDocLine.find_first_not_of(" \t"));
145 size_t nPos = _cTip.sDocumentation.find("\\procedure{");
146
147 if (nPos != std::string::npos)
148 _cTip.sDocumentation.erase(nPos, _cTip.sDocumentation.find('}', nPos)+1 - nPos);
149 else if ((nPos = _cTip.sDocumentation.find("\\procedure ")) != std::string::npos)
150 {
151 size_t nPos2 = nPos + 10;
152 nPos2 = _cTip.sDocumentation.find_first_not_of(" \r\n", nPos2);
153 nPos2 = _cTip.sDocumentation.find_first_of(" \r\n", nPos2);
154 _cTip.sDocumentation.erase(nPos, nPos2-nPos);
155 }
156 }
157
158
172 static std::string CleanDocumentation(std::string sDocumentation, std::string& sReturns)
173 {
174 if (sDocumentation.find_first_not_of(" \n") != std::string::npos)
175 {
176 // Clean whitespace before and after the documentation
177 sDocumentation.erase(0, sDocumentation.find_first_not_of(" \n"));
178
179 if (sDocumentation.back() == ' ' || sDocumentation.back() == '\n')
180 sDocumentation.erase(sDocumentation.find_last_not_of(" \n")+1);
181
182 size_t nPos = sDocumentation.find("\\param ");
183
184 // Resolve "\param" keywords
185 if (nPos != std::string::npos)
186 {
187 // Insert a headline above the first parameter
188 if (nPos > 5 && sDocumentation.substr(nPos-5, 5) != "\n ")
189 sDocumentation.insert(nPos, "\n " + toUpperCase(_lang.get("GUI_EDITOR_CALLTIP_PROC_PARAMS")) + "\n ");
190 else
191 sDocumentation.insert(nPos, toUpperCase(_lang.get("GUI_EDITOR_CALLTIP_PROC_PARAMS")) + "\n ");
192
193 while ((nPos = sDocumentation.find("\\param ")) != std::string::npos)
194 {
195 sDocumentation.replace(nPos, 6, "-");
196 size_t spacePos = sDocumentation.find(' ', sDocumentation.find_first_not_of(' ', nPos+1));
197
198 if (spacePos == std::string::npos)
199 break;
200
201 sDocumentation.insert(spacePos, ":");
202
203 if (sDocumentation[sDocumentation.find_first_not_of(' ', nPos+1)] == '_')
204 sDocumentation.erase(sDocumentation.find_first_not_of(' ', nPos+1), 1);
205 }
206 }
207
208 // Extract \return
209 while ((nPos = sDocumentation.find("\\return ")) != std::string::npos)
210 {
211 // Find the next \return or \remark alternatively
212 // This is a candidate for issues with new keywords
213 size_t newReturn = std::min(sDocumentation.find("\\return ", nPos+1), sDocumentation.find("\\remark ", nPos+1));
214
215 // Extract the current return statement and
216 // remove the corresponding part from the
217 // documentation
218 std::string sCurrReturn = sDocumentation.substr(nPos+8, newReturn-nPos-8);
219 sDocumentation.erase(nPos, newReturn-nPos);
220
221 while (sDocumentation.front() == ' ')
222 sDocumentation.erase(0, 1);
223
224 if (sReturns.length())
225 sReturns += ",";
226
227 sReturns += sCurrReturn.substr(0, sCurrReturn.find(' '));
228 }
229
230 // Replace \remark
231 while ((nPos = sDocumentation.find("\\remark ")) != std::string::npos)
232 sDocumentation.replace(nPos, 7, toUpperCase(_lang.get("GUI_EDITOR_CALLTIP_PROC_REMARK"))+":");
233
234 // Remove doubled exclamation marks
235 while ((nPos = sDocumentation.find("!!")) != std::string::npos)
236 sDocumentation.erase(nPos, 2);
237
238 // Replace \begin{} and \end{} with line breaks
239 // This logic bases upon the replacements done
240 // in NumeReEditor::AppendToDocumentation
241 size_t nMatch = 0;
242
243 while ((nMatch = sDocumentation.find("\\begin{")) != std::string::npos)
244 {
245 sDocumentation.erase(nMatch, sDocumentation.find('}', nMatch) + 1 - nMatch);
246
247 if (sDocumentation.substr(nMatch, 5) == "\n ")
248 sDocumentation.erase(nMatch, 5);
249 }
250
251 while ((nMatch = sDocumentation.find("\\end{")) != std::string::npos)
252 {
253 sDocumentation.erase(nMatch, sDocumentation.find('}', nMatch) + 1 - nMatch + 1);
254 }
255
256 // Insert returns
257 if (sReturns.length())
258 {
259 if (sReturns.find(',') == std::string::npos)
260 sReturns = "-> " + sReturns;
261 else
262 sReturns = "-> {" + sReturns + "}";
263 }
264 }
265 else
266 sDocumentation.clear();
267
268 return sDocumentation;
269 }
270
271
286 CallTip FindProcedureDefinition(const std::string& pathname, const std::string& procedurename)
287 {
288 if (!fileExists(pathname + ".nprc"))
289 return CallTip();
290 else
291 {
292 CallTip _cTip;
293 std::ifstream procedure_in;
294 std::string sProcCommandLine;
295 bool bBlockComment = false;
296 std::string sDocumentation;
297 bool bDocFound = false;
298 procedure_in.open(pathname + ".nprc");
299
300 // Ensure that the file is in good state
301 if (!procedure_in.good())
302 return CallTip();
303
304 // As long as we're not at the end of the file
305 while (!procedure_in.eof())
306 {
307 // Read one line and strip all spaces
308 std::getline(procedure_in, sProcCommandLine);
309 StripSpaces(sProcCommandLine);
310
311 // Ignore empty lines
312 if (!sProcCommandLine.length())
313 {
314 _cTip.sDocumentation.clear();
315 bDocFound = false;
316 continue;
317 }
318
319 // Ignore comment lines
320 if (sProcCommandLine.substr(0, 2) == "##")
321 {
322 // Append each documentation string
323 if (sProcCommandLine.substr(0, 3) == "##!")
324 AppendToDocumentation(_cTip, sProcCommandLine.substr(3));
325
326 continue;
327 }
328
329 // Erase line comment parts
330 if (sProcCommandLine.find("##") != std::string::npos)
331 sProcCommandLine = sProcCommandLine.substr(0, sProcCommandLine.find("##"));
332
333 // Remove block comments and continue
334 if (sProcCommandLine.substr(0, 2) == "#*" && sProcCommandLine.find("*#", 2) == std::string::npos)
335 {
336 if (sProcCommandLine.substr(0, 3) == "#*!")
337 {
338 bDocFound = true;
339 AppendToDocumentation(_cTip, sProcCommandLine.substr(3));
340 }
341
342 bBlockComment = true;
343 continue;
344 }
345
346 // Search for the end of the current block comment
347 if (bBlockComment && sProcCommandLine.find("*#") != std::string::npos)
348 {
349 bBlockComment = false;
350
351 if (bDocFound)
352 AppendToDocumentation(_cTip, sProcCommandLine.substr(0, sProcCommandLine.find("*#")));
353 if (sProcCommandLine.find("*#") == sProcCommandLine.length() - 2)
354 continue;
355 else
356 sProcCommandLine = sProcCommandLine.substr(sProcCommandLine.find("*#") + 2);
357 }
358 else if (bBlockComment && sProcCommandLine.find("*#") == std::string::npos)
359 {
360 // if the documentation has a length, append the current block
361 if (bDocFound)
362 AppendToDocumentation(_cTip, sProcCommandLine);
363
364 continue;
365 }
366
367 // Ignore includes
368 if (sProcCommandLine[0] != '@' && findCommand(sProcCommandLine).sString != "procedure")
369 {
370 _cTip.sDocumentation.clear();
371 bDocFound = false;
372 continue;
373 }
374 else if (sProcCommandLine[0] == '@')
375 {
376 _cTip.sDocumentation.clear();
377 bDocFound = false;
378 continue;
379 }
380
381 // Ignore lines without "procedure"
382 if (findCommand(sProcCommandLine).sString != "procedure")
383 {
384 _cTip.sDocumentation.clear();
385 bDocFound = false;
386 continue;
387 }
388
389 // Search for the current procedure name
390 if (sProcCommandLine.find(procedurename) == std::string::npos || sProcCommandLine.find('(') == std::string::npos)
391 {
392 // clear the documentation string
393 _cTip.sDocumentation.clear();
394 bDocFound = false;
395 continue;
396 }
397 else
398 {
399 // Found the procedure name, now extract the definition
400 if (getMatchingParenthesis(sProcCommandLine.substr(sProcCommandLine.find(procedurename))) == std::string::npos)
401 return CallTip();
402
403 _cTip.sDefinition = sProcCommandLine.substr(sProcCommandLine.find(procedurename), getMatchingParenthesis(sProcCommandLine.substr(sProcCommandLine.find(procedurename))) + 1);
404 size_t nFirstParens = _cTip.sDefinition.find('(');
405 std::string sArgList = _cTip.sDefinition.substr(nFirstParens + 1, getMatchingParenthesis(_cTip.sDefinition.substr(nFirstParens)) - 1);
406 _cTip.sDefinition.erase(nFirstParens + 1);
407
408 while (sArgList.length())
409 {
410 std::string currentarg = getNextArgument(sArgList, true);
411
412 if (currentarg.front() == '_')
413 currentarg.erase(0, 1);
414
415 _cTip.sDefinition += currentarg;
416
417 if (sArgList.length())
418 _cTip.sDefinition += ", ";
419 }
420
421 _cTip.sDefinition += ")";
422
423 if (sProcCommandLine.find("::") != std::string::npos)
424 {
425 std::string sFlags = sProcCommandLine.substr(sProcCommandLine.find("::") + 2).c_str();
426
427 if (sFlags.find("##") != std::string::npos)
428 sFlags.erase(sFlags.find("##"));
429
430 StripSpaces(sFlags);
431 _cTip.sDefinition += " :: " + sFlags;
432 }
433
434 // If no documentation was found, search in the following lines
435 if (!_cTip.sDocumentation.length())
436 {
437 while (!procedure_in.eof())
438 {
439 std::getline(procedure_in, sProcCommandLine);
440 StripSpaces(sProcCommandLine);
441
442 if (sProcCommandLine.substr(0, 3) == "##!")
443 AppendToDocumentation(_cTip, sProcCommandLine.substr(3));
444 else if (sProcCommandLine.substr(0, 3) == "#*!")
445 {
446 AppendToDocumentation(_cTip, sProcCommandLine.substr(3));
447 bBlockComment = true;
448 }
449 else if (bBlockComment)
450 {
451 AppendToDocumentation(_cTip, sProcCommandLine.substr(0, sProcCommandLine.find("*#")));
452
453 if (sProcCommandLine.find("*#") != std::string::npos)
454 break;
455 }
456 else
457 break;
458 }
459 }
460
461 std::string sReturns;
462 // clean the documentation
463 _cTip.sDocumentation = CleanDocumentation(_cTip.sDocumentation, sReturns);
464 _cTip.nStart = 0;
465 _cTip.nEnd = std::min(_cTip.sDefinition.length(), _cTip.sDefinition.find("::"));
466
467 // if the documentation has a length, append it here
468 if (sReturns.length())
469 _cTip.sDefinition += " " + sReturns;
470
471 return _cTip;
472 }
473 }
474 }
475
476 return CallTip();
477 }
478
479
490 CallTip addLinebreaks(CallTip _cTip, size_t maxLineLength)
491 {
492 // Remove escaped dollar signs
493 replaceAll(_cTip.sDefinition, "\\$", "$");
494 replaceAll(_cTip.sDocumentation, "\\$", "$");
495
496 if (!_cTip.sDocumentation.length())
497 return _cTip;
498
499 _cTip.sDocumentation.insert(0, " ");
500
501 size_t nIndentPos = 4;
502 size_t nLastLineBreak = 0;
503 bool isItemize = false;
504 std::string& sReturn = _cTip.sDocumentation;
505
506 nLastLineBreak = 0;
507
508 for (size_t i = 0; i < sReturn.length(); i++)
509 {
510 if (sReturn[i] == '\n')
511 {
512 nLastLineBreak = i;
513
514 if (sReturn.substr(i, 7) == "\n - ")
515 isItemize = true;
516 else
517 isItemize = false;
518 }
519
520 if ((i == maxLineLength && !nLastLineBreak)
521 || (nLastLineBreak && i - nLastLineBreak == maxLineLength))
522 {
523 for (int j = i; j >= 0; j--)
524 {
525 if (sReturn[j] == ' ')
526 {
527 sReturn[j] = '\n';
528 sReturn.insert(j + 1, nIndentPos + 2*isItemize, ' ');
529 nLastLineBreak = j;
530 break;
531 }
532 else if (sReturn[j] == '-' && j != (int)i)
533 {
534 // --> Minuszeichen: nicht immer ist das Trennen an dieser Stelle sinnvoll. Wir pruefen die einfachsten Faelle <--
535 if (j &&
536 (sReturn[j - 1] == ' '
537 || sReturn[j - 1] == '('
538 || sReturn[j + 1] == ')'
539 || sReturn[j - 1] == '['
540 || (sReturn[j + 1] >= '0' && sReturn[j + 1] <= '9')
541 || sReturn[j + 1] == ','
542 || (sReturn[j + 1] == '"' && sReturn[j - 1] == '"')
543 ))
544 continue;
545
546 sReturn.insert(j + 1, "\n");
547 sReturn.insert(j + 2, nIndentPos + 2*isItemize, ' ');
548 nLastLineBreak = j + 1;
549 break;
550 }
551 else if (sReturn[j] == ',' && j != (int)i && sReturn[j + 1] != ' ')
552 {
553 sReturn.insert(j + 1, "\n");
554 sReturn.insert(j + 2, nIndentPos + 2*isItemize, ' ');
555 nLastLineBreak = j + 1;
556 break;
557 }
558 }
559 }
560 }
561
562 return _cTip;
563 }
564
565
574 CallTip CallTipProvider::getCommand(std::string sToken) const
575 {
576 if (sToken == "showf")
577 sToken = "show";
578 else if (sToken == "view")
579 sToken = "edit";
580 else if (sToken == "undef")
581 sToken = "undefine";
582 else if (sToken == "ifndef")
583 sToken = "ifndefined";
584 else if (sToken == "redef")
585 sToken = "redefine";
586 else if (sToken == "del")
587 sToken = "delete";
588 else if (sToken == "search")
589 sToken = "find";
590 else if (sToken == "vector")
591 sToken = "vect";
592 else if (sToken == "vector3d")
593 sToken = "vect3d";
594 else if (sToken == "graph")
595 sToken = "plot";
596 else if (sToken == "graph3d")
597 sToken = "plot3d";
598 else if (sToken == "gradient")
599 sToken = "grad";
600 else if (sToken == "gradient3d")
601 sToken = "grad3d";
602 else if (sToken == "surface")
603 sToken = "surf";
604 else if (sToken == "surface3d")
605 sToken = "surf3d";
606 else if (sToken == "meshgrid")
607 sToken = "mesh";
608 else if (sToken == "meshgrid3d")
609 sToken = "mesh3d";
610 else if (sToken == "density")
611 sToken = "dens";
612 else if (sToken == "density3d")
613 sToken = "dens3d";
614 else if (sToken == "contour")
615 sToken = "cont";
616 else if (sToken == "contour3d")
617 sToken = "cont3d";
618 else if (sToken == "mtrxop")
619 sToken = "matop";
620 else if (sToken == "man")
621 sToken = "help";
622 else if (sToken == "credits" || sToken == "info")
623 sToken = "about";
624 else if (sToken == "integrate2" || sToken == "integrate2d")
625 sToken = "integrate";
626
627 return addLinebreaks(realignLangString(_lang.get("PARSERFUNCS_LISTCMD_CMD_" + toUpperCase(sToken) + "_*")), m_maxLineLength);
628 }
629
630
639 CallTip CallTipProvider::getFunction(std::string sToken) const
640 {
641 // Handle aliases
642 if (sToken == "arcsin")
643 sToken = "asin";
644 else if (sToken == "arccos")
645 sToken = "acos";
646 else if (sToken == "arctan")
647 sToken = "atan";
648 else if (sToken == "arsinh")
649 sToken = "asinh";
650 else if (sToken == "arcosh")
651 sToken = "acosh";
652 else if (sToken == "artanh")
653 sToken = "atanh";
654
655 return addLinebreaks(realignLangString(_lang.get("PARSERFUNCS_LISTFUNC_FUNC_" + toUpperCase(sToken) + "_[*")), m_maxLineLength);
656 }
657
658
667 CallTip CallTipProvider::getProcedure(std::string sToken) const
668 {
669 std::string sProcPath = NumeReKernel::getInstance()->getSettings().getProcPath();
670 std::string pathname = sToken;
671 std::string procedurename = pathname.substr(pathname.rfind('~') + 1); // contains a "$", if it's not used for the "thisfile~" case
672
673 // Handle the namespaces
674 if (pathname.find("$this~") != std::string::npos)
675 {
676 // This namespace (the current folder)
677 return CallTip();
678 }
679 else if (pathname.find("$thisfile~") != std::string::npos)
680 {
681 // local namespace
682 return CallTip();
683 }
684 else
685 {
686 // All other namespaces
687 if (pathname.find("$main~") != std::string::npos)
688 pathname.erase(pathname.find("$main~") + 1, 5);
689
690 while (pathname.find('~') != std::string::npos)
691 pathname[pathname.find('~')] = '/';
692
693 // Add the root folders to the path name
694 if (pathname[0] == '$' && pathname.find(':') == std::string::npos)
695 pathname.replace(0, 1, sProcPath + "/");
696 else if (pathname.find(':') == std::string::npos)
697 pathname.insert(0, sProcPath);
698 else // pathname.find(':') != string::npos
699 {
700 // Absolute file paths
701 pathname = pathname.substr(pathname.find('\'') + 1, pathname.rfind('\'') - pathname.find('\'') - 1);
702 }
703 }
704
705 // Find the namespace in absolute procedure paths
706 while (procedurename.find('\'') != std::string::npos)
707 procedurename.erase(procedurename.find('\''), 1);
708
709 if (procedurename.find('/') != std::string::npos)
710 procedurename = "$" + procedurename.substr(procedurename.rfind('/') + 1);
711
712 if (procedurename.find('\\') != std::string::npos)
713 procedurename = "$" + procedurename.substr(procedurename.rfind('\\') + 1);
714
715 if (procedurename[0] != '$')
716 procedurename.insert(0, 1, '$');
717
718 // Find procedure in a global procedure file
719 return addLinebreaks(FindProcedureDefinition(pathname, procedurename), m_maxLineLength);
720 }
721
722
731 CallTip CallTipProvider::getOption(std::string sToken) const
732 {
733 sToken = _lang.get("GUI_EDITOR_CALLTIP_OPT_" + toUpperCase(sToken));
734
735 size_t highlightlength = sToken.length();
736
737 if (sToken.find(' ') != std::string::npos)
738 highlightlength = sToken.find(' ');
739
740 return {sToken, "", 0, highlightlength};
741 }
742
743
752 CallTip CallTipProvider::getMethod(std::string sToken) const
753 {
754 if (_lang.get("PARSERFUNCS_LISTFUNC_METHOD_" + toUpperCase(sToken) + "_[STRING]") != "PARSERFUNCS_LISTFUNC_METHOD_" + toUpperCase(sToken) + "_[STRING]")
755 sToken = "STRINGVAR." + _lang.get("PARSERFUNCS_LISTFUNC_METHOD_" + toUpperCase(sToken) + "_[STRING]");
756 else
757 sToken = "TABLE()." + _lang.get("PARSERFUNCS_LISTFUNC_METHOD_" + toUpperCase(sToken) + "_[DATA]");
758
760 _cTip.nStart = _cTip.sDefinition.find('.')+1;
761
762 return _cTip;
763 }
764
765
774 CallTip CallTipProvider::getPredef(std::string sToken) const
775 {
776 return addLinebreaks(realignLangString(_lang.get("GUI_EDITOR_CALLTIP_" + toUpperCase(sToken))), m_maxLineLength);
777 }
778
779
788 CallTip CallTipProvider::getConstant(std::string sToken) const
789 {
790 CallTip _cTip;
791
792 if (sToken == "_G")
793 _cTip.sDefinition = _lang.get("GUI_EDITOR_CALLTIP_CONST_GRAV_*");
794 else
795 _cTip.sDefinition = _lang.get("GUI_EDITOR_CALLTIP_CONST" + toUpperCase(sToken) + "_*");
796
797 _cTip.nStart = 0;
798 _cTip.nEnd = _cTip.sDefinition.find('=');
799
800 return _cTip;
801 }
802
803
804
805}
806
807
Language _lang
Definition: kernel.cpp:39
This class handles the internal language system and returns the language strings of the selected lang...
Definition: language.hpp:38
std::string get(const std::string &sMessage, const std::vector< std::string > &vTokens) const
This member function returns the language string for the passed language identifier and replaces all ...
Definition: language.cpp:292
CallTip getProcedure(std::string sToken) const
Get the calltip for the selected (global) procedure.
CallTip getOption(std::string sToken) const
Get the calltip for the selected option.
CallTip getConstant(std::string sToken) const
Get the calltip for the selected constant.
CallTip getMethod(std::string sToken) const
Get the calltip for the selected method.
CallTip getFunction(std::string sToken) const
Get the calltip for the selected (built-in) function.
CallTip getCommand(std::string sToken) const
Get the calltip for the selected command.
CallTip getPredef(std::string sToken) const
Get the calltip for the selected predefined symbol.
static NumeReKernel * getInstance()
This static member function returns a a pointer to the singleton instance of the kernel.
Definition: kernel.hpp:221
Settings & getSettings()
Definition: kernel.hpp:296
std::string getProcPath() const
Returns the current procedure root import path.
Definition: settings.hpp:1068
This class is the immutable (const) version of a string view. It can be constructed from a MutableStr...
bool fileExists(const string &)
This function checks, whether the file with the passed file name exists.
Definition: tools.cpp:2500
unsigned int getMatchingParenthesis(const StringView &)
Returns the position of the closing parenthesis.
Definition: tools.cpp:414
CallTip FindProcedureDefinition(const std::string &pathname, const std::string &procedurename)
Search the procedure definition in a global file.
CallTip addLinebreaks(CallTip _cTip, size_t maxLineLength)
Adds the necessary linebreaks to the documentation part of the CallTip to fit inside the desired maxi...
static void AppendToDocumentation(CallTip &_cTip, const std::string &sNewDocLine)
Appends the new documentation line to the already existing line.
static std::string CleanDocumentation(std::string sDocumentation, std::string &sReturns)
Checks layout and finishes styling of the documentation string.
static CallTip realignLangString(std::string sLine)
Converts the language file documentation layout into something more fitting for the calltips in the g...
#define min(a, b)
Definition: resampler.cpp:34
void StripSpaces(std::string &)
Removes leading and trailing white spaces and tabulator characters.
std::string toUpperCase(const std::string &sLowerCase)
Converts lowercase letters to uppercase ones.
std::string getNextArgument(std::string &sArgList, bool bCut)
Definition: tools.cpp:2294
void replaceAll(std::string &sToModify, const char *sToRep, const char *sNewValue, size_t nStart, size_t nEnd)
This function replaces all occurences of the string sToRep in the string sToModify with the new value...
This structure contains the data for a single calltip, which might be shown in the editor or the term...
std::string sDefinition
std::string sDocumentation
Match findCommand(StringView sCmd, const std::string &sCommand)
This function is very important for the command handler.
Definition: tools.cpp:1275