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:
Diffstat (limited to 'source/blender/editors/space_console')
-rw-r--r--source/blender/editors/space_console/CMakeLists.txt7
-rw-r--r--source/blender/editors/space_console/console_intern.h2
-rw-r--r--source/blender/editors/space_console/console_ops.c2
-rw-r--r--source/blender/editors/space_console/space_console.c46
4 files changed, 52 insertions, 5 deletions
diff --git a/source/blender/editors/space_console/CMakeLists.txt b/source/blender/editors/space_console/CMakeLists.txt
index 345ab8b0970..51523bcb383 100644
--- a/source/blender/editors/space_console/CMakeLists.txt
+++ b/source/blender/editors/space_console/CMakeLists.txt
@@ -5,11 +5,15 @@ set(INC
../../blenfont
../../blenkernel
../../blenlib
+ ../../blenloader
../../gpu
../../makesdna
../../makesrna
../../windowmanager
../../../../intern/guardedalloc
+
+ # dna_type_offsets.h
+ ${CMAKE_CURRENT_BINARY_DIR}/../../makesdna/intern
)
set(SRC
@@ -31,3 +35,6 @@ endif()
blender_add_lib(bf_editor_space_console "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
+
+# dna_type_offsets.h
+add_dependencies(bf_editor_space_console bf_dna)
diff --git a/source/blender/editors/space_console/console_intern.h b/source/blender/editors/space_console/console_intern.h
index deaaff05a33..8e2ebc9b8e9 100644
--- a/source/blender/editors/space_console/console_intern.h
+++ b/source/blender/editors/space_console/console_intern.h
@@ -15,7 +15,7 @@ struct wmOperatorType;
/* console_draw.c */
void console_textview_main(struct SpaceConsole *sc, const struct ARegion *region);
-/* needed to calculate the scrollbar */
+/* Needed to calculate the scroll-bar. */
int console_textview_height(struct SpaceConsole *sc, const struct ARegion *region);
int console_char_pick(struct SpaceConsole *sc, const struct ARegion *region, const int mval[2]);
diff --git a/source/blender/editors/space_console/console_ops.c b/source/blender/editors/space_console/console_ops.c
index ef22b1b9f0b..11234d446da 100644
--- a/source/blender/editors/space_console/console_ops.c
+++ b/source/blender/editors/space_console/console_ops.c
@@ -280,7 +280,7 @@ static bool console_line_column_from_index(
return false;
}
-/* static funcs for text editing */
+/* Static functions for text editing. */
/* similar to the text editor, with some not used. keep compatible */
static const EnumPropertyItem console_move_type_items[] = {
diff --git a/source/blender/editors/space_console/space_console.c b/source/blender/editors/space_console/space_console.c
index 8af0c1fc6ab..0abb108d5e8 100644
--- a/source/blender/editors/space_console/space_console.c
+++ b/source/blender/editors/space_console/space_console.c
@@ -28,6 +28,8 @@
#include "UI_resources.h"
#include "UI_view2d.h"
+#include "BLO_read_write.h"
+
#include "console_intern.h" /* own include */
/* ******************** default callbacks for console space ***************** */
@@ -121,13 +123,14 @@ static void console_main_region_init(wmWindowManager *wm, ARegion *region)
region->v2d.cur.ymax = prev_y_min + cur_y_range;
}
- keymap = WM_keymap_ensure(wm->defaultconf, "View2D Buttons List", 0, 0);
- WM_event_add_keymap_handler(&region->handlers, keymap);
-
/* own keymap */
keymap = WM_keymap_ensure(wm->defaultconf, "Console", SPACE_CONSOLE, 0);
WM_event_add_keymap_handler_v2d_mask(&region->handlers, keymap);
+ /* Include after "Console" so cursor motion keys such as "Home" isn't overridden. */
+ keymap = WM_keymap_ensure(wm->defaultconf, "View2D Buttons List", 0, 0);
+ WM_event_add_keymap_handler(&region->handlers, keymap);
+
/* add drop boxes */
lb = WM_dropboxmap_find("Console", SPACE_CONSOLE, RGN_TYPE_WINDOW);
@@ -283,6 +286,41 @@ static void console_main_region_listener(const wmRegionListenerParams *params)
}
}
+static void console_blend_read_data(BlendDataReader *reader, SpaceLink *sl)
+{
+ SpaceConsole *sconsole = (SpaceConsole *)sl;
+
+ BLO_read_list(reader, &sconsole->scrollback);
+ BLO_read_list(reader, &sconsole->history);
+
+ /* Comma expressions, (e.g. expr1, expr2, expr3) evaluate each expression,
+ * from left to right. the right-most expression sets the result of the comma
+ * expression as a whole. */
+ LISTBASE_FOREACH_MUTABLE (ConsoleLine *, cl, &sconsole->history) {
+ BLO_read_data_address(reader, &cl->line);
+ if (cl->line) {
+ /* The allocated length is not written, so reset here. */
+ cl->len_alloc = cl->len + 1;
+ }
+ else {
+ BLI_remlink(&sconsole->history, cl);
+ MEM_freeN(cl);
+ }
+ }
+}
+
+static void console_blend_write(BlendWriter *writer, SpaceLink *sl)
+{
+ SpaceConsole *con = (SpaceConsole *)sl;
+
+ LISTBASE_FOREACH (ConsoleLine *, cl, &con->history) {
+ /* 'len_alloc' is invalid on write, set from 'len' on read */
+ BLO_write_struct(writer, ConsoleLine, cl);
+ BLO_write_raw(writer, (size_t)cl->len + 1, cl->line);
+ }
+ BLO_write_struct(writer, SpaceConsole, sl);
+}
+
void ED_spacetype_console(void)
{
SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype console");
@@ -298,6 +336,8 @@ void ED_spacetype_console(void)
st->operatortypes = console_operatortypes;
st->keymap = console_keymap;
st->dropboxes = console_dropboxes;
+ st->blend_read_data = console_blend_read_data;
+ st->blend_write = console_blend_write;
/* regions: main window */
art = MEM_callocN(sizeof(ARegionType), "spacetype console region");