Add a command to show the symbol replacement#9287
Conversation
…anguage * The gesture can be assigned in text review category * In the symbol itself, corresponding to the character where the review cursor is placed, and the replacement, are shown in browse mode * The title of the browse mode dialog contains the language for the current voice, i.e., the language for which the symbols can be edited from Preferences submenu
|
Would it be possible to add a second command to show a replacement for the symbol on which cared is located? For people who like me works with review cursor not following the cared it would be a huge benefit. |
|
Replying to lukaszgo1:
I started this PR before it's accepted since, if it isn't, I will use the code for Emoticons add-on. Let's wait for other feedback and reviews, but your suggestion could make sense. I haven't assigned a gesture for this command so we don't waste too much keystrokes, and I think that, if only it's possible to add a unique command, it's better to use review cursor, not caret, for flexibility. But both commands could benefit. BTW, ui.browseableMessage() is the better option for me since it's very navigable. Anyway, it can be opened multiple times, but this maybe considered in a separate issue, since this affects for example to formatting dialog (which can be opened NVDA+f twice). |
LeonarddeR
left a comment
There was a problem hiding this comment.
- You do not need a special symbol processor for this, just use speech.getCurrentLanguage. I can see why you don't take language switching into account, though I consider this a bit of a drawback to this approach. I'm not sure what's currently the best way to do this.
- Please make this script similar to the report formatting script (i.e. just speak the info at first press and show a browsable message at second press. I think that's more consistent.
|
Actually, I think it must be possible to get the appropriate language from the textInfo in a similar way to how speech.speakTextInfo does it. |
|
Yes, I will try to do it.
Enviado desde mi iPhone
… El 19 feb 2019, a las 19:49, Leonard de Ruijter ***@***.***> escribió:
Actually, I think it must be possible to get the appropriate language from the textInfo in a similar way to how speech.speakTextInfo does it.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
|
@LeonarddeR, I have addresed your request and have tested this in NV Access website with autoLanguageSwitching activated, and in Notepad. Also, pressing twice on normal characters (then the browseable message is not shown), and over symbols. |
|
I have addressed other requested change, not using symbolProcessor, but just current language. |
| expandedSymbol = characterProcessing.processSpeechSymbol(curLanguage, text) | ||
| repeats=scriptHandler.getLastScriptRepeatCount() | ||
| if repeats == 0: | ||
| # Explicitly tether here |
There was a problem hiding this comment.
Rather than tethering and using speech.SpeakTextInfo, I think I'd prefer just calling ui.message(expandedSymbol)
| # Explicitly tether here | ||
| braille.handler.setTether(braille.handler.TETHER_REVIEW, auto=True) | ||
| speech.speakTextInfo(info,unit=textInfos.UNIT_CHARACTER,reason=controlTypes.REASON_CARET) | ||
| elif expandedSymbol != text: |
There was a problem hiding this comment.
There is some overlap between this script and the script_review_currentCharacter script. On closer inspection, I think it makes sense to let this script only report something if there is a real replacement. In other words, if the current character isn't replaced by something else, it might make sense to report just that: No symbol pronunciation rule for {text}. @feerrenrut: thoughts?
| speech.speakTextInfo(info,unit=textInfos.UNIT_CHARACTER,reason=controlTypes.REASON_CARET) | ||
| elif expandedSymbol != text: | ||
| # Translators: title for expanded symbol dialog. | ||
| ui.browseableMessage("%s\n%s" % (text, expandedSymbol), _("Expanded symbol %s" % languageHandler.getLanguageDescription(curLanguage))) |
There was a problem hiding this comment.
For speech users, I think it is confusing that both the original and replacement are shown here. I initially thought that the replacement was just duplicated.
| ui.browseableMessage("%s\n%s" % (text, expandedSymbol), _("Expanded symbol %s" % languageHandler.getLanguageDescription(curLanguage))) | |
| ui.browseableMessage(_( | |
| "Character: {character}\n" | |
| "Replacement: {replacement}" | |
| ).format(character=text, replacement=expandedSymbol), | |
| _("Expanded symbol ({language})").format( | |
| language=languageHandler.getLanguageDescription(curLanguage) | |
| )) |
| elif expandedSymbol != text: | ||
| # Translators: title for expanded symbol dialog. | ||
| ui.browseableMessage("%s\n%s" % (text, expandedSymbol), _("Expanded symbol %s" % languageHandler.getLanguageDescription(curLanguage))) | ||
| script_review_currentSymbol.__doc__=_("Speaks the symbol where the review cursor is positioned. Pressed twice, shows the symbol and the text used to speak it in browse mode") |
There was a problem hiding this comment.
| script_review_currentSymbol.__doc__=_("Speaks the symbol where the review cursor is positioned. Pressed twice, shows the symbol and the text used to speak it in browse mode") | |
| script_review_currentSymbol.__doc__=_( | |
| "Reports the symbol where the review cursor is positioned. " | |
| "Pressed twice, shows the symbol and the text used to speak it in browse mode" | |
| ) |
| | Select then Copy from review cursor | NVDA+f9 | NVDA+f9 | none | Starts the select then copy process from the current position of the review cursor. The actual action is not performed until you tell NVDA where the end of the text range is | | ||
| | Select then Copy to review cursor | NVDA+f10 | NVDA+f10 | none | On the first press, text is selected from the position previously set start marker up to and including the review cursor's current position. After pressing this key a second time, the text will be copied to the Windows clipboard | | ||
| | Report text formatting | NVDA+f | NVDA+f | none | Reports the formatting of the text where the review cursor is currently situated. Pressing twice shows the information in browse mode | | ||
| | Report current symbol replacement | None | None | none | Speaks the symbol where the review cursor is positioned. Pressed twice, shows the symbol and the text used to speak it in browse mode. | |
There was a problem hiding this comment.
Are there more entries in here that have no default assignments?
|
@LeonarddeR , requested changes have been addressed in 85a0e3d @LeonarddeR asked:
| Select then Copy from review cursor | NVDA+f9 | NVDA+f9 | none | Starts the select then copy process from the current position of the review cursor. The actual action is not performed until you tell NVDA where the end of the text range is | | Select then Copy to review cursor | NVDA+f10 | NVDA+f10 | none | On the first press, text is selected from the position previously set start marker up to and including the review cursor's current position. After pressing this key a second time, the text will be copied to the Windows clipboard | | Report text formatting | NVDA+f | NVDA+f | none | Reports the formatting of the text where the review cursor is currently situated. Pressing twice shows the information in browse mode | +| Report current symbol replacement | None | None | none | Speaks the symbol where the review cursor is positioned. Pressed twice, shows the symbol and the text used to speak it in browse mode. | Are there more entries in here that have no default assignments? I think this would be the unique entry. Could we use windows+NVDA+. as an assigned gesture for this command? Thanks |
|
The following error occurred while building NVDA17213: |
…itioned at a symbol
- Use %s instead of format, and add translator comments for _("Character %s") and _("Replacement %s")
- When the cursor is not positioned at a symbol, report just _("No symbol") instead of announcing the character where it's situated, to avoid inconsistent messages if the text is blank.
|
Fixed in
dfdab0f
Thanks
El 11/05/2019 a las 0:37, eric escribió:
… The following error occurred while building NVDA17213:
checkPotAction(["tests \ checkPot"],["output \
nvda_snapshot_pr9287-17213,35d31059.pot"]) The message has no
translation comments. Source: globalCommands.py:1212 Message: Character:
{character} \ n 1 error, 0 unexpected success, 75 expected error scons:
*** [tests \ checkPot] error 1 scons: The building terminated due to an
error. Command exit code 2
thank
cc
@nvdaes <https://github.com/nvdaes>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#9287 (comment)>, or
mute the thread
<https://github.com/notifications/unsubscribe-auth/ADYTVZDQC74CVDDCDVFHR2LPUX2KZANCNFSM4GX5OG4A>.
|
| expandedSymbol = characterProcessing.processSpeechSymbol(curLanguage, text) | ||
| if expandedSymbol == text: | ||
| # Translators: Reported when there is no symbol at the position of the review cursor. | ||
| ui.message(_("No symbol")) |
There was a problem hiding this comment.
I would prefer "no symbol replacement". NO symbol is ambiguous in the case where the cursor is at a symbol, but the symbol has no replacement defined.
* When the symbol at the review cursor has no replacement, specify that there is no replacement for it, instead of mentioning that there is no symbol at this position.
|
OK, addressed in
6b1bf1e
El 13/05/2019 a las 19:39, Leonard de Ruijter escribió:
… ***@***.**** commented on this pull request.
------------------------------------------------------------------------
In source/globalCommands.py
<#9287 (comment)>:
> @@ -1188,6 +1188,36 @@ def script_review_endOfLine(self,gesture):
script_review_endOfLine.__doc__=_("Moves the review cursor to the last character of the line where it is situated in the current navigator object and speaks it")
script_review_endOfLine.category=SCRCAT_TEXTREVIEW
+ def script_review_currentSymbol(self,gesture):
+ info=api.getReviewPosition().copy()
+ info.expand(textInfos.UNIT_CHARACTER)
+ text = info.text
+ curLanguage = None
+ if config.conf['speech']['autoLanguageSwitching']:
+ for field in info.getTextWithFields({}):
+ if isinstance(field,textInfos.FieldCommand) and field.command=="formatChange":
+ curLanguage=field.field.get('language')
+ if curLanguage is None:
+ curLanguage = speech.getCurrentLanguage()
+ expandedSymbol = characterProcessing.processSpeechSymbol(curLanguage, text)
+ if expandedSymbol == text:
+ # Translators: Reported when there is no symbol at the position of the review cursor.
+ ui.message(_("No symbol"))
I would prefer "no symbol replacement". NO symbol is ambiguous in the
case where the cursor is at a symbol, but the symbol has no replacement
defined.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#9287?email_source=notifications&email_token=ADYTVZCBNCCLDUDIC5KJTE3PVGRTXA5CNFSM4GX5OG4KYY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOBYOZORA#pullrequestreview-236820292>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ADYTVZDWN2CFEZNWH32IPQTPVGRTXANCNFSM4GX5OG4A>.
|
|
@feerrenrut: I'm done reviewing this |
feerrenrut
left a comment
There was a problem hiding this comment.
Thanks for your work on this!
Overall it looks good, just a couple of small things I would like to see changed.
|
@feerrenrut, I think all your requested changes have been addressed.
Thanks for considering this PR! |
Put first: _getCurrentLanguageForTextInfo Then: script_review_currentSymbol This is consistent with _reportFormattingHelper and script_reportFormatting order, and more readable.
|
I have put the helper function before the script and I think I won't change anything else unless it's requested. I like the idea of the helper function, for readability and since this could be useful for add-ons like Emoticons, by Christianlm, making possible more flexibility to extend the functionality implemented in NVDA's core. Thanks a lot for this suggestion. |
I think the best strategy to introduce changes in style like this is to do it incrementally, along with other changes that bring value. This helps to ensure the changes are tested properly. |
|
Replying to @feerrenrut:
OK. Thanks for merging this. |
Link to issue number:
Closes #9286
Summary of the issue:
Sometimes, it's useful to review and copy symbol replacements, to ensure how they are writen.
Description of how this pull request fixes the issue:
A command has been added to show the replacement for the symbol where the review cursor is placed. This information is presented in browse mode, using ui.browseableMessage().
The dialog title shows the language for which symbols can be edited when the command is activated, that is, autoLanguageSwitching setting is not considered. Only the language used for SpeechSymbols dialog is addressed. This is retrieved using the same code contained in the gui to present the language in the dialog title for Speech Symbols, i.e., using characterProcessing and languageHandler.getLanguageDescription() for the corresponding locale.
The text corresponding to the current character is retrieved via text property of textInfo object of api.getReviewPosition(). This text is compared with the corresponding characterProcessing.processSpeechSymbol(). If the results are differents, then the symbol replacement is present and is shown in browse mode, after the symbol itself, for example:
Testing performed:
Known issues with pull request:
None
Change log entry:
Section: New features
Added a command to show the replacement for the symbol where the review cursor is positioned (#9286)