diff --git a/WpfTex/LatexEditor/App.xaml.cs b/WpfTex/LatexEditor/App.xaml.cs index 4846236..bf1774f 100644 --- a/WpfTex/LatexEditor/App.xaml.cs +++ b/WpfTex/LatexEditor/App.xaml.cs @@ -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 { diff --git a/WpfTex/LatexEditor/Fonts/CmFont.cs b/WpfTex/LatexEditor/Fonts/CmFont.cs index e2fe24d..5e27045 100644 --- a/WpfTex/LatexEditor/Fonts/CmFont.cs +++ b/WpfTex/LatexEditor/Fonts/CmFont.cs @@ -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 { diff --git a/WpfTex/LatexEditor/Fonts/CmManager.cs b/WpfTex/LatexEditor/Fonts/CmManager.cs index 73ed246..d342fa6 100644 --- a/WpfTex/LatexEditor/Fonts/CmManager.cs +++ b/WpfTex/LatexEditor/Fonts/CmManager.cs @@ -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 diff --git a/WpfTex/LatexEditor/Fonts/GlyphInfo.cs b/WpfTex/LatexEditor/Fonts/GlyphInfo.cs index b755ac4..05b6a32 100644 --- a/WpfTex/LatexEditor/Fonts/GlyphInfo.cs +++ b/WpfTex/LatexEditor/Fonts/GlyphInfo.cs @@ -1,7 +1,5 @@ -using System.Collections.Generic; -using System.Windows; +using System.Windows; using System.Windows.Media; -using JetBrains.Annotations; namespace LatexEditor.Fonts { diff --git a/WpfTex/LatexEditor/LatexDocument.cs b/WpfTex/LatexEditor/LatexDocument.cs index 501c8ad..d34be5a 100644 --- a/WpfTex/LatexEditor/LatexDocument.cs +++ b/WpfTex/LatexEditor/LatexDocument.cs @@ -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 { diff --git a/WpfTex/LatexEditor/LatexEditor.csproj b/WpfTex/LatexEditor/LatexEditor.csproj index ab3dc79..e4f92c1 100644 --- a/WpfTex/LatexEditor/LatexEditor.csproj +++ b/WpfTex/LatexEditor/LatexEditor.csproj @@ -76,13 +76,14 @@ - - - - - - - + + + + + + + + diff --git a/WpfTex/LatexEditor/LatexViewer.cs b/WpfTex/LatexEditor/LatexViewer.cs index b6dce6a..ae42efe 100644 --- a/WpfTex/LatexEditor/LatexViewer.cs +++ b/WpfTex/LatexEditor/LatexViewer.cs @@ -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) diff --git a/WpfTex/LatexEditor/MainWindow.xaml.cs b/WpfTex/LatexEditor/MainWindow.xaml.cs index 4143617..0fe63d9 100644 --- a/WpfTex/LatexEditor/MainWindow.xaml.cs +++ b/WpfTex/LatexEditor/MainWindow.xaml.cs @@ -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 { diff --git a/WpfTex/LatexEditor/Parser/Lexer.cs b/WpfTex/LatexEditor/Parser/Lexer.cs index 17a4fbe..36256f5 100644 --- a/WpfTex/LatexEditor/Parser/Lexer.cs +++ b/WpfTex/LatexEditor/Parser/Lexer.cs @@ -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 { diff --git a/WpfTex/LatexEditor/Parser/LatexParser.cs b/WpfTex/LatexEditor/Parser/Parser.cs similarity index 95% rename from WpfTex/LatexEditor/Parser/LatexParser.cs rename to WpfTex/LatexEditor/Parser/Parser.cs index ab0a044..748423c 100644 --- a/WpfTex/LatexEditor/Parser/LatexParser.cs +++ b/WpfTex/LatexEditor/Parser/Parser.cs @@ -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+"), diff --git a/WpfTex/LatexEditor/Parser/LatexNull.cs b/WpfTex/LatexEditor/Parser/Segments/LatexNull.cs similarity index 89% rename from WpfTex/LatexEditor/Parser/LatexNull.cs rename to WpfTex/LatexEditor/Parser/Segments/LatexNull.cs index 45b88c8..c0acfda 100644 --- a/WpfTex/LatexEditor/Parser/LatexNull.cs +++ b/WpfTex/LatexEditor/Parser/Segments/LatexNull.cs @@ -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 { diff --git a/WpfTex/LatexEditor/Parser/LatexReturn.cs b/WpfTex/LatexEditor/Parser/Segments/LatexReturn.cs similarity index 92% rename from WpfTex/LatexEditor/Parser/LatexReturn.cs rename to WpfTex/LatexEditor/Parser/Segments/LatexReturn.cs index bfa39ce..d39ac7d 100644 --- a/WpfTex/LatexEditor/Parser/LatexReturn.cs +++ b/WpfTex/LatexEditor/Parser/Segments/LatexReturn.cs @@ -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 { diff --git a/WpfTex/LatexEditor/Parser/LatexRun.cs b/WpfTex/LatexEditor/Parser/Segments/LatexRun.cs similarity index 96% rename from WpfTex/LatexEditor/Parser/LatexRun.cs rename to WpfTex/LatexEditor/Parser/Segments/LatexRun.cs index 06b56ee..3d7aaee 100644 --- a/WpfTex/LatexEditor/Parser/LatexRun.cs +++ b/WpfTex/LatexEditor/Parser/Segments/LatexRun.cs @@ -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 { diff --git a/WpfTex/LatexEditor/Parser/LatexSegment.cs b/WpfTex/LatexEditor/Parser/Segments/LatexSegment.cs similarity index 70% rename from WpfTex/LatexEditor/Parser/LatexSegment.cs rename to WpfTex/LatexEditor/Parser/Segments/LatexSegment.cs index 6a8fd3e..d00212c 100644 --- a/WpfTex/LatexEditor/Parser/LatexSegment.cs +++ b/WpfTex/LatexEditor/Parser/Segments/LatexSegment.cs @@ -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(); + // 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(); 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 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; - } - } - } } \ No newline at end of file diff --git a/WpfTex/LatexEditor/Parser/LatexSpace.cs b/WpfTex/LatexEditor/Parser/Segments/LatexSpace.cs similarity index 92% rename from WpfTex/LatexEditor/Parser/LatexSpace.cs rename to WpfTex/LatexEditor/Parser/Segments/LatexSpace.cs index 03275bf..1772bcd 100644 --- a/WpfTex/LatexEditor/Parser/LatexSpace.cs +++ b/WpfTex/LatexEditor/Parser/Segments/LatexSpace.cs @@ -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 { diff --git a/WpfTex/LatexEditor/Parser/Segments/LatexSuper.cs b/WpfTex/LatexEditor/Parser/Segments/LatexSuper.cs new file mode 100644 index 0000000..f5d36ae --- /dev/null +++ b/WpfTex/LatexEditor/Parser/Segments/LatexSuper.cs @@ -0,0 +1,26 @@ +using System.Collections.Generic; +using LatexEditor.Fonts; + +namespace LatexEditor.Parser.Segments +{ + public class LatexSuper : LatexSegment + { + public override IEnumerable 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; + } + } + } +} \ No newline at end of file diff --git a/WpfTex/LatexEditor/Parser/LatexText.cs b/WpfTex/LatexEditor/Parser/Segments/LatexText.cs similarity index 96% rename from WpfTex/LatexEditor/Parser/LatexText.cs rename to WpfTex/LatexEditor/Parser/Segments/LatexText.cs index cf4f883..f257220 100644 --- a/WpfTex/LatexEditor/Parser/LatexText.cs +++ b/WpfTex/LatexEditor/Parser/Segments/LatexText.cs @@ -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 { diff --git a/WpfTex/LatexEditor/Properties/AssemblyInfo.cs b/WpfTex/LatexEditor/Properties/AssemblyInfo.cs index 3ffff92..e19f85d 100644 --- a/WpfTex/LatexEditor/Properties/AssemblyInfo.cs +++ b/WpfTex/LatexEditor/Properties/AssemblyInfo.cs @@ -1,6 +1,4 @@ using System.Reflection; -using System.Resources; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Windows;