shoko/Media/PlainMediaHandler.cs

33 lines
709 B
C#
Raw Normal View History

2023-10-02 18:49:24 +00:00
namespace Shoko;
[MediaType("text/plain")]
[MediaType("text/*")]
class PlainMediaHandler : MediaHandler
{
List<string> lines;
public PlainMediaHandler(ProtoHandler content)
{
Content = content;
lines = new List<string>();
}
public override void Load()
{
Title = Content.URL.AbsolutePath;
2023-10-02 18:49:24 +00:00
var reader = new StreamReader(Content.Content);
string line;
while((line = reader.ReadLine()) is not null)
{
lines.Add(line);
}
}
public override void Render()
{
Gui.Font(MainUI.MonospaceFont, ()=>
{
foreach(var line in lines)
Gui.Text(line);
});
2023-10-02 18:49:24 +00:00
}
}