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()
|
|
|
|
{
|
2023-10-12 18:29:32 +00:00
|
|
|
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()
|
|
|
|
{
|
2023-10-12 18:29:32 +00:00
|
|
|
Gui.Font(MainUI.MonospaceFont, ()=>
|
|
|
|
{
|
|
|
|
foreach(var line in lines)
|
|
|
|
Gui.Text(line);
|
|
|
|
});
|
2023-10-02 18:49:24 +00:00
|
|
|
}
|
|
|
|
}
|