From 471c28f91c489d40ae80561ce4d9629d2f152292 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sat, 7 May 2011 17:52:44 +0000 Subject: Fix #27319: Text editor "Find" does not locate words. Added new option to find panel of space text which toggles case-esensitive search. Additional changes: - Send NC_TEXT|NA_EDITED when removing markers in find_and_replace modifier this prevents "sticked" markers which disappears on first redraw when search text wasn't found - Do not show "Text wasn't found" error when text to be searched is contained in the end of buffer and it's selected. Replacing/marking used to happen, but this popup message was really annoying for this case. TODO: It's incorrect to use UI_GetThemeColor4ubv from this operator --- source/blender/editors/space_text/text_ops.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index c0c928dcb24..e87719084ce 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -2841,8 +2841,14 @@ static int find_and_replace(bContext *C, wmOperator *op, short mode) flags ^= ST_FIND_WRAP; do { - if(first) + int proceed= 0; + + if(first) { + if(text->markers.first) + WM_event_add_notifier(C, NC_TEXT|NA_EDITED, text); + txt_clear_markers(text, TMARK_GRP_FINDALL, 0); + } first= 0; @@ -2850,7 +2856,10 @@ static int find_and_replace(bContext *C, wmOperator *op, short mode) if(mode!=TEXT_FIND && txt_has_sel(text)) { tmp= txt_sel_to_buf(text); - if(strcmp(st->findstr, tmp)==0) { + if(flags & ST_MATCH_CASE) proceed= strcmp(st->findstr, tmp)==0; + else proceed= BLI_strcasecmp(st->findstr, tmp)==0; + + if(proceed) { if(mode==TEXT_REPLACE) { txt_insert_buf(text, st->replacestr); if(text->curl && text->curl->format) { @@ -2880,7 +2889,7 @@ static int find_and_replace(bContext *C, wmOperator *op, short mode) } /* Find next */ - if(txt_find_string(text, st->findstr, flags & ST_FIND_WRAP)) { + if(txt_find_string(text, st->findstr, flags & ST_FIND_WRAP, flags & ST_MATCH_CASE)) { text_update_cursor_moved(C); WM_event_add_notifier(C, NC_TEXT|ND_CURSOR, text); } @@ -2897,7 +2906,7 @@ static int find_and_replace(bContext *C, wmOperator *op, short mode) first= 1; } else { - if(!found) BKE_reportf(op->reports, RPT_ERROR, "Text not found: %s", st->findstr); + if(!found && !proceed) BKE_reportf(op->reports, RPT_ERROR, "Text not found: %s", st->findstr); break; } found = 1; -- cgit v1.2.3