-
-
Notifications
You must be signed in to change notification settings - Fork 650
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
TextInfo move by codepoint characters function #16219
Conversation
Also:
|
See test results for failed build of commit 18fc288efd |
@mltony thanks for this. Very interesting. Can this be used also for character by character or word by word navigation? If yes, then this would probably open up a good way to solve also #11908, #2649, #13712, or #4431. Also does this in your testing workwwell with compund characters in Asian or Arabic languages? |
Co-authored-by: Łukasz Golonka <lukasz.golonka@mailbox.org>
Co-authored-by: Łukasz Golonka <lukasz.golonka@mailbox.org>
Co-authored-by: Łukasz Golonka <lukasz.golonka@mailbox.org>
@Adriani90, |
See test results for failed build of commit 5b3ed7e7d6 |
I really like this approach, but I'm not sure about the name
So may be code point offset is better. |
@LeonarddeR, Would be happy to rename it to something else more intuitive. But not sure that code point offset is more intuitive - I bet the term code point will definitely require people to look up the meaning of - whereas the term Pythonic is at least familiar to those devs who are aware of the difference between different offset schemes. |
See test results for failed build of commit 432c167854 |
@michaelDCurran, wondering if you can take a look at this PR? You gave green light for sentence navigation - this one is apparently required to make sentence navigation to work properly. |
@mltony I agree with @LeonarddeR re the name. Pythonic is way too general... this is all "Python". Please rename it to moveToCodepointOffset. |
@michaelDCurran, I addressed your comments, please have another look.
|
@mltony could you also update the title and the initial description of this PR? |
@michaelDCurran, @seanbudd, kindly ping - can either of you review this? This PR is blocking sentence navigation PR and style navigation PR. My leave is coming to an end soon and I really wanted to contribute these two PRs to NVDA before I go back to full time work. |
This pr removes / renames public symbols in textUtils.py? Can you state how you have handled add-on compatibility? Assuming we can guarantee compatibility for with 2024.1, then I'm happy to approve. |
In textUtils.py lines 236..238 I declare old function names and just assign new function names to them. Just like aliases. So any add-on calling these functions won't be affected. That only applies to |
Link to issue number:
This function is needed for both #8518 and #16050.
Summary of the issue:
Suppose we have TextInfo that represents a paragraph of text:
Suppose that we would like to put the cursor at the first letter of the word 'world'.
That means jumping to index 7:
The problem is that calling
paragraphInfo.move(UNIT_CHARACTER, 7, "start")
is not guaranteed to achieve desired effect. There are two main reasons for that:TextInfo.move(UNIT_CHARACTER)
function is its performance in some implementations. In particular, moving by 10000 characters in Notepad++ takes over a second on a reasonably modern PC. I might not need to move by 10000 characters in my upcoming PRs, but I will need to move by a few thousands for sure since for sentence navigation I would need to move within a paragraph and some large paragraphs in typical texts can easily be few thousands characters. I need to find both beginning and end textInfos, and if each operation takes say 200ms, then we'd be wasting almost half a second on just moving by characters. Since there were previous concerns about sentence navigation being not fast enough, II would like to introduce this efficient implementation.Here is how this can be done efficiently using this PR:
Description of user facing changes
N/A
Description of development approach
def moveToPythonicOffset
function intextInfos\__init__.py
.OffsetsTextInfo
andCompoundTextInfo
.textUtils.py
making it conformant to OOP style. I implementedUTF8OffsetConverter
and dummyIdentityOffsetConverter
as well as their abstract base class and a functiongetOffsetConverter
that selects correct converter based on encoding. I renamed a couple of methods ofWideStringOffsetConverter
in order to remove the wordwide
- as now I would like to use similar methods for UTF8 converter, and it has nothing to do with wide strings.Testing strategy:
WideStringOffsetConverter
- just to make sure my refactoring didn't break this class.Known issues with pull request:
N/A
Code Review Checklist: