Basic Syntax highlighting, added CodeTextBox to MainWindow to test it.

This commit is contained in:
David
2016-10-13 21:08:34 -04:00
parent 071b63f01d
commit 1c44e00a1d
7 changed files with 137 additions and 17 deletions

View File

@@ -0,0 +1,38 @@
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Documents;
using System.Windows.Media;
namespace Befunge.Editor.CharStyles
{
public class BefungeStyler : ITextStyler
{
private string _directionals = "<>^v?r";
public IEnumerable<Run> StyledString(string input)
{
var runs = new List<Run>();
foreach (var c in input)
{
if (_directionals.Contains(c))
runs.Add(new Run(c.ToString())
{
Foreground = new SolidColorBrush(Colors.CornflowerBlue),
FontWeight = FontWeights.Bold
});
else
{
runs.Add(new Run(c.ToString())
{
Foreground = new SolidColorBrush(Colors.Black),
FontWeight = FontWeights.Normal
});
}
}
return runs;
}
}
}

View File

@@ -1,14 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Documents;
namespace Befunge.Editor.CharStyles
{
public interface ICharStyler
public interface ITextStyler
{
Run StyledString(string input);
IEnumerable<Run> StyledString(string input);
}
}
}