diff options
Diffstat (limited to 'source/blender/blenkernel/intern/text.c')
-rw-r--r-- | source/blender/blenkernel/intern/text.c | 55 |
1 files changed, 28 insertions, 27 deletions
diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index 19bc853276a..1bd41c7aa86 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -36,6 +36,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" +#include "BLI_utildefines.h" #include "DNA_constraint_types.h" #include "DNA_controller_types.h" @@ -51,9 +52,9 @@ #include "BKE_library.h" #include "BKE_main.h" #include "BKE_text.h" -#include "BKE_utildefines.h" -#ifndef DISABLE_PYTHON + +#ifdef WITH_PYTHON #include "BPY_extern.h" #endif @@ -93,7 +94,7 @@ TMARK_EDITALL is set the group ID defines which other markers should be edited. The mrk->clr field is used to visually group markers where the flags may not match. A template system, for example, may allow editing of repeating tokens (in one group) but include other marked positions (in another group) all in the -same template with the same colour. +same template with the same color. Undo -- @@ -167,12 +168,12 @@ void free_text(Text *text) if(text->name) MEM_freeN(text->name); MEM_freeN(text->undo_buf); -#ifndef DISABLE_PYTHON - if (text->compiled) BPY_free_compiled_text(text); +#ifdef WITH_PYTHON + if (text->compiled) BPY_text_free_code(text); #endif } -Text *add_empty_text(char *name) +Text *add_empty_text(const char *name) { Main *bmain= G.main; Text *ta; @@ -241,7 +242,7 @@ int reopen_text(Text *text) if (!text || !text->name) return 0; BLI_strncpy(str, text->name, FILE_MAXDIR+FILE_MAXFILE); - BLI_path_abs(str, G.sce); + BLI_path_abs(str, G.main->name); fp= fopen(str, "r"); if(fp==NULL) return 0; @@ -279,7 +280,6 @@ int reopen_text(Text *text) text->mtime= st.st_mtime; text->nlines=0; - i=0; llen=0; for(i=0; i<len; i++) { if (buffer[i]=='\n') { @@ -325,7 +325,7 @@ int reopen_text(Text *text) return 1; } -Text *add_text(char *file, const char *relpath) +Text *add_text(const char *file, const char *relpath) { Main *bmain= G.main; FILE *fp; @@ -521,7 +521,7 @@ void unlink_text(Main *bmain, Text *text) } if(update) - DAG_id_flush_update(&ob->id, OB_RECALC_DATA); + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); } /* pynodes */ @@ -559,7 +559,7 @@ void clear_text(Text *text) /* called directly from rna */ txt_make_dirty(text); } -void write_text(Text *text, char *str) /* called directly from rna */ +void write_text(Text *text, const char *str) /* called directly from rna */ { int oldstate; @@ -585,7 +585,7 @@ static void make_new_line (TextLine *line, char *newline) line->format= NULL; } -static TextLine *txt_new_line(char *str) +static TextLine *txt_new_line(const char *str) { TextLine *tmp; @@ -683,8 +683,8 @@ int txt_get_span (TextLine *from, TextLine *to) static void txt_make_dirty (Text *text) { text->flags |= TXT_ISDIRTY; -#ifndef DISABLE_PYTHON - if (text->compiled) BPY_free_compiled_text(text); +#ifdef WITH_PYTHON + if (text->compiled) BPY_text_free_code(text); #endif } @@ -991,8 +991,8 @@ void txt_move_to (Text *text, unsigned int line, unsigned int ch, short sel) if ((*linep)->next) *linep= (*linep)->next; else break; } - if (ch>(*linep)->len) - ch= (*linep)->len; + if (ch>(unsigned int)((*linep)->len)) + ch= (unsigned int)((*linep)->len); *charp= ch; if(!sel) txt_pop_sel(text); @@ -1232,7 +1232,7 @@ int txt_find_string(Text *text, char *findstr, int wrap) { TextLine *tl, *startl; char *s= NULL; - int oldcl, oldsl, oldcc, oldsc; + int oldcl, oldsl; if (!text || !text->curl || !text->sell) return 0; @@ -1241,8 +1241,6 @@ int txt_find_string(Text *text, char *findstr, int wrap) oldcl= txt_get_span(text->lines.first, text->curl); oldsl= txt_get_span(text->lines.first, text->sell); tl= startl= text->sell; - oldcc= text->curc; - oldsc= text->selc; s= strstr(&tl->line[text->selc], findstr); while (!s) { @@ -1431,7 +1429,7 @@ void txt_print_undo(Text *text) { int i= 0; int op; - char *ops; + const char *ops; int linep, charp; dump_buffer(text); @@ -2219,7 +2217,6 @@ static void txt_combine_lines (Text *text, TextLine *linea, TextLine *lineb) } while (mrk && mrk->lineno==lineno); } if (lineno==-1) lineno= txt_get_span(text->lines.first, lineb); - if (!mrk) mrk= text->markers.first; tmp= MEM_mallocN(linea->len+lineb->len+1, "textline_string"); @@ -2470,7 +2467,7 @@ void indent(Text *text) int len, num; char *tmp; - char *add = "\t"; + const char *add = "\t"; int indentlen = 1; /* hardcoded: TXT_TABSIZE = 4 spaces: */ @@ -2531,7 +2528,7 @@ void indent(Text *text) void unindent(Text *text) { int num = 0; - char *remove = "\t"; + const char *remove = "\t"; int indent = 1; /* hardcoded: TXT_TABSIZE = 4 spaces: */ @@ -2694,7 +2691,7 @@ int setcurr_tab_spaces (Text *text, int space) const char *word = ":"; const char *comm = "#"; const char indent= (text->flags & TXT_TABSTOSPACES) ? ' ' : '\t'; - static char *back_words[]= {"return", "break", "continue", "pass", "yield", NULL}; + static const char *back_words[]= {"return", "break", "continue", "pass", "yield", NULL}; if (!text) return 0; if (!text->curl) return 0; @@ -2710,9 +2707,13 @@ int setcurr_tab_spaces (Text *text, int space) } if(strstr(text->curl->line, word)) { - //if we find a : then add a tab but not if it is in a comment + /* if we find a ':' on this line, then add a tab but not if it is: + * 1) in a comment + * 2) within an identifier + * 3) after the cursor (text->curc), i.e. when creating space before a function def [#25414] + */ int a, indent = 0; - for(a=0; text->curl->line[a] != '\0'; a++) + for(a=0; (a < text->curc) && (text->curl->line[a] != '\0'); a++) { if (text->curl->line[a]=='#') { break; @@ -2746,7 +2747,7 @@ int setcurr_tab_spaces (Text *text, int space) /*********************************/ /* Creates and adds a marker to the list maintaining sorted order */ -void txt_add_marker(Text *text, TextLine *line, int start, int end, char color[4], int group, int flags) { +void txt_add_marker(Text *text, TextLine *line, int start, int end, const unsigned char color[4], int group, int flags) { TextMarker *tmp, *marker; marker= MEM_mallocN(sizeof(TextMarker), "text_marker"); |