Hi,
I'm using wxSTC and i would like to let users make a replace on a rectangular selection.
Not problems since in the stc document there are unicode chars
Ah, I'm using wx2.5.3msw unicode version
This is the code i'm using:
def ReplaceRect(self, evt):
doc = self.GetTextCtrl() # this is my stc document
if not doc:
wx.Bell()
return
if not doc.SelectionIsRectangle():
wx.Bell()
return
else:
dlg = wx.TextEntryDialog(self, 'Insert replace words here', 'Replace with', '')
if dlg.ShowModal() == wx.ID_OK:
replaced_text = dlg.GetValue()
s_start = min(doc.GetSelectionStart(), doc.GetSelectionEnd())
s_end = max(doc.GetSelectionStart(), doc.GetSelectionEnd())
l_start = doc.LineFromPosition(s_start)
l_end = doc.LineFromPosition(s_end)
c_start = doc.GetColumn(s_start)
c_end = doc.GetColumn(s_end)
while l_start <= l_end:
pos = doc.PositionFromLine(l_start) + c_start
end_position = pos + (c_end - c_start)
if (end_position) > doc.GetLineEndPosition(l_start):
end_position = doc.GetLineEndPosition(l_start)
doc.SetSelection(pos, end_position)
doc.ReplaceSelection( replaced_text )
l_start += 1
When in a line of the selection is present a char, let's say € (euro symbol), the application crashes.
The problem is on the setSelection and replaceSelection due to the fact unicode chars have lenght > 1. but i don't know how to fix the problem and the script.
Can anyone help me?
Thanks in advance
Alessandro Crugnola - sephiroth
···
---------------------------------------------
Macromedia Flash Team Volunteer
http://www.macromedia.com/go/team
Flash && PHP developer
alessandro@sephiroth.it
*relax with SEPY http://www.sf.net/projects/sepy
---------------------------------------------