Mercurial > vim
comparison src/gui_kde.cc @ 45:e474bae3795f
updated for version 7.0027
author | vimboss |
---|---|
date | Fri, 31 Dec 2004 20:58:58 +0000 |
parents | c75153d791d0 |
children | 388f285bda1b |
comparison
equal
deleted
inserted
replaced
44:af1bcb9a13c0 | 45:e474bae3795f |
---|---|
486 /* | 486 /* |
487 * Implementation of the file selector related stuff | 487 * Implementation of the file selector related stuff |
488 */ | 488 */ |
489 | 489 |
490 /* | 490 /* |
491 * Convert the Vim-style filter specification 's' to the KDE-style | |
492 * filter specification. | |
493 * Vim-style: {label}\t{pattern1};{pattern2}\n | |
494 * KDE-style: {pattern1} {pattern2}|{label}\n | |
495 * | |
496 * The newly constructed filter is returned in allocated memory and | |
497 * must be freed by the calling program. | |
498 */ | |
499 static char * | |
500 convert_filter(char_u *s) | |
501 { | |
502 char *res; | |
503 unsigned i; | |
504 unsigned pattern_len; | |
505 char *filter_label; | |
506 char *filter_pattern; | |
507 | |
508 // The conversion generates a string of equal length to the original | |
509 // pattern, so allocate enough memory to hold the original string. | |
510 res = new char[STRLEN(s) + 1]; | |
511 s = vim_strsave(s); | |
512 if (res != NULL && s != NULL) | |
513 { | |
514 // Make sure the first byte is a NUL so that strcat() | |
515 // will append at the beginning of the string. | |
516 res[0] = '\0'; | |
517 filter_label = strtok((char *) s, "\t"); | |
518 while (filter_label != NULL) | |
519 { | |
520 filter_pattern = strtok( 0L, "\n"); | |
521 if (filter_pattern != NULL) | |
522 { | |
523 pattern_len = (unsigned) STRLEN(filter_pattern); | |
524 for (i = 0; i < pattern_len; ++i) | |
525 if (filter_pattern[i] == ';') | |
526 filter_pattern[i] = ' '; | |
527 | |
528 strcat(res, filter_pattern); | |
529 strcat(res, "|"); | |
530 strcat(res, filter_label); | |
531 strcat(res, "\n"); | |
532 } | |
533 filter_label = strtok(0L, "\t"); | |
534 } | |
535 } | |
536 if (s) | |
537 vim_free(s); | |
538 return res; | |
539 } | |
540 | |
541 /* | |
491 * Put up a file requester. | 542 * Put up a file requester. |
492 * Returns the selected name in allocated memory, or NULL for Cancel. | 543 * Returns the selected name in allocated memory, or NULL for Cancel. |
493 * saving, select file to write | 544 * saving, select file to write |
494 * title title for the window | 545 * title title for the window |
495 * dflt default name | 546 * dflt default name |
506 char_u *initdir, | 557 char_u *initdir, |
507 char_u *filter) | 558 char_u *filter) |
508 { | 559 { |
509 char *filt_glob; | 560 char *filt_glob; |
510 | 561 |
511 if (filter != (char_u *)0x0) | 562 filt_glob = convert_filter(filter); |
512 { | |
513 filter = vim_strsave(filter); | |
514 strtok((char *)filter, "("); | |
515 filt_glob = strtok(0L, ")"); | |
516 } | |
517 else | |
518 filt_glob = (char *)filter; | |
519 | 563 |
520 gui_mch_mousehide(FALSE); | 564 gui_mch_mousehide(FALSE); |
521 | 565 |
522 QString s; | 566 QString s; |
523 if (!saving) | 567 if (!saving) |
524 s = KFileDialog::getOpenFileName(QSTR(initdir), QSTR(filt_glob), | 568 s = KFileDialog::getOpenFileName(QSTR(initdir), QSTR(filt_glob), |
525 vmw, QSTR(title)); | 569 vmw, QSTR(title)); |
526 else | 570 else |
527 s = KFileDialog::getSaveFileName(); | 571 s = KFileDialog::getSaveFileName(); |
528 | 572 |
529 if (filter) | 573 if (filt_glob) |
530 vim_free(filter); | 574 delete filt_glob; |
531 | 575 |
532 if (s.isNull()) | 576 if (s.isNull()) |
533 return NULL; | 577 return NULL; |
534 QCString unistring = vmw->codec->fromUnicode(s); | 578 QCString unistring = vmw->codec->fromUnicode(s); |
535 char_u *s2 = (char_u *)(const char *)unistring; | 579 char_u *s2 = (char_u *)(const char *)unistring; |