Skip to content

Commit

Permalink
add w[idget] popup surpport
Browse files Browse the repository at this point in the history
  • Loading branch information
yang qianjun committed Oct 20, 2014
1 parent 0c36f62 commit 27a3447
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,19 @@ Sublime Avalon Completion Package

可以通过设置Avalon语法字典或者直接修改helper.txt文件来添加更多语法支持

-------
how to use

2014.10.17 - 修复多次换行缩进 bug
1,git clone code to sublime 3/data/packages/AvalonHelper

2,ms召唤出属性绑定,组件名字可以召唤出组件自动完成,data召唤出data绑定,data-组件名字召唤出组件属性自动完成(暂时未提供组件属性、接口等字典)

3,helper.txt第一行是ms绑定,第二行是组件名字(组件名字+"="意味这个替换字符串是ms-组件名字=""),第三行是data绑定


-------
time line

2014.10.17 - 修复多次换行缩进 bug

2014.10.20 - 添加 w[idget] 召唤出组件列表功能
15 changes: 12 additions & 3 deletions avalonHelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,21 +58,21 @@ def on_load():
widgetList[loop] = v
specialList.append(v)
loop = loop + 1
_widgetList.append((v + "\tWidget", widget_place(v, True)))
_widgetList.append(("widget " + v + "\t组件", widget_place(v, True)))
for v in msAttrList:
_msAttrList.append((v + "\tbind", "" + v + "=\"${1:}\""))
for v in dataAttrList:
_dataAttrList.append((v + "\tbind", "" + v + "=\"${1:}\""))

def create_select(view, _from, to):
pass

# define parttens
msLike = re.compile(r"^ms")
msWidget = re.compile(r"^ms\-w[^\s\"\']+")
dataLike = re.compile(r"^d(ata\-)?")
blankLike= re.compile(r"[\s\"\']+")
indexLike= re.compile(r"^[^<\s\n]+\s")
# add ms-widget partten
widgetLike = re.compile(r"^w[idget]")

class AvalonHelperCompletionsPackageEventListener(sublime_plugin.EventListener):

Expand All @@ -81,10 +81,19 @@ def on_query_completions(self, view, prefix, locations):
self.view = view
indent = self.get_indent(len(prefix))
if select.empty():
if widgetLike.match(prefix):
if not indent:
return _widgetList
_list = []
for i,v in _widgetList:
_list.append((i, indent + v))
return _list;
if prefix in widgetList:
replacer = widget_place(prefix, True, indent)
return [(prefix + "\tWidget", replacer)]
if prefix == "m" or msLike.match(prefix):
if not indent:
return _msAttrList
_list = []
for i,v in _msAttrList:
_list.append((i, indent + v ))
Expand Down

0 comments on commit 27a3447

Please sign in to comment.