Swap blocks in pattern

I’m looking for a function that will swap the pattern selection with a same-sized block at the cursor position. If they overlap, pop up an error message. In Impulse Tracker and related, this can be done with alt+Y.

Bonus points for a version that does this only within a track, and another that does so across several tracks if swap blocks overflow the current track =)

well, i’m sure this CAN be done, but the amount of checks for possible errors is going to be absolutely mindboggling…uhh.

Well, i figured if (a) you can do it with cut/copy/paste, it just takes longer, and (b ) the functionality exists since ST3… then it must not be impossible to do in lua B)

this is very doable