// Macro Paste_Around.bsh // Author: Gael Ecorchard (galou_breizh yahoo.fr) // Version 0.3 // 2007 08 31 // Paste the content of register 'a' before the selection (prefix) // and the content of register 'e' after the selection (suffix) // Usage: // - select the prefix part and paste it into register 'a' (C-r C-c a) // - select the suffix part and paste it into register 'e' (C-r C-c e) // - select something and use the macro. Works also with empty selection. Does // not work yet with multiple selections and rectangular ones (error message) // // Best used with a shortcut like CS-v void Paste_Around () { Selection[] selection = textArea.getSelection(); // doesn't work with rectangular selections and multi-selections, check for // them up-front // copied from Sort_Lines_(editplus_style_sort).bsh if (selection.length > 1) { Macros.error(view, "Sorry, this macro doesn't work with more than one Selection."); return; } else if (selection.length == 1 && selection[0] instanceof Selection.Rect) { Macros.error(view, "Sorry, this macro doesn't work with Rectangular Selections."); return; } if(selection.length != 0) { Registers.cut(textArea,'%'); } Registers.paste(textArea,'a',false); if(selection.length != 0) { Registers.paste(textArea,'%',false); } Registers.paste(textArea,'e',false); } // Actual macro if(buffer.isReadOnly()) Macros.error(view, "Buffer is read-only."); else Paste_Around() ;