Author Topic: Bad user experience of the replace dialog  (Read 6639 times)

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6077
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Bad user experience of the replace dialog
« on: November 23, 2009, 12:10:03 pm »
See the first screen shot below:



I want to replace the text "editor", so I double click on the "editor", good, the text is automatically select when I open the "replace dialog".

Then I press the button "Replace" to start the replacement process.

See the second screen shot.



To bad :(, not the text in current caret position is a candidate, but the next occurrence of "editor" was firstly prompt to be replaced.


What I expect the good way is:

The replace precess should start from the current caret position, not the next occurrence of the search text.

If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7252
Re: Bad user experience of the replace dialog
« Reply #1 on: November 23, 2009, 12:19:10 pm »
If you double-clicked the word, the cursor position is most likely somewhere in the middle of the word, so the behaviour is correct (even if the user might expect the actual selected word to be the first one that is replaced).

To change this there are two possibilities: always start replacing/searching at the beginning of a selection (if any) or set the cursor-position to the beginning of the selection and start replacing/searching afterwards.

Both would have the same effect, but if "Origin" is "from cursor" I guess many users would expect to start there and not to change the position automatically.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6077
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Bad user experience of the replace dialog
« Reply #2 on: November 23, 2009, 02:57:13 pm »
The related code was in

sdk\editormanager.cpp  line 1634

Code
int EditorManager::ReplaceInFiles(cbFindReplaceData* data)

But this function was too long, and I can't understand the whole logic. :(
« Last Edit: November 23, 2009, 03:33:30 pm by ollydbg »
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7252
Re: Bad user experience of the replace dialog
« Reply #3 on: November 23, 2009, 03:25:37 pm »
But this function was too long, and I can't understand the whole logic. :(

The logic is quite simple: if "Origin" is "from cursor", C::B searches from cursor-position, but if you select a word by double-click scintilla places the cursor at the end of the selection, so it finds the next occurrence first.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6077
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Bad user experience of the replace dialog
« Reply #4 on: November 23, 2009, 03:33:10 pm »
Thanks.
Is it possible to change the start position of the search. It seems this function control the start position.

sdk\editormanager.cpp  line 1287

Code
void EditorManager::CalculateFindReplaceStartEnd(cbStyledTextCtrl* control, cbFindReplaceData* data, bool replace)
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7252
Re: Bad user experience of the replace dialog
« Reply #5 on: November 23, 2009, 04:11:26 pm »
Thanks.
Is it possible to change the start position of the search. It seems this function control the start position.

sdk\editormanager.cpp  line 1287

Code
void EditorManager::CalculateFindReplaceStartEnd(cbStyledTextCtrl* control, cbFindReplaceData* data, bool replace)

It's possible, but might be incorrect, what if you select text with pressed mouse-button from left to right ?
In this case it would be incorrect to set the cursor to the start of the selection (the user might have had a cause to do so).

How to decide when the current position has to be corrected and when not ?

The only place to change the default behaviour (of a doubleclick) is inside the scintilla-code (in my opinion).
[see Editor.cxx:5404  void Editor::ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt)]

But to place the cursor at the beginning of a word after duble-clicking it would be quiet unusual as far as I know.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6077
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Bad user experience of the replace dialog
« Reply #6 on: November 23, 2009, 04:33:08 pm »
Hi, jens, I think you misunderstand my idea.

I don't want to change the behavior when I double click on a string.

I just want to change the search(replace) start position, it seems we can change it in the function
 
void EditorManager::CalculateFindReplaceStartEnd,

And that don't affect the scintilla related behavior.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7252
Re: Bad user experience of the replace dialog
« Reply #7 on: November 23, 2009, 04:45:06 pm »
Hi, jens, I think you misunderstand my idea.

I don't want to change the behavior when I double click on a string.

I just want to change the search(replace) start position, it seems we can change it in the function
 
void EditorManager::CalculateFindReplaceStartEnd,

And that don't affect the scintilla related behavior.

No you misunderstood me.

Please read carefully what I wrote:

It's possible, but might be incorrect, what if you select text with pressed mouse-button from left to right ?
In this case it would be incorrect to set the cursor to the start of the selection (the user might have had a cause to do so).
It's of course also incorrect to change the start position for a search (at least in this case), because as written: the user might have had a cause to do so.
How to decide when the current position has to be corrected and when not ?

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6077
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Bad user experience of the replace dialog
« Reply #8 on: November 23, 2009, 04:54:46 pm »
Sorry, my English is not so good. :wink:
At least I can select the text by select text with pressed mouse-button from right to left, this time, the caret was before the text.

It's midnight now, I will reread this thread tomorrow. Thanks.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.