pascalabcnet/VisualPascalABCNET/IB/Debugger/Actions.cs
Бондарев Иван e6e67c193c initial commit
2015-05-14 21:35:07 +02:00

45 lines
1.5 KiB
C#

using System;
using ICSharpCode.TextEditor;
namespace VisualPascalABC
{
public class AddToWatchAction : ICSharpCode.TextEditor.Actions.AbstractEditAction
{
public override void Execute(TextArea textArea)
{
try
{
int num_line = 0;
string var = null;
if (!textArea.SelectionManager.HasSomethingSelected)
var = WorkbenchServiceFactory.DebuggerManager.GetVariable(textArea, out num_line);
else
{
var = textArea.SelectionManager.SelectedText;
//num_line = textArea.SelectionManager.SelectionStart.Line;
}
if (var == null || var == "")
{
WorkbenchServiceFactory.DebuggerOperationsService.GotoWatch();
return;
//VisualPABCSingleton.MainForm.SetCursorInWatch();
}
ValueItem vi = WorkbenchServiceFactory.DebuggerManager.FindVarByName(var, num_line) as ValueItem;
if (vi != null)
{
VisualPABCSingleton.MainForm.AddVariable(vi);
}
else
{
WorkbenchServiceFactory.DebuggerOperationsService.AddVariable(var, true);
}
}
catch (System.Exception e)
{
WorkbenchServiceFactory.DebuggerOperationsService.GotoWatch();
}
}
}
}