Added todos, moved LatexSegments to new namespace.

This commit is contained in:
2017-05-24 23:23:01 -04:00
parent 9ed077c1ba
commit 7e5566c1cc
18 changed files with 61 additions and 100 deletions

View File

@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using System.Windows;
namespace LatexEditor
{

View File

@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LatexEditor.Fonts
namespace LatexEditor.Fonts
{
public enum CmFont
{

View File

@@ -1,8 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;
namespace LatexEditor.Fonts

View File

@@ -1,7 +1,5 @@
using System.Collections.Generic;
using System.Windows;
using System.Windows;
using System.Windows.Media;
using JetBrains.Annotations;
namespace LatexEditor.Fonts
{

View File

@@ -1,12 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;
using System.Windows.Media.TextFormatting;
namespace LatexEditor
namespace LatexEditor
{
public class LatexDocument
{

View File

@@ -76,13 +76,14 @@
</Compile>
</ItemGroup>
<ItemGroup>
<Compile Include="Parser\LatexNull.cs" />
<Compile Include="Parser\LatexParser.cs" />
<Compile Include="Parser\LatexReturn.cs" />
<Compile Include="Parser\LatexRun.cs" />
<Compile Include="Parser\LatexSegment.cs" />
<Compile Include="Parser\LatexSpace.cs" />
<Compile Include="Parser\LatexText.cs" />
<Compile Include="Parser\Segments\LatexNull.cs" />
<Compile Include="Parser\Parser.cs" />
<Compile Include="Parser\Segments\LatexReturn.cs" />
<Compile Include="Parser\Segments\LatexRun.cs" />
<Compile Include="Parser\Segments\LatexSegment.cs" />
<Compile Include="Parser\Segments\LatexSpace.cs" />
<Compile Include="Parser\Segments\LatexSuper.cs" />
<Compile Include="Parser\Segments\LatexText.cs" />
<Compile Include="Parser\Lexer.cs" />
<Compile Include="Parser\Token.cs" />
<Compile Include="Parser\TokenDescriptor.cs" />

View File

@@ -1,16 +1,9 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Markup;
using System.Windows.Media;
using LatexEditor.Fonts;
using LatexEditor.Parser;
namespace LatexEditor
{
@@ -48,7 +41,7 @@ namespace LatexEditor
if (string.IsNullOrEmpty(Content)) return;
var glyphInfoList = LatexParser.ToGlyphInfos(Content);
var glyphInfoList = Parser.Parser.ToGlyphInfos(Content);
var gtfGroups = glyphInfoList.GroupBy(gi => gi.Gtf);
foreach (var gtfGroup in gtfGroups)

View File

@@ -1,17 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows;
namespace LatexEditor
{

View File

@@ -1,8 +1,5 @@
using System;
using System.Collections;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Net.NetworkInformation;
namespace LatexEditor.Parser
{

View File

@@ -1,12 +1,12 @@
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Windows.Navigation;
using LatexEditor.Fonts;
using LatexEditor.Parser.Segments;
namespace LatexEditor.Parser
{
public static class LatexParser
public static class Parser
{
// todo: move these tables to an environment class
private static readonly Lexer LatexLexer = new Lexer()
{
new TokenDescriptor("whitespace", @"\s+"),

View File

@@ -2,7 +2,7 @@ using System.Collections.Generic;
using System.Linq;
using LatexEditor.Fonts;
namespace LatexEditor.Parser
namespace LatexEditor.Parser.Segments
{
public class LatexNull : LatexSegment
{

View File

@@ -2,7 +2,7 @@ using System.Collections.Generic;
using System.Linq;
using LatexEditor.Fonts;
namespace LatexEditor.Parser
namespace LatexEditor.Parser.Segments
{
public class LatexReturn : LatexSegment
{

View File

@@ -2,7 +2,7 @@ using System.Collections.Generic;
using System.Linq;
using LatexEditor.Fonts;
namespace LatexEditor.Parser
namespace LatexEditor.Parser.Segments
{
public class LatexRun : LatexSegment
{

View File

@@ -1,9 +1,8 @@
using System.Collections.Generic;
using System.Diagnostics;
using JetBrains.Annotations;
using LatexEditor.Fonts;
namespace LatexEditor.Parser
namespace LatexEditor.Parser.Segments
{
public abstract class LatexSegment
{
@@ -42,10 +41,10 @@ namespace LatexEditor.Parser
val = new LatexText(CmFont.SerifItalic, head.Value);
if (head.TokenName == "command")
{
if (LatexParser.GreekLetters.ContainsKey(head.Value))
val = new LatexText(CmFont.SerifItalic, LatexParser.GreekLetters[head.Value]);
if (LatexParser.Spaces.ContainsKey(head.Value))
val = new LatexSpace(LatexParser.Spaces[head.Value]);
if (Parser.GreekLetters.ContainsKey(head.Value))
val = new LatexText(CmFont.SerifItalic, Parser.GreekLetters[head.Value]);
if (Parser.Spaces.ContainsKey(head.Value))
val = new LatexSpace(Parser.Spaces[head.Value]);
if (head.Value == "^")
if (PopLatexSegment(tokens, out var content))
{
@@ -64,9 +63,13 @@ namespace LatexEditor.Parser
if (head.TokenName == "escape")
if (head.Value == "\\")
val = new LatexReturn(1);
if (head.TokenName == "open")
if (head.TokenName == "open")
{
var segments = new List<LatexSegment>();
// todo: fix incorrect glyph placement within {}
// Should create a LatexGlyph: LatexSegment, and change LatexSegment.Glyphs
// to be of LatexGlyphs.Then, ON ITERATION, not creation, compute the altered positions of
// the LatexGlyphs and create the GlyphRuns from that.
var segments = new List<LatexSegment>();
while (tokens.Peek().TokenName != "close")
if (PopLatexSegment(tokens, out var content))
segments.Add(content);
@@ -78,24 +81,4 @@ namespace LatexEditor.Parser
}
}
public class LatexSuper : LatexSegment
{
public override IEnumerable<GlyphInfo> Glyphs => Content.Glyphs;
public override double RelAdvWidth => Content.RelAdvWidth;
public override double RelAdvHeight => Content.RelAdvHeight;
public LatexSegment Content { get; set; }
public LatexSuper(LatexSegment content)
{
Content = content;
foreach (var gi in Content.Glyphs)
{
gi.RelativeOffset.Y += 1;
gi.RelativeSize *= 0.5;
}
}
}
}

View File

@@ -2,7 +2,7 @@ using System.Collections.Generic;
using System.Linq;
using LatexEditor.Fonts;
namespace LatexEditor.Parser
namespace LatexEditor.Parser.Segments
{
public class LatexSpace : LatexSegment
{

View File

@@ -0,0 +1,26 @@
using System.Collections.Generic;
using LatexEditor.Fonts;
namespace LatexEditor.Parser.Segments
{
public class LatexSuper : LatexSegment
{
public override IEnumerable<GlyphInfo> Glyphs => Content.Glyphs;
public override double RelAdvWidth => Content.RelAdvWidth;
public override double RelAdvHeight => Content.RelAdvHeight;
public LatexSegment Content { get; set; }
public LatexSuper(LatexSegment content)
{
Content = content;
foreach (var gi in Content.Glyphs)
{
gi.RelativeOffset.Y += 1;
gi.RelativeSize *= 0.5;
}
}
}
}

View File

@@ -2,7 +2,7 @@ using System.Collections.Generic;
using System.Windows;
using LatexEditor.Fonts;
namespace LatexEditor.Parser
namespace LatexEditor.Parser.Segments
{
public class LatexText : LatexSegment
{

View File

@@ -1,6 +1,4 @@
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Windows;