Exemplo n.º 1
0
    def stop(self):
        """
        Cleans up any hooks added to the event loop.  Only call this if you're
        managing the event loop yourself, after the loop stops.
        """
        self.event_loop.remove_enter_idle(self.idle_handle)
        del self.idle_handle
        signals.disconnect_signal(self.screen, INPUT_DESCRIPTORS_CHANGED, self._reset_input_descriptors)
        self.screen.unhook_event_loop(self.event_loop)

        self.screen.stop()
Exemplo n.º 2
0
    def _run(self):
        if self.handle_mouse:
            self.screen.set_mouse_tracking()

        if not hasattr(self.screen, 'get_input_descriptors'):
            return self._run_screen_event_loop()

        self.draw_screen()

        fd_handles = []

        def reset_input_descriptors(only_remove=False):
            for handle in fd_handles:
                self.event_loop.remove_watch_file(handle)
            if only_remove:
                del fd_handles[:]
            else:
                fd_handles[:] = [
                    self.event_loop.watch_file(fd, self._update)
                    for fd in self.screen.get_input_descriptors()
                ]
            if not fd_handles and self._input_timeout is not None:
                self.event_loop.remove_alarm(self._input_timeout)

        try:
            signals.connect_signal(self.screen, INPUT_DESCRIPTORS_CHANGED,
                                   reset_input_descriptors)
        except NameError:
            pass
        # watch our input descriptors
        reset_input_descriptors()
        idle_handle = self.event_loop.enter_idle(self.entering_idle)

        # Go..
        self.event_loop.run()

        # tidy up
        self.event_loop.remove_enter_idle(idle_handle)
        reset_input_descriptors(True)
        signals.disconnect_signal(self.screen, INPUT_DESCRIPTORS_CHANGED,
                                  reset_input_descriptors)
Exemplo n.º 3
0
    def _run(self):
        if self.handle_mouse:
            self.screen.set_mouse_tracking()

        if not hasattr(self.screen, 'get_input_descriptors'):
            return self._run_screen_event_loop()

        self.draw_screen()

        fd_handles = []
        def reset_input_descriptors(only_remove=False):
            for handle in fd_handles:
                self.event_loop.remove_watch_file(handle)
            if only_remove:
                del fd_handles[:]
            else:
                fd_handles[:] = [
                    self.event_loop.watch_file(fd, self._update)
                    for fd in self.screen.get_input_descriptors()]
            if not fd_handles and self._input_timeout is not None:
                self.event_loop.remove_alarm(self._input_timeout)

        try:
            signals.connect_signal(self.screen, INPUT_DESCRIPTORS_CHANGED,
                reset_input_descriptors)
        except NameError:
            pass
        # watch our input descriptors
        reset_input_descriptors()
        idle_handle = self.event_loop.enter_idle(self.entering_idle)

        # Go..
        self.event_loop.run()

        # tidy up
        self.event_loop.remove_enter_idle(idle_handle)
        reset_input_descriptors(True)
        signals.disconnect_signal(self.screen, INPUT_DESCRIPTORS_CHANGED,
            reset_input_descriptors)
 def disconnect_signal(self, signal):
     signals.disconnect_signal(self.term, signal, self._set_signal_response)
Exemplo n.º 5
0
 def disconnect_signal(self, signal):
     signals.disconnect_signal(self.term, signal, self._set_signal_response)