diff --git a/Protocols/AboutProtoHandler.cs b/Protocols/AboutProtoHandler.cs index bb894b8..919438d 100644 --- a/Protocols/AboutProtoHandler.cs +++ b/Protocols/AboutProtoHandler.cs @@ -1,5 +1,6 @@ using System.Reflection; using System.Text; +using System.Web; using ImGuiNET; using Raylib_cs; @@ -9,6 +10,8 @@ namespace Shoko; [Protocol("shoko")] class AboutProtoHandler : ProtoHandler { + string txtDebug = ""; + public AboutProtoHandler(Uri url) { URL = url; @@ -28,6 +31,10 @@ class AboutProtoHandler : ProtoHandler case "version": case "demo": break; + case "debugtext": + txtDebug = HttpUtility.UrlDecode(URL.Query); + if(txtDebug.Length > 0) txtDebug = txtDebug[1..]; + break; default: throw new NotImplementedException(); } @@ -69,6 +76,18 @@ class AboutProtoHandler : ProtoHandler case "demo": ImGui.ShowDemoWindow(); break; + case "debugtext": + ImGui.InputText("Text", ref txtDebug, 1024); + ImGui.SameLine(); + Gui.Button("Debug", ()=>{ + var tourl = new UriBuilder(URL) + { + Query = txtDebug + }; + CurrentTab.Load(tourl.Uri.ToString()); + }); + ImGui.DebugTextEncoding(HttpUtility.UrlDecode(URL.Query)); + break; default: break; } diff --git a/Tab.cs b/Tab.cs index e519b7f..6ad87a0 100644 --- a/Tab.cs +++ b/Tab.cs @@ -1,4 +1,3 @@ -using HtmlAgilityPack; using ImGuiNET; namespace Shoko; @@ -9,11 +8,13 @@ class Tab MediaHandler Document; public bool IsOpen = true; Exception Error = null; + Stack History; string txtURL = ""; public Tab(string url) { + History = new Stack(); Load(url); txtURL = url; } @@ -21,14 +22,17 @@ class Tab public void Load(string url) { Error = null; + ImGui.SetScrollX(0); + ImGui.SetScrollY(0); try { Handler = ProtoHandler.GetHandler(url); Handler.CurrentTab = this; Handler.Load(); + txtURL = Handler.URL.ToString(); + History.Push(Handler.URL); Document = MediaHandler.GetHandler(Handler); Document.Load(); - txtURL = Handler.URL.ToString(); } catch(Exception ex) { @@ -36,6 +40,15 @@ class Tab } } + public void Previous() + { + if(History.Count > 1) + { + History.Pop(); + Load(History.Pop().ToString()); + } + } + public void Render() { var title = txtURL; @@ -56,6 +69,10 @@ class Tab Document.MenuBar(); } + Gui.Button("<<", ()=>{ + Previous(); + }); + ImGui.InputText("##url", ref txtURL, 1024); Gui.Button("Go", ()=>{