Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2011-05-07 21:52:44 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2011-05-07 21:52:44 +0400
commit471c28f91c489d40ae80561ce4d9629d2f152292 (patch)
treede175451299ed2115202f761500e67161b656b08 /source/blender
parente239085f70173b631861e58aede62484e246246e (diff)
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
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenkernel/BKE_text.h2
-rw-r--r--source/blender/blenkernel/intern/text.c8
-rw-r--r--source/blender/editors/space_text/text_ops.c17
-rw-r--r--source/blender/makesdna/DNA_space_types.h1
-rw-r--r--source/blender/makesrna/intern/rna_space.c5
5 files changed, 25 insertions, 8 deletions
diff --git a/source/blender/blenkernel/BKE_text.h b/source/blender/blenkernel/BKE_text.h
index 136ce416037..20e5bc27146 100644
--- a/source/blender/blenkernel/BKE_text.h
+++ b/source/blender/blenkernel/BKE_text.h
@@ -58,7 +58,7 @@ void write_text(struct Text *text, const char *str);
char* txt_to_buf (struct Text *text);
void txt_clean_text (struct Text *text);
void txt_order_cursors (struct Text *text);
-int txt_find_string (struct Text *text, char *findstr, int wrap);
+int txt_find_string (struct Text *text, char *findstr, int wrap, int match_case);
int txt_has_sel (struct Text *text);
int txt_get_span (struct TextLine *from, struct TextLine *to);
void txt_move_up (struct Text *text, short sel);
diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c
index ba5d4282416..512914e2c52 100644
--- a/source/blender/blenkernel/intern/text.c
+++ b/source/blender/blenkernel/intern/text.c
@@ -1232,7 +1232,7 @@ char *txt_to_buf (Text *text)
return buf;
}
-int txt_find_string(Text *text, char *findstr, int wrap)
+int txt_find_string(Text *text, char *findstr, int wrap, int match_case)
{
TextLine *tl, *startl;
char *s= NULL;
@@ -1246,7 +1246,8 @@ int txt_find_string(Text *text, char *findstr, int wrap)
oldsl= txt_get_span(text->lines.first, text->sell);
tl= startl= text->sell;
- s= strstr(&tl->line[text->selc], findstr);
+ if(match_case) s= strstr(&tl->line[text->selc], findstr);
+ else s= BLI_strcasestr(&tl->line[text->selc], findstr);
while (!s) {
tl= tl->next;
if (!tl) {
@@ -1256,7 +1257,8 @@ int txt_find_string(Text *text, char *findstr, int wrap)
break;
}
- s= strstr(tl->line, findstr);
+ if(match_case) s= strstr(tl->line, findstr);
+ else s= BLI_strcasestr(tl->line, findstr);
if (tl==startl)
break;
}
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;
diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h
index 7cb0c9456db..e120cd14775 100644
--- a/source/blender/makesdna/DNA_space_types.h
+++ b/source/blender/makesdna/DNA_space_types.h
@@ -824,6 +824,7 @@ enum {
#define ST_FIND_WRAP 0x0020
#define ST_FIND_ALL 0x0040
#define ST_SHOW_MARGIN 0x0080
+#define ST_MATCH_CASE 0x0100
/* stext->findstr/replacestr */
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index 75225f01598..59824d6a752 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -1825,6 +1825,11 @@ static void rna_def_space_text(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Find Wrap", "Search again from the start of the file when reaching the end");
RNA_def_property_update(prop, NC_SPACE|ND_SPACE_TEXT, NULL);
+ prop= RNA_def_property(srna, "use_match_case", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flags", ST_MATCH_CASE);
+ RNA_def_property_ui_text(prop, "Match case", "Search string is sensitive to uppercase and lowercase letters");
+ RNA_def_property_update(prop, NC_SPACE|ND_SPACE_TEXT, NULL);
+
prop= RNA_def_property(srna, "find_text", PROP_STRING, PROP_NONE);
RNA_def_property_string_sdna(prop, NULL, "findstr");
RNA_def_property_ui_text(prop, "Find Text", "Text to search for with the find tool");