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:
authorCampbell Barton <ideasman42@gmail.com>2009-07-16 04:50:27 +0400
committerCampbell Barton <ideasman42@gmail.com>2009-07-16 04:50:27 +0400
commit2f74b5a2605d3bb83f6c7500f9d3899296bfbb59 (patch)
treec1b951cd060da50afce59791dbbd123347d18a46 /source/blender/makesrna
parentce431c5c6e17877846812bab2d6bf9f8dc40fd48 (diff)
Console Space Type
* interactive console python console. * display reports and filter types. defaults to operator display so you can see the python commands for tools as you use them, eventually it should be possible to select commands and make macto/tools from them. Example use of autocomp. b<tab>, bpy.<tab>, bpy.<tab>, bpy.data.<tab> etc. basic instructions are printed when opening the console. Details... * Console exec and autocomp are done with operators written in python. * added CTX_wm_reports() to get the global report list. * The window manager had a report ListBase but reports have their own struct, switched to allocate and assign when initializing the WM since the type is not available in DNA. * changed report types flags for easier display filtering. * added report type RPT_OPERATOR * logging operators also adds a python-syntax report into CTX_wm_reports() so they can be displayed in the console as well as calling a notifier for console to redraw. * RnaAPI context.area.tag_redraw() to redraw the current area from a python operator. Todo... * better interactions with the console, scrolling, copy/paste. * the text displayed doesnt load back. * colors need to be themed. * scroll limit needs to be a user pref. * only tested with cmake and scons.
Diffstat (limited to 'source/blender/makesrna')
-rw-r--r--source/blender/makesrna/RNA_access.h1
-rw-r--r--source/blender/makesrna/intern/rna_screen.c11
-rw-r--r--source/blender/makesrna/intern/rna_space.c134
3 files changed, 146 insertions, 0 deletions
diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h
index ed1a8052acd..a04a09d4d11 100644
--- a/source/blender/makesrna/RNA_access.h
+++ b/source/blender/makesrna/RNA_access.h
@@ -371,6 +371,7 @@ extern StructRNA RNA_SoundSequence;
extern StructRNA RNA_Space;
extern StructRNA RNA_Space3DView;
extern StructRNA RNA_SpaceButtonsWindow;
+extern StructRNA RNA_SpaceConsole;
extern StructRNA RNA_SpaceDopeSheetEditor;
extern StructRNA RNA_SpaceGraphEditor;
extern StructRNA RNA_SpaceImageEditor;
diff --git a/source/blender/makesrna/intern/rna_screen.c b/source/blender/makesrna/intern/rna_screen.c
index fb836a98a52..e3171d38932 100644
--- a/source/blender/makesrna/intern/rna_screen.c
+++ b/source/blender/makesrna/intern/rna_screen.c
@@ -43,6 +43,9 @@ EnumPropertyItem region_type_items[] = {
#ifdef RNA_RUNTIME
+#include "ED_screen.h"
+
+
#include "WM_api.h"
#include "WM_types.h"
@@ -97,15 +100,23 @@ static void rna_def_scrarea(BlenderRNA *brna)
prop= RNA_def_property(srna, "show_menus", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", HEADER_NO_PULLDOWN);
RNA_def_property_ui_text(prop, "Show Menus", "Show menus in the header.");
+
+ RNA_def_function(srna, "tag_redraw", "ED_area_tag_redraw");
}
static void rna_def_region(BlenderRNA *brna)
{
StructRNA *srna;
+ PropertyRNA *prop;
srna= RNA_def_struct(brna, "Region", NULL);
RNA_def_struct_ui_text(srna, "Region", "Region in a subdivided screen area.");
RNA_def_struct_sdna(srna, "ARegion");
+
+ prop= RNA_def_property(srna, "id", PROP_INT, PROP_NONE);
+ RNA_def_property_int_sdna(prop, NULL, "swinid");
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_ui_text(prop, "Region ID", "Uniqute ID for this region.");
}
static void rna_def_bscreen(BlenderRNA *brna)
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