Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 48 additions & 46 deletions text_editor_tools/api_navigator.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
Expand All @@ -19,11 +19,11 @@
#
# ***** END GPL LICENCE BLOCK *****

# bl_info = {
#bl_info = {
# "name": "API Navigator",
# "author": "Dany Lebel (Axon_D)",
# "version": (1, 0, 2),
# "blender": (2, 57, 0),
# "blender": (2, 80, 0),
# "location": "Text Editor > Properties > API Navigator Panel",
# "description": "Allows exploration of the python api via the user interface",
# "warning": "",
Expand Down Expand Up @@ -124,7 +124,7 @@ def evaluate(module):

def get_tree_level():
# print('get_tree_level')
prefs = bpy.context.user_preferences.addons['weed'].preferences
prefs = bpy.context.preferences.addons['weed'].preferences
path = prefs.anp_path

def object_list():
Expand Down Expand Up @@ -193,7 +193,7 @@ def parent(path):
def update_filter():
"""Update the filter according to the current path"""
global filter_mem
prefs = bpy.context.user_preferences.addons['weed'].preferences
prefs = bpy.context.preferences.addons['weed'].preferences

try:
prefs.anp_filter = filter_mem[prefs.anp_path]
Expand All @@ -217,7 +217,7 @@ def isiterable(mod):

def fill_filter_mem():
global filter_mem
prefs = bpy.context.user_preferences.addons['weed'].preferences
prefs = bpy.context.preferences.addons['weed'].preferences

filter = prefs.anp_filter
if filter:
Expand All @@ -235,7 +235,7 @@ class ApiNavigator():
def generate_global_values():
"""Populate the level attributes to display the panel buttons and the documentation"""
global tree_level, current_module, module_type, return_report, last_text
prefs = bpy.context.user_preferences.addons['weed'].preferences
prefs = bpy.context.preferences.addons['weed'].preferences

try:
text = bpy.context.space_data.text
Expand Down Expand Up @@ -268,7 +268,7 @@ def generate_global_values():
def generate_api_doc():
"""Format the doc string for API Navigator"""
global current_module, api_doc_, return_report, module_type
prefs = bpy.context.user_preferences.addons['weed'].preferences
prefs = bpy.context.preferences.addons['weed'].preferences
path = prefs.anp_path
doc = current_module.__doc__

Expand All @@ -281,7 +281,7 @@ def generate_api_doc():


def api_update(context):
prefs = bpy.context.user_preferences.addons['weed'].preferences
prefs = bpy.context.preferences.addons['weed'].preferences
if prefs.anp_path != prefs.anp_old_path:
fill_filter_mem()
prefs.anp_old_path = prefs.anp_path
Expand All @@ -306,7 +306,7 @@ class BackToBpy(ApiNavigator, bpy.types.Operator):

def execute(self, context):
fill_filter_mem()
prefs = bpy.context.user_preferences.addons['weed'].preferences
prefs = bpy.context.preferences.addons['weed'].preferences

if not prefs.anp_path:
prefs.anp_old_path = prefs.anp_path = 'bpy'
Expand All @@ -321,11 +321,11 @@ class Down(ApiNavigator, bpy.types.Operator):
"""go to this Module"""
bl_idname = "weed.api_navigator_down"
bl_label = "API Navigator Down"
pointed_module = bpy.props.StringProperty(name='Current Module', default='')
pointed_module: bpy.props.StringProperty(name='Current Module', default='')

def execute(self, context):
fill_filter_mem()
prefs = bpy.context.user_preferences.addons['weed'].preferences
prefs = bpy.context.preferences.addons['weed'].preferences

if not prefs.anp_path:
prefs.anp_old_path = prefs.anp_path = prefs.anp_path + self.pointed_module
Expand All @@ -343,7 +343,7 @@ class Parent(ApiNavigator, bpy.types.Operator):
bl_label = "API Navigator Parent"

def execute(self, context):
prefs = bpy.context.user_preferences.addons['weed'].preferences
prefs = bpy.context.preferences.addons['weed'].preferences
path = prefs.anp_path

if path:
Expand All @@ -358,23 +358,24 @@ class Subscript(ApiNavigator, bpy.types.Operator):
"""Subscript to this Item"""
bl_idname = "weed.api_navigator_subscript"
bl_label = "API Navigator Subscript"
subscription = bpy.props.StringProperty(name='', default='')
subscription: bpy.props.StringProperty(name='', default='')

def execute(self, context):
fill_filter_mem()
prefs = bpy.context.user_preferences.addons['weed'].preferences
prefs = bpy.context.preferences.addons['weed'].preferences
prefs.anp_old_path = prefs.anp_path = prefs.anp_path + '[' + self.subscription + ']'
update_filter()
self.generate_global_values()
return {'FINISHED'}


class ClearFilter(ApiNavigator, bpy.types.Operator):
"""Clear the filter"""
bl_idname = 'weed.api_navigator_clear_filter'
bl_label = 'API Nav clear filter'

def execute(self, context):
prefs = bpy.context.user_preferences.addons['weed'].preferences
prefs = bpy.context.preferences.addons['weed'].preferences
prefs.anp_filter = ''
return {'FINISHED'}

Expand All @@ -392,12 +393,12 @@ class SelectModule(ApiNavigator, bpy.types.Menu):
emboss=True).subscription = '\"' + obj + '\"'",
1 : "col.operator('weed.api_navigator_subscript', text=str(obj)[:30],\
emboss=True).subscription = str(i)",
8 : "col.label(obj[:30])"
8 : "col.label(text=obj[:30])"
}

def draw(self, context):
global tree_level, current_module, module_type, return_report
prefs = bpy.context.user_preferences.addons['weed'].preferences
prefs = bpy.context.preferences.addons['weed'].preferences
layout = self.layout
text_filter = prefs.anp_filter
split = layout.split()
Expand All @@ -423,7 +424,7 @@ class PopupApiNavigator(ApiNavigator, bpy.types.Operator):
bl_options = {'REGISTER', 'UNDO'}

def __init__(self):
prefs = bpy.context.user_preferences.addons['weed'].preferences
prefs = bpy.context.preferences.addons['weed'].preferences
modules_types = [
(0, "Items", "DOTSDOWN"),
(1, "Item Values", "DOTSDOWN"),
Expand All @@ -443,22 +444,21 @@ def __init__(self):
module.icon = icon



def draw(self, context):
global tree_level, current_module, module_type, return_report, api_doc_
prefs = bpy.context.user_preferences.addons['weed'].preferences
prefs = bpy.context.preferences.addons['weed'].preferences

layout = self.layout
box = layout.box()
split = box.split(percentage=0.7)
split = box.split(factor=0.7)
split.prop(prefs, 'anp_path', text='', icon='OOPS')
row = split.row(align=True)
row.operator('weed.api_navigator_parent',
text='parent', icon='FILE_PARENT')
row.operator('weed.api_navigator_back_to_bpy',
text='back to bpy', icon='BACK')

split = box.split(percentage=0.85)
split = box.split(factor=0.85)
row = split.row(align=True)
for module in prefs.submodules:
if tree_level[module.level].__len__():
Expand All @@ -473,9 +473,9 @@ def draw(self, context):
col = layout.column(align=True)
try:
for line in api_doc_.splitlines():
col.label(line)
col.label(text=line)
except:
col.label('Empty:::')
col.label(text='Empty:::')

def check(self, context):
return True
Expand All @@ -488,29 +488,31 @@ def invoke(self, context, event):
return context.window_manager.invoke_props_dialog(self, width=700)


# registro automatico de modulos.
## registro automatico de modulos.

#def register():
# bpy.utils.register_class(Update)
# bpy.utils.register_class(BackToBpy)
# bpy.utils.register_class(Down)
# bpy.utils.register_class(Parent)
# bpy.utils.register_class(Subscript)
# bpy.utils.register_class(ClearFilter)
# bpy.utils.register_class(SelectModule)
# bpy.utils.register_class(PopupApiNavigator)

# def register():
# bpy.utils.register_class(Update)
# bpy.utils.register_class(BackToBpy)
# bpy.utils.register_class(Down)
# bpy.utils.register_class(Parent)
# bpy.utils.register_class(Subscript)
# bpy.utils.register_class(ClearFilter)
# bpy.utils.register_class(SelectModule)
# bpy.utils.register_class(PopupApiNavigator)

#def unregister():
# bpy.utils.unregister_class(PopupApiNavigator)
# bpy.utils.unregister_class(SelectModule)
# bpy.utils.unregister_class(ClearFilter)
# bpy.utils.unregister_class(Subscript)
# bpy.utils.unregister_class(Parent)
# bpy.utils.unregister_class(Down)
# bpy.utils.unregister_class(BackToBpy)
# bpy.utils.unregister_class(Update)

# def unregister():
# bpy.utils.unregister_class(PopupApiNavigator)
# bpy.utils.unregister_class(SelectModule)
# bpy.utils.unregister_class(ClearFilter)
# bpy.utils.unregister_class(Subscript)
# bpy.utils.unregister_class(Parent)
# bpy.utils.unregister_class(Down)
# bpy.utils.unregister_class(BackToBpy)
# bpy.utils.unregister_class(Update)

#if __name__ == '__main__':
# register()

# if __name__ == '__main__':
# register()
##unregister()
4 changes: 2 additions & 2 deletions text_editor_tools/code_editor.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# ##### BEGIN GPL LICENSE BLOCK #####
# ###### BEGIN GPL LICENSE BLOCK ######
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
Expand All @@ -14,7 +14,7 @@
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ##### END GPL LICENSE BLOCK #####
# ###### END GPL LICENSE BLOCK ######

# bl_info = {
# "name": "Code Editor",
Expand Down
3 changes: 2 additions & 1 deletion text_editor_tools/code_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ def draw_code_tree_box(self, context, layout):
col = layout.column(align=False)
row = col.row(align=False)
row.prop(get_addon_preferences(), 'user_site_packages',
icon = 'RECOVER_AUTO', text = '')
icon = 'RECOVER_LAST', text = '')
selector = row.row(align=True)
selector.prop(context.scene, 'explorer_root_folder', text='')
selector.operator('weed.open_addon_menu',
Expand Down Expand Up @@ -77,3 +77,4 @@ def execute(self, context):

# def unregister():
# bpy.utils.unregister_class(WEED_OT_ViewCodeTree)

68 changes: 34 additions & 34 deletions text_editor_tools/find_replace.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import bpy


class PopupFindReplace(bpy.types.Operator):
bl_idname = 'weed.popup_find_replace'
bl_label = 'Popup Find and Replace'
bl_description = 'popup with Find and Replace'
bl_description = 'Pop-up with Find and Replace'
bl_options = {'REGISTER', 'UNDO'}

# Needed hack for repeat operator
find_hack = bpy.props.BoolProperty(default=False)
replace_hack = bpy.props.BoolProperty(default=False)
find_hack: bpy.props.BoolProperty(default=False)
replace_hack: bpy.props.BoolProperty(default=False)

# set_selected_hack = bpy.props.BoolProperty(default = False)
# set_selected_hack: bpy.props.BoolProperty(default = False)
@classmethod
def poll(cls, context):
return context.area.type == 'TEXT_EDITOR'
Expand Down Expand Up @@ -67,41 +68,40 @@ def invoke(self, context, event):
return context.window_manager.invoke_props_popup(self, event)


# def register_keymaps():
# kc = bpy.context.window_manager.keyconfigs
# if kc.addon:
# km = kc.addon.keymaps.new(name='Text', space_type='TEXT_EDITOR')
# km.keymap_items.new('weed.popup_find_replace',
#def register_keymaps():
# kc = bpy.context.window_manager.keyconfigs
# if kc.addon:
# km = kc.addon.keymaps.new(name='Text', space_type='TEXT_EDITOR')
# km.keymap_items.new('weed.popup_find_replace',
# 'F', 'PRESS', ctrl=True, shift=True)
# # km.keymap_items.new('weed.popup_find_replace', 'H', 'PRESS', ctrl=True)
# # dkm = kc.default.keymaps['Text Generic']
# # dkm.keymap_items['text.start_find'].active = False
# # dkm.keymap_items['text.replace'].active = False

# # km.keymap_items.new('weed.popup_find_replace', 'H', 'PRESS', ctrl=True)
# # dkm = kc.default.keymaps['Text Generic']
# # dkm.keymap_items['text.start_find'].active = False
# # dkm.keymap_items['text.replace'].active = False

# def unregister_keymaps():
# kc = bpy.context.window_manager.keyconfigs
# if kc.addon:
# km = kc.addon.keymaps['Text']
# kmi = km.keymap_items['weed.popup_find_replace']
# km.keymap_items.remove(kmi)
# # kmi = km.keymap_items['weed.popup_replace']
# # km.keymap_items.remove(kmi)
# # dkm = kc.default.keymaps['Text Generic']
# # dkm.keymap_items['text.start_find'].active = True
# # dkm.keymap_items['text.replace'].active = True

#def unregister_keymaps():
# kc = bpy.context.window_manager.keyconfigs
# if kc.addon:
# km = kc.addon.keymaps['Text']
# kmi = km.keymap_items['weed.popup_find_replace']
# km.keymap_items.remove(kmi)
# # kmi = km.keymap_items['weed.popup_replace']
# # km.keymap_items.remove(kmi)
# # dkm = kc.default.keymaps['Text Generic']
# # dkm.keymap_items['text.start_find'].active = True
# # dkm.keymap_items['text.replace'].active = True

# def register():
# bpy.utils.register_class(PopupFindReplace)
# register_keymaps()
#def register():
# bpy.utils.register_class(PopupFindReplace)
# register_keymaps()


# def unregister():
# bpy.utils.unregister_class(PopupFindReplace)
# unregister_keymaps()
#def unregister():
# bpy.utils.unregister_class(PopupFindReplace)
# unregister_keymaps()


# if __name__ == '__main__':
# # unregister()
# register()
#if __name__ == '__main__':
# # unregister()
# register()
Loading