Mercurial > vim
comparison src/ex_cmds.c @ 7402:2c63e9ecf29d v7.4.1005
commit https://github.com/vim/vim/commit/86e179dbe75010e9545e1a2fcc92a15d57bf27fd
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Dec 31 16:10:23 2015 +0100
patch 7.4.1005
Problem: Vim users are not always happy.
Solution: Make them happy.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Thu, 31 Dec 2015 16:15:07 +0100 |
parents | 645abb8d8daf |
children | 1886f2863437 |
comparison
equal
deleted
inserted
replaced
7401:254d2d36b143 | 7402:2c63e9ecf29d |
---|---|
6936 { | 6936 { |
6937 sign_T *sn_next; /* next sign in list */ | 6937 sign_T *sn_next; /* next sign in list */ |
6938 int sn_typenr; /* type number of sign */ | 6938 int sn_typenr; /* type number of sign */ |
6939 char_u *sn_name; /* name of sign */ | 6939 char_u *sn_name; /* name of sign */ |
6940 char_u *sn_icon; /* name of pixmap */ | 6940 char_u *sn_icon; /* name of pixmap */ |
6941 #ifdef FEAT_SIGN_ICONS | 6941 # ifdef FEAT_SIGN_ICONS |
6942 void *sn_image; /* icon image */ | 6942 void *sn_image; /* icon image */ |
6943 #endif | 6943 # endif |
6944 char_u *sn_text; /* text used instead of pixmap */ | 6944 char_u *sn_text; /* text used instead of pixmap */ |
6945 int sn_line_hl; /* highlight ID for line */ | 6945 int sn_line_hl; /* highlight ID for line */ |
6946 int sn_text_hl; /* highlight ID for text */ | 6946 int sn_text_hl; /* highlight ID for text */ |
6947 }; | 6947 }; |
6948 | 6948 |
6953 static void sign_list_defined __ARGS((sign_T *sp)); | 6953 static void sign_list_defined __ARGS((sign_T *sp)); |
6954 static void sign_undefine __ARGS((sign_T *sp, sign_T *sp_prev)); | 6954 static void sign_undefine __ARGS((sign_T *sp, sign_T *sp_prev)); |
6955 | 6955 |
6956 static char *cmds[] = { | 6956 static char *cmds[] = { |
6957 "define", | 6957 "define", |
6958 #define SIGNCMD_DEFINE 0 | 6958 # define SIGNCMD_DEFINE 0 |
6959 "undefine", | 6959 "undefine", |
6960 #define SIGNCMD_UNDEFINE 1 | 6960 # define SIGNCMD_UNDEFINE 1 |
6961 "list", | 6961 "list", |
6962 #define SIGNCMD_LIST 2 | 6962 # define SIGNCMD_LIST 2 |
6963 "place", | 6963 "place", |
6964 #define SIGNCMD_PLACE 3 | 6964 # define SIGNCMD_PLACE 3 |
6965 "unplace", | 6965 "unplace", |
6966 #define SIGNCMD_UNPLACE 4 | 6966 # define SIGNCMD_UNPLACE 4 |
6967 "jump", | 6967 "jump", |
6968 #define SIGNCMD_JUMP 5 | 6968 # define SIGNCMD_JUMP 5 |
6969 NULL | 6969 NULL |
6970 #define SIGNCMD_LAST 6 | 6970 # define SIGNCMD_LAST 6 |
6971 }; | 6971 }; |
6972 | 6972 |
6973 /* | 6973 /* |
6974 * Find index of a ":sign" subcmd from its name. | 6974 * Find index of a ":sign" subcmd from its name. |
6975 * "*end_cmd" must be writable. | 6975 * "*end_cmd" must be writable. |
7108 { | 7108 { |
7109 arg += 5; | 7109 arg += 5; |
7110 vim_free(sp->sn_icon); | 7110 vim_free(sp->sn_icon); |
7111 sp->sn_icon = vim_strnsave(arg, (int)(p - arg)); | 7111 sp->sn_icon = vim_strnsave(arg, (int)(p - arg)); |
7112 backslash_halve(sp->sn_icon); | 7112 backslash_halve(sp->sn_icon); |
7113 #ifdef FEAT_SIGN_ICONS | 7113 # ifdef FEAT_SIGN_ICONS |
7114 if (gui.in_use) | 7114 if (gui.in_use) |
7115 { | 7115 { |
7116 out_flush(); | 7116 out_flush(); |
7117 if (sp->sn_image != NULL) | 7117 if (sp->sn_image != NULL) |
7118 gui_mch_destroy_sign(sp->sn_image); | 7118 gui_mch_destroy_sign(sp->sn_image); |
7119 sp->sn_image = gui_mch_register_sign(sp->sn_icon); | 7119 sp->sn_image = gui_mch_register_sign(sp->sn_icon); |
7120 } | 7120 } |
7121 #endif | 7121 # endif |
7122 } | 7122 } |
7123 else if (STRNCMP(arg, "text=", 5) == 0) | 7123 else if (STRNCMP(arg, "text=", 5) == 0) |
7124 { | 7124 { |
7125 char_u *s; | 7125 char_u *s; |
7126 int cells; | 7126 int cells; |
7127 int len; | 7127 int len; |
7128 | 7128 |
7129 arg += 5; | 7129 arg += 5; |
7130 #ifdef FEAT_MBYTE | 7130 # ifdef FEAT_MBYTE |
7131 /* Count cells and check for non-printable chars */ | 7131 /* Count cells and check for non-printable chars */ |
7132 if (has_mbyte) | 7132 if (has_mbyte) |
7133 { | 7133 { |
7134 cells = 0; | 7134 cells = 0; |
7135 for (s = arg; s < p; s += (*mb_ptr2len)(s)) | 7135 for (s = arg; s < p; s += (*mb_ptr2len)(s)) |
7138 break; | 7138 break; |
7139 cells += (*mb_ptr2cells)(s); | 7139 cells += (*mb_ptr2cells)(s); |
7140 } | 7140 } |
7141 } | 7141 } |
7142 else | 7142 else |
7143 #endif | 7143 # endif |
7144 { | 7144 { |
7145 for (s = arg; s < p; ++s) | 7145 for (s = arg; s < p; ++s) |
7146 if (!vim_isprintc(*s)) | 7146 if (!vim_isprintc(*s)) |
7147 break; | 7147 break; |
7148 cells = (int)(s - arg); | 7148 cells = (int)(s - arg); |
7341 return; | 7341 return; |
7342 sprintf((char *)cmd, "e +%ld %s", (long)lnum, buf->b_fname); | 7342 sprintf((char *)cmd, "e +%ld %s", (long)lnum, buf->b_fname); |
7343 do_cmdline_cmd(cmd); | 7343 do_cmdline_cmd(cmd); |
7344 vim_free(cmd); | 7344 vim_free(cmd); |
7345 } | 7345 } |
7346 #ifdef FEAT_FOLDING | 7346 # ifdef FEAT_FOLDING |
7347 foldOpenCursor(); | 7347 foldOpenCursor(); |
7348 #endif | 7348 # endif |
7349 } | 7349 } |
7350 else | 7350 else |
7351 EMSGN(_("E157: Invalid sign ID: %ld"), id); | 7351 EMSGN(_("E157: Invalid sign ID: %ld"), id); |
7352 } | 7352 } |
7353 else if (idx == SIGNCMD_UNPLACE) | 7353 else if (idx == SIGNCMD_UNPLACE) |
7393 else | 7393 else |
7394 EMSG(_(e_invarg)); | 7394 EMSG(_(e_invarg)); |
7395 } | 7395 } |
7396 } | 7396 } |
7397 | 7397 |
7398 #if defined(FEAT_SIGN_ICONS) || defined(PROTO) | 7398 # if defined(FEAT_SIGN_ICONS) || defined(PROTO) |
7399 /* | 7399 /* |
7400 * Allocate the icons. Called when the GUI has started. Allows defining | 7400 * Allocate the icons. Called when the GUI has started. Allows defining |
7401 * signs before it starts. | 7401 * signs before it starts. |
7402 */ | 7402 */ |
7403 void | 7403 void |
7407 | 7407 |
7408 for (sp = first_sign; sp != NULL; sp = sp->sn_next) | 7408 for (sp = first_sign; sp != NULL; sp = sp->sn_next) |
7409 if (sp->sn_icon != NULL) | 7409 if (sp->sn_icon != NULL) |
7410 sp->sn_image = gui_mch_register_sign(sp->sn_icon); | 7410 sp->sn_image = gui_mch_register_sign(sp->sn_icon); |
7411 } | 7411 } |
7412 #endif | 7412 # endif |
7413 | 7413 |
7414 /* | 7414 /* |
7415 * List one sign. | 7415 * List one sign. |
7416 */ | 7416 */ |
7417 static void | 7417 static void |
7423 smsg((char_u *)"sign %s", sp->sn_name); | 7423 smsg((char_u *)"sign %s", sp->sn_name); |
7424 if (sp->sn_icon != NULL) | 7424 if (sp->sn_icon != NULL) |
7425 { | 7425 { |
7426 MSG_PUTS(" icon="); | 7426 MSG_PUTS(" icon="); |
7427 msg_outtrans(sp->sn_icon); | 7427 msg_outtrans(sp->sn_icon); |
7428 #ifdef FEAT_SIGN_ICONS | 7428 # ifdef FEAT_SIGN_ICONS |
7429 if (sp->sn_image == NULL) | 7429 if (sp->sn_image == NULL) |
7430 MSG_PUTS(_(" (NOT FOUND)")); | 7430 MSG_PUTS(_(" (NOT FOUND)")); |
7431 #else | 7431 # else |
7432 MSG_PUTS(_(" (not supported)")); | 7432 MSG_PUTS(_(" (not supported)")); |
7433 #endif | 7433 # endif |
7434 } | 7434 } |
7435 if (sp->sn_text != NULL) | 7435 if (sp->sn_text != NULL) |
7436 { | 7436 { |
7437 MSG_PUTS(" text="); | 7437 MSG_PUTS(" text="); |
7438 msg_outtrans(sp->sn_text); | 7438 msg_outtrans(sp->sn_text); |
7465 sign_T *sp; | 7465 sign_T *sp; |
7466 sign_T *sp_prev; | 7466 sign_T *sp_prev; |
7467 { | 7467 { |
7468 vim_free(sp->sn_name); | 7468 vim_free(sp->sn_name); |
7469 vim_free(sp->sn_icon); | 7469 vim_free(sp->sn_icon); |
7470 #ifdef FEAT_SIGN_ICONS | 7470 # ifdef FEAT_SIGN_ICONS |
7471 if (sp->sn_image != NULL) | 7471 if (sp->sn_image != NULL) |
7472 { | 7472 { |
7473 out_flush(); | 7473 out_flush(); |
7474 gui_mch_destroy_sign(sp->sn_image); | 7474 gui_mch_destroy_sign(sp->sn_image); |
7475 } | 7475 } |
7476 #endif | 7476 # endif |
7477 vim_free(sp->sn_text); | 7477 vim_free(sp->sn_text); |
7478 if (sp_prev == NULL) | 7478 if (sp_prev == NULL) |
7479 first_sign = sp->sn_next; | 7479 first_sign = sp->sn_next; |
7480 else | 7480 else |
7481 sp_prev->sn_next = sp->sn_next; | 7481 sp_prev->sn_next = sp->sn_next; |
7525 if (sp->sn_typenr == typenr) | 7525 if (sp->sn_typenr == typenr) |
7526 return sp->sn_text; | 7526 return sp->sn_text; |
7527 return NULL; | 7527 return NULL; |
7528 } | 7528 } |
7529 | 7529 |
7530 #if defined(FEAT_SIGN_ICONS) || defined(PROTO) | 7530 # if defined(FEAT_SIGN_ICONS) || defined(PROTO) |
7531 void * | 7531 void * |
7532 sign_get_image(typenr) | 7532 sign_get_image(typenr) |
7533 int typenr; /* the attribute which may have a sign */ | 7533 int typenr; /* the attribute which may have a sign */ |
7534 { | 7534 { |
7535 sign_T *sp; | 7535 sign_T *sp; |
7537 for (sp = first_sign; sp != NULL; sp = sp->sn_next) | 7537 for (sp = first_sign; sp != NULL; sp = sp->sn_next) |
7538 if (sp->sn_typenr == typenr) | 7538 if (sp->sn_typenr == typenr) |
7539 return sp->sn_image; | 7539 return sp->sn_image; |
7540 return NULL; | 7540 return NULL; |
7541 } | 7541 } |
7542 #endif | 7542 # endif |
7543 | 7543 |
7544 /* | 7544 /* |
7545 * Get the name of a sign by its typenr. | 7545 * Get the name of a sign by its typenr. |
7546 */ | 7546 */ |
7547 char_u * | 7547 char_u * |
7554 if (sp->sn_typenr == typenr) | 7554 if (sp->sn_typenr == typenr) |
7555 return sp->sn_name; | 7555 return sp->sn_name; |
7556 return (char_u *)_("[Deleted]"); | 7556 return (char_u *)_("[Deleted]"); |
7557 } | 7557 } |
7558 | 7558 |
7559 #if defined(EXITFREE) || defined(PROTO) | 7559 # if defined(EXITFREE) || defined(PROTO) |
7560 /* | 7560 /* |
7561 * Undefine/free all signs. | 7561 * Undefine/free all signs. |
7562 */ | 7562 */ |
7563 void | 7563 void |
7564 free_signs() | 7564 free_signs() |
7565 { | 7565 { |
7566 while (first_sign != NULL) | 7566 while (first_sign != NULL) |
7567 sign_undefine(first_sign, NULL); | 7567 sign_undefine(first_sign, NULL); |
7568 } | 7568 } |
7569 #endif | 7569 # endif |
7570 | 7570 |
7571 #if defined(FEAT_CMDL_COMPL) || defined(PROTO) | 7571 # if defined(FEAT_CMDL_COMPL) || defined(PROTO) |
7572 static enum | 7572 static enum |
7573 { | 7573 { |
7574 EXP_SUBCMD, /* expand :sign sub-commands */ | 7574 EXP_SUBCMD, /* expand :sign sub-commands */ |
7575 EXP_DEFINE, /* expand :sign define {name} args */ | 7575 EXP_DEFINE, /* expand :sign define {name} args */ |
7576 EXP_PLACE, /* expand :sign place {id} args */ | 7576 EXP_PLACE, /* expand :sign place {id} args */ |
7744 default: | 7744 default: |
7745 xp->xp_context = EXPAND_NOTHING; | 7745 xp->xp_context = EXPAND_NOTHING; |
7746 } | 7746 } |
7747 } | 7747 } |
7748 } | 7748 } |
7749 #endif | 7749 # endif |
7750 #endif | 7750 #endif |
7751 | |
7752 /* | |
7753 * Make the user happy. | |
7754 */ | |
7755 void | |
7756 ex_smile(eap) | |
7757 exarg_T *eap UNUSED; | |
7758 { | |
7759 static char *code = "\34 \4o\14$\4ox\30 \2o\30$\1ox\25 \2o\36$\1o\11 \1o\1$\3 \2$\1 \1o\1$x\5 \1o\1 \1$\1 \2o\10 \1o\44$\1o\7 \2$\1 \2$\1 \2$\1o\1$x\2 \2o\1 \1$\1 \1$\1 \1\"\1$\6 \1o\11$\4 \15$\4 \11$\1o\7 \3$\1o\2$\1o\1$x\2 \1\"\6$\1o\1$\5 \1o\11$\6 \13$\6 \12$\1o\4 \10$x\4 \7$\4 \13$\6 \13$\6 \27$x\4 \27$\4 \15$\4 \16$\2 \3\"\3$x\5 \1\"\3$\4\"\61$\5 \1\"\3$x\6 \3$\3 \1o\62$\5 \1\"\3$\1ox\5 \1o\2$\1\"\3 \63$\7 \3$\1ox\5 \3$\4 \55$\1\"\1 \1\"\6$\5o\4$\1ox\4 \1o\3$\4o\5$\2 \45$\3 \1o\21$x\4 \10$\1\"\4$\3 \42$\5 \4$\10\"x\3 \4\"\7 \4$\4 \1\"\34$\1\"\6 \1o\3$x\16 \1\"\3$\1o\5 \3\"\22$\1\"\2$\1\"\11 \3$x\20 \3$\1o\12 \1\"\2$\2\"\6$\4\"\13 \1o\3$x\21 \4$\1o\40 \1o\3$\1\"x\22 \1\"\4$\1o\6 \1o\6$\1o\1\"\4$\1o\10 \1o\4$x\24 \1\"\5$\2o\5 \2\"\4$\1o\5$\1o\3 \1o\4$\2\"x\27 \2\"\5$\4o\2 \1\"\3$\1o\11$\3\"x\32 \2\"\7$\2o\1 \12$x\42 \4\"\13$x\46 \14$x\47 \12$\1\"x\50 \1\"\3$\4\"x"; | |
7760 char *p; | |
7761 int n; | |
7762 | |
7763 msg_start(); | |
7764 msg_putchar('\n'); | |
7765 for (p = code; *p != NUL; ++p) | |
7766 if (*p == 'x') | |
7767 msg_putchar('\n'); | |
7768 else | |
7769 for (n = *p++; n > 0; --n) | |
7770 msg_putchar(*p); | |
7771 msg_clr_eos(); | |
7772 } | |
7751 | 7773 |
7752 #if defined(FEAT_GUI) || defined(FEAT_CLIENTSERVER) || defined(PROTO) | 7774 #if defined(FEAT_GUI) || defined(FEAT_CLIENTSERVER) || defined(PROTO) |
7753 /* | 7775 /* |
7754 * ":drop" | 7776 * ":drop" |
7755 * Opens the first argument in a window. When there are two or more arguments | 7777 * Opens the first argument in a window. When there are two or more arguments |