Recent

Author Topic: stop cursor blinking  (Read 1246 times)

dbannon

  • Hero Member
  • *****
  • Posts: 1044
    • tomboy-ng, a rewrite of the classic Tomboy
stop cursor blinking
« on: April 01, 2020, 12:23:50 am »

This is a pretty unusual one IMHO. I have an end user who needs to turn off the blink that the cursor normally does.  He/she apparently has some secret trick to do just that on the Mac but it does not work with the Lazarus application.  I am using KMemo but I believe the 'problem' is any text entry field.

Anyone know how to disable the cursor blink, or maybe make it less obtrusive ?

Says this person -
I have neuro issues, and can't see near the blinking cursors, and can get migraines from them.

It must be real problem, I would like to help if I can ....

Davo
Lazarus 2, Linux (and reluctantly Win10, OSX)
My Project - https://github.com/tomboy-notes/tomboy-ng

440bx

  • Hero Member
  • *****
  • Posts: 1827
Re: stop cursor blinking
« Reply #1 on: April 01, 2020, 01:15:51 am »
On Windows, that's normally done using the control panel by controlling the cursor blink rate. 

Control Panel -> keyboard -> Cursor Blink Rate -> None.

Of course, the setting is global but it seems your user would probably like that.

HTH.

ETA: I don't know if other O/Ses offer that option but, they might.
« Last Edit: April 01, 2020, 01:17:48 am by 440bx »
FPC v3.0.4 and Lazarus 1.8.2 on Windows 7 64bit.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 6290
    • wiki
Re: stop cursor blinking
« Reply #2 on: April 01, 2020, 02:30:04 pm »
You mean the cursor in the source editor? Or cursor in edit fields of the object inspector, or option dialogs?

The latter (usually one line edit fields) should be controlled by the OS.

The one in the Source editor (SynEdit) is not entirely. And that may largely depend on the Widgetset (I assume you want help for MacOS? )

(not tested....) For the source editor, if all else fails:
- Open components\synedit\syneditpointclasses.pas
- line approx 2633 procedure TSynEditScreenCaretTimer.SetInterval(AValue: Integer);
- Start the function with "AValue := 0;"
- Recompile the IDE
- In the IDE: menu: Tools > Option > Editor > Color: find caret, and change the color to any color, away from default (e.g. a very very light grey)

That should stop the source editor.

Zoran

  • Hero Member
  • *****
  • Posts: 1558
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: stop cursor blinking
« Reply #3 on: April 01, 2020, 04:34:04 pm »
You mean the cursor in the source editor? Or cursor in edit fields of the object inspector, or option dialogs?

No, he is obviously interested in end-user's experience.
See:
I have an end user who needs to turn off the blink that the cursor normally does.

Davo, if your application uses synedit, then I believe that you can try with Martin's advices for Source editor -- change in sources what Martin mentions, then, instead of recompiling the ide, compile your application and try it on your user's computer.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 6290
    • wiki
Re: stop cursor blinking
« Reply #4 on: April 01, 2020, 05:10:52 pm »
Davo, if your application uses synedit, then I believe that you can try with Martin's advices for Source editor -- change in sources what Martin mentions, then, instead of recompiling the ide, compile your application and try it on your user's computer.
Then you also need to replace the "Tools > Option > Editor > Color:...". Let me know, and I find where to set this in code.

valdir.marcos

  • Hero Member
  • *****
  • Posts: 986
Re: stop cursor blinking
« Reply #5 on: April 02, 2020, 03:16:28 am »
This is a pretty unusual one IMHO. I have an end user who needs to turn off the blink that the cursor normally does.  He/she apparently has some secret trick to do just that on the Mac but it does not work with the Lazarus application.  I am using KMemo but I believe the 'problem' is any text entry field.

Anyone know how to disable the cursor blink, or maybe make it less obtrusive ?

Says this person -
I have neuro issues, and can't see near the blinking cursors, and can get migraines from them.

It must be real problem, I would like to help if I can ....

Davo
On Windows, that's normally done using the control panel by controlling the cursor blink rate.

Control Panel -> keyboard -> Cursor Blink Rate -> None.

Of course, the setting is global but it seems your user would probably like that.

HTH.

ETA: I don't know if other O/Ses offer that option but, they might.
You mean the cursor in the source editor? Or cursor in edit fields of the object inspector, or option dialogs?
No, he is obviously interested in end-user's experience.
See:
I have an end user who needs to turn off the blink that the cursor normally does.

Davo, if your application uses synedit, then I believe that you can try with Martin's advices for Source editor -- change in sources what Martin mentions, then, instead of recompiling the ide, compile your application and try it on your user's computer.
Talking about OSes, there are settings for that somewhere:
How do I disable the blinking cursor in gnome-terminal?
https://askubuntu.com/questions/49606/how-do-i-disable-the-blinking-cursor-in-gnome-terminal

dbannon

  • Hero Member
  • *****
  • Posts: 1044
    • tomboy-ng, a rewrite of the classic Tomboy
Re: stop cursor blinking
« Reply #6 on: April 02, 2020, 11:45:48 am »
Thanks for this input folks.  Yes, its in an application made with Lazarus rather than in Lazarus itself.

I am afraid my need is to deal with the cursor in KMemo, not synedit.  But if its possible in synedit, maybe its also possible in KMemo ?   Lot of source there to troll through but maybe ....

And while nice to know, doing it in Windows or GTK does not help either, this user is a Mac person. Sigh ...

Thanks folks !
Lazarus 2, Linux (and reluctantly Win10, OSX)
My Project - https://github.com/tomboy-notes/tomboy-ng

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 6290
    • wiki
Re: stop cursor blinking
« Reply #7 on: April 02, 2020, 11:55:45 am »
I had a quick look at the kmemo sources at github. It uses SetCaretPosEx.

On Windows that is a system call. On some other OS, the LCL (the widgetset part) emulates this.

Not tested / Just searched through sources.....
On cocoa, search for TEmulatedCaret in  lcl/interfaces/cocoa/cocoacaret.pas
It probably has a TTimer.

On Carbon, no idea => follow SetCaretEx in in  lcl/interfaces/carbon/*

If Mac allows to set the blink-rate/behaviour, then maybe there should be a feature request, to check if the LCL can obey those settings.

valdir.marcos

  • Hero Member
  • *****
  • Posts: 986
Re: stop cursor blinking
« Reply #8 on: April 02, 2020, 06:42:15 pm »
Thanks for this input folks.  Yes, its in an application made with Lazarus rather than in Lazarus itself.
I am afraid my need is to deal with the cursor in KMemo, not synedit.  But if its possible in synedit, maybe its also possible in KMemo ?   Lot of source there to troll through but maybe ....
And while nice to know, doing it in Windows or GTK does not help either, this user is a Mac person. Sigh ...
Thanks folks !
I had a quick look at the kmemo sources at github. It uses SetCaretPosEx.

On Windows that is a system call. On some other OS, the LCL (the widgetset part) emulates this.

Not tested / Just searched through sources.....
On cocoa, search for TEmulatedCaret in  lcl/interfaces/cocoa/cocoacaret.pas
It probably has a TTimer.

On Carbon, no idea => follow SetCaretEx in in  lcl/interfaces/carbon/*

If Mac allows to set the blink-rate/behaviour, then maybe there should be a feature request, to check if the LCL can obey those settings.
Some other alternatives and ideas:

Google: mac osx cocoa disable blinking cursor
https://bugs.documentfoundation.org/show_bug.cgi?id=100706
https://superuser.com/questions/466660/how-to-disable-blinking-caret-when-editing-text-in-os-x

Google: mac osx carbon disable blinking cursor
https://answers.microsoft.com/en-us/msoffice/forum/all/mac-disable-blinking-cursor-word-2016/21c3c392-9bb7-4f46-8b15-0d3f4ee530c1
https://answers.microsoft.com/en-us/mac/forum/macoffice2011-macword/why-does-the-blinking-i-beam-cursor-keep/10870d8e-dd13-40be-8bc2-b6230b5a0602?page=5&tab=question&status=AllReplies
https://superuser.com/questions/466660/how-to-disable-blinking-caret-when-editing-text-in-os-x
https://bugs.eclipse.org/bugs/show_bug.cgi?id=301282
https://discussions.apple.com/thread/6990400
https://macosx.com/threads/how-to-turn-off-cursor-blink.318919/
https://www.defaults-write.com/change-os-x-text-cursor-blink-rate/

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 6290
    • wiki
Re: stop cursor blinking
« Reply #9 on: April 02, 2020, 06:51:34 pm »
Some other alternatives and ideas:

The problem is that KMemo is custom drawn.

Under Windows, the app can tell the OS to paint the caret anywhere on the screen (inside the apps window). So under Window SetCaretPosEx tells the OS to draw a caret for KMemo.

Under Cocoa (and likely Carbon) SetCaretPosEx is emulated in the LCL-widgetset code. There is a timer, and the LCL paints (and un-paints) the caret.
So unless the LCL can be fixed to query the system settings, disabling for the System, does not affect the LCL.

Mind, that a TEdit is entirely drawn by the OS, content and caret. So a TEdit will follow the rules. The issue only exists for custom draw.

valdir.marcos

  • Hero Member
  • *****
  • Posts: 986
Re: stop cursor blinking
« Reply #10 on: April 02, 2020, 07:07:02 pm »
Some other alternatives and ideas:
The problem is that KMemo is custom drawn.

Under Windows, the app can tell the OS to paint the caret anywhere on the screen (inside the apps window). So under Window SetCaretPosEx tells the OS to draw a caret for KMemo.

Under Cocoa (and likely Carbon) SetCaretPosEx is emulated in the LCL-widgetset code. There is a timer, and the LCL paints (and un-paints) the caret.
So unless the LCL can be fixed to query the system settings, disabling for the System, does not affect the LCL.

Mind, that a TEdit is entirely drawn by the OS, content and caret. So a TEdit will follow the rules. The issue only exists for custom draw.
Now, I got it.
I am sorry.
Thanks.

dbannon

  • Hero Member
  • *****
  • Posts: 1044
    • tomboy-ng, a rewrite of the classic Tomboy
Re: stop cursor blinking
« Reply #11 on: April 03, 2020, 02:41:19 pm »
http://www.macissues.com/2014/12/08/how-to-change-your-macs-text-cursor-blink-rate/

Documents the blink control on the mac. But it says
"....Also note that this will only work for applications and text fields that are coded with Apple’s text view coding objects, so programs that use alternative text handling routines may not show a difference in blink rate."

Some digging ....

Davo
Lazarus 2, Linux (and reluctantly Win10, OSX)
My Project - https://github.com/tomboy-notes/tomboy-ng

PascalDragon

  • Hero Member
  • *****
  • Posts: 1523
  • Compiler Developer
Re: stop cursor blinking
« Reply #12 on: April 04, 2020, 11:19:15 am »
This fix in Eclipse shows how to query these defaults. What's needed is the NSUserDefaults class with the message standardUserDefaults (it's already used in the LCL for the scrollbars). Then as mentioned in the link by dbannon for 10.8 and older you query for NSTextInsertionPointBlinkPeriod and for 10.9 and newer for both NSTextInsertionPointBlinkPeriodOn and NSTextInsertionPointBlinkPeriodOff (though that might require some adjustments so that cursors can handle different on and off periods).

 

TinyPortal © 2005-2018