diff options
author | Campbell Barton <ideasman42@gmail.com> | 2008-09-27 19:32:28 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2008-09-27 19:32:28 +0400 |
commit | ff6d4e84cb97a29f1f51a1335a83314792265429 (patch) | |
tree | fd84bf8bbf8a39e960a39e0b7cd96f4bac0519bc /source/blender/src/drawtext.c | |
parent | fe5dd015956bd2a4cab9e0161daf6bac2faf5a3f (diff) |
text editor changes
* out of sync text dosnt automatically popup a menu anymore since it was too easy to click on it without intending to, moved this to an alert button on the header.
* "_" character was acting as a delimiter, but in python its not.
* renamed "File" to "Text" (so as not to confuse with blenders file menu)
* added redraw_alltext function to remove many duplicate loops where every text display is redrawn.
Diffstat (limited to 'source/blender/src/drawtext.c')
-rw-r--r-- | source/blender/src/drawtext.c | 188 |
1 files changed, 27 insertions, 161 deletions
diff --git a/source/blender/src/drawtext.c b/source/blender/src/drawtext.c index 3120d1931e4..7f913eb5d49 100644 --- a/source/blender/src/drawtext.c +++ b/source/blender/src/drawtext.c @@ -30,22 +30,12 @@ #include <stdlib.h> #include <math.h> #include <string.h> -#include <ctype.h> -#include <sys/types.h> -#include <sys/stat.h> #ifdef HAVE_CONFIG_H #include <config.h> #endif -#ifndef _WIN32 -#include <unistd.h> -#else -#include <io.h> -#include "BLI_winstuff.h" -#endif #include "MEM_guardedalloc.h" -#include "PIL_time.h" #include "BMF_Api.h" @@ -88,6 +78,8 @@ #include "blendef.h" #include "winlay.h" +#include <sys/stat.h> + /***********************/ /* Notes on word-wrap @@ -133,6 +125,7 @@ void drawtextspace(ScrArea *sa, void *spacedata); void winqreadtextspace(struct ScrArea *sa, void *spacedata, struct BWinEvent *evt); void txt_copy_selectbuffer (Text *text); void draw_brackets(SpaceText *st); +void redraw_alltext(void); static void get_selection_buffer(Text *text); static int check_bracket(char ch); @@ -152,7 +145,6 @@ static char *g_find_str= NULL; static char *g_replace_str= NULL; static int doc_scroll= 0; -static double last_check_time= 0; static int jump_to= 0; static double last_jump= 0; @@ -1763,60 +1755,6 @@ void free_textspace(SpaceText *st) st->text= NULL; } -/* returns 0 if file on disk is the same or Text is in memory only - returns 1 if file has been modified on disk since last local edit - returns 2 if file on disk has been deleted - -1 is returned if an error occurs -*/ -int txt_file_modified(Text *text) -{ - struct stat st; - int result; - char file[FILE_MAXDIR+FILE_MAXFILE]; - - if (!text || !text->name) - return 0; - - BLI_strncpy(file, text->name, FILE_MAXDIR+FILE_MAXFILE); - BLI_convertstringcode(file, G.sce); - - if (!BLI_exists(file)) - return 2; - - result = stat(file, &st); - - if(result == -1) - return -1; - - if((st.st_mode & S_IFMT) != S_IFREG) - return -1; - - if (st.st_mtime > text->mtime) - return 1; - - return 0; -} - -void txt_ignore_modified(Text *text) { - struct stat st; - int result; - char file[FILE_MAXDIR+FILE_MAXFILE]; - - if (!text || !text->name) return; - - BLI_strncpy(file, text->name, FILE_MAXDIR+FILE_MAXFILE); - BLI_convertstringcode(file, G.sce); - - if (!BLI_exists(file)) return; - - result = stat(file, &st); - - if(result == -1 || (st.st_mode & S_IFMT) != S_IFREG) - return; - - text->mtime= st.st_mtime; -} - static void save_mem_text(char *str) { SpaceText *st= curarea->spacedata.first; @@ -2459,18 +2397,9 @@ static short do_texttools(SpaceText *st, char ascii, unsigned short evnt, short } } - if (draw) { - ScrArea *sa; - - for (sa= G.curscreen->areabase.first; sa; sa= sa->next) { - SpaceText *st= sa->spacedata.first; - - if (st && st->spacetype==SPACE_TEXT) { - scrarea_queue_redraw(sa); - } - } - } - + if (draw) + redraw_alltext(); + return swallow; } @@ -2632,80 +2561,12 @@ static short do_markers(SpaceText *st, char ascii, unsigned short evnt, short va } } - if (draw) { - ScrArea *sa; - - for (sa= G.curscreen->areabase.first; sa; sa= sa->next) { - SpaceText *st= sa->spacedata.first; - - if (st && st->spacetype==SPACE_TEXT) { - scrarea_queue_redraw(sa); - } - } - } + if (draw) + redraw_alltext(); + return swallow; } -static short do_modification_check(SpaceText *st) { - Text *text= st->text; - - if (last_check_time < PIL_check_seconds_timer() - 2.0) { - switch (txt_file_modified(text)) { - case 1: - /* Modified locally and externally, ahhh. Offer more possibilites. */ - if (text->flags & TXT_ISDIRTY) { - switch (pupmenu("File Modified Outside and Inside Blender %t|Load outside changes (ignore local changes) %x0|Save local changes (ignore outside changes) %x1|Make text internal (separate copy) %x2")) { - case 0: - reopen_text(text); - if (st->showsyntax) txt_format_text(st); - return 1; - case 1: - txt_write_file(text); - return 1; - case 2: - text->flags |= TXT_ISMEM | TXT_ISDIRTY | TXT_ISTMP; - MEM_freeN(text->name); - text->name= NULL; - return 1; - } - } else { - switch (pupmenu("File Modified Outside Blender %t|Reload from disk %x0|Make text internal (separate copy) %x1|Ignore %x2")) { - case 0: - if (text->compiled) BPY_free_compiled_text(text); - text->compiled = NULL; - reopen_text(text); - if (st->showsyntax) txt_format_text(st); - return 1; - case 1: - text->flags |= TXT_ISMEM | TXT_ISDIRTY | TXT_ISTMP; - MEM_freeN(text->name); - text->name= NULL; - return 1; - case 2: - txt_ignore_modified(text); - return 1; - } - } - break; - case 2: - switch (pupmenu("File Deleted Outside Blender %t|Make text internal %x0|Recreate file %x1")) { - case 0: - text->flags |= TXT_ISMEM | TXT_ISDIRTY | TXT_ISTMP; - MEM_freeN(text->name); - text->name= NULL; - return 1; - case 1: - txt_write_file(text); - return 1; - } - break; - default: - break; - } - last_check_time = PIL_check_seconds_timer(); - } - return 0; -} void winqreadtextspace(ScrArea *sa, void *spacedata, BWinEvent *evt) { @@ -3315,19 +3176,8 @@ void winqreadtextspace(ScrArea *sa, void *spacedata, BWinEvent *evt) } } - if (do_modification_check(st)) do_draw= 1; - - if (do_draw) { - ScrArea *sa; - - for (sa= G.curscreen->areabase.first; sa; sa= sa->next) { - SpaceText *st= sa->spacedata.first; - - if (st && st->spacetype==SPACE_TEXT) { - scrarea_queue_redraw(sa); - } - } - } + if (do_draw) + redraw_alltext(); } void draw_brackets(SpaceText *st) @@ -3582,3 +3432,19 @@ void convert_tabs (struct SpaceText *st, int tab) if (st->showsyntax) txt_format_text(st); } + +void redraw_alltext(void) +{ + ScrArea *sa; + + if(!G.curscreen) + return; + + for (sa= G.curscreen->areabase.first; sa; sa= sa->next) { + SpaceText *st= sa->spacedata.first; + + if (st && st->spacetype==SPACE_TEXT) { + scrarea_queue_redraw(sa); + } + } +} |