shoko/Media/PlainMediaHandler.cs

34 lines
744 B
C#
Raw Normal View History

2023-10-02 18:49:24 +00:00
using ImGuiNET;
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 = new UriBuilder(Content.URL).Path;
var reader = new StreamReader(Content.Content);
string line;
while((line = reader.ReadLine()) is not null)
{
lines.Add(line);
}
}
public override void Render()
{
ImGui.PushFont(MainUI.MonospaceFont);
2023-10-02 18:49:24 +00:00
foreach(var line in lines)
ImGui.TextUnformatted(line);
ImGui.PopFont();
2023-10-02 18:49:24 +00:00
}
}