Mercurial > vim
comparison src/edit.c @ 13380:69517d67421f v8.0.1564
patch 8.0.1564: too many #ifdefs
commit https://github.com/vim/vim/commit/f2bd8ef2b4507d02c6043affff8f7e85e3414d5f
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Mar 4 18:08:14 2018 +0100
patch 8.0.1564: too many #ifdefs
Problem: Too many #ifdefs.
Solution: Graduate the +autocmd feature. Takes away 450 #ifdefs and
increases code size of tiny Vim by only 40 Kbyte.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 04 Mar 2018 18:15:08 +0100 |
parents | ac42c4b11dbc |
children | 6740c499de13 |
comparison
equal
deleted
inserted
replaced
13379:0f9dd1b43244 | 13380:69517d67421f |
---|---|
271 static int ins_ctrl_ey(int tc); | 271 static int ins_ctrl_ey(int tc); |
272 #ifdef FEAT_SMARTINDENT | 272 #ifdef FEAT_SMARTINDENT |
273 static void ins_try_si(int c); | 273 static void ins_try_si(int c); |
274 #endif | 274 #endif |
275 static colnr_T get_nolist_virtcol(void); | 275 static colnr_T get_nolist_virtcol(void); |
276 #ifdef FEAT_AUTOCMD | 276 #if defined(FEAT_EVAL) |
277 static char_u *do_insert_char_pre(int c); | 277 static char_u *do_insert_char_pre(int c); |
278 #endif | 278 #endif |
279 | 279 |
280 static colnr_T Insstart_textlen; /* length of line when insert started */ | 280 static colnr_T Insstart_textlen; /* length of line when insert started */ |
281 static colnr_T Insstart_blank_vcol; /* vcol for first inserted blank */ | 281 static colnr_T Insstart_blank_vcol; /* vcol for first inserted blank */ |
386 return FALSE; | 386 return FALSE; |
387 } | 387 } |
388 ins_compl_clear(); /* clear stuff for CTRL-X mode */ | 388 ins_compl_clear(); /* clear stuff for CTRL-X mode */ |
389 #endif | 389 #endif |
390 | 390 |
391 #ifdef FEAT_AUTOCMD | |
392 /* | 391 /* |
393 * Trigger InsertEnter autocommands. Do not do this for "r<CR>" or "grx". | 392 * Trigger InsertEnter autocommands. Do not do this for "r<CR>" or "grx". |
394 */ | 393 */ |
395 if (cmdchar != 'r' && cmdchar != 'v') | 394 if (cmdchar != 'r' && cmdchar != 'v') |
396 { | 395 { |
397 pos_T save_cursor = curwin->w_cursor; | 396 pos_T save_cursor = curwin->w_cursor; |
398 | 397 |
399 # ifdef FEAT_EVAL | 398 #ifdef FEAT_EVAL |
400 if (cmdchar == 'R') | 399 if (cmdchar == 'R') |
401 ptr = (char_u *)"r"; | 400 ptr = (char_u *)"r"; |
402 else if (cmdchar == 'V') | 401 else if (cmdchar == 'V') |
403 ptr = (char_u *)"v"; | 402 ptr = (char_u *)"v"; |
404 else | 403 else |
405 ptr = (char_u *)"i"; | 404 ptr = (char_u *)"i"; |
406 set_vim_var_string(VV_INSERTMODE, ptr, 1); | 405 set_vim_var_string(VV_INSERTMODE, ptr, 1); |
407 set_vim_var_string(VV_CHAR, NULL, -1); /* clear v:char */ | 406 set_vim_var_string(VV_CHAR, NULL, -1); /* clear v:char */ |
408 # endif | 407 #endif |
409 apply_autocmds(EVENT_INSERTENTER, NULL, NULL, FALSE, curbuf); | 408 apply_autocmds(EVENT_INSERTENTER, NULL, NULL, FALSE, curbuf); |
410 | 409 |
411 /* Make sure the cursor didn't move. Do call check_cursor_col() in | 410 /* Make sure the cursor didn't move. Do call check_cursor_col() in |
412 * case the text was modified. Since Insert mode was not started yet | 411 * case the text was modified. Since Insert mode was not started yet |
413 * a call to check_cursor_col() may move the cursor, especially with | 412 * a call to check_cursor_col() may move the cursor, especially with |
414 * the "A" command, thus set State to avoid that. Also check that the | 413 * the "A" command, thus set State to avoid that. Also check that the |
415 * line number is still valid (lines may have been deleted). | 414 * line number is still valid (lines may have been deleted). |
416 * Do not restore if v:char was set to a non-empty string. */ | 415 * Do not restore if v:char was set to a non-empty string. */ |
417 if (!EQUAL_POS(curwin->w_cursor, save_cursor) | 416 if (!EQUAL_POS(curwin->w_cursor, save_cursor) |
418 # ifdef FEAT_EVAL | 417 #ifdef FEAT_EVAL |
419 && *get_vim_var_str(VV_CHAR) == NUL | 418 && *get_vim_var_str(VV_CHAR) == NUL |
420 # endif | 419 #endif |
421 && save_cursor.lnum <= curbuf->b_ml.ml_line_count) | 420 && save_cursor.lnum <= curbuf->b_ml.ml_line_count) |
422 { | 421 { |
423 int save_state = State; | 422 int save_state = State; |
424 | 423 |
425 curwin->w_cursor = save_cursor; | 424 curwin->w_cursor = save_cursor; |
426 State = INSERT; | 425 State = INSERT; |
427 check_cursor_col(); | 426 check_cursor_col(); |
428 State = save_state; | 427 State = save_state; |
429 } | 428 } |
430 } | 429 } |
431 #endif | |
432 | 430 |
433 #ifdef FEAT_CONCEAL | 431 #ifdef FEAT_CONCEAL |
434 /* Check if the cursor line needs redrawing before changing State. If | 432 /* Check if the cursor line needs redrawing before changing State. If |
435 * 'concealcursor' is "n" it needs to be redrawn without concealing. */ | 433 * 'concealcursor' is "n" it needs to be redrawn without concealing. */ |
436 conceal_check_cursur_line(); | 434 conceal_check_cursur_line(); |
519 * 'iminsert' value may not reflect what is actually used. It is updated | 517 * 'iminsert' value may not reflect what is actually used. It is updated |
520 * when hitting <Esc>. | 518 * when hitting <Esc>. |
521 */ | 519 */ |
522 if (curbuf->b_p_iminsert == B_IMODE_LMAP) | 520 if (curbuf->b_p_iminsert == B_IMODE_LMAP) |
523 State |= LANGMAP; | 521 State |= LANGMAP; |
524 #ifdef FEAT_MBYTE | 522 #ifdef HAVE_INPUT_METHOD |
525 im_set_active(curbuf->b_p_iminsert == B_IMODE_IM); | 523 im_set_active(curbuf->b_p_iminsert == B_IMODE_IM); |
526 #endif | 524 #endif |
527 | 525 |
528 #ifdef FEAT_MOUSE | 526 #ifdef FEAT_MOUSE |
529 setmouse(); | 527 setmouse(); |
803 do | 801 do |
804 { | 802 { |
805 c = safe_vgetc(); | 803 c = safe_vgetc(); |
806 } while (c == K_IGNORE || c == K_NOP); | 804 } while (c == K_IGNORE || c == K_NOP); |
807 | 805 |
808 #ifdef FEAT_AUTOCMD | |
809 /* Don't want K_CURSORHOLD for the second key, e.g., after CTRL-V. */ | 806 /* Don't want K_CURSORHOLD for the second key, e.g., after CTRL-V. */ |
810 did_cursorhold = TRUE; | 807 did_cursorhold = TRUE; |
811 #endif | |
812 | 808 |
813 #ifdef FEAT_RIGHTLEFT | 809 #ifdef FEAT_RIGHTLEFT |
814 if (p_hkmap && KeyTyped) | 810 if (p_hkmap && KeyTyped) |
815 c = hkmap(c); /* Hebrew mode mapping */ | 811 c = hkmap(c); /* Hebrew mode mapping */ |
816 #endif | 812 #endif |
854 | 850 |
855 /* A non-white character that fits in with the current | 851 /* A non-white character that fits in with the current |
856 * completion: Add to "compl_leader". */ | 852 * completion: Add to "compl_leader". */ |
857 if (ins_compl_accept_char(c)) | 853 if (ins_compl_accept_char(c)) |
858 { | 854 { |
859 #ifdef FEAT_AUTOCMD | 855 #if defined(FEAT_EVAL) |
860 /* Trigger InsertCharPre. */ | 856 /* Trigger InsertCharPre. */ |
861 char_u *str = do_insert_char_pre(c); | 857 char_u *str = do_insert_char_pre(c); |
862 char_u *p; | 858 char_u *p; |
863 | 859 |
864 if (str != NULL) | 860 if (str != NULL) |
1028 if (ins_at_eol && gchar_cursor() == NUL) | 1024 if (ins_at_eol && gchar_cursor() == NUL) |
1029 o_lnum = curwin->w_cursor.lnum; | 1025 o_lnum = curwin->w_cursor.lnum; |
1030 | 1026 |
1031 if (ins_esc(&count, cmdchar, nomove)) | 1027 if (ins_esc(&count, cmdchar, nomove)) |
1032 { | 1028 { |
1033 #ifdef FEAT_AUTOCMD | |
1034 if (cmdchar != 'r' && cmdchar != 'v') | 1029 if (cmdchar != 'r' && cmdchar != 'v') |
1035 apply_autocmds(EVENT_INSERTLEAVE, NULL, NULL, | 1030 apply_autocmds(EVENT_INSERTLEAVE, NULL, NULL, |
1036 FALSE, curbuf); | 1031 FALSE, curbuf); |
1037 did_cursorhold = FALSE; | 1032 did_cursorhold = FALSE; |
1038 #endif | |
1039 return (c == Ctrl_O); | 1033 return (c == Ctrl_O); |
1040 } | 1034 } |
1041 continue; | 1035 continue; |
1042 | 1036 |
1043 case Ctrl_Z: /* suspend when 'insertmode' set */ | 1037 case Ctrl_Z: /* suspend when 'insertmode' set */ |
1232 #endif | 1226 #endif |
1233 | 1227 |
1234 case K_IGNORE: /* Something mapped to nothing */ | 1228 case K_IGNORE: /* Something mapped to nothing */ |
1235 break; | 1229 break; |
1236 | 1230 |
1237 #ifdef FEAT_AUTOCMD | |
1238 case K_CURSORHOLD: /* Didn't type something for a while. */ | 1231 case K_CURSORHOLD: /* Didn't type something for a while. */ |
1239 apply_autocmds(EVENT_CURSORHOLDI, NULL, NULL, FALSE, curbuf); | 1232 apply_autocmds(EVENT_CURSORHOLDI, NULL, NULL, FALSE, curbuf); |
1240 did_cursorhold = TRUE; | 1233 did_cursorhold = TRUE; |
1241 break; | 1234 break; |
1242 #endif | |
1243 | 1235 |
1244 #ifdef FEAT_GUI_W32 | 1236 #ifdef FEAT_GUI_W32 |
1245 /* On Win32 ignore <M-F4>, we get it when closing the window was | 1237 /* On Win32 ignore <M-F4>, we get it when closing the window was |
1246 * cancelled. */ | 1238 * cancelled. */ |
1247 case K_F4: | 1239 case K_F4: |
1486 | 1478 |
1487 normalchar: | 1479 normalchar: |
1488 /* | 1480 /* |
1489 * Insert a normal character. | 1481 * Insert a normal character. |
1490 */ | 1482 */ |
1491 #ifdef FEAT_AUTOCMD | 1483 #if defined(FEAT_EVAL) |
1492 if (!p_paste) | 1484 if (!p_paste) |
1493 { | 1485 { |
1494 /* Trigger InsertCharPre. */ | 1486 /* Trigger InsertCharPre. */ |
1495 char_u *str = do_insert_char_pre(c); | 1487 char_u *str = do_insert_char_pre(c); |
1496 char_u *p; | 1488 char_u *p; |
1563 foldOpenCursor(); | 1555 foldOpenCursor(); |
1564 #endif | 1556 #endif |
1565 break; | 1557 break; |
1566 } /* end of switch (c) */ | 1558 } /* end of switch (c) */ |
1567 | 1559 |
1568 #ifdef FEAT_AUTOCMD | |
1569 /* If typed something may trigger CursorHoldI again. */ | 1560 /* If typed something may trigger CursorHoldI again. */ |
1570 if (c != K_CURSORHOLD | 1561 if (c != K_CURSORHOLD |
1571 # ifdef FEAT_COMPL_FUNC | 1562 #ifdef FEAT_COMPL_FUNC |
1572 /* but not in CTRL-X mode, a script can't restore the state */ | 1563 /* but not in CTRL-X mode, a script can't restore the state */ |
1573 && ctrl_x_mode == CTRL_X_NORMAL | 1564 && ctrl_x_mode == CTRL_X_NORMAL |
1574 # endif | 1565 #endif |
1575 ) | 1566 ) |
1576 did_cursorhold = FALSE; | 1567 did_cursorhold = FALSE; |
1577 #endif | |
1578 | 1568 |
1579 /* If the cursor was moved we didn't just insert a space */ | 1569 /* If the cursor was moved we didn't just insert a space */ |
1580 if (arrow_used) | 1570 if (arrow_used) |
1581 inserted_space = FALSE; | 1571 inserted_space = FALSE; |
1582 | 1572 |
1622 #endif | 1612 #endif |
1623 | 1613 |
1624 if (char_avail()) | 1614 if (char_avail()) |
1625 return; | 1615 return; |
1626 | 1616 |
1627 #if defined(FEAT_AUTOCMD) || defined(FEAT_CONCEAL) | 1617 #if defined(FEAT_CONCEAL) |
1628 /* Trigger CursorMoved if the cursor moved. Not when the popup menu is | 1618 /* Trigger CursorMoved if the cursor moved. Not when the popup menu is |
1629 * visible, the command might delete it. */ | 1619 * visible, the command might delete it. */ |
1630 if (ready && ( | 1620 if (ready && (has_cursormovedI() |
1631 # ifdef FEAT_AUTOCMD | 1621 # if defined(FEAT_CONCEAL) |
1632 has_cursormovedI() | 1622 || curwin->w_p_cole > 0 |
1633 # endif | |
1634 # if defined(FEAT_AUTOCMD) && defined(FEAT_CONCEAL) | |
1635 || | |
1636 # endif | |
1637 # ifdef FEAT_CONCEAL | |
1638 curwin->w_p_cole > 0 | |
1639 # endif | 1623 # endif |
1640 ) | 1624 ) |
1641 # ifdef FEAT_AUTOCMD | 1625 && !EQUAL_POS(last_cursormoved, curwin->w_cursor) |
1642 && !EQUAL_POS(last_cursormoved, curwin->w_cursor) | |
1643 # endif | |
1644 # ifdef FEAT_INS_EXPAND | 1626 # ifdef FEAT_INS_EXPAND |
1645 && !pum_visible() | 1627 && !pum_visible() |
1646 # endif | 1628 # endif |
1647 ) | 1629 ) |
1648 { | 1630 { |
1649 # ifdef FEAT_SYN_HL | 1631 # ifdef FEAT_SYN_HL |
1650 /* Need to update the screen first, to make sure syntax | 1632 /* Need to update the screen first, to make sure syntax |
1652 * a "(". The autocommand may also require a redraw, so it's done | 1634 * a "(". The autocommand may also require a redraw, so it's done |
1653 * again below, unfortunately. */ | 1635 * again below, unfortunately. */ |
1654 if (syntax_present(curwin) && must_redraw) | 1636 if (syntax_present(curwin) && must_redraw) |
1655 update_screen(0); | 1637 update_screen(0); |
1656 # endif | 1638 # endif |
1657 # ifdef FEAT_AUTOCMD | |
1658 if (has_cursormovedI()) | 1639 if (has_cursormovedI()) |
1659 { | 1640 { |
1660 /* Make sure curswant is correct, an autocommand may call | 1641 /* Make sure curswant is correct, an autocommand may call |
1661 * getcurpos(). */ | 1642 * getcurpos(). */ |
1662 update_curswant(); | 1643 update_curswant(); |
1663 apply_autocmds(EVENT_CURSORMOVEDI, NULL, NULL, FALSE, curbuf); | 1644 apply_autocmds(EVENT_CURSORMOVEDI, NULL, NULL, FALSE, curbuf); |
1664 } | 1645 } |
1665 # endif | |
1666 # ifdef FEAT_CONCEAL | 1646 # ifdef FEAT_CONCEAL |
1667 if (curwin->w_p_cole > 0) | 1647 if (curwin->w_p_cole > 0) |
1668 { | 1648 { |
1669 # ifdef FEAT_AUTOCMD | |
1670 conceal_old_cursor_line = last_cursormoved.lnum; | 1649 conceal_old_cursor_line = last_cursormoved.lnum; |
1671 # endif | |
1672 conceal_new_cursor_line = curwin->w_cursor.lnum; | 1650 conceal_new_cursor_line = curwin->w_cursor.lnum; |
1673 conceal_update_lines = TRUE; | 1651 conceal_update_lines = TRUE; |
1674 } | 1652 } |
1675 # endif | 1653 # endif |
1676 # ifdef FEAT_AUTOCMD | |
1677 last_cursormoved = curwin->w_cursor; | 1654 last_cursormoved = curwin->w_cursor; |
1678 # endif | 1655 } |
1679 } | 1656 #endif |
1680 #endif | 1657 |
1681 | |
1682 #ifdef FEAT_AUTOCMD | |
1683 /* Trigger TextChangedI if b_changedtick differs. */ | 1658 /* Trigger TextChangedI if b_changedtick differs. */ |
1684 if (ready && has_textchangedI() | 1659 if (ready && has_textchangedI() |
1685 && curbuf->b_last_changedtick != CHANGEDTICK(curbuf) | 1660 && curbuf->b_last_changedtick != CHANGEDTICK(curbuf) |
1686 # ifdef FEAT_INS_EXPAND | 1661 #ifdef FEAT_INS_EXPAND |
1687 && !pum_visible() | 1662 && !pum_visible() |
1688 # endif | 1663 #endif |
1689 ) | 1664 ) |
1690 { | 1665 { |
1691 apply_autocmds(EVENT_TEXTCHANGEDI, NULL, NULL, FALSE, curbuf); | 1666 apply_autocmds(EVENT_TEXTCHANGEDI, NULL, NULL, FALSE, curbuf); |
1692 curbuf->b_last_changedtick = CHANGEDTICK(curbuf); | 1667 curbuf->b_last_changedtick = CHANGEDTICK(curbuf); |
1693 } | 1668 } |
1694 | 1669 |
1695 # ifdef FEAT_INS_EXPAND | 1670 #ifdef FEAT_INS_EXPAND |
1696 /* Trigger TextChangedP if b_changedtick differs. When the popupmenu closes | 1671 /* Trigger TextChangedP if b_changedtick differs. When the popupmenu closes |
1697 * TextChangedI will need to trigger for backwards compatibility, thus use | 1672 * TextChangedI will need to trigger for backwards compatibility, thus use |
1698 * different b_last_changedtick* variables. */ | 1673 * different b_last_changedtick* variables. */ |
1699 if (ready && has_textchangedP() | 1674 if (ready && has_textchangedP() |
1700 && curbuf->b_last_changedtick_pum != CHANGEDTICK(curbuf) | 1675 && curbuf->b_last_changedtick_pum != CHANGEDTICK(curbuf) |
1701 && pum_visible()) | 1676 && pum_visible()) |
1702 { | 1677 { |
1703 apply_autocmds(EVENT_TEXTCHANGEDP, NULL, NULL, FALSE, curbuf); | 1678 apply_autocmds(EVENT_TEXTCHANGEDP, NULL, NULL, FALSE, curbuf); |
1704 curbuf->b_last_changedtick_pum = CHANGEDTICK(curbuf); | 1679 curbuf->b_last_changedtick_pum = CHANGEDTICK(curbuf); |
1705 } | 1680 } |
1706 # endif | |
1707 #endif | 1681 #endif |
1708 | 1682 |
1709 if (must_redraw) | 1683 if (must_redraw) |
1710 update_screen(0); | 1684 update_screen(0); |
1711 else if (clear_cmdline || redraw_cmdline) | 1685 else if (clear_cmdline || redraw_cmdline) |
3999 * Indent now if a key was typed that is in 'cinkeys'. | 3973 * Indent now if a key was typed that is in 'cinkeys'. |
4000 */ | 3974 */ |
4001 if (want_cindent && in_cinkeys(KEY_COMPLETE, ' ', inindent(0))) | 3975 if (want_cindent && in_cinkeys(KEY_COMPLETE, ' ', inindent(0))) |
4002 do_c_expr_indent(); | 3976 do_c_expr_indent(); |
4003 #endif | 3977 #endif |
4004 #ifdef FEAT_AUTOCMD | |
4005 /* Trigger the CompleteDone event to give scripts a chance to act | 3978 /* Trigger the CompleteDone event to give scripts a chance to act |
4006 * upon the completion. */ | 3979 * upon the completion. */ |
4007 apply_autocmds(EVENT_COMPLETEDONE, NULL, NULL, FALSE, curbuf); | 3980 apply_autocmds(EVENT_COMPLETEDONE, NULL, NULL, FALSE, curbuf); |
4008 #endif | 3981 } |
4009 } | 3982 } |
4010 } | |
4011 #ifdef FEAT_AUTOCMD | |
4012 else if (ctrl_x_mode == CTRL_X_LOCAL_MSG) | 3983 else if (ctrl_x_mode == CTRL_X_LOCAL_MSG) |
4013 /* Trigger the CompleteDone event to give scripts a chance to act | 3984 /* Trigger the CompleteDone event to give scripts a chance to act |
4014 * upon the (possibly failed) completion. */ | 3985 * upon the (possibly failed) completion. */ |
4015 apply_autocmds(EVENT_COMPLETEDONE, NULL, NULL, FALSE, curbuf); | 3986 apply_autocmds(EVENT_COMPLETEDONE, NULL, NULL, FALSE, curbuf); |
4016 #endif | |
4017 | 3987 |
4018 /* reset continue_* if we left expansion-mode, if we stay they'll be | 3988 /* reset continue_* if we left expansion-mode, if we stay they'll be |
4019 * (re)set properly in ins_complete() */ | 3989 * (re)set properly in ins_complete() */ |
4020 if (!vim_is_ctrl_x_key(c)) | 3990 if (!vim_is_ctrl_x_key(c)) |
4021 { | 3991 { |
6222 && !cindent_on() | 6192 && !cindent_on() |
6223 #endif | 6193 #endif |
6224 #ifdef FEAT_RIGHTLEFT | 6194 #ifdef FEAT_RIGHTLEFT |
6225 && !p_ri | 6195 && !p_ri |
6226 #endif | 6196 #endif |
6227 #ifdef FEAT_AUTOCMD | 6197 && !has_insertcharpre()) |
6228 && !has_insertcharpre() | |
6229 #endif | |
6230 ) | |
6231 { | 6198 { |
6232 #define INPUT_BUFLEN 100 | 6199 #define INPUT_BUFLEN 100 |
6233 char_u buf[INPUT_BUFLEN + 1]; | 6200 char_u buf[INPUT_BUFLEN + 1]; |
6234 int i; | 6201 int i; |
6235 colnr_T virtcol = 0; | 6202 colnr_T virtcol = 0; |
8402 /* Don't call u_sync() while typing the expression or giving an error | 8369 /* Don't call u_sync() while typing the expression or giving an error |
8403 * message for it. Only call it explicitly. */ | 8370 * message for it. Only call it explicitly. */ |
8404 ++no_u_sync; | 8371 ++no_u_sync; |
8405 if (regname == '=') | 8372 if (regname == '=') |
8406 { | 8373 { |
8407 # ifdef FEAT_MBYTE | 8374 # ifdef HAVE_INPUT_METHOD |
8408 int im_on = im_get_status(); | 8375 int im_on = im_get_status(); |
8409 # endif | 8376 # endif |
8410 /* Sync undo when evaluating the expression calls setline() or | 8377 /* Sync undo when evaluating the expression calls setline() or |
8411 * append(), so that it can be undone separately. */ | 8378 * append(), so that it can be undone separately. */ |
8412 u_sync_once = 2; | 8379 u_sync_once = 2; |
8413 | 8380 |
8414 regname = get_expr_register(); | 8381 regname = get_expr_register(); |
8415 # ifdef FEAT_MBYTE | 8382 # ifdef HAVE_INPUT_METHOD |
8416 /* Restore the Input Method. */ | 8383 /* Restore the Input Method. */ |
8417 if (im_on) | 8384 if (im_on) |
8418 im_set_active(TRUE); | 8385 im_set_active(TRUE); |
8419 # endif | 8386 # endif |
8420 } | 8387 } |
8539 } | 8506 } |
8540 else | 8507 else |
8541 { | 8508 { |
8542 curbuf->b_p_iminsert = B_IMODE_LMAP; | 8509 curbuf->b_p_iminsert = B_IMODE_LMAP; |
8543 State |= LANGMAP; | 8510 State |= LANGMAP; |
8544 #ifdef FEAT_MBYTE | 8511 #ifdef HAVE_INPUT_METHOD |
8545 im_set_active(FALSE); | 8512 im_set_active(FALSE); |
8546 #endif | 8513 #endif |
8547 } | 8514 } |
8548 } | 8515 } |
8549 #ifdef FEAT_MBYTE | 8516 #ifdef HAVE_INPUT_METHOD |
8550 else | 8517 else |
8551 { | 8518 { |
8552 /* There are no ":lmap" mappings, toggle IM */ | 8519 /* There are no ":lmap" mappings, toggle IM */ |
8553 if (im_get_status()) | 8520 if (im_get_status()) |
8554 { | 8521 { |
8691 mb_adjust_cursor(); | 8658 mb_adjust_cursor(); |
8692 #endif | 8659 #endif |
8693 } | 8660 } |
8694 } | 8661 } |
8695 | 8662 |
8696 #ifdef FEAT_MBYTE | 8663 #ifdef HAVE_INPUT_METHOD |
8697 /* Disable IM to allow typing English directly for Normal mode commands. | 8664 /* Disable IM to allow typing English directly for Normal mode commands. |
8698 * When ":lmap" is enabled don't change 'iminsert' (IM can be enabled as | 8665 * When ":lmap" is enabled don't change 'iminsert' (IM can be enabled as |
8699 * well). */ | 8666 * well). */ |
8700 if (!(State & LANGMAP)) | 8667 if (!(State & LANGMAP)) |
8701 im_save_status(&curbuf->b_p_iminsert); | 8668 im_save_status(&curbuf->b_p_iminsert); |
8841 EMSG(farsi_text_3); /* encoded in Farsi */ | 8808 EMSG(farsi_text_3); /* encoded in Farsi */ |
8842 return; | 8809 return; |
8843 } | 8810 } |
8844 #endif | 8811 #endif |
8845 | 8812 |
8846 #ifdef FEAT_AUTOCMD | |
8847 # ifdef FEAT_EVAL | 8813 # ifdef FEAT_EVAL |
8848 set_vim_var_string(VV_INSERTMODE, | 8814 set_vim_var_string(VV_INSERTMODE, |
8849 (char_u *)((State & REPLACE_FLAG) ? "i" : | 8815 (char_u *)((State & REPLACE_FLAG) ? "i" : |
8850 # ifdef FEAT_VREPLACE | 8816 # ifdef FEAT_VREPLACE |
8851 replaceState == VREPLACE ? "v" : | 8817 replaceState == VREPLACE ? "v" : |
8852 # endif | 8818 # endif |
8853 "r"), 1); | 8819 "r"), 1); |
8854 # endif | 8820 # endif |
8855 apply_autocmds(EVENT_INSERTCHANGE, NULL, NULL, FALSE, curbuf); | 8821 apply_autocmds(EVENT_INSERTCHANGE, NULL, NULL, FALSE, curbuf); |
8856 #endif | |
8857 if (State & REPLACE_FLAG) | 8822 if (State & REPLACE_FLAG) |
8858 State = INSERT | (State & LANGMAP); | 8823 State = INSERT | (State & LANGMAP); |
8859 else | 8824 else |
8860 State = replaceState | (State & LANGMAP); | 8825 State = replaceState | (State & LANGMAP); |
8861 AppendCharToRedobuff(K_INS); | 8826 AppendCharToRedobuff(K_INS); |
10571 return getvcol_nolist(&curwin->w_cursor); | 10536 return getvcol_nolist(&curwin->w_cursor); |
10572 validate_virtcol(); | 10537 validate_virtcol(); |
10573 return curwin->w_virtcol; | 10538 return curwin->w_virtcol; |
10574 } | 10539 } |
10575 | 10540 |
10576 #ifdef FEAT_AUTOCMD | 10541 #if defined(FEAT_EVAL) |
10577 /* | 10542 /* |
10578 * Handle the InsertCharPre autocommand. | 10543 * Handle the InsertCharPre autocommand. |
10579 * "c" is the character that was typed. | 10544 * "c" is the character that was typed. |
10580 * Return a pointer to allocated memory with the replacement string. | 10545 * Return a pointer to allocated memory with the replacement string. |
10581 * Return NULL to continue inserting "c". | 10546 * Return NULL to continue inserting "c". |
10588 | 10553 |
10589 /* Return quickly when there is nothing to do. */ | 10554 /* Return quickly when there is nothing to do. */ |
10590 if (!has_insertcharpre()) | 10555 if (!has_insertcharpre()) |
10591 return NULL; | 10556 return NULL; |
10592 | 10557 |
10593 #ifdef FEAT_MBYTE | 10558 # ifdef FEAT_MBYTE |
10594 if (has_mbyte) | 10559 if (has_mbyte) |
10595 buf[(*mb_char2bytes)(c, buf)] = NUL; | 10560 buf[(*mb_char2bytes)(c, buf)] = NUL; |
10596 else | 10561 else |
10597 #endif | 10562 # endif |
10598 { | 10563 { |
10599 buf[0] = c; | 10564 buf[0] = c; |
10600 buf[1] = NUL; | 10565 buf[1] = NUL; |
10601 } | 10566 } |
10602 | 10567 |