[wingide-users] duplicate current line extension

Richard D. Moores rdmoores at gmail.com
Mon Dec 28 16:01:23 MST 2009


#duplicate_line.py

import wingapi

def duplicate_line(app=wingapi.kArgApplication):
 """Duplicate the current line on the line that follows it"""

 editor = app.GetActiveEditor()
 doc = editor.GetDocument()
 start, end = editor.GetSelection()

 start_lineno = doc.GetLineNumberFromPosition(start)

 line_start = doc.GetLineStart(start_lineno)
 line_end = doc.GetLineEnd(start_lineno)
 line = doc.GetCharRange(line_start, line_end)

 doc.InsertChars(line_end, editor.GetEol() + line)

##################################

I put the above in the Scripts folder as duplicate_line.py, and assigned the
key binding  Alt-Equal , duplicate-line .  After reloading all scripts, I
find the message,

Error::Failed to load duplicate_line from
C:\PROGRA~2\WINGID~1.2\scripts\duplicate_line.py:
Runtime failure details:
Exception: "<type 'exceptions.NameError'>"
Value = "name 'duplicate_line' is not defined"
Traceback:
  File "C:\src\ide\bin\2.5\src\scripting\cap_scriptmgr.pyo", line 716, in
_ProcessScriptModule
  File "C:\PROGRA~2\WINGID~1.2\scripts\duplicate_line.py", line 1, in
<module>
    duplicate_line.py

######################################

I don't know how to correct this. Please advise.

Thanks,

Dick Moores
Vista, SP2 64-bit
Win IDE 3.2.3-1 (rev 21238)

On Mon, Dec 28, 2009 at 10:31, Wingware Support <support at wingware.com>wrote:

> Larry Eitel wrote:
>
>> I am new to wingide.
>>
>> Is there an extension around for duplicating the current line without
>> using the clipboard buffer?
>>
>
> Here's an implementation:
>
> def duplicate_line(app=wingapi.kArgApplication):
>  """Duplicate the current line on the line that follows it"""
>
>  editor = app.GetActiveEditor()
>  doc = editor.GetDocument()
>  start, end = editor.GetSelection()
>
>  start_lineno = doc.GetLineNumberFromPosition(start)
>
>  line_start = doc.GetLineStart(start_lineno)
>  line_end = doc.GetLineEnd(start_lineno)
>  line = doc.GetCharRange(line_start, line_end)
>
>  doc.InsertChars(line_end, editor.GetEol() + line)
>
> --
>
> Stephan Deibel
> Wingware | Python IDE
> Advancing Software Development
>
> www.wingware.com
>
> _________________________________________________
> Wing IDE users list
> http://wingware.com/lists/wingide
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: /pipermail/wingide-users/attachments/20091228/97533029/attachment.html


More information about the wingide-users mailing list