Update cursor style(block/under-line/vertical-line) doesn't take effect immediately
Here is a script which changes cursor style every 0.2 seconds:
while true ; do for i in 2 4 6 ; do echo -en "\033[${i} q"; sleep 0.2 ; done; done
But the cursor doesn't change at all, unless press any key to trigger update. Tested gnome-terminal, works perfectly
Also, add updateCursor when cursor style changes doesn't pass this test:
while true ; do for i in 2 4 6 ; do echo -en "\033[1C\033[${i} q\033[1D"; sleep 0.2 ; done; done
Which move cursor forward then change style, then move backward.
@yan12125 - is this really a bug?
Why not ? When you press insert key, you expect that the cursor changes immediately, not after you press any other key.
is this really a bug?
Yes IMO
I also would expect the cursor to update immediately - the referenced commit here fixes it for me but I don't see a pull request for it?
It does not fix the second case. Still good to apply it first.
Note to myself: reopen this issue if the PR closes it.
This issue still is open as of git version Jan 8, 2020.
It seems that the root cause of the problem is that cursorPosition() sometimes is wrong...
Please try this patch.
diff --git a/lib/TerminalDisplay.cpp b/lib/TerminalDisplay.cpp
index 79fd16b..d06a565 100644
--- a/lib/TerminalDisplay.cpp
+++ b/lib/TerminalDisplay.cpp
@@ -20,6 +20,7 @@
02110-1301 USA.
*/
+#include <stdio.h>
// Own
#include "TerminalDisplay.h"
@@ -1728,6 +1729,11 @@ void TerminalDisplay::updateCursor()
{
QRect cursorRect = imageToWidget( QRect(cursorPosition(),QSize(1,1)) );
update(cursorRect);
+#if 1
+ const QPoint cp = cursorPosition();
+ printf("updateCursor x=%d y=%d\n", cp.x(), cp.y());
+ update(); // update all
+#endif
}
void TerminalDisplay::blinkCursorEvent()