"""
Copy_Selection_or_Line.py - A Jython macro for jEdit that
is an enhanced version of the built-in `copy` action. If no
text is selection the current line is copied to the clipboard,
otherwise the default copy behavior is used.

Copyright(2002) Ollie Rutherfurd <oliver@rutherfurd.net>

$Id: Copy_Selection_or_Line.py 51 2003-07-23 20:48:53Z oliver $
"""

from org.gjt.sp.jedit import Registers

def copySelectionOrLine(textArea):

    # if nothing selected, select current line
    if len(textArea.getSelection()) == 0:
        textArea.smartHome(0)
        textArea.smartEnd(1)

    Registers.copy(textArea,'$');


if __name__ in ('__main__','main'):
    copySelectionOrLine(init.textArea)

# :indentSize=4:lineSeparator=\n:noTabs=true:tabSize=4:
