static int reports_to_text_exec(bContext *C, wmOperator *UNUSED(op)) { ReportList *reports = CTX_wm_reports(C); Main *bmain = CTX_data_main(C); Text *txt; char *str; /* create new text-block to write to */ txt = BKE_text_add(bmain, "Recent Reports"); /* convert entire list to a display string, and add this to the text-block * - if commandline debug option enabled, show debug reports too * - otherwise, up to info (which is what users normally see) */ str = BKE_reports_string(reports, (G.debug & G_DEBUG) ? RPT_DEBUG : RPT_INFO); if (str) { BKE_text_write(txt, str); MEM_freeN(str); return OPERATOR_FINISHED; } else { return OPERATOR_CANCELLED; } }
static void rna_Text_write(Text *text, const char *str) { BKE_text_write(text, str); WM_main_add_notifier(NC_TEXT | NA_EDITED, text); }