public override void PreprocessMouseUp(MouseButtonEventArgs e) { if (Settings.Default.AsmDoc_On) { try { if (this.mouseDownAnchorPoint_.HasValue && this.state_.Enabled) { Point currentMousePosition = this.RelativeToView(e.GetPosition(this.view_.VisualElement)); if (!this.InDragOperation(this.mouseDownAnchorPoint_.Value, currentMousePosition)) { this.state_.Enabled = false; ITextViewLine line = this.view_.TextViewLines.GetTextViewLineContainingYCoordinate(currentMousePosition.Y); SnapshotPoint?bufferPosition = line.GetBufferPositionFromXCoordinate(currentMousePosition.X); string keyword = AsmDudeToolsStatic.Get_Keyword_Str(bufferPosition); if (keyword != null) { (Mnemonic mnemonic, AttType type) = AsmSourceTools.ParseMnemonic_Att(keyword, false); System.Runtime.CompilerServices.ConfiguredTaskAwaitable <bool> result = this.Dispatch_Goto_DocAsync(mnemonic).ConfigureAwait(false); // use .ConfigureAwait(false) to signal your intention for continuation. } this.Set_Highlight_Span(null); this.view_.Selection.Clear(); e.Handled = true; } } this.mouseDownAnchorPoint_ = null; } catch (Exception ex) { AsmDudeToolsStatic.Output_ERROR(string.Format(AsmDudeToolsStatic.CultureUI, "{0} PreprocessMouseUp; e={1}", this.ToString(), ex.ToString())); } } }
public AsmTokenType Get_Token_Type_Att(string keyword) { Contract.Requires(keyword != null); Contract.Requires(keyword == keyword.ToUpperInvariant()); int length = keyword.Length; Contract.Requires(length > 0); char firstChar = keyword[0]; #region Test if keyword is a register if (firstChar == '%') { string keyword2 = keyword.Substring(1); Rn reg = RegisterTools.ParseRn(keyword2, true); if (reg != Rn.NOREG) { return((this.RegisterSwitchedOn(reg)) ? AsmTokenType.Register : AsmTokenType.Register); //TODO } } #endregion #region Test if keyword is an imm if (firstChar == '$') { return(AsmTokenType.Constant); } #endregion #region Test if keyword is an instruction { (Mnemonic mnemonic, AttType type) = AsmSourceTools.ParseMnemonic_Att(keyword, true); if (mnemonic != Mnemonic.NONE) { return((this.MnemonicSwitchedOn(mnemonic)) ? AsmSourceTools.IsJump(mnemonic) ? AsmTokenType.Jump : AsmTokenType.Mnemonic : AsmSourceTools.IsJump(mnemonic) ? AsmTokenType.Jump : AsmTokenType.MnemonicOff); } } #endregion return(this.type_.TryGetValue(keyword, out AsmTokenType tokenType) ? tokenType : AsmTokenType.UNKNOWN); }
public AsmTokenType Get_Token_Type_Att(string keyword) { Debug.Assert(keyword == keyword.ToUpper()); int length = keyword.Length; Debug.Assert(length > 0); char firstChar = keyword[0]; #region Test if keyword is a register if (firstChar == '%') { string keyword2 = keyword.Substring(1); Rn reg = RegisterTools.ParseRn(keyword2, true); if (reg != Rn.NOREG) { if (RegisterSwitchedOn(reg)) { return(AsmTokenType.Register); } } } #endregion #region Test if keyword is an imm if (firstChar == '$') { return(AsmTokenType.Constant); } #endregion #region Test if keyword is an instruction { Mnemonic mnemonic = AsmSourceTools.ParseMnemonic_Att(keyword, true); if (mnemonic != Mnemonic.NONE) { if (MnemonicSwitchedOn(mnemonic)) { return((AsmSourceTools.IsJump(mnemonic)) ? AsmTokenType.Jump : AsmTokenType.Mnemonic); } } } #endregion return((this._type.TryGetValue(keyword, out var tokenType)) ? tokenType : AsmTokenType.UNKNOWN); }
private void Handle(IQuickInfoSession session, IList <object> quickInfoContent, out ITrackingSpan applicableToSpan) { applicableToSpan = null; DateTime time1 = DateTime.Now; ITextSnapshot snapshot = this._sourceBuffer.CurrentSnapshot; var triggerPoint = (SnapshotPoint)session.GetTriggerPoint(snapshot); if (triggerPoint == null) { AsmDudeToolsStatic.Output_WARNING("AsmQuickInfoSource:AugmentQuickInfoSession: trigger point is null"); return; } Brush foreground = AsmDudeToolsStatic.Get_Font_Color(); var enumerator = this._aggregator.GetTags(new SnapshotSpan(triggerPoint, triggerPoint)).GetEnumerator(); if (enumerator.MoveNext()) { var asmTokenTag = enumerator.Current; var enumerator2 = asmTokenTag.Span.GetSpans(this._sourceBuffer).GetEnumerator(); if (enumerator2.MoveNext()) { SnapshotSpan tagSpan = enumerator2.Current; string keyword = tagSpan.GetText(); string keywordUpper = keyword.ToUpper(); #region Tests // TODO: multiple tags at the provided triggerPoint is most likely the result of a bug in AsmTokenTagger, but it seems harmless... if (false) { if (enumerator.MoveNext()) { var asmTokenTagX = enumerator.Current; var enumeratorX = asmTokenTagX.Span.GetSpans(this._sourceBuffer).GetEnumerator(); enumeratorX.MoveNext(); AsmDudeToolsStatic.Output_WARNING(string.Format("{0}:AugmentQuickInfoSession. current keyword " + keyword + ": but span has more than one tag! next tag=\"{1}\"", ToString(), enumeratorX.Current.GetText())); } } #endregion //AsmDudeToolsStatic.Output_INFO("AsmQuickInfoSource:AugmentQuickInfoSession: keyword=\""+ keyword + "\"; type=" + asmTokenTag.Tag.type +"; file="+AsmDudeToolsStatic.GetFileName(session.TextView.TextBuffer)); applicableToSpan = snapshot.CreateTrackingSpan(tagSpan, SpanTrackingMode.EdgeInclusive); TextBlock description = null; AsmTokenType type = asmTokenTag.Tag.Type; switch (type) { case AsmTokenType.Misc: { description = new TextBlock(); description.Inlines.Add(Make_Run1("Keyword ", foreground)); description.Inlines.Add(Make_Run2(keyword, new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Misc)))); string descr = this._asmDudeTools.Get_Description(keywordUpper); if (descr.Length > 0) { if (keyword.Length > (AsmDudePackage.maxNumberOfCharsInToolTips / 2)) { descr = "\n" + descr; } description.Inlines.Add(new Run(AsmSourceTools.Linewrap(": " + descr, AsmDudePackage.maxNumberOfCharsInToolTips)) { Foreground = foreground }); } break; } case AsmTokenType.Directive: { description = new TextBlock(); description.Inlines.Add(Make_Run1("Directive ", foreground)); description.Inlines.Add(Make_Run2(keyword, new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Directive)))); string descr = this._asmDudeTools.Get_Description(keywordUpper); if (descr.Length > 0) { if (keyword.Length > (AsmDudePackage.maxNumberOfCharsInToolTips / 2)) { descr = "\n" + descr; } description.Inlines.Add(new Run(AsmSourceTools.Linewrap(": " + descr, AsmDudePackage.maxNumberOfCharsInToolTips)) { Foreground = foreground }); } break; } case AsmTokenType.Register: { int lineNumber = AsmDudeToolsStatic.Get_LineNumber(tagSpan); if (keywordUpper.StartsWith("%")) { keywordUpper = keywordUpper.Substring(1); // remove the preceding % in AT&T syntax } Rn reg = RegisterTools.ParseRn(keywordUpper, true); if (this._asmDudeTools.RegisterSwitchedOn(reg)) { var registerTooltipWindow = new RegisterTooltipWindow(foreground); registerTooltipWindow.SetDescription(reg, this._asmDudeTools); registerTooltipWindow.SetAsmSim(this._asmSimulator, reg, lineNumber, true); quickInfoContent.Add(registerTooltipWindow); } break; } case AsmTokenType.Mnemonic: case AsmTokenType.Jump: { int lineNumber = AsmDudeToolsStatic.Get_LineNumber(tagSpan); Mnemonic mnemonic = AsmSourceTools.ParseMnemonic_Att(keywordUpper, true); if (this._asmDudeTools.MnemonicSwitchedOn(mnemonic)) { var instructionTooltipWindow = new InstructionTooltipWindow(foreground) { Session = session // set the owner of this windows such that we can manually close this window }; instructionTooltipWindow.SetDescription(mnemonic, this._asmDudeTools); instructionTooltipWindow.SetPerformanceInfo(mnemonic, this._asmDudeTools, false); instructionTooltipWindow.SetAsmSim(this._asmSimulator, lineNumber, true); quickInfoContent.Add(instructionTooltipWindow); } break; } case AsmTokenType.Label: { string label = keyword; string labelPrefix = asmTokenTag.Tag.Misc; string full_Qualified_Label = AsmDudeToolsStatic.Make_Full_Qualified_Label(labelPrefix, label, AsmDudeToolsStatic.Used_Assembler); description = new TextBlock(); description.Inlines.Add(Make_Run1("Label ", foreground)); description.Inlines.Add(Make_Run2(full_Qualified_Label, new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Label)))); string descr = Get_Label_Description(full_Qualified_Label); if (descr.Length == 0) { descr = Get_Label_Description(label); } if (descr.Length > 0) { if (keyword.Length > (AsmDudePackage.maxNumberOfCharsInToolTips / 2)) { descr = "\n" + descr; } description.Inlines.Add(new Run(AsmSourceTools.Linewrap(": " + descr, AsmDudePackage.maxNumberOfCharsInToolTips)) { Foreground = foreground }); } break; } case AsmTokenType.LabelDef: { string label = keyword; string extra_Tag_Info = asmTokenTag.Tag.Misc; string full_Qualified_Label; if ((extra_Tag_Info != null) && extra_Tag_Info.Equals(AsmTokenTag.MISC_KEYWORD_PROTO)) { full_Qualified_Label = label; } else { full_Qualified_Label = AsmDudeToolsStatic.Make_Full_Qualified_Label(extra_Tag_Info, label, AsmDudeToolsStatic.Used_Assembler); } AsmDudeToolsStatic.Output_INFO("AsmQuickInfoSource:AugmentQuickInfoSession: found label def " + full_Qualified_Label); description = new TextBlock(); description.Inlines.Add(Make_Run1("Label ", foreground)); description.Inlines.Add(Make_Run2(full_Qualified_Label, new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Label)))); string descr = Get_Label_Def_Description(full_Qualified_Label, label); if (descr.Length > 0) { if (keyword.Length > (AsmDudePackage.maxNumberOfCharsInToolTips / 2)) { descr = "\n" + descr; } description.Inlines.Add(new Run(AsmSourceTools.Linewrap(": " + descr, AsmDudePackage.maxNumberOfCharsInToolTips)) { Foreground = foreground }); } break; } case AsmTokenType.Constant: { description = new TextBlock(); description.Inlines.Add(Make_Run1("Constant ", foreground)); var(Valid, Value, NBits) = AsmSourceTools.Evaluate_Constant(keyword); string constantStr = (Valid) ? Value + "d = " + Value.ToString("X") + "h = " + AsmSourceTools.ToStringBin(Value, NBits) + "b" : keyword; description.Inlines.Add(Make_Run2(constantStr, new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Constant)))); break; } case AsmTokenType.UserDefined1: { description = new TextBlock(); description.Inlines.Add(Make_Run1("User defined 1: ", foreground)); description.Inlines.Add(Make_Run2(keyword, new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Userdefined1)))); string descr = this._asmDudeTools.Get_Description(keywordUpper); if (descr.Length > 0) { if (keyword.Length > (AsmDudePackage.maxNumberOfCharsInToolTips / 2)) { descr = "\n" + descr; } description.Inlines.Add(new Run(AsmSourceTools.Linewrap(": " + descr, AsmDudePackage.maxNumberOfCharsInToolTips)) { Foreground = foreground }); } break; } case AsmTokenType.UserDefined2: { description = new TextBlock(); description.Inlines.Add(Make_Run1("User defined 2: ", foreground)); description.Inlines.Add(Make_Run2(keyword, new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Userdefined2)))); string descr = this._asmDudeTools.Get_Description(keywordUpper); if (descr.Length > 0) { if (keyword.Length > (AsmDudePackage.maxNumberOfCharsInToolTips / 2)) { descr = "\n" + descr; } description.Inlines.Add(new Run(AsmSourceTools.Linewrap(": " + descr, AsmDudePackage.maxNumberOfCharsInToolTips)) { Foreground = foreground }); } break; } case AsmTokenType.UserDefined3: { description = new TextBlock(); description.Inlines.Add(Make_Run1("User defined 3: ", foreground)); description.Inlines.Add(Make_Run2(keyword, new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Userdefined3)))); string descr = this._asmDudeTools.Get_Description(keywordUpper); if (descr.Length > 0) { if (keyword.Length > (AsmDudePackage.maxNumberOfCharsInToolTips / 2)) { descr = "\n" + descr; } description.Inlines.Add(new Run(AsmSourceTools.Linewrap(": " + descr, AsmDudePackage.maxNumberOfCharsInToolTips)) { Foreground = foreground }); } break; } default: //description = new TextBlock(); //description.Inlines.Add(makeRun1("Unused tagType " + asmTokenTag.Tag.type)); break; } if (description != null) { description.FontSize = AsmDudeToolsStatic.Get_Font_Size() + 2; description.FontFamily = AsmDudeToolsStatic.Get_Font_Type(); //AsmDudeToolsStatic.Output_INFO(string.Format("{0}:AugmentQuickInfoSession; setting description fontSize={1}; fontFamily={2}", this.ToString(), description.FontSize, description.FontFamily)); quickInfoContent.Add(description); } } } //AsmDudeToolsStatic.Output_INFO("AsmQuickInfoSource:AugmentQuickInfoSession: applicableToSpan=\"" + applicableToSpan + "\"; quickInfoContent,Count=" + quickInfoContent.Count); AsmDudeToolsStatic.Print_Speed_Warning(time1, "QuickInfo"); }
private void Handle(IQuickInfoSession session, IList <object> quickInfoContent, out ITrackingSpan applicableToSpan) { applicableToSpan = null; DateTime time1 = DateTime.Now; ITextSnapshot snapshot = this.textBuffer_.CurrentSnapshot; SnapshotPoint?triggerPoint = session.GetTriggerPoint(snapshot); if (!triggerPoint.HasValue) { AsmDudeToolsStatic.Output_WARNING(string.Format(AsmDudeToolsStatic.CultureUI, "{0}:Handle: trigger point is null", this.ToString())); return; } Brush foreground = AsmDudeToolsStatic.GetFontColor(); (AsmTokenTag tag, SnapshotSpan? keywordSpan) = AsmDudeToolsStatic.GetAsmTokenTag(this.aggregator_, triggerPoint.Value); if (keywordSpan.HasValue) { SnapshotSpan tagSpan = keywordSpan.Value; string keyword = tagSpan.GetText(); string keyword_upcase = keyword.ToUpperInvariant(); AsmDudeToolsStatic.Output_INFO(string.Format(AsmDudeToolsStatic.CultureUI, "{0}:Handle: keyword=\"{1}\"; type={2}; file=\"{3}\"", this.ToString(), keyword, tag.Type, AsmDudeToolsStatic.GetFilename(session.TextView.TextBuffer))); applicableToSpan = snapshot.CreateTrackingSpan(tagSpan, SpanTrackingMode.EdgeInclusive); TextBlock description = null; switch (tag.Type) { case AsmTokenType.Misc: { description = new TextBlock(); description.Inlines.Add(Make_Run1("Keyword ", foreground)); description.Inlines.Add(Make_Run2(keyword, new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Misc)))); string descr = this.asmDudeTools_.Get_Description(keyword_upcase); if (descr.Length > 0) { if (keyword.Length > (AsmDudePackage.MaxNumberOfCharsInToolTips / 2)) { descr = "\n" + descr; } description.Inlines.Add(new Run(AsmSourceTools.Linewrap(": " + descr, AsmDudePackage.MaxNumberOfCharsInToolTips)) { Foreground = foreground, }); } break; } case AsmTokenType.Directive: { description = new TextBlock(); description.Inlines.Add(Make_Run1("Directive ", foreground)); description.Inlines.Add(Make_Run2(keyword, new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Directive)))); string descr = this.asmDudeTools_.Get_Description(keyword_upcase); if (descr.Length > 0) { if (keyword.Length > (AsmDudePackage.MaxNumberOfCharsInToolTips / 2)) { descr = "\n" + descr; } description.Inlines.Add(new Run(AsmSourceTools.Linewrap(": " + descr, AsmDudePackage.MaxNumberOfCharsInToolTips)) { Foreground = foreground, }); } break; } case AsmTokenType.Register: { int lineNumber = AsmDudeToolsStatic.Get_LineNumber(tagSpan); if (keyword_upcase.StartsWith("%", StringComparison.Ordinal)) { keyword_upcase = keyword_upcase.Substring(1); // remove the preceding % in AT&T syntax } Rn reg = RegisterTools.ParseRn(keyword_upcase, true); if (this.asmDudeTools_.RegisterSwitchedOn(reg)) { RegisterTooltipWindow registerTooltipWindow = new RegisterTooltipWindow(foreground); registerTooltipWindow.SetDescription(reg, this.asmDudeTools_); registerTooltipWindow.SetAsmSim(this.asmSimulator_, reg, lineNumber, true); quickInfoContent.Add(registerTooltipWindow); } break; } case AsmTokenType.Mnemonic: // intentional fall through case AsmTokenType.MnemonicOff: // intentional fall through case AsmTokenType.Jump: { (Mnemonic mnemonic, _) = AsmSourceTools.ParseMnemonic_Att(keyword_upcase, true); InstructionTooltipWindow instructionTooltipWindow = new InstructionTooltipWindow(foreground) { Session = session, // set the owner of this windows such that we can manually close this window }; instructionTooltipWindow.SetDescription(mnemonic, this.asmDudeTools_); instructionTooltipWindow.SetPerformanceInfo(mnemonic, this.asmDudeTools_); int lineNumber = AsmDudeToolsStatic.Get_LineNumber(tagSpan); instructionTooltipWindow.SetAsmSim(this.asmSimulator_, lineNumber, true); quickInfoContent.Add(instructionTooltipWindow); break; } case AsmTokenType.Label: { string label = keyword; string labelPrefix = tag.Misc; string full_Qualified_Label = AsmDudeToolsStatic.Make_Full_Qualified_Label(labelPrefix, label, AsmDudeToolsStatic.Used_Assembler); description = new TextBlock(); description.Inlines.Add(Make_Run1("Label ", foreground)); description.Inlines.Add(Make_Run2(full_Qualified_Label, new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Label)))); string descr = this.Get_Label_Description(full_Qualified_Label); if (descr.Length == 0) { descr = this.Get_Label_Description(label); } if (descr.Length > 0) { if (keyword.Length > (AsmDudePackage.MaxNumberOfCharsInToolTips / 2)) { descr = "\n" + descr; } description.Inlines.Add(new Run(AsmSourceTools.Linewrap(": " + descr, AsmDudePackage.MaxNumberOfCharsInToolTips)) { Foreground = foreground, }); } break; } case AsmTokenType.LabelDef: { string label = keyword; string extra_Tag_Info = tag.Misc; string full_Qualified_Label; if ((extra_Tag_Info != null) && extra_Tag_Info.Equals(AsmTokenTag.MISC_KEYWORD_PROTO, StringComparison.Ordinal)) { full_Qualified_Label = label; } else { full_Qualified_Label = AsmDudeToolsStatic.Make_Full_Qualified_Label(extra_Tag_Info, label, AsmDudeToolsStatic.Used_Assembler); } AsmDudeToolsStatic.Output_INFO("AsmQuickInfoSource:AugmentQuickInfoSession: found label def " + full_Qualified_Label); description = new TextBlock(); description.Inlines.Add(Make_Run1("Label ", foreground)); description.Inlines.Add(Make_Run2(full_Qualified_Label, new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Label)))); string descr = this.Get_Label_Def_Description(full_Qualified_Label, label); if (descr.Length > 0) { if (keyword.Length > (AsmDudePackage.MaxNumberOfCharsInToolTips / 2)) { descr = "\n" + descr; } description.Inlines.Add(new Run(AsmSourceTools.Linewrap(": " + descr, AsmDudePackage.MaxNumberOfCharsInToolTips)) { Foreground = foreground, }); } break; } case AsmTokenType.Constant: { (bool valid, ulong value, int nBits) = AsmSourceTools.Evaluate_Constant(keyword); string constantStr = valid ? value + "d = " + value.ToString("X", AsmDudeToolsStatic.CultureUI) + "h = " + AsmSourceTools.ToStringBin(value, nBits) + "b" : keyword; if (false) // experiment to get text selectable { TextBoxWindow myWindow = new TextBoxWindow(); myWindow.MouseRightButtonUp += this.MyWindow_MouseRightButtonUp; myWindow.MyContent.Text = "Constant X: " + constantStr; myWindow.MyContent.Foreground = foreground; myWindow.MyContent.MouseRightButtonUp += this.MyContent_MouseRightButtonUp; quickInfoContent.Add(myWindow); } else { description = new SelectableTextBlock(); description.Inlines.Add(Make_Run1("Constant ", foreground)); description.Inlines.Add(Make_Run2(constantStr, new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Constant)))); } break; } case AsmTokenType.UserDefined1: { description = new TextBlock(); description.Inlines.Add(Make_Run1("User defined 1: ", foreground)); description.Inlines.Add(Make_Run2(keyword, new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Userdefined1)))); string descr = this.asmDudeTools_.Get_Description(keyword_upcase); if (descr.Length > 0) { if (keyword.Length > (AsmDudePackage.MaxNumberOfCharsInToolTips / 2)) { descr = "\n" + descr; } description.Inlines.Add(new Run(AsmSourceTools.Linewrap(": " + descr, AsmDudePackage.MaxNumberOfCharsInToolTips)) { Foreground = foreground, }); } break; } case AsmTokenType.UserDefined2: { description = new TextBlock(); description.Inlines.Add(Make_Run1("User defined 2: ", foreground)); description.Inlines.Add(Make_Run2(keyword, new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Userdefined2)))); string descr = this.asmDudeTools_.Get_Description(keyword_upcase); if (descr.Length > 0) { if (keyword.Length > (AsmDudePackage.MaxNumberOfCharsInToolTips / 2)) { descr = "\n" + descr; } description.Inlines.Add(new Run(AsmSourceTools.Linewrap(": " + descr, AsmDudePackage.MaxNumberOfCharsInToolTips)) { Foreground = foreground, }); } break; } case AsmTokenType.UserDefined3: { description = new TextBlock(); description.Inlines.Add(Make_Run1("User defined 3: ", foreground)); description.Inlines.Add(Make_Run2(keyword, new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Userdefined3)))); string descr = this.asmDudeTools_.Get_Description(keyword_upcase); if (descr.Length > 0) { if (keyword.Length > (AsmDudePackage.MaxNumberOfCharsInToolTips / 2)) { descr = "\n" + descr; } description.Inlines.Add(new Run(AsmSourceTools.Linewrap(": " + descr, AsmDudePackage.MaxNumberOfCharsInToolTips)) { Foreground = foreground, }); } break; } default: //description = new TextBlock(); //description.Inlines.Add(makeRun1("Unused tagType " + asmTokenTag.Tag.type)); break; } if (description != null) { description.Focusable = true; description.FontSize = AsmDudeToolsStatic.GetFontSize() + 2; description.FontFamily = AsmDudeToolsStatic.GetFontType(); //AsmDudeToolsStatic.Output_INFO(string.Format(AsmDudeToolsStatic.CultureUI, "{0}:AugmentQuickInfoSession; setting description fontSize={1}; fontFamily={2}", this.ToString(), description.FontSize, description.FontFamily)); quickInfoContent.Add(description); } } //AsmDudeToolsStatic.Output_INFO("AsmQuickInfoSource:AugmentQuickInfoSession: applicableToSpan=\"" + applicableToSpan + "\"; quickInfoContent,Count=" + quickInfoContent.Count); AsmDudeToolsStatic.Print_Speed_Warning(time1, "QuickInfo"); }
private bool TryHighlightItemUnderMouse(Point position) { AsmDudeToolsStatic.Output_INFO(string.Format(AsmDudeToolsStatic.CultureUI, "{0}:event: TryHighlightItemUnderMouse; position={1}", this.ToString(), position)); if (!Settings.Default.AsmDoc_On) { return(false); } bool updated = false; try { ITextViewLine line = this.view_.TextViewLines.GetTextViewLineContainingYCoordinate(position.Y); if (line == null) { return(false); } SnapshotPoint?bufferPosition = line.GetBufferPositionFromXCoordinate(position.X); if (!bufferPosition.HasValue) { return(false); } SnapshotPoint triggerPoint = bufferPosition.Value; // Quick check - if the mouse is still inside the current underline span, we're already set SnapshotSpan?currentSpan = this.CurrentUnderlineSpan; if (currentSpan.HasValue && currentSpan.Value.Contains(triggerPoint)) { updated = true; return(true); } (AsmTokenTag tag, SnapshotSpan? keywordSpan) = AsmDudeToolsStatic.GetAsmTokenTag(this.aggregator2_, triggerPoint); if (keywordSpan.HasValue) { switch (tag.Type) { case AsmTokenType.Mnemonic: // intentional fall through case AsmTokenType.MnemonicOff: case AsmTokenType.Jump: { SnapshotSpan tagSpan = keywordSpan.Value; (Mnemonic mnemonic, AttType type) = AsmSourceTools.ParseMnemonic_Att(tagSpan.GetText(), false); string url = this.Get_Url(mnemonic); //Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, "INFO: {0}:TryHighlightItemUnderMouse: keyword={1}; type={2}; url={3}", this.ToString(), keyword, type, url)); if ((url != null) && this.Set_Highlight_Span(keywordSpan)) { updated = true; return(true); } break; } default: break; } } } finally { if (!updated) { this.Set_Highlight_Span(null); } } // No update occurred, so return false return(false); }
private void ToolTipLegacy(SnapshotPoint triggerPoint, Point p) { DateTime time1 = DateTime.Now; ITextSnapshot snapshot = this.textView_.TextSnapshot; (AsmTokenTag tag, SnapshotSpan? keywordSpan) = AsmDudeToolsStatic.GetAsmTokenTag(this.aggregator_, triggerPoint); if (keywordSpan.HasValue) { SnapshotSpan tagSpan = keywordSpan.Value; string keyword = tagSpan.GetText(); string keyword_upcase = keyword.ToUpperInvariant(); //AsmDudeToolsStatic.Output_INFO(string.Format(AsmDudeToolsStatic.CultureUI, "{0}:ToolTipLegacy: keyword=\"{1}\"; type={2}; file=\"{3}\"", this.ToString(), keyword, tag.Type, AsmDudeToolsStatic.GetFilename(this._textView.TextBuffer))); ITrackingSpan applicableTo = snapshot.CreateTrackingSpan(tagSpan, SpanTrackingMode.EdgeInclusive); // check if a tooltip window is already visible for the applicable span if ((this.legacySpan_ != null) && this.legacySpan_.OverlapsWith(tagSpan)) { AsmDudeToolsStatic.Output_INFO(string.Format(AsmDudeToolsStatic.CultureUI, "{0}:ToolTipLegacy: tooltip is already visible. span = {1}, content = {2}", this.ToString(), this.legacySpan_.ToString(), applicableTo.GetText(this.textView_.TextSnapshot))); return; } switch (tag.Type) { case AsmTokenType.Mnemonic: // intentional fall through case AsmTokenType.Jump: { (Mnemonic mnemonic, AttType type) = AsmSourceTools.ParseMnemonic_Att(keyword_upcase, true); InstructionTooltipWindow instructionTooltipWindow = new InstructionTooltipWindow(AsmDudeToolsStatic.GetFontColor()) { Owner = this, // set the owner of this windows such that we can manually close this window }; instructionTooltipWindow.SetDescription(mnemonic, AsmDudeTools.Instance); instructionTooltipWindow.SetPerformanceInfo(mnemonic, AsmDudeTools.Instance); instructionTooltipWindow.Margin = new Thickness(7.0); Border border = new Border() { BorderBrush = System.Windows.Media.Brushes.LightGray, BorderThickness = new Thickness(1.0), CornerRadius = new CornerRadius(2.0), Background = AsmDudeToolsStatic.GetBackgroundColor(), Child = instructionTooltipWindow, }; // cleanup old window remnants if (this.legacyTooltipWindow_ != null) { AsmDudeToolsStatic.Output_INFO(string.Format(AsmDudeToolsStatic.CultureUI, "{0}:ToolTipLegacy: going to cleanup old window remnants.", this.ToString())); if (this.legacyTooltipWindow_.IsLoaded) { this.legacyTooltipWindow_ = null; } else { this.legacyTooltipWindow_?.Close(); } } this.legacyTooltipWindow_ = new Window { WindowStyle = WindowStyle.None, ResizeMode = ResizeMode.NoResize, SizeToContent = SizeToContent.WidthAndHeight, ShowInTaskbar = false, Left = p.X + 15, // placement slightly to the right Top = p.Y + 5, // placement slightly lower such that the code that is selected is visible //TODO find the space to the left and if not enough space is available, place the window more to the left Content = border, }; this.legacyTooltipWindow_.LostKeyboardFocus += (o, i) => { //AsmDudeToolsStatic.Output_INFO("AsmQuickInfoController:LostKeyboardFocus: going to close the tooltip window."); try { (o as Window).Close(); } catch (Exception e) { AsmDudeToolsStatic.Output_WARNING(string.Format(AsmDudeToolsStatic.CultureUI, "{0}:ToolTipLegacy: e={1}", this.ToString(), e.Message)); } }; this.legacySpan_ = tagSpan; this.legacyTooltipWindow_.Show(); this.legacyTooltipWindow_.Focus(); //give the tooltip window focus, such that we can use the lostKeyboardFocus event to close this window; break; } default: break; } //AsmDudeToolsStatic.Output_INFO("AsmQuickInfoSource:AugmentQuickInfoSession: applicableToSpan=\"" + applicableToSpan + "\"; quickInfoContent,Count=" + quickInfoContent.Count); AsmDudeToolsStatic.Print_Speed_Warning(time1, "QuickInfo ToolTipLegacy"); } }