private void ScrollViewer_Click(object sender, RoutedEventArgs e) { AsmDudeToolsStatic.Output_INFO("InstructionTooltipWindow:ScrollViewer_Click"); }
public override void PreprocessMouseLeave(MouseEventArgs e) { AsmDudeToolsStatic.Output_INFO(string.Format(AsmDudeToolsStatic.CultureUI, "{0}:event: PreprocessMouseLeave; position={1}", this.ToString(), e)); this.mouseDownAnchorPoint_ = null; }
private async Task <int> Open_File_Async(Mnemonic mnemonic) { if (!ThreadHelper.CheckAccess()) { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); } string url = this.Get_Url(mnemonic); if (url == null) { // this situation happens for all keywords that do not have an url specified (such as registers). //AsmDudeToolsStatic.Output_INFO(string.Format(AsmDudeToolsStatic.CultureUI, "INFO: {0}:openFile; url for keyword \"{1}\" is null.", this.ToString(), keyword)); return(1); } //AsmDudeToolsStatic.Output_INFO(string.Format(AsmDudeToolsStatic.CultureUI, "{0}:Open_File; url={1}", this.ToString(), url)); DTE2 dte2 = Package.GetGlobalService(typeof(SDTE)) as DTE2; if (dte2 == null) { AsmDudeToolsStatic.Output_WARNING(string.Format(AsmDudeToolsStatic.CultureUI, "{0}:Open_File; dte2 is null.", this.ToString())); return(1); } try { EnvDTE.Window window = await GetWindowAsync(dte2, url).ConfigureAwait(false); // use .ConfigureAwait(false) to signal your intention for continuation. if (window == null) { // vsNavigateOptionsDefault 0 The Web page opens in the currently open browser window. (Default) // vsNavigateOptionsNewWindow 1 The Web page opens in a new browser window. AsmDudeToolsStatic.Output_INFO(string.Format(AsmDudeToolsStatic.CultureUI, "{0}:Open_File; going to open url {1}.", this.ToString(), url)); window = dte2.ItemOperations.Navigate(url, EnvDTE.vsNavigateOptions.vsNavigateOptionsNewWindow); string[] parts = url.Split('/'); string caption = parts[parts.Length - 1]; caption = caption.Replace('_', '/'); window.Caption = caption; Action action = new Action(() => { try { ThreadHelper.ThrowIfNotOnUIThread(); if (!window.Caption.Equals(caption, StringComparison.Ordinal)) { window.Caption = caption; } } catch (Exception e) { AsmDudeToolsStatic.Output_ERROR(string.Format(AsmDudeToolsStatic.CultureUI, "{0}:Open_File; exception={1}", this.ToString(), e)); } }); DelayAction(100, action); DelayAction(500, action); DelayAction(1000, action); DelayAction(1500, action); DelayAction(3000, action); } else { window.Activate(); } return(0); } catch (Exception e) { AsmDudeToolsStatic.Output_ERROR(string.Format(AsmDudeToolsStatic.CultureUI, "{0}:Open_File; exception={1}", this.ToString(), e)); return(2); } }
private void Parse() { if (!this._enabled) { return; } lock (this._updateLock) { DateTime time1 = DateTime.Now; ITextSnapshot newSnapshot = this._buffer.CurrentSnapshot; IList <Region> newRegions = new List <Region>(); // keep the current (deepest) partial region, which will have // references to any parent partial regions. PartialRegion currentRegion = null; IEnumerator <ITextSnapshotLine> enumerator = newSnapshot.Lines.GetEnumerator(); ITextSnapshotLine line = null; bool hasNext = enumerator.MoveNext(); bool already_advanced = true; if (hasNext) { line = enumerator.Current; } while (hasNext) { already_advanced = false; #region Parse Line if (line.Length > 0) { string lineContent = line.GetText(); int lineNumber = line.LineNumber; var(regionStart, regionStartHoverText) = Is_Start_Keyword(lineContent, lineNumber); if (regionStart != -1) { Add_Start_Region(lineContent, regionStart, lineNumber, regionStartHoverText, ref currentRegion, newRegions); } else { int regionEnd = Is_End_Keyword(lineContent, lineNumber); if (regionEnd != -1) { Add_End_Region(lineContent, regionEnd, lineNumber, ref currentRegion, newRegions); } else { #region Search for multi-line Remark if (AsmSourceTools.IsRemarkOnly(lineContent)) { int lineNumber2 = -1; string lineContent2 = null; while (enumerator.MoveNext()) { line = enumerator.Current; string lineContent3 = line.GetText(); if (AsmSourceTools.IsRemarkOnly(lineContent3) && (Is_Start_Directive_Keyword(lineContent3).StartPos == -1) && (Is_End_Directive_Keyword(lineContent3) == -1)) { lineNumber2 = line.LineNumber; lineContent2 = lineContent3; already_advanced = false; } else { already_advanced = true; break; } } if (lineNumber2 != -1) { int regionStartPos = AsmSourceTools.GetRemarkCharPosition(lineContent); Add_Start_Region(lineContent, regionStartPos, lineNumber, regionStartPos, ref currentRegion, newRegions); //this.updateChangedSpans(newSnapshot, newRegions); Add_End_Region(lineContent2, 0, lineNumber2, ref currentRegion, newRegions); } } #endregion } } } #endregion Parse Line #region Update Changed Spans Update_Changed_Spans(newSnapshot, newRegions); #endregion #region Advance to next line if (!already_advanced) { hasNext = enumerator.MoveNext(); if (hasNext) { line = enumerator.Current; } } #endregion } AsmDudeToolsStatic.Print_Speed_Warning(time1, "CodeFoldingTagger"); double elapsedSec = (double)(DateTime.Now.Ticks - time1.Ticks) / 10000000; if (elapsedSec > AsmDudePackage.slowShutdownThresholdSec) { # if DEBUG AsmDudeToolsStatic.Output_WARNING("CodeFoldingTagger: Parse: disabled CodeFolding had I been in Release mode"); # else Disable(); # endif }
public HighlightWordTagger(ITextView view, ITextBuffer buffer, ITextSearchService textSearchService, ITextStructureNavigator textStructureNavigator) { this.view_ = view ?? throw new ArgumentNullException(nameof(view)); this.sourceBuffer_ = buffer ?? throw new ArgumentNullException(nameof(buffer)); this.textSearchService_ = textSearchService ?? throw new ArgumentNullException(nameof(textSearchService)); this.textStructureNavigator_ = textStructureNavigator ?? throw new ArgumentNullException(nameof(textStructureNavigator)); if (buffer.CurrentSnapshot.LineCount < AsmDudeToolsStatic.MaxFileLines) { this.wordSpans_ = new NormalizedSnapshotSpanCollection(); this.CurrentWord = null; this.currentWordSpan_ = null; this.NewWord = null; this.NewWordSpan = null; // Subscribe to both change events in the view - any time the view is updated // or the caret is moved, we refresh our list of highlighted words. this.view_.Caret.PositionChanged += this.CaretPositionChanged; this.view_.LayoutChanged += this.ViewLayoutChanged; } else { AsmDudeToolsStatic.Output_WARNING(string.Format(AsmDudeToolsStatic.CultureUI, "{0}:HighlightWordTagger; file {1} contains {2} lines which is more than maxLines {3}; switching off word highlighting", this.ToString(), AsmDudeToolsStatic.GetFilename(buffer), buffer.CurrentSnapshot.LineCount, AsmDudeToolsStatic.MaxFileLines)); } }
public int Exec(ref Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut) { Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread(); try { if (pguidCmdGroup == VSConstants.VSStd2K) { //AsmDudeToolsStatic.Output_INFO(string.Format("{0}:Exec: nCmdID={1}; nCmdexecopt={2}", this.ToString(), nCmdID, nCmdexecopt)); if (nCmdID == (uint)VSConstants.VSStd2KCmdID.RETURN) { // return typed if (this._session != null) { this._session.Dismiss(); this._session = null; } } else if (nCmdID == (uint)VSConstants.VSStd2KCmdID.TYPECHAR) { // character typed SnapshotPoint currentPoint = this._textView.Caret.Position.BufferPosition; if ((currentPoint != null) && (currentPoint > 0)) { SnapshotPoint point = currentPoint - 1; if (point.Position > 1) { ITextSnapshotLine line = point.Snapshot.GetLineFromPosition(point.Position); string lineStr = line.GetText(); int pos = point.Position - line.Start; if (!AsmSourceTools.IsInRemark(pos, lineStr)) { //check if current position is in a remark; if we are in a remark, no signature help char typedChar = this.GetTypeChar(pvaIn); if (char.IsWhiteSpace(typedChar) || typedChar.Equals(',')) { (string Label, Mnemonic Mnemonic, string[] Args, string Remark)t = AsmSourceTools.ParseLine(lineStr); if (this._session != null) { this._session.Dismiss(); // cleanup previous session } if (t.Mnemonic != Mnemonic.NONE) { this._session = this._broker.TriggerSignatureHelp(this._textView); } } else if (AsmSourceTools.IsRemarkChar(typedChar) && (this._session != null)) { this._session.Dismiss(); this._session = null; } } } } } } } catch (Exception e) { AsmDudeToolsStatic.Output_ERROR(string.Format("{0}:Exec; e={1}", this.ToString(), e.ToString())); } return(this._nextCommandHandler.Exec(ref pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut)); }
private void parse(object threadContext) { if (!this._enabled) { return; } this._waiting = true; Thread.Sleep(AsmDudePackage.msSleepBeforeAsyncExecution); this._busy = true; this._waiting = false; #region Payload lock (_updateLock) { DateTime time1 = DateTime.Now; ITextSnapshot newSnapshot = _buffer.CurrentSnapshot; IList <Region> newRegions = new List <Region>(); // keep the current (deepest) partial region, which will have // references to any parent partial regions. PartialRegion currentRegion = null; IEnumerator <ITextSnapshotLine> enumerator = newSnapshot.Lines.GetEnumerator(); ITextSnapshotLine line = null; bool hasNext = enumerator.MoveNext(); bool already_advanced = true; if (hasNext) { line = enumerator.Current; } while (hasNext) { already_advanced = false; #region Parse Line if (line.Length > 0) { string lineContent = line.GetText(); int lineNumber = line.LineNumber; Tuple <int, int> tup = this.isStartKeyword(lineContent, lineNumber); int regionStart = tup.Item1; int regionStartHoverText = tup.Item2; if (regionStart != -1) { this.addStartRegion(lineContent, regionStart, lineNumber, regionStartHoverText, ref currentRegion, newRegions); } else { int regionEnd = this.isEndKeyword(lineContent, lineNumber); if (regionEnd != -1) { this.addEndRegion(lineContent, regionEnd, lineNumber, ref currentRegion, newRegions); } else { #region Search for multi-line Remark if (AsmSourceTools.isRemarkOnly(lineContent)) { int lineNumber2 = -1; string lineContent2 = null; while (enumerator.MoveNext()) { line = enumerator.Current; string lineContent3 = line.GetText(); if (AsmSourceTools.isRemarkOnly(lineContent3) && (this.isStartDirectiveKeyword(lineContent3).Item1 == -1) && (this.isEndDirectiveKeyword(lineContent3) == -1)) { lineNumber2 = line.LineNumber; lineContent2 = lineContent3; already_advanced = false; } else { already_advanced = true; break; } } if (lineNumber2 != -1) { int regionStartPos = AsmSourceTools.getRemarkCharPosition(lineContent); this.addStartRegion(lineContent, regionStartPos, lineNumber, regionStartPos, ref currentRegion, newRegions); //this.updateChangedSpans(newSnapshot, newRegions); this.addEndRegion(lineContent2, 0, lineNumber2, ref currentRegion, newRegions); } } #endregion } } } #endregion Parse Line #region Update Changed Spans this.updateChangedSpans(newSnapshot, newRegions); #endregion #region Advance to next line if (!already_advanced) { hasNext = enumerator.MoveNext(); if (hasNext) { line = enumerator.Current; } } #endregion } AsmDudeToolsStatic.printSpeedWarning(time1, "CodeFoldingTagger"); double elapsedSec = (double)(DateTime.Now.Ticks - time1.Ticks) / 10000000; if (elapsedSec > AsmDudePackage.slowShutdownThresholdSec) { this.disable(); } } #endregion Payload this._busy = false; if (this._scheduled) { this._scheduled = false; this.parse_Delayed(); } }
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("{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 keywordUpper = keyword.ToUpper(); AsmDudeToolsStatic.Output_INFO(string.Format("{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(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)) { 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(keywordUpper, 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)) { 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") + "h = " + AsmSourceTools.ToStringBin(value, nBits) + "b" : keyword; if (true) { 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(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.Focusable = true; description.FontSize = AsmDudeToolsStatic.GetFontSize() + 2; description.FontFamily = AsmDudeToolsStatic.GetFontType(); //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"); }
public AsmDocMouseHandler( IWpfTextView view, IBufferTagAggregatorFactoryService aggregatorFactory, CtrlKeyState state, AsmDudeTools asmDudeTools) { AsmDudeToolsStatic.Output_INFO(string.Format("{0}:constructor: file={1}", this.ToString(), AsmDudeToolsStatic.GetFilename(view.TextBuffer))); this._view = view; this._state = state; this._aggregator2 = AsmDudeToolsStatic.GetOrCreate_Aggregator(view.TextBuffer, aggregatorFactory); this._asmDudeTools = asmDudeTools; this._state.CtrlKeyStateChanged += (sender, args) => { if (Settings.Default.AsmDoc_On) { if (this._state.Enabled) { this.TryHighlightItemUnderMouse(this.RelativeToView(Mouse.PrimaryDevice.GetPosition(this._view.VisualElement))); } else { this.Set_Highlight_Span(null); } } }; // Some other points to clear the highlight span: this._view.LostAggregateFocus += (sender, args) => this.Set_Highlight_Span(null); this._view.VisualElement.MouseLeave += (sender, args) => this.Set_Highlight_Span(null); }
public void Dispose() { AsmDudeToolsStatic.Output_INFO(string.Format("{0}:Dispose", this.ToString())); }
private void PerformanceExpander_MouseLeftDown(object sender, RoutedEventArgs e) { AsmDudeToolsStatic.Output_INFO("InstructionTooltipWindow:PerformanceExpander_MouseLeftDown"); }
private void TextBlock_Click(object sender, RoutedEventArgs e) { AsmDudeToolsStatic.Output_INFO("InstructionTooltipWindow:TextBlock_Click"); }
public void DisconnectSubjectBuffer(ITextBuffer subjectBuffer) { AsmDudeToolsStatic.Output_INFO(string.Format("{0}:DisconnectSubjectBuffer", this.ToString())); }
private async System.Threading.Tasks.Task Update_Error_Tasks_AsmSim_Async() { if (!this._asmSimulator.Enabled) { return; } await System.Threading.Tasks.Task.Run(() => { lock (this._updateLock) { try { if (Settings.Default.AsmSim_Show_Syntax_Errors || Settings.Default.AsmSim_Show_Usage_Of_Undefined) { AsmDudeToolsStatic.Output_INFO("SquigglesTagger:Update_Error_Tasks_AsmSim_Async: going to update the error list"); TaskProvider.TaskCollection errorTasks = this._errorListProvider.Tasks; bool errorListNeedsRefresh = false; #region Remove stale error tasks from the error list for (int i = errorTasks.Count - 1; i >= 0; --i) { AsmMessageEnum subCategory = (AsmMessageEnum)errorTasks[i].SubcategoryIndex; if ((subCategory == AsmMessageEnum.USAGE_OF_UNDEFINED) || (subCategory == AsmMessageEnum.SYNTAX_ERROR) || (subCategory == AsmMessageEnum.REDUNDANT)) { errorTasks.RemoveAt(i); errorListNeedsRefresh = true; } } #endregion if (Settings.Default.AsmSim_Show_Syntax_Errors) { foreach ((int LineNumber, (string Message, Mnemonic Mnemonic)info) in this._asmSimulator.Syntax_Errors) { this.AddErrorTask_Syntax_Error_Async(LineNumber, info.Mnemonic.ToString(), info.Message).ConfigureAwait(false); errorListNeedsRefresh = true; } } if (Settings.Default.AsmSim_Show_Usage_Of_Undefined) { foreach ((int LineNumber, (string Message, Mnemonic Mnemonic)info) in this._asmSimulator.Usage_Undefined) { this.AddErrorTask_Usage_Undefined_Async(LineNumber, info.Mnemonic.ToString(), info.Message).ConfigureAwait(false); errorListNeedsRefresh = true; } } if (Settings.Default.AsmSim_Show_Redundant_Instructions) { foreach ((int LineNumber, (string Message, Mnemonic Mnemonic)info) in this._asmSimulator.Redundant_Instruction) { this.AddErrorTask_Redundant_Instruction_Async(LineNumber, info.Mnemonic.ToString(), info.Message).ConfigureAwait(false); errorListNeedsRefresh = true; } } if (Settings.Default.AsmSim_Show_Unreachable_Instructions) { foreach ((int LineNumber, (string Message, Mnemonic Mnemonic)info) in this._asmSimulator.Unreachable_Instruction) { this.AddErrorTask_Unreachable_Instruction_Async(LineNumber, info.Mnemonic.ToString(), info.Message).ConfigureAwait(false); errorListNeedsRefresh = true; } } if (errorListNeedsRefresh) { this._errorListProvider.Refresh(); //this._errorListProvider.Show(); // do not use BringToFront since that will select the error window. } } } catch (Exception e) { AsmDudeToolsStatic.Output_ERROR(string.Format("{0}:Update_AsmSim_Error_Task_Async; e={1}", this.ToString(), e.ToString())); } } }); }
/// <summary> /// Determine if the mouse is hovering over a token. If so, display QuickInfo /// </summary> private void OnTextViewMouseHover(object sender, MouseHoverEventArgs e) { AsmDudeToolsStatic.Output_INFO(string.Format("{0}:OnTextViewMouseHover: file={1}", this.ToString(), AsmDudeToolsStatic.GetFilename(this._textView.TextBuffer))); try { SnapshotPoint?point = this.GetMousePosition(new SnapshotPoint(this._textView.TextSnapshot, e.Position)); if (point.HasValue) { string contentType = this._textView.TextBuffer.ContentType.DisplayName; if (contentType.Equals(AsmDudePackage.AsmDudeContentType, StringComparison.Ordinal)) { int pos = point.Value.Position; int pos2 = this.Get_Keyword_Span_At_Point(point.Value).Start; //AsmDudeToolsStatic.Output_INFO("AsmQuickInfoController:OnTextViewMouseHover: CreateQuickInfoSession for triggerPoint " + pos + "; pos2=" + pos2); //ITrackingPoint triggerPoint = point.Value.Snapshot.CreateTrackingPoint(pos, PointTrackingMode.Positive); ITrackingPoint triggerPoint = point.Value.Snapshot.CreateTrackingPoint(pos2, PointTrackingMode.Positive); if (this._session == null) { AsmDudeToolsStatic.Output_INFO(string.Format("{0}:OnTextViewMouseHover: A: session was null, create a new session for triggerPoint {1}; pos2={2}", this.ToString(), pos, pos2)); this._session = this._quickInfoBroker.TriggerQuickInfo(this._textView, triggerPoint, false); if (this._session != null) { this._session.Dismissed += this._session_Dismissed; //this._session.ApplicableToSpanChanged += (o, i) => { AsmDudeToolsStatic.Output_INFO("InstructionTooltipWindow:ApplicableToSpanChanged Event"); }; //this._session.PresenterChanged += (o, i) => { AsmDudeToolsStatic.Output_INFO("InstructionTooltipWindow:PresenterChanged Event"); }; //this._session.Recalculated += (o, i) => { AsmDudeToolsStatic.Output_INFO("InstructionTooltipWindow:Recalculated Event"); }; } } else { if (this._session.IsDismissed) { AsmDudeToolsStatic.Output_INFO(string.Format("{0}:OnTextViewMouseHover: B: session was not null but was dismissed, create a new session for triggerPoint {1}; pos2={2}", this.ToString(), pos, pos2)); this._session = this._quickInfoBroker.TriggerQuickInfo(this._textView, triggerPoint, false); if (this._session != null) { this._session.Dismissed += this._session_Dismissed; } } else { if (this._session.ApplicableToSpan.GetSpan(this._textView.TextSnapshot).IntersectsWith(new Span(point.Value.Position, 0))) { AsmDudeToolsStatic.Output_INFO(string.Format("{0}:OnTextViewMouseHover: C: session was not dismissed: intersects!", this.ToString())); } else { AsmDudeToolsStatic.Output_INFO(string.Format("{0}:OnTextViewMouseHover: D: session was not dismissed but we need a new session for triggerPoint {1}; pos2={2}", this.ToString(), pos, pos2)); //if (this._session != null) this._session.Dismiss(); this._session = this._quickInfoBroker.TriggerQuickInfo(this._textView, triggerPoint, false); if (this._session != null) { this._session.Dismissed += this._session_Dismissed; } } } } } else if (contentType.Equals(AsmDudePackage.DisassemblyContentType, StringComparison.Ordinal)) { //AsmDudeToolsStatic.Output_INFO(string.Format("{0}:OnTextViewMouseHover: Quickinfo for disassembly view", ToString())); System.Drawing.Point p = System.Windows.Forms.Control.MousePosition; this.ToolTipLegacy(point.Value, new Point(p.X, p.Y)); } else { AsmDudeToolsStatic.Output_WARNING(string.Format("{0}:OnTextViewMouseHover: does not have have AsmDudeContentType: but has type {1}", this.ToString(), contentType)); } } else { //AsmDudeToolsStatic.Output_INFO("AsmQuickInfoController:OnTextViewMouseHover: point is null; file=" + AsmDudeToolsStatic.GetFileName(this._textView.TextBuffer)); } } catch (Exception e2) { AsmDudeToolsStatic.Output_WARNING(string.Format("{0}:OnTextViewMouseHover: exception={1}", this.ToString(), e2.Message)); } }
private async System.Threading.Tasks.Task Update_Error_Tasks_Labels_Async() { if (!this._labelGraph.Enabled) { return; } await System.Threading.Tasks.Task.Run(() => { lock (this._updateLock) { try { #region Update Error Tasks if (Settings.Default.IntelliSense_Show_Clashing_Labels || Settings.Default.IntelliSense_Show_Undefined_Labels || Settings.Default.IntelliSense_Show_Undefined_Includes) { TaskProvider.TaskCollection errorTasks = this._errorListProvider.Tasks; bool errorListNeedsRefresh = false; #region Remove stale error tasks from the error list for (int i = errorTasks.Count - 1; i >= 0; --i) { AsmMessageEnum subCategory = (AsmMessageEnum)errorTasks[i].SubcategoryIndex; if ((subCategory == AsmMessageEnum.LABEL_UNDEFINED) || (subCategory == AsmMessageEnum.LABEL_CLASH) || (subCategory == AsmMessageEnum.INCLUDE_UNDEFINED)) { errorTasks.RemoveAt(i); errorListNeedsRefresh = true; } } #endregion if (Settings.Default.IntelliSense_Show_Clashing_Labels) { foreach ((uint Key, string Value) in this._labelGraph.Label_Clashes) // TODO Label_Clashes does not return the classes in any particular order, { string label = Value; int lineNumber = this._labelGraph.Get_Linenumber(Key); //TODO retrieve the lineContent of the correct buffer! string lineContent = this._sourceBuffer.CurrentSnapshot.GetLineFromLineNumber(lineNumber).GetText(); ErrorTask errorTask = new ErrorTask() { SubcategoryIndex = (int)AsmMessageEnum.LABEL_CLASH, Line = this._labelGraph.Get_Linenumber(Key), Column = this.Get_Keyword_Begin_End(lineContent, label), Text = "Label Clash: \"" + label + "\"", ErrorCategory = TaskErrorCategory.Warning, Document = this._labelGraph.Get_Filename(Key) }; errorTask.Navigate += AsmDudeToolsStatic.Error_Task_Navigate_Handler; errorTasks.Add(errorTask); errorListNeedsRefresh = true; } } if (Settings.Default.IntelliSense_Show_Undefined_Labels) { foreach ((uint Key, string Value) in this._labelGraph.Undefined_Labels) { string label = Value; int lineNumber = this._labelGraph.Get_Linenumber(Key); //TODO retrieve the lineContent of the correct buffer! string lineContent = this._sourceBuffer.CurrentSnapshot.GetLineFromLineNumber(lineNumber).GetText(); ErrorTask errorTask = new ErrorTask() { SubcategoryIndex = (int)AsmMessageEnum.LABEL_UNDEFINED, Line = lineNumber, Column = this.Get_Keyword_Begin_End(lineContent, label), Text = "Undefined Label: \"" + label + "\"", ErrorCategory = TaskErrorCategory.Warning, Document = this._labelGraph.Get_Filename(Key) }; errorTask.Navigate += AsmDudeToolsStatic.Error_Task_Navigate_Handler; errorTasks.Add(errorTask); errorListNeedsRefresh = true; } } if (Settings.Default.IntelliSense_Show_Undefined_Includes) { foreach ((string Include_Filename, string Path, string Source_Filename, int LineNumber)entry in this._labelGraph.Undefined_Includes) { string include = entry.Include_Filename; int lineNumber = entry.LineNumber; //TODO retrieve the lineContent of the correct buffer! string lineContent = this._sourceBuffer.CurrentSnapshot.GetLineFromLineNumber(lineNumber).GetText(); ErrorTask errorTask = new ErrorTask() { SubcategoryIndex = (int)AsmMessageEnum.INCLUDE_UNDEFINED, Line = lineNumber, Column = this.Get_Keyword_Begin_End(lineContent, include), Text = "Could not resolve include \"" + include + "\" at line " + (lineNumber + 1) + " in file \"" + entry.Source_Filename + "\"", ErrorCategory = TaskErrorCategory.Warning, Document = entry.Source_Filename }; errorTask.Navigate += AsmDudeToolsStatic.Error_Task_Navigate_Handler; errorTasks.Add(errorTask); errorListNeedsRefresh = true; } } if (errorListNeedsRefresh) { this._errorListProvider.Refresh(); //this._errorListProvider.Show(); // do not use BringToFront since that will select the error window. } } #endregion Update Error Tasks } catch (Exception e) { AsmDudeToolsStatic.Output_ERROR(string.Format("{0}:Update_Error_Tasks_Labels_Async; e={1}", this.ToString(), e.ToString())); } } }); }
public IEnumerable <ITagSpan <IErrorTag> > GetTags(NormalizedSnapshotSpanCollection spans) { if (spans.Count == 0) { // there is no content in the buffer yield break; } bool labelGraph_Enabled = this._labelGraph.Enabled; bool asmSimulator_Enabled = this._asmSimulator.Enabled; if (!labelGraph_Enabled && !asmSimulator_Enabled) { // nothing to decorate yield break; } DateTime time1 = DateTime.Now; //TODO move the followign boolean to constructor bool Decorate_Undefined_Labels = labelGraph_Enabled && Settings.Default.IntelliSense_Decorate_Undefined_Labels; bool Decorate_Clashing_Labels = labelGraph_Enabled && Settings.Default.IntelliSense_Decorate_Clashing_Labels; bool Decorate_Undefined_Includes = labelGraph_Enabled && Settings.Default.IntelliSense_Show_Undefined_Includes; bool Decorate_Registers_Known_Register_Values = asmSimulator_Enabled && Settings.Default.AsmSim_Decorate_Registers; bool Decorate_Syntax_Errors = asmSimulator_Enabled && Settings.Default.AsmSim_Decorate_Syntax_Errors; bool Decorate_Unimplemented = asmSimulator_Enabled && Settings.Default.AsmSim_Decorate_Unimplemented; bool Decorate_Usage_Of_Undefined = asmSimulator_Enabled && Settings.Default.AsmSim_Decorate_Usage_Of_Undefined; bool Decorate_Redundant_Instructions = asmSimulator_Enabled && Settings.Default.AsmSim_Decorate_Redundant_Instructions; bool Decorate_Unreachable_Instructions = asmSimulator_Enabled && Settings.Default.AsmSim_Decorate_Unreachable_Instructions; bool Show_Syntax_Error_Error_List = asmSimulator_Enabled && Settings.Default.AsmSim_Show_Syntax_Errors; bool Show_Usage_Of_Undefined = asmSimulator_Enabled && Settings.Default.AsmSim_Show_Usage_Of_Undefined; AssemblerEnum usedAssember = AsmDudeToolsStatic.Used_Assembler; foreach (IMappingTagSpan <AsmTokenTag> asmTokenTag in this._aggregator.GetTags(spans)) { SnapshotSpan tagSpan = asmTokenTag.Span.GetSpans(this._sourceBuffer)[0]; //AsmDudeToolsStatic.Output_INFO(string.Format("SquigglesTagger:GetTags: found keyword \"{0}\"", tagSpan.GetText())); int lineNumber = AsmDudeToolsStatic.Get_LineNumber(tagSpan); switch (asmTokenTag.Tag.Type) { case AsmTokenType.Label: { if (Decorate_Undefined_Labels) { string label = tagSpan.GetText(); string full_Qualified_Label = AsmDudeToolsStatic.Make_Full_Qualified_Label(asmTokenTag.Tag.Misc, label, usedAssember); if (this._labelGraph.Has_Label(full_Qualified_Label)) { // Nothing to report } else { //AsmDudeToolsStatic.Output_INFO(string.Format("SquigglesTagger:GetTags: found label \"{0}\"; full-label \"{1}\"", label, full_Qualified_Label)); if (usedAssember == AssemblerEnum.MASM) { if (this._labelGraph.Has_Label(label)) { // TODO: is this always a valid label? Nothing to report } else { TextBlock toolTipContent = this.Undefined_Label_Tool_Tip_Content(); yield return(new TagSpan <IErrorTag>(tagSpan, new ErrorTag(PredefinedErrorTypeNames.SyntaxError, toolTipContent))); } } else { TextBlock toolTipContent = this.Undefined_Label_Tool_Tip_Content(); yield return(new TagSpan <IErrorTag>(tagSpan, new ErrorTag(PredefinedErrorTypeNames.SyntaxError, toolTipContent))); } } } break; } case AsmTokenType.LabelDef: { if (Decorate_Clashing_Labels) { string label = tagSpan.GetText(); string full_Qualified_Label = AsmDudeToolsStatic.Make_Full_Qualified_Label(asmTokenTag.Tag.Misc, label, usedAssember); if (this._labelGraph.Has_Label_Clash(full_Qualified_Label)) { TextBlock toolTipContent = this.Label_Clash_Tool_Tip_Content(full_Qualified_Label); //PredefinedErrorTypeNames.Warning is green //PredefinedErrorTypeNames.SyntaxError is red //PredefinedErrorTypeNames.CompilerError is blue //PredefinedErrorTypeNames.Suggestion is NOTHING //PredefinedErrorTypeNames.OtherError is purple yield return(new TagSpan <IErrorTag>(tagSpan, new ErrorTag(PredefinedErrorTypeNames.SyntaxError, toolTipContent))); } } break; } case AsmTokenType.Register: { if (Decorate_Registers_Known_Register_Values) { Rn regName = RegisterTools.ParseRn(tagSpan.GetText()); //AsmDudeToolsStatic.Output_INFO("SquigglesTagger:GetTags: found register " + regName + " at line " + lineNumber); bool preCompute = false; (bool HasValue1, bool Bussy1) = this._asmSimulator.Has_Register_Value(regName, lineNumber, true, preCompute); if (!Bussy1) { (bool HasValue2, bool Bussy2) = this._asmSimulator.Has_Register_Value(regName, lineNumber, false, preCompute); if (!Bussy2) { if (HasValue1 || HasValue2) { // only show squiggles to indicate that information is available //AsmDudeToolsStatic.Output_INFO("SquigglesTagger:GetTags: adding squiggles for register " + regName + " at line " + lineNumber); yield return(new TagSpan <IErrorTag>(tagSpan, new ErrorTag(PredefinedErrorTypeNames.Warning))); } } } } break; } case AsmTokenType.Mnemonic: { if (Decorate_Syntax_Errors || Decorate_Unimplemented) { if (this._asmSimulator.Is_Implemented(lineNumber)) { if (Decorate_Syntax_Errors && this._asmSimulator.Has_Syntax_Error(lineNumber)) { string message = AsmSourceTools.Linewrap("Syntax Error: " + this._asmSimulator.Get_Syntax_Error(lineNumber).Message, AsmDudePackage.maxNumberOfCharsInToolTips); yield return(new TagSpan <IErrorTag>(tagSpan, new ErrorTag(PredefinedErrorTypeNames.SyntaxError, message))); } } else if (Decorate_Unimplemented) { string message = AsmSourceTools.Linewrap("Info: Instruction " + tagSpan.GetText() + " is not (yet) supported by the simulator.", AsmDudePackage.maxNumberOfCharsInToolTips); yield return(new TagSpan <IErrorTag>(tagSpan, new ErrorTag(PredefinedErrorTypeNames.CompilerError, message))); } } if (Decorate_Usage_Of_Undefined) { if (this._asmSimulator.Has_Usage_Undefined_Warning(lineNumber)) { string message = AsmSourceTools.Linewrap("Semantic Warning: " + this._asmSimulator.Get_Usage_Undefined_Warning(lineNumber).Message, AsmDudePackage.maxNumberOfCharsInToolTips); yield return(new TagSpan <IErrorTag>(tagSpan, new ErrorTag(PredefinedErrorTypeNames.OtherError, message))); } } if (Decorate_Redundant_Instructions) { if (this._asmSimulator.Has_Redundant_Instruction_Warning(lineNumber)) { string message = AsmSourceTools.Linewrap("Semantic Warning: " + this._asmSimulator.Get_Redundant_Instruction_Warning(lineNumber).Message, AsmDudePackage.maxNumberOfCharsInToolTips); yield return(new TagSpan <IErrorTag>(tagSpan, new ErrorTag(PredefinedErrorTypeNames.OtherError, message))); } } if (Decorate_Unreachable_Instructions) { if (this._asmSimulator.Has_Unreachable_Instruction_Warning(lineNumber)) { string message = AsmSourceTools.Linewrap("Semantic Warning: " + this._asmSimulator.Get_Unreachable_Instruction_Warning(lineNumber).Message, AsmDudePackage.maxNumberOfCharsInToolTips); yield return(new TagSpan <IErrorTag>(tagSpan, new ErrorTag(PredefinedErrorTypeNames.OtherError, message))); } } break; } case AsmTokenType.Constant: { if (Decorate_Undefined_Includes) { foreach ((string Include_Filename, string Path, string Source_Filename, int LineNumber)tup in this._labelGraph.Undefined_Includes) { if (tup.LineNumber == lineNumber) //TODO this is inefficient! { string toolTipContent = "Could not resolve include \"" + tagSpan.GetText() + "\""; yield return(new TagSpan <IErrorTag>(tagSpan, new ErrorTag(PredefinedErrorTypeNames.SyntaxError, toolTipContent))); break; // leave the foreach loop } } } break; } default: break; } } AsmDudeToolsStatic.Print_Speed_Warning(time1, "SquiggleTagger"); }
/// <summary> /// The currently highlighted word has changed. Update the adornments to reflect this change /// </summary> private void Update_Word_Adornments() { try { DateTime time1 = DateTime.Now; if (this.NewWord.Length > 0) { ITextSnapshot s = this.RequestedPoint.Snapshot; SnapshotSpan sp = this.NewWordSpan.Value; // Find the new spans FindData findData; Rn reg = RegisterTools.ParseRn(this.NewWord); if (reg != Rn.NOREG) { AsmDudeToolsStatic.Output_INFO(string.Format(AsmDudeToolsStatic.CultureUI, "{0}:Update_Word_Adornments. Register={1}", this.ToString(), this.NewWord)); string t = RegisterTools.GetRelatedRegister(reg); findData = new FindData(t, s) { FindOptions = FindOptions.WholeWord | FindOptions.SingleLine | FindOptions.UseRegularExpressions, }; } else { (bool valid, ulong value, int nBits) = AsmSourceTools.Parse_Constant(this.NewWord); if (valid) { AsmDudeToolsStatic.Output_INFO(string.Format(AsmDudeToolsStatic.CultureUI, "{0}:Update_Word_Adornments. Contant={1}", this.ToString(), this.NewWord)); string t = AsmSourceTools.Get_Related_Constant(this.NewWord, value, nBits); findData = new FindData(t, s) { FindOptions = FindOptions.WholeWord | FindOptions.SingleLine | FindOptions.UseRegularExpressions, }; } else { AsmDudeToolsStatic.Output_INFO(string.Format(AsmDudeToolsStatic.CultureUI, "{0}:Update_Word_Adornments. Keyword={1}", this.ToString(), this.NewWord)); //We have to replace all occurrences of special characters with escaped versions of that char since we cannot use verbatim strings. string t = this.NewWord.Replace(".", "\\.").Replace("$", "\\$").Replace("?", "\\?").Replace("/", "\\/"); findData = new FindData(t, s) { FindOptions = FindOptions.WholeWord | FindOptions.SingleLine | FindOptions.UseRegularExpressions, }; } } List <SnapshotSpan> wordSpans = new List <SnapshotSpan>(); try { wordSpans.AddRange(this.textSearchService_.FindAll(findData)); } catch (Exception e2) { AsmDudeToolsStatic.Output_WARNING(string.Format(AsmDudeToolsStatic.CultureUI, "could not highlight string \"{0}\"; e={1}", findData.SearchString, e2.InnerException.Message)); } this.SynchronousUpdate(this.RequestedPoint, new NormalizedSnapshotSpanCollection(wordSpans), this.NewWord, sp); } else { // If we couldn't find a word, just clear out the existing markers this.SynchronousUpdate(this.RequestedPoint, new NormalizedSnapshotSpanCollection(), null, null); } AsmDudeToolsStatic.Print_Speed_Warning(time1, "HighlightWordTagger"); } catch (Exception e) { AsmDudeToolsStatic.Output_ERROR(string.Format(AsmDudeToolsStatic.CultureUI, "{0}:UpdateWordAdornments; e={1}", this.ToString(), e.ToString())); } }
public void SetAsmSim(AsmSimulator asmSimulator, int lineNumber, bool isExpanded) { this._asmSimulator = asmSimulator; this._lineNumber = lineNumber; bool empty = true; if (this._asmSimulator.Enabled & Settings.Default.AsmSim_Show_Register_In_Instruction_Tooltip) { this._itemsOnPage = new List <TextBox>(); this.AsmSimGridExpander.IsExpanded = isExpanded; this.AsmSimGridExpanderNumeration.Text = Settings.Default.AsmSim_Show_Register_In_Instruction_Tooltip_Numeration; var usage = this._asmSimulator.Get_Usage(lineNumber); var readReg = new HashSet <Rn>(usage.ReadReg); var writeReg = new HashSet <Rn>(usage.WriteReg); this.GenerateHeader(); int row = 2; foreach (Rn reg in Enum.GetValues(typeof(Rn))) { bool b1 = readReg.Contains(reg); bool b2 = writeReg.Contains(reg); if (b1 || b2) { empty = false; if (b1) { this.Generate(reg, true, row); } if (b2) { this.Generate(reg, false, row); } row++; } } foreach (Flags flag in FlagTools.GetFlags(usage.ReadFlag | usage.WriteFlag)) { if (flag == Flags.NONE) { continue; } bool b1 = usage.ReadFlag.HasFlag(flag); bool b2 = usage.WriteFlag.HasFlag(flag); if (b1 || b2) { empty = false; if (b1) { this.Generate(flag, true, row); } if (b2) { this.Generate(flag, false, row); } row++; } } } this.AsmSimGridExpander.Visibility = (empty) ? Visibility.Collapsed : Visibility.Visible; this.AsmSimGridBorder.Visibility = (empty) ? Visibility.Collapsed : Visibility.Visible; this.AsmSimGridExpanderNumeration.SelectionChanged += (sender, i) => { string numerationStr = ((sender as ComboBox).SelectedItem as ComboBoxItem).Content.ToString(); NumerationEnum numeration = AsmSourceTools.ParseNumeration(numerationStr); if (numeration == NumerationEnum.UNKNOWN) { AsmDudeToolsStatic.Output_WARNING("SetAsmSim:smSimGridExpanderNumeration.SelectionChanged: unknown numerationStr=" + numerationStr); } //AsmDudeToolsStatic.Output_INFO("AsmSimGridExpanderNumeration:SelectionChanged: numeration="+ numeration); foreach (var textBox in this._itemsOnPage) { var info = textBox.Tag as ButtonInfo; string content = (info.reg == Rn.NOREG) ? this._asmSimulator.Get_Flag_Value_If_Already_Computed(info.flag, this._lineNumber, info.before) : this._asmSimulator.Get_Register_Value_If_Already_Computed(info.reg, this._lineNumber, info.before, numeration); if (content != null) { textBox.Text = info.reg.ToString() + " = " + content; } } }; }
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 PerformanceExpander_Click(object sender, RoutedEventArgs e) { AsmDudeToolsStatic.Output_INFO("InstructionTooltipWindow:PerformanceExpander_Click"); e.Handled = true; }
public AsmDocMouseHandler( IWpfTextView view, IBufferTagAggregatorFactoryService aggregatorFactory, CtrlKeyState state, AsmDudeTools asmDudeTools) { AsmDudeToolsStatic.Output_INFO(string.Format(AsmDudeToolsStatic.CultureUI, "{0}:constructor: file={1}", this.ToString(), AsmDudeToolsStatic.GetFilename(view.TextBuffer))); this.view_ = view ?? throw new ArgumentNullException(nameof(view)); this.state_ = state ?? throw new ArgumentNullException(nameof(state)); this.aggregator2_ = AsmDudeToolsStatic.GetOrCreate_Aggregator(view.TextBuffer, aggregatorFactory); this.asmDudeTools_ = asmDudeTools ?? throw new ArgumentNullException(nameof(asmDudeTools)); this.state_.CtrlKeyStateChanged += (sender, args) => { if (Settings.Default.AsmDoc_On) { if (this.state_.Enabled) { this.TryHighlightItemUnderMouse(this.RelativeToView(Mouse.PrimaryDevice.GetPosition(this.view_.VisualElement))); } else { this.Set_Highlight_Span(null); } } }; // Some other points to clear the highlight span: this.view_.LostAggregateFocus += (sender, args) => { AsmDudeToolsStatic.Output_INFO(string.Format(AsmDudeToolsStatic.CultureUI, "{0}:event: LostAggregateFocus", this.ToString())); this.Set_Highlight_Span(null); }; this.view_.VisualElement.MouseLeave += (sender, args) => { AsmDudeToolsStatic.Output_INFO(string.Format(AsmDudeToolsStatic.CultureUI, "{0}:event: MouseLeave", this.ToString())); this.Set_Highlight_Span(null); }; }
private void _session_Dismissed(object sender, EventArgs e) { this._session = null; AsmDudeToolsStatic.Output_INFO(string.Format("{0}:_session_Dismissed: event={1}", this.ToString(), e)); }
private void ToolTipLegacy(SnapshotPoint triggerPoint, Point p) { var span = this.Get_Keyword_Span_At_Point(triggerPoint); ITrackingSpan applicableTo = this._textView.TextSnapshot.CreateTrackingSpan(span, SpanTrackingMode.EdgeInclusive); // check if a tooltip window is already visible for the applicable span if ((this._legacySpan != null) && this._legacySpan.OverlapsWith(span)) { //AsmDudeToolsStatic.Output_INFO("AsmQuickInfoController:ToolTipLegacy: tooltip is already visible. span = " + this._legacySpan.ToString() + ", content =" + applicableTo.GetText(this._textView.TextSnapshot)); return; } string keyword = applicableTo.GetText(this._textView.TextSnapshot); Mnemonic mnemonic = AsmSourceTools.ParseMnemonic(keyword, false); if (mnemonic != Mnemonic.NONE) { var 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); var 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("AsmQuickInfoController:ToolTipLegacy: going to cleanup old window remnants."); if (this._legacyTooltipWindow.IsLoaded) { this._legacyTooltipWindow = null; } else { this._legacyTooltipWindow?.Close(); } } this._legacyTooltipWindow = new Window { WindowStyle = WindowStyle.None, ResizeMode = ResizeMode.NoResize, SizeToContent = SizeToContent.WidthAndHeight, Left = p.X, Top = p.Y, 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("AsmQuickInfoController:LostKeyboardFocus: e=" + e.Message); } }; this._legacySpan = span; this._legacyTooltipWindow.Show(); this._legacyTooltipWindow.Focus(); //give the tooltip window focus, such that we can use the lostKeyboardFocus event to close this window; } }
private void AsmSimExpander_Click(object sender, RoutedEventArgs e) { AsmDudeToolsStatic.Output_INFO("InstructionTooltipWindow:AsmSimExpander_Click"); }