[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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章