Opened 6 years ago

Closed 4 years ago

#17305 closed enhancement (fixed)

[wxSTC] FindText should return start/end position of matched text

Reported by: eran Owned by: Artur Wieczorek <artwik@…>
Priority: normal Milestone:
Component: wxStyledText Version: dev-latest
Keywords: findtext Cc:
Blocked By: Blocking:
Patch: yes

Description

wxSTC hides a meaningful API from the original Scintilla API:

wxStyledTextCtrl::FindText only returns the match position (or wxNOT_FOUND if no match is found), however, it should also return the matched string start and end position in the document

The original API is described here: http://www.scintilla.org/ScintillaDoc.html#SCI_FINDTEXT also returns the start/end position.

wxWidget API does not offer this options which makes it quite impossible to highlight the matched text (Usually, I could use findString.length() to get the matched string length, however, when using a regex this is not the case)

Attachments (1)

stcfindtext.patch download (6.2 KB) - added by NewPagodi 4 years ago.

Download all attachments as: .zip

Change History (4)

comment:1 Changed 6 years ago by vadz

  • Priority changed from high to normal
  • Status changed from new to confirmed
  • Type changed from defect to enhancement

This shouldn't be too difficult to fix, but you will need to update source:git-wxWidgets/src/stc/gen_iface.py and rerun it to do it.

comment:2 Changed 4 years ago by NewPagodi

  • Patch set

I'm attaching a patch to address this. This also addresses pullrequest 23 on github https://github.com/wxWidgets/wxWidgets/pull/23

This patch
1) makes a modification to gen_iface.py to add a 5th parameter that can be used to receive the end position of matched text.
2) alters gen_docs.py to fully document the inputs and output values of the FindText method.

In the discussion of the pull request it is mentioned adding an extra parameter is probably not the best way to deal with this. However I think this is the most minimally disruptive way of exposing this information. By adding an extra parameter with a default value, no new method is needed and new FindText method will still work with all old code.

Also this style of returning extra information is in keeping with the spirit of the other methods in the control. GetCurLine, GetCurLineRaw, GetSelection, PositionToXY, and HitTest all use this method of returning extra data from a method.

Changed 4 years ago by NewPagodi

comment:3 Changed 4 years ago by Artur Wieczorek <artwik@…>

  • Owner set to Artur Wieczorek <artwik@…>
  • Resolution set to fixed
  • Status changed from confirmed to closed

In 91a2869b0e56da3650c2778e655b7df19d3d2617/git-wxWidgets:

Extend FindText() to return end position of matched text in wxSTC

New 5th parameter of FindText() can be used to receive the end position of matched text returned by SCI_FINDTEXT API.

Closes #17305.
Closes https://github.com/wxWidgets/wxWidgets/pull/23

Note: See TracTickets for help on using tickets.