On Linux, after copying a rectangular selection into the clipboard, it is possible to paste it into existing text while maintaining the rectangular structure (and not insert newlines where none existed before). On a Mac, this appears to be broken.
Geany 1.37 Using GTK+ v3.24.20 and GLib v2.66.0 runtime libraries
System Version: macOS 10.15.7 (19H15) Kernel Version: Darwin 19.6.0
Example. I want to move the two lines of "hub." into the links above: ![image](https://user-images.githubusercontent.com/22303046/101183682-716b4280-3615-1...)
But when I do a rectangular select (using the mouse since the keys don't work.......that's a different issue), the result of pasting does not at all look like it would on Linux. It looks like this: ![image](https://user-images.githubusercontent.com/22303046/101184032-d9218d80-3615-1...)
When it should look like this: ![image](https://user-images.githubusercontent.com/22303046/101184132-f6565c00-3615-1...)
I had a look what Scintilla does with copy/pasting rectangular selections and probably have an explanation for what happens. Scintilla has to distinguish somehow whether the text in the clipboard is a rectangular selection or ordinary lines ending with `\n`. It does this by placing `\0` behind the `\n` for rectangular selections. So for example ``` abc\n\0 abc\n\0 abc\n\0 ``` in clipboard is a rectangular selection, ``` abc\n abc\n abc\n ``` is ordinary selection.
I assume that macOS just doesn't like the `\0` characters and drops them which effectively changes the rectangular selection in clipboard into ordinary selection.
Maybe on macOS some other character could be used, e.g. `\1`, I'm just not sure how hard it would be to make this change in Scintilla.
To correct myself, the `\0` is only at the end, not after every line.
I tried using `\1` on macOS instead - the paste works correctly within Geany, the only problem is, that when pasted in other applications the final `\1` is included because the other applications don't know that it means block copy in Geany. Not sure if this is something we want.
I also looked at GTK clipboard API if we could store the block selection information somewhere but didn't find anything I could use.
I bet when the data goes through the Mac clipboard code somewhere it uses a C type null terminated string copy so the `\0` is taken as the terminator and lost from the data.
I bet when the data goes through the Mac clipboard code somewhere it uses a C type null terminated string copy so the \0 is taken as the terminator and lost from the data.
Yes, something like that. It can also be the GTK quartz backend or maybe the Mac clipboard can be used in text mode (where it strips `\0`) or binary mode where it doesn't (copy/paste has to work for e.g. pictures where `\0` needs to be preserved).
I've just made the following builds:
Geany 1.38 built with the latest GTK and other dependencies, including some extra fixes which I plan to release as the official macOS build on the Downloads page unless there are some problems with it: https://download.geany.org/snapshots/geany-1.38_osx-5.dmg https://download.geany.org/snapshots/geany-1.38_osx_arm64-2.dmg
Like the above but Geany and plugins are from current git master: https://download.geany.org/snapshots/geany-1.38_osx.dmg https://download.geany.org/snapshots/geany-1.38_osx_arm64.dmg
I decided to "fix" this by trading one bug for another. Instead of the `\0` in the copy/pasted text that indicates block copy I use `\1` which is preserved by macOS. This will include the `\1` when the block-copied text is pasted outside Geany but I don't think people commonly use block-copy to paste it to other applications (it doesn't work as a block-copy in this case anyway).
I just created a simple patch doing this on top of Geany sources that is applied automatically during macOS binary build - it's really just an ugly workaround which I don't want to submit upstream.
Closed #2685 as completed.
github-comments@lists.geany.org