Repository navigation
Say all, move caret per word instead of per line/sentence #9937
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
8f0921c
ce53201
ff1872c
07b90c8
3225897
3341210
db74dc6
7bf925c
795b6ca
c1d0fb2
f67bbd3
4947f97
28abd3c
c832f7e
7af96e2
3b40b04
000d680
4f5d791
9e9918b
21c310d
1dc834d
60f53b5
5f2154c
aad4c99
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,11 +5,15 @@ | |
| #Copyright (C) 2006-2019 NV Access Limited | ||
|
LeonarddeR marked this conversation as resolved.
Resolved
|
||
|
|
||
| """Commands that can be embedded in a speech sequence for changing synth parameters, playing sounds or running other callbacks.""" | ||
|
|
||
|
LeonarddeR marked this conversation as resolved.
Resolved
|
||
| from abc import ABCMeta, abstractmethod | ||
| import config | ||
| import languageHandler | ||
| from synthDriverHandler import getSynth | ||
| from inspect import signature | ||
| from functools import partial | ||
| from types import FunctionType, MethodType | ||
| from typing import Union | ||
|
|
||
| class SpeechCommand(object): | ||
| """The base class for objects that can be inserted between strings of text to perform actions, change voice parameters, etc. | ||
|
|
@@ -36,7 +40,8 @@ def __init__(self,index): | |
| @param index: the value of this index | ||
| @type index: integer | ||
| """ | ||
| if not isinstance(index,int): raise ValueError("index must be int, not %s"%type(index)) | ||
| if not isinstance(index,int): | ||
| raise TypeError("index must be int, not %s"%type(index)) | ||
| self.index=index | ||
|
|
||
| def __repr__(self): | ||
|
|
@@ -245,6 +250,8 @@ def run(self): | |
| otherwise it will block production of further speech and or other functionality in NVDA. | ||
| """ | ||
|
|
||
| SUPPORTED_CALLBACK_TYPES = (FunctionType, MethodType, partial) | ||
|
|
||
| class CallbackCommand(BaseCallbackCommand): | ||
| """ | ||
| Call a function when speech reaches this point. | ||
|
|
@@ -253,12 +260,27 @@ class CallbackCommand(BaseCallbackCommand): | |
| otherwise it will block production of further speech and or other functionality in NVDA. | ||
| """ | ||
|
|
||
| def __init__(self, callback): | ||
| def __init__(self, callback: Union[SUPPORTED_CALLBACK_TYPES]): | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is a class with a call supported by this union?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No. The only way to acoomplish this seems to be the use of collections.abc.Callable, but that also applies to classes itself. I'm reluctant to do this. |
||
| if not isinstance(callback, SUPPORTED_CALLBACK_TYPES): | ||
| raise TypeError( | ||
| "callback must be one of %s, not %s" | ||
| % (", ".join(SUPPORTED_CALLBACK_TYPES), type(callback)) | ||
| ) | ||
| self._callback = callback | ||
|
|
||
| def run(self,*args, **kwargs): | ||
| return self._callback(*args,**kwargs) | ||
|
|
||
| def __repr__(self): | ||
| if isinstance(self._callback, partial): | ||
| callBackName = "partial[{}]".format(self._callback.func.__qualname__) | ||
| else: | ||
| callBackName = self._callback.__qualname__ | ||
| return "CallbackCommand({name}{signature})".format( | ||
| name=callBackName, | ||
| signature=str(signature(self._callback)) | ||
| ) | ||
|
|
||
| class BeepCommand(BaseCallbackCommand): | ||
| """Produce a beep. | ||
| """ | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be a speech synth dependent setting? For example, users may have many synths, and some might work better with this feature than others.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@derekriemer wrote:
Because while the caret is intended to move per word, the movement is also limited to once per half a second.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ugh, sorry for the comment above, it ended up at the wrong place.
Anyway, making this a per synth setting makes sense to me. I will do that.