Exemple #1
0
        private void OnExecutionLocationChanged(string source, int line, List <CallStackItem> callstack)
        {
            string fullPathName = GetFullSourcePath(source);

            if (!string.IsNullOrEmpty(fullPathName))
            {
                LuaSourceEditor editor = OpenFile(fullPathName);
                if (editor != null)
                {
                    editor.OnExecutionLocationChanged(line);

                    if (this.waitingForBreakpointToTrigger)
                    {
                        this.TopMost = true;                            // will be reset to false by timer_Tick() to prevent this application to reside on top of all other applications, even when alt-tabbing to a different one
                        this.waitingForBreakpointToTrigger = false;
                    }
                }
            }

            // Update the call stack
            listViewCallStack.Items.Clear();
            foreach (CallStackItem item in callstack)
            {
                ListViewItem listItem = listViewCallStack.Items.Add(item.Description);
                listItem.SubItems.Add(item.Line == 0 ? string.Empty : item.Line.ToString());
                listItem.SubItems.Add(item.Source);
                listItem.Tag = item;
            }

            SetDebugState(DebugState.Halted);
            if (debugger.HostVersion >= 7)
            {
                luaVariablesModel.SetFilter(0, true);
            }
        }
Exemple #2
0
 private void SetDebugState(DebugState state)
 {
     if (state != DebugState.Halted)
     {
         foreach (TabPage page in tabControlSourceFiles.TabPages)
         {
             LuaSourceEditor editor = page.Tag as LuaSourceEditor;
             if (editor != null)
             {
                 editor.ClearExecutionLocation();
             }
         }
         listViewCallStack.Items.Clear();
         treeViewAdvLocals.Enabled = false;
         treeViewAdvWatch.Enabled  = false;
     }
     else
     {
         treeViewAdvLocals.Enabled = true;
         treeViewAdvWatch.Enabled  = true;
         if (!Focused)
         {
             // Flash window to grab user's attention
             FlashWindow();
         }
     }
     continueToolStripMenuItem.Enabled = toolStripButtonContinue.Enabled = (state == DebugState.Halted);
     breakToolStripMenuItem.Enabled    = toolStripButtonBreak.Enabled = (state == DebugState.Executing);
     stepIntoToolStripMenuItem.Enabled = toolStripButtonStepInto.Enabled = (state == DebugState.Halted);
     stepOverToolStripMenuItem.Enabled = toolStripButtonStepOver.Enabled = (state == DebugState.Halted);
     stepOutToolStripMenuItem.Enabled  = toolStripButtonStepOut.Enabled = (state == DebugState.Halted);
 }
Exemple #3
0
        private void OnBreakpointsChanged(bool updateListView)
        {
            // Update the breakpoints window
            if (updateListView)
            {
                listViewBreakpoints.Items.Clear();
                foreach (EditorBreakpoint editorBreakpoint in editorBreakpoints)
                {
                    string       text = string.Format("{0}, line {1}", Path.GetFileName(editorBreakpoint.FileName), editorBreakpoint.Line);
                    ListViewItem item = listViewBreakpoints.Items.Add(text);
                    item.Tag     = editorBreakpoint;
                    item.Checked = editorBreakpoint.Enabled;
                }
            }

            // Update the source editors
            foreach (TabPage page in tabControlSourceFiles.TabPages)
            {
                LuaSourceEditor editor = page.Tag as LuaSourceEditor;
                if (editor != null)
                {
                    UpdateEditorBreakpoints(editor);
                }
            }

            // Update the debugger
            SendBreakpointsToDebugger();
        }
Exemple #4
0
        private void goToToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LuaSourceEditor editor = GetCurrentEditor();

            if (editor != null)
            {
                editor.ShowGoToLine();
            }
        }
Exemple #5
0
        private void findTextDialog_FindText(object sender, FindTextEventArgs e)
        {
            LuaSourceEditor editor = GetCurrentEditor();

            if (editor != null)
            {
                editor.FindText(e.Text, e.Options);
            }
        }
Exemple #6
0
        private void OnFileContentsReceived(string fileName, string contents)
        {
            string          fullPath = GetFullSourcePath(fileName);
            LuaSourceEditor editor   = FindEditor(fullPath);

            if (editor != null)
            {
                editor.SetContents(contents);
            }
        }
Exemple #7
0
 private void CheckFileDifferences()
 {
     foreach (TabPage page in tabControlSourceFiles.TabPages)
     {
         LuaSourceEditor editor = page.Tag as LuaSourceEditor;
         if (editor != null)
         {
             debugger.RequestFileMD5(GetRelativeSourcePath(editor.FileName));
         }
     }
 }
Exemple #8
0
 private void UpdateEditorBreakpoints(LuaSourceEditor editor)
 {
     editor.ClearBreakpoints();
     foreach (EditorBreakpoint editorBreakpoint in editorBreakpoints)
     {
         if (editor.FileName.ToLower() == editorBreakpoint.FileName.ToLower())
         {
             editor.SetBreakpoint(editorBreakpoint.Line, editorBreakpoint.Enabled);
         }
     }
 }
Exemple #9
0
        private void listViewBreakpoints_ItemDoubleClicked(object sender, LuaRemoteDebuggerControls.ItemDoubleClickEventArgs e)
        {
            EditorBreakpoint breakpoint = e.Item.Tag as EditorBreakpoint;

            if (breakpoint != null)
            {
                LuaSourceEditor editor = OpenFile(breakpoint.FileName);
                if (editor != null)
                {
                    editor.GoToLine(breakpoint.Line);
                }
            }
        }
Exemple #10
0
        private void listViewCallStack_ItemDoubleClicked(object sender, LuaRemoteDebuggerControls.ItemDoubleClickEventArgs e)
        {
            CallStackItem?item = e.Item.Tag as CallStackItem?;

            if (item != null && item.Value.Source != null && item.Value.Source.EndsWith(".lua", StringComparison.OrdinalIgnoreCase))
            {
                LuaSourceEditor editor = OpenFile(GetFullSourcePath(item.Value.Source));
                if (editor != null)
                {
                    editor.GoToLine(item.Value.Line);
                }
            }

            if (debugger.HostVersion >= 7)
            {
                luaVariablesModel.SetFilter(item != null ? item.Value.FrameIndex : -1, false);
            }
        }
Exemple #11
0
 private void ToggleBreakpoint()
 {
     if (tabControlSourceFiles.SelectedTab != null)
     {
         LuaSourceEditor editor = tabControlSourceFiles.SelectedTab.Tag as LuaSourceEditor;
         if (editor != null)
         {
             bool             addBreakpoint = true;
             EditorBreakpoint newBreakpoint = new EditorBreakpoint();
             newBreakpoint.FileName = editor.FileName;
             newBreakpoint.Line     = editor.GetSelectedLine();
             foreach (EditorBreakpoint breakpoint in editorBreakpoints)
             {
                 if (breakpoint.FileName.ToLower() == newBreakpoint.FileName.ToLower() &&
                     breakpoint.Line == newBreakpoint.Line)
                 {
                     // Breakpoint already exists
                     if (breakpoint.Enabled)
                     {
                         // Let's remove it if it was enabled
                         editorBreakpoints.Remove(breakpoint);
                         editor.ClearBreakpoint(breakpoint.Line);
                     }
                     else
                     {
                         // Let's enabled it if it was disabled
                         breakpoint.Enabled = true;
                         editor.SetBreakpoint(breakpoint.Line, true);
                     }
                     addBreakpoint = false;
                     break;
                 }
             }
             if (addBreakpoint)
             {
                 editorBreakpoints.Add(newBreakpoint);
                 editor.SetBreakpoint(newBreakpoint.Line, true);
             }
             OnBreakpointsChanged(true);
         }
     }
 }
Exemple #12
0
        private LuaSourceEditor FindEditor(string fileName)
        {
            // Normalize path
            fileName = Path.GetFullPath(fileName);

            foreach (TabPage page in tabControlSourceFiles.TabPages)
            {
                LuaSourceEditor editor = page.Tag as LuaSourceEditor;
                if (editor != null)
                {
                    if (fileName.ToLower() == editor.FileName.ToLower())
                    {
                        // This file is already open, just select it
                        tabControlSourceFiles.SelectedTab = page;
                        return(page.Tag as LuaSourceEditor);
                    }
                }
            }

            return(null);
        }
Exemple #13
0
        private LuaSourceEditor OpenFile(string fileName)
        {
            // Normalize path
            fileName = Path.GetFullPath(fileName);

            LuaSourceEditor editor = FindEditor(fileName);

            if (editor != null)
            {
                return(editor);
            }

            if (!File.Exists(fileName))
            {
                MessageBox.Show(this, string.Format("Source file not found: {0}", fileName), "File not found error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(null);
            }

            debugger.RequestFileMD5(GetRelativeSourcePath(fileName));

            // File not yet open, lets open it
            TabPage         newPage   = new TabPage(Path.GetFileName(fileName));
            LuaSourceEditor newEditor = new LuaSourceEditor();

            newEditor.OnHoverOverVariable += newEditor_OnHoverOverVariable;
            newEditor.BackColor            = System.Drawing.Color.WhiteSmoke;
            newEditor.BorderStyle          = System.Windows.Forms.BorderStyle.None;
            newEditor.Dock = System.Windows.Forms.DockStyle.Fill;
            newEditor.OpenFile(fileName);
            newPage.Controls.Add(newEditor);
            newPage.Tag         = newEditor;
            newPage.ToolTipText = fileName;
            tabControlSourceFiles.TabPages.Add(newPage);
            tabControlSourceFiles.SelectedTab = newPage;

            UpdateEditorBreakpoints(newEditor);

            return(newEditor);
        }
Exemple #14
0
        private void SaveSettings()
        {
            Settings.Default.OpenFiles = new StringCollection();

            foreach (TabPage page in tabControlSourceFiles.TabPages)
            {
                LuaSourceEditor editor = page.Tag as LuaSourceEditor;
                if (editor != null)
                {
                    Settings.Default.OpenFiles.Add(editor.FileName);
                }
            }

            XmlSerializer serializer = new XmlSerializer(typeof(List <EditorBreakpoint>));

            using (MemoryStream memStream = new MemoryStream())
            {
                serializer.Serialize(memStream, editorBreakpoints);

                memStream.Position = 0;

                StreamReader reader  = new StreamReader(memStream);
                string       xmlData = reader.ReadToEnd();

                Settings.Default.Breakpoints = xmlData;
            }

            Settings.Default.FindTextOptions = (int)findTextOptions;

            Settings.Default.EnableCppCallstack = (int)GetCppCallStackMode();

            Settings.Default.WatchVariables = new StringCollection();
            foreach (LuaWatchVariable watchVariable in luaWatchModel.WatchVariables)
            {
                Settings.Default.WatchVariables.Add(watchVariable.Name);
            }

            Settings.Default.Save();
        }