Tab as Space as a User Preference option. to affect new and loaded text files.

* I put it under General->System. Not sure is the better place for it though (space_userpref.py)
** also: creator.c fix to avoid autoplay of games when scripts are disabled.
This commit is contained in:
Dalai Felinto
2010-03-06 21:45:46 +00:00
parent 50b13f0a56
commit 782cb1f0e0
5 changed files with 14 additions and 5 deletions

View File

@@ -423,6 +423,7 @@ class USERPREF_PT_system(bpy.types.Panel):
col.prop(system, "frame_server_port")
col.prop(system, "scrollback", text="Console Scrollback")
col.prop(system, "auto_execute_scripts")
col.prop(system, "tabs_as_spaces")
col.separator()
col.separator()

View File

@@ -190,7 +190,9 @@ Text *add_empty_text(char *name)
init_undo_text(ta);
ta->nlines=1;
ta->flags= TXT_ISDIRTY | TXT_ISMEM | TXT_TABSTOSPACES;
ta->flags= TXT_ISDIRTY | TXT_ISMEM;
if(U.flag & USER_TXT_TABSTOSPACES)
ta->flags |= TXT_TABSTOSPACES;
ta->lines.first= ta->lines.last= NULL;
ta->markers.first= ta->markers.last= NULL;
@@ -354,9 +356,10 @@ Text *add_text(char *file, const char *relpath)
ta->lines.first= ta->lines.last= NULL;
ta->markers.first= ta->markers.last= NULL;
ta->curl= ta->sell= NULL;
ta->flags= TXT_TABSTOSPACES;
if(U.flag & USER_TXT_TABSTOSPACES)
ta->flags= TXT_TABSTOSPACES;
fseek(fp, 0L, SEEK_END);
len= ftell(fp);
fseek(fp, 0L, SEEK_SET);

View File

@@ -406,6 +406,7 @@ extern UserDef U; /* from blenkernel blender.c */
#define USER_SCRIPT_AUTOEXEC_DISABLE (1 << 22)
#define USER_FILENOUI (1 << 23)
#define USER_NONEGFRAMES (1 << 24)
#define USER_TXT_TABSTOSPACES (1 << 25)
/* helper macro for checking frame clamping */
#define FRAMENUMBER_MIN_CLAMP(cfra) \

View File

@@ -2358,6 +2358,10 @@ static void rna_def_userdef_system(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Auto Run Python Scripts", "Allow any .blend file to run scripts automatically (unsafe with blend files from an untrusted source)");
RNA_def_property_update(prop, 0, "rna_userdef_script_autoexec_update");
prop= RNA_def_property(srna, "tabs_as_spaces", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", USER_TXT_TABSTOSPACES);
RNA_def_property_ui_text(prop, "Tabs as Spaces", "Automatically converts all new tabs into spaces in Text Editor");
prop= RNA_def_property(srna, "prefetch_frames", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "prefetchframes");
RNA_def_property_range(prop, 0, 500);

View File

@@ -1038,7 +1038,7 @@ int main(int argc, char **argv)
}
else {
if(G.fileflags & G_FILE_AUTOPLAY){
if((G.fileflags & (G_FILE_AUTOPLAY | G_SCRIPT_AUTOEXEC)){
WM_init_game(C);
}