2009/3/1 Bram Moolenaar <[email protected]>: > > Dominique Pelle wrote: > >> >> > John Little wrote: >> >> > >> >> >> On Feb 28, 6:53am, Kenneth Reid Beesley wrote: >> >> >> >> >> >>> But :help lCursor =A0returned no information. >> >> >> >> >> >> BTW, You could have tried >> >> >> >> >> >> :helpgrep lCursor >> >> >> >> >> >> Regards, John >> >> > >> >> > Yes, ":helpgrep lCursor" gives a few hints. But still, >> >> > lCursor deserves a tag I think to make ":help lCursor" >> >> > work. I did not know about lCursor until today, it's useful. >> >> > >> >> > I wonder whether this is a bug though: >> >> > >> >> > $ gvim -u NONE -U NONE >> >> > >> >> > :hi Cursor guibg=3D#ff0000 =A0 =A0 =A0" red cursor >> >> > :hi lCursor guibg=3D#00ff00 =A0 =A0 " green cursor when keymap activat= >> ed >> >> > >> >> > :set imcursor? >> >> > iminsert=3D2 =A0 =A0 =A0" OK, expected >> >> > >> >> > :set keymap=3Desperanto =A0" or any other keymap >> >> > :set iminsert? >> >> > iminsert=3D1 =A0 =A0 =A0" OK, expected >> >> > >> >> > :set keymap=3D >> >> > :set iminsert? >> >> > iminsert=3D1 =A0 =A0 =A0" Hmmm, shouldn't this be back to 2??? >> >> > >> >> > lCursor is nice so that cursor color changes aspect when a >> >> > keymap is being activated. But if I cancel the keymap with >> >> > ":set keymap=3D" then cursor remains in the same color >> >> > (green, lCursor) as if there was still a keymap activated. >> >> > It seems to me that the cursor should then become red >> >> > (Cursor). I can work around with ":set imcursor=3D2" which >> >> > puts back the cursor in red (Cursor). >> >> > >> >> > In ":help iminsert" I see: >> >> > >> >> > =A0 =A0Specifies whether :lmap or an Input Method (IM) is to be used i= >> n >> >> > =A0 =A0Insert mode. Valid values: >> >> > =A0 =A0 =A0 =A00 =A0 =A0:lmap is off and IM is off >> >> > =A0 =A0 =A0 =A01 =A0 =A0:lmap is ON and IM is off >> >> > =A0 =A0 =A0 =A02 =A0 =A0:lmap is off and IM is ON >> >> > >> >> > I'm using vim-7.2.127 (huge), GUI GTK2 on Linux x86. >> >> > >> >> > -- Dominique >> >> >> >> >> >> Attached patch fixes the problem I described in my previous >> >> email: it makes the cursor go back to normal color (Cursor >> >> instead of lCursor) when cancelling keymaps with ":set keymap=3D". >> >> >> >> Please review it since I must admit I don't fully understand >> >> how 'iminsert' and 'imsearch' are supposed to work... >> > >> > Does this have any real effect? =A0If 'iminsert' is set to use lmap's >> > (value is 1), but there are none, it works the same way as setting >> > 'iminsert' off (value 0), right? >> >> >> I'm not 100% sure I understand the question. If 'iminsert' is value 1, >> then cursor has color "lCursor" regardless of whether there are keymaps >> or not. >> >> Problem happens in gVim only since lCursor only matters in GUI. > > OK, so this is just about the cursor color. I thought the intention was > to fix something else. > >> The following test case illustrates the problem: >> >> $ gvim -u NONE -U NONE >> >> :hi Cursor guibg=#ff0000 " red cursor >> :hi lCursor guibg=#00ff00 " green cursor when keymap activated >> >> :set keymap=esperanto " or any other keymap >> >> :" type something in INSERT mode (Cursor should be green) >> icxgx<Esc> >> >> :" disable keymaps >> :set keymap= >> >> :" type something in INSERT mode again. >> :" Observe that cursor is still green (I would expect it to be red) >> icxgx<Esc> >> >> With proposed patch, the cursor is read (as I'd expect) >> in INSERT mode after disabling keymaps with ":set keymap=" >> >> Without patch, the workaround to have proper cursor color >> when disabling keymaps is to do... >> >> :set iminsert=0 imsearch=0 keymap= > > The alternative would be to have the cursor color also take into account > if any keymappings are defined. But that's getting complicated. > > I think the code should check that 'iminsert' and 'imsearch' are > actually at the B_IMODE_LMAP value. Otherwise this doesn't work: > > :set iminsert=2 keymap= > > New patch: > > > *** ../vim-7.2.128/src/option.c Sat Feb 21 20:27:00 2009 > --- src/option.c Sun Mar 1 23:15:21 2009 > *************** > *** 5797,5810 **** > /* load or unload key mapping tables */ > errmsg = keymap_init(); > > ! /* When successfully installed a new keymap switch on using it. */ > ! if (*curbuf->b_p_keymap != NUL && errmsg == NULL) > { > ! curbuf->b_p_iminsert = B_IMODE_LMAP; > ! if (curbuf->b_p_imsearch != B_IMODE_USE_INSERT) > ! curbuf->b_p_imsearch = B_IMODE_LMAP; > ! set_iminsert_global(); > ! set_imsearch_global(); > # ifdef FEAT_WINDOWS > status_redraw_curbuf(); > # endif > --- 5797,5824 ---- > /* load or unload key mapping tables */ > errmsg = keymap_init(); > > ! if (errmsg == NULL) > { > ! if (*curbuf->b_p_keymap != NUL) > ! { > ! /* Installed a new keymap, switch on using it. */ > ! curbuf->b_p_iminsert = B_IMODE_LMAP; > ! if (curbuf->b_p_imsearch != B_IMODE_USE_INSERT) > ! curbuf->b_p_imsearch = B_IMODE_LMAP; > ! } > ! else > ! { > ! /* Cleared the keyamp, may reset 'iminsert' and 'imsearch'. */ > ! if (curbuf->b_p_iminsert == B_IMODE_LMAP) > ! curbuf->b_p_iminsert = B_IMODE_NONE; > ! if (curbuf->b_p_imsearch == B_IMODE_LMAP) > ! curbuf->b_p_imsearch = B_IMODE_USE_INSERT; > ! } > ! if ((opt_flags & OPT_LOCAL) == 0) > ! { > ! set_iminsert_global(); > ! set_imsearch_global(); > ! } > # ifdef FEAT_WINDOWS > status_redraw_curbuf(); > # endif >
I tried the proposed patch. It looks OK. Just a minor typo to report in the comment: keyamp -> keymap Thanks! -- Dominique --~--~---------~--~----~------------~-------~--~----~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~----------~----~----~----~------~----~------~--~---
