Mercurial > vim
comparison src/ops.c @ 15:631143ac4a01 v7.0007
updated for version 7.0007
author | vimboss |
---|---|
date | Sat, 10 Jul 2004 09:47:34 +0000 |
parents | 3fc0f57ecb91 |
children | 3ba373b54370 |
comparison
equal
deleted
inserted
replaced
14:946da5994c01 | 15:631143ac4a01 |
---|---|
92 | 92 |
93 #ifdef FEAT_VISUALEXTRA | 93 #ifdef FEAT_VISUALEXTRA |
94 static void shift_block __ARGS((oparg_T *oap, int amount)); | 94 static void shift_block __ARGS((oparg_T *oap, int amount)); |
95 static void block_insert __ARGS((oparg_T *oap, char_u *s, int b_insert, struct block_def*bdp)); | 95 static void block_insert __ARGS((oparg_T *oap, char_u *s, int b_insert, struct block_def*bdp)); |
96 #endif | 96 #endif |
97 static void get_yank_register __ARGS((int regname, int writing)); | |
98 static int stuff_yank __ARGS((int, char_u *)); | 97 static int stuff_yank __ARGS((int, char_u *)); |
99 static void put_reedit_in_typebuf __ARGS((void)); | 98 static void put_reedit_in_typebuf __ARGS((void)); |
100 static int put_in_typebuf __ARGS((char_u *s, int colon)); | 99 static int put_in_typebuf __ARGS((char_u *s, int colon)); |
101 static void stuffescaped __ARGS((char_u *arg, int literally)); | 100 static void stuffescaped __ARGS((char_u *arg, int literally)); |
102 static int get_spec_reg __ARGS((int regname, char_u **argp, int *allocated, int errmsg)); | |
103 static void cmdline_paste_str __ARGS((char_u *s, int literally)); | |
104 #ifdef FEAT_MBYTE | 101 #ifdef FEAT_MBYTE |
105 static void mb_adjust_opend __ARGS((oparg_T *oap)); | 102 static void mb_adjust_opend __ARGS((oparg_T *oap)); |
106 #endif | 103 #endif |
107 static void free_yank __ARGS((long)); | 104 static void free_yank __ARGS((long)); |
108 static void free_yank_all __ARGS((void)); | 105 static void free_yank_all __ARGS((void)); |
818 * Cannot handle the '_' register. | 815 * Cannot handle the '_' register. |
819 * | 816 * |
820 * If regname is 0 and writing, use register 0 | 817 * If regname is 0 and writing, use register 0 |
821 * If regname is 0 and reading, use previous register | 818 * If regname is 0 and reading, use previous register |
822 */ | 819 */ |
823 static void | 820 void |
824 get_yank_register(regname, writing) | 821 get_yank_register(regname, writing) |
825 int regname; | 822 int regname; |
826 int writing; | 823 int writing; |
827 { | 824 { |
828 int i; | 825 int i; |
862 y_current = &(y_regs[i]); | 859 y_current = &(y_regs[i]); |
863 if (writing) /* remember the register we write into for do_put() */ | 860 if (writing) /* remember the register we write into for do_put() */ |
864 y_previous = y_current; | 861 y_previous = y_current; |
865 } | 862 } |
866 | 863 |
867 #ifdef FEAT_CLIPBOARD | 864 #if defined(FEAT_CLIPBOARD) || defined(PROTO) |
868 /* | 865 /* |
869 * When "regname" is a clipboard register, obtain the selection. If it's not | 866 * When "regname" is a clipboard register, obtain the selection. If it's not |
870 * available return zero, otherwise return "regname". | 867 * available return zero, otherwise return "regname". |
871 */ | 868 */ |
872 static int may_get_selection __ARGS((int regname)); | 869 int |
873 | |
874 static int | |
875 may_get_selection(regname) | 870 may_get_selection(regname) |
876 int regname; | 871 int regname; |
877 { | 872 { |
878 if (regname == '*') | 873 if (regname == '*') |
879 { | 874 { |
1345 } | 1340 } |
1346 | 1341 |
1347 /* | 1342 /* |
1348 * If "regname" is a special register, return a pointer to its value. | 1343 * If "regname" is a special register, return a pointer to its value. |
1349 */ | 1344 */ |
1350 static int | 1345 int |
1351 get_spec_reg(regname, argp, allocated, errmsg) | 1346 get_spec_reg(regname, argp, allocated, errmsg) |
1352 int regname; | 1347 int regname; |
1353 char_u **argp; | 1348 char_u **argp; |
1354 int *allocated; | 1349 int *allocated; |
1355 int errmsg; /* give error message when failing */ | 1350 int errmsg; /* give error message when failing */ |
1424 | 1419 |
1425 return FALSE; | 1420 return FALSE; |
1426 } | 1421 } |
1427 | 1422 |
1428 /* | 1423 /* |
1429 * paste a yank register into the command line. | 1424 * Paste a yank register into the command line. |
1430 * used by CTRL-R command in command-line mode | 1425 * Only for non-special registers. |
1426 * Used by CTRL-R command in command-line mode | |
1431 * insert_reg() can't be used here, because special characters from the | 1427 * insert_reg() can't be used here, because special characters from the |
1432 * register contents will be interpreted as commands. | 1428 * register contents will be interpreted as commands. |
1433 * | 1429 * |
1434 * return FAIL for failure, OK otherwise | 1430 * return FAIL for failure, OK otherwise |
1435 */ | 1431 */ |
1436 int | 1432 int |
1437 cmdline_paste(regname, literally) | 1433 cmdline_paste_reg(regname, literally) |
1438 int regname; | 1434 int regname; |
1439 int literally; /* Insert text literally instead of "as typed" */ | 1435 int literally; /* Insert text literally instead of "as typed" */ |
1440 { | 1436 { |
1441 long i; | 1437 long i; |
1442 char_u *arg; | |
1443 int allocated; | |
1444 | |
1445 /* check for valid regname; also accept special characters for CTRL-R in | |
1446 * the command line */ | |
1447 if (regname != Ctrl_F && regname != Ctrl_P && regname != Ctrl_W | |
1448 && regname != Ctrl_A && !valid_yank_reg(regname, FALSE)) | |
1449 return FAIL; | |
1450 | |
1451 /* A register containing CTRL-R can cause an endless loop. Allow using | |
1452 * CTRL-C to break the loop. */ | |
1453 line_breakcheck(); | |
1454 if (got_int) | |
1455 return FAIL; | |
1456 | |
1457 #ifdef FEAT_CLIPBOARD | |
1458 regname = may_get_selection(regname); | |
1459 #endif | |
1460 | |
1461 if (get_spec_reg(regname, &arg, &allocated, TRUE)) | |
1462 { | |
1463 if (arg == NULL) | |
1464 return FAIL; | |
1465 cmdline_paste_str(arg, literally); | |
1466 if (allocated) | |
1467 vim_free(arg); | |
1468 return OK; | |
1469 } | |
1470 | 1438 |
1471 get_yank_register(regname, FALSE); | 1439 get_yank_register(regname, FALSE); |
1472 if (y_current->y_array == NULL) | 1440 if (y_current->y_array == NULL) |
1473 return FAIL; | 1441 return FAIL; |
1474 | 1442 |
1485 ui_breakcheck(); | 1453 ui_breakcheck(); |
1486 if (got_int) | 1454 if (got_int) |
1487 return FAIL; | 1455 return FAIL; |
1488 } | 1456 } |
1489 return OK; | 1457 return OK; |
1490 } | |
1491 | |
1492 /* | |
1493 * Put a string on the command line. | |
1494 * When "literally" is TRUE, insert literally. | |
1495 * When "literally" is FALSE, insert as typed, but don't leave the command | |
1496 * line. | |
1497 */ | |
1498 static void | |
1499 cmdline_paste_str(s, literally) | |
1500 char_u *s; | |
1501 int literally; | |
1502 { | |
1503 int c, cv; | |
1504 | |
1505 if (literally) | |
1506 put_on_cmdline(s, -1, TRUE); | |
1507 else | |
1508 while (*s != NUL) | |
1509 { | |
1510 cv = *s; | |
1511 if (cv == Ctrl_V && s[1]) | |
1512 ++s; | |
1513 #ifdef FEAT_MBYTE | |
1514 if (has_mbyte) | |
1515 { | |
1516 c = mb_ptr2char(s); | |
1517 s += mb_char2len(c); | |
1518 } | |
1519 else | |
1520 #endif | |
1521 c = *s++; | |
1522 if (cv == Ctrl_V || c == ESC || c == Ctrl_C || c == CAR || c == NL | |
1523 #ifdef UNIX | |
1524 || c == intr_char | |
1525 #endif | |
1526 || (c == Ctrl_BSL && *s == Ctrl_N)) | |
1527 stuffcharReadbuff(Ctrl_V); | |
1528 stuffcharReadbuff(c); | |
1529 } | |
1530 } | 1458 } |
1531 | 1459 |
1532 #if defined(FEAT_CLIPBOARD) || defined(PROTO) | 1460 #if defined(FEAT_CLIPBOARD) || defined(PROTO) |
1533 /* | 1461 /* |
1534 * Adjust the register name pointed to with "rp" for the clipboard being | 1462 * Adjust the register name pointed to with "rp" for the clipboard being |