qtermwidget icon indicating copy to clipboard operation
qtermwidget copied to clipboard

Update cursor style(block/under-line/vertical-line) doesn't take effect immediately

Open kghost opened this issue 8 years ago • 7 comments

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.

kghost avatar Dec 29 '17 15:12 kghost

@yan12125 - is this really a bug?

agaida avatar Sep 22 '18 22:09 agaida

Why not ? When you press insert key, you expect that the cursor changes immediately, not after you press any other key.

kghost avatar Sep 27 '18 11:09 kghost

is this really a bug?

Yes IMO

yan12125 avatar Sep 28 '18 06:09 yan12125

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?

DonnieWest avatar Oct 07 '18 16:10 DonnieWest

It does not fix the second case. Still good to apply it first.

yan12125 avatar Oct 08 '18 01:10 yan12125

Note to myself: reopen this issue if the PR closes it.

yan12125 avatar Oct 08 '18 01:10 yan12125

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

markus-oberhumer-forks avatar Jan 07 '20 23:01 markus-oberhumer-forks