BUG: Fix cursor position during auto-complete
BUG: Fix cursor position during auto-complete

When error messages were printed during auto-complete, the error messages got mixed up with the entered command.

Fixed by inserting text into the correct position (this->textCursor()  was called twice in ctkConsolePrivate::printString() and so the movePosition() call had no effect); also changed the code to use this->textCursor() consistently to get the cursor (sometimes the equivalent `QTextCursor c(this->document())` call was used)

Also fixed output printing: always print pending messages before displaying the prompt.

see https://github.com/Slicer/Slicer/issues/6630

commontk/CTK,commontk/CTK,commontk/CTK,commontk/CTK