Esempio n. 1
0
        private void GenerateCode()
        {
            LogTextBox.Text = "";

            var dfm = _dfmTextArea.Text;

            _codeTextArea.ClearAll();

            Logger.WriteLn("Code generation beginning..." + Environment.NewLine);

            if (string.IsNullOrWhiteSpace(dfm))
            {
                Logger.WriteLn("Dfm is empty, nothing to do.");
                return;
            }

            try
            {
                var tokens    = Tokenizer.Execute(dfm);
                var dfmObject = DfmParser.Execute(tokens);
                var code      = CodeGen.Execute(dfmObject);

                _codeTextArea.Text = code;
            }
            catch (Exception e)
            {
                Logger.OnLog($"Error occured during processing:{Environment.NewLine}{e}");
            }
        }
        public void AddToPanel(Scintilla editor, Scintilla resultsPanel)
        {
            resultsPanel.ClearAll();

            var indicator = resultsPanel.Indicators[16];

            indicator.ForeColor           = Color.Red;
            indicator.Alpha               = 100;
            indicator.Style               = IndicatorStyle.RoundBox;
            indicator.Under               = true;
            resultsPanel.IndicatorCurrent = indicator.Index;

            //Write lines
            foreach (var item in this.Items)
            {
                var startLine = editor.LineFromPosition(item.cpMin);
                var endLine   = editor.LineFromPosition(item.cpMax);

                if (startLine == endLine)
                {
                    var resultsLinePrefix = $"Line {startLine + 1}: ";

                    resultsPanel.AppendText($"{resultsLinePrefix}{editor.Lines[startLine].Text}");
                }
            }

            //Highlight
            var resultLineIndex = 0;

            foreach (var item in this.Items)
            {
                var startLine = editor.LineFromPosition(item.cpMin);
                var endLine   = editor.LineFromPosition(item.cpMax);

                if (startLine == endLine)
                {
                    var resultsLinePrefix = $"Line {startLine + 1}: ";

                    var linePos        = editor.Lines[startLine].Position;
                    var startPosInLine = item.cpMin - linePos;

                    var lastLineStartPos = resultsPanel.Lines[resultLineIndex].Position;

                    resultsPanel.IndicatorFillRange(lastLineStartPos + resultsLinePrefix.Length + startPosInLine, item.cpMax - item.cpMin);

                    resultLineIndex++;
                }
            }
        }
Esempio n. 3
0
        public void AddToPanel(Scintilla editor, Scintilla resultsPanel)
        {
            resultsPanel.ClearAll();
            foreach (var item in this.Items)
            {
                resultsPanel.AppendText($"Ln {item.LineNumber}, Col {item.LinePosition}: {item.Message}\n");
            }

            if (this.Items.Count == 1)
            {
                // Go to that single line immediately

                // There is a chance that the following happens:
                // - The panel is initially hidden
                // - The line to be selected is below the visible region of the editor
                // - The line gets selected before the panel is shown
                // - When shown, the panel hides the line
                // To prevent this from happening, we introduce a small delay to give the editor time to show the panel
                // TODO: Find a more robust way to achieve the same effect

                Task.Delay(100).ContinueWith(t => Application.Current.Dispatcher?.Invoke(() => this.GoToPosition(1, editor, resultsPanel)), TaskScheduler.Current);
            }
        }
Esempio n. 4
0
 public void Clear()
 {
     _editor.ClearAll();
 }
Esempio n. 5
0
 public void Clear()
 {
     currentPath = "";
     codeEditor.ClearAll();
     mainWindow.Title = LocalizedLangExtension.GetString("MookEditor");
 }