diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2015-09-24 18:24:20 +0300 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2015-09-24 18:24:20 +0300 |
commit | 27b3ea622f8bd313a8e2827dfec752bf2125566c (patch) | |
tree | f212e49d224ce8e1cfc3b17a64ae524711494391 /source/blender/editors/space_console | |
parent | 372dff8d1dc7e24d4b2cd37de245588ecfce8bfa (diff) | |
parent | de80e687689032cb85179a1f7e89750573631d5d (diff) |
Merge remote-tracking branch 'origin/master' into cycles_camera_nodescycles_camera_nodes
Note: the branch currently crashes in blender_camera_nodes.cpp:
BL::NodeTree b_ntree = b_data.node_groups[nodes_tree_name];
The crash was introduced in:
cb7cf523e5c000609f32a382e2c0fcc57f635a42
Conflicts:
intern/cycles/SConscript
intern/cycles/blender/addon/__init__.py
intern/cycles/blender/addon/properties.py
intern/cycles/blender/blender_camera.cpp
intern/cycles/kernel/kernel_types.h
intern/cycles/kernel/svm/svm.h
intern/cycles/kernel/svm/svm_types.h
intern/cycles/render/camera.cpp
intern/cycles/render/camera.h
Diffstat (limited to 'source/blender/editors/space_console')
6 files changed, 105 insertions, 8 deletions
diff --git a/source/blender/editors/space_console/CMakeLists.txt b/source/blender/editors/space_console/CMakeLists.txt index 241a48c1e2d..ecfb1f0e0df 100644 --- a/source/blender/editors/space_console/CMakeLists.txt +++ b/source/blender/editors/space_console/CMakeLists.txt @@ -23,10 +23,12 @@ set(INC ../../blenfont ../../blenkernel ../../blenlib + ../../gpu ../../makesdna ../../makesrna ../../windowmanager ../../../../intern/guardedalloc + ../../../../intern/glew-mx ) set(INC_SYS @@ -45,4 +47,6 @@ if(WITH_PYTHON) add_definitions(-DWITH_PYTHON) endif() +add_definitions(${GL_DEFINITIONS}) + blender_add_lib(bf_editor_space_console "${SRC}" "${INC}" "${INC_SYS}") diff --git a/source/blender/editors/space_console/SConscript b/source/blender/editors/space_console/SConscript index 0395a33cd97..f189cd3920a 100644 --- a/source/blender/editors/space_console/SConscript +++ b/source/blender/editors/space_console/SConscript @@ -28,16 +28,20 @@ Import ('env') sources = env.Glob('*.c') + defs = [] +defs += env['BF_GL_DEFINITIONS'] incs = [ '../include', - '#/extern/glew/include', '#/intern/guardedalloc', + env['BF_GLEW_INC'], + '#/intern/glew-mx', '../../makesdna', '../../makesrna', '../../blenkernel', '../../blenlib', + '../../gpu', '../../windowmanager', '../../blenfont', ] diff --git a/source/blender/editors/space_console/console_draw.c b/source/blender/editors/space_console/console_draw.c index 635d5ea07fd..d206ce4699e 100644 --- a/source/blender/editors/space_console/console_draw.c +++ b/source/blender/editors/space_console/console_draw.c @@ -30,7 +30,6 @@ #include <sys/stat.h> #include <limits.h> -#include "BLF_api.h" #include "BLI_blenlib.h" #include "BLI_utildefines.h" diff --git a/source/blender/editors/space_console/console_intern.h b/source/blender/editors/space_console/console_intern.h index 00f1f8c21c9..d8a4a6fd2bb 100644 --- a/source/blender/editors/space_console/console_intern.h +++ b/source/blender/editors/space_console/console_intern.h @@ -31,7 +31,6 @@ struct ConsoleLine; struct wmOperatorType; -struct ReportList; struct bContext; /* console_draw.c */ @@ -66,6 +65,7 @@ void CONSOLE_OT_history_cycle(struct wmOperatorType *ot); void CONSOLE_OT_copy(struct wmOperatorType *ot); void CONSOLE_OT_paste(struct wmOperatorType *ot); void CONSOLE_OT_select_set(struct wmOperatorType *ot); +void CONSOLE_OT_select_word(struct wmOperatorType *ot); enum { LINE_BEGIN, LINE_END, PREV_CHAR, NEXT_CHAR, PREV_WORD, NEXT_WORD }; enum { DEL_ALL, DEL_NEXT_CHAR, DEL_PREV_CHAR, DEL_NEXT_WORD, DEL_PREV_WORD, DEL_SELECTION, DEL_NEXT_SEL, DEL_PREV_SEL }; diff --git a/source/blender/editors/space_console/console_ops.c b/source/blender/editors/space_console/console_ops.c index b44e942527c..92731c2f135 100644 --- a/source/blender/editors/space_console/console_ops.c +++ b/source/blender/editors/space_console/console_ops.c @@ -95,7 +95,7 @@ static void console_scrollback_limit(SpaceConsole *sc) if (U.scrollback < 32) U.scrollback = 256; // XXX - save in user defaults - for (tot = BLI_countlist(&sc->scrollback); tot > U.scrollback; tot--) + for (tot = BLI_listbase_count(&sc->scrollback); tot > U.scrollback; tot--) console_scrollback_free(sc, sc->scrollback.first); } @@ -107,7 +107,7 @@ static ConsoleLine *console_history_find(SpaceConsole *sc, const char *str, Cons if (cl == cl_ignore) continue; - if (strcmp(str, cl->line) == 0) + if (STREQ(str, cl->line)) return cl; } @@ -136,7 +136,7 @@ static void console_lb_debug__internal(ListBase *lb) { ConsoleLine *cl; - printf("%d: ", BLI_countlist(lb)); + printf("%d: ", BLI_listbase_count(lb)); for (cl = lb->first; cl; cl = cl->next) printf("<%s> ", cl->line); printf("\n"); @@ -262,6 +262,40 @@ static int console_line_insert(ConsoleLine *ci, char *str) return len; } +/** + * Take an absolute index and give the line/column info. + * + * \note be sure to call console_scrollback_prompt_begin first + */ +static bool console_line_column_from_index( + SpaceConsole *sc, const int pos, + ConsoleLine **r_cl, int *r_cl_offset, int *r_col) +{ + ConsoleLine *cl; + int offset = 0; + + for (cl = sc->scrollback.last; cl; cl = cl->prev) { + offset += cl->len + 1; + if (offset >= pos) { + break; + } + } + + if (cl) { + offset -= 1; + *r_cl = cl; + *r_cl_offset = offset; + *r_col = offset - pos; + return true; + } + else { + *r_cl = NULL; + *r_cl_offset = -1; + *r_col = -1; + return false; + } +} + /* static funcs for text editing */ /* similar to the text editor, with some not used. keep compatible */ @@ -722,7 +756,7 @@ static int console_history_cycle_exec(bContext *C, wmOperator *op) if (ci->prev) { ConsoleLine *ci_prev = (ConsoleLine *)ci->prev; - if (strcmp(ci->line, ci_prev->line) == 0) + if (STREQ(ci->line, ci_prev->line)) console_history_free(sc, ci_prev); } @@ -791,7 +825,7 @@ static int console_history_append_exec(bContext *C, wmOperator *op) while ((cl = console_history_find(sc, ci->line, ci))) console_history_free(sc, cl); - if (strcmp(str, ci->line) == 0) { + if (STREQ(str, ci->line)) { MEM_freeN(str); return OPERATOR_FINISHED; } @@ -1134,3 +1168,57 @@ void CONSOLE_OT_select_set(wmOperatorType *ot) ot->cancel = console_modal_select_cancel; ot->poll = ED_operator_console_active; } + +static int console_selectword_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event) +{ + SpaceConsole *sc = CTX_wm_space_console(C); + ARegion *ar = CTX_wm_region(C); + + ConsoleLine cl_dummy = {NULL}; + ConsoleLine *cl; + int ret = OPERATOR_CANCELLED; + int pos, offset, n; + + pos = console_char_pick(sc, ar, event->mval); + + console_scrollback_prompt_begin(sc, &cl_dummy); + + if (console_line_column_from_index(sc, pos, &cl, &offset, &n)) { + int sel[2] = {n, n}; + + BLI_str_cursor_step_utf8( + cl->line, cl->len, + &sel[0], STRCUR_DIR_NEXT, + STRCUR_JUMP_DELIM, true); + + BLI_str_cursor_step_utf8( + cl->line, cl->len, + &sel[1], STRCUR_DIR_PREV, + STRCUR_JUMP_DELIM, true); + + sel[0] = offset - sel[0]; + sel[1] = offset - sel[1]; + + if ((sel[0] != sc->sel_start) || (sel[1] != sc->sel_end)) { + sc->sel_start = sel[0]; + sc->sel_end = sel[1]; + ED_area_tag_redraw(CTX_wm_area(C)); + ret = OPERATOR_FINISHED; + } + } + + console_scrollback_prompt_end(sc, &cl_dummy); + return ret; +} + +void CONSOLE_OT_select_word(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Select Word"; + ot->description = "Select word at cursor position"; + ot->idname = "CONSOLE_OT_select_word"; + + /* api callbacks */ + ot->invoke = console_selectword_invoke; + ot->poll = ED_operator_console_active; +} diff --git a/source/blender/editors/space_console/space_console.c b/source/blender/editors/space_console/space_console.c index e4a61a8f06e..a592f35f629 100644 --- a/source/blender/editors/space_console/space_console.c +++ b/source/blender/editors/space_console/space_console.c @@ -270,6 +270,7 @@ static void console_operatortypes(void) WM_operatortype_append(CONSOLE_OT_copy); WM_operatortype_append(CONSOLE_OT_paste); WM_operatortype_append(CONSOLE_OT_select_set); + WM_operatortype_append(CONSOLE_OT_select_word); } static void console_keymap(struct wmKeyConfig *keyconf) @@ -348,6 +349,7 @@ static void console_keymap(struct wmKeyConfig *keyconf) #endif WM_keymap_add_item(keymap, "CONSOLE_OT_select_set", LEFTMOUSE, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "CONSOLE_OT_select_word", LEFTMOUSE, KM_DBL_CLICK, 0, 0); RNA_string_set(WM_keymap_add_item(keymap, "CONSOLE_OT_insert", TABKEY, KM_PRESS, KM_CTRL, 0)->ptr, "text", "\t"); /* fake tabs */ |