2008-06-24 15:25:25 +00:00
|
|
|
#!BPY
|
|
|
|
"""
|
2008-07-15 07:34:46 +00:00
|
|
|
Name: 'Suggest All'
|
|
|
|
Blender: 246
|
2008-06-24 15:25:25 +00:00
|
|
|
Group: 'TextPlugin'
|
2008-07-15 07:04:31 +00:00
|
|
|
Shortcut: 'Ctrl+Space'
|
2008-07-15 07:34:46 +00:00
|
|
|
Tooltip: 'Performs suggestions based on the context of the cursor'
|
2008-06-24 15:25:25 +00:00
|
|
|
"""
|
|
|
|
|
2008-07-15 07:34:46 +00:00
|
|
|
# Only run if we have the required modules
|
|
|
|
try:
|
|
|
|
import bpy
|
|
|
|
from BPyTextPlugin import *
|
|
|
|
OK = True
|
|
|
|
except:
|
|
|
|
OK = False
|
2008-06-24 15:25:25 +00:00
|
|
|
|
2008-07-15 07:34:46 +00:00
|
|
|
def main():
|
|
|
|
txt = bpy.data.texts.active
|
|
|
|
(line, c) = current_line(txt)
|
2008-06-24 15:25:25 +00:00
|
|
|
|
2008-07-15 07:34:46 +00:00
|
|
|
# Check we are in a normal context
|
|
|
|
if get_context(line, c) != NORMAL:
|
|
|
|
return
|
2008-06-24 15:25:25 +00:00
|
|
|
|
2008-07-15 07:34:46 +00:00
|
|
|
# Check that which precedes the cursor and perform the following:
|
|
|
|
# Period(.) - Run textplugin_membersuggest.py
|
|
|
|
# 'import' or 'from' - Run textplugin_imports.py
|
|
|
|
# Other - Continue this script (global suggest)
|
|
|
|
pre = get_targets(line, c)
|
2008-06-24 15:25:25 +00:00
|
|
|
|
2008-07-15 07:34:46 +00:00
|
|
|
count = len(pre)
|
2008-06-24 15:25:25 +00:00
|
|
|
|
2008-07-15 07:34:46 +00:00
|
|
|
if count > 1: # Period found
|
|
|
|
import textplugin_membersuggest
|
|
|
|
textplugin_membersuggest.main()
|
|
|
|
return
|
|
|
|
# Look for 'import' or 'from'
|
|
|
|
elif line.rfind('import ', 0, c) == c-7 or line.rfind('from ', 0, c) == c-5:
|
|
|
|
import textplugin_imports
|
|
|
|
textplugin_imports.main()
|
|
|
|
return
|
2008-06-24 15:25:25 +00:00
|
|
|
|
2008-07-15 07:34:46 +00:00
|
|
|
list = []
|
2008-06-24 15:25:25 +00:00
|
|
|
|
2008-07-15 07:34:46 +00:00
|
|
|
for k in KEYWORDS:
|
|
|
|
list.append((k, 'k'))
|
2008-06-24 15:25:25 +00:00
|
|
|
|
2008-07-15 07:34:46 +00:00
|
|
|
for k, v in get_builtins().items():
|
|
|
|
list.append((k, type_char(v)))
|
2008-06-24 15:25:25 +00:00
|
|
|
|
2008-07-15 07:34:46 +00:00
|
|
|
for k, v in get_imports(txt).items():
|
|
|
|
list.append((k, type_char(v)))
|
2008-06-24 15:25:25 +00:00
|
|
|
|
2008-07-15 07:34:46 +00:00
|
|
|
for k, v in get_defs(txt).items():
|
|
|
|
list.append((k, 'f'))
|
2008-06-25 13:51:54 +00:00
|
|
|
|
2008-07-15 07:34:46 +00:00
|
|
|
list.sort(cmp = suggest_cmp)
|
|
|
|
txt.suggest(list, pre[-1])
|
2008-06-24 15:25:25 +00:00
|
|
|
|
2008-07-15 07:34:46 +00:00
|
|
|
if OK:
|
|
|
|
main()
|