2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2009-07-16 00:50:27 +00:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2009-07-16 00:50:27 +00:00
|
|
|
*
|
|
|
|
* Contributor(s): Campbell Barton
|
|
|
|
*
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
*/
|
2011-02-27 20:29:51 +00:00
|
|
|
|
|
|
|
/** \file blender/editors/space_console/space_console.c
|
|
|
|
* \ingroup spconsole
|
|
|
|
*/
|
|
|
|
|
2011-02-14 17:55:27 +00:00
|
|
|
#include <string.h>
|
2009-07-16 00:50:27 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
|
2010-05-08 07:25:26 +00:00
|
|
|
#ifdef WIN32
|
|
|
|
#include "BLI_winstuff.h"
|
|
|
|
#endif
|
2009-07-16 00:50:27 +00:00
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
|
|
#include "BLI_blenlib.h"
|
2009-11-10 20:43:45 +00:00
|
|
|
#include "BLI_math.h"
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BLI_utildefines.h"
|
2009-07-16 00:50:27 +00:00
|
|
|
|
|
|
|
#include "BKE_context.h"
|
|
|
|
#include "BKE_screen.h"
|
2010-08-10 15:14:19 +00:00
|
|
|
#include "BKE_idcode.h"
|
2009-07-16 00:50:27 +00:00
|
|
|
|
2011-02-14 17:55:27 +00:00
|
|
|
#include "ED_space_api.h"
|
2009-07-16 00:50:27 +00:00
|
|
|
#include "ED_screen.h"
|
|
|
|
|
|
|
|
#include "BIF_gl.h"
|
|
|
|
|
|
|
|
#include "RNA_access.h"
|
|
|
|
|
|
|
|
#include "WM_api.h"
|
|
|
|
#include "WM_types.h"
|
|
|
|
|
|
|
|
#include "UI_resources.h"
|
|
|
|
#include "UI_view2d.h"
|
|
|
|
|
|
|
|
#include "console_intern.h" // own include
|
|
|
|
|
|
|
|
/* ******************** default callbacks for console space ***************** */
|
|
|
|
|
2010-10-13 23:46:42 +00:00
|
|
|
static SpaceLink *console_new(const bContext *UNUSED(C))
|
2009-07-16 00:50:27 +00:00
|
|
|
{
|
|
|
|
ARegion *ar;
|
|
|
|
SpaceConsole *sconsole;
|
|
|
|
|
|
|
|
sconsole= MEM_callocN(sizeof(SpaceConsole), "initconsole");
|
|
|
|
sconsole->spacetype= SPACE_CONSOLE;
|
|
|
|
|
|
|
|
sconsole->lheight= 14;
|
|
|
|
|
|
|
|
/* header */
|
|
|
|
ar= MEM_callocN(sizeof(ARegion), "header for console");
|
|
|
|
|
|
|
|
BLI_addtail(&sconsole->regionbase, ar);
|
|
|
|
ar->regiontype= RGN_TYPE_HEADER;
|
|
|
|
ar->alignment= RGN_ALIGN_BOTTOM;
|
|
|
|
|
|
|
|
|
|
|
|
/* main area */
|
|
|
|
ar= MEM_callocN(sizeof(ARegion), "main area for text");
|
|
|
|
|
|
|
|
BLI_addtail(&sconsole->regionbase, ar);
|
|
|
|
ar->regiontype= RGN_TYPE_WINDOW;
|
|
|
|
|
2010-11-11 13:36:57 +00:00
|
|
|
/* keep in sync with info */
|
2009-07-17 12:35:57 +00:00
|
|
|
ar->v2d.scroll |= (V2D_SCROLL_RIGHT);
|
2009-07-16 22:47:27 +00:00
|
|
|
ar->v2d.align |= V2D_ALIGN_NO_NEG_X|V2D_ALIGN_NO_NEG_Y; /* align bottom left */
|
|
|
|
ar->v2d.keepofs |= V2D_LOCKOFS_X;
|
2009-07-29 22:57:53 +00:00
|
|
|
ar->v2d.keepzoom = (V2D_LOCKZOOM_X|V2D_LOCKZOOM_Y|V2D_LIMITZOOM|V2D_KEEPASPECT);
|
2009-07-16 22:47:27 +00:00
|
|
|
ar->v2d.keeptot= V2D_KEEPTOT_BOUNDS;
|
2009-07-16 00:50:27 +00:00
|
|
|
ar->v2d.minzoom= ar->v2d.maxzoom= 1.0f;
|
2009-07-16 22:47:27 +00:00
|
|
|
|
|
|
|
/* for now, aspect ratio should be maintained, and zoom is clamped within sane default limits */
|
2009-07-29 22:57:53 +00:00
|
|
|
//ar->v2d.keepzoom= (V2D_KEEPASPECT|V2D_LIMITZOOM);
|
2009-07-16 22:47:27 +00:00
|
|
|
|
2009-07-16 00:50:27 +00:00
|
|
|
return (SpaceLink *)sconsole;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* not spacelink itself */
|
|
|
|
static void console_free(SpaceLink *sl)
|
|
|
|
{
|
|
|
|
SpaceConsole *sc= (SpaceConsole*) sl;
|
|
|
|
|
|
|
|
while(sc->scrollback.first)
|
|
|
|
console_scrollback_free(sc, sc->scrollback.first);
|
|
|
|
|
|
|
|
while(sc->history.first)
|
|
|
|
console_history_free(sc, sc->history.first);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* spacetype; init callback */
|
2010-10-13 23:46:42 +00:00
|
|
|
static void console_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa))
|
2009-07-16 00:50:27 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static SpaceLink *console_duplicate(SpaceLink *sl)
|
|
|
|
{
|
|
|
|
SpaceConsole *sconsolen= MEM_dupallocN(sl);
|
|
|
|
|
|
|
|
/* clear or remove stuff from old */
|
|
|
|
|
|
|
|
/* TODO - duplicate?, then we also need to duplicate the py namespace */
|
|
|
|
sconsolen->scrollback.first= sconsolen->scrollback.last= NULL;
|
|
|
|
sconsolen->history.first= sconsolen->history.last= NULL;
|
|
|
|
|
|
|
|
return (SpaceLink *)sconsolen;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* add handlers, stuff you only do once or on area/region changes */
|
|
|
|
static void console_main_area_init(wmWindowManager *wm, ARegion *ar)
|
|
|
|
{
|
2009-09-17 21:36:02 +00:00
|
|
|
wmKeyMap *keymap;
|
2010-05-08 07:25:26 +00:00
|
|
|
ListBase *lb;
|
2009-07-16 22:47:27 +00:00
|
|
|
|
2011-09-25 12:33:51 +00:00
|
|
|
const float prev_y_min= ar->v2d.cur.ymin; /* so resizing keeps the cursor visible */
|
2011-09-18 01:34:53 +00:00
|
|
|
|
2009-07-16 22:47:27 +00:00
|
|
|
UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy);
|
|
|
|
|
2011-09-18 01:34:53 +00:00
|
|
|
/* always keep the bottom part of the view aligned, less annoying */
|
|
|
|
if(prev_y_min != ar->v2d.cur.ymin) {
|
|
|
|
const float cur_y_range= ar->v2d.cur.ymax - ar->v2d.cur.ymin;
|
|
|
|
ar->v2d.cur.ymin= prev_y_min;
|
|
|
|
ar->v2d.cur.ymax= prev_y_min + cur_y_range;
|
|
|
|
}
|
|
|
|
|
2009-07-16 00:50:27 +00:00
|
|
|
/* own keymap */
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
keymap= WM_keymap_find(wm->defaultconf, "Console", SPACE_CONSOLE, 0);
|
2009-07-16 00:50:27 +00:00
|
|
|
WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
|
2010-05-08 07:25:26 +00:00
|
|
|
|
|
|
|
/* add drop boxes */
|
|
|
|
lb= WM_dropboxmap_find("Console", SPACE_CONSOLE, RGN_TYPE_WINDOW);
|
|
|
|
|
|
|
|
WM_event_add_dropbox_handler(&ar->handlers, lb);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* ************* dropboxes ************* */
|
|
|
|
|
2010-11-11 13:36:57 +00:00
|
|
|
static int id_drop_poll(bContext *UNUSED(C), wmDrag *drag, wmEvent *UNUSED(event))
|
2010-05-08 07:25:26 +00:00
|
|
|
{
|
2010-11-11 13:36:57 +00:00
|
|
|
// SpaceConsole *sc= CTX_wm_space_console(C);
|
|
|
|
if(drag->type==WM_DRAG_ID)
|
|
|
|
return 1;
|
2010-05-08 07:25:26 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void id_drop_copy(wmDrag *drag, wmDropBox *drop)
|
|
|
|
{
|
|
|
|
char text[64];
|
|
|
|
ID *id= drag->poin;
|
2011-08-23 15:08:54 +00:00
|
|
|
char id_esc[(sizeof(id->name) - 2) * 2];
|
2010-05-08 07:25:26 +00:00
|
|
|
|
2011-08-23 15:08:54 +00:00
|
|
|
BLI_strescape(id_esc, id->name+2, sizeof(id_esc));
|
|
|
|
|
2011-08-30 10:07:50 +00:00
|
|
|
BLI_snprintf(text, sizeof(text), "bpy.data.%s[\"%s\"]", BKE_idcode_to_name_plural(GS(id->name)), id_esc);
|
2010-05-08 07:25:26 +00:00
|
|
|
|
|
|
|
/* copy drag path to properties */
|
|
|
|
RNA_string_set(drop->ptr, "text", text);
|
2009-07-16 00:50:27 +00:00
|
|
|
}
|
|
|
|
|
2010-11-11 13:36:57 +00:00
|
|
|
static int path_drop_poll(bContext *UNUSED(C), wmDrag *drag, wmEvent *UNUSED(event))
|
2010-05-08 07:25:26 +00:00
|
|
|
{
|
2010-11-11 13:36:57 +00:00
|
|
|
// SpaceConsole *sc= CTX_wm_space_console(C);
|
|
|
|
if(drag->type==WM_DRAG_PATH)
|
|
|
|
return 1;
|
2010-05-08 07:25:26 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void path_drop_copy(wmDrag *drag, wmDropBox *drop)
|
|
|
|
{
|
2011-11-26 04:07:38 +00:00
|
|
|
char pathname[FILE_MAX+2];
|
2011-08-30 10:07:50 +00:00
|
|
|
BLI_snprintf(pathname, sizeof(pathname), "\"%s\"", drag->path);
|
2010-05-08 07:25:26 +00:00
|
|
|
RNA_string_set(drop->ptr, "text", pathname);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* this region dropbox definition */
|
|
|
|
static void console_dropboxes(void)
|
|
|
|
{
|
|
|
|
ListBase *lb= WM_dropboxmap_find("Console", SPACE_CONSOLE, RGN_TYPE_WINDOW);
|
|
|
|
|
|
|
|
WM_dropbox_add(lb, "CONSOLE_OT_insert", id_drop_poll, id_drop_copy);
|
|
|
|
WM_dropbox_add(lb, "CONSOLE_OT_insert", path_drop_poll, path_drop_copy);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ************* end drop *********** */
|
|
|
|
|
2009-07-16 00:50:27 +00:00
|
|
|
static void console_main_area_draw(const bContext *C, ARegion *ar)
|
|
|
|
{
|
|
|
|
/* draw entirely, view changes should be handled here */
|
|
|
|
SpaceConsole *sc= CTX_wm_space_console(C);
|
2009-07-16 22:47:27 +00:00
|
|
|
View2D *v2d= &ar->v2d;
|
|
|
|
View2DScrollers *scrollers;
|
2010-11-30 22:39:41 +00:00
|
|
|
|
2010-11-11 13:36:57 +00:00
|
|
|
if(sc->scrollback.first==NULL)
|
2009-11-05 11:17:09 +00:00
|
|
|
WM_operator_name_call((bContext *)C, "CONSOLE_OT_banner", WM_OP_EXEC_DEFAULT, NULL);
|
|
|
|
|
2009-07-16 22:47:27 +00:00
|
|
|
/* clear and setup matrix */
|
2010-04-06 07:02:16 +00:00
|
|
|
UI_ThemeClearColor(TH_BACK);
|
2009-07-16 22:47:27 +00:00
|
|
|
glClear(GL_COLOR_BUFFER_BIT);
|
|
|
|
|
|
|
|
/* worlks best with no view2d matrix set */
|
2010-10-14 01:22:14 +00:00
|
|
|
UI_view2d_view_ortho(v2d);
|
2009-07-16 22:47:27 +00:00
|
|
|
|
|
|
|
/* data... */
|
|
|
|
|
2009-07-16 00:50:27 +00:00
|
|
|
console_history_verify(C); /* make sure we have some command line */
|
2010-11-30 22:39:41 +00:00
|
|
|
console_textview_main(sc, ar);
|
2009-07-16 00:50:27 +00:00
|
|
|
|
|
|
|
/* reset view matrix */
|
2009-07-16 22:47:27 +00:00
|
|
|
UI_view2d_view_restore(C);
|
2009-07-16 00:50:27 +00:00
|
|
|
|
|
|
|
/* scrollers */
|
2009-07-16 22:47:27 +00:00
|
|
|
scrollers= UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_GRID_CLAMP);
|
2009-07-16 00:50:27 +00:00
|
|
|
UI_view2d_scrollers_draw(C, v2d, scrollers);
|
|
|
|
UI_view2d_scrollers_free(scrollers);
|
|
|
|
}
|
|
|
|
|
2011-02-14 17:55:27 +00:00
|
|
|
static void console_operatortypes(void)
|
2009-07-16 00:50:27 +00:00
|
|
|
{
|
2009-07-19 00:49:44 +00:00
|
|
|
/* console_ops.c */
|
2009-07-16 00:50:27 +00:00
|
|
|
WM_operatortype_append(CONSOLE_OT_move);
|
|
|
|
WM_operatortype_append(CONSOLE_OT_delete);
|
|
|
|
WM_operatortype_append(CONSOLE_OT_insert);
|
|
|
|
|
|
|
|
/* for use by python only */
|
|
|
|
WM_operatortype_append(CONSOLE_OT_history_append);
|
|
|
|
WM_operatortype_append(CONSOLE_OT_scrollback_append);
|
|
|
|
|
|
|
|
WM_operatortype_append(CONSOLE_OT_clear);
|
|
|
|
WM_operatortype_append(CONSOLE_OT_history_cycle);
|
2009-07-26 04:31:46 +00:00
|
|
|
WM_operatortype_append(CONSOLE_OT_copy);
|
2009-07-30 01:52:00 +00:00
|
|
|
WM_operatortype_append(CONSOLE_OT_paste);
|
2009-12-27 20:22:06 +00:00
|
|
|
WM_operatortype_append(CONSOLE_OT_select_set);
|
2009-07-16 00:50:27 +00:00
|
|
|
}
|
|
|
|
|
2011-02-14 17:55:27 +00:00
|
|
|
static void console_keymap(struct wmKeyConfig *keyconf)
|
2009-07-16 00:50:27 +00:00
|
|
|
{
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
wmKeyMap *keymap= WM_keymap_find(keyconf, "Console", SPACE_CONSOLE, 0);
|
2010-01-03 02:24:53 +00:00
|
|
|
wmKeyMapItem *kmi;
|
2009-07-16 00:50:27 +00:00
|
|
|
|
2009-09-22 16:23:46 +00:00
|
|
|
#ifdef __APPLE__
|
2009-07-16 00:50:27 +00:00
|
|
|
RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_move", LEFTARROWKEY, KM_PRESS, KM_OSKEY, 0)->ptr, "type", LINE_BEGIN);
|
2009-09-09 19:43:05 +00:00
|
|
|
RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_move", RIGHTARROWKEY, KM_PRESS, KM_OSKEY, 0)->ptr, "type", LINE_END);
|
2009-09-22 16:23:46 +00:00
|
|
|
#endif
|
2009-09-09 19:43:05 +00:00
|
|
|
|
2009-09-22 16:23:46 +00:00
|
|
|
RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_move", LEFTARROWKEY, KM_PRESS, KM_CTRL, 0)->ptr, "type", PREV_WORD);
|
|
|
|
RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_move", RIGHTARROWKEY, KM_PRESS, KM_CTRL, 0)->ptr, "type", NEXT_WORD);
|
2009-07-16 00:50:27 +00:00
|
|
|
|
|
|
|
RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_move", HOMEKEY, KM_PRESS, 0, 0)->ptr, "type", LINE_BEGIN);
|
|
|
|
RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_move", ENDKEY, KM_PRESS, 0, 0)->ptr, "type", LINE_END);
|
|
|
|
|
2010-01-03 02:24:53 +00:00
|
|
|
kmi = WM_keymap_add_item(keymap, "WM_OT_context_cycle_int", WHEELUPMOUSE, KM_PRESS, KM_CTRL, 0);
|
2010-06-14 03:52:10 +00:00
|
|
|
RNA_string_set(kmi->ptr, "data_path", "space_data.font_size");
|
2010-01-03 02:24:53 +00:00
|
|
|
RNA_boolean_set(kmi->ptr, "reverse", 0);
|
2009-07-16 00:50:27 +00:00
|
|
|
|
2010-01-03 02:24:53 +00:00
|
|
|
kmi = WM_keymap_add_item(keymap, "WM_OT_context_cycle_int", WHEELDOWNMOUSE, KM_PRESS, KM_CTRL, 0);
|
2010-06-14 03:52:10 +00:00
|
|
|
RNA_string_set(kmi->ptr, "data_path", "space_data.font_size");
|
2010-01-03 02:24:53 +00:00
|
|
|
RNA_boolean_set(kmi->ptr, "reverse", 1);
|
|
|
|
|
|
|
|
kmi = WM_keymap_add_item(keymap, "WM_OT_context_cycle_int", PADPLUSKEY, KM_PRESS, KM_CTRL, 0);
|
2010-06-14 03:52:10 +00:00
|
|
|
RNA_string_set(kmi->ptr, "data_path", "space_data.font_size");
|
2010-01-03 02:24:53 +00:00
|
|
|
RNA_boolean_set(kmi->ptr, "reverse", 0);
|
2009-07-16 00:50:27 +00:00
|
|
|
|
2010-01-03 02:24:53 +00:00
|
|
|
kmi = WM_keymap_add_item(keymap, "WM_OT_context_cycle_int", PADMINUS, KM_PRESS, KM_CTRL, 0);
|
2010-06-14 03:52:10 +00:00
|
|
|
RNA_string_set(kmi->ptr, "data_path", "space_data.font_size");
|
2010-01-03 02:24:53 +00:00
|
|
|
RNA_boolean_set(kmi->ptr, "reverse", 1);
|
|
|
|
|
2009-07-16 00:50:27 +00:00
|
|
|
RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_move", LEFTARROWKEY, KM_PRESS, 0, 0)->ptr, "type", PREV_CHAR);
|
|
|
|
RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_move", RIGHTARROWKEY, KM_PRESS, 0, 0)->ptr, "type", NEXT_CHAR);
|
|
|
|
|
|
|
|
RNA_boolean_set(WM_keymap_add_item(keymap, "CONSOLE_OT_history_cycle", UPARROWKEY, KM_PRESS, 0, 0)->ptr, "reverse", 1);
|
|
|
|
WM_keymap_add_item(keymap, "CONSOLE_OT_history_cycle", DOWNARROWKEY, KM_PRESS, 0, 0);
|
|
|
|
|
|
|
|
/*
|
|
|
|
RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_move", LEFTARROWKEY, KM_PRESS, KM_CTRL, 0)->ptr, "type", PREV_WORD);
|
|
|
|
RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_move", RIGHTARROWKEY, KM_PRESS, KM_CTRL, 0)->ptr, "type", NEXT_WORD);
|
|
|
|
RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_move", UPARROWKEY, KM_PRESS, 0, 0)->ptr, "type", PREV_LINE);
|
|
|
|
RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_move", DOWNARROWKEY, KM_PRESS, 0, 0)->ptr, "type", NEXT_LINE);
|
|
|
|
RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_move", PAGEUPKEY, KM_PRESS, 0, 0)->ptr, "type", PREV_PAGE);
|
|
|
|
RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_move", PAGEDOWNKEY, KM_PRESS, 0, 0)->ptr, "type", NEXT_PAGE);
|
|
|
|
|
|
|
|
|
|
|
|
//RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_delete", DELKEY, KM_PRESS, 0, 0)->ptr, "type", DEL_NEXT_CHAR);
|
|
|
|
RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_delete", DKEY, KM_PRESS, KM_CTRL, 0)->ptr, "type", DEL_NEXT_CHAR);
|
|
|
|
//RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_delete", BACKSPACEKEY, KM_PRESS, 0, 0)->ptr, "type", DEL_PREV_CHAR);
|
|
|
|
RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_delete", DELKEY, KM_PRESS, KM_CTRL, 0)->ptr, "type", DEL_NEXT_WORD);
|
|
|
|
RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_delete", BACKSPACEKEY, KM_PRESS, KM_CTRL, 0)->ptr, "type", DEL_PREV_WORD);
|
|
|
|
*/
|
|
|
|
|
|
|
|
RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_delete", DELKEY, KM_PRESS, 0, 0)->ptr, "type", DEL_NEXT_CHAR);
|
|
|
|
RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_delete", BACKSPACEKEY, KM_PRESS, 0, 0)->ptr, "type", DEL_PREV_CHAR);
|
2011-03-29 16:52:26 +00:00
|
|
|
RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_delete", BACKSPACEKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "type", DEL_PREV_CHAR); /* same as above [#26623] */
|
2009-07-16 00:50:27 +00:00
|
|
|
|
2010-10-31 04:11:39 +00:00
|
|
|
#ifdef WITH_PYTHON
|
2009-09-04 04:29:54 +00:00
|
|
|
WM_keymap_add_item(keymap, "CONSOLE_OT_execute", RETKEY, KM_PRESS, 0, 0); /* python operator - space_text.py */
|
|
|
|
WM_keymap_add_item(keymap, "CONSOLE_OT_execute", PADENTER, KM_PRESS, 0, 0);
|
2009-07-24 23:07:18 +00:00
|
|
|
|
2009-07-16 22:47:27 +00:00
|
|
|
//WM_keymap_add_item(keymap, "CONSOLE_OT_autocomplete", TABKEY, KM_PRESS, 0, 0); /* python operator - space_text.py */
|
2009-07-28 08:50:11 +00:00
|
|
|
WM_keymap_add_item(keymap, "CONSOLE_OT_autocomplete", SPACEKEY, KM_PRESS, KM_CTRL, 0); /* python operator - space_text.py */
|
2009-07-16 00:50:27 +00:00
|
|
|
#endif
|
2009-07-16 22:47:27 +00:00
|
|
|
|
2009-07-26 04:31:46 +00:00
|
|
|
WM_keymap_add_item(keymap, "CONSOLE_OT_copy", CKEY, KM_PRESS, KM_CTRL, 0);
|
2009-07-30 01:52:00 +00:00
|
|
|
WM_keymap_add_item(keymap, "CONSOLE_OT_paste", VKEY, KM_PRESS, KM_CTRL, 0);
|
2010-03-10 02:44:21 +00:00
|
|
|
#ifdef __APPLE__
|
|
|
|
WM_keymap_add_item(keymap, "CONSOLE_OT_copy", CKEY, KM_PRESS, KM_OSKEY, 0);
|
|
|
|
WM_keymap_add_item(keymap, "CONSOLE_OT_paste", VKEY, KM_PRESS, KM_OSKEY, 0);
|
|
|
|
#endif
|
|
|
|
|
2009-12-27 20:22:06 +00:00
|
|
|
WM_keymap_add_item(keymap, "CONSOLE_OT_select_set", LEFTMOUSE, KM_PRESS, 0, 0);
|
2009-07-19 00:49:44 +00:00
|
|
|
|
2010-09-27 17:22:59 +00:00
|
|
|
RNA_string_set(WM_keymap_add_item(keymap, "CONSOLE_OT_insert", TABKEY, KM_PRESS, 0, 0)->ptr, "text", "\t"); /* fake tabs */
|
2009-07-24 23:07:18 +00:00
|
|
|
WM_keymap_add_item(keymap, "CONSOLE_OT_insert", KM_TEXTINPUT, KM_ANY, KM_ANY, 0); // last!
|
2009-07-16 00:50:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/****************** header region ******************/
|
|
|
|
|
|
|
|
/* add handlers, stuff you only do once or on area/region changes */
|
2010-10-13 23:46:42 +00:00
|
|
|
static void console_header_area_init(wmWindowManager *UNUSED(wm), ARegion *ar)
|
2009-07-16 00:50:27 +00:00
|
|
|
{
|
|
|
|
ED_region_header_init(ar);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void console_header_area_draw(const bContext *C, ARegion *ar)
|
|
|
|
{
|
|
|
|
ED_region_header(C, ar);
|
|
|
|
}
|
|
|
|
|
2010-11-11 13:36:57 +00:00
|
|
|
static void console_main_area_listener(ARegion *ar, wmNotifier *wmn)
|
2009-07-16 00:50:27 +00:00
|
|
|
{
|
2010-11-11 13:36:57 +00:00
|
|
|
// SpaceInfo *sinfo= sa->spacedata.first;
|
2009-07-16 00:50:27 +00:00
|
|
|
|
|
|
|
/* context changes */
|
|
|
|
switch(wmn->category) {
|
2.5
Notifiers
---------
Various fixes for wrong use of notifiers, and some new notifiers
to make things a bit more clear and consistent, with two notable
changes:
* Geometry changes are now done with NC_GEOM, rather than
NC_OBJECT|ND_GEOM_, so an object does need to be available.
* Space data now use NC_SPACE|ND_SPACE_*, instead of data
notifiers or even NC_WINDOW in some cases. Note that NC_SPACE
should only be used for notifying about changes in space data,
we don't want to go back to allqueue(REDRAW..).
Depsgraph
---------
The dependency graph now has a different flush call:
DAG_object_flush_update(scene, ob, flag)
is replaced by:
DAG_id_flush_update(id, flag)
It still works basically the same, one difference is that it now
also accepts object data (e.g. Mesh), again to avoid requiring an
Object to be available. Other ID types will simply do nothing at
the moment.
Docs
----
I made some guidelines for how/when to do which kinds of updates
and notifiers. I can't specify totally exact how to make these
decisions, but these are basically the guidelines I use. So, new
and updated docs are here:
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/NotifiersUpdates
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/DataNotifiers
2009-09-04 20:51:09 +00:00
|
|
|
case NC_SPACE:
|
|
|
|
if(wmn->data == ND_SPACE_CONSOLE) { /* generic redraw request */
|
2010-11-11 13:36:57 +00:00
|
|
|
ED_region_tag_redraw(ar);
|
2009-07-16 00:50:27 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* only called once, from space/spacetypes.c */
|
|
|
|
void ED_spacetype_console(void)
|
|
|
|
{
|
2009-12-19 22:37:51 +00:00
|
|
|
SpaceType *st= MEM_callocN(sizeof(SpaceType), "spacetype console");
|
2009-07-16 00:50:27 +00:00
|
|
|
ARegionType *art;
|
|
|
|
|
2009-12-19 22:37:51 +00:00
|
|
|
st->spaceid= SPACE_CONSOLE;
|
|
|
|
strncpy(st->name, "Console", BKE_ST_MAXNAME);
|
2009-07-16 00:50:27 +00:00
|
|
|
|
2009-12-19 22:37:51 +00:00
|
|
|
st->new= console_new;
|
|
|
|
st->free= console_free;
|
|
|
|
st->init= console_init;
|
|
|
|
st->duplicate= console_duplicate;
|
|
|
|
st->operatortypes= console_operatortypes;
|
|
|
|
st->keymap= console_keymap;
|
2010-05-08 07:25:26 +00:00
|
|
|
st->dropboxes= console_dropboxes;
|
2009-07-16 00:50:27 +00:00
|
|
|
|
|
|
|
/* regions: main window */
|
|
|
|
art= MEM_callocN(sizeof(ARegionType), "spacetype console region");
|
|
|
|
art->regionid = RGN_TYPE_WINDOW;
|
2009-07-16 22:47:27 +00:00
|
|
|
art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D;
|
|
|
|
|
2009-07-16 00:50:27 +00:00
|
|
|
art->init= console_main_area_init;
|
|
|
|
art->draw= console_main_area_draw;
|
2010-11-11 13:36:57 +00:00
|
|
|
art->listener= console_main_area_listener;
|
2009-07-16 00:50:27 +00:00
|
|
|
|
|
|
|
|
2009-07-16 22:47:27 +00:00
|
|
|
|
2009-12-19 22:37:51 +00:00
|
|
|
BLI_addhead(&st->regiontypes, art);
|
2009-07-16 00:50:27 +00:00
|
|
|
|
|
|
|
/* regions: header */
|
|
|
|
art= MEM_callocN(sizeof(ARegionType), "spacetype console region");
|
|
|
|
art->regionid = RGN_TYPE_HEADER;
|
Drag and drop 2.5 integration! Finally, slashdot regulars can use
Blender too now! :)
** Drag works as follows:
- drag-able items are defined by the standard interface ui toolkit
- each button can get this feature, via uiButSetDragXXX(but, ...).
There are calls to define drag-able images, ID blocks, RNA paths,
file paths, and so on. By default you drag an icon, exceptionally
an ImBuf
- Drag items are registered centrally in the WM, it allows more drag
items simultaneous too, but not implemented
** Drop works as follows:
- On mouse release, and if drag items exist in the WM, it converts
the mouse event to an EVT_DROP type. This event then gets the full
drag info as customdata
- drop regions are defined with WM_dropbox_add(), similar to keymaps
you can make a "drop map" this way, which become 'drop map handlers'
in the queues.
- next to that the UI kit handles some common button types (like
accepting ID or names) to be catching a drop event too.
- Every "drop box" has two callbacks:
- poll() = check if the event drag data is relevant for this box
- copy() = fill in custom properties in the dropbox to initialize
an operator
- The dropbox handler then calls its standard Operator with its
dropbox properties.
** Currently implemented
Drag items:
- ID icons in browse buttons
- ID icons in context menu of properties region
- ID icons in outliner and rna viewer
- FileBrowser icons
- FileBrowser preview images
Drag-able icons are subtly visualized by making them brighter a bit
on mouse-over. In case the icon is a button or UI element too (most
cases), the drag-able feature will make the item react to
mouse-release instead of mouse-press.
Drop options:
- UI buttons: ID and text buttons (paste name)
- View3d: Object ID drop copies object
- View3d: Material ID drop assigns to object under cursor
- View3d: Image ID drop assigns to object UV texture under cursor
- Sequencer: Path drop will add either Image or Movie strip
- Image window: Path drop will open image
** Drag and drop Notes:
- Dropping into another Blender window (from same application) works
too. I've added code that passes on mousemoves and clicks to other
windows, without activating them though. This does make using multi-window
Blender a bit friendler.
- Dropping a file path to an image, is not the same as dropping an
Image ID... keep this in mind. Sequencer for example wants paths to
be dropped, textures in 3d window wants an Image ID.
- Although drop boxes could be defined via Python, I suggest they're
part of the UI and editor design (= how we want an editor to work), and
not default offered configurable like keymaps.
- At the moment only one item can be dragged at a time. This is for
several reasons.... For one, Blender doesn't have a well defined
uniform way to define "what is selected" (files, outliner items, etc).
Secondly there's potential conflicts on what todo when you drop mixed
drag sets on spots. All undefined stuff... nice for later.
- Example to bypass the above: a collection of images that form a strip,
should be represented in filewindow as a single sequence anyway.
This then will fit well and gets handled neatly by design.
- Another option to check is to allow multiple options per drop... it
could show the operator as a sort of menu, allowing arrow or scrollwheel
to choose. For time being I'd prefer to try to design a singular drop
though, just offer only one drop action per data type on given spots.
- What does work already, but a tad slow, is to use a function that
detects an object (type) under cursor, so a drag item's option can be
further refined (like drop object on object = parent). (disabled)
** More notes
- Added saving for Region layouts (like split points for toolbar)
- Label buttons now handle mouse over
- File list: added full path entry for drop feature.
- Filesel bugfix: wm_operator_exec() got called there and fully handled,
while WM event code tried same. Added new OPERATOR_HANDLED flag for this.
Maybe python needs it too?
- Cocoa: added window move event, so multi-win setups work OK (didnt save).
- Interface_handlers.c: removed win->active
- Severe area copy bug: area handlers were not set to NULL
- Filesel bugfix: next/prev folder list was not copied on area copies
** Leftover todos
- Cocoa windows seem to hang on cases still... needs check
- Cocoa 'draw overlap' swap doesn't work
- Cocoa window loses focus permanently on using Spotlight
(for these reasons, makefile building has Carbon as default atm)
- ListView templates in UI cannot become dragged yet, needs review...
it consists of two overlapping UI elements, preventing handling icon clicks.
- There's already Ghost library code to handle dropping from OS
into Blender window. I've noticed this code is unfinished for Macs, but
seems to be complete for Windows. Needs test... currently, an external
drop event will print in console when succesfully delivered to Blender's WM.
2010-01-26 18:18:21 +00:00
|
|
|
art->prefsizey= HEADERY;
|
2009-11-27 06:24:09 +00:00
|
|
|
art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D|ED_KEYMAP_HEADER;
|
2009-07-16 00:50:27 +00:00
|
|
|
|
|
|
|
art->init= console_header_area_init;
|
|
|
|
art->draw= console_header_area_draw;
|
|
|
|
|
2009-12-19 22:37:51 +00:00
|
|
|
BLI_addhead(&st->regiontypes, art);
|
2009-07-16 00:50:27 +00:00
|
|
|
|
|
|
|
|
2009-12-19 22:37:51 +00:00
|
|
|
BKE_spacetype_register(st);
|
2009-07-18 16:27:25 +00:00
|
|
|
}
|