~halega/+junk/sharpdevelop

« back to all changes in this revision

Viewing changes to src/AddIns/Debugger/Debugger.AddIn/Service/RunToCursorCommand.cs

  • Committer: sk
  • Date: 2011-09-10 05:17:57 UTC
  • Revision ID: halega@halega.com-20110910051757-qfouz1llya9m6boy
4.1.0.7915 Release Candidate 1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
 
2
// This code is distributed under the BSD license (for details please see \src\AddIns\Debugger\Debugger.AddIn\license.txt)
 
3
 
 
4
using Debugger;
 
5
using ICSharpCode.Core;
 
6
using ICSharpCode.SharpDevelop.Debugging;
 
7
using ICSharpCode.SharpDevelop.Editor;
 
8
using ICSharpCode.SharpDevelop.Gui;
 
9
 
 
10
namespace ICSharpCode.SharpDevelop.Services
 
11
{
 
12
        public class RunToCursorCommand : AbstractMenuCommand
 
13
        {
 
14
                public override void Run()
 
15
                {
 
16
                        ITextEditorProvider provider = WorkbenchSingleton.Workbench.ActiveViewContent as ITextEditorProvider;
 
17
                        WindowsDebugger winDebugger = DebuggerService.CurrentDebugger as WindowsDebugger;
 
18
                        
 
19
                        if (provider == null || winDebugger == null)
 
20
                                return;
 
21
                        
 
22
                        ITextEditor textEditor = provider.TextEditor;
 
23
                        
 
24
                        Breakpoint breakpoint = winDebugger.DebuggerCore.Breakpoints.Add(textEditor.FileName, null, textEditor.Caret.Line, textEditor.Caret.Column, true);
 
25
                        // Be careful to remove the breakpoint just once
 
26
                        breakpoint.Hit += delegate {
 
27
                                if (breakpoint != null)
 
28
                                        breakpoint.Remove();
 
29
                                breakpoint = null;
 
30
                        };
 
31
                        winDebugger.DebuggedProcess.Paused += delegate {
 
32
                                if (breakpoint != null)
 
33
                                        breakpoint.Remove();
 
34
                                breakpoint = null;
 
35
                        };
 
36
                        if (!winDebugger.IsProcessRunning) {
 
37
                                winDebugger.Continue();
 
38
                        }
 
39
                }
 
40
        }
 
41
}