Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/text.c
| Show First 20 Lines • Show All 443 Lines • ▼ Show 20 Lines | Text *BKE_text_load_ex(Main *bmain, const char *file, const char *relpath, const bool is_internal) | ||||
| return ta; | return ta; | ||||
| } | } | ||||
| Text *BKE_text_load(Main *bmain, const char *file, const char *relpath) | Text *BKE_text_load(Main *bmain, const char *file, const char *relpath) | ||||
| { | { | ||||
| return BKE_text_load_ex(bmain, file, relpath, false); | return BKE_text_load_ex(bmain, file, relpath, false); | ||||
| } | } | ||||
| Text *BKE_text_copy(Main *bmain, const Text *ta) | /** | ||||
| * Only copy internal data of Text ID from source to already allocated/initialized destination. | |||||
| * You probably nerver want to use that directly, use id_copy or BKE_id_copy_ex for typical needs. | |||||
| * | |||||
| * WARNING! This function will not handle ID user count! | |||||
| * | |||||
| * \param flag Copying options (see BKE_library.h's LIB_ID_COPY_... flags for more). | |||||
| */ | |||||
| void BKE_text_copy_data(Main *UNUSED(bmain), Text *ta_dst, const Text *ta_src, const int UNUSED(flag)) | |||||
| { | { | ||||
| Text *tan; | |||||
| TextLine *line, *tmp; | |||||
| tan = BKE_libblock_copy(bmain, &ta->id); | |||||
| /* file name can be NULL */ | /* file name can be NULL */ | ||||
| if (ta->name) { | if (ta_src->name) { | ||||
| tan->name = BLI_strdup(ta->name); | ta_dst->name = BLI_strdup(ta_src->name); | ||||
| } | |||||
| else { | |||||
| tan->name = NULL; | |||||
| } | } | ||||
| tan->flags = ta->flags | TXT_ISDIRTY; | ta_dst->flags |= TXT_ISDIRTY; | ||||
| BLI_listbase_clear(&tan->lines); | BLI_listbase_clear(&ta_dst->lines); | ||||
| tan->curl = tan->sell = NULL; | ta_dst->curl = ta_dst->sell = NULL; | ||||
| tan->compiled = NULL; | ta_dst->compiled = NULL; | ||||
| tan->nlines = ta->nlines; | |||||
| line = ta->lines.first; | |||||
| /* Walk down, reconstructing */ | /* Walk down, reconstructing */ | ||||
| while (line) { | for (TextLine *line_src = ta_src->lines.first; line_src; line_src = line_src->next) { | ||||
| tmp = (TextLine *) MEM_mallocN(sizeof(TextLine), "textline"); | TextLine *line_dst = MEM_mallocN(sizeof(*line_dst), __func__); | ||||
| tmp->line = MEM_mallocN(line->len + 1, "textline_string"); | |||||
| tmp->format = NULL; | |||||
| strcpy(tmp->line, line->line); | |||||
| tmp->len = line->len; | |||||
| BLI_addtail(&tan->lines, tmp); | line_dst->line = BLI_strdup(line_src->line); | ||||
| line_dst->format = NULL; | |||||
| line_dst->len = line_src->len; | |||||
| line = line->next; | BLI_addtail(&ta_dst->lines, line_dst); | ||||
| } | } | ||||
| tan->curl = tan->sell = tan->lines.first; | ta_dst->curl = ta_dst->sell = ta_dst->lines.first; | ||||
| tan->curc = tan->selc = 0; | ta_dst->curc = ta_dst->selc = 0; | ||||
| init_undo_text(tan); | init_undo_text(ta_dst); | ||||
| } | |||||
| BKE_id_copy_ensure_local(bmain, &ta->id, &tan->id); | |||||
| return tan; | Text *BKE_text_copy(Main *bmain, const Text *ta) | ||||
| { | |||||
| Text *ta_copy; | |||||
| BKE_id_copy_ex(bmain, &ta->id, (ID **)&ta_copy, 0, false); | |||||
| return ta_copy; | |||||
| } | } | ||||
| void BKE_text_make_local(Main *bmain, Text *text, const bool lib_local) | void BKE_text_make_local(Main *bmain, Text *text, const bool lib_local) | ||||
| { | { | ||||
| BKE_id_make_local_generic(bmain, &text->id, true, lib_local); | BKE_id_make_local_generic(bmain, &text->id, true, lib_local); | ||||
| } | } | ||||
| void BKE_text_clear(Text *text) /* called directly from rna */ | void BKE_text_clear(Text *text) /* called directly from rna */ | ||||
| ▲ Show 20 Lines • Show All 2,542 Lines • Show Last 20 Lines | |||||