shoko/Media/PlainMediaHandler.cs

34 lines
746 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>();
}
2023-10-20 04:59:28 +00:00
public override async Task Load()
2023-10-02 18:49:24 +00:00
{
Title = Content.URL.AbsolutePath;
2023-10-02 18:49:24 +00:00
var reader = new StreamReader(Content.Content);
string line;
2023-10-20 04:59:28 +00:00
while((line = await reader.ReadLineAsync()) is not null)
2023-10-02 18:49:24 +00:00
{
lines.Add(line);
}
2023-10-20 04:59:28 +00:00
OnLoaded();
2023-10-02 18:49:24 +00:00
}
public override void Render()
{
Gui.Font(MainUI.MonospaceFont, ()=>
{
foreach(var line in lines)
Gui.Text(line);
});
2023-10-02 18:49:24 +00:00
}
}