|
|
|
@ -238,8 +238,8 @@ namespace ICSharpCode.Core |
|
|
|
if (e.Content.Control is TextEditor.TextEditorControl) { |
|
|
|
if (e.Content.Control is TextEditor.TextEditorControl) { |
|
|
|
TextArea textArea = ((TextEditor.TextEditorControl)e.Content.Control).ActiveTextAreaControl.TextArea; |
|
|
|
TextArea textArea = ((TextEditor.TextEditorControl)e.Content.Control).ActiveTextAreaControl.TextArea; |
|
|
|
|
|
|
|
|
|
|
|
textArea.IconBarMargin.MouseDown += new MarginMouseEventHandler(IconBarMouseDown); |
|
|
|
textArea.IconBarMargin.MouseDown += IconBarMouseDown; |
|
|
|
textArea.MouseMove += new MouseEventHandler(TextAreaMouseMove); |
|
|
|
textArea.ToolTipRequest += TextAreaToolTipRequest; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -248,8 +248,8 @@ namespace ICSharpCode.Core |
|
|
|
if (e.Content.Control is TextEditor.TextEditorControl) { |
|
|
|
if (e.Content.Control is TextEditor.TextEditorControl) { |
|
|
|
TextArea textArea = ((TextEditor.TextEditorControl)e.Content.Control).ActiveTextAreaControl.TextArea; |
|
|
|
TextArea textArea = ((TextEditor.TextEditorControl)e.Content.Control).ActiveTextAreaControl.TextArea; |
|
|
|
|
|
|
|
|
|
|
|
textArea.IconBarMargin.MouseDown -= new MarginMouseEventHandler(IconBarMouseDown); |
|
|
|
textArea.IconBarMargin.MouseDown -= IconBarMouseDown; |
|
|
|
textArea.MouseMove -= new MouseEventHandler(TextAreaMouseMove); |
|
|
|
textArea.ToolTipRequest -= TextAreaToolTipRequest; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -277,18 +277,16 @@ namespace ICSharpCode.Core |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#region Tool tips
|
|
|
|
#region Tool tips
|
|
|
|
static string oldExpression, oldToolTip; |
|
|
|
|
|
|
|
static DebuggerGridControl oldToolTipControl; |
|
|
|
static DebuggerGridControl oldToolTipControl; |
|
|
|
static int oldLine; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// This function shows variable values as tooltips
|
|
|
|
/// This function shows variable values as tooltips
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
static void TextAreaMouseMove(object sender, MouseEventArgs args) |
|
|
|
static void TextAreaToolTipRequest(object sender, ToolTipRequestEventArgs e) |
|
|
|
{ |
|
|
|
{ |
|
|
|
try { |
|
|
|
try { |
|
|
|
TextArea textArea = (TextArea)sender; |
|
|
|
TextArea textArea = (TextArea)sender; |
|
|
|
if (textArea.ToolTipVisible) return; |
|
|
|
if (e.ToolTipShown) return; |
|
|
|
if (oldToolTipControl != null && !oldToolTipControl.AllowClose) return; |
|
|
|
if (oldToolTipControl != null && !oldToolTipControl.AllowClose) return; |
|
|
|
if (!CodeCompletionOptions.TooltipsEnabled) return; |
|
|
|
if (!CodeCompletionOptions.TooltipsEnabled) return; |
|
|
|
|
|
|
|
|
|
|
|
@ -297,64 +295,47 @@ namespace ICSharpCode.Core |
|
|
|
if (!currentDebugger.IsDebugging) return; |
|
|
|
if (!currentDebugger.IsDebugging) return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Point mousepos = textArea.PointToClient(Control.MousePosition); |
|
|
|
if (e.InDocument) { |
|
|
|
Rectangle viewRect = textArea.TextView.DrawingPosition; |
|
|
|
Point logicPos = e.LogicalPosition; |
|
|
|
if (viewRect.Contains(mousepos)) { |
|
|
|
IDocument doc = textArea.Document; |
|
|
|
Point logicPos = textArea.TextView.GetLogicalPosition(mousepos.X - viewRect.Left, |
|
|
|
IExpressionFinder expressionFinder = ParserService.GetExpressionFinder(textArea.MotherTextEditorControl.FileName); |
|
|
|
mousepos.Y - viewRect.Top); |
|
|
|
if (expressionFinder == null) |
|
|
|
if (logicPos.Y >= 0 && logicPos.Y < textArea.Document.TotalNumberOfLines) { |
|
|
|
return; |
|
|
|
IDocument doc = textArea.Document; |
|
|
|
LineSegment seg = doc.GetLineSegment(logicPos.Y); |
|
|
|
IExpressionFinder expressionFinder = ParserService.GetExpressionFinder(textArea.MotherTextEditorControl.FileName); |
|
|
|
if (logicPos.X > seg.Length - 1) |
|
|
|
if (expressionFinder == null) |
|
|
|
return; |
|
|
|
return; |
|
|
|
string textContent = doc.TextContent; |
|
|
|
LineSegment seg = doc.GetLineSegment(logicPos.Y); |
|
|
|
ExpressionResult expressionResult = expressionFinder.FindFullExpression(textContent, seg.Offset + logicPos.X); |
|
|
|
if (logicPos.X > seg.Length - 1) |
|
|
|
string expression = expressionResult.Expression; |
|
|
|
return; |
|
|
|
if (expression != null && expression.Length > 0) { |
|
|
|
string textContent = doc.TextContent; |
|
|
|
// Look if it is variable
|
|
|
|
ExpressionResult expressionResult = expressionFinder.FindFullExpression(textContent, seg.Offset + logicPos.X); |
|
|
|
ResolveResult result = ParserService.Resolve(expressionResult, logicPos.Y + 1, logicPos.X + 1, textArea.MotherTextEditorControl.FileName, textContent); |
|
|
|
string expression = expressionResult.Expression; |
|
|
|
bool debuggerCanShowValue; |
|
|
|
if (expression != null && expression.Length > 0) { |
|
|
|
string toolTipText = GetText(result, expression, out debuggerCanShowValue); |
|
|
|
if (expression == oldExpression && oldLine == logicPos.Y) { |
|
|
|
DebuggerGridControl toolTipControl = null; |
|
|
|
// same expression in same line -> reuse old tooltip
|
|
|
|
if (toolTipText != null) { |
|
|
|
if (oldToolTip != null) { |
|
|
|
if (Control.ModifierKeys == Keys.Control) { |
|
|
|
textArea.SetToolTip(oldToolTip, oldLine + 1); |
|
|
|
toolTipText = "expr: " + expressionResult.ToString() + "\n" + toolTipText; |
|
|
|
} |
|
|
|
} else if (debuggerCanShowValue && currentDebugger != null) { |
|
|
|
// SetToolTip must be called in every mousemove event,
|
|
|
|
toolTipControl = currentDebugger.GetTooltipControl(expressionResult.Expression); |
|
|
|
// otherwise textArea will close the tooltip.
|
|
|
|
toolTipText = null; |
|
|
|
} else { |
|
|
|
|
|
|
|
// Look if it is variable
|
|
|
|
|
|
|
|
ResolveResult result = ParserService.Resolve(expressionResult, logicPos.Y + 1, logicPos.X + 1, textArea.MotherTextEditorControl.FileName, textContent); |
|
|
|
|
|
|
|
bool debuggerCanShowValue; |
|
|
|
|
|
|
|
string toolTipText = GetText(result, expression, out debuggerCanShowValue); |
|
|
|
|
|
|
|
DebuggerGridControl toolTipControl = null; |
|
|
|
|
|
|
|
if (toolTipText != null) { |
|
|
|
|
|
|
|
if (Control.ModifierKeys == Keys.Control) { |
|
|
|
|
|
|
|
toolTipText = "expr: " + expressionResult.ToString() + "\n" + toolTipText; |
|
|
|
|
|
|
|
} else if (debuggerCanShowValue && currentDebugger != null) { |
|
|
|
|
|
|
|
toolTipControl = currentDebugger.GetTooltipControl(expressionResult.ToString().Replace("<","").Replace(">","")); |
|
|
|
|
|
|
|
toolTipText = null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (toolTipText != null) { |
|
|
|
|
|
|
|
textArea.SetToolTip(toolTipText, logicPos.Y + 1); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (oldToolTipControl != null) { |
|
|
|
|
|
|
|
Form frm = oldToolTipControl.FindForm(); |
|
|
|
|
|
|
|
if (frm != null) frm.Close(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (toolTipControl != null) { |
|
|
|
|
|
|
|
toolTipControl.ShowForm(textArea, logicPos); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
oldToolTip = toolTipText; |
|
|
|
|
|
|
|
oldToolTipControl = toolTipControl; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
oldLine = logicPos.Y; |
|
|
|
if (toolTipText != null) { |
|
|
|
oldExpression = expression; |
|
|
|
e.ShowToolTip(toolTipText); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (oldToolTipControl != null) { |
|
|
|
|
|
|
|
Form frm = oldToolTipControl.FindForm(); |
|
|
|
|
|
|
|
if (frm != null) frm.Close(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (toolTipControl != null) { |
|
|
|
|
|
|
|
toolTipControl.ShowForm(textArea, logicPos); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
oldToolTipControl = toolTipControl; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception ex) { |
|
|
|
ICSharpCode.Core.MessageService.ShowError(e); |
|
|
|
ICSharpCode.Core.MessageService.ShowError(ex); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|