예제 #1
0
        public static bool ValidateText(string fullText, int maxLines, int maxPerLine)
        {
            List <string> preCodeTextLines = IDEParser.ParseIntoLines(PMWrapper.preCode);
            int           preCodeLineCount = CountCodeLines(preCodeTextLines);

            List <string> mainCodeTextLines = IDEParser.ParseIntoLines(fullText);
            int           mainCodeLineCount = CountCodeLines(mainCodeTextLines);

            if (Progress.instance)
            {
                Progress.instance.levelData[PMWrapper.currentLevel.id].codeLineCount = mainCodeLineCount + preCodeLineCount;
            }
            UISingleton.instance.rowsLimit.UpdateRowsLeft(mainCodeLineCount, maxLines);

            if (mainCodeLineCount > maxLines)
            {
                // Too many rows
                UISingleton.instance.rowsLimit.redness = 1;
                return(false);
            }

            foreach (string t in mainCodeTextLines)
            {
                if (LineSize(t) > maxPerLine)
                {
                    return(false);
                }
            }

            return(true);
        }
예제 #2
0
        public static char MyValidate(
            char c,
            int charIndex,
            bool isPasting,
            List <IndentLevel> toAddLevels,
            string currentText,
            IDETextField theTextField)
        {
            if (isPasting)
            {
                return(c);
            }

            if (c == '\n')
            {
                toAddLevels.Clear();
                toAddLevels.Add(new IndentLevel(charIndex, IDEParser.GetIndentLevel(charIndex, currentText)));
                theTextField.SetNewCaretPos(toAddLevels[0].GetNewCaretPos());

                return('\n');
            }

            return(c);
        }
예제 #3
0
 public void SelectEndOfLine(int lineNumber)
 {
     theTextField.SetNewCaretPos(IDEParser.CalcSelectedLineLastIndex(lineNumber, theInputField.text));
 }