Clear current line in Python Console


I’m looking for a shortcut to clear the current line in the Python Console. In other terminals I just use Ctrl+C, so I was kind of expecting that this would work in Blender as well.

Furthermore, I’d like to be able to use Tab for auto completion. I know, this is a little difficult because Tab is needed for the indentation. But with some smart coding, you should be able to use Tab for both applications (when the Tab key is pressed, just look at the preceding character, I’d say)?

Perhaps someone already wrote some code for this purpose, that I could use? I already compile Blender from source (from SVN).

Edit: I know there are already some topics discussing these things, but I couldn’t find a conclusive solution.

Or perhaps it is possible to somehow connect the actual Python terminal (so open a terminal and type “python”) to Blender? I recall reading something similar to this, I think on this very forum. A person asked whether it would be possible to move the Python console outside of Blender, after which somebody replied that it should be the case but he didn’t remember how.

i coded a patch which empties the current line using Ctrl + Y (sergey’s preference)


//edit: Here’s my own build (r46400) with console patch applied:

Thanks a lot for the effort! Compiling right now (can’t use your build because I’m on Linux).

Edit: it works, excellent addition to the Python Console. Would it be difficult to implement the Tab behaviour as I described in my first post? So:

  • If you’re at the start of a new line, or if the preceding “character” is whitespace, add four spaces (same behaviour as the current Tab)
  • Otherwise (try to) autocomplete