0

hi I am new to jedit and I am trying to install a feature that lets me copy the current line when nothing is selected. I found this macro here http://www.jedit.org/users-guide/macros-clipboard.html under Copy_Selection_or_Line.bsh.

it seems like it is a default macro and I should be able to just use it without installing anything. but I can't find it in the list.

then I tried using the code for this macro here https://github.com/aismail/sedemo2011/blob/master/lib/jason/bin/jedit/macros/Clipboard/Copy_Selection_or_Line.bsh I installed it and I can now enable it, but it doesn't work.

I spent ages trying to get this macro working but it's just not working. anyone able to give me a hand? thanks

Mad Program
  • 129
  • 1
  • 1
  • 9

2 Answers2

0

The Copy_Selection_or_Line.bsh macro was renamed 7 years ago as can bee seen here: https://sourceforge.net/p/jedit/svn/11860. It seems the documentation was not updated accordingly. Would be great if you open a documentation bug here: https://sourceforge.net/p/jedit/bugs/new/ This shipped macro should work without any problems.

What you linked above is the macro as it was before that change I linked. It could well be that some API changed since 7 years ago and that the macro is not usable as is. Is the Copy_Lines.bsh macro doing what you want? If not, it could maybe at least help in updating the old Copy_Selection_or_Line.bsh macro to work with current jEdit.

Vampire
  • 35,631
  • 4
  • 76
  • 102
0

I modified the macro (attached below):

// My Copy_Selection_or_Line.bsh
if (textArea.getSelectionCount() == 0) {
    caretLine = textArea.getCaretLine();
    lineEndOffset = textArea.getLineEndOffset(caretLine);
    textArea.setSelection(new Selection.Range(textArea.getLineStartOffset(caretLine), textArea.getBufferLength() >= lineEndOffset? lineEndOffset : lineEndOffset-1));
}

Registers.copy(textArea,'$');
AhLeung
  • 207
  • 1
  • 5