Example #1
0
        public HighlightedLine HighlightLine(int lineNumber)
        {
            var documentLine    = Document.GetLineByNumber(lineNumber);
            var lineText        = Document.GetText(documentLine);
            var highlightedLine = new HighlightedLine(Document, documentLine);
            var parser          = new LyricsParser();

            foreach (var node in parser.ParseLine(lineText))
            {
                foreach (var token in node.Tokens)
                {
                    highlightedLine.Sections.Add(new HighlightedSection
                    {
                        Offset = token.Span.Start.Index + documentLine.Offset,
                        Length = token.Span.Length,
                        Color  = GetNamedColor(token.Label)
                    });
                }
            }
            return(highlightedLine);
        }
Example #2
0
        static void Main(string[] args)
        {
            var serviceCollection = new ServiceCollection();

            ConfigureServices(serviceCollection);

            _spinner = new Spinner();

            // TODO: make this work with dependency injection
            var musicBrainzQuery = new MusicBrainzQuery(_musicBrainzSettings);
            var lyricsApiQuery   = new LyricsApiQuery(new HttpClient {
                BaseAddress = new Uri(_lyricsApiSettings.BaseAddress)
            });
            var lyricsParser = new LyricsParser(_lyricsParserSettings);
            var cacheManager = new CacheManager(Path.Combine(Path.GetTempPath(), "Lyricalculator"));

            _musicService = new MusicService(musicBrainzQuery, lyricsApiQuery, lyricsParser, cacheManager);

            WriteLogo();
            Start();
            End();
        }