Broken project to implement a cross-protocol browser in textual
Bindings: Bind back and soon
Zach DeCook 2023-01-11
parent 50c38b6 · commit d236dd9
-rwxr-xr-xbrowset.py25
1 files changed, 16 insertions, 9 deletions
diff --git a/browset.py b/browset.py
index 739e894..5fb365e 100755
--- a/browset.py
+++ b/browset.py
@@ -11,7 +11,9 @@ class Browset(App):
url = ""
CSS_PATH = "browset.css"
BINDINGS = [
- Binding("ctrl+c,ctrl+q", "app.quit", "Quit", show=True),
+ Binding("ctrl+q,ctrl+c", "app.quit", "Quit", show=True),
+ Binding("ctrl+left", "back()", "Back", show=False),
+ Binding("ctrl+right", "soon()", "Soon", show=False),
]
history = []
fistory = [] # forward history
@@ -37,20 +39,25 @@ class Browset(App):
if event.button.name == 'refresh':
self._do_url(self.url)
elif event.button.name == 'back':
- if len(self.history):
- self.fistory.append(self.url)
- url = self.history.pop()
- self._do_url(url, histore=False, clearF=False)
+ self.action_back()
elif event.button.name == 'soon':
- if len(self.fistory):
- url = self.fistory.pop()
- self._do_url(url, clearF=False)
+ self.action_soon()
else:
url = event.button.name
if not ":" in url:
url = GeminiProtocol.relativeURL(url, self.url)
self._do_url(url)
-
+
+ def action_back(self):
+ if len(self.history):
+ self.fistory.append(self.url)
+ url = self.history.pop()
+ self._do_url(url, histore=False, clearF=False)
+ def action_soon(self):
+ if len(self.fistory):
+ url = self.fistory.pop()
+ self._do_url(url, clearF=False)
+
def _do_url(self, url, histore=True, setbar=True, clearF=True):
if clearF:
self.fistory = []