def disable(self): if self.enabled: self.enabled = False cron.cancel(self.job) self.job = None self.content.publish_event("status_icons", "programming_toggle", "remove")
def move_focus_indicator(self, window): cron.cancel(self.move_indicator_job) active_window = ui.active_window() if active_window.rect.x != self.previous_window_x and active_window.rect.y != self.previous_window_y: self.move_indicator_job = cron.after("30ms", self.update_focus_indicator)
def disable(self, persisted=False): if self.enabled: self.soft_disable() super().disable(persisted) cron.cancel(self.ttl_poller) self.ttl_poller = None
def disable(self): if (self.enabled != False): self.enabled = False speech_system.unregister("phrase", self.on_phrase) if (self.job is not None): cron.cancel(self.job) self.job = None
def mouse_move(self, pos): super().mouse_move(pos) # Hit detection of buttons pos = numpy.array(pos) hover_index = -1 for index, icon in enumerate(self.icon_positions): if (numpy.linalg.norm( pos - numpy.array([icon['center_x'], icon['center_y']])) < icon['radius']): hover_index = index break # Only resume for a frame if our button state has changed if (self.icon_hover_index != hover_index): self.icon_hover_index = hover_index if (self.dwell_job is not None): cron.cancel(self.dwell_job) if (hover_index != -1): self.dwell_job = cron.interval( str(int(self.icon_hover_activate_dwell_seconds * 1000)) + 'ms', self.activate_icon) self.canvas.resume()
def soft_disable(self): if self.soft_enabled: self.soft_enabled = False cron.cancel(self.mouse_poller) self.mouse_poller = None if self.canvas: self.canvas.resume()
def destroy(self): cron.cancel(self.disable_poller_job) cron.cancel(self.update_environment_debouncer) self.event_dispatch.unregister("persist_preferences", self.debounce_widget_preferences) self.event_dispatch.unregister("hide_context_menu", self.hide_context_menu) self.event_dispatch.unregister("deactivate_poller", self.deactivate_poller) self.event_dispatch.unregister("show_context_menu", self.move_context_menu) self.event_dispatch.unregister("synchronize_poller", self.synchronize_widget_poller) self.event_dispatch = None ui.unregister('screen_change', self.reload_preferences) settings.unregister("user.talon_hud_environment", self.hud_environment_change) if self.display_state: self.display_state.unregister('broadcast_update', self.broadcast_update) self.display_state = None if self.enabled: for widget in self.widget_manager.widgets: show_animations = widget.show_animations widget.show_animations = False widget.disable() widget.show_animations = show_animations self.widget_manager.widgets = [] self.widget_manager = None
def disable(self): if not self.enabled: return cron.cancel(self.job) self.enabled = False self.canvas.close() self.canvas = None
def stop(self): # Guard everything in case of spurious stops if self._job: cron.cancel(self._job) self._job = None # Move mouse to neutral position self._move_function(False, False, False, False)
def on_mouse(self, event): pos = numpy.array(event.gpos) # Hit detection of buttons hover_index = -1 for index, icon in enumerate(self.icon_positions): if (numpy.linalg.norm( pos - numpy.array([icon['center_x'], icon['center_y']])) < icon['radius']): hover_index = index break if (event.event == "mousemove"): # Only resume for a frame if our button state has changed if (self.icon_hover_index != hover_index): self.icon_hover_index = hover_index cron.cancel(self.dwell_job) if (hover_index != -1): self.dwell_job = cron.interval( str(int(self.icon_hover_activate_dwell_seconds * 1000)) + 'ms', self.activate_icon) self.canvas.resume() # Click a button instantly elif (event.event == "mouseup" and event.button == 0): self.icon_hover_index = hover_index self.activate_icon()
def check_step(self, phrase): """Check if contents in the phrase match the voice commands available in the step""" if self.current_walkthrough is not None and self.is_in_right_context(): phrase_to_check = " ".join(phrase["phrase"]).lower() if self.current_stepnumber < len(self.current_walkthrough.steps): step = self.current_walkthrough.steps[self.current_stepnumber] current_length = len(self.current_words) for index, voice_command in enumerate(step.voice_commands): # Make sure the activations can only happen in-order if index >= current_length: if voice_command in phrase_to_check: self.current_words.append(voice_command) phrase_to_check = phrase_to_check.split(voice_command, 1)[1] else: break # Send an update about the voice commands said during the step if it has changed if current_length != len(self.current_words): step.said_walkthrough_commands = self.current_words[:] self.content.publish_event("walkthrough_step", "walkthrough_step", "replace", copy.copy(step), show=True, claim=True) # Skip to the next step if no voice commands are available voice_commands_remaining = copy.copy(step.voice_commands) all_commands_said = False for said_word in self.current_words: if said_word in voice_commands_remaining: voice_commands_remaining.remove(said_word) if len(step.voice_commands) > 0 and len(voice_commands_remaining) == 0 and not "skip step" in step.voice_commands and not "continue" in step.voice_commands: cron.cancel(self.next_step_job) self.next_step_job = cron.after("1500ms", self.next_step)
def disable(self): if self.enabled: cron.cancel(self.job) self.job = None self.enabled = False self.previous_scope_state = "" self.content.publish_event("text", "scope", "remove")
def poll_ttl_visuals(self): current_time = time.monotonic() resume_canvas = self.visual_log_length != len(self.visual_logs) for visual_log in self.visual_logs: if self.show_animations and visual_log[ "ttl"] - self.ttl_animation_duration_seconds <= current_time and visual_log[ "animation_tick"] >= 0: visual_log["animation_tick"] = -1 visual_log["animation_goal"] = -self.ttl_animation_max_duration resume_canvas = True # Clear the logs marked for deletion self.visual_logs = [ visual_log for visual_log in self.visual_logs if visual_log["ttl"] > current_time ] # Only start drawing when changes have been made if resume_canvas and self.enabled: self.canvas.resume() self.visual_log_length = len(self.visual_logs) if self.visual_log_length == 0 and self.ttl_poller is not None: self.canvas.resume() cron.cancel(self.ttl_poller) self.ttl_poller = None
def _toggle(_): global hideJob ctrl.cursor_visible(show) if show: cron.cancel(hideJob) else: hideJob = cron.interval("500ms", lambda: ctrl.cursor_visible(show))
def disable(self, animated=True): if self.enabled: self.soft_disable(animated) super().disable(animated) if self.ttl_poller: cron.cancel(self.ttl_poller) self.ttl_poller = None
def _update_scope(): global _terminalContextJob if active_app().bundle == "com.microsoft.VSCode": print("In vscode, updating scope...") talon.update_scope() else: cron.cancel(_terminalContextJob) _terminalContextJob = None
def unregister(self, name): if name in self.callbacks: del self.callbacks[name] current_callback_amount = len(self.callbacks.values()) if current_callback_amount == 0: cron.cancel(self.job) self.job = None
def activate_icon(self): cron.cancel(self.dwell_job) if self.icon_hover_index < len( self.icon_positions) and self.icon_hover_index > -1: actions.user.activate_statusbar_icon( self.icon_positions[self.icon_hover_index]['icon']['id']) self.icon_hover_index = -1
def disable(self): if self.enabled: self.enabled = False cron.cancel(self.job) self.job = None self.current_language = None self.content.publish_event("status_icons", "language_toggle", "remove")
def soft_disable(self): self.clear_canvases() if self.soft_enabled: self.soft_enabled = False cron.cancel(self.mouse_poller) self.mouse_poller = None self.regions = [] self.active_regions = []
def disable(self): if self.enabled == True: cron.cancel(self.scope_job) self.scope_job = None speech_system.unregister("pre:phrase", self.check_step) ctx.tags = [] if self.development_mode: self.watch_walkthrough_file(False) self.enabled = False
def activate_icon(self): if (self.dwell_job is not None): cron.cancel(self.dwell_job) if self.icon_hover_index < len(self.icon_positions): if (self.icon_positions[self.icon_hover_index]['action'] == "mode"): actions.user.activate_statusbar_icon_mode() elif (self.icon_positions[self.icon_hover_index]['action'] == "close"): actions.user.activate_statusbar_icon_close()
def unregister(self, name): if name in self.callbacks: del self.callbacks[name] self.previous_mode = None current_callback_amount = len(self.callbacks.values()) if (current_callback_amount == 0): cron.cancel(self.job) self.job = None
def on_start(self): try: with self._job_lock: if self._end_job: cron.cancel(self._end_job) self._end_job = None self._handler.__enter__() except Exception as e: logging.exception("Error handling noise start")
def hud_environment_change(self, hud_environment: str): if self.current_talon_hud_environment != hud_environment: self.set_current_flow("environment_changed") self.current_talon_hud_environment = hud_environment # Add a debouncer for the environment change to reduce flickering on transitioning cron.cancel(self.update_environment_debouncer) self.update_environment_debouncer = cron.after( "200ms", self.debounce_environment_change)
def on_noise(self, noise): if noise == 'hiss_start' and talon.enabled: if self.job is None: self.job = cron.after(self.initial_delay, self.repeat) print('HISS START') elif noise == 'hiss_end' and self.job: print('HISS STOP') cron.cancel(self.job) self.job = None
def disable(self): if self.enabled: self.enabled = False self.content.publish_event("status_icons", "focus_toggle", "remove") self.content.publish_event("screen_regions", "focus", "remove") ui.unregister("win_focus", self.update_focus_indicator) ui.unregister("win_resize", self.update_focus_indicator) ui.unregister("win_move", self.move_focus_indicator) cron.cancel(self.move_indicator_job)
def enable(self, persisted=False): if not self.enabled: self.enabled = True self.display_state.register("broadcast_update", self.broadcast_update) # Only reset the talon HUD environment after a user action # And only set the visible tag self.current_talon_hud_environment = settings.get( "user.talon_hud_environment", "") if persisted: self.set_current_flow("enabled") self.current_flow = "enable" ctx.tags = [ "user.talon_hud_available", "user.talon_hud_visible", "user.talon_hud_choices_visible" ] # Connect the events relating to non-content communication self.event_dispatch.register("persist_preferences", self.debounce_widget_preferences) self.event_dispatch.register("hide_context_menu", self.hide_context_menu) self.event_dispatch.register("deactivate_poller", self.deactivate_poller) self.event_dispatch.register("show_context_menu", self.move_context_menu) self.event_dispatch.register("synchronize_poller", self.synchronize_widget_poller) # Reload the preferences just in case a screen change happened in between the hidden state if persisted or self.current_flow in ["repair", "initialize"]: reload_theme = self.widget_manager.reload_preferences( True, self.current_talon_hud_environment) if reload_theme != self.theme.name: self.switch_theme(reload_theme, True) for widget in self.widget_manager.widgets: if widget.preferences.enabled and not widget.enabled: widget.enable() self.synchronize_pollers() ui.register("screen_change", self.reload_preferences) settings.register("user.talon_hud_environment", self.hud_environment_change) self.determine_active_setup_mouse() if persisted: self.preferences.persist_preferences({"enabled": True}) self.set_current_flow("manual") # Make sure context isn't updated in this thread because of automatic reloads cron.cancel(self.update_context_debouncer) self.update_context_debouncer = cron.after("50ms", self.update_context)
def stop_scroll(): global scroll_amount, scroll_job, gaze_job scroll_amount = 0 if scroll_job: cron.cancel(scroll_job) if gaze_job: cron.cancel(gaze_job) scroll_job = None gaze_job = None
def disable_poller_check(self): enabled = False for widget in self.widget_manager.widgets: if not widget.cleared: enabled = True break if not enabled: for topic, poller in self.pollers.items(): poller.disable() cron.cancel(self.disable_poller_job) self.disable_poller_job = None