1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-10 12:32:20 +02:00

Named arguments

This commit is contained in:
Brian Fiete 2022-06-24 18:41:54 -07:00
parent d204922403
commit 79320652e3
15 changed files with 341 additions and 37 deletions

View file

@ -1017,6 +1017,77 @@ namespace IDE.ui
if (cursorSection >= textSections.Count - 1)
cursorSection = textSections.Count - 2;
if (cursorSection < mAutoComplete.mInvokeSrcPositions.Count)
{
var argText = mAutoComplete.mTargetEditWidget.mEditWidgetContent.ExtractString(mAutoComplete.mInvokeSrcPositions[cursorSection - 1],
mAutoComplete.mInvokeSrcPositions[cursorSection] - mAutoComplete.mInvokeSrcPositions[cursorSection - 1], .. scope .());
int colonPos = argText.IndexOf(':');
if (colonPos != -1)
{
do
{
bool foundSep = false;
int nameStart = -1;
for (int i = colonPos - 1; i >= 0; i--)
{
char8 c = argText[i];
if (nameStart == -1)
{
if ((c != '_') && (!c.IsLetterOrDigit))
nameStart = i + 1;
}
else
{
if (!c.IsWhiteSpace)
{
if ((!foundSep) &&
((c == ',') || (c == '(')))
foundSep = true;
else
break;
}
}
}
if (nameStart == -1)
break;
var argParamName = argText.Substring(nameStart, colonPos - nameStart);
for (int checkSectionIdx = 1; checkSectionIdx < textSections.Count; checkSectionIdx++)
{
var sectionStr = textSections[checkSectionIdx];
var checkParamName = sectionStr;
if (checkParamName.EndsWith(','))
checkParamName.RemoveFromEnd(1);
for (int checkIdx = checkParamName.Length - 1; checkIdx >= 0; checkIdx--)
{
char8 c = checkParamName[checkIdx];
if (c.IsWhiteSpace)
{
checkParamName.RemoveFromStart(checkIdx + 1);
break;
}
}
if (checkParamName == argParamName)
{
cursorSection = checkSectionIdx;
break;
}
}
}
}
/*if ((argText.StartsWith('(')) || (argText.StartsWith(',')))
argText.Remove(0, 1);
argText.Trim();
Debug.WriteLine($"ArgText: {argText}");*/
}
float paramX = 0;
for (int sectionIdx = 0; sectionIdx < textSections.Count; sectionIdx++)
{