/// <summary> /// Marks the currently loaded text file as being saved and updates the git diff indicators /// </summary> public void MarkTextAsSaved() { _LoadedText = CodeEditBox.Text; UpdateDiffInfo(); IdeOverlaysCanvas.Invalidate(); }
/// <summary> /// Clears all the existing breakpoints /// </summary> /// <param name="sender">The <see cref="MenuFlyoutItem"/> that was clicked</param> /// <param name="e">The <see cref="RoutedEventArgs"/> for the current event</param> private void RemoveAllBreakpointsButton_Clicked(object sender, RoutedEventArgs e) { BreakpointsCleared?.Invoke(this, BreakpointIndicators.Count); BreakpointIndicators.Clear(); UpdateBreakpointsInfo(); IdeOverlaysCanvas.Invalidate(); CodeEditBox.InvalidateOverlays(); }
/// <summary> /// Updates the UI when the source code displayed into the <see cref="Brainf_ckEditBox"/> instance changes /// </summary> /// <param name="sender">The <see cref="Brainf_ckEditBox"/> instance in use</param> /// <param name="args">The arguments for the new Brainf*ck/Pbrain source code being displayed</param> private void CodeEditBox_TextChanged(Brainf_ckEditBox sender, TextChangedEventArgs args) { TextChanged?.Invoke(this, args); int numberOfLines = args.PlainText.Count(Characters.CarriageReturn); UpdateLineIndicators(numberOfLines); UpdateDiffInfo(args.PlainText); UpdateIndentationInfo(args.PlainText, args.ValidationResult.IsSuccessOrEmptyScript, numberOfLines); IdeOverlaysCanvas.Invalidate(); }
/// <summary> /// Sets up a breakpoint when the user taps on the breakpoints area /// </summary> /// <param name="sender">The <see cref="Canvas"/> instance in use</param> /// <param name="e">The <see cref="TappedRoutedEventArgs"/> instance for the event</param> private void BreakpointsCanvas_Tapped(object sender, TappedRoutedEventArgs e) { // Calculate the target vertical offset for the tap double yOffset = e.GetPosition((Border)sender).Y - 8 - // Tap Y offset and adjustment CodeEditBox.VerticalScrollBarMargin.Top + // Top internal padding CodeEditBox.ContentScroller !.VerticalOffset; // Vertical scroll offset // Get the range aligned to the left edge of the tapped line ITextRange range = CodeEditBox.Document.GetRangeFromPoint(new Point(0, yOffset), PointOptions.ClientCoordinates); range.GetRect(PointOptions.Transform, out Rect line, out _); // Get the line number int lineNumber = CodeEditBox.Text.AsSpan(0, range.StartPosition).Count(Characters.CarriageReturn) + 1; if (lineNumber == 1) { return; } // Store or remove the breakpoint if (BreakpointIndicators.ContainsKey(lineNumber)) { BreakpointIndicators.Remove(lineNumber); if (BreakpointIndicators.Count == 0) { BreakpointsBorder.ContextFlyout = null; } BreakpointRemoved?.Invoke(this, new BreakpointToggleEventArgs(lineNumber, BreakpointIndicators.Count)); } else { if (BreakpointIndicators.Count == 0) { BreakpointsBorder.ContextFlyout = BreakpointsMenuFlyout; } BreakpointIndicators.GetOrAddValueRef(lineNumber) = (float)line.Top; BreakpointAdded?.Invoke(this, new BreakpointToggleEventArgs(lineNumber, BreakpointIndicators.Count)); } UpdateBreakpointsInfo(); IdeOverlaysCanvas.Invalidate(); CodeEditBox.InvalidateOverlays(); }