New Add-on: Console text editing improvements

move cursor under mouse clic and with selections:
so you can insert text everywhere overwrite a selection
same with ctrl x, ctrl v, suppr, backspace
Now an undo Ctrl+Z and a redo shift+ctrl+Z in the console!
add ctrl Q: quick favorite

6 Likes

This is awesome! Why not submit it as a patch to be integrated into master?

2 Likes

I don’t know how to do

https://wiki.blender.org/wiki/Process/Contributing_Code
The change doesn’t seem to be large enough for an add-on, so the source code is at release/scripts/startup/bl_ui/space_console.py & source/blender/editors/space_console/console_ops.c

Upload a patch, keep improving it using arcanist [1] & add a reviewer.
Feel free to ask for help at https://blender.chat

[1] https://wiki.blender.org/wiki/Tools/CodeReview

2 Likes

ok thks I will watch this

I added a Ctrl V to paste over a selection if exists. and same to cut a selection
writing on a selected word is writing at the end of the word where the cursor is, by default.
but I did a script to write over selection too but I can’t do bpy.ops.console.insert(‘INVOKE_DEFAULT’)
in the C file related to console operators they are telling they only considered the situation or the invoke would be called from a key and not from a script. Apparently not a bug but I don’t know where to ask. really accessing this part is like a wall for me

For the record, I just commented out the bpy.ops.console.insert('INVOKE_DEFAULT') lines and replaced the return value with {'PASS_THROUGH'} and it worked.

class CONSOLE_OT_Insert(bpy.types.Operator):
    """insert"""
    bl_idname = "console.easy_insert"
    bl_label = "console easy insert"

    @classmethod
    def poll(cls, context):
        return context.area.type == 'CONSOLE'

    def execute(self, context):

        sc = context.space_data
        st, se = (sc.select_start, sc.select_end)
        if st == se:
            # bpy.ops.console.insert('INVOKE_DEFAULT')
            print("no")    
            pass
        else:
            print("hi")
            for _ in range(se-st):
                bpy.ops.console.move(type='LINE_END')
                for _ in range(st):
                    bpy.ops.console.move(type='PREVIOUS_CHARACTER')
                bpy.ops.console.delete(type='PREVIOUS_CHARACTER')
            sc.select_start = st
            sc.select_end = st
            # bpy.ops.console.insert('INVOKE_DEFAULT')

        return {'PASS_THROUGH'}
1 Like