// TODO, get this working again! static int report_replay_exec(bContext *C, wmOperator *UNUSED(op)) { // SpaceInfo *sc = CTX_wm_space_info(C); // ReportList *reports = CTX_wm_reports(C); // int report_mask = info_report_mask(sc); // Report *report; #if 0 sc->type = CONSOLE_TYPE_PYTHON; for (report = reports->list.last; report; report = report->prev) { if ((report->type & report_mask) && (report->type & RPT_OPERATOR_ALL | RPT_PROPERTY_ALL) && (report->flag & SELECT)) { console_history_add_str(sc, report->message, 0); WM_operator_name_call(C, "CONSOLE_OT_execute", WM_OP_EXEC_DEFAULT, NULL); ED_area_tag_redraw(CTX_wm_area(C)); } } sc->type = CONSOLE_TYPE_REPORT; #endif ED_area_tag_redraw(CTX_wm_area(C)); return OPERATOR_FINISHED; }
/* the python exec operator uses this */ static int history_append_exec(bContext *C, wmOperator *op) { SpaceConsole *sc= CTX_wm_space_console(C); ScrArea *sa= CTX_wm_area(C); ConsoleLine *ci= console_history_verify(C); char *str= RNA_string_get_alloc(op->ptr, "text", NULL, 0); /* own this text in the new line, dont free */ int cursor= RNA_int_get(op->ptr, "current_character"); short rem_dupes= RNA_boolean_get(op->ptr, "remove_duplicates"); int prev_len= ci->len; if(rem_dupes) { ConsoleLine *cl; while((cl= console_history_find(sc, ci->line, ci))) console_history_free(sc, cl); if(strcmp(str, ci->line)==0) { MEM_freeN(str); return OPERATOR_FINISHED; } } ci= console_history_add_str(sc, str, 1); /* own the string */ console_select_offset(sc, ci->len - prev_len); console_line_cursor_set(ci, cursor); ED_area_tag_redraw(sa); return OPERATOR_FINISHED; }
/* the python exec operator uses this */ static int console_history_append_exec(bContext *C, wmOperator *op) { SpaceConsole *sc = CTX_wm_space_console(C); ARegion *ar = CTX_wm_region(C); ScrArea *sa = CTX_wm_area(C); ConsoleLine *ci = console_history_verify(C); char *str = RNA_string_get_alloc(op->ptr, "text", NULL, 0); /* own this text in the new line, don't free */ int cursor = RNA_int_get(op->ptr, "current_character"); const bool rem_dupes = RNA_boolean_get(op->ptr, "remove_duplicates"); int prev_len = ci->len; if (rem_dupes) { ConsoleLine *cl; while ((cl = console_history_find(sc, ci->line, ci))) console_history_free(sc, cl); if (STREQ(str, ci->line)) { MEM_freeN(str); return OPERATOR_FINISHED; } } ci = console_history_add_str(sc, str, 1); /* own the string */ console_select_offset(sc, ci->len - prev_len); console_line_cursor_set(ci, cursor); ED_area_tag_redraw(sa); /* when calling render modally this can be NULL when calling: * bpy.ops.render.render('INVOKE_DEFAULT') */ if (ar) { console_scroll_bottom(ar); } return OPERATOR_FINISHED; }