Esempio n. 1
0
    def on_attributes(self, attributes):
        sel = self.callbacks["get_var"]("reader_item")
        if sel and sel.id in attributes:
            remove_hook("curses_attributes", self.on_attributes)

            # Don't bother checking attributes. If we're still
            # lacking, refresh  will re-enable this hook

            self.refresh()
Esempio n. 2
0
 def on_attributes(self, attributes):
     sel = self.reader.callbacks["get_var"]("reader_item")
     if sel and sel.id in attributes:
         # Sucks that we have to check these, but we can't be sure
         # any particular call is ours.
         for attr in self.needed_attrs:
             if attr not in attributes[sel.id]:
                 break
         else:
             remove_hook("curses_attributes", self.on_attributes)
             self.got_attrs = True
             self.reader.callbacks["set_var"]("needs_refresh", True)
             self.reader.callbacks["release_gui"]()
Esempio n. 3
0
 def on_attributes(self, attributes):
     sel = self.reader.callbacks["get_var"]("reader_item")
     if sel and sel.id in attributes:
         # Sucks that we have to check these, but we can't be sure
         # any particular call is ours.
         for attr in self.needed_attrs:
             if attr not in attributes[sel.id]:
                 break
         else:
             remove_hook("curses_attributes", self.on_attributes)
             self.got_attrs = True
             self.reader.callbacks["set_var"]("needs_refresh", True)
             self.reader.callbacks["release_gui"]()
Esempio n. 4
0
    def check(self):
        hooks.on_hook("test", self.hook_a) # No key
        hooks.on_hook("test", self.hook_b, "first_remove")
        hooks.on_hook("test", self.hook_c, "first_remove")
        hooks.on_hook("test2", self.hook_a, "second_remove")

        hooks.call_hook("test", [])

        if self.test_set != "abc":
            raise Exception("Basic hook test failed: %s" % self.test_set)

        self.test_set = ""
        hooks.call_hook("test2", [])

        if self.test_set != "a":
            raise Exception("Basic hook test2 failed: %s" % self.test_set)

        self.test_set = ""
        hooks.unhook_all("first_remove")
        hooks.call_hook("test", [])

        if self.test_set != "a":
            raise Exception("unhook_all failed: %s" % self.test_set)

        self.test_set = ""
        hooks.remove_hook("test", self.hook_a)
        hooks.call_hook("test", [])

        if self.test_set != "":
            raise Exception("remove_hook failed: %s" % self.test_set)

        hooks.call_hook("test2", [])

        if self.test_set != "a":
            raise Exception("improper hook removed: %s" % self.test_set)

        hooks.unhook_all("second_remove")

        if hooks.hooks != {}:
            raise Exception("hooks.hooks should be empty! %s" % hooks.hooks)

        hooks.on_hook("argtest", self.hook_args)

        for args in [ [], ["abc"], [1, 2, 3] ]:
            self.test_args = []
            hooks.call_hook("argtest", args)
            if self.test_args != tuple(args):
                raise Exception("hook arguments failed in %s out %s" % (args, self.test_args)) 

        return True
Esempio n. 5
0
    def die(self):
        # Reset so items get die() called and everything
        # else is notified about items disappearing.

        self.reset()
        remove_hook("curses_opt_change", self.on_opt_change)
        remove_hook("curses_tag_opt_change", self.on_tag_opt_change)
        remove_hook("curses_attributes", self.on_attributes)
Esempio n. 6
0
 def on_attributes(self, attributes):
     sel = self.callbacks["get_var"]("reader_item")
     if sel and sel.id in attributes:
         remove_hook("curses_attributes", self.on_attributes)
         self.callbacks["set_var"]("needs_refresh", True)
         self.callbacks["release_gui"]()
Esempio n. 7
0
 def unhook_tag_list(self, vars):
     # Perhaps this should be a separate hook for command completion?
     if "input_prompt" in vars:
         self.callbacks["set_opt"]("taglist.tags_enumerated", False)
         self.callbacks["release_gui"]()
         remove_hook("curses_var_change", self.unhook_tag_list)
Esempio n. 8
0
 def die(self):
     remove_hook("curses_opt_change", self.on_opt_change)
     remove_hook("curses_tag_opt_change", self.on_tag_opt_change)
     remove_hook("curses_attributes", self.on_attributes)
Esempio n. 9
0
 def on_attributes(self, attributes):
     sel = self.callbacks["get_var"]("reader_item")
     if sel and sel.id in attributes:
         remove_hook("curses_attributes", self.on_attributes)
         self.callbacks["set_var"]("needs_refresh", True)
         self.callbacks["release_gui"]()
Esempio n. 10
0
 def unhook_tag_list(self, vars):
     # Perhaps this should be a separate hook for command completion?
     if "input_prompt" in vars:
         self.callbacks["set_opt"]("taglist.tags_enumerated", False)
         self.callbacks["release_gui"]()
         remove_hook("curses_var_change", self.unhook_tag_list)
Esempio n. 11
0
 def die(self):
     log.debug("Cleaning up hooks...")
     remove_hook("curses_eval_tags_changed", self.refresh)
     remove_hook("curses_items_added", self.on_items_added)
     remove_hook("curses_items_removed", self.on_items_removed)
Esempio n. 12
0
 def die(self):
     remove_hook("curses_opt_change", self.on_opt_change)
     remove_hook("curses_var_change", self.on_var_change)
Esempio n. 13
0
 def die(self):
     remove_hook("curses_opt_change", self.on_opt_change)
     remove_hook("curses_var_change", self.on_var_change)
     unregister_all(self)