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:
Diffstat (limited to 'source/blender/editors/space_text')
-rw-r--r--source/blender/editors/space_text/CMakeLists.txt14
-rw-r--r--source/blender/editors/space_text/text_draw.c2
-rw-r--r--source/blender/editors/space_text/text_header.c14
-rw-r--r--source/blender/editors/space_text/text_ops.c52
-rw-r--r--source/blender/editors/space_text/text_python.c2
5 files changed, 53 insertions, 31 deletions
diff --git a/source/blender/editors/space_text/CMakeLists.txt b/source/blender/editors/space_text/CMakeLists.txt
index 6241d397417..acf00d205a6 100644
--- a/source/blender/editors/space_text/CMakeLists.txt
+++ b/source/blender/editors/space_text/CMakeLists.txt
@@ -23,12 +23,15 @@ set(INC
../include
../../blenfont
../../blenkernel
- ../../blenloader
../../blenlib
+ ../../blenloader
../../makesdna
../../makesrna
../../windowmanager
../../../../intern/guardedalloc
+)
+
+set(INC_SYS
${GLEW_INCLUDE_PATH}
)
@@ -43,8 +46,13 @@ set(SRC
)
if(WITH_PYTHON)
- list(APPEND INC ${PYTHON_INCLUDE_DIRS} ../../python)
+ list(APPEND INC
+ ../../python
+ )
+ list(APPEND INC_SYS
+ ${PYTHON_INCLUDE_DIRS}
+ )
add_definitions(-DWITH_PYTHON)
endif()
-blender_add_lib(bf_editor_text "${SRC}" "${INC}")
+blender_add_lib(bf_editor_text "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/blender/editors/space_text/text_draw.c b/source/blender/editors/space_text/text_draw.c
index 2601d1ffdf3..625e5561389 100644
--- a/source/blender/editors/space_text/text_draw.c
+++ b/source/blender/editors/space_text/text_draw.c
@@ -1495,6 +1495,8 @@ static void draw_cursor(SpaceText *st, ARegion *ar)
glRecti(x-4, y, ar->winx, y-st->lheight), y-=st->lheight;
glRecti(x-4, y, x+toc*st->cwidth, y-st->lheight); y-=st->lheight;
+
+ (void)y;
}
}
else {
diff --git a/source/blender/editors/space_text/text_header.c b/source/blender/editors/space_text/text_header.c
index bfc600c774a..165cec238c0 100644
--- a/source/blender/editors/space_text/text_header.c
+++ b/source/blender/editors/space_text/text_header.c
@@ -55,6 +55,7 @@
#include "BLI_utildefines.h"
#include "BKE_context.h"
+#include "BKE_screen.h"
#include "ED_screen.h"
@@ -78,16 +79,13 @@
static ARegion *text_has_properties_region(ScrArea *sa)
{
ARegion *ar, *arnew;
-
- for(ar= sa->regionbase.first; ar; ar= ar->next)
- if(ar->regiontype==RGN_TYPE_UI)
- return ar;
+
+ ar= BKE_area_find_region_type(sa, RGN_TYPE_UI);
+ if(ar) return ar;
/* add subdiv level; after header */
- for(ar= sa->regionbase.first; ar; ar= ar->next)
- if(ar->regiontype==RGN_TYPE_HEADER)
- break;
-
+ ar= BKE_area_find_region_type(sa, RGN_TYPE_HEADER);
+
/* is error! */
if(ar==NULL) return NULL;
diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c
index c0c928dcb24..13eb24ed1f2 100644
--- a/source/blender/editors/space_text/text_ops.c
+++ b/source/blender/editors/space_text/text_ops.c
@@ -36,6 +36,7 @@
#include <string.h>
#include <ctype.h> /* ispunct */
#include <sys/stat.h>
+#include <errno.h>
#include "MEM_guardedalloc.h"
@@ -449,15 +450,14 @@ static void txt_write_file(Text *text, ReportList *reports)
FILE *fp;
TextLine *tmp;
struct stat st;
- int res;
- char file[FILE_MAXDIR+FILE_MAXFILE];
+ char filepath[FILE_MAXDIR+FILE_MAXFILE];
- BLI_strncpy(file, text->name, FILE_MAXDIR+FILE_MAXFILE);
- BLI_path_abs(file, G.main->name);
+ BLI_strncpy(filepath, text->name, FILE_MAXDIR+FILE_MAXFILE);
+ BLI_path_abs(filepath, G.main->name);
- fp= fopen(file, "w");
+ fp= fopen(filepath, "w");
if(fp==NULL) {
- BKE_report(reports, RPT_ERROR, "Unable to save file.");
+ BKE_reportf(reports, RPT_ERROR, "Unable to save \"%s\": %s.", filepath, errno ? strerror(errno) : "Unknown error writing file");
return;
}
@@ -471,8 +471,13 @@ static void txt_write_file(Text *text, ReportList *reports)
fclose (fp);
- res= stat(file, &st);
- text->mtime= st.st_mtime;
+ if(stat(filepath, &st) == 0) {
+ text->mtime= st.st_mtime;
+ }
+ else {
+ text->mtime= 0;
+ BKE_reportf(reports, RPT_WARNING, "Unable to stat \"%s\": %s.", filepath, errno ? strerror(errno) : "Unknown error starrng file");
+ }
if(text->flags & TXT_ISDIRTY)
text->flags ^= TXT_ISDIRTY;
@@ -894,7 +899,7 @@ static int indent_exec(bContext *C, wmOperator *UNUSED(op))
if(txt_has_sel(text)) {
txt_order_cursors(text);
- indent(text);
+ txt_indent(text);
}
else
txt_add_char(text, '\t');
@@ -929,7 +934,7 @@ static int unindent_exec(bContext *C, wmOperator *UNUSED(op))
text_drawcache_tag_update(CTX_wm_space_text(C), 0);
txt_order_cursors(text);
- unindent(text);
+ txt_unindent(text);
text_update_edited(text);
@@ -1011,7 +1016,7 @@ static int comment_exec(bContext *C, wmOperator *UNUSED(op))
text_drawcache_tag_update(CTX_wm_space_text(C), 0);
txt_order_cursors(text);
- comment(text);
+ txt_comment(text);
text_update_edited(text);
text_update_cursor_moved(C);
@@ -1044,7 +1049,7 @@ static int uncomment_exec(bContext *C, wmOperator *UNUSED(op))
text_drawcache_tag_update(CTX_wm_space_text(C), 0);
txt_order_cursors(text);
- uncomment(text);
+ txt_uncomment(text);
text_update_edited(text);
text_update_cursor_moved(C);
@@ -2109,7 +2114,7 @@ static void scroll_apply(bContext *C, wmOperator *op, wmEvent *event)
SpaceText *st= CTX_wm_space_text(C);
ARegion *ar= CTX_wm_region(C);
TextScroll *tsc= op->customdata;
- short mval[2]= {event->x, event->y};
+ int mval[2]= {event->x, event->y};
short txtdelta[2] = {0, 0};
text_update_character_width(st);
@@ -2283,7 +2288,7 @@ static int scroll_bar_invoke(bContext *C, wmOperator *op, wmEvent *event)
SpaceText *st= CTX_wm_space_text(C);
ARegion *ar= CTX_wm_region(C);
TextScroll *tsc;
- const short *mval= event->mval;
+ const int *mval= event->mval;
int zone= -1;
if(RNA_property_is_set(op->ptr, "lines"))
@@ -2694,7 +2699,7 @@ static int line_number_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *even
SpaceText *st= CTX_wm_space_text(C);
Text *text= CTX_data_edit_text(C);
ARegion *ar= CTX_wm_region(C);
- const short *mval= event->mval;
+ const int *mval= event->mval;
double time;
static int jump_to= 0;
static double last_jump= 0;
@@ -2841,8 +2846,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 +2861,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 +2894,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 +2911,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/editors/space_text/text_python.c b/source/blender/editors/space_text/text_python.c
index bd8710ec120..6e6f131655b 100644
--- a/source/blender/editors/space_text/text_python.c
+++ b/source/blender/editors/space_text/text_python.c
@@ -54,7 +54,7 @@ int text_do_suggest_select(SpaceText *st, ARegion *ar)
TextLine *tmp;
int l, x, y, w, h, i;
int tgti, *top;
- short mval[2] = {0, 0};
+ int mval[2] = {0, 0};
if(!st || !st->text) return 0;
if(!texttool_text_is_active(st->text)) return 0;