Mercurial > vim
comparison src/workshop.c @ 273:2463194c8cdd
updated for version 7.0073
author | vimboss |
---|---|
date | Thu, 19 May 2005 21:00:46 +0000 |
parents | 504c627f7474 |
children | c4d200412ae9 |
comparison
equal
deleted
inserted
replaced
272:ddada568db54 | 273:2463194c8cdd |
---|---|
292 if (WSDLEVEL(WS_TRACE_VERBOSE | WS_TRACE)) | 292 if (WSDLEVEL(WS_TRACE_VERBOSE | WS_TRACE)) |
293 wstrace("workshop_save_file(%s)\n", filename); | 293 wstrace("workshop_save_file(%s)\n", filename); |
294 #endif | 294 #endif |
295 | 295 |
296 /* Save the given file */ | 296 /* Save the given file */ |
297 sprintf(cbuf, "w %s", filename); | 297 vim_snprintf(cbuf, sizeof(cbuf), "w %s", filename); |
298 coloncmd(cbuf, TRUE); | 298 coloncmd(cbuf, TRUE); |
299 } | 299 } |
300 | 300 |
301 void | 301 void |
302 workshop_save_files() | 302 workshop_save_files() |
378 | 378 |
379 if (gbuf[0] != '-' && gbuf[1] != NUL) | 379 if (gbuf[0] != '-' && gbuf[1] != NUL) |
380 { | 380 { |
381 if (colorspec != NULL && *colorspec) | 381 if (colorspec != NULL && *colorspec) |
382 { | 382 { |
383 sprintf(cbuf, "highlight WS%s guibg=%s", gbuf, colorspec); | 383 vim_snprintf(cbuf, sizeof(cbuf), |
384 "highlight WS%s guibg=%s", gbuf, colorspec); | |
384 coloncmd(cbuf, FALSE); | 385 coloncmd(cbuf, FALSE); |
385 sprintf(cibuf, "linehl=WS%s", gbuf); | 386 vim_snprintf(cibuf, sizeof(cibuf), "linehl=WS%s", gbuf); |
386 } | 387 } |
387 else | 388 else |
388 cibuf[0] = NUL; | 389 cibuf[0] = NUL; |
389 | 390 |
390 sprintf(cbuf, "sign define %d %s icon=%s", idx, cibuf, sign); | 391 vim_snprintf(cbuf, sizeof(cbuf), |
392 "sign define %d %s icon=%s", idx, cibuf, sign); | |
391 coloncmd(cbuf, TRUE); | 393 coloncmd(cbuf, TRUE); |
392 } | 394 } |
393 } | 395 } |
394 | 396 |
395 void | 397 void |
406 if (WSDLEVEL(WS_TRACE_VERBOSE | WS_TRACE)) | 408 if (WSDLEVEL(WS_TRACE_VERBOSE | WS_TRACE)) |
407 wstrace("workshop_set_mark(%s, %d (ln), %d (id), %d (idx))\n", | 409 wstrace("workshop_set_mark(%s, %d (ln), %d (id), %d (idx))\n", |
408 filename, lineno, markId, idx); | 410 filename, lineno, markId, idx); |
409 #endif | 411 #endif |
410 | 412 |
411 sprintf(cbuf, "sign place %d line=%d name=%d file=%s", | 413 vim_snprintf(cbuf, sizeof(cbuf), "sign place %d line=%d name=%d file=%s", |
412 markId, lineno, idx, filename); | 414 markId, lineno, idx, filename); |
413 coloncmd(cbuf, TRUE); | 415 coloncmd(cbuf, TRUE); |
414 } | 416 } |
415 | 417 |
416 void | 418 void |
426 if (WSDLEVEL(WS_TRACE_VERBOSE | WS_TRACE)) | 428 if (WSDLEVEL(WS_TRACE_VERBOSE | WS_TRACE)) |
427 wstrace("workshop_change_mark_type(%s, %d, %d)\n", | 429 wstrace("workshop_change_mark_type(%s, %d, %d)\n", |
428 filename, markId, idx); | 430 filename, markId, idx); |
429 #endif | 431 #endif |
430 | 432 |
431 sprintf(cbuf, "sign place %d name=%d file=%s", markId, idx, filename); | 433 vim_snprintf(cbuf, sizeof(cbuf), |
434 "sign place %d name=%d file=%s", markId, idx, filename); | |
432 coloncmd(cbuf, TRUE); | 435 coloncmd(cbuf, TRUE); |
433 } | 436 } |
434 | 437 |
435 /* | 438 /* |
436 * Goto the given mark in a file (e.g. show it). | 439 * Goto the given mark in a file (e.g. show it). |
451 filename, markId, message && *message && | 454 filename, markId, message && *message && |
452 !(*message == ' ' && message[1] == NULL) ? | 455 !(*message == ' ' && message[1] == NULL) ? |
453 message : "<None>"); | 456 message : "<None>"); |
454 #endif | 457 #endif |
455 | 458 |
456 sprintf(cbuf, "sign jump %d file=%s", markId, filename); | 459 vim_snprintf(cbuf, sizeof(cbuf), "sign jump %d file=%s", markId, filename); |
457 coloncmd(cbuf, TRUE); | 460 coloncmd(cbuf, TRUE); |
458 if (message != NULL && *message != NUL) | 461 if (message != NULL && *message != NUL) |
459 gui_mch_set_footer((char_u *)message); | 462 gui_mch_set_footer((char_u *)message); |
460 } | 463 } |
461 | 464 |
471 if (WSDLEVEL(WS_TRACE_VERBOSE | WS_TRACE)) | 474 if (WSDLEVEL(WS_TRACE_VERBOSE | WS_TRACE)) |
472 wstrace("workshop_delete_mark(%s, %d (id))\n", | 475 wstrace("workshop_delete_mark(%s, %d (id))\n", |
473 filename, markId); | 476 filename, markId); |
474 #endif | 477 #endif |
475 | 478 |
476 sprintf(cbuf, "sign unplace %d file=%s", markId, filename); | 479 vim_snprintf(cbuf, sizeof(cbuf), |
480 "sign unplace %d file=%s", markId, filename); | |
477 coloncmd(cbuf, TRUE); | 481 coloncmd(cbuf, TRUE); |
478 } | 482 } |
479 | 483 |
480 #if 0 /* not used */ | 484 #if 0 /* not used */ |
481 void | 485 void |
631 } | 635 } |
632 } | 636 } |
633 mnembuf[idx++] = NUL; | 637 mnembuf[idx++] = NUL; |
634 name = addUniqueMnemonic(mnembuf, label); | 638 name = addUniqueMnemonic(mnembuf, label); |
635 | 639 |
636 sprintf(curMenuName, "%s", name); | 640 vim_snprintf(curMenuName, sizeof(curMenuName), "%s", name); |
637 sprintf(curMenuPriority, "%d.0", menuPriority); | 641 sprintf(curMenuPriority, "%d.0", menuPriority); |
638 } | 642 } |
639 | 643 |
640 /* | 644 /* |
641 * Append the name and priority to strings to be used in vim menu commands. | 645 * Append the name and priority to strings to be used in vim menu commands. |
733 wstrace("menu: %-21.20s%-21.20s(%s)\n", label, verb, | 737 wstrace("menu: %-21.20s%-21.20s(%s)\n", label, verb, |
734 *sensitive == '1' ? "Sensitive" : "Insensitive"); | 738 *sensitive == '1' ? "Sensitive" : "Insensitive"); |
735 #endif | 739 #endif |
736 | 740 |
737 if (acceleratorText != NULL) | 741 if (acceleratorText != NULL) |
738 sprintf(accText, "<Tab>%s", acceleratorText); | 742 vim_snprintf(accText, sizeof(accText), "<Tab>%s", acceleratorText); |
739 else | 743 else |
740 accText[0] = NUL; | 744 accText[0] = NUL; |
741 updatePriority(False); | 745 updatePriority(False); |
742 sprintf(namebuf, "%s.%s", curMenuName, fixup(label)); | 746 vim_snprintf(namebuf, sizeof(namebuf), "%s.%s", curMenuName, fixup(label)); |
743 sprintf(cbuf, "amenu %s %s%s\t:wsverb %s<CR>", | 747 vim_snprintf(cbuf, sizeof(cbuf), "amenu %s %s%s\t:wsverb %s<CR>", |
744 curMenuPriority, namebuf, accText, verb); | 748 curMenuPriority, namebuf, accText, verb); |
745 | 749 |
746 coloncmd(cbuf, TRUE); | 750 coloncmd(cbuf, TRUE); |
747 addMenu(namebuf, fixAccelText(acceleratorText), verb); | 751 addMenu(namebuf, fixAccelText(acceleratorText), verb); |
748 | 752 |
749 if (*sensitive == '0') | 753 if (*sensitive == '0') |
750 { | 754 { |
751 sprintf(cbuf, "amenu disable %s", namebuf); | 755 vim_snprintf(cbuf, sizeof(cbuf), "amenu disable %s", namebuf); |
752 coloncmd(cbuf, TRUE); | 756 coloncmd(cbuf, TRUE); |
753 } | 757 } |
754 } | 758 } |
755 | 759 |
756 /* | 760 /* |
822 { | 826 { |
823 char cbuf[BUFSIZ + MAXPATHLEN]; | 827 char cbuf[BUFSIZ + MAXPATHLEN]; |
824 char namebuf[BUFSIZ]; | 828 char namebuf[BUFSIZ]; |
825 static int tbid = 1; | 829 static int tbid = 1; |
826 char_u *p; | 830 char_u *p; |
831 int len; | |
827 | 832 |
828 #ifdef WSDEBUG_TRACE | 833 #ifdef WSDEBUG_TRACE |
829 if (WSDLEVEL(WS_TRACE_VERBOSE)) | 834 if (WSDLEVEL(WS_TRACE_VERBOSE)) |
830 wsdebug("workshop_toolbar_button(\"%s\", %s, %s,\n" | 835 wsdebug("workshop_toolbar_button(\"%s\", %s, %s,\n" |
831 "\t%s, \"%s\", %s,\n\t\"%s\",\n\t<%s>)\n", | 836 "\t%s, \"%s\", %s,\n\t\"%s\",\n\t<%s>)\n", |
856 | 861 |
857 coloncmd(cbuf, True); | 862 coloncmd(cbuf, True); |
858 } | 863 } |
859 | 864 |
860 p = vim_strsave_escaped((char_u *)label, (char_u *)"\\. "); | 865 p = vim_strsave_escaped((char_u *)label, (char_u *)"\\. "); |
861 sprintf(namebuf, "ToolBar.%s", p); | 866 vim_snprintf(namebuf, sizeof(namebuf), "ToolBar.%s", p); |
862 vim_free(p); | 867 vim_free(p); |
863 STRCPY(cbuf, "amenu <silent> "); | 868 STRCPY(cbuf, "amenu <silent> "); |
864 if (file != NULL && *file != NUL) | 869 if (file != NULL && *file != NUL) |
865 { | 870 { |
866 p = vim_strsave_escaped((char_u *)file, (char_u *)" "); | 871 p = vim_strsave_escaped((char_u *)file, (char_u *)" "); |
867 sprintf(cbuf + STRLEN(cbuf), "icon=%s ", p); | 872 len = STRLEN(cbuf); |
873 vim_snprintf(cbuf + len, sizeof(cbuf) - len, "icon=%s ", p); | |
868 vim_free(p); | 874 vim_free(p); |
869 } | 875 } |
870 sprintf(cbuf + STRLEN(cbuf), "1.%d %s :wsverb %s<CR>", | 876 len = STRLEN(cbuf); |
877 vim_snprintf(cbuf + len, sizeof(cbuf) - len,"1.%d %s :wsverb %s<CR>", | |
871 tbpri, namebuf, verb); | 878 tbpri, namebuf, verb); |
872 | 879 |
873 /* Define the menu item */ | 880 /* Define the menu item */ |
874 coloncmd(cbuf, True); | 881 coloncmd(cbuf, True); |
875 | 882 |
876 if (*sense == '0') | 883 if (*sense == '0') |
877 { | 884 { |
878 /* If menu isn't sensitive at startup... */ | 885 /* If menu isn't sensitive at startup... */ |
879 sprintf(cbuf, "amenu disable %s", namebuf); | 886 vim_snprintf(cbuf, sizeof(cbuf), "amenu disable %s", namebuf); |
880 coloncmd(cbuf, True); | 887 coloncmd(cbuf, True); |
881 } | 888 } |
882 | 889 |
883 if (help && *help) | 890 if (help && *help) |
884 { | 891 { |
885 /* Do the tooltip */ | 892 /* Do the tooltip */ |
886 sprintf(cbuf, "tmenu %s %s", namebuf, help); | 893 vim_snprintf(cbuf, sizeof(cbuf), "tmenu %s %s", namebuf, help); |
887 coloncmd(cbuf, True); | 894 coloncmd(cbuf, True); |
888 } | 895 } |
889 | 896 |
890 addMenu(namebuf, NULL, verb); | 897 addMenu(namebuf, NULL, verb); |
891 tbpri += 10; | 898 tbpri += 10; |
959 cbuf[0] = NUL; | 966 cbuf[0] = NUL; |
960 switch (*option) /* switch on 1st letter */ | 967 switch (*option) /* switch on 1st letter */ |
961 { | 968 { |
962 case 's': | 969 case 's': |
963 if (strcmp(option, "syntax") == 0) | 970 if (strcmp(option, "syntax") == 0) |
964 sprintf(cbuf, "syntax %s", value); | 971 vim_snprintf(cbuf, sizeof(cbuf), "syntax %s", value); |
965 else if (strcmp(option, "savefiles") == 0) | 972 else if (strcmp(option, "savefiles") == 0) |
966 ; /* XXX - Not yet implemented */ | 973 ; /* XXX - Not yet implemented */ |
967 break; | 974 break; |
968 | 975 |
969 case 'l': | 976 case 'l': |
1072 if (workshopHotKeysEnabled) | 1079 if (workshopHotKeysEnabled) |
1073 for (mp = menuMap; mp < &menuMap[menuMapSize]; mp++) | 1080 for (mp = menuMap; mp < &menuMap[menuMapSize]; mp++) |
1074 { | 1081 { |
1075 if (mp->accel != NULL) | 1082 if (mp->accel != NULL) |
1076 { | 1083 { |
1077 sprintf(cbuf, "map %s :wsverb %s<CR>", mp->accel, mp->verb); | 1084 vim_snprintf(cbuf, sizeof(cbuf), |
1085 "map %s :wsverb %s<CR>", mp->accel, mp->verb); | |
1078 coloncmd(cbuf, TRUE); | 1086 coloncmd(cbuf, TRUE); |
1079 } | 1087 } |
1080 } | 1088 } |
1081 else | 1089 else |
1082 for (mp = menuMap; mp < &menuMap[menuMapSize]; mp++) | 1090 for (mp = menuMap; mp < &menuMap[menuMapSize]; mp++) |
1083 { | 1091 { |
1084 if (mp->accel != NULL) | 1092 if (mp->accel != NULL) |
1085 { | 1093 { |
1086 sprintf(cbuf, "unmap %s", mp->accel); | 1094 vim_snprintf(cbuf, sizeof(cbuf), "unmap %s", mp->accel); |
1087 coloncmd(cbuf, TRUE); | 1095 coloncmd(cbuf, TRUE); |
1088 } | 1096 } |
1089 } | 1097 } |
1090 } | 1098 } |
1091 | 1099 |
1270 if (lnum > 0) | 1278 if (lnum > 0) |
1271 sprintf(lnumbuf, "+%d", lnum); | 1279 sprintf(lnumbuf, "+%d", lnum); |
1272 else | 1280 else |
1273 lnumbuf[0] = NUL; | 1281 lnumbuf[0] = NUL; |
1274 | 1282 |
1275 sprintf(cbuf, "e %s %s", lnumbuf, filename); | 1283 vim_snprintf(cbuf, sizeof(cbuf), "e %s %s", lnumbuf, filename); |
1276 coloncmd(cbuf, False); | 1284 coloncmd(cbuf, False); |
1277 } | 1285 } |
1278 | 1286 |
1279 | 1287 |
1280 static void | 1288 static void |
1390 *p++ = NUL; | 1398 *p++ = NUL; |
1391 | 1399 |
1392 pri = atoi(p) + 10; /* our new priority */ | 1400 pri = atoi(p) + 10; /* our new priority */ |
1393 | 1401 |
1394 if (subMenu) | 1402 if (subMenu) |
1395 sprintf(curMenuPriority, "%s.%d.0", curMenuPriority, pri); | 1403 vim_snprintf(curMenuPriority, sizeof(curMenuPriority), |
1404 "%s.%d.0", curMenuPriority, pri); | |
1396 else | 1405 else |
1397 sprintf(curMenuPriority, "%s.%d", curMenuPriority, pri); | 1406 vim_snprintf(curMenuPriority, sizeof(curMenuPriority), |
1407 "%s.%d", curMenuPriority, pri); | |
1398 } | 1408 } |
1399 | 1409 |
1400 static char * | 1410 static char * |
1401 addUniqueMnemonic( | 1411 addUniqueMnemonic( |
1402 char *mnemonics, /* currently used mnemonics */ | 1412 char *mnemonics, /* currently used mnemonics */ |
1541 else | 1551 else |
1542 shift = ""; | 1552 shift = ""; |
1543 | 1553 |
1544 if (*ap == 'F' && atoi(&ap[1]) > 0) | 1554 if (*ap == 'F' && atoi(&ap[1]) > 0) |
1545 { | 1555 { |
1546 sprintf(buf, "<%s%s>", shift, ap); | 1556 vim_snprintf(buf, sizeof(buf), "<%s%s>", shift, ap); |
1547 return strdup(buf); | 1557 return strdup(buf); |
1548 } | 1558 } |
1549 else | 1559 else |
1550 return NULL; | 1560 return NULL; |
1551 } | 1561 } |
1605 else | 1615 else |
1606 /* Evaluate value(expression) */ | 1616 /* Evaluate value(expression) */ |
1607 type = (int)GPLineEval_EVALUATE; | 1617 type = (int)GPLineEval_EVALUATE; |
1608 | 1618 |
1609 /* Send request to dbx */ | 1619 /* Send request to dbx */ |
1610 sprintf(buf, "toolVerb debug.balloonEval " | 1620 vim_snprintf(buf, sizeof(buf), "toolVerb debug.balloonEval " |
1611 "%s %ld,0 %d,0 %d,%d %ld %s\n", | 1621 "%s %ld,0 %d,0 %d,%d %ld %s\n", |
1612 (char *)wp->w_buffer->b_ffname, | 1622 (char *)wp->w_buffer->b_ffname, |
1613 (long)lnum, idx, type, serialNo++, | 1623 (long)lnum, idx, type, serialNo++, |
1614 (long)strlen((char *)text), (char *)text); | 1624 (long)strlen((char *)text), (char *)text); |
1615 balloonEval = beval; | 1625 balloonEval = beval; |
1668 menuMap[menuMapSize].name = strdup(menu); | 1678 menuMap[menuMapSize].name = strdup(menu); |
1669 menuMap[menuMapSize].accel = accel && *accel ? strdup(accel) : NULL; | 1679 menuMap[menuMapSize].accel = accel && *accel ? strdup(accel) : NULL; |
1670 menuMap[menuMapSize++].verb = strdup(verb); | 1680 menuMap[menuMapSize++].verb = strdup(verb); |
1671 if (accel && workshopHotKeysEnabled) | 1681 if (accel && workshopHotKeysEnabled) |
1672 { | 1682 { |
1673 sprintf(cbuf, "map %s :wsverb %s<CR>", accel, verb); | 1683 vim_snprintf(cbuf, sizeof(cbuf), |
1684 "map %s :wsverb %s<CR>", accel, verb); | |
1674 coloncmd(cbuf, TRUE); | 1685 coloncmd(cbuf, TRUE); |
1675 } | 1686 } |
1676 } | 1687 } |
1677 } | 1688 } |
1678 | 1689 |