Browse Source

Made tooltip static so only one tooltip can be displayed at one time.

Tooltip now shows current value of local variables/parameters when debugging.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@101 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 21 years ago
parent
commit
8b3d5f9b89
  1. 22
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/WindowsDebugger.cs
  2. 6
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/NDebugger.cs
  3. 18
      src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/TextArea.cs
  4. 2
      src/Main/Base/Project/Src/Internal/Auswerter/IsProcessRunningAuswerter.cs
  5. 23
      src/Main/Base/Project/Src/Services/Debugger/DebuggerService.cs
  6. 8
      src/Main/Base/Project/Src/Services/Debugger/DefaultDebugger.cs
  7. 5
      src/Main/Base/Project/Src/Services/Debugger/IDebugger.cs

22
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/WindowsDebugger.cs

@ -342,5 +342,27 @@ namespace ICSharpCode.SharpDevelop.Services
// WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.ActiveViewContent.RedrawContent(); // WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.ActiveViewContent.RedrawContent();
//} //}
} }
/// <summary>
/// Gets the current value of the variable as string that can be displayed in tooltips.
/// </summary>
public string GetValueAsString(string variableName)
{
VariableCollection collection = NDebugger.LocalVariables;
if (collection == null)
return null;
foreach (Variable v in collection) {
if (v.Name == variableName) {
object val = v.Value;
if (val == null)
return "<null>";
else if (val is string)
return "\"" + val.ToString() + "\"";
else
return val.ToString();
}
}
return null;
}
} }
} }

6
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/NDebugger.cs

@ -1,5 +1,5 @@
// <file> // <file>
// <owner name="David Srbecký" email="dsrbecky@post.cz"/> // <owner name="David Srbeck" email="dsrbecky@post.cz"/>
// </file> // </file>
using System; using System;
@ -308,6 +308,7 @@ namespace DebuggerLibrary
static public Thread CurrentThread { static public Thread CurrentThread {
get { get {
if (!IsDebugging) return null;
return CurrentProcess.CurrentThread; return CurrentProcess.CurrentThread;
} }
set { set {
@ -317,6 +318,7 @@ namespace DebuggerLibrary
static public Thread MainThread { static public Thread MainThread {
get { get {
if (!IsDebugging) return null;
return CurrentProcess.MainThread; return CurrentProcess.MainThread;
} }
set { set {
@ -326,12 +328,14 @@ namespace DebuggerLibrary
static public SourcecodeSegment NextStatement { static public SourcecodeSegment NextStatement {
get { get {
if (!IsDebugging) return null;
return CurrentProcess.NextStatement; return CurrentProcess.NextStatement;
} }
} }
static public VariableCollection LocalVariables { static public VariableCollection LocalVariables {
get { get {
if (!IsDebugging) return null;
return CurrentProcess.LocalVariables; return CurrentProcess.LocalVariables;
} }
} }

18
src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/TextArea.cs

@ -55,9 +55,6 @@ namespace ICSharpCode.TextEditor
SelectionManager selectionManager; SelectionManager selectionManager;
Caret caret; Caret caret;
ToolTip toolTip = new ToolTip();
bool toolTipSet = false;
public TextEditorControl MotherTextEditorControl { public TextEditorControl MotherTextEditorControl {
get { get {
return motherTextEditorControl; return motherTextEditorControl;
@ -296,18 +293,22 @@ namespace ICSharpCode.TextEditor
} }
} }
string oldToolTip;
// static because the mouse can only be in one text area and we don't want to have
// tooltips of text areas from inactive tabs floating around.
static ToolTip toolTip;
static string oldToolTip;
bool toolTipSet;
public void SetToolTip(string text) public void SetToolTip(string text)
{ {
if (toolTip == null) toolTip = new ToolTip();
toolTipSet = (text != null); toolTipSet = (text != null);
if (oldToolTip == text) if (oldToolTip == text)
return; return;
ToolTip toolTip = this.toolTip;
if (text == null) { if (text == null) {
//Console.WriteLine("Tooltip disabled"); toolTip.Hide(this);
toolTip.Hide(this.FindForm());
} else { } else {
//Console.WriteLine("Tooltip set to " + text);
Point p = PointToClient(Control.MousePosition); Point p = PointToClient(Control.MousePosition);
p.Offset(3, 3); p.Offset(3, 3);
toolTip.Show(text, this, p); toolTip.Show(text, this, p);
@ -696,7 +697,6 @@ namespace ICSharpCode.TextEditor
base.Dispose(disposing); base.Dispose(disposing);
if (disposing) { if (disposing) {
Caret.Dispose(); Caret.Dispose();
toolTip.Dispose();
} }
} }

2
src/Main/Base/Project/Src/Internal/Auswerter/IsProcessRunningAuswerter.cs

@ -19,7 +19,7 @@ namespace ICSharpCode.Core
bool isprocessrunning = Boolean.Parse(condition.Properties["isprocessrunning"]); bool isprocessrunning = Boolean.Parse(condition.Properties["isprocessrunning"]);
string isDebugging = condition.Properties.Get("isdebugging", String.Empty); string isDebugging = condition.Properties.Get("isdebugging", String.Empty);
IDebugger debugger = DebuggerService.CurrentDebugger; IDebugger debugger = DebuggerService.CurrentDebugger;
return isprocessrunning == DebuggerService.IsProcessRuning && return isprocessrunning == DebuggerService.IsProcessRunning &&
(isDebugging == String.Empty || (isDebugging == String.Empty ||
DebuggerService.IsDebugging == Boolean.Parse(isDebugging) DebuggerService.IsDebugging == Boolean.Parse(isDebugging)
); );

23
src/Main/Base/Project/Src/Services/Debugger/DebuggerService.cs

@ -66,7 +66,7 @@ namespace ICSharpCode.Core
} }
} }
public static bool IsProcessRuning { public static bool IsProcessRunning {
get { get {
if (standardProcess != null) { if (standardProcess != null) {
return isRunning; return isRunning;
@ -175,7 +175,7 @@ namespace ICSharpCode.Core
public static void StartWithoutDebugging(System.Diagnostics.ProcessStartInfo psi) public static void StartWithoutDebugging(System.Diagnostics.ProcessStartInfo psi)
{ {
if (IsProcessRuning) { if (IsProcessRunning) {
return; return;
} }
try { try {
@ -200,7 +200,7 @@ namespace ICSharpCode.Core
public static void Start(string fileName, string workingDirectory, string arguments) public static void Start(string fileName, string workingDirectory, string arguments)
{ {
if (IsProcessRuning) { if (IsProcessRunning) {
return; return;
} }
oldLayoutConfiguration = LayoutConfiguration.CurrentLayoutName; oldLayoutConfiguration = LayoutConfiguration.CurrentLayoutName;
@ -548,7 +548,9 @@ namespace ICSharpCode.Core
if (expression != null && expression.Length > 0) { if (expression != null && expression.Length > 0) {
if (expression == oldExpression && oldLine == logicPos.Y) { if (expression == oldExpression && oldLine == logicPos.Y) {
// same expression in same line -> reuse old tooltip // same expression in same line -> reuse old tooltip
if (oldToolTip != null) {
textArea.SetToolTip(oldToolTip); textArea.SetToolTip(oldToolTip);
}
// SetToolTip must be called in every mousemove event, // SetToolTip must be called in every mousemove event,
// otherwise textArea will close the tooltip. // otherwise textArea will close the tooltip.
} else { } else {
@ -586,10 +588,21 @@ namespace ICSharpCode.Core
ambience.ConversionFlags = ConversionFlags.UseFullyQualifiedNames ambience.ConversionFlags = ConversionFlags.UseFullyQualifiedNames
| ConversionFlags.ShowReturnType | ConversionFlags.ShowReturnType
| ConversionFlags.QualifiedNamesOnlyForReturnTypes; | ConversionFlags.QualifiedNamesOnlyForReturnTypes;
StringBuilder b = new StringBuilder();
if (rr.IsParameter) if (rr.IsParameter)
return "parameter " + ambience.Convert(rr.Field); b.Append("parameter ");
else else
return "local variable " + ambience.Convert(rr.Field); b.Append("local variable ");
b.Append(ambience.Convert(rr.Field));
IDebugger debugger = CurrentDebugger;
if (debugger != null) {
string currentValue = debugger.GetValueAsString(rr.Field.Name);
if (currentValue != null) {
b.Append(" = ");
b.Append(currentValue);
}
}
return b.ToString();
} else if (result is NamespaceResolveResult) { } else if (result is NamespaceResolveResult) {
return "namespace " + ((NamespaceResolveResult)result).Name; return "namespace " + ((NamespaceResolveResult)result).Name;
} else if (result is TypeResolveResult) { } else if (result is TypeResolveResult) {

8
src/Main/Base/Project/Src/Services/Debugger/DefaultDebugger.cs

@ -134,5 +134,13 @@ namespace ICSharpCode.Core
} }
public event EventHandler DebugStopped; public event EventHandler DebugStopped;
/// <summary>
/// Gets the current value of the variable as string that can be displayed in tooltips.
/// </summary>
public string GetValueAsString(string variable)
{
return null;
}
} }
} }

5
src/Main/Base/Project/Src/Services/Debugger/IDebugger.cs

@ -66,5 +66,10 @@ namespace ICSharpCode.Core
void StepOut(); void StepOut();
event EventHandler DebugStopped; event EventHandler DebugStopped;
/// <summary>
/// Gets the current value of the variable as string that can be displayed in tooltips.
/// </summary>
string GetValueAsString(string variable);
} }
} }

Loading…
Cancel
Save