2023-06-23 00:37:25 +08:00
|
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
2021-04-27 17:01:32 +08:00
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
|
|
|
|
|
using Markdig.Syntax;
|
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers.Markdown;
|
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
|
|
|
|
using osu.Game.Overlays;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Graphics.Containers.Markdown
|
|
|
|
|
{
|
2022-11-24 13:32:20 +08:00
|
|
|
|
public partial class OsuMarkdownFencedCodeBlock : MarkdownFencedCodeBlock
|
2021-04-27 17:01:32 +08:00
|
|
|
|
{
|
2021-05-06 18:05:41 +08:00
|
|
|
|
// TODO : change to monospace font for this component
|
2021-04-27 17:01:32 +08:00
|
|
|
|
public OsuMarkdownFencedCodeBlock(FencedCodeBlock fencedCodeBlock)
|
|
|
|
|
: base(fencedCodeBlock)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-06 18:05:41 +08:00
|
|
|
|
protected override Drawable CreateBackground() => new CodeBlockBackground();
|
2021-04-27 17:01:32 +08:00
|
|
|
|
|
2021-05-06 18:05:41 +08:00
|
|
|
|
public override MarkdownTextFlowContainer CreateTextFlow() => new CodeBlockTextFlowContainer();
|
|
|
|
|
|
2022-11-24 13:32:20 +08:00
|
|
|
|
private partial class CodeBlockBackground : Box
|
2021-04-27 17:01:32 +08:00
|
|
|
|
{
|
2021-05-06 18:05:41 +08:00
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(OverlayColourProvider colourProvider)
|
2021-04-27 17:01:32 +08:00
|
|
|
|
{
|
2021-05-06 18:05:41 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
|
|
|
|
Colour = colourProvider.Background6;
|
|
|
|
|
}
|
2021-04-27 17:01:32 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-11-24 13:32:20 +08:00
|
|
|
|
private partial class CodeBlockTextFlowContainer : OsuMarkdownTextFlowContainer
|
2021-04-27 17:01:32 +08:00
|
|
|
|
{
|
2021-05-06 18:05:41 +08:00
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(OverlayColourProvider colourProvider)
|
|
|
|
|
{
|
|
|
|
|
Colour = colourProvider.Light1;
|
|
|
|
|
Margin = new MarginPadding(10);
|
|
|
|
|
}
|
2021-04-27 17:01:32 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|