Skip to content

xtext: getSelectedWords returns with indices#2013

Merged
Frenzie merged 2 commits into
koreader:masterfrom
TnS-hun:getSelectedWordIndices
Jan 3, 2025
Merged

xtext: getSelectedWords returns with indices#2013
Frenzie merged 2 commits into
koreader:masterfrom
TnS-hun:getSelectedWordIndices

Conversation

@TnS-hun

@TnS-hun TnS-hun commented Dec 27, 2024

Copy link
Copy Markdown
Contributor

Rename getSelectedWords to getSelectedWordIndices, and return the word boundary indices instead of the words. This is needed for highlighting. The words themselves can be obtained by passing the indices to the getText function.

Warning! Breaking change.


This change is Reviewable

@poire-z poire-z left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine with me. I'll review the frontend PR later.

Comment thread xtext.cpp Outdated
// Get (as a single UTF-8 string) the segment of m_text, extended to include
// the full words that may be cut at boundaries (start, end).
void getSelectedWords(int start, int end, int context) {
// Get extended start and end indices that include the full words that may be cut at boundaries (start, end).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Get extended start and end indices that include the full words that may be cut at boundaries (start, end).
// Get start and end indices of an extended segment of m_text that includes the full words that may be cut at boundaries (start, end).

(Just for clarity, "extended indices" reads odd to me.)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the comments.

Rename getSelectedWords to getSelectedWordIndices, and return the word boundary indices instead of the words. This is needed for highlighting. The words themselves can obtained by passing the indices to the getText function.

Warning! Breaking change.
@TnS-hun TnS-hun force-pushed the getSelectedWordIndices branch from 2fb4f9e to 734eb01 Compare December 27, 2024 18:42
@TnS-hun

TnS-hun commented Dec 28, 2024

Copy link
Copy Markdown
Contributor Author

I introduced and off by one error, so I added a small fix commit. (I did not want to use force push because it is two character change.)

@Frenzie

Frenzie commented Dec 28, 2024

Copy link
Copy Markdown
Member

We'll just squash it. :-)

@Frenzie Frenzie merged commit c844e4b into koreader:master Jan 3, 2025
@poire-z

poire-z commented Jan 3, 2025

Copy link
Copy Markdown
Contributor

Warning! Breaking change.

You may have been too quick at merging this :/
If you need to bump base into frontend, we'll need to either finalize #12948, or an interim commit to just translate bits to the xtext api change.

@Frenzie

Frenzie commented Jan 3, 2025

Copy link
Copy Markdown
Member

Hm, indeed. If necessary I'll force push or revert.

Frenzie pushed a commit to koreader/koreader that referenced this pull request Jan 12, 2025
When selecting text in the dictionary (including Wikipedia) or the pop-up footnotes highlight the selected text using an inverting rectangle. After closing the opened dictionary remove the highlight after a short delay just like in the reader.

Depends on koreader/koreader-base#2013
0xstillb pushed a commit to 0xstillb/koreader-thai that referenced this pull request May 9, 2026
When selecting text in the dictionary (including Wikipedia) or the pop-up footnotes highlight the selected text using an inverting rectangle. After closing the opened dictionary remove the highlight after a short delay just like in the reader.

Depends on koreader/koreader-base#2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants