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>2019-04-17 07:17:24 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-04-17 07:21:24 +0300
commite12c08e8d170b7ca40f204a5b0423c23a9fbc2c1 (patch)
tree8cf3453d12edb177a218ef8009357518ec6cab6a /source/blender/editors/space_text/space_text.c
parentb3dabc200a4b0399ec6b81f2ff2730d07b44fcaa (diff)
ClangFormat: apply to source, most of intern
Apply clang format as proposed in T53211. For details on usage and instructions for migrating branches without conflicts, see: https://wiki.blender.org/wiki/Tools/ClangFormat
Diffstat (limited to 'source/blender/editors/space_text/space_text.c')
-rw-r--r--source/blender/editors/space_text/space_text.c617
1 files changed, 309 insertions, 308 deletions
diff --git a/source/blender/editors/space_text/space_text.c b/source/blender/editors/space_text/space_text.c
index 55165e4840f..9232d0322ab 100644
--- a/source/blender/editors/space_text/space_text.c
+++ b/source/blender/editors/space_text/space_text.c
@@ -21,7 +21,6 @@
* \ingroup sptext
*/
-
#include <string.h>
#include "DNA_text_types.h"
@@ -38,7 +37,6 @@
#include "ED_space_api.h"
#include "ED_screen.h"
-
#include "WM_api.h"
#include "WM_types.h"
@@ -48,217 +46,217 @@
#include "RNA_access.h"
-
#include "text_format.h"
-#include "text_intern.h" /* own include */
+#include "text_intern.h" /* own include */
#include "GPU_framebuffer.h"
/* ******************** default callbacks for text space ***************** */
static SpaceLink *text_new(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
{
- ARegion *ar;
- SpaceText *stext;
+ ARegion *ar;
+ SpaceText *stext;
- stext = MEM_callocN(sizeof(SpaceText), "inittext");
- stext->spacetype = SPACE_TEXT;
+ stext = MEM_callocN(sizeof(SpaceText), "inittext");
+ stext->spacetype = SPACE_TEXT;
- stext->lheight = 12;
- stext->tabnumber = 4;
- stext->margin_column = 80;
+ stext->lheight = 12;
+ stext->tabnumber = 4;
+ stext->margin_column = 80;
- /* header */
- ar = MEM_callocN(sizeof(ARegion), "header for text");
+ /* header */
+ ar = MEM_callocN(sizeof(ARegion), "header for text");
- BLI_addtail(&stext->regionbase, ar);
- ar->regiontype = RGN_TYPE_HEADER;
- ar->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM : RGN_ALIGN_TOP;
+ BLI_addtail(&stext->regionbase, ar);
+ ar->regiontype = RGN_TYPE_HEADER;
+ ar->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM : RGN_ALIGN_TOP;
- /* footer */
- ar = MEM_callocN(sizeof(ARegion), "footer for text");
- BLI_addtail(&stext->regionbase, ar);
- ar->regiontype = RGN_TYPE_FOOTER;
- ar->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_TOP : RGN_ALIGN_BOTTOM;
+ /* footer */
+ ar = MEM_callocN(sizeof(ARegion), "footer for text");
+ BLI_addtail(&stext->regionbase, ar);
+ ar->regiontype = RGN_TYPE_FOOTER;
+ ar->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_TOP : RGN_ALIGN_BOTTOM;
- /* properties region */
- ar = MEM_callocN(sizeof(ARegion), "properties region for text");
+ /* properties region */
+ ar = MEM_callocN(sizeof(ARegion), "properties region for text");
- BLI_addtail(&stext->regionbase, ar);
- ar->regiontype = RGN_TYPE_UI;
- ar->alignment = RGN_ALIGN_LEFT;
- ar->flag = RGN_FLAG_HIDDEN;
+ BLI_addtail(&stext->regionbase, ar);
+ ar->regiontype = RGN_TYPE_UI;
+ ar->alignment = RGN_ALIGN_LEFT;
+ ar->flag = RGN_FLAG_HIDDEN;
- /* main region */
- ar = MEM_callocN(sizeof(ARegion), "main region for text");
+ /* main region */
+ ar = MEM_callocN(sizeof(ARegion), "main region for text");
- BLI_addtail(&stext->regionbase, ar);
- ar->regiontype = RGN_TYPE_WINDOW;
+ BLI_addtail(&stext->regionbase, ar);
+ ar->regiontype = RGN_TYPE_WINDOW;
- return (SpaceLink *)stext;
+ return (SpaceLink *)stext;
}
/* not spacelink itself */
static void text_free(SpaceLink *sl)
{
- SpaceText *stext = (SpaceText *) sl;
+ SpaceText *stext = (SpaceText *)sl;
- stext->text = NULL;
- text_free_caches(stext);
+ stext->text = NULL;
+ text_free_caches(stext);
}
-
/* spacetype; init callback */
static void text_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa))
{
-
}
static SpaceLink *text_duplicate(SpaceLink *sl)
{
- SpaceText *stextn = MEM_dupallocN(sl);
+ SpaceText *stextn = MEM_dupallocN(sl);
- /* clear or remove stuff from old */
+ /* clear or remove stuff from old */
- stextn->drawcache = NULL; /* space need it's own cache */
+ stextn->drawcache = NULL; /* space need it's own cache */
- return (SpaceLink *)stextn;
+ return (SpaceLink *)stextn;
}
-static void text_listener(wmWindow *UNUSED(win), ScrArea *sa, wmNotifier *wmn, Scene *UNUSED(scene))
+static void text_listener(wmWindow *UNUSED(win),
+ ScrArea *sa,
+ wmNotifier *wmn,
+ Scene *UNUSED(scene))
{
- SpaceText *st = sa->spacedata.first;
-
- /* context changes */
- switch (wmn->category) {
- case NC_TEXT:
- /* check if active text was changed, no need to redraw if text isn't active
- * (reference == NULL) means text was unlinked, should update anyway for this
- * case -- no way to know was text active before unlinking or not */
- if (wmn->reference && wmn->reference != st->text)
- break;
-
- switch (wmn->data) {
- case ND_DISPLAY:
- ED_area_tag_redraw(sa);
- break;
- case ND_CURSOR:
- if (st->text && st->text == wmn->reference)
- text_scroll_to_cursor__area(st, sa, true);
-
- ED_area_tag_redraw(sa);
- break;
- }
-
- switch (wmn->action) {
- case NA_EDITED:
- if (st->text) {
- text_drawcache_tag_update(st, 1);
- text_update_edited(st->text);
- }
-
- ED_area_tag_redraw(sa);
- ATTR_FALLTHROUGH; /* fall down to tag redraw */
- case NA_ADDED:
- case NA_REMOVED:
- ED_area_tag_redraw(sa);
- break;
- case NA_SELECTED:
- if (st->text && st->text == wmn->reference)
- text_scroll_to_cursor__area(st, sa, true);
-
- break;
- }
-
- break;
- case NC_SPACE:
- if (wmn->data == ND_SPACE_TEXT)
- ED_area_tag_redraw(sa);
- break;
- }
+ SpaceText *st = sa->spacedata.first;
+
+ /* context changes */
+ switch (wmn->category) {
+ case NC_TEXT:
+ /* check if active text was changed, no need to redraw if text isn't active
+ * (reference == NULL) means text was unlinked, should update anyway for this
+ * case -- no way to know was text active before unlinking or not */
+ if (wmn->reference && wmn->reference != st->text)
+ break;
+
+ switch (wmn->data) {
+ case ND_DISPLAY:
+ ED_area_tag_redraw(sa);
+ break;
+ case ND_CURSOR:
+ if (st->text && st->text == wmn->reference)
+ text_scroll_to_cursor__area(st, sa, true);
+
+ ED_area_tag_redraw(sa);
+ break;
+ }
+
+ switch (wmn->action) {
+ case NA_EDITED:
+ if (st->text) {
+ text_drawcache_tag_update(st, 1);
+ text_update_edited(st->text);
+ }
+
+ ED_area_tag_redraw(sa);
+ ATTR_FALLTHROUGH; /* fall down to tag redraw */
+ case NA_ADDED:
+ case NA_REMOVED:
+ ED_area_tag_redraw(sa);
+ break;
+ case NA_SELECTED:
+ if (st->text && st->text == wmn->reference)
+ text_scroll_to_cursor__area(st, sa, true);
+
+ break;
+ }
+
+ break;
+ case NC_SPACE:
+ if (wmn->data == ND_SPACE_TEXT)
+ ED_area_tag_redraw(sa);
+ break;
+ }
}
static void text_operatortypes(void)
{
- WM_operatortype_append(TEXT_OT_new);
- WM_operatortype_append(TEXT_OT_open);
- WM_operatortype_append(TEXT_OT_reload);
- WM_operatortype_append(TEXT_OT_unlink);
- WM_operatortype_append(TEXT_OT_save);
- WM_operatortype_append(TEXT_OT_save_as);
- WM_operatortype_append(TEXT_OT_make_internal);
- WM_operatortype_append(TEXT_OT_run_script);
- WM_operatortype_append(TEXT_OT_refresh_pyconstraints);
-
- WM_operatortype_append(TEXT_OT_paste);
- WM_operatortype_append(TEXT_OT_copy);
- WM_operatortype_append(TEXT_OT_cut);
- WM_operatortype_append(TEXT_OT_duplicate_line);
-
- WM_operatortype_append(TEXT_OT_convert_whitespace);
- WM_operatortype_append(TEXT_OT_uncomment);
- WM_operatortype_append(TEXT_OT_comment);
- WM_operatortype_append(TEXT_OT_unindent);
- WM_operatortype_append(TEXT_OT_indent);
-
- WM_operatortype_append(TEXT_OT_select_line);
- WM_operatortype_append(TEXT_OT_select_all);
- WM_operatortype_append(TEXT_OT_select_word);
-
- WM_operatortype_append(TEXT_OT_move_lines);
-
- WM_operatortype_append(TEXT_OT_jump);
- WM_operatortype_append(TEXT_OT_move);
- WM_operatortype_append(TEXT_OT_move_select);
- WM_operatortype_append(TEXT_OT_delete);
- WM_operatortype_append(TEXT_OT_overwrite_toggle);
-
- WM_operatortype_append(TEXT_OT_selection_set);
- WM_operatortype_append(TEXT_OT_cursor_set);
- WM_operatortype_append(TEXT_OT_scroll);
- WM_operatortype_append(TEXT_OT_scroll_bar);
- WM_operatortype_append(TEXT_OT_line_number);
-
- WM_operatortype_append(TEXT_OT_line_break);
- WM_operatortype_append(TEXT_OT_insert);
-
- WM_operatortype_append(TEXT_OT_properties);
-
- WM_operatortype_append(TEXT_OT_find);
- WM_operatortype_append(TEXT_OT_find_set_selected);
- WM_operatortype_append(TEXT_OT_replace);
- WM_operatortype_append(TEXT_OT_replace_set_selected);
-
- WM_operatortype_append(TEXT_OT_start_find);
-
- WM_operatortype_append(TEXT_OT_to_3d_object);
-
- WM_operatortype_append(TEXT_OT_resolve_conflict);
-
- WM_operatortype_append(TEXT_OT_autocomplete);
+ WM_operatortype_append(TEXT_OT_new);
+ WM_operatortype_append(TEXT_OT_open);
+ WM_operatortype_append(TEXT_OT_reload);
+ WM_operatortype_append(TEXT_OT_unlink);
+ WM_operatortype_append(TEXT_OT_save);
+ WM_operatortype_append(TEXT_OT_save_as);
+ WM_operatortype_append(TEXT_OT_make_internal);
+ WM_operatortype_append(TEXT_OT_run_script);
+ WM_operatortype_append(TEXT_OT_refresh_pyconstraints);
+
+ WM_operatortype_append(TEXT_OT_paste);
+ WM_operatortype_append(TEXT_OT_copy);
+ WM_operatortype_append(TEXT_OT_cut);
+ WM_operatortype_append(TEXT_OT_duplicate_line);
+
+ WM_operatortype_append(TEXT_OT_convert_whitespace);
+ WM_operatortype_append(TEXT_OT_uncomment);
+ WM_operatortype_append(TEXT_OT_comment);
+ WM_operatortype_append(TEXT_OT_unindent);
+ WM_operatortype_append(TEXT_OT_indent);
+
+ WM_operatortype_append(TEXT_OT_select_line);
+ WM_operatortype_append(TEXT_OT_select_all);
+ WM_operatortype_append(TEXT_OT_select_word);
+
+ WM_operatortype_append(TEXT_OT_move_lines);
+
+ WM_operatortype_append(TEXT_OT_jump);
+ WM_operatortype_append(TEXT_OT_move);
+ WM_operatortype_append(TEXT_OT_move_select);
+ WM_operatortype_append(TEXT_OT_delete);
+ WM_operatortype_append(TEXT_OT_overwrite_toggle);
+
+ WM_operatortype_append(TEXT_OT_selection_set);
+ WM_operatortype_append(TEXT_OT_cursor_set);
+ WM_operatortype_append(TEXT_OT_scroll);
+ WM_operatortype_append(TEXT_OT_scroll_bar);
+ WM_operatortype_append(TEXT_OT_line_number);
+
+ WM_operatortype_append(TEXT_OT_line_break);
+ WM_operatortype_append(TEXT_OT_insert);
+
+ WM_operatortype_append(TEXT_OT_properties);
+
+ WM_operatortype_append(TEXT_OT_find);
+ WM_operatortype_append(TEXT_OT_find_set_selected);
+ WM_operatortype_append(TEXT_OT_replace);
+ WM_operatortype_append(TEXT_OT_replace_set_selected);
+
+ WM_operatortype_append(TEXT_OT_start_find);
+
+ WM_operatortype_append(TEXT_OT_to_3d_object);
+
+ WM_operatortype_append(TEXT_OT_resolve_conflict);
+
+ WM_operatortype_append(TEXT_OT_autocomplete);
}
static void text_keymap(struct wmKeyConfig *keyconf)
{
- WM_keymap_ensure(keyconf, "Text Generic", SPACE_TEXT, 0);
- WM_keymap_ensure(keyconf, "Text", SPACE_TEXT, 0);
+ WM_keymap_ensure(keyconf, "Text Generic", SPACE_TEXT, 0);
+ WM_keymap_ensure(keyconf, "Text", SPACE_TEXT, 0);
}
const char *text_context_dir[] = {"edit_text", NULL};
static int text_context(const bContext *C, const char *member, bContextDataResult *result)
{
- SpaceText *st = CTX_wm_space_text(C);
-
- if (CTX_data_dir(member)) {
- CTX_data_dir_set(result, text_context_dir);
- return 1;
- }
- else if (CTX_data_equals(member, "edit_text")) {
- CTX_data_id_pointer_set(result, &st->text->id);
- return 1;
- }
-
- return 0;
+ SpaceText *st = CTX_wm_space_text(C);
+
+ if (CTX_data_dir(member)) {
+ CTX_data_dir_set(result, text_context_dir);
+ return 1;
+ }
+ else if (CTX_data_equals(member, "edit_text")) {
+ CTX_data_id_pointer_set(result, &st->text->id);
+ return 1;
+ }
+
+ return 0;
}
/********************* main region ********************/
@@ -266,116 +264,120 @@ static int text_context(const bContext *C, const char *member, bContextDataResul
/* add handlers, stuff you only do once or on area/region changes */
static void text_main_region_init(wmWindowManager *wm, ARegion *ar)
{
- wmKeyMap *keymap;
- ListBase *lb;
+ wmKeyMap *keymap;
+ ListBase *lb;
- UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_STANDARD, ar->winx, ar->winy);
+ UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_STANDARD, ar->winx, ar->winy);
- /* own keymap */
- keymap = WM_keymap_ensure(wm->defaultconf, "Text Generic", SPACE_TEXT, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
- keymap = WM_keymap_ensure(wm->defaultconf, "Text", SPACE_TEXT, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ /* own keymap */
+ keymap = WM_keymap_ensure(wm->defaultconf, "Text Generic", SPACE_TEXT, 0);
+ WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ keymap = WM_keymap_ensure(wm->defaultconf, "Text", SPACE_TEXT, 0);
+ WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
- /* add drop boxes */
- lb = WM_dropboxmap_find("Text", SPACE_TEXT, RGN_TYPE_WINDOW);
+ /* add drop boxes */
+ lb = WM_dropboxmap_find("Text", SPACE_TEXT, RGN_TYPE_WINDOW);
- WM_event_add_dropbox_handler(&ar->handlers, lb);
+ WM_event_add_dropbox_handler(&ar->handlers, lb);
}
static void text_main_region_draw(const bContext *C, ARegion *ar)
{
- /* draw entirely, view changes should be handled here */
- SpaceText *st = CTX_wm_space_text(C);
- //View2D *v2d = &ar->v2d;
+ /* draw entirely, view changes should be handled here */
+ SpaceText *st = CTX_wm_space_text(C);
+ //View2D *v2d = &ar->v2d;
- /* clear and setup matrix */
- UI_ThemeClearColor(TH_BACK);
- GPU_clear(GPU_COLOR_BIT);
+ /* clear and setup matrix */
+ UI_ThemeClearColor(TH_BACK);
+ GPU_clear(GPU_COLOR_BIT);
- // UI_view2d_view_ortho(v2d);
+ // UI_view2d_view_ortho(v2d);
- /* data... */
- draw_text_main(st, ar);
+ /* data... */
+ draw_text_main(st, ar);
- /* reset view matrix */
- // UI_view2d_view_restore(C);
+ /* reset view matrix */
+ // UI_view2d_view_restore(C);
- /* scrollers? */
+ /* scrollers? */
}
static void text_cursor(wmWindow *win, ScrArea *sa, ARegion *ar)
{
- SpaceText *st = sa->spacedata.first;
- int wmcursor = BC_TEXTEDITCURSOR;
+ SpaceText *st = sa->spacedata.first;
+ int wmcursor = BC_TEXTEDITCURSOR;
- if (st->text && BLI_rcti_isect_pt(&st->txtbar, win->eventstate->x - ar->winrct.xmin, st->txtbar.ymin)) {
- wmcursor = CURSOR_STD;
- }
+ if (st->text &&
+ BLI_rcti_isect_pt(&st->txtbar, win->eventstate->x - ar->winrct.xmin, st->txtbar.ymin)) {
+ wmcursor = CURSOR_STD;
+ }
- WM_cursor_set(win, wmcursor);
+ WM_cursor_set(win, wmcursor);
}
-
-
/* ************* dropboxes ************* */
-static bool text_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent *UNUSED(event), const char **UNUSED(tooltip))
+static bool text_drop_poll(bContext *UNUSED(C),
+ wmDrag *drag,
+ const wmEvent *UNUSED(event),
+ const char **UNUSED(tooltip))
{
- if (drag->type == WM_DRAG_PATH) {
- /* rule might not work? */
- if (ELEM(drag->icon, ICON_FILE_SCRIPT, ICON_FILE_TEXT, ICON_FILE_BLANK)) {
- return true;
- }
- }
- return false;
+ if (drag->type == WM_DRAG_PATH) {
+ /* rule might not work? */
+ if (ELEM(drag->icon, ICON_FILE_SCRIPT, ICON_FILE_TEXT, ICON_FILE_BLANK)) {
+ return true;
+ }
+ }
+ return false;
}
static void text_drop_copy(wmDrag *drag, wmDropBox *drop)
{
- /* copy drag path to properties */
- RNA_string_set(drop->ptr, "filepath", drag->path);
+ /* copy drag path to properties */
+ RNA_string_set(drop->ptr, "filepath", drag->path);
}
-static bool text_drop_paste_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent *UNUSED(event), const char **UNUSED(tooltip))
+static bool text_drop_paste_poll(bContext *UNUSED(C),
+ wmDrag *drag,
+ const wmEvent *UNUSED(event),
+ const char **UNUSED(tooltip))
{
- return (drag->type == WM_DRAG_ID);
+ return (drag->type == WM_DRAG_ID);
}
static void text_drop_paste(wmDrag *drag, wmDropBox *drop)
{
- char *text;
- ID *id = WM_drag_ID(drag, 0);
+ char *text;
+ ID *id = WM_drag_ID(drag, 0);
- /* copy drag path to properties */
- text = RNA_path_full_ID_py(id);
- RNA_string_set(drop->ptr, "text", text);
- MEM_freeN(text);
+ /* copy drag path to properties */
+ text = RNA_path_full_ID_py(id);
+ RNA_string_set(drop->ptr, "text", text);
+ MEM_freeN(text);
}
/* this region dropbox definition */
static void text_dropboxes(void)
{
- ListBase *lb = WM_dropboxmap_find("Text", SPACE_TEXT, RGN_TYPE_WINDOW);
+ ListBase *lb = WM_dropboxmap_find("Text", SPACE_TEXT, RGN_TYPE_WINDOW);
- WM_dropbox_add(lb, "TEXT_OT_open", text_drop_poll, text_drop_copy);
- WM_dropbox_add(lb, "TEXT_OT_insert", text_drop_paste_poll, text_drop_paste);
+ WM_dropbox_add(lb, "TEXT_OT_open", text_drop_poll, text_drop_copy);
+ WM_dropbox_add(lb, "TEXT_OT_insert", text_drop_paste_poll, text_drop_paste);
}
/* ************* end drop *********** */
-
/****************** header region ******************/
/* add handlers, stuff you only do once or on area/region changes */
static void text_header_region_init(wmWindowManager *UNUSED(wm), ARegion *ar)
{
- ED_region_header_init(ar);
+ ED_region_header_init(ar);
}
static void text_header_region_draw(const bContext *C, ARegion *ar)
{
- ED_region_header(C, ar);
+ ED_region_header(C, ar);
}
/****************** properties region ******************/
@@ -383,46 +385,45 @@ static void text_header_region_draw(const bContext *C, ARegion *ar)
/* add handlers, stuff you only do once or on area/region changes */
static void text_properties_region_init(wmWindowManager *wm, ARegion *ar)
{
- wmKeyMap *keymap;
-
- ar->v2d.scroll = V2D_SCROLL_RIGHT | V2D_SCROLL_VERTICAL_HIDE;
- ED_region_panels_init(wm, ar);
+ wmKeyMap *keymap;
- /* own keymaps */
- keymap = WM_keymap_ensure(wm->defaultconf, "Text Generic", SPACE_TEXT, 0);
- WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+ ar->v2d.scroll = V2D_SCROLL_RIGHT | V2D_SCROLL_VERTICAL_HIDE;
+ ED_region_panels_init(wm, ar);
+ /* own keymaps */
+ keymap = WM_keymap_ensure(wm->defaultconf, "Text Generic", SPACE_TEXT, 0);
+ WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
}
static void text_properties_region_draw(const bContext *C, ARegion *ar)
{
- SpaceText *st = CTX_wm_space_text(C);
-
- ED_region_panels(C, ar);
-
- /* this flag trick is make sure buttons have been added already */
- if (st->flags & ST_FIND_ACTIVATE) {
- if (UI_textbutton_activate_rna(C, ar, st, "find_text")) {
- /* if the panel was already open we need to do another redraw */
- ScrArea *sa = CTX_wm_area(C);
- WM_event_add_notifier(C, NC_SPACE | ND_SPACE_TEXT, sa);
- }
- st->flags &= ~ST_FIND_ACTIVATE;
- }
+ SpaceText *st = CTX_wm_space_text(C);
+
+ ED_region_panels(C, ar);
+
+ /* this flag trick is make sure buttons have been added already */
+ if (st->flags & ST_FIND_ACTIVATE) {
+ if (UI_textbutton_activate_rna(C, ar, st, "find_text")) {
+ /* if the panel was already open we need to do another redraw */
+ ScrArea *sa = CTX_wm_area(C);
+ WM_event_add_notifier(C, NC_SPACE | ND_SPACE_TEXT, sa);
+ }
+ st->flags &= ~ST_FIND_ACTIVATE;
+ }
}
static void text_id_remap(ScrArea *UNUSED(sa), SpaceLink *slink, ID *old_id, ID *new_id)
{
- SpaceText *stext = (SpaceText *)slink;
+ SpaceText *stext = (SpaceText *)slink;
- if (!ELEM(GS(old_id->name), ID_TXT)) {
- return;
- }
+ if (!ELEM(GS(old_id->name), ID_TXT)) {
+ return;
+ }
- if ((ID *)stext->text == old_id) {
- stext->text = (Text *)new_id;
- id_us_ensure_real(new_id);
- }
+ if ((ID *)stext->text == old_id) {
+ stext->text = (Text *)new_id;
+ id_us_ensure_real(new_id);
+ }
}
/********************* registration ********************/
@@ -430,68 +431,68 @@ static void text_id_remap(ScrArea *UNUSED(sa), SpaceLink *slink, ID *old_id, ID
/* only called once, from space/spacetypes.c */
void ED_spacetype_text(void)
{
- SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype text");
- ARegionType *art;
-
- st->spaceid = SPACE_TEXT;
- strncpy(st->name, "Text", BKE_ST_MAXNAME);
-
- st->new = text_new;
- st->free = text_free;
- st->init = text_init;
- st->duplicate = text_duplicate;
- st->operatortypes = text_operatortypes;
- st->keymap = text_keymap;
- st->listener = text_listener;
- st->context = text_context;
- st->dropboxes = text_dropboxes;
- st->id_remap = text_id_remap;
-
- /* regions: main window */
- art = MEM_callocN(sizeof(ARegionType), "spacetype text region");
- art->regionid = RGN_TYPE_WINDOW;
- art->init = text_main_region_init;
- art->draw = text_main_region_draw;
- art->cursor = text_cursor;
- art->event_cursor = true;
-
- BLI_addhead(&st->regiontypes, art);
-
- /* regions: properties */
- art = MEM_callocN(sizeof(ARegionType), "spacetype text region");
- art->regionid = RGN_TYPE_UI;
- art->prefsizex = UI_COMPACT_PANEL_WIDTH;
- art->keymapflag = ED_KEYMAP_UI;
-
- art->init = text_properties_region_init;
- art->draw = text_properties_region_draw;
- BLI_addhead(&st->regiontypes, art);
-
- /* regions: header */
- art = MEM_callocN(sizeof(ARegionType), "spacetype text region");
- art->regionid = RGN_TYPE_HEADER;
- art->prefsizey = HEADERY;
- art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_HEADER;
-
- art->init = text_header_region_init;
- art->draw = text_header_region_draw;
- BLI_addhead(&st->regiontypes, art);
-
- /* regions: footer */
- art = MEM_callocN(sizeof(ARegionType), "spacetype text region");
- art->regionid = RGN_TYPE_FOOTER;
- art->prefsizey = HEADERY;
- art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FOOTER;
- art->init = text_header_region_init;
- art->draw = text_header_region_draw;
- BLI_addhead(&st->regiontypes, art);
-
- BKE_spacetype_register(st);
-
- /* register formatters */
- ED_text_format_register_py();
- ED_text_format_register_osl();
- ED_text_format_register_lua();
- ED_text_format_register_pov();
- ED_text_format_register_pov_ini();
+ SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype text");
+ ARegionType *art;
+
+ st->spaceid = SPACE_TEXT;
+ strncpy(st->name, "Text", BKE_ST_MAXNAME);
+
+ st->new = text_new;
+ st->free = text_free;
+ st->init = text_init;
+ st->duplicate = text_duplicate;
+ st->operatortypes = text_operatortypes;
+ st->keymap = text_keymap;
+ st->listener = text_listener;
+ st->context = text_context;
+ st->dropboxes = text_dropboxes;
+ st->id_remap = text_id_remap;
+
+ /* regions: main window */
+ art = MEM_callocN(sizeof(ARegionType), "spacetype text region");
+ art->regionid = RGN_TYPE_WINDOW;
+ art->init = text_main_region_init;
+ art->draw = text_main_region_draw;
+ art->cursor = text_cursor;
+ art->event_cursor = true;
+
+ BLI_addhead(&st->regiontypes, art);
+
+ /* regions: properties */
+ art = MEM_callocN(sizeof(ARegionType), "spacetype text region");
+ art->regionid = RGN_TYPE_UI;
+ art->prefsizex = UI_COMPACT_PANEL_WIDTH;
+ art->keymapflag = ED_KEYMAP_UI;
+
+ art->init = text_properties_region_init;
+ art->draw = text_properties_region_draw;
+ BLI_addhead(&st->regiontypes, art);
+
+ /* regions: header */
+ art = MEM_callocN(sizeof(ARegionType), "spacetype text region");
+ art->regionid = RGN_TYPE_HEADER;
+ art->prefsizey = HEADERY;
+ art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_HEADER;
+
+ art->init = text_header_region_init;
+ art->draw = text_header_region_draw;
+ BLI_addhead(&st->regiontypes, art);
+
+ /* regions: footer */
+ art = MEM_callocN(sizeof(ARegionType), "spacetype text region");
+ art->regionid = RGN_TYPE_FOOTER;
+ art->prefsizey = HEADERY;
+ art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FOOTER;
+ art->init = text_header_region_init;
+ art->draw = text_header_region_draw;
+ BLI_addhead(&st->regiontypes, art);
+
+ BKE_spacetype_register(st);
+
+ /* register formatters */
+ ED_text_format_register_py();
+ ED_text_format_register_osl();
+ ED_text_format_register_lua();
+ ED_text_format_register_pov();
+ ED_text_format_register_pov_ini();
}