def toggle_webview(m):
    global webview_shown
    if webview_shown:
        webview.hide()
    else:
        webview.show()
    webview_shown = not webview_shown
 def on_phrase_post(self, j):
     phrase = self.parse_phrase(j.get('phrase', []))
     if phrase in ('history show', 'history hide'):
         return
     cmd = j['cmd']
     if cmd == 'p.end' and phrase:
         if len(self.history) > 0 and self.history[-1][0] == phrase:
             self.history[-1] = (phrase, '', self.history[-1][2] + 1)
         else:
             self.history.append((phrase, '', 1))
             self.history = self.history[-hist_len:]
         if phrase == macro_record_phrase():
             self.macro_history = []
         elif is_recording() and phrase != macro_stop_phrase():
             self.macro_history.append(phrase)
         self.render()
         if self.auto_hidden:
             webview.show()
         if self.timer != None:
             cron.cancel(self.timer)
         self.timer = cron.after('15s', self.auto_hide)
 def refresh(self):
     webview.hide()
     if self.visible:
         webview.show()
    def webview_blur(*args, **kwargs):
        global webview_locations
        key = screen_key()
        r = webview.rect
        new_location = {"x": r.x, "y": r.y}
        webview_location = webview_locations[key]
        if (webview_location["x"] != new_location["x"]
                or webview_location["y"] != new_location["y"]):
            webview_locations[key] = new_location
            config.save_config_json("webview_locations.json",
                                    webview_locations)

    webview = webview.Webview()
    webview.render(template, phrases=["command"])
    webview.show()

    key = screen_key()
    if key not in webview_locations:
        webview_locations[key] = {"x": 1, "y": ui.main_screen().height}
    print("moving webview_locations", webview_locations[key])
    webview.move(webview_locations[key]["x"], webview_locations[key]["y"])

    webview.register("blur", webview_blur)


class History:
    def __init__(self):
        self.visible = True
        self.history = []
        engine.register("post:phrase", self.on_phrase_post)
Exemple #5
0
webview.move(0, ui.main_screen().height)


class History:
    def __init__(self):
        self.history = []
        engine.register('post:phrase', self.on_phrase_post)

    def parse_phrase(self, phrase):
        return ' '.join(word.split('\\')[0] for word in phrase)

    def on_phrase_post(self, j):
        phrase = self.parse_phrase(j.get('phrase', []))
        if phrase in ('history show', 'history hide'):
            return
        cmd = j['cmd']
        if cmd == 'p.end' and phrase:
            self.history.append((phrase, ''))
            self.history = self.history[-hist_len:]
            webview.render(template, phrases=self.history)


history = History()

ctx = Context('phrase_history')
ctx.keymap({
    'history show': lambda m: webview.show(),
    'history hide': lambda m: webview.hide(),
})
# webview.show()
Exemple #6
0
def open_history():
    webview.show()
Exemple #7
0
webview.move(0, ui.main_screen().height)


class History:
    def __init__(self):
        self.history = []
        engine.register("post:phrase", self.on_phrase_post)

    def parse_phrase(self, phrase):
        return " ".join(word.split("\\")[0] for word in phrase)

    def on_phrase_post(self, j):
        phrase = self.parse_phrase(j.get("phrase", []))
        if phrase in ("history show", "history hide"):
            return
        cmd = j["cmd"]
        if cmd == "p.end" and phrase:
            self.history.append((phrase, ""))
            self.history = self.history[-hist_len:]
            webview.render(template, phrases=self.history)


history = History()

ctx = Context("phrase_history")
ctx.keymap({
    "history show": lambda m: webview.show(),
    "history hide": lambda m: webview.hide()
})
# webview.show()