[UliPad]wxSnip in UliPad

Thanks Kibleur C. (http://kib2.webfactional.com/) for his wxSnip package, and I'v ported it into UliPad, you can get the lastest code from svn (http://cvs.woodpecker.org.cn/svn/woodpecker/ulipad/trunk). But wxSnip is not very suit for UliPad, because UliPad has its own InputAssistant functionality, so I changed wxSnip code and made it more suitable for UliPad. The source file in UliPad is named mixins/SnipMixin.py. And I made a SnipMixin class, it receives a `editor` argument, and not like in wxSnipEdit.py it's  SnipEditor. So I can merge this class into my own StyledTextCtrl object. And I also don't need the adding template string process, because InputAssistant functionality can do this, but I indeed fixed the indent bug when adding template string according wxSnipEdit. And I trigger the process of snippet field outside the SnipMixin class, so I bind the key_down event in my own editor class but not in SnipEditor class. So there are two method which I need to call:

start(self, tpl, start, end)

this function will be invoked after adding template string, and it comes from insertSnippet() method of SnipEditor, and it'll auto invoke the nextField() method.

nextField(self, pos)

this function will be invoked after you pressing the trigger keystroke Ctrl+] now.

And the snippet template is defined in a ACP(Auto Completion Pattern) file, you can find in conf folder of UliPad. Each syntax has such a file, such as Python.acp. For now, I made some example in python.acp, you can see:

[autore]
(^\s*)def<space> = \\1def ${1:method_name}(${2:}):\n\t'''${3:}'''\n\t${0}
(^\s*)cdef<space> = \\1def ${1:method_name}(self, ${2:}):\n\t'''${3:}'''\n\t${0}

The acp file is a ini-like file. If the value is quoted by double-quoter("), then it's just like a python string. If there is not, it just like a raw string. Notice, if there is a ',' in the string, you should quote it by double-quoter, just like:

"ab,cd"

If you don't quote it, it'll be treate as a list. So you'll see a popup list when the pattern is matched. And for keys, there are some special character representations just like: <space> (' '), <equal> ('='), <div> ('/'), <square> ('['), etc

1163158.aspx
limodou?i=4DkZUDxC limodou?i=rNkGtMwx limodou?i=KG0qObjG
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值