private static void ToggleBreakpoint(string file, int line) { RefreshBreakPointsFromContent(); string key = BuildBreakpointKey(file, line); if (breakpoints.ContainsKey(key)) { Npp.DeleteMarker(breakpoints[key]); breakpoints.Remove(key); if (IsRunning) { string actualKey = TranslateSourceBreakpoint(key); DebuggerServer.RemoveBreakpoint(key); } } else { var handle = Npp.PlaceMarker(MARK_BREAKPOINT, line); breakpoints.Add(key, handle); if (IsRunning) { string actualKey = TranslateSourceBreakpoint(key); DebuggerServer.AddBreakpoint(actualKey); } } SaveBreakPointsFor(file); }
private static void ShowBreakpointSourceLocation(FileLocation location) { if (lastLocation != null && lastLocation.IsSame(location)) { return; } lastLocation = location; ClearDebuggingMarkers(); Npp.PlaceIndicator(INDICATOR_DEBUGSTEP, location.Start, location.End); Npp.PlaceMarker(MARK_DEBUGSTEP, location.Line); int start = Npp.GetFirstVisibleLine(); int end = start + Npp.GetLinesOnScreen(); if (location.Line > end || location.Line < start) { Npp.SetFirstVisibleLine(Math.Max(location.Line - (end - start) / 2, 0)); } Npp.SetCaretPosition(location.Start); Npp.ClearSelection(); //need this one as otherwise parasitic selection can be triggered Win32.SetForegroundWindow(Npp.NppHandle); }
private static void PlaceBreakPointsForCurrentTab() { try { string file = Npp.GetCurrentFile(); string expectedkeyPrefix = file + "|"; string[] fileBreakpoints = breakpoints.Keys.Where(x => x.StartsWith(expectedkeyPrefix, StringComparison.OrdinalIgnoreCase)).ToArray(); foreach (var key in fileBreakpoints) { if (breakpoints[key] == IntPtr.Zero) //not placed yet { //key = <file>|<line + 1> //server debugger operates in '1-based' and NPP in '0-based' lines int line = int.Parse(key.Split('|').Last()) - 1; breakpoints[key] = Npp.PlaceMarker(MARK_BREAKPOINT, line); } } } catch { } }