Blender V5.3
console_ops.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include <algorithm>
10#include <cctype> /* #ispunct */
11#include <cstdlib>
12#include <cstring>
13#include <sys/stat.h>
14
15#include "MEM_guardedalloc.h"
16
17#include "DNA_userdef_types.h"
18
19#include "BLI_dynstr.hh"
20#include "BLI_listbase.hh"
21#include "BLI_math_base_c.hh"
22#include "BLI_string.hh"
24#include "BLI_string_utf8.hh"
25#include "BLI_utildefines.hh"
26
27#include "BKE_context.hh"
28#include "BKE_global.hh"
29#include "BKE_report.hh"
30#include "BKE_screen.hh"
31
32#include "WM_api.hh"
33#include "WM_types.hh"
34
35#include "ED_screen.hh"
36
37#include "UI_view2d.hh"
38
39#include "RNA_access.hh"
40#include "RNA_define.hh"
41
42#include "console_intern.hh"
43
44namespace blender {
45
46#define TAB_LENGTH 4
47
48/* -------------------------------------------------------------------- */
51
53{
54 if (sc->sel_start == sc->sel_end) {
55 return nullptr;
56 }
57
58 ConsoleLine cl_dummy = {nullptr};
60
61 int offset = 0;
62 for (ConsoleLine &cl : sc->scrollback) {
63 offset += cl.len + 1;
64 }
65
66 char *buf_str = nullptr;
67 if (offset != 0) {
68 offset -= 1;
69 int sel[2] = {offset - sc->sel_end, offset - sc->sel_start};
70 DynStr *buf_dyn = BLI_dynstr_new();
71 for (ConsoleLine &cl : sc->scrollback) {
72 if (sel[0] <= cl.len && sel[1] >= 0) {
73 int sta = max_ii(sel[0], 0);
74 int end = min_ii(sel[1], cl.len);
75
76 if (BLI_dynstr_get_len(buf_dyn)) {
77 BLI_dynstr_append(buf_dyn, "\n");
78 }
79
80 BLI_dynstr_nappend(buf_dyn, cl.line + sta, end - sta);
81 }
82
83 sel[0] -= cl.len + 1;
84 sel[1] -= cl.len + 1;
85 }
86
87 buf_str = BLI_dynstr_get_cstring(buf_dyn);
88
89 BLI_dynstr_free(buf_dyn);
90 }
91 console_scrollback_prompt_end(sc, &cl_dummy);
92
93 return buf_str;
94}
95
97{
98 if (G.background) {
99 return;
100 }
101
103 return;
104 }
105 if (sc->sel_start == sc->sel_end) {
106 return;
107 }
108 char *buf = console_select_to_buffer(sc);
109 if (buf == nullptr) {
110 return;
111 }
112 WM_clipboard_text_set(buf, true);
113 MEM_delete(buf);
114}
115
116/* Delete selected characters in the edit line. */
118{
119 if (sc->sel_start == sc->sel_end) {
120 return 0;
121 }
122
123 sc->sel_start = std::max(sc->sel_start, 0);
124
125 ConsoleLine *cl = sc->history.last();
126 if (!cl || sc->sel_start > cl->len) {
127 sc->sel_start = sc->sel_end;
128 return 0;
129 }
130
131 int del_start = sc->sel_start;
132 int del_end = sc->sel_end;
133
134 del_end = std::min(del_end, cl->len);
135
136 const int len = del_end - del_start;
137 memmove(cl->line + cl->len - del_end, cl->line + cl->len - del_start, del_start);
138 cl->len -= len;
139 cl->line[cl->len] = 0;
140 cl->cursor = cl->len - del_start;
141
142 sc->sel_start = sc->sel_end = cl->cursor;
143 return len;
144}
145
147
148/* so when we type - the view scrolls to the bottom */
149static void console_scroll_bottom(ARegion *region)
150{
151 View2D *v2d = &region->v2d;
152 v2d->cur.ymin = 0.0;
153 v2d->cur.ymax = float(v2d->winy);
154}
155
157{
158 View2D *v2d = &region->v2d;
159
160 ui::view2d_totRect_set(v2d, region->winx - 1, console_textview_height(sc, region));
161}
162
163static void console_select_offset(SpaceConsole *sc, const int offset)
164{
165 sc->sel_start += offset;
166 sc->sel_end += offset;
167}
168
170{
171 BLI_remlink(&sc->history, cl);
172 MEM_delete(cl->line);
173 MEM_delete(cl);
174}
176{
177 BLI_remlink(&sc->scrollback, cl);
178 MEM_delete(cl->line);
179 MEM_delete(cl);
180}
181
183{
184 int tot;
185
186 for (tot = sc->scrollback.count(); tot > U.scrollback; tot--) {
187 console_scrollback_free(sc, sc->scrollback.first());
188 }
189}
190
191/* return 0 if no change made, clamps the range */
192static bool console_line_cursor_set(ConsoleLine *cl, int cursor)
193{
194 int cursor_new;
195
196 if (cursor < 0) {
197 cursor_new = 0;
198 }
199 else if (cursor > cl->len) {
200 cursor_new = cl->len;
201 }
202 else {
203 cursor_new = cursor;
204 }
205
206 if (cursor_new == cl->cursor) {
207 return false;
208 }
209
210 cl->cursor = cursor_new;
211 return true;
212}
213
214#if 0 /* XXX unused */
215static void console_lb_debug__internal(ListBaseT<ConsoleLine> *lb)
216{
217 ConsoleLine *cl;
218
219 printf("%d: ", lb->count());
220 for (cl = lb->first_; cl; cl = cl->next) {
221 printf("<%s> ", cl->line);
222 }
223 printf("\n");
224}
225
226static void console_history_debug(const bContext *C)
227{
229
230 console_lb_debug__internal(&sc->history);
231}
232#endif
233
234static ConsoleLine *console_lb_add__internal(ListBaseT<ConsoleLine> *lb, ConsoleLine *from)
235{
236 ConsoleLine *ci = MEM_new<ConsoleLine>("ConsoleLine Add");
237
238 if (from) {
239 BLI_assert(strlen(from->line) == from->len);
240 ci->line = BLI_strdupn(from->line, from->len);
241 ci->len = ci->len_alloc = from->len;
242 ci->cursor = from->cursor;
243 ci->type = from->type;
244 }
245 else {
246 ci->line = MEM_new_array_zeroed<char>(64, "console-in-line");
247 ci->len_alloc = 64;
248 ci->len = 0;
249 }
250
251 BLI_addtail(lb, ci);
252 return ci;
253}
254
256{
257 return console_lb_add__internal(&sc->history, from);
258}
259
260#if 0 /* may use later ? */
261static ConsoleLine *console_scrollback_add(const bContext *C, ConsoleLine *from)
262{
263 SpaceConsole *sc = CTX_wm_space_console(C);
264
265 return console_lb_add__internal(&sc->scrollback, from);
266}
267#endif
268
269static ConsoleLine *console_lb_add_str__internal(ListBaseT<ConsoleLine> *lb, char *str, bool own)
270{
271 ConsoleLine *ci = MEM_new<ConsoleLine>("ConsoleLine Add");
272 const int str_len = strlen(str);
273 if (own) {
274 ci->line = str;
275 }
276 else {
277 ci->line = BLI_strdupn(str, str_len);
278 }
279
280 ci->len = ci->len_alloc = str_len;
281
282 BLI_addtail(lb, ci);
283 return ci;
284}
286{
287 return console_lb_add_str__internal(&sc->history, str, own);
288}
290{
292 console_select_offset(sc, ci->len + 1);
293 return ci;
294}
295
297{
299 ConsoleLine *ci = sc->history.last();
300 if (ci == nullptr) {
301 ci = console_history_add(sc, nullptr);
302 }
303
304 return ci;
305}
306
308{
309 /* resize the buffer if needed */
310 if (len >= ci->len_alloc) {
311 /* new length */
312#ifndef NDEBUG
313 int new_len = len + 1;
314#else
315 int new_len = (len + 1) * 2;
316#endif
317 ci->line = static_cast<char *>(MEM_realloc_zeroed_id(ci->line, new_len, "console line"));
318 ci->len_alloc = new_len;
319 }
320}
321
322static void console_line_insert(ConsoleLine *ci, const char *str, int len)
323{
324 if (len == 0) {
325 return;
326 }
327
328 BLI_assert(len <= strlen(str));
329 /* The caller must delimit new-lines. */
330 BLI_assert(str[len - 1] != '\n');
331
333
334 memmove(ci->line + ci->cursor + len, ci->line + ci->cursor, (ci->len - ci->cursor) + 1);
335 memcpy(ci->line + ci->cursor, str, len);
336
337 ci->len += len;
338 ci->cursor += len;
339}
340
347 SpaceConsole *sc, const int pos, ConsoleLine **r_cl, int *r_cl_offset, int *r_col)
348{
349 ConsoleLine *cl;
350 int offset = 0;
351
352 for (cl = sc->scrollback.last(); cl; cl = cl->prev) {
353 offset += cl->len + 1;
354 if (offset > pos) {
355 break;
356 }
357 }
358
359 if (cl) {
360 offset -= 1;
361 *r_cl = cl;
362 *r_cl_offset = offset;
363 *r_col = offset - pos;
364 return true;
365 }
366
367 *r_cl = nullptr;
368 *r_cl_offset = -1;
369 *r_col = -1;
370 return false;
371}
372
373/* Static functions for text editing. */
374
375/* similar to the text editor, with some not used. keep compatible */
377 {LINE_BEGIN, "LINE_BEGIN", 0, "Line Begin", ""},
378 {LINE_END, "LINE_END", 0, "Line End", ""},
379 {PREV_CHAR, "PREVIOUS_CHARACTER", 0, "Previous Character", ""},
380 {NEXT_CHAR, "NEXT_CHARACTER", 0, "Next Character", ""},
381 {PREV_WORD, "PREVIOUS_WORD", 0, "Previous Word", ""},
382 {NEXT_WORD, "NEXT_WORD", 0, "Next Word", ""},
383 {0, nullptr, 0, nullptr, nullptr},
384};
385
387{
390 ScrArea *area = CTX_wm_area(C);
392
393 int type = RNA_enum_get(op->ptr, "type");
394 const bool select = RNA_boolean_get(op->ptr, "select");
395
396 bool done = false;
397 const int old_pos = ci->cursor;
398 int pos = 0;
399
400 if (!select && sc->sel_start != sc->sel_end) {
401 /* Clear selection if we are not extending it. */
402 sc->sel_start = sc->sel_end;
403 }
404 const bool had_select = sc->sel_start != sc->sel_end;
405
406 int select_side = 0;
407 if (had_select) {
408 if (sc->sel_start == ci->len - old_pos) {
409 select_side = -1;
410 }
411 else if (sc->sel_end == ci->len - old_pos) {
412 select_side = 1;
413 }
414 }
415
416 switch (type) {
417 case LINE_BEGIN:
418 pos = ci->cursor;
420 done = console_line_cursor_set(ci, pos);
421 break;
422 case LINE_END:
423 pos = ci->cursor;
425 done = console_line_cursor_set(ci, pos);
426 break;
427 case PREV_CHAR:
428 pos = ci->cursor;
430 done = console_line_cursor_set(ci, pos);
431 break;
432 case NEXT_CHAR:
433 pos = ci->cursor;
435 done = console_line_cursor_set(ci, pos);
436 break;
437
438 /* - if the character is a delimiter then skip delimiters (including white space)
439 * - when jump over the word */
440 case PREV_WORD:
441 pos = ci->cursor;
443 done = console_line_cursor_set(ci, pos);
444 break;
445 case NEXT_WORD:
446 pos = ci->cursor;
448 done = console_line_cursor_set(ci, pos);
449 break;
450 }
451
452 if (select) {
453 if (had_select) {
454 if (select_side != 0) {
455 /* Modify the current selection if either side was positioned at the cursor. */
456 if (select_side == -1) {
457 sc->sel_start = ci->len - pos;
458 }
459 else if (select_side == 1) {
460 sc->sel_end = ci->len - pos;
461 }
462 if (sc->sel_start > sc->sel_end) {
463 std::swap(sc->sel_start, sc->sel_end);
464 }
465 }
466 }
467 else {
468 /* Create a new selection. */
469 if (old_pos > pos) {
470 sc->sel_start = ci->len - old_pos;
471 sc->sel_end = ci->len - pos;
472 BLI_assert(sc->sel_start < sc->sel_end);
473 }
474 else if (old_pos < pos) {
475 sc->sel_start = ci->len - pos;
476 sc->sel_end = ci->len - old_pos;
477 BLI_assert(sc->sel_start < sc->sel_end);
478 }
479 }
480 }
481
482 if (done) {
483 ED_area_tag_redraw(area);
484 console_scroll_bottom(region);
485 }
486
487 return OPERATOR_FINISHED;
488}
489
491{
492 /* identifiers */
493 ot->name = "Move Cursor";
494 ot->description = "Move cursor position";
495 ot->idname = "CONSOLE_OT_move";
496
497 /* API callbacks. */
500
501 /* properties */
503 ot->srna, "type", console_move_type_items, LINE_BEGIN, "Type", "Where to move cursor to");
505 ot->srna, "select", false, "Select", "Whether to select while moving");
507}
508
510{
512 ScrArea *area = CTX_wm_area(C);
515 char *str = RNA_string_get_alloc(op->ptr, "text", nullptr, 0, nullptr);
516 int len = strlen(str);
517
518 /* Allow trailing newlines (but strip them). */
519 while (len > 0 && str[len - 1] == '\n') {
520 len--;
521 str[len] = '\0';
522 }
523
524 if (strchr(str, '\n')) {
525 BKE_report(op->reports, RPT_ERROR, "New lines unsupported, call this operator multiple times");
526 /* Force cancel. */
527 len = 0;
528 }
529
530 if (len != 0) {
533 }
534
535 MEM_delete(str);
536
537 if (len == 0) {
538 return OPERATOR_CANCELLED;
539 }
540
542
544 ED_area_tag_redraw(area);
545
546 console_scroll_bottom(region);
547
548 return OPERATOR_FINISHED;
549}
550
552{
553#ifdef WITH_INPUT_IME
554 if (const std::optional<wmOperatorStatus> status = WM_operator_IME_insert_maybe(
555 C, op, event, "text"))
556 {
557 return *status;
558 }
559#endif
560
561 /* NOTE: the "text" property is always set from key-map,
562 * so we can't use #RNA_struct_property_is_set, check the length instead. */
563 if (!RNA_string_length(op->ptr, "text")) {
564 /* If alt/control/super are pressed pass through except for UTF8 character event
565 * (when input method are used for UTF8 inputs, the user may assign key event
566 * including alt/control/super like control-m to commit UTF8 string.
567 * in such case, the modifiers in the UTF8 character event make no sense.) */
568 if ((event->modifier & (KM_CTRL | KM_OSKEY)) && !event->utf8_buf[0]) {
570 }
571
572 char str[BLI_UTF8_MAX + 1];
573 const size_t len = BLI_str_utf8_size_safe(event->utf8_buf);
574 memcpy(str, event->utf8_buf, len);
575 str[len] = '\0';
576 RNA_string_set(op->ptr, "text", str);
577 }
578 return console_insert_exec(C, op);
579}
580
582{
583 PropertyRNA *prop;
584
585 /* identifiers */
586 ot->name = "Insert";
587 ot->description = "Insert text at cursor position";
588 ot->idname = "CONSOLE_OT_insert";
589
590 /* API callbacks. */
594
595 /* properties */
596 prop = RNA_def_string(
597 ot->srna, "text", nullptr, 0, "Text", "Text to insert at the cursor position");
599}
600
601/* -------------------------------------------------------------------- */
604
606{
608 bool text_before_cursor = false;
609
610 /* Check any text before cursor (not just the previous character) as is done for
611 * #TEXT_OT_indent_or_autocomplete because Python auto-complete operates on import
612 * statements such as completing possible sub-modules: `from bpy import `. */
613 for (int i = 0; i < ci->cursor; i += BLI_str_utf8_size_safe(&ci->line[i])) {
614 if (!ELEM(ci->line[i], ' ', '\t')) {
615 text_before_cursor = true;
616 break;
617 }
618 }
619
620 if (text_before_cursor) {
622 C, "CONSOLE_OT_autocomplete", wm::OpCallContext::InvokeDefault, nullptr, nullptr);
623 }
624 else {
626 C, "CONSOLE_OT_indent", wm::OpCallContext::ExecDefault, nullptr, nullptr);
627 }
628 return OPERATOR_FINISHED;
629}
630
632{
633 /* identifiers */
634 ot->name = "Indent or Autocomplete";
635 ot->idname = "CONSOLE_OT_indent_or_autocomplete";
636 ot->description = "Indent selected text or autocomplete";
637
638 /* API callbacks. */
641
642 /* flags */
643 ot->flag = 0;
644}
645
647
648/* -------------------------------------------------------------------- */
651
653{
656 ScrArea *area = CTX_wm_area(C);
658
659 int spaces;
660 int len;
661
662 for (spaces = 0; spaces < ci->len; spaces++) {
663 if (ci->line[spaces] != ' ') {
664 break;
665 }
666 }
667
668 len = TAB_LENGTH - spaces % TAB_LENGTH;
669
671
672 memmove(ci->line + len, ci->line, ci->len + 1);
673 memset(ci->line, ' ', len);
674 ci->len += len;
675 BLI_assert(ci->len >= 0);
678
680 ED_area_tag_redraw(area);
681
682 console_scroll_bottom(region);
683
684 return OPERATOR_FINISHED;
685}
686
688{
689 /* identifiers */
690 ot->name = "Indent";
691 ot->description = "Add 4 spaces at line beginning";
692 ot->idname = "CONSOLE_OT_indent";
693
694 /* API callbacks. */
697}
698
700
702{
705 ScrArea *area = CTX_wm_area(C);
707
708 int spaces;
709 int len;
710
711 for (spaces = 0; spaces < ci->len; spaces++) {
712 if (ci->line[spaces] != ' ') {
713 break;
714 }
715 }
716
717 if (spaces == 0) {
718 return OPERATOR_CANCELLED;
719 }
720
721 len = spaces % TAB_LENGTH;
722 if (len == 0) {
723 len = TAB_LENGTH;
724 }
725
727
728 memmove(ci->line, ci->line + len, (ci->len - len) + 1);
729 ci->len -= len;
730 BLI_assert(ci->len >= 0);
731
734
736 ED_area_tag_redraw(area);
737
738 console_scroll_bottom(region);
739
740 return OPERATOR_FINISHED;
741}
742
744{
745 /* identifiers */
746 ot->name = "Unindent";
747 ot->description = "Delete 4 spaces from line beginning";
748 ot->idname = "CONSOLE_OT_unindent";
749
750 /* API callbacks. */
753}
754
756 {DEL_NEXT_CHAR, "NEXT_CHARACTER", 0, "Next Character", ""},
757 {DEL_PREV_CHAR, "PREVIOUS_CHARACTER", 0, "Previous Character", ""},
758 {DEL_NEXT_WORD, "NEXT_WORD", 0, "Next Word", ""},
759 {DEL_PREV_WORD, "PREVIOUS_WORD", 0, "Previous Word", ""},
760 {0, nullptr, 0, nullptr, nullptr},
761};
762
764{
765#ifdef WITH_INPUT_IME
766 if (const std::optional<wmOperatorStatus> status = WM_operator_IME_edit_maybe(C)) {
767 return *status;
768 }
769#endif
770
773 ScrArea *area = CTX_wm_area(C);
775
776 int pos;
777 int stride;
778
779 const short type = RNA_enum_get(op->ptr, "type");
780 bool done = false;
781
782 if (ci->len == 0) {
783 return OPERATOR_CANCELLED;
784 }
785
786 /* If there is a selection just delete it and nothing else. */
787 if (sc->sel_start != sc->sel_end && console_delete_editable_selection(sc) > 0) {
789 ED_area_tag_redraw(area);
790 console_scroll_bottom(region);
791 return OPERATOR_FINISHED;
792 }
793
794 switch (type) {
795 case DEL_NEXT_CHAR:
796 case DEL_NEXT_WORD:
797 if (ci->cursor < ci->len) {
798 pos = ci->cursor;
800 ci->len,
801 &pos,
804 true);
805 stride = pos - ci->cursor;
806 if (stride) {
807 memmove(ci->line + ci->cursor,
808 ci->line + ci->cursor + stride,
809 (ci->len - (ci->cursor + stride)) + 1);
810 ci->len -= stride;
811 BLI_assert(ci->len >= 0);
812 done = true;
813 }
814 }
815 break;
816 case DEL_PREV_CHAR:
817 case DEL_PREV_WORD:
818 if (ci->cursor > 0) {
819 pos = ci->cursor;
821 ci->len,
822 &pos,
825 true);
826 stride = ci->cursor - pos;
827 if (stride) {
828 ci->cursor -= stride; /* same as above */
829 memmove(ci->line + ci->cursor,
830 ci->line + ci->cursor + stride,
831 (ci->len - (ci->cursor + stride)) + 1);
832 ci->len -= stride;
833 BLI_assert(ci->len >= 0);
834 done = true;
835 }
836 }
837 break;
838 }
839
840 if (!done) {
841 return OPERATOR_CANCELLED;
842 }
843
844 console_select_offset(sc, -stride);
845
847 ED_area_tag_redraw(area);
848
849 console_scroll_bottom(region);
850
851 return OPERATOR_FINISHED;
852}
853
855{
856 /* identifiers */
857 ot->name = "Delete";
858 ot->description = "Delete text by cursor position";
859 ot->idname = "CONSOLE_OT_delete";
860
861 /* API callbacks. */
864
865 /* properties */
866 RNA_def_enum(ot->srna,
867 "type",
870 "Type",
871 "Which part of the text to delete");
872}
873
875{
878 ScrArea *area = CTX_wm_area(C);
880
881 if (ci->len == 0) {
882 return OPERATOR_CANCELLED;
883 }
884
885 console_history_add(sc, ci);
886 console_history_add(sc, nullptr);
887 console_select_offset(sc, -ci->len);
888
890
891 ED_area_tag_redraw(area);
892
893 console_scroll_bottom(region);
894
895 return OPERATOR_FINISHED;
896}
897
899{
900 /* identifiers */
901 ot->name = "Clear Line";
902 ot->description = "Clear the line and store in history";
903 ot->idname = "CONSOLE_OT_clear_line";
904
905 /* API callbacks. */
908}
909
910/* the python exec operator uses this */
912{
914 ScrArea *area = CTX_wm_area(C);
916
917 const bool scrollback = RNA_boolean_get(op->ptr, "scrollback");
918 const bool history = RNA_boolean_get(op->ptr, "history");
919
920 /* ConsoleLine *ci = */ console_history_verify(C);
921
922 if (scrollback) { /* Last item in history. */
923 while (sc->scrollback.first_) {
924 console_scrollback_free(sc, sc->scrollback.first());
925 }
926 }
927
928 if (history) {
929 while (sc->history.first_) {
930 console_history_free(sc, sc->history.first());
931 }
933 }
934
936 ED_area_tag_redraw(area);
937
938 return OPERATOR_FINISHED;
939}
940
942{
943 /* identifiers */
944 ot->name = "Clear All";
945 ot->description = "Clear text by type";
946 ot->idname = "CONSOLE_OT_clear";
947
948 /* API callbacks. */
951
952 /* properties */
953 RNA_def_boolean(ot->srna, "scrollback", true, "Scrollback", "Clear the scrollback history");
954 RNA_def_boolean(ot->srna, "history", false, "History", "Clear the command history");
955}
956
957/* the python exec operator uses this */
959{
961 ScrArea *area = CTX_wm_area(C);
963
964 /* TODO: stupid, just prevents crashes when no command line. */
966 const bool reverse = RNA_boolean_get(op->ptr, "reverse"); /* assumes down, reverse is up */
967 int prev_len = ci->len;
968
969 int old_index = sc->history_index;
970 int new_index;
971 if (reverse) {
972 if (old_index <= 0) {
973 new_index = 1;
974 }
975 else {
976 new_index = old_index + 1;
977 }
978 }
979 else {
980 if (old_index <= 0) { /* Down-arrow after exec. */
981 new_index = -old_index;
982 }
983 else {
984 new_index = old_index - 1;
985 }
986 }
987
988 /* Find the history item. */
989 ConsoleLine *ci_prev = ci;
990 if (old_index > 0) {
991 /* Skip a previous copy of history item. */
992 if (ci_prev->prev) {
993 ci_prev = ci_prev->prev;
994 }
995 else { /* Just in case the duplicate item got deleted. */
996 old_index = 0;
997 }
998 }
999 for (int i = 0; i < new_index; i++) {
1000 if (!ci_prev->prev) {
1001 new_index = i;
1002 break;
1003 }
1004 ci_prev = ci_prev->prev;
1005 }
1006
1007 sc->history_index = new_index;
1008
1009 if (old_index > 0) { /* Remove old copy. */
1010 console_history_free(sc, ci);
1011 ci = ci_prev;
1012 }
1013 if (new_index > 0) { /* Copy history item to the end. */
1014 ci = console_history_add(sc, ci_prev);
1015 }
1016
1017 console_select_offset(sc, ci->len - prev_len);
1018
1019 /* could be wrapped so update scroll rect */
1020 console_textview_update_rect(sc, region);
1021 ED_area_tag_redraw(area);
1022
1023 console_scroll_bottom(region);
1024
1025 return OPERATOR_FINISHED;
1026}
1027
1029{
1030 /* identifiers */
1031 ot->name = "History Cycle";
1032 ot->description = "Cycle through history";
1033 ot->idname = "CONSOLE_OT_history_cycle";
1034
1035 /* API callbacks. */
1038
1039 /* properties */
1040 RNA_def_boolean(ot->srna, "reverse", false, "Reverse", "Reverse cycle history");
1041}
1042
1043/* the python exec operator uses this */
1045{
1047 ScrArea *area = CTX_wm_area(C);
1049
1051 /* own this text in the new line, don't free */
1052 char *str = RNA_string_get_alloc(op->ptr, "text", nullptr, 0, nullptr);
1053 int cursor = RNA_int_get(op->ptr, "current_character");
1054 const bool rem_dupes = RNA_boolean_get(op->ptr, "remove_duplicates");
1055 int prev_len = ci->len;
1056
1057 if (sc->history_index > 0) {
1058 /* Keep the copy of history item, remove the saved "history 0". */
1059 ConsoleLine *cl = ci->prev;
1060 if (cl) {
1061 console_history_free(sc, cl);
1062 }
1063 /* Negative number makes down-arrow go to same item as before. */
1064 sc->history_index = -sc->history_index;
1065 }
1066
1067 if (rem_dupes) {
1068 /* Remove a repeated command. */
1069 ConsoleLine *cl = ci->prev;
1070 if (cl && STREQ(cl->line, ci->line)) {
1071 console_history_free(sc, cl);
1072 }
1073 /* Remove blank command. */
1074 if (STREQ(str, ci->line)) {
1075 MEM_delete(str);
1076 return OPERATOR_FINISHED;
1077 }
1078 }
1079
1080 ci = console_history_add_str(sc, str, true); /* own the string */
1081 console_select_offset(sc, ci->len - prev_len);
1082 console_line_cursor_set(ci, cursor);
1083
1084 ED_area_tag_redraw(area);
1085 console_scroll_bottom(region);
1086
1087 return OPERATOR_FINISHED;
1088}
1089
1091{
1092 /* identifiers */
1093 ot->name = "History Append";
1094 ot->description = "Append history at cursor position";
1095 ot->idname = "CONSOLE_OT_history_append";
1096
1097 /* API callbacks. */
1100
1101 /* properties */
1102 RNA_def_string(ot->srna, "text", nullptr, 0, "Text", "Text to insert at the cursor position");
1104 ot->srna, "current_character", 0, 0, INT_MAX, "Cursor", "The index of the cursor", 0, 10000);
1106 "remove_duplicates",
1107 false,
1108 "Remove Duplicates",
1109 "Remove duplicate items in the history");
1110}
1111
1112/* the python exec operator uses this */
1114{
1116 ConsoleLine *ci;
1117 ScrArea *area = CTX_wm_area(C);
1119
1120 /* own this text in the new line, don't free */
1121 char *str = RNA_string_get_alloc(op->ptr, "text", nullptr, 0, nullptr);
1122 int type = RNA_enum_get(op->ptr, "type");
1123
1125
1126 ci = console_scrollback_add_str(sc, str, true); /* own the string */
1127 ci->type = type;
1128
1130
1131 console_textview_update_rect(sc, region);
1132 ED_area_tag_redraw(area);
1133
1134 return OPERATOR_FINISHED;
1135}
1136
1138{
1139 /* defined in DNA_space_types.h */
1140 static const EnumPropertyItem console_line_type_items[] = {
1141 {CONSOLE_LINE_OUTPUT, "OUTPUT", 0, "Output", ""},
1142 {CONSOLE_LINE_INPUT, "INPUT", 0, "Input", ""},
1143 {CONSOLE_LINE_INFO, "INFO", 0, "Information", ""},
1144 {CONSOLE_LINE_ERROR, "ERROR", 0, "Error", ""},
1145 {0, nullptr, 0, nullptr, nullptr},
1146 };
1147
1148 /* identifiers */
1149 ot->name = "Scrollback Append";
1150 ot->description = "Append scrollback text by type";
1151 ot->idname = "CONSOLE_OT_scrollback_append";
1152
1153 /* API callbacks. */
1156
1157 /* properties */
1158 RNA_def_string(ot->srna, "text", nullptr, 0, "Text", "Text to insert at the cursor position");
1159 RNA_def_enum(ot->srna,
1160 "type",
1161 console_line_type_items,
1163 "Type",
1164 "Console output type");
1165}
1166
1168{
1170 char *buf = console_select_to_buffer(sc);
1171 if (buf == nullptr) {
1172 return OPERATOR_CANCELLED;
1173 }
1174
1175 WM_clipboard_text_set(buf, false);
1176
1177 if (RNA_boolean_get(op->ptr, "delete")) {
1180 }
1181
1182 MEM_delete(buf);
1183 return OPERATOR_FINISHED;
1184}
1185
1187{
1189 return ED_operator_console_active(C) && sc && (sc->sel_start != sc->sel_end);
1190}
1191
1193{
1194 /* identifiers */
1195 ot->name = "Copy to Clipboard";
1196 ot->description = "Copy selected text to clipboard";
1197 ot->idname = "CONSOLE_OT_copy";
1198
1199 /* API callbacks. */
1200 ot->poll = console_copy_poll;
1201 ot->exec = console_copy_exec;
1202
1203 /* properties */
1204 PropertyRNA *prop = RNA_def_boolean(ot->srna,
1205 "delete",
1206 false,
1207 "Delete Selection",
1208 "Whether to delete the selection after copying");
1210}
1211
1213{
1214 const bool selection = RNA_boolean_get(op->ptr, "selection");
1217 ScrArea *area = CTX_wm_area(C);
1218
1219 int buf_str_len;
1220
1221 char *buf_str = WM_clipboard_text_get(selection, true, &buf_str_len);
1222 if (buf_str == nullptr) {
1223 return OPERATOR_CANCELLED;
1224 }
1225 if (*buf_str == '\0') {
1226 MEM_delete(buf_str);
1227 return OPERATOR_CANCELLED;
1228 }
1229 bool context_valid = true;
1230 const char *buf_step = buf_str;
1231 do {
1232 const char *buf = buf_step;
1233 buf_step = const_cast<char *>(BLI_strchr_or_end(buf, '\n'));
1234 const int buf_len = buf_step - buf;
1235 if (buf != buf_str) {
1237 C, "CONSOLE_OT_execute", wm::OpCallContext::ExecDefault, nullptr, nullptr);
1238 /* Detect context changes from actions such as loading a new file or direct
1239 * context manipulation (switching area type for e.g.).
1240 * While it's not an error, we only support executing in the active context.
1241 * So bail out with a warning, see: #161595. */
1242 if (sc != CTX_wm_space_console(C)) {
1243 context_valid = false;
1244 break;
1245 }
1247 }
1249 console_line_insert(ci, buf, buf_len);
1250 console_select_offset(sc, buf_len);
1251 } while (*buf_step ? ((void)buf_step++, true) : false);
1252
1253 MEM_delete(buf_str);
1254
1255 if (context_valid) {
1257 console_textview_update_rect(sc, region);
1258 ED_area_tag_redraw(area);
1259
1260 console_scroll_bottom(region);
1261 }
1262 else {
1263 BKE_report(op->reports,
1265 "Context changed during paste, "
1266 "console execution may be incomplete");
1267 }
1268
1269 return OPERATOR_FINISHED;
1270}
1271
1273{
1274 /* identifiers */
1275 ot->name = "Paste from Clipboard";
1276 ot->description = "Paste text from clipboard";
1277 ot->idname = "CONSOLE_OT_paste";
1278
1279 /* API callbacks. */
1282
1283 /* properties */
1284 PropertyRNA *prop;
1285 prop = RNA_def_boolean(ot->srna,
1286 "selection",
1287 false,
1288 "Selection",
1289 "Paste text selected elsewhere rather than copied (X11/Wayland only)");
1291}
1292
1294 int sel_old[2];
1296};
1297
1299 ARegion *region,
1300 SetConsoleCursor *scu,
1301 const wmEvent *event)
1302{
1303 int pos = console_char_pick(sc, region, event->mval);
1304 bool dragging = event->type == MOUSEMOVE;
1305
1306 if (scu->sel_init == INT_MAX) {
1307 scu->sel_init = pos;
1308 sc->sel_start = sc->sel_end = pos;
1309 return;
1310 }
1311
1312 if (pos < scu->sel_init) {
1313 sc->sel_start = pos;
1314 sc->sel_end = scu->sel_init;
1315 }
1316 else if (pos > sc->sel_start) {
1317 sc->sel_start = scu->sel_init;
1318 sc->sel_end = pos;
1319 }
1320 else {
1321 sc->sel_start = sc->sel_end = pos;
1322 }
1323
1324 /* Move text cursor to the last selection point. */
1325 ConsoleLine *cl = sc->history.last();
1326
1327 if (cl != nullptr) {
1328 if (dragging && sc->sel_end > cl->len && pos <= cl->len) {
1329 /* Do not move cursor while dragging into the editable area. */
1330 }
1331 else if (pos <= cl->len) {
1332 console_line_cursor_set(cl, cl->len - pos);
1333 }
1334 else if (pos > cl->len && sc->sel_start < cl->len) {
1335 /* Dragging out of editable area, move cursor to start of selection. */
1336 console_line_cursor_set(cl, cl->len - sc->sel_start);
1337 }
1338 }
1339}
1340
1342{
1344 ScrArea *area = CTX_wm_area(C);
1346
1347 SetConsoleCursor *scu = static_cast<SetConsoleCursor *>(op->customdata);
1348 const int sel_prev[2] = {sc->sel_start, sc->sel_end};
1349
1350 console_cursor_set_to_pos(sc, region, scu, event);
1351
1352 /* only redraw if the selection changed */
1353 if (sel_prev[0] != sc->sel_start || sel_prev[1] != sc->sel_end) {
1354 ED_area_tag_redraw(area);
1355 }
1356}
1357
1359{
1361 SetConsoleCursor *scu = static_cast<SetConsoleCursor *>(op->customdata);
1362
1364
1365 MEM_delete(scu);
1366}
1367
1369 wmOperator *op,
1370 const wmEvent *event)
1371{
1373 ScrArea *area = CTX_wm_area(C);
1375
1376 SetConsoleCursor *scu;
1377
1378 ConsoleLine *cl = sc->history.last();
1379 if (cl != nullptr) {
1380 const int pos = console_char_pick(sc, region, event->mval);
1381 if (pos >= 0 && pos <= cl->len) {
1382 /* Set text cursor immediately. */
1383 console_line_cursor_set(cl, cl->len - pos);
1384 }
1385 }
1386
1387 op->customdata = MEM_new_zeroed<SetConsoleCursor>("SetConsoleCursor");
1388 scu = static_cast<SetConsoleCursor *>(op->customdata);
1389
1390 scu->sel_old[0] = sc->sel_start;
1391 scu->sel_old[1] = sc->sel_end;
1392
1393 scu->sel_init = INT_MAX;
1394
1396
1397 console_modal_select_apply(C, op, event);
1398
1400}
1401
1403{
1404 /* Move text cursor to the last selection point. */
1405 switch (event->type) {
1406 case LEFTMOUSE:
1407 case MIDDLEMOUSE:
1408 case RIGHTMOUSE:
1409 if (event->val == KM_PRESS) {
1410 console_modal_select_apply(C, op, event);
1411 break;
1412 }
1413 else if (event->val == KM_RELEASE) {
1414 console_modal_select_apply(C, op, event);
1417 return OPERATOR_FINISHED;
1418 }
1419 break;
1420 case MOUSEMOVE:
1421 console_modal_select_apply(C, op, event);
1422 break;
1423 default: {
1424 break;
1425 }
1426 }
1427
1429}
1430
1435
1437{
1438 /* identifiers */
1439 ot->name = "Set Selection";
1440 ot->idname = "CONSOLE_OT_select_set";
1441 ot->description = "Set the console selection";
1442
1443 /* API callbacks. */
1448}
1449
1451 wmOperator * /*op*/,
1452 const wmEvent * /*event*/)
1453{
1454 ScrArea *area = CTX_wm_area(C);
1456
1457 int offset = strlen(sc->prompt);
1458
1459 for (ConsoleLine &cl : sc->scrollback) {
1460 offset += cl.len + 1;
1461 }
1462
1463 ConsoleLine *cl = sc->history.last();
1464 if (cl) {
1465 offset += cl->len + 1;
1466 }
1467
1468 sc->sel_start = 0;
1469 sc->sel_end = offset;
1470
1471 ED_area_tag_redraw(area);
1472
1473 return OPERATOR_FINISHED;
1474}
1475
1477{
1478 /* identifiers */
1479 ot->name = "Select All";
1480 ot->idname = "CONSOLE_OT_select_all";
1481 ot->description = "Select all the text";
1482
1483 /* API callbacks. */
1486}
1487
1489 wmOperator * /*op*/,
1490 const wmEvent *event)
1491{
1493 ScrArea *area = CTX_wm_area(C);
1495
1496 ConsoleLine cl_dummy = {nullptr};
1497 ConsoleLine *cl;
1499 int pos, offset, n;
1500
1501 pos = console_char_pick(sc, region, event->mval);
1502
1503 console_scrollback_prompt_begin(sc, &cl_dummy);
1504
1505 if (console_line_column_from_index(sc, pos, &cl, &offset, &n)) {
1506 int sel[2] = {n, n};
1507
1508 BLI_str_cursor_step_bounds_utf8(cl->line, cl->len, n, &sel[1], &sel[0]);
1509
1510 sel[0] = offset - sel[0];
1511 sel[1] = offset - sel[1];
1512
1513 if ((sel[0] != sc->sel_start) || (sel[1] != sc->sel_end)) {
1514 sc->sel_start = sel[0];
1515 sc->sel_end = sel[1];
1516 ED_area_tag_redraw(area);
1518 }
1519 }
1520
1521 console_scrollback_prompt_end(sc, &cl_dummy);
1522
1523 ConsoleLine *ci = sc->history.last();
1524 if (ci && sc->sel_start <= ci->len) {
1525 console_line_cursor_set(ci, ci->len - sc->sel_start);
1526 }
1527
1528 if (ret & OPERATOR_FINISHED) {
1530 }
1531
1532 return ret;
1533}
1534
1536{
1537 /* identifiers */
1538 ot->name = "Select Word";
1539 ot->description = "Select word at cursor position";
1540 ot->idname = "CONSOLE_OT_select_word";
1541
1542 /* API callbacks. */
1545}
1546
1547} // namespace blender
A dynamically sized string ADT.
#define BLI_UTF8_MAX
Read Blender memory allocation and freeing.
#define C
Definition RandGen.cpp:29
#define ELEM(...)
#define STREQ(a, b)
#define TAB_LENGTH
#define printf
#define str(s)
#define INT_MAX
ccl_device_inline dual1 len(const ccl_private dual< T > &a)
Definition math_dual.h:263
void view2d_totRect_set(View2D *v2d, int width, int height)
Definition view2d.cc:1021
BMesh Iterators.
UserDef U
Definition blender.cc:58
void CONSOLE_OT_history_cycle(wmOperatorType *ot)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
static void console_cursor_set_exit(bContext *C, wmOperator *op)
static wmOperatorStatus console_indent_exec(bContext *C, wmOperator *)
ScrArea * CTX_wm_area(const bContext *C)
int RNA_enum_get(PointerRNA *ptr, const char *name)
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, const int maxlen, const char *ui_name, const char *ui_description)
@ RPT_WARNING
Definition BKE_report.hh:40
static void console_modal_select_apply(bContext *C, wmOperator *op, const wmEvent *event)
static void console_line_verify_length(ConsoleLine *ci, int len)
void BLI_dynstr_nappend(DynStr *__restrict ds, const char *cstr, int len) ATTR_NONNULL()
Definition BLI_dynstr.cc:77
void CONSOLE_OT_scrollback_append(wmOperatorType *ot)
SpaceConsole * CTX_wm_space_console(const bContext *C)
static wmOperatorStatus console_clear_exec(bContext *C, wmOperator *op)
void CONSOLE_OT_paste(wmOperatorType *ot)
static const EnumPropertyItem console_move_type_items[]
void RNA_string_set(PointerRNA *ptr, const char *name, const char *value)
void CONSOLE_OT_select_set(wmOperatorType *ot)
static wmOperatorStatus console_modal_select_all_invoke(bContext *C, wmOperator *, const wmEvent *)
static void console_select_set_cancel(bContext *C, wmOperator *op)
static wmOperatorStatus console_select_set_invoke(bContext *C, wmOperator *op, const wmEvent *event)
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
void CONSOLE_OT_select_all(wmOperatorType *ot)
ConsoleLine * console_history_verify(const bContext *C)
int RNA_int_get(PointerRNA *ptr, const char *name)
ConsoleLine * console_scrollback_add_str(SpaceConsole *sc, char *str, bool own)
char * BLI_strdupn(const char *str, size_t len) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
MINLINE int max_ii(int a, int b)
void CONSOLE_OT_select_word(wmOperatorType *ot)
char * RNA_string_get_alloc(PointerRNA *ptr, const char *name, char *fixedbuf, int fixedlen, int *r_len)
void BLI_dynstr_free(DynStr *ds) ATTR_NONNULL()
void CONSOLE_OT_copy(wmOperatorType *ot)
static wmOperatorStatus console_history_append_exec(bContext *C, wmOperator *op)
static char * console_select_to_buffer(SpaceConsole *sc)
Global G
Definition blender.cc:57
static wmOperatorStatus console_paste_exec(bContext *C, wmOperator *op)
static wmOperatorStatus console_unindent_exec(bContext *C, wmOperator *)
static void console_scrollback_limit(SpaceConsole *sc)
void CONSOLE_OT_unindent(wmOperatorType *ot)
void CONSOLE_OT_clear_line(wmOperatorType *ot)
void BLI_dynstr_append(DynStr *__restrict ds, const char *cstr) ATTR_NONNULL()
Definition BLI_dynstr.cc:58
void * MEM_new_zeroed(size_t len, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2)
static wmOperatorStatus console_delete_exec(bContext *C, wmOperator *op)
void BLI_remlink(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:138
void BKE_report(ReportList *reports, eReportType type, const char *message)
Definition report.cc:162
static wmOperatorStatus console_select_set_modal(bContext *C, wmOperator *op, const wmEvent *event)
bool ED_operator_console_active(bContext *C)
void CONSOLE_OT_history_append(wmOperatorType *ot)
static void console_select_update_primary_clipboard(SpaceConsole *sc)
void console_history_free(SpaceConsole *sc, ConsoleLine *cl)
static bool console_line_column_from_index(SpaceConsole *sc, const int pos, ConsoleLine **r_cl, int *r_cl_offset, int *r_col)
char * BLI_dynstr_get_cstring(const DynStr *ds) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
void CONSOLE_OT_indent(wmOperatorType *ot)
int BLI_str_utf8_size_safe(const char *p) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
wmOperatorStatus WM_operator_name_call(bContext *C, const char *opstring, wm::OpCallContext context, PointerRNA *properties, const wmEvent *event)
void console_textview_update_rect(SpaceConsole *sc, ARegion *region)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
static wmOperatorStatus console_insert_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static void console_scroll_bottom(ARegion *region)
int RNA_string_length(PointerRNA *ptr, const char *name)
void CONSOLE_OT_clear(wmOperatorType *ot)
static void console_line_insert(ConsoleLine *ci, const char *str, int len)
static wmOperatorStatus console_copy_exec(bContext *C, wmOperator *op)
void CONSOLE_OT_indent_or_autocomplete(wmOperatorType *ot)
@ WM_CAPABILITY_CLIPBOARD_PRIMARY
Definition WM_api.hh:227
ARegion * BKE_area_find_region_type(const ScrArea *area, int region_type)
Definition screen.cc:1024
static ConsoleLine * console_lb_add__internal(ListBaseT< ConsoleLine > *lb, ConsoleLine *from)
wmEventHandler_Op * WM_event_add_modal_handler(bContext *C, wmOperator *op)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
static void console_select_offset(SpaceConsole *sc, const int offset)
PropertyRNA * RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, const int default_value, const int hardmin, const int hardmax, const char *ui_name, const char *ui_description, const int softmin, const int softmax)
static bool console_copy_poll(bContext *C)
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:118
char * WM_clipboard_text_get(bool selection, bool ensure_utf8, int *r_len)
static wmOperatorStatus console_history_cycle_exec(bContext *C, wmOperator *op)
static ConsoleLine * console_lb_add_str__internal(ListBaseT< ConsoleLine > *lb, char *str, bool own)
void BLI_str_cursor_step_utf8(const char *str, int str_maxlen, int *pos, eStrCursorJumpDirection direction, eStrCursorJumpType jump, bool use_init_step)
eWM_CapabilitiesFlag WM_capabilities_flag()
void CONSOLE_OT_move(wmOperatorType *ot)
void WM_clipboard_text_set(const char *buf, bool selection)
@ PROP_SKIP_SAVE
Definition RNA_types.hh:414
static wmOperatorStatus console_move_exec(bContext *C, wmOperator *op)
void CONSOLE_OT_insert(wmOperatorType *ot)
@ KM_RELEASE
Definition WM_types.hh:325
static wmOperatorStatus console_scrollback_append_exec(bContext *C, wmOperator *op)
int console_textview_height(SpaceConsole *sc, const ARegion *region)
static bool console_line_cursor_set(ConsoleLine *cl, int cursor)
static wmOperatorStatus console_insert_exec(bContext *C, wmOperator *op)
static const EnumPropertyItem console_delete_type_items[]
static wmOperatorStatus console_indent_or_autocomplete_exec(bContext *C, wmOperator *)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
void console_scrollback_free(SpaceConsole *sc, ConsoleLine *cl)
int BLI_dynstr_get_len(const DynStr *ds) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
void *(*) MEM_realloc_zeroed_id(void *vmemh, size_t len, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(2)
MINLINE int min_ii(int a, int b)
void console_scrollback_prompt_end(SpaceConsole *sc, ConsoleLine *cl_dummy)
DynStr * BLI_dynstr_new() ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
Definition BLI_dynstr.cc:39
ConsoleLine * console_history_add_str(SpaceConsole *sc, char *str, bool own)
static void console_cursor_set_to_pos(SpaceConsole *sc, ARegion *region, SetConsoleCursor *scu, const wmEvent *event)
static wmOperatorStatus console_selectword_invoke(bContext *C, wmOperator *, const wmEvent *event)
void console_scrollback_prompt_begin(SpaceConsole *sc, ConsoleLine *cl_dummy)
static int console_delete_editable_selection(SpaceConsole *sc)
void CONSOLE_OT_delete(wmOperatorType *ot)
void * MEM_new_array_zeroed(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
static ConsoleLine * console_history_add(SpaceConsole *sc, ConsoleLine *from)
int console_char_pick(SpaceConsole *sc, const ARegion *region, const int mval[2])
void ED_area_tag_redraw(ScrArea *area)
Definition area.cc:784
char char size_t char const char * BLI_strchr_or_end(const char *str, char ch) ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL ATTR_NONNULL(1)
void BLI_str_cursor_step_bounds_utf8(const char *str, int str_maxlen, int pos, int *r_start, int *r_end)
static wmOperatorStatus console_clear_line_exec(bContext *C, wmOperator *)
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
struct ConsoleLine * prev
ListBaseT< ConsoleLine > scrollback
ListBaseT< ConsoleLine > history
wmEventType type
Definition WM_types.hh:817
wmEventModifierFlag modifier
Definition WM_types.hh:834
wmOperatorStatus(*) exec(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1125
const char * description
Definition WM_types.hh:1115
void(*) cancel(bContext *C, wmOperator *op)
Definition WM_types.hh:1149
bool(*) poll(bContext *C) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1165
wmOperatorStatus(*) invoke(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1141
wmOperatorStatus(*) modal(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1157
struct ReportList * reports