Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Thompson <quornian@googlemail.com>2008-08-10 20:07:14 +0400
committerIan Thompson <quornian@googlemail.com>2008-08-10 20:07:14 +0400
commit5dad15441439065cbbe79c54edf0b2bdfab810dc (patch)
tree024fba6021a2728ca74eeea3fbd5472131806ad6 /release
parentfb3a42d0f961bc575e3c56d0ad1c9ea46af4b2ed (diff)
Fixed inconsistencies between the text plugins and them not suggesting when called from the menu.
Diffstat (limited to 'release')
-rw-r--r--release/scripts/textplugin_functiondocs.py10
-rw-r--r--release/scripts/textplugin_imports.py75
-rw-r--r--release/scripts/textplugin_membersuggest.py2
-rw-r--r--release/scripts/textplugin_outliner.py4
-rw-r--r--release/scripts/textplugin_suggest.py16
-rw-r--r--release/scripts/textplugin_templates.py2
6 files changed, 73 insertions, 36 deletions
diff --git a/release/scripts/textplugin_functiondocs.py b/release/scripts/textplugin_functiondocs.py
index 7456f7236da..d9cf6657a25 100644
--- a/release/scripts/textplugin_functiondocs.py
+++ b/release/scripts/textplugin_functiondocs.py
@@ -1,6 +1,6 @@
#!BPY
"""
-Name: 'Function Documentation'
+Name: 'Function Documentation | Ctrl I'
Blender: 246
Group: 'TextPlugin'
Shortcut: 'Ctrl+I'
@@ -29,14 +29,22 @@ def main():
# Look backwards for first '(' without ')'
b = 0
+ found = False
for i in range(c-1, -1, -1):
if line[i] == ')': b += 1
elif line[i] == '(':
b -= 1
if b < 0:
+ found = True
c = i
break
+ # Otherwise identify the name under the cursor
+ if not found:
+ llen = len(line)
+ while c<llen and (line[c].isalnum() or line[c]=='_'):
+ c += 1
+
pre = get_targets(line, c)
if len(pre) == 0:
diff --git a/release/scripts/textplugin_imports.py b/release/scripts/textplugin_imports.py
index 16d27ac1004..0e32a6fb2a6 100644
--- a/release/scripts/textplugin_imports.py
+++ b/release/scripts/textplugin_imports.py
@@ -1,6 +1,6 @@
#!BPY
"""
-Name: 'Import Complete'
+Name: 'Import Complete|Space'
Blender: 246
Group: 'TextPlugin'
Shortcut: 'Space'
@@ -31,41 +31,62 @@ def main():
# No 'from' found
if pos == -1:
- # Check instead for straight 'import'
+ # Check instead for straight 'import xxxx'
pos2 = line.rfind('import ', 0, c)
- if pos2 != -1 and (pos2 == c-7 or (pos2 < c-7 and line[c-2]==',')):
+ if pos2 != -1:
+ pos2 += 7
+ for i in range(pos2, c):
+ if line[i]==',' or (line[i]==' ' and line[i-1]==','):
+ pos2 = i+1
+ elif not line[i].isalnum() and line[i] != '_':
+ return
items = [(m, 'm') for m in get_modules()]
items.sort(cmp = suggest_cmp)
- txt.suggest(items, '')
+ txt.suggest(items, line[pos2:c].strip())
+ return
+
+ # Found 'from xxxxx' before cursor
+ immediate = True
+ pos += 5
+ for i in range(pos, c):
+ if line[i]=='.':
+ pos = i+1
+ elif not line[i].isalnum() and line[i] != '_':
+ immediate = False
+ break
- # Immediate 'from' before cursor
- elif pos == c-5:
+ # Immediate 'from' followed by at most a module name
+ if immediate:
items = [(m, 'm') for m in get_modules()]
items.sort(cmp = suggest_cmp)
txt.suggest(items, '')
+ return
+
+ # Found 'from' earlier, suggest import if not already there
+ pos2 = line.rfind('import ', pos, c)
- # Found 'from' earlier
- else:
- pos2 = line.rfind('import ', pos+5, c)
+ # No 'import' found after 'from' so suggest it
+ if pos2 == -1:
+ txt.suggest([('import', 'k')], '')
+ return
- # No 'import' found after 'from' so suggest it
- if pos2 == -1:
- txt.suggest([('import', 'k')], '')
-
- # Immediate 'import' before cursor and after 'from...'
- elif pos2 == c-7 or line[c-2] == ',':
- between = line[pos+5:pos2-1].strip()
- try:
- mod = get_module(between)
- except ImportError:
- print 'Module not found:', between
- return
-
- items = [('*', 'k')]
- for (k,v) in mod.__dict__.items():
- items.append((k, type_char(v)))
- items.sort(cmp = suggest_cmp)
- txt.suggest(items, '')
+ # Immediate 'import' before cursor and after 'from...'
+ for i in range(pos2+7, c):
+ if line[i]==',' or (line[i]==' ' and line[i-1]==','):
+ pass
+ elif not line[i].isalnum() and line[i] != '_':
+ return
+ between = line[pos:pos2-1].strip()
+ try:
+ mod = get_module(between)
+ except ImportError:
+ return
+
+ items = [('*', 'k')]
+ for (k,v) in mod.__dict__.items():
+ items.append((k, type_char(v)))
+ items.sort(cmp = suggest_cmp)
+ txt.suggest(items, '')
# Check we are running as a script and not imported as a module
if __name__ == "__main__" and OK:
diff --git a/release/scripts/textplugin_membersuggest.py b/release/scripts/textplugin_membersuggest.py
index 63ade4b660b..2b261703e19 100644
--- a/release/scripts/textplugin_membersuggest.py
+++ b/release/scripts/textplugin_membersuggest.py
@@ -1,6 +1,6 @@
#!BPY
"""
-Name: 'Member Suggest'
+Name: 'Member Suggest | .'
Blender: 246
Group: 'TextPlugin'
Shortcut: 'Period'
diff --git a/release/scripts/textplugin_outliner.py b/release/scripts/textplugin_outliner.py
index 0dbdb624dc5..345361b47d4 100644
--- a/release/scripts/textplugin_outliner.py
+++ b/release/scripts/textplugin_outliner.py
@@ -1,6 +1,6 @@
#!BPY
"""
-Name: 'Outline'
+Name: 'Code Outline | Ctrl T'
Blender: 246
Group: 'TextPlugin'
Shortcut: 'Ctrl+T'
@@ -99,7 +99,7 @@ def main():
vars_menu_length = len(tmp)
items.extend(tmp)
- menu = [('Outliner%t', 0),
+ menu = [('Script %t', 0),
('Classes', class_menu),
('Functions', defs_menu),
('Variables', vars_menu)]
diff --git a/release/scripts/textplugin_suggest.py b/release/scripts/textplugin_suggest.py
index c2a12ac15f5..0e83e1e8cc7 100644
--- a/release/scripts/textplugin_suggest.py
+++ b/release/scripts/textplugin_suggest.py
@@ -1,6 +1,6 @@
#!BPY
"""
-Name: 'Suggest All'
+Name: 'Suggest All | Ctrl Space'
Blender: 246
Group: 'TextPlugin'
Shortcut: 'Ctrl+Space'
@@ -21,14 +21,22 @@ def check_membersuggest(line, c):
if pos == -1:
return False
for s in line[pos+1:c]:
- if not s.isalnum() and not s == '_':
+ if not s.isalnum() and s != '_':
return False
return True
def check_imports(line, c):
- if c >= 7 and line.rfind('import ', 0, c) == c-7:
+ pos = line.rfind('import ', 0, c)
+ if pos > -1:
+ for s in line[pos+7:c]:
+ if not s.isalnum() and s != '_':
+ return False
return True
- if c >= 5 and line.rfind('from ', 0, c) == c-5:
+ pos = line.rfind('from ', 0, c)
+ if pos > -1:
+ for s in line[pos+5:c]:
+ if not s.isalnum() and s != '_':
+ return False
return True
return False
diff --git a/release/scripts/textplugin_templates.py b/release/scripts/textplugin_templates.py
index 0cd772f863e..508ede11ddc 100644
--- a/release/scripts/textplugin_templates.py
+++ b/release/scripts/textplugin_templates.py
@@ -1,6 +1,6 @@
#!BPY
"""
-Name: 'Templates'
+Name: 'Template Completion | Tab'
Blender: 246
Group: 'TextPlugin'
Shortcut: 'Tab'