Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
## What does this PR do?

<!-- Describe the change and why it's needed. Link to the related issue if one exists. -->

Fixes #

## How was this tested?

<!-- Describe how you verified the change works. Include OS and any manual steps. -->

- [ ] `dotnet build` — 0 errors, 0 warnings
- [ ] Manually tested on Windows ___

## Checklist

- [ ] Changes are focused — one logical change per PR
- [ ] Documentation updated (if user-visible behavior changed)
- [ ] New NuGet dependencies are MIT/Apache-2.0 and security-vetted
- [ ] No commented-out code or debug leftovers
38 changes: 25 additions & 13 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:

permissions:
contents: write
pull-requests: write

jobs:
release:
Expand All @@ -17,7 +18,6 @@ jobs:
with:
ref: main
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}

- name: Setup .NET 9
uses: actions/setup-dotnet@v4
Expand All @@ -39,26 +39,38 @@ jobs:
echo "new_version=$new_version" >> "$GITHUB_OUTPUT"
echo "Bumped version: $new_version"

- name: Update version in csproj
run: |
sed -i "s|<Version>${{ steps.current.outputs.version }}</Version>|<Version>${{ steps.bump.outputs.new_version }}</Version>|" GithubMarkdownViewer/GithubMarkdownViewer.csproj

- name: Verify build with new version
run: dotnet build --configuration Release

- name: Commit version bump
- name: Create tag and GitHub Release
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add GithubMarkdownViewer/GithubMarkdownViewer.csproj
git commit -m "Bump version to v${{ steps.bump.outputs.new_version }}"
git push origin main
git tag "v${{ steps.bump.outputs.new_version }}" HEAD
git push origin "v${{ steps.bump.outputs.new_version }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ steps.bump.outputs.new_version }}
name: v${{ steps.bump.outputs.new_version }}
generate_release_notes: true
target_commitish: main

- name: Create version bump PR
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
branch="auto/bump-version-${{ steps.bump.outputs.new_version }}"
git checkout -b "$branch"
sed -i "s|<Version>${{ steps.current.outputs.version }}</Version>|<Version>${{ steps.bump.outputs.new_version }}</Version>|" GithubMarkdownViewer/GithubMarkdownViewer.csproj
dotnet build --configuration Release --nologo -v q
git add GithubMarkdownViewer/GithubMarkdownViewer.csproj
git commit -m "Bump version to v${{ steps.bump.outputs.new_version }}"
git push origin "$branch"
gh pr create \
--base main \
--head "$branch" \
--title "Bump version to v${{ steps.bump.outputs.new_version }}" \
--body "Automated version bump following release v${{ steps.bump.outputs.new_version }}."
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

27 changes: 14 additions & 13 deletions GithubMarkdownViewer/App.axaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
<Application xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="GithubMarkdownViewer.App"
xmlns:local="using:GithubMarkdownViewer"
RequestedThemeVariant="Default">

<Application.DataTemplates>
<local:ViewLocator/>
</Application.DataTemplates>

<Application.Styles>
<FluentTheme />
</Application.Styles>
<Application xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="GithubMarkdownViewer.App"
xmlns:local="using:GithubMarkdownViewer"
RequestedThemeVariant="Default">

<Application.DataTemplates>
<local:ViewLocator/>
</Application.DataTemplates>

<Application.Styles>
<FluentTheme />
<StyleInclude Source="avares://AvaloniaEdit/Themes/Fluent/AvaloniaEdit.xaml" />
</Application.Styles>
</Application>
1 change: 1 addition & 0 deletions GithubMarkdownViewer/GithubMarkdownViewer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

<ItemGroup>
<PackageReference Include="Avalonia" Version="11.3.12" />
<PackageReference Include="Avalonia.AvaloniaEdit" Version="11.4.1" />
<PackageReference Include="Avalonia.Desktop" Version="11.3.12" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.3.12" />
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.3.12" />
Expand Down
6 changes: 6 additions & 0 deletions GithubMarkdownViewer/Models/AppSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ public class AppSettings
[JsonPropertyName("fontFamily")]
public string FontFamilyName { get; set; } = DefaultFontFamily;

[JsonPropertyName("fontWeightName")]
public string FontWeightName { get; set; } = "Regular";

[JsonPropertyName("fontSizePt")]
public double FontSizePt { get; set; } = DefaultFontSizePt;

Expand All @@ -38,6 +41,9 @@ public class AppSettings
[JsonPropertyName("wordWrap")]
public bool WordWrap { get; set; } = true;

[JsonPropertyName("showLineNumbers")]
public bool ShowLineNumbers { get; set; } = true;

[JsonPropertyName("themeMode")]
public string ThemeMode { get; set; } = "System";

Expand Down
61 changes: 61 additions & 0 deletions GithubMarkdownViewer/Services/FindHighlightRenderer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
using System.Collections.Generic;
using Avalonia;
using Avalonia.Media;
using AvaloniaEdit.Document;
using AvaloniaEdit.Rendering;

namespace GithubMarkdownViewer.Services;

/// <summary>
/// Renders yellow background rectangles behind find-match ranges in the AvaloniaEdit TextEditor.
/// </summary>
public class FindHighlightRenderer : IBackgroundRenderer
{
private readonly List<TextSegment> _segments = new();

public IBrush MatchBrush { get; set; } = new SolidColorBrush(Color.Parse("#FBC02D"));
public IBrush CurrentMatchBrush { get; set; } = new SolidColorBrush(Color.Parse("#FF6F00"));
public int CurrentMatchIndex { get; set; } = -1;

public KnownLayer Layer => KnownLayer.Selection;

public void SetMatches(IEnumerable<TextSegment> segments)
{
_segments.Clear();
_segments.AddRange(segments);
}

public void ClearMatches()
{
_segments.Clear();
CurrentMatchIndex = -1;
}

public void Draw(TextView textView, DrawingContext drawingContext)
{
if (_segments.Count == 0) return;

var builder = new BackgroundGeometryBuilder
{
CornerRadius = 2
};

for (int i = 0; i < _segments.Count; i++)
{
var segment = _segments[i];
bool isCurrent = i == CurrentMatchIndex;

var geoBuilder = new BackgroundGeometryBuilder { CornerRadius = 2 };
geoBuilder.AddSegment(textView, segment);
var geometry = geoBuilder.CreateGeometry();

if (geometry != null)
{
drawingContext.DrawGeometry(
isCurrent ? CurrentMatchBrush : MatchBrush,
null,
geometry);
}
}
}
}
Loading
Loading