static int editsource_text_edit(bContext *C, wmOperator *op, const char filepath[FILE_MAX], const int line) { struct Main *bmain = CTX_data_main(C); Text *text; /* Developers may wish to copy-paste to an external editor. */ printf("%s:%d\n", filepath, line); for (text = bmain->texts.first; text; text = text->id.next) { if (text->name && BLI_path_cmp(text->name, filepath) == 0) { break; } } if (text == NULL) { text = BKE_text_load(bmain, filepath, BKE_main_blendfile_path(bmain)); id_us_ensure_real(&text->id); } if (text == NULL) { BKE_reportf(op->reports, RPT_WARNING, "File '%s' cannot be opened", filepath); return OPERATOR_CANCELLED; } else { /* naughty!, find text area to set, not good behavior * but since this is a dev tool lets allow it - campbell */ ScrArea *sa = BKE_screen_find_big_area(CTX_wm_screen(C), SPACE_TEXT, 0); if (sa) { SpaceText *st = sa->spacedata.first; st->text = text; } else { BKE_reportf(op->reports, RPT_INFO, "See '%s' in the text editor", text->id.name + 2); } txt_move_toline(text, line - 1, false); WM_event_add_notifier(C, NC_TEXT | ND_CURSOR, text); } return OPERATOR_FINISHED; }
static int editsource_text_edit(bContext *C, wmOperator *op, char filepath[240], int line) { struct Main *bmain= CTX_data_main(C); Text *text; for (text=bmain->text.first; text; text=text->id.next) { if (text->name && BLI_path_cmp(text->name, filepath) == 0) { break; } } if (text == NULL) { text= add_text(filepath, bmain->name); } if (text == NULL) { BKE_reportf(op->reports, RPT_WARNING, "file: '%s' can't be opened", filepath); return OPERATOR_CANCELLED; } else { /* naughty!, find text area to set, not good behavior * but since this is a dev tool lets allow it - campbell */ ScrArea *sa= BKE_screen_find_big_area(CTX_wm_screen(C), SPACE_TEXT, 0); if(sa) { SpaceText *st= sa->spacedata.first; st->text= text; } else { BKE_reportf(op->reports, RPT_INFO, "See '%s' in the text editor", text->id.name + 2); } txt_move_toline(text, line - 1, FALSE); WM_event_add_notifier(C, NC_TEXT|ND_CURSOR, text); } return OPERATOR_FINISHED; }
static void rna_Text_current_line_index_set(PointerRNA *ptr, int value) { Text *text = (Text *)ptr->data; txt_move_toline(text, value, 0); }