Text Editor Extras

web search addon for Text Editor
This addon adds to the header panel:

  • a button to switch on all colour / syntax / ruler options.

5 new options: (ctrl+I , with selected text in Text Editor)

  • eval selected text (useful for equations, contrived example will replace 244+24+23+4 / 4 with 292.0)
  • search pydocs (works on selected words, searches python.org: try for example tuple )
  • search bpy docs (also works on selected words, requests blender.org for most up to date api docs)
  • search blenderscripting.blogspot (will return the snippets that relate to your search term)
  • search stack overlfow

The search features connect directly to the specified website and spawns a webbrowser, if possible.

1 Like

if you are just learning blender bpy API and python, this is a ridiculously useful addon for the Text Editor.
http://i.imgur.com/ios8z.png

and because i got sick of pressing 4 buttons.

1 Like

Hey, that’s cool! thanks

update, now added stack overflow to the list of engines that can be spawned.
https://github.com/downloads/zeffii/rawr/text_editor_extras_w4searches.rar

(select any text in Text Editor, then hit Ctrl+I and choose the option)

1 Like

I may have asked this before, but is there any way to make CTRL-F actually find automatically? With all other text editors if I have a word selected and press CTRL-F the text editor will search for the selection. In Blender it just opens up the side panel. Then you have to click on the field and type in what you want to search for.

Is there anyway to automate that process so if I have a selected word or phrase and press CTRL-F that the text editor will just populate the search field for me and perform an initial search?

looks promising


bpy.context.space_data.find_text = 'hello'   

currently find is mapped to ctrl+g. I think it makes sense for me to add this to the addon as ctrl+somekey, ideally maybe use opengl to overlay all search matches with a transparency. I’m also looking a ’ replace x with y in selection z ’ ( so a replace isn’t global )

Something like this, assign auto_search to ctrl+somekey (i use F to hide the properties panel)


import bpy

def has_selection(text):
    return not (text.select_end_line == text.current_line and \
    text.current_character == text.select_end_character)

def find_in_current_text(context, search_term):
    context.space_data.find_text = search_term

class SearchCurrentSelection(bpy.types.Operator):
    bl_idname = "scene.auto_search"
    bl_label = "User Auto Search"

    def execute(self, context):

        if has_selection(context.edit_text):
            bpy.ops.text.copy() # get angry!
            search_term = context.window_manager.clipboard
            find_in_current_text(context, search_term)

        return{'FINISHED'}

# map to ctrl K
if True:
    wm = bpy.context.window_manager
    km = wm.keyconfigs.default.keymaps['Text']
    new_shortcut = km.keymap_items.new('scene.auto_search', 'K', 'PRESS', ctrl=True)

def register():
    bpy.utils.register_module(__name__)


def unregister():
    bpy.utils.unregister_module(__name__)

if __name__ == "__main__":
    register()

then ctrl+G to find subsequent

1 Like