Cleanup: pass boolean to text_drawcache_tag_update
Also remove redundant CTX_wm_space_text(C) calls.
This commit is contained in:
parent
6fbad2ce7e
commit
c7a508be50
|
@ -132,7 +132,7 @@ static void text_listener(const wmSpaceTypeListenerParams *params)
|
|||
switch (wmn->action) {
|
||||
case NA_EDITED:
|
||||
if (st->text) {
|
||||
text_drawcache_tag_update(st, 1);
|
||||
text_drawcache_tag_update(st, true);
|
||||
text_update_edited(st->text);
|
||||
}
|
||||
|
||||
|
|
|
@ -712,7 +712,7 @@ static void text_update_drawcache(SpaceText *st, ARegion *region)
|
|||
drawcache->valid_tail = 0;
|
||||
}
|
||||
|
||||
void text_drawcache_tag_update(SpaceText *st, int full)
|
||||
void text_drawcache_tag_update(SpaceText *st, const bool full)
|
||||
{
|
||||
/* This happens if text editor ops are called from Python. */
|
||||
if (st == NULL) {
|
||||
|
|
|
@ -85,7 +85,7 @@ void wrap_offset_in_line(const struct SpaceText *st,
|
|||
int *offc);
|
||||
int text_get_char_pos(const struct SpaceText *st, const char *line, int cur);
|
||||
|
||||
void text_drawcache_tag_update(struct SpaceText *st, int full);
|
||||
void text_drawcache_tag_update(struct SpaceText *st, bool full);
|
||||
void text_free_caches(struct SpaceText *st);
|
||||
|
||||
bool text_do_suggest_select(struct SpaceText *st, struct ARegion *region, const int mval[2]);
|
||||
|
|
|
@ -306,7 +306,7 @@ static int text_new_exec(bContext *C, wmOperator *UNUSED(op))
|
|||
st->top = 0;
|
||||
st->runtime.scroll_ofs_px[0] = 0;
|
||||
st->runtime.scroll_ofs_px[1] = 0;
|
||||
text_drawcache_tag_update(st, 1);
|
||||
text_drawcache_tag_update(st, true);
|
||||
}
|
||||
|
||||
WM_event_add_notifier(C, NC_TEXT | NA_ADDED, text);
|
||||
|
@ -389,7 +389,7 @@ static int text_open_exec(bContext *C, wmOperator *op)
|
|||
st->runtime.scroll_ofs_px[1] = 0;
|
||||
}
|
||||
|
||||
text_drawcache_tag_update(st, 1);
|
||||
text_drawcache_tag_update(st, true);
|
||||
WM_event_add_notifier(C, NC_TEXT | NA_ADDED, text);
|
||||
|
||||
MEM_freeN(op->customdata);
|
||||
|
@ -479,7 +479,7 @@ static int text_reload_exec(bContext *C, wmOperator *op)
|
|||
|
||||
text_update_edited(text);
|
||||
text_update_cursor_moved(C);
|
||||
text_drawcache_tag_update(CTX_wm_space_text(C), 1);
|
||||
text_drawcache_tag_update(st, true);
|
||||
WM_event_add_notifier(C, NC_TEXT | NA_EDITED, text);
|
||||
|
||||
text->flags &= ~TXT_ISDIRTY;
|
||||
|
@ -538,7 +538,7 @@ static int text_unlink_exec(bContext *C, wmOperator *UNUSED(op))
|
|||
|
||||
BKE_id_delete(bmain, text);
|
||||
|
||||
text_drawcache_tag_update(st, 1);
|
||||
text_drawcache_tag_update(st, true);
|
||||
WM_event_add_notifier(C, NC_TEXT | NA_REMOVED, NULL);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
|
@ -918,8 +918,11 @@ void TEXT_OT_refresh_pyconstraints(wmOperatorType *ot)
|
|||
|
||||
static int text_paste_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
const bool selection = RNA_boolean_get(op->ptr, "selection");
|
||||
SpaceText *st = CTX_wm_space_text(C);
|
||||
Text *text = CTX_data_edit_text(C);
|
||||
|
||||
const bool selection = RNA_boolean_get(op->ptr, "selection");
|
||||
|
||||
char *buf;
|
||||
int buf_len;
|
||||
|
||||
|
@ -930,7 +933,7 @@ static int text_paste_exec(bContext *C, wmOperator *op)
|
|||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
text_drawcache_tag_update(CTX_wm_space_text(C), 0);
|
||||
text_drawcache_tag_update(st, false);
|
||||
|
||||
ED_text_undo_push_init(C);
|
||||
|
||||
|
@ -950,7 +953,7 @@ static int text_paste_exec(bContext *C, wmOperator *op)
|
|||
WM_event_add_notifier(C, NC_TEXT | NA_EDITED, text);
|
||||
|
||||
/* run the script while editing, evil but useful */
|
||||
if (CTX_wm_space_text(C)->live_edit) {
|
||||
if (st->live_edit) {
|
||||
text_run_script(C, NULL);
|
||||
}
|
||||
|
||||
|
@ -1071,9 +1074,10 @@ void TEXT_OT_copy(wmOperatorType *ot)
|
|||
|
||||
static int text_cut_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
{
|
||||
SpaceText *st = CTX_wm_space_text(C);
|
||||
Text *text = CTX_data_edit_text(C);
|
||||
|
||||
text_drawcache_tag_update(CTX_wm_space_text(C), 0);
|
||||
text_drawcache_tag_update(st, false);
|
||||
|
||||
txt_copy_clipboard(text);
|
||||
|
||||
|
@ -1084,7 +1088,7 @@ static int text_cut_exec(bContext *C, wmOperator *UNUSED(op))
|
|||
WM_event_add_notifier(C, NC_TEXT | NA_EDITED, text);
|
||||
|
||||
/* run the script while editing, evil but useful */
|
||||
if (CTX_wm_space_text(C)->live_edit) {
|
||||
if (st->live_edit) {
|
||||
text_run_script(C, NULL);
|
||||
}
|
||||
|
||||
|
@ -1149,9 +1153,10 @@ void TEXT_OT_indent_or_autocomplete(wmOperatorType *ot)
|
|||
|
||||
static int text_indent_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
{
|
||||
SpaceText *st = CTX_wm_space_text(C);
|
||||
Text *text = CTX_data_edit_text(C);
|
||||
|
||||
text_drawcache_tag_update(CTX_wm_space_text(C), 0);
|
||||
text_drawcache_tag_update(st, false);
|
||||
|
||||
ED_text_undo_push_init(C);
|
||||
|
||||
|
@ -1194,9 +1199,10 @@ void TEXT_OT_indent(wmOperatorType *ot)
|
|||
|
||||
static int text_unindent_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
{
|
||||
SpaceText *st = CTX_wm_space_text(C);
|
||||
Text *text = CTX_data_edit_text(C);
|
||||
|
||||
text_drawcache_tag_update(CTX_wm_space_text(C), 0);
|
||||
text_drawcache_tag_update(st, false);
|
||||
|
||||
ED_text_undo_push_init(C);
|
||||
|
||||
|
@ -1239,7 +1245,7 @@ static int text_line_break_exec(bContext *C, wmOperator *UNUSED(op))
|
|||
int a, curts;
|
||||
int space = (text->flags & TXT_TABSTOSPACES) ? st->tabnumber : 1;
|
||||
|
||||
text_drawcache_tag_update(st, 0);
|
||||
text_drawcache_tag_update(st, false);
|
||||
|
||||
/* Double check tabs/spaces before splitting the line. */
|
||||
curts = txt_setcurr_tab_spaces(text, space);
|
||||
|
@ -1291,11 +1297,12 @@ void TEXT_OT_line_break(wmOperatorType *ot)
|
|||
|
||||
static int text_comment_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
SpaceText *st = CTX_wm_space_text(C);
|
||||
Text *text = CTX_data_edit_text(C);
|
||||
int type = RNA_enum_get(op->ptr, "type");
|
||||
const char *prefix = ED_text_format_comment_line_prefix(text);
|
||||
|
||||
text_drawcache_tag_update(CTX_wm_space_text(C), 0);
|
||||
text_drawcache_tag_update(st, false);
|
||||
|
||||
ED_text_undo_push_init(C);
|
||||
|
||||
|
@ -1477,7 +1484,7 @@ static int text_convert_whitespace_exec(bContext *C, wmOperator *op)
|
|||
|
||||
text_update_edited(text);
|
||||
text_update_cursor_moved(C);
|
||||
text_drawcache_tag_update(st, 1);
|
||||
text_drawcache_tag_update(st, true);
|
||||
WM_event_add_notifier(C, NC_TEXT | NA_EDITED, text);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
|
@ -2406,7 +2413,7 @@ static int text_delete_exec(bContext *C, wmOperator *op)
|
|||
Text *text = CTX_data_edit_text(C);
|
||||
int type = RNA_enum_get(op->ptr, "type");
|
||||
|
||||
text_drawcache_tag_update(st, 0);
|
||||
text_drawcache_tag_update(st, true);
|
||||
|
||||
/* behavior could be changed here,
|
||||
* but for now just don't jump words when we have a selection */
|
||||
|
@ -3479,7 +3486,7 @@ static int text_insert_exec(bContext *C, wmOperator *op)
|
|||
size_t i = 0;
|
||||
uint code;
|
||||
|
||||
text_drawcache_tag_update(st, 0);
|
||||
text_drawcache_tag_update(st, false);
|
||||
|
||||
str = RNA_string_get_alloc(op->ptr, "text", NULL, 0, &str_len);
|
||||
|
||||
|
@ -3514,6 +3521,7 @@ static int text_insert_exec(bContext *C, wmOperator *op)
|
|||
|
||||
static int text_insert_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
{
|
||||
SpaceText *st = CTX_wm_space_text(C);
|
||||
uint auto_close_char = 0;
|
||||
int ret;
|
||||
|
||||
|
@ -3551,7 +3559,7 @@ static int text_insert_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
|||
}
|
||||
|
||||
/* run the script while editing, evil but useful */
|
||||
if (ret == OPERATOR_FINISHED && CTX_wm_space_text(C)->live_edit) {
|
||||
if (ret == OPERATOR_FINISHED && st->live_edit) {
|
||||
text_run_script(C, NULL);
|
||||
}
|
||||
|
||||
|
@ -3630,7 +3638,7 @@ static int text_find_and_replace(bContext *C, wmOperator *op, short mode)
|
|||
}
|
||||
text_update_cursor_moved(C);
|
||||
WM_event_add_notifier(C, NC_TEXT | NA_EDITED, text);
|
||||
text_drawcache_tag_update(CTX_wm_space_text(C), 1);
|
||||
text_drawcache_tag_update(st, true);
|
||||
}
|
||||
}
|
||||
MEM_freeN(tmp);
|
||||
|
@ -3716,7 +3724,7 @@ static int text_replace_all(bContext *C)
|
|||
} while (found);
|
||||
|
||||
WM_event_add_notifier(C, NC_TEXT | NA_EDITED, text);
|
||||
text_drawcache_tag_update(CTX_wm_space_text(C), 1);
|
||||
text_drawcache_tag_update(st, true);
|
||||
}
|
||||
else {
|
||||
/* Restore position */
|
||||
|
|
|
@ -209,7 +209,7 @@ static void text_undosys_step_decode(struct bContext *C,
|
|||
st->text = text;
|
||||
}
|
||||
text_update_cursor_moved(C);
|
||||
text_drawcache_tag_update(st, 1);
|
||||
text_drawcache_tag_update(st, true);
|
||||
WM_event_add_notifier(C, NC_TEXT | NA_EDITED, text);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue