Exemplo n.º 1
0
        /// <summary>
        /// Update debug interface.
        /// </summary>
        private void DebugInterfaceUpdate()
        {
            if (CurrentDebugInfo < 0)
            {
                return;
            }
            var trace = DebugInfo[CurrentDebugInfo];
            var range = new int[2];

            // highlight current debug variable
            range[0] = CompiledEditor.Lines[trace.Location.Line].Position + trace.Location.Column;
            range[1] = range[0] + trace.Location.Length;
            CompiledEditor.ClearIndicators(CodeEditor.DebugHighlight);
            CompiledEditor.AddIndicators(CodeEditor.DebugHighlight, new[] { range });

            // place execution marker
            CompiledEditor.RemoveExecutionMarker();
            CompiledEditor.AddExecutionMarker(trace.Location.Line);

            // scroll debug variable into view
            CompiledEditor.ScrollRange(range[0], range[1]);

            // show debug information for the line
            UpdateDebugListView();
        }
Exemplo n.º 2
0
        /// <summary>
        /// On double clicking on a compiler error, jump to the line where the error happened.
        /// </summary>
        /// <param name="s"></param>
        /// <param name="e"></param>
        private void Output_DoubleClick(object s, EventArgs e)
        {
            // if no item is selected and no code compiled, return
            var view = s as DataGridView;

            if (view.SelectedRows.Count == 0 || CompiledEditor == null)
            {
                return;
            }

            // get line from selected item
            var text = view.SelectedRows[0].Cells[1].Value as string;

            if (!int.TryParse(text, NumberStyles.Integer, CultureInfo.CurrentCulture, out int line))
            {
                return;
            }

            // scroll to line
            line = Math.Max(1, line - CompiledEditor.LinesOnScreen / 2);
            CompiledEditor.LineScroll(line - CompiledEditor.FirstVisibleLine - 1, 0);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Step to next breakpoint.
        /// </summary>
        /// <param name="s"></param>
        /// <param name="e"></param>
        private void DebugStepBreakpoint_Click(object s = null, EventArgs e = null)
        {
            if (DebugInfo.Length == 0)
            {
                return;
            }

            // goto next debug info
            CurrentDebugInfo = ++CurrentDebugInfo % DebugInfo.Length;

            // select all debug information after the current line
            var lines = DebugInfo.Skip(CurrentDebugInfo).Select(x => x.Location.Line);

            // get all breakpoints
            var points = CompiledEditor.GetBreakpoints();

            // find all debug information that contains a breakpoint
            var union = from line in lines
                        join point in points on line equals point
                        select line;

            // next debug line found
            if (union.Count() > 0)
            {
                var line = union.First();
                CurrentDebugInfo = DebugInfo.IndexOf(x => x.Location.Line == line, CurrentDebugInfo);
            }
            // no breakpoint found
            else
            {
                CurrentDebugInfo = -1;
            }

            // update debug interface
            DebugInterfaceUpdate();
        }