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?
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()