Rectangular selection for paste, aka column edit, doesn't seem to function properly.

.any thoughts on the following?

When copying a rectangular selection of text, then pasting it
to a rectangular selection in another part of a file - both rectangular
selections are equal in size - the rectangular paste doesn't seem to
respect the selection boundaries.

E.g.

- Press the "Alt" key, then select several rows of text within the same column.
- Use Ctrl-C to copy the rectangular selection.
- In this example say rows 1 thru 4, column 4. This would be all the upper case "D"s
  of the following text snippet.

a b c D
a b c D
a b c D
a b c D

- Now press the "Alt" key, then select rows 1 thru 4, column 2. This would be all
  the lower case case "b"s
- Now use Ctrl-V to paste the previously copied column of "D"s.
- On several wxPython designed editors (DrPython, PyPE, SPE, and my own creation)
  the output is incorrect and looks as follows :

a D
D
D
D
c D
a c D
a c D
a c D

I also tried this on the SciTE editor and it worked as expected, i.e., all the lower case
"b"s were replaced with the upper case "D"s.

Also, I tried a few hacks, such as intercepting the paste event and using
ReplaceSelection() [along with a few others :slight_smile: ], but nothing seemed to work.

Any help, insight, suggestions, hacks, code, etc... would be greatly appreciated.

Thanks,
Joe

Joseph D. Poirier
DSP Software
IMN, Nokia Inc.
6000 Connection Drive
Irving, TX 75039

joseph.poirier@nokia.com

Joseph D. Poirier:

When copying a rectangular selection of text, then pasting it
to a rectangular selection in another part of a file - both rectangular
selections are equal in size - the rectangular paste doesn't seem to
respect the selection boundaries.

   With Scintilla for Windows, a rectangular selection is represented on the
clipboard by two objects: the text and an empty object of type
"MSDEVColumnSelect" which is compatible with Visual Studio. The paste
operation is performed differently if the rectangular marker
"MSDEVColumnSelect" is present. With Scintilla for GTK+ on X the same effect
is produced by ending the text wth a \n\0 marker.

   Looks like wxStyledTextControl does not do anything to store or retrieve
a rectangular marker.

   Neil

Neil Hodgson wrote:

Joseph D. Poirier:

When copying a rectangular selection of text, then pasting it
to a rectangular selection in another part of a file - both rectangular
selections are equal in size - the rectangular paste doesn't seem to
respect the selection boundaries.

   With Scintilla for Windows, a rectangular selection is represented on the
clipboard by two objects: the text and an empty object of type
"MSDEVColumnSelect" which is compatible with Visual Studio. The paste
operation is performed differently if the rectangular marker
"MSDEVColumnSelect" is present. With Scintilla for GTK+ on X the same effect
is produced by ending the text wth a \n\0 marker.

   Looks like wxStyledTextControl does not do anything to store or retrieve
a rectangular marker.

I'll add this to my ToDo list, but I wouldn't mind if somebody beat me to it and submitted a patch. :wink:

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

We are using a wxTreeCtrl in a way very similar to the one in the
left pane of the wxPython demo. It works fine on Linux and GTK2.

But when running on Windows XP, the following debug messages show
up when expanding and collapsing tree items:

  Debug: e:\Projects\wx2.4\src\msw\treectrl.cpp(754): 'TreeView_GetItem' failed with error 0x00000005 (access is denied.).
  Debug: e:\Projects\wx2.4\src\msw\treectrl.cpp(754): 'TreeView_GetItem' failed with error 0x00000000 (the operation completed successfully.).

Here is the code handling the tree expansion/collapse:

     def OnTreeExpanded(self, wx_evt):
         i = wx_evt.GetItem()
         e = self._tree.GetItemText(i)
         self._treex[e] = True
         wx_evt.Skip()

     def OnTreeCollapsed(self, wx_evt):
         i = wx_evt.GetItem()
         e = self._tree.GetItemText(i)
         if self._treex.has_key(e):
            del self._treex[e]
         wx_evt.Skip()

Noting unusual there. However, the messages are only printed
to the log file of the TreeCtrl and before the very first line

         i = wx_evt.GetItem()

is executed in each event handler above.

Therefore, the messages must originate from the wx event handler
after the tree item is clicked but before the handler is called.

Initially, it seemed that tree items may be missing or deleted.
But saving a copy of the entire tree does not make a difference.

Any idea what is wrong?

/Jean Brouwers

PS) This is wxPython 2.4.1.2 and Python 2.3.1 on Windows XP and
also on Linux RedHat 8 with GTK2.

Jean Brouwers wrote:

We are using a wxTreeCtrl in a way very similar to the one in the
left pane of the wxPython demo. It works fine on Linux and GTK2.

But when running on Windows XP, the following debug messages show
up when expanding and collapsing tree items:

Debug: e:\Projects\wx2.4\src\msw\treectrl.cpp(754): 'TreeView_GetItem' failed with error 0x00000005 (access is denied.).
Debug: e:\Projects\wx2.4\src\msw\treectrl.cpp(754): 'TreeView_GetItem' failed with error 0x00000000 (the operation completed successfully.).

[...]

Noting unusual there. However, the messages are only printed
to the log file of the TreeCtrl and before the very first line

        i = wx_evt.GetItem()

is executed in each event handler above.

Therefore, the messages must originate from the wx event handler
after the tree item is clicked but before the handler is called.

Yep, the "TreeView_GetItem" mentioned is the win32 API that is being called and so the message is just reporting the results of that funciton call. IIRC, the code has already been updated to not generate log messages for the successful case. The access is denied case may be because something is trying to access a hidden root.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Is the 'hidden root' something we created? /Jean

Robin Dunn wrote:

···

Jean Brouwers wrote:

We are using a wxTreeCtrl in a way very similar to the one in the
left pane of the wxPython demo. It works fine on Linux and GTK2.

But when running on Windows XP, the following debug messages show
up when expanding and collapsing tree items:

Debug: e:\Projects\wx2.4\src\msw\treectrl.cpp(754): 'TreeView_GetItem' failed with error 0x00000005 (access is denied.).
Debug: e:\Projects\wx2.4\src\msw\treectrl.cpp(754): 'TreeView_GetItem' failed with error 0x00000000 (the operation completed successfully.).

[...]

Noting unusual there. However, the messages are only printed
to the log file of the TreeCtrl and before the very first line

        i = wx_evt.GetItem()

is executed in each event handler above.

Therefore, the messages must originate from the wx event handler
after the tree item is clicked but before the handler is called.

Yep, the "TreeView_GetItem" mentioned is the win32 API that is being called and so the message is just reporting the results of that funciton call. IIRC, the code has already been updated to not generate log messages for the successful case. The access is denied case may be because something is trying to access a hidden root.

Jean Brouwers wrote:

Is the 'hidden root' something we created? /Jean

Did you use wxTR_HIDE_ROOT?

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Nope, just _HAS_BOTTONS and _HAS_VARIABLE_ROW_HEIGHT like the
tree in the left window pane of the demo.

/Jean

PS) We will call tree.DeleteAllItems() and tree.AddRoot() when
the tree needs to be updated with additional items.

However, that is not the case when the Debug messages occur. In
that case, the tree was created and tree.AddRoot() was called just
once. No call to tree.DeleteAllItems().

Robin Dunn wrote:

···

Jean Brouwers wrote:

Is the 'hidden root' something we created? /Jean

Did you use wxTR_HIDE_ROOT?