comparison src/gui.c @ 28:726bdc53fa49

updated for version 7.0018
author vimboss
date Mon, 11 Oct 2004 10:06:20 +0000
parents db5102f7e29f
children fdf55076c53f
comparison
equal deleted inserted replaced
27:ce185ac4a252 28:726bdc53fa49
4409 # endif 4409 # endif
4410 ); 4410 );
4411 } 4411 }
4412 #endif 4412 #endif
4413 4413
4414 #if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_MOTIF) \ 4414 #if defined(FIND_REPLACE_DIALOG) || defined(FEAT_SUN_WORKSHOP) \
4415 || defined(MSWIN_FIND_REPLACE) || defined(FEAT_SUN_WORKSHOP) \ 4415 || defined(PROTO)
4416 || defined(PROTO) || defined(FEAT_GUI_KDE)
4417 /* 4416 /*
4418 * Update the current window and the screen. 4417 * Update the current window and the screen.
4419 */ 4418 */
4420 void 4419 void
4421 gui_update_screen() 4420 gui_update_screen()
4428 gui_update_cursor(TRUE, FALSE); 4427 gui_update_cursor(TRUE, FALSE);
4429 gui_mch_flush(); 4428 gui_mch_flush();
4430 } 4429 }
4431 #endif 4430 #endif
4432 4431
4433 #if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_MOTIF) \ 4432 #if defined(FIND_REPLACE_DIALOG) || defined(PROTO)
4434 || defined(MSWIN_FIND_REPLACE) || defined(PROTO) || defined(FEAT_GUI_KDE)
4435 static void concat_esc __ARGS((garray_T *gap, char_u *text, int what)); 4433 static void concat_esc __ARGS((garray_T *gap, char_u *text, int what));
4436 4434
4437 /* 4435 /*
4438 * Get the text to use in a find/replace dialog. Uses the last search pattern 4436 * Get the text to use in a find/replace dialog. Uses the last search pattern
4439 * if the argument is empty. 4437 * if the argument is empty.
4537 { 4535 {
4538 garray_T ga; 4536 garray_T ga;
4539 int i; 4537 int i;
4540 int type = (flags & FRD_TYPE_MASK); 4538 int type = (flags & FRD_TYPE_MASK);
4541 char_u *p; 4539 char_u *p;
4540 regmatch_T regmatch;
4542 4541
4543 ga_init2(&ga, 1, 100); 4542 ga_init2(&ga, 1, 100);
4544 4543 if (type == FRD_REPLACEALL)
4545 if (type == FRD_REPLACE)
4546 {
4547 /* Do the replacement when the text under the cursor matches. */
4548 i = STRLEN(find_text);
4549 p = ml_get_cursor();
4550 if (((flags & FRD_MATCH_CASE)
4551 ? STRNCMP(p, find_text, i) == 0
4552 : STRNICMP(p, find_text, i) == 0)
4553 && u_save_cursor() == OK)
4554 {
4555 /* A button was pressed thus undo should be synced. */
4556 if (no_u_sync == 0)
4557 u_sync();
4558
4559 del_bytes((long)i, FALSE);
4560 ins_str(repl_text);
4561 }
4562 }
4563 else if (type == FRD_REPLACEALL)
4564 ga_concat(&ga, (char_u *)"%s/"); 4544 ga_concat(&ga, (char_u *)"%s/");
4565 4545
4566 ga_concat(&ga, (char_u *)"\\V"); 4546 ga_concat(&ga, (char_u *)"\\V");
4567 if (flags & FRD_MATCH_CASE) 4547 if (flags & FRD_MATCH_CASE)
4568 ga_concat(&ga, (char_u *)"\\C"); 4548 ga_concat(&ga, (char_u *)"\\C");
4577 if (flags & FRD_WHOLE_WORD) 4557 if (flags & FRD_WHOLE_WORD)
4578 ga_concat(&ga, (char_u *)"\\>"); 4558 ga_concat(&ga, (char_u *)"\\>");
4579 4559
4580 if (type == FRD_REPLACEALL) 4560 if (type == FRD_REPLACEALL)
4581 { 4561 {
4562 ga_concat(&ga, (char_u *)"/");
4563 concat_esc(&ga, repl_text, '/'); /* escape slashes */
4564 ga_concat(&ga, (char_u *)"/g");
4565 }
4566 ga_append(&ga, NUL);
4567
4568 if (type == FRD_REPLACE)
4569 {
4570 /* Do the replacement when the text at the cursor matches. Thus no
4571 * replacement is done if the cursor was moved! */
4572 regmatch.regprog = vim_regcomp(ga.ga_data, RE_MAGIC + RE_STRING);
4573 regmatch.rm_ic = 0;
4574 if (regmatch.regprog != NULL)
4575 {
4576 p = ml_get_cursor();
4577 if (vim_regexec_nl(&regmatch, p, (colnr_T)0)
4578 && regmatch.startp[0] == p)
4579 {
4580 /* Clear the command line to remove any old "No match"
4581 * error. */
4582 msg_end_prompt();
4583
4584 if (u_save_cursor() == OK)
4585 {
4586 /* A button was pressed thus undo should be synced. */
4587 if (no_u_sync == 0)
4588 u_sync();
4589
4590 del_bytes((long)(regmatch.endp[0] - regmatch.startp[0]),
4591 FALSE);
4592 ins_str(repl_text);
4593 }
4594 }
4595 else
4596 MSG(_("No match at cursor, finding next"));
4597 vim_free(regmatch.regprog);
4598 }
4599 }
4600
4601 if (type == FRD_REPLACEALL)
4602 {
4582 /* A button was pressed, thus undo should be synced. */ 4603 /* A button was pressed, thus undo should be synced. */
4583 if (no_u_sync == 0) 4604 if (no_u_sync == 0)
4584 u_sync(); 4605 u_sync();
4585
4586 ga_concat(&ga, (char_u *)"/");
4587 concat_esc(&ga, repl_text, '/'); /* escape slashes */
4588 ga_concat(&ga, (char_u *)"/g");
4589 ga_append(&ga, NUL);
4590 do_cmdline_cmd(ga.ga_data); 4606 do_cmdline_cmd(ga.ga_data);
4591 } 4607 }
4592 else 4608 else
4593 { 4609 {
4594 /* Search for the next match. */ 4610 /* Search for the next match. */
4595 i = msg_scroll; 4611 i = msg_scroll;
4596 ga_append(&ga, NUL);
4597 do_search(NULL, down ? '/' : '?', ga.ga_data, 1L, 4612 do_search(NULL, down ? '/' : '?', ga.ga_data, 1L,
4598 SEARCH_MSG + SEARCH_MARK); 4613 SEARCH_MSG + SEARCH_MARK);
4599 msg_scroll = i; /* don't let an error message set msg_scroll */ 4614 msg_scroll = i; /* don't let an error message set msg_scroll */
4600 } 4615 }
4601 4616