Skip to content

Commit

Permalink
Merge branch 'master' into disable-veldrid-gl
Browse files Browse the repository at this point in the history
  • Loading branch information
bdach authored Feb 20, 2024
2 parents cff136e + e7ffb59 commit 29b5f04
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,27 @@ public void TestQuote()
}

[Test]
public void TestFencedCode()
public void TestIndentedCodeBlock()
{
AddStep("Markdown Fenced Code", () =>
AddStep("Markdown Indented Code Block", () =>
{
markdownContainer.Text = @"
[Escape me]
[[Escape me]]
{{
x = ""5"" # This assignment will not output anything
x # This expression will print 5
x + 1 # This expression will print 6
}}
";
});
}

[Test]
public void TestFencedCodeBlock()
{
AddStep("Markdown Fenced Code Block", () =>
{
markdownContainer.Text = @"```scriban-html
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,32 @@
namespace osu.Framework.Graphics.Containers.Markdown
{
/// <summary>
/// Visualises a fenced code block.
/// Visualises an indented/fenced code block.
/// </summary>
/// <code>
/// ```
/// code
/// code1
/// code2
/// code3
/// ```
/// </code>
public partial class MarkdownFencedCodeBlock : CompositeDrawable, IMarkdownTextFlowComponent
/// <code>
///
/// code1
/// code2
/// code3
///
/// </code>
public partial class MarkdownCodeBlock : CompositeDrawable, IMarkdownTextFlowComponent
{
private readonly FencedCodeBlock fencedCodeBlock;
private readonly CodeBlock codeBlock;

[Resolved]
private IMarkdownTextFlowComponent parentFlowComponent { get; set; } = null!;

public MarkdownFencedCodeBlock(FencedCodeBlock fencedCodeBlock)
public MarkdownCodeBlock(CodeBlock codeBlock)
{
this.fencedCodeBlock = fencedCodeBlock;
this.codeBlock = codeBlock;

AutoSizeAxes = Axes.Y;
RelativeSizeAxes = Axes.X;
Expand All @@ -42,8 +51,8 @@ private void load()
};

// Markdig sometimes appends empty lines to the processed block, only add original lines to the container
for (int i = 0; i < fencedCodeBlock.Lines.Count; i++)
textFlowContainer.AddParagraph(fencedCodeBlock.Lines.Lines[i].ToString());
for (int i = 0; i < codeBlock.Lines.Count; i++)
textFlowContainer.AddParagraph(codeBlock.Lines.Lines[i].ToString());
}

protected virtual Drawable CreateBackground() => new Box
Expand Down
10 changes: 5 additions & 5 deletions osu.Framework/Graphics/Containers/Markdown/MarkdownContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,8 @@ protected virtual void AddMarkdownComponent(IMarkdownObject markdownObject, Fill
container.Add(CreateQuoteBlock(quoteBlock));
break;

case FencedCodeBlock fencedCodeBlock:
container.Add(CreateFencedCodeBlock(fencedCodeBlock));
case CodeBlock codeBlock:
container.Add(CreateCodeBlock(codeBlock));
break;

case Table table:
Expand Down Expand Up @@ -311,11 +311,11 @@ protected virtual void AddMarkdownComponent(IMarkdownObject markdownObject, Fill
protected virtual MarkdownQuoteBlock CreateQuoteBlock(QuoteBlock quoteBlock) => new MarkdownQuoteBlock(quoteBlock);

/// <summary>
/// Creates the visualiser for a <see cref="FencedCodeBlock"/>.
/// Creates the visualiser for a <see cref="CodeBlock"/>.
/// </summary>
/// <param name="fencedCodeBlock">The <see cref="FencedCodeBlock"/> to visualise.</param>
/// <param name="codeBlock">The <see cref="CodeBlock"/> to visualise.</param>
/// <returns>The visualiser.</returns>
protected virtual MarkdownFencedCodeBlock CreateFencedCodeBlock(FencedCodeBlock fencedCodeBlock) => new MarkdownFencedCodeBlock(fencedCodeBlock);
protected virtual MarkdownCodeBlock CreateCodeBlock(CodeBlock codeBlock) => new MarkdownCodeBlock(codeBlock);

/// <summary>
/// Creates the visualiser for a <see cref="Table"/>.
Expand Down
4 changes: 3 additions & 1 deletion osu.Framework/Input/Bindings/KeyBindingContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Extensions.ListExtensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Input.Events;
using osu.Framework.Input.States;
using osu.Framework.Lists;
using osu.Framework.Logging;
using osuTK;

Expand Down Expand Up @@ -45,7 +47,7 @@ protected KeyBindingContainer(SimultaneousBindingMode simultaneousMode = Simulta
/// <summary>
/// All actions in a currently pressed state.
/// </summary>
public IEnumerable<T> PressedActions => pressedActions;
public SlimReadOnlyListWrapper<T> PressedActions => pressedActions.AsSlimReadOnly();

private readonly Dictionary<IKeyBinding, List<Drawable>> keyBindingQueues = new Dictionary<IKeyBinding, List<Drawable>>();
private readonly List<Drawable> queue = new List<Drawable>();
Expand Down

0 comments on commit 29b5f04

Please sign in to comment.