Nessesarius / mintty

Automatically exported from code.google.com/p/mintty
GNU General Public License v3.0
0 stars 0 forks source link

Changing cursor colour when IME is on #206

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
It would be very useful to change cursor color when IME is on/off.
I hope this feature would be implemented.

A patch for putty-0.6 is as follows:
(maybe to be applied to win_proc() for mintty)

+ case WM_IME_NOTIFY :  /* IME_Notify_Message */
+     if(wParam == IMN_SETOPENSTATUS) {
+         hImc = ImmGetContext(hwnd);
+         if(hImc) {
+             BOOL bIMEOpen = ImmGetOpenStatus(hImc);
+             if(bIMEOpen) {
+                 /* default cursor color setting */
+                 defCursorPal[0] = defpal[261].rgbtRed;
+                 defCursorPal[1] = defpal[261].rgbtGreen;
+                 defCursorPal[2] = defpal[261].rgbtBlue;
+
+                 /* IME_ON cursor color setting */
+                 defpal[261].rgbtRed = defpal[262].rgbtRed;
+                 defpal[261].rgbtGreen = defpal[262].rgbtGreen;
+                 defpal[261].rgbtBlue = defpal[262].rgbtBlue;
+
+                 init_palette();
+                 InvalidateRect(hwnd,NULL,FALSE);
+                 UpdateWindow(hwnd);
+             } else {
+                 /* IME_OFF cursor color setting */
+                 defpal[261].rgbtRed = defCursorPal[0];
+                 defpal[261].rgbtGreen = defCursorPal[1];
+                 defpal[261].rgbtBlue = defCursorPal[2];
+
+                 init_palette();
+                 InvalidateRect(hwnd,NULL,FALSE);
+                 UpdateWindow(hwnd);
+             }
+         }
+     }
+     break ;

Thanks.

Original issue reported on code.google.com by yoshihik...@gmail.com on 29 Jul 2010 at 4:05

GoogleCodeExporter commented 8 years ago
Please explain why this would be useful. Screenshots of PuTTY with and without 
the change would probably help with that. Also, would all IME users want this, 
or is it a question of personal preference?

Has the patch been submitted to PuTTY developers? Is there a PuTTY derivative 
that includes it?

Btw, the patch seems to be incomplete, as there is no array called defCursorPal 
in PuTTY. It would certainly need to be adapted for mintty, because colour 
handling has changed somewhat.

Original comment by andy.koppe on 29 Jul 2010 at 6:54

GoogleCodeExporter commented 8 years ago
> Please explain why this would be useful.

Editing with IME is mode-dependent like vim. IME needs to be OFF to input ascii 
characters, and ON to input CJK characters. The current IME mode can be 
recognized by the IME task bar which is usually swallowed in the Windows task 
tray. But, it would be very useful to recognize IME mode by cursor color. 
Therefore, I think many IME users want this. This is common feature of Japanese 
text editor as far as I know.

> Has the patch been submitted to PuTTY developers?

I don't know that the patch has been submitted to original putty.

> Is there a PuTTY derivative that includes it?

Yes, followings are the private patched version of putty.
(sorry, these pages are in Japanese)
http://ice.hotmint.com/putty/
http://d.hatena.ne.jp/guyon/200803251206456001/

> Btw, the patch seems to be incomplete, as there is no array called
> defCursorPal in PuTTY. It would certainly need to be adapted for mintty,
> because colour handling has changed somewhat.

Yes, the main process for recognizing IME on/off seems to be handling of
the WM_IME_NOTIFY message. The colour setting would be adapted.

Original comment by yoshihik...@gmail.com on 31 Jul 2010 at 3:51

GoogleCodeExporter commented 8 years ago
Thank you very much for the explanation. The links are rather interesting too 
(with the help of Google Translate).

I've seen vim support for IME-dependent cursor colour, have you got other 
examples, particularly native Windows programs?

I see the hotmint PuTTY version adds entries to the list of colours in the 
options dialog. Of course mintty no longer has that list, hence I'd probably 
just add colour index 262 for the IME cursor, which would need to be set 
through an escape sequence, and then think about an easier UI for this if 
there's more demand.

Original comment by andy.koppe on 3 Aug 2010 at 6:01

GoogleCodeExporter commented 8 years ago
Certainly, gvim has already supported IME-dependent cursor colour.
Followings are other examples.

sakura editor (Japanese text editor)
http://sakura-editor.sourceforge.net/

teraterm (terminal emulator)
http://ttssh2.sourceforge.jp/index.html.en

xyzzy (emacs like text editor)
http://www.jsdlab.co.jp/~kamei/

Hope this helps.
Thanks.

Original comment by yoshihik...@gmail.com on 3 Aug 2010 at 4:14

GoogleCodeExporter commented 8 years ago
Implemented in 996 on trunk.

Configure the colour using the 'IMECursorColour' setting in .minttyrc, e.g.:

IMECursorColour=255,0,0

Or using the OSC 4 colour setting control sequence with colour number 262:

echo -ne '\e]4;262;#FF0000\a'

Original comment by andy.koppe on 27 Aug 2010 at 9:17

GoogleCodeExporter commented 8 years ago

Original comment by andy.koppe on 2 Sep 2010 at 6:20

GoogleCodeExporter commented 8 years ago

Original comment by andy.koppe on 3 Oct 2010 at 3:41

GoogleCodeExporter commented 8 years ago
This doesn't seem to work under Windows 8. IMECursorColour=255,0,0 is set in 
~/.minttyrc

Original comment by xue...@gmail.com on 6 Jun 2015 at 4:41