diff options
Diffstat (limited to 'source/blender/makesrna/intern/rna_space.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_space.c | 134 |
1 files changed, 134 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 697548de817..fb41262b812 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -24,6 +24,8 @@ #include <stdlib.h> +#include "MEM_guardedalloc.h" + #include "RNA_access.h" #include "RNA_define.h" #include "RNA_types.h" @@ -56,6 +58,7 @@ EnumPropertyItem space_type_items[] = { {SPACE_TIME, "TIMELINE", 0, "Timeline", ""}, {SPACE_NODE, "NODE_EDITOR", 0, "Node Editor", ""}, {SPACE_LOGIC, "LOGIC_EDITOR", 0, "Logic Editor", ""}, + {SPACE_CONSOLE, "CONSOLE", 0, "Console", ""}, {0, NULL, 0, NULL, NULL}}; #define DC_RGB {0, "COLOR", ICON_IMAGE_RGB, "Color", "Draw image with RGB colors."} @@ -122,6 +125,8 @@ static StructRNA* rna_Space_refine(struct PointerRNA *ptr) return &RNA_SpaceNodeEditor; case SPACE_LOGIC: return &RNA_SpaceLogicEditor;*/ + case SPACE_CONSOLE: + return &RNA_SpaceConsole; default: return &RNA_Space; } @@ -234,6 +239,46 @@ StructRNA *rna_SpaceButtonsWindow_pin_id_typef(PointerRNA *ptr) return &RNA_ID; } +/* Space Console */ +static void rna_ConsoleLine_line_get(PointerRNA *ptr, char *value) +{ + ConsoleLine *ci= (ConsoleLine*)ptr->data; + strcpy(value, ci->line); +} + +static int rna_ConsoleLine_line_length(PointerRNA *ptr) +{ + ConsoleLine *ci= (ConsoleLine*)ptr->data; + return ci->len; +} + +static void rna_ConsoleLine_line_set(PointerRNA *ptr, const char *value) +{ + ConsoleLine *ci= (ConsoleLine*)ptr->data; + int len= strlen(value); + + if(len < ci->len_alloc) { /* allocated size is enough? */ + strcpy(ci->line, value); + } + else { /* allocate a new strnig */ + MEM_freeN(ci->line); + ci->line= BLI_strdup(value); + ci->len_alloc= len; + } + ci->len= len; + + if(ci->cursor > len) /* clamp the cursor */ + ci->cursor= len; +} + +static void rna_ConsoleLine_cursor_index_range(PointerRNA *ptr, int *min, int *max) +{ + ConsoleLine *ci= (ConsoleLine*)ptr->data; + + *min= 0; + *max= ci->len; +} + #else static void rna_def_space(BlenderRNA *brna) @@ -987,6 +1032,93 @@ static void rna_def_space_nla(BlenderRNA *brna) // TODO... autosnap, dopesheet? } +static void rna_def_console_line(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "ConsoleLine", NULL); + RNA_def_struct_ui_text(srna, "Console Input", "Input line for the interactive console."); + + prop= RNA_def_property(srna, "line", PROP_STRING, PROP_NONE); + RNA_def_property_string_funcs(prop, "rna_ConsoleLine_line_get", "rna_ConsoleLine_line_length", "rna_ConsoleLine_line_set"); + RNA_def_property_ui_text(prop, "Line", "Text in the line."); + + prop= RNA_def_property(srna, "current_character", PROP_INT, PROP_NONE); /* copied from text editor */ + RNA_def_property_int_sdna(prop, NULL, "cursor"); + RNA_def_property_int_funcs(prop, NULL, NULL, "rna_ConsoleLine_cursor_index_range"); + +} + +static EnumPropertyItem console_type_items[] = { + {CONSOLE_TYPE_PYTHON, "PYTHON", 0, "Python", ""}, + {CONSOLE_TYPE_REPORT, "REPORT", 0, "Report", ""}, + {0, NULL, 0, NULL, NULL}}; + +static void rna_def_space_console(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna= RNA_def_struct(brna, "SpaceConsole", "Space"); + RNA_def_struct_sdna(srna, "SpaceConsole"); + RNA_def_struct_ui_text(srna, "Space Console", "Interactive python console."); + + /* display */ + prop= RNA_def_property(srna, "font_size", PROP_INT, PROP_NONE); /* copied from text editor */ + RNA_def_property_int_sdna(prop, NULL, "lheight"); + RNA_def_property_range(prop, 8, 32); + RNA_def_property_ui_text(prop, "Font Size", "Font size to use for displaying the text."); + RNA_def_property_update(prop, NC_CONSOLE | ND_CONSOLE, NULL); + + prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, console_type_items); + RNA_def_property_ui_text(prop, "Type", "Console type."); + RNA_def_property_update(prop, NC_CONSOLE | ND_CONSOLE, NULL); + + /* reporting display */ + prop= RNA_def_property(srna, "show_report_debug", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "rpt_mask", CONSOLE_RPT_DEBUG); + RNA_def_property_ui_text(prop, "Show Debug", "Display debug reporting info."); + RNA_def_property_update(prop, NC_CONSOLE | ND_CONSOLE_REPORT, NULL); + + prop= RNA_def_property(srna, "show_report_info", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "rpt_mask", CONSOLE_RPT_INFO); + RNA_def_property_ui_text(prop, "Show Info", "Display general information."); + RNA_def_property_update(prop, NC_CONSOLE | ND_CONSOLE_REPORT, NULL); + + prop= RNA_def_property(srna, "show_report_operator", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "rpt_mask", CONSOLE_RPT_OP); + RNA_def_property_ui_text(prop, "Show Operator", "Display the operator log."); + RNA_def_property_update(prop, NC_CONSOLE | ND_CONSOLE_REPORT, NULL); + + prop= RNA_def_property(srna, "show_report_warn", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "rpt_mask", CONSOLE_RPT_WARN); + RNA_def_property_ui_text(prop, "Show Warn", "Display warnings."); + RNA_def_property_update(prop, NC_CONSOLE | ND_CONSOLE_REPORT, NULL); + + prop= RNA_def_property(srna, "show_report_error", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "rpt_mask", CONSOLE_RPT_ERR); + RNA_def_property_ui_text(prop, "Show Error", "Display error text."); + RNA_def_property_update(prop, NC_CONSOLE | ND_CONSOLE_REPORT, NULL); + + + + prop= RNA_def_property(srna, "prompt", PROP_STRING, PROP_NONE); + RNA_def_property_ui_text(prop, "Prompt", "Command line prompt."); + RNA_def_struct_name_property(srna, prop); + + prop= RNA_def_property(srna, "history", PROP_COLLECTION, PROP_NONE); + RNA_def_property_collection_sdna(prop, NULL, "history", NULL); + RNA_def_property_struct_type(prop, "ConsoleLine"); + RNA_def_property_ui_text(prop, "History", "Command history."); + + prop= RNA_def_property(srna, "scrollback", PROP_COLLECTION, PROP_NONE); + RNA_def_property_collection_sdna(prop, NULL, "scrollback", NULL); + RNA_def_property_struct_type(prop, "ConsoleLine"); + RNA_def_property_ui_text(prop, "Output", "Command output."); +} + static void rna_def_fileselect_params(BlenderRNA *brna) { StructRNA *srna; @@ -1127,6 +1259,8 @@ void RNA_def_space(BlenderRNA *brna) rna_def_space_dopesheet(brna); rna_def_space_graph(brna); rna_def_space_nla(brna); + rna_def_space_console(brna); + rna_def_console_line(brna); } #endif |