Mercurial > vim
comparison src/ops.c @ 1034:98d1c149be76 v7.0.160
updated for version 7.0-160
author | vimboss |
---|---|
date | Tue, 07 Nov 2006 17:43:47 +0000 |
parents | 64e2b75e1615 |
children | a11e2070c964 |
comparison
equal
deleted
inserted
replaced
1033:19ed3bfbe488 | 1034:98d1c149be76 |
---|---|
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 int stuff_yank __ARGS((int, char_u *)); | 97 static int stuff_yank __ARGS((int, char_u *)); |
98 static void put_reedit_in_typebuf __ARGS((void)); | 98 static void put_reedit_in_typebuf __ARGS((int silent)); |
99 static int put_in_typebuf __ARGS((char_u *s, int colon)); | 99 static int put_in_typebuf __ARGS((char_u *s, int colon, int silent)); |
100 static void stuffescaped __ARGS((char_u *arg, int literally)); | 100 static void stuffescaped __ARGS((char_u *arg, int literally)); |
101 #ifdef FEAT_MBYTE | 101 #ifdef FEAT_MBYTE |
102 static void mb_adjust_opend __ARGS((oparg_T *oap)); | 102 static void mb_adjust_opend __ARGS((oparg_T *oap)); |
103 #endif | 103 #endif |
104 static void free_yank __ARGS((long)); | 104 static void free_yank __ARGS((long)); |
1118 * execute a yank register: copy it into the stuff buffer | 1118 * execute a yank register: copy it into the stuff buffer |
1119 * | 1119 * |
1120 * return FAIL for failure, OK otherwise | 1120 * return FAIL for failure, OK otherwise |
1121 */ | 1121 */ |
1122 int | 1122 int |
1123 do_execreg(regname, colon, addcr) | 1123 do_execreg(regname, colon, addcr, silent) |
1124 int regname; | 1124 int regname; |
1125 int colon; /* insert ':' before each line */ | 1125 int colon; /* insert ':' before each line */ |
1126 int addcr; /* always add '\n' to end of line */ | 1126 int addcr; /* always add '\n' to end of line */ |
1127 int silent; /* set "silent" flag in typeahead buffer */ | |
1127 { | 1128 { |
1128 static int lastc = NUL; | 1129 static int lastc = NUL; |
1129 long i; | 1130 long i; |
1130 char_u *p; | 1131 char_u *p; |
1131 int retval = OK; | 1132 int retval = OK; |
1171 if (p != NULL) | 1172 if (p != NULL) |
1172 { | 1173 { |
1173 /* When in Visual mode "'<,'>" will be prepended to the command. | 1174 /* When in Visual mode "'<,'>" will be prepended to the command. |
1174 * Remove it when it's already there. */ | 1175 * Remove it when it's already there. */ |
1175 if (VIsual_active && STRNCMP(p, "'<,'>", 5) == 0) | 1176 if (VIsual_active && STRNCMP(p, "'<,'>", 5) == 0) |
1176 retval = put_in_typebuf(p + 5, TRUE); | 1177 retval = put_in_typebuf(p + 5, TRUE, silent); |
1177 else | 1178 else |
1178 retval = put_in_typebuf(p, TRUE); | 1179 retval = put_in_typebuf(p, TRUE, silent); |
1179 } | 1180 } |
1180 vim_free(p); | 1181 vim_free(p); |
1181 } | 1182 } |
1182 #endif | 1183 #endif |
1183 #ifdef FEAT_EVAL | 1184 #ifdef FEAT_EVAL |
1184 else if (regname == '=') | 1185 else if (regname == '=') |
1185 { | 1186 { |
1186 p = get_expr_line(); | 1187 p = get_expr_line(); |
1187 if (p == NULL) | 1188 if (p == NULL) |
1188 return FAIL; | 1189 return FAIL; |
1189 retval = put_in_typebuf(p, colon); | 1190 retval = put_in_typebuf(p, colon, silent); |
1190 vim_free(p); | 1191 vim_free(p); |
1191 } | 1192 } |
1192 #endif | 1193 #endif |
1193 else if (regname == '.') /* use last inserted text */ | 1194 else if (regname == '.') /* use last inserted text */ |
1194 { | 1195 { |
1196 if (p == NULL) | 1197 if (p == NULL) |
1197 { | 1198 { |
1198 EMSG(_(e_noinstext)); | 1199 EMSG(_(e_noinstext)); |
1199 return FAIL; | 1200 return FAIL; |
1200 } | 1201 } |
1201 retval = put_in_typebuf(p, colon); | 1202 retval = put_in_typebuf(p, colon, silent); |
1202 vim_free(p); | 1203 vim_free(p); |
1203 } | 1204 } |
1204 else | 1205 else |
1205 { | 1206 { |
1206 get_yank_register(regname, FALSE); | 1207 get_yank_register(regname, FALSE); |
1211 remap = colon ? REMAP_NONE : REMAP_YES; | 1212 remap = colon ? REMAP_NONE : REMAP_YES; |
1212 | 1213 |
1213 /* | 1214 /* |
1214 * Insert lines into typeahead buffer, from last one to first one. | 1215 * Insert lines into typeahead buffer, from last one to first one. |
1215 */ | 1216 */ |
1216 put_reedit_in_typebuf(); | 1217 put_reedit_in_typebuf(silent); |
1217 for (i = y_current->y_size; --i >= 0; ) | 1218 for (i = y_current->y_size; --i >= 0; ) |
1218 { | 1219 { |
1219 /* insert NL between lines and after last line if type is MLINE */ | 1220 /* insert NL between lines and after last line if type is MLINE */ |
1220 if (y_current->y_type == MLINE || i < y_current->y_size - 1 | 1221 if (y_current->y_type == MLINE || i < y_current->y_size - 1 |
1221 || addcr) | 1222 || addcr) |
1222 { | 1223 { |
1223 if (ins_typebuf((char_u *)"\n", remap, 0, TRUE, FALSE) == FAIL) | 1224 if (ins_typebuf((char_u *)"\n", remap, 0, TRUE, silent) == FAIL) |
1224 return FAIL; | 1225 return FAIL; |
1225 } | 1226 } |
1226 if (ins_typebuf(y_current->y_array[i], remap, 0, TRUE, FALSE) | 1227 if (ins_typebuf(y_current->y_array[i], remap, 0, TRUE, silent) |
1227 == FAIL) | 1228 == FAIL) |
1228 return FAIL; | 1229 return FAIL; |
1229 if (colon && ins_typebuf((char_u *)":", remap, 0, TRUE, FALSE) | 1230 if (colon && ins_typebuf((char_u *)":", remap, 0, TRUE, silent) |
1230 == FAIL) | 1231 == FAIL) |
1231 return FAIL; | 1232 return FAIL; |
1232 } | 1233 } |
1233 Exec_reg = TRUE; /* disable the 'q' command */ | 1234 Exec_reg = TRUE; /* disable the 'q' command */ |
1234 } | 1235 } |
1238 /* | 1239 /* |
1239 * If "restart_edit" is not zero, put it in the typeahead buffer, so that it's | 1240 * If "restart_edit" is not zero, put it in the typeahead buffer, so that it's |
1240 * used only after other typeahead has been processed. | 1241 * used only after other typeahead has been processed. |
1241 */ | 1242 */ |
1242 static void | 1243 static void |
1243 put_reedit_in_typebuf() | 1244 put_reedit_in_typebuf(silent) |
1245 int silent; | |
1244 { | 1246 { |
1245 char_u buf[3]; | 1247 char_u buf[3]; |
1246 | 1248 |
1247 if (restart_edit != NUL) | 1249 if (restart_edit != NUL) |
1248 { | 1250 { |
1255 else | 1257 else |
1256 { | 1258 { |
1257 buf[0] = restart_edit == 'I' ? 'i' : restart_edit; | 1259 buf[0] = restart_edit == 'I' ? 'i' : restart_edit; |
1258 buf[1] = NUL; | 1260 buf[1] = NUL; |
1259 } | 1261 } |
1260 if (ins_typebuf(buf, REMAP_NONE, 0, TRUE, FALSE) == OK) | 1262 if (ins_typebuf(buf, REMAP_NONE, 0, TRUE, silent) == OK) |
1261 restart_edit = NUL; | 1263 restart_edit = NUL; |
1262 } | 1264 } |
1263 } | 1265 } |
1264 | 1266 |
1265 static int | 1267 static int |
1266 put_in_typebuf(s, colon) | 1268 put_in_typebuf(s, colon, silent) |
1267 char_u *s; | 1269 char_u *s; |
1268 int colon; /* add ':' before the line */ | 1270 int colon; /* add ':' before the line */ |
1271 int silent; | |
1269 { | 1272 { |
1270 int retval = OK; | 1273 int retval = OK; |
1271 | 1274 |
1272 put_reedit_in_typebuf(); | 1275 put_reedit_in_typebuf(silent); |
1273 if (colon) | 1276 if (colon) |
1274 retval = ins_typebuf((char_u *)"\n", REMAP_YES, 0, TRUE, FALSE); | 1277 retval = ins_typebuf((char_u *)"\n", REMAP_YES, 0, TRUE, silent); |
1275 if (retval == OK) | 1278 if (retval == OK) |
1276 retval = ins_typebuf(s, REMAP_YES, 0, TRUE, FALSE); | 1279 retval = ins_typebuf(s, REMAP_YES, 0, TRUE, silent); |
1277 if (colon && retval == OK) | 1280 if (colon && retval == OK) |
1278 retval = ins_typebuf((char_u *)":", REMAP_YES, 0, TRUE, FALSE); | 1281 retval = ins_typebuf((char_u *)":", REMAP_YES, 0, TRUE, silent); |
1279 return retval; | 1282 return retval; |
1280 } | 1283 } |
1281 | 1284 |
1282 /* | 1285 /* |
1283 * Insert a yank register: copy it into the Read buffer. | 1286 * Insert a yank register: copy it into the Read buffer. |