~earboxer/browset

d236dd91d458035a455a4fa4f198aa1fb0e7fad9 — Zach DeCook 1 year, 1 month ago 50c38b6
Bindings: Bind back and soon
1 files changed, 16 insertions(+), 9 deletions(-)

M browset.py
M browset.py => browset.py +16 -9
@@ 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 = []