To: vim-dev@vim.org Subject: Patch 5.5.073 Fcc: outbox From: Bram Moolenaar ------------ Patch 5.5.073 (extra) Problem: Win 32 GUI: The Find and Find/Replace dialogs didn't show the "match case" checkbox. The Find/Replace dialog didn't handle the "match whole word" checkbox. Solution: Support the "match case" and "match whole word" checkboxes. Files: src/gui_w32.c *** ../vim-5.5.72/src/gui_w32.c Sun Oct 24 19:27:14 1999 --- src/gui_w32.c Thu Dec 16 15:41:43 1999 *************** *** 1473,1478 **** --- 1473,1506 ---- } #ifdef WIN32_FIND_REPLACE + static void + fr_setwhat(char_u *cmd) + { + if (s_findrep_struct.Flags & FR_WHOLEWORD) + STRCAT(cmd, "\\<"); + STRCAT(cmd, s_findrep_struct.lpstrFindWhat); + if (s_findrep_struct.Flags & FR_WHOLEWORD) + STRCAT(cmd, "\\>"); + } + + static void + fr_setreplcmd(char_u *cmd) + { + STRCAT(cmd, ":%sno/"); + fr_setwhat(cmd); + STRCAT(cmd, "/"); + STRCAT(cmd, s_findrep_struct.lpstrReplaceWith); + if (s_findrep_struct.Flags & FR_REPLACE) + STRCAT(cmd, "/gc"); + else + STRCAT(cmd, "/g"); + if (s_findrep_struct.Flags & FR_MATCHCASE) + STRCAT(cmd, "I"); + else + STRCAT(cmd, "i"); + STRCAT(cmd, "\r"); + } + /* * Handle a Find/Replace window message. */ *************** *** 1484,1490 **** /* Add a char before the command if needed */ if (State & INSERT) cmd[0] = Ctrl('O'); ! else if ((State | NORMAL) == 0 && State != CONFIRM) cmd[0] = ESC; else cmd[0] = NUL; --- 1512,1518 ---- /* Add a char before the command if needed */ if (State & INSERT) cmd[0] = Ctrl('O'); ! else if ((State & NORMAL) == 0 && State != CONFIRM) cmd[0] = ESC; else cmd[0] = NUL; *************** *** 1507,1524 **** } else { if (s_findrep_struct.Flags & FR_DOWN) STRCAT(cmd, "/"); else STRCAT(cmd, "?"); ! ! if (s_findrep_struct.Flags & FR_WHOLEWORD) ! STRCAT(cmd, "\\<"); ! STRCAT(cmd, s_findrep_struct.lpstrFindWhat); ! if (s_findrep_struct.Flags & FR_WHOLEWORD) ! STRCAT(cmd, "\\>"); ! STRCAT(cmd, "\r"); } /* * Give main window the focus back: this is so --- 1535,1565 ---- } else { + /* Set 'ignorecase' just for this search command. */ + if (!(s_findrep_struct.Flags & FR_MATCHCASE) == !p_ic) + { + if (p_ic) + STRCAT(cmd, ":set noic\r"); + else + STRCAT(cmd, ":set ic\r"); + if (State & INSERT) + STRCAT(cmd, "\017"); /* CTRL-O */ + } if (s_findrep_struct.Flags & FR_DOWN) STRCAT(cmd, "/"); else STRCAT(cmd, "?"); ! fr_setwhat(cmd); STRCAT(cmd, "\r"); + if (!(s_findrep_struct.Flags & FR_MATCHCASE) == !p_ic) + { + if (State & INSERT) + STRCAT(cmd, "\017"); /* CTRL-O */ + if (p_ic) + STRCAT(cmd, ":set ic\r"); + else + STRCAT(cmd, ":set noic\r"); + } } /* * Give main window the focus back: this is so *************** *** 1529,1545 **** else if (s_findrep_struct.Flags & FR_REPLACE) { if (State == CONFIRM) - { STRCAT(cmd, "y"); - } else ! { ! STRCAT(cmd, ":%sno/"); ! STRCAT(cmd, s_findrep_struct.lpstrFindWhat); ! STRCAT(cmd, "/"); ! STRCAT(cmd, s_findrep_struct.lpstrReplaceWith); ! STRCAT(cmd, "/gc\r"); ! } /* * Give main window the focus back: this is to allow * handling of the confirmation y/n/a/q stuff. --- 1570,1578 ---- else if (s_findrep_struct.Flags & FR_REPLACE) { if (State == CONFIRM) STRCAT(cmd, "y"); else ! fr_setreplcmd(cmd); /* * Give main window the focus back: this is to allow * handling of the confirmation y/n/a/q stuff. *************** *** 1549,1565 **** else if (s_findrep_struct.Flags & FR_REPLACEALL) { if (State == CONFIRM) - { STRCAT(cmd, "a"); - } else ! { ! STRCAT(cmd, ":%sno/"); ! STRCAT(cmd, s_findrep_struct.lpstrFindWhat); ! STRCAT(cmd, "/"); ! STRCAT(cmd, s_findrep_struct.lpstrReplaceWith); ! STRCAT(cmd, "/g\r"); ! } } if (*cmd) add_to_input_buf(cmd, STRLEN(cmd)); --- 1582,1590 ---- else if (s_findrep_struct.Flags & FR_REPLACEALL) { if (State == CONFIRM) STRCAT(cmd, "a"); else ! fr_setreplcmd(cmd); } if (*cmd) add_to_input_buf(cmd, STRLEN(cmd)); *************** *** 5664,5674 **** initialise_findrep(char_u *initial_string) { s_findrep_struct.hwndOwner = s_hwnd; ! s_findrep_struct.Flags = FR_HIDEMATCHCASE | FR_DOWN; if (initial_string != NULL && *initial_string != NUL) { STRCPY(s_findrep_struct.lpstrFindWhat, initial_string); ! s_findrep_struct.lpstrReplaceWith[0] = NUL; } } #endif --- 5689,5703 ---- initialise_findrep(char_u *initial_string) { s_findrep_struct.hwndOwner = s_hwnd; ! s_findrep_struct.Flags = FR_DOWN; ! if (p_ic) ! s_findrep_struct.Flags &= ~FR_MATCHCASE; ! else ! s_findrep_struct.Flags |= FR_MATCHCASE; if (initial_string != NULL && *initial_string != NUL) { STRCPY(s_findrep_struct.lpstrFindWhat, initial_string); ! s_findrep_struct.lpstrReplaceWith[0] = NUL; } } #endif *** ../vim-5.5.72/src/version.c Thu Dec 16 16:06:45 1999 --- src/version.c Thu Dec 16 16:07:03 1999 *************** *** 420,420 **** --- 420,421 ---- { /* Add new patch number below this line */ + 73, -- CRONE: Who sent you? ARTHUR: The Knights Who Say Ni! CRONE: Aaaagh! (she looks around in rear) No! We have no shrubberies here. "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD --/-/---- Bram Moolenaar ---- Bram@moolenaar.net ---- Bram@vim.org ---\-\-- \ \ www.vim.org/iccf www.moolenaar.net www.vim.org / /