Blender V4.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
9#include <cctype> /* #ispunct */
10#include <cstdlib>
11#include <cstring>
12#include <sys/stat.h>
13
14#include "MEM_guardedalloc.h"
15
16#include "DNA_userdef_types.h"
17
18#include "BLI_dynstr.h"
19#include "BLI_listbase.h"
20#include "BLI_string.h"
22#include "BLI_string_utf8.h"
23#include "BLI_utildefines.h"
24
25#include "BKE_context.hh"
26#include "BKE_report.hh"
27#include "BKE_screen.hh"
28
29#include "WM_api.hh"
30#include "WM_types.hh"
31
32#include "ED_screen.hh"
33#include "UI_view2d.hh"
34
35#include "RNA_access.hh"
36#include "RNA_define.hh"
37
38#include "console_intern.hh"
39
40#define TAB_LENGTH 4
41
42/* -------------------------------------------------------------------- */
47{
48 if (sc->sel_start == sc->sel_end) {
49 return nullptr;
50 }
51
52 ConsoleLine cl_dummy = {nullptr};
54
55 int offset = 0;
57 offset += cl->len + 1;
58 }
59
60 char *buf_str = nullptr;
61 if (offset != 0) {
62 offset -= 1;
63 int sel[2] = {offset - sc->sel_end, offset - sc->sel_start};
64 DynStr *buf_dyn = BLI_dynstr_new();
66 if (sel[0] <= cl->len && sel[1] >= 0) {
67 int sta = max_ii(sel[0], 0);
68 int end = min_ii(sel[1], cl->len);
69
70 if (BLI_dynstr_get_len(buf_dyn)) {
71 BLI_dynstr_append(buf_dyn, "\n");
72 }
73
74 BLI_dynstr_nappend(buf_dyn, cl->line + sta, end - sta);
75 }
76
77 sel[0] -= cl->len + 1;
78 sel[1] -= cl->len + 1;
79 }
80
81 buf_str = BLI_dynstr_get_cstring(buf_dyn);
82
83 BLI_dynstr_free(buf_dyn);
84 }
85 console_scrollback_prompt_end(sc, &cl_dummy);
86
87 return buf_str;
88}
89
91{
93 return;
94 }
95 if (sc->sel_start == sc->sel_end) {
96 return;
97 }
98 char *buf = console_select_to_buffer(sc);
99 if (buf == nullptr) {
100 return;
101 }
102 WM_clipboard_text_set(buf, true);
103 MEM_freeN(buf);
104}
105
106/* Delete selected characters in the edit line. */
108{
109 if (sc->sel_start == sc->sel_end) {
110 return 0;
111 }
112
113 if (sc->sel_start < 0) {
114 sc->sel_start = 0;
115 }
116
117 ConsoleLine *cl = static_cast<ConsoleLine *>(sc->history.last);
118 if (!cl || sc->sel_start > cl->len) {
119 sc->sel_start = sc->sel_end;
120 return 0;
121 }
122
123 int del_start = sc->sel_start;
124 int del_end = sc->sel_end;
125
126 if (del_end > cl->len) {
127 /* Adjust range to only editable portion. */
128 del_end = cl->len;
129 }
130
131 const int len = del_end - del_start;
132 memmove(cl->line + cl->len - del_end, cl->line + cl->len - del_start, del_start);
133 cl->len -= len;
134 cl->line[cl->len] = 0;
135 cl->cursor = cl->len - del_start;
136
137 sc->sel_start = sc->sel_end = cl->cursor;
138 return len;
139}
140
143/* so when we type - the view scrolls to the bottom */
144static void console_scroll_bottom(ARegion *region)
145{
146 View2D *v2d = &region->v2d;
147 v2d->cur.ymin = 0.0;
148 v2d->cur.ymax = float(v2d->winy);
149}
150
152{
153 View2D *v2d = &region->v2d;
154
155 UI_view2d_totRect_set(v2d, region->winx - 1, console_textview_height(sc, region));
156}
157
158static void console_select_offset(SpaceConsole *sc, const int offset)
159{
160 sc->sel_start += offset;
161 sc->sel_end += offset;
162}
163
165{
166 BLI_remlink(&sc->history, cl);
167 MEM_freeN(cl->line);
168 MEM_freeN(cl);
169}
171{
172 BLI_remlink(&sc->scrollback, cl);
173 MEM_freeN(cl->line);
174 MEM_freeN(cl);
175}
176
178{
179 int tot;
180
181 for (tot = BLI_listbase_count(&sc->scrollback); tot > U.scrollback; tot--) {
182 console_scrollback_free(sc, static_cast<ConsoleLine *>(sc->scrollback.first));
183 }
184}
185
186/* return 0 if no change made, clamps the range */
187static bool console_line_cursor_set(ConsoleLine *cl, int cursor)
188{
189 int cursor_new;
190
191 if (cursor < 0) {
192 cursor_new = 0;
193 }
194 else if (cursor > cl->len) {
195 cursor_new = cl->len;
196 }
197 else {
198 cursor_new = cursor;
199 }
200
201 if (cursor_new == cl->cursor) {
202 return false;
203 }
204
205 cl->cursor = cursor_new;
206 return true;
207}
208
209#if 0 /* XXX unused */
210static void console_lb_debug__internal(ListBase *lb)
211{
212 ConsoleLine *cl;
213
214 printf("%d: ", BLI_listbase_count(lb));
215 for (cl = lb->first; cl; cl = cl->next) {
216 printf("<%s> ", cl->line);
217 }
218 printf("\n");
219}
220
221static void console_history_debug(const bContext *C)
222{
224
225 console_lb_debug__internal(&sc->history);
226}
227#endif
228
230{
231 ConsoleLine *ci = static_cast<ConsoleLine *>(
232 MEM_callocN(sizeof(ConsoleLine), "ConsoleLine Add"));
233
234 if (from) {
235 BLI_assert(strlen(from->line) == from->len);
236 ci->line = BLI_strdupn(from->line, from->len);
237 ci->len = ci->len_alloc = from->len;
238 ci->cursor = from->cursor;
239 ci->type = from->type;
240 }
241 else {
242 ci->line = static_cast<char *>(MEM_callocN(64, "console-in-line"));
243 ci->len_alloc = 64;
244 ci->len = 0;
245 }
246
247 BLI_addtail(lb, ci);
248 return ci;
249}
250
252{
253 return console_lb_add__internal(&sc->history, from);
254}
255
256#if 0 /* may use later ? */
257static ConsoleLine *console_scrollback_add(const bContext *C, ConsoleLine *from)
258{
260
261 return console_lb_add__internal(&sc->scrollback, from);
262}
263#endif
264
266{
267 ConsoleLine *ci = static_cast<ConsoleLine *>(
268 MEM_callocN(sizeof(ConsoleLine), "ConsoleLine Add"));
269 const int str_len = strlen(str);
270 if (own) {
271 ci->line = str;
272 }
273 else {
274 ci->line = BLI_strdupn(str, str_len);
275 }
276
277 ci->len = ci->len_alloc = str_len;
278
279 BLI_addtail(lb, ci);
280 return ci;
281}
283{
284 return console_lb_add_str__internal(&sc->history, str, own);
285}
287{
289 console_select_offset(sc, ci->len + 1);
290 return ci;
291}
292
294{
296 ConsoleLine *ci = static_cast<ConsoleLine *>(sc->history.last);
297 if (ci == nullptr) {
298 ci = console_history_add(sc, nullptr);
299 }
300
301 return ci;
302}
303
305{
306 /* resize the buffer if needed */
307 if (len >= ci->len_alloc) {
308 /* new length */
309#ifndef NDEBUG
310 int new_len = len + 1;
311#else
312 int new_len = (len + 1) * 2;
313#endif
314 ci->line = static_cast<char *>(MEM_recallocN_id(ci->line, new_len, "console line"));
315 ci->len_alloc = new_len;
316 }
317}
318
319static void console_line_insert(ConsoleLine *ci, const char *str, int len)
320{
321 if (len == 0) {
322 return;
323 }
324
325 BLI_assert(len <= strlen(str));
326 /* The caller must delimit new-lines. */
327 BLI_assert(str[len - 1] != '\n');
328
330
331 memmove(ci->line + ci->cursor + len, ci->line + ci->cursor, (ci->len - ci->cursor) + 1);
332 memcpy(ci->line + ci->cursor, str, len);
333
334 ci->len += len;
335 ci->cursor += len;
336}
337
344 SpaceConsole *sc, const int pos, ConsoleLine **r_cl, int *r_cl_offset, int *r_col)
345{
346 ConsoleLine *cl;
347 int offset = 0;
348
349 for (cl = static_cast<ConsoleLine *>(sc->scrollback.last); cl; cl = cl->prev) {
350 offset += cl->len + 1;
351 if (offset > pos) {
352 break;
353 }
354 }
355
356 if (cl) {
357 offset -= 1;
358 *r_cl = cl;
359 *r_cl_offset = offset;
360 *r_col = offset - pos;
361 return true;
362 }
363
364 *r_cl = nullptr;
365 *r_cl_offset = -1;
366 *r_col = -1;
367 return false;
368}
369
370/* Static functions for text editing. */
371
372/* similar to the text editor, with some not used. keep compatible */
374 {LINE_BEGIN, "LINE_BEGIN", 0, "Line Begin", ""},
375 {LINE_END, "LINE_END", 0, "Line End", ""},
376 {PREV_CHAR, "PREVIOUS_CHARACTER", 0, "Previous Character", ""},
377 {NEXT_CHAR, "NEXT_CHARACTER", 0, "Next Character", ""},
378 {PREV_WORD, "PREVIOUS_WORD", 0, "Previous Word", ""},
379 {NEXT_WORD, "NEXT_WORD", 0, "Next Word", ""},
380 {0, nullptr, 0, nullptr, nullptr},
381};
382
384{
387 ScrArea *area = CTX_wm_area(C);
389
390 int type = RNA_enum_get(op->ptr, "type");
391 bool select = RNA_boolean_get(op->ptr, "select");
392
393 bool done = false;
394 int old_pos = ci->cursor;
395 int pos = 0;
396
397 if (!select && sc->sel_start != sc->sel_end) {
398 /* Clear selection if we are not extending it. */
399 sc->sel_start = sc->sel_end;
400 }
401
402 switch (type) {
403 case LINE_BEGIN:
404 pos = ci->cursor;
406 done = console_line_cursor_set(ci, pos);
407 break;
408 case LINE_END:
409 pos = ci->cursor;
411 done = console_line_cursor_set(ci, pos);
412 break;
413 case PREV_CHAR:
414 pos = ci->cursor;
416 done = console_line_cursor_set(ci, pos);
417 break;
418 case NEXT_CHAR:
419 pos = ci->cursor;
421 done = console_line_cursor_set(ci, pos);
422 break;
423
424 /* - if the character is a delimiter then skip delimiters (including white space)
425 * - when jump over the word */
426 case PREV_WORD:
427 pos = ci->cursor;
429 done = console_line_cursor_set(ci, pos);
430 break;
431 case NEXT_WORD:
432 pos = ci->cursor;
434 done = console_line_cursor_set(ci, pos);
435 break;
436 }
437
438 if (select) {
439 if (sc->sel_start == sc->sel_end || sc->sel_start > ci->len || sc->sel_end > ci->len) {
440 sc->sel_start = ci->len - old_pos;
441 sc->sel_end = sc->sel_start;
442 }
443 if (pos > old_pos) {
444 sc->sel_start = ci->len - pos;
445 }
446 else {
447 sc->sel_end = ci->len - pos;
448 }
449 }
450
451 if (done) {
452 ED_area_tag_redraw(area);
453 console_scroll_bottom(region);
454 }
455
456 return OPERATOR_FINISHED;
457}
458
460{
461 /* identifiers */
462 ot->name = "Move Cursor";
463 ot->description = "Move cursor position";
464 ot->idname = "CONSOLE_OT_move";
465
466 /* api callbacks */
469
470 /* properties */
472 ot->srna, "type", console_move_type_items, LINE_BEGIN, "Type", "Where to move cursor to");
474 ot->srna, "select", false, "Select", "Whether to select while moving");
476}
477
479{
481 ScrArea *area = CTX_wm_area(C);
484 char *str = RNA_string_get_alloc(op->ptr, "text", nullptr, 0, nullptr);
485 int len = strlen(str);
486
487 /* Allow trailing newlines (but strip them). */
488 while (len > 0 && str[len - 1] == '\n') {
489 len--;
490 str[len] = '\0';
491 }
492
493 if (strchr(str, '\n')) {
494 BKE_report(op->reports, RPT_ERROR, "New lines unsupported, call this operator multiple times");
495 /* Force cancel. */
496 len = 0;
497 }
498
499 if (len != 0) {
502 }
503
504 MEM_freeN(str);
505
506 if (len == 0) {
507 return OPERATOR_CANCELLED;
508 }
509
511
513 ED_area_tag_redraw(area);
514
515 console_scroll_bottom(region);
516
517 return OPERATOR_FINISHED;
518}
519
520static int console_insert_invoke(bContext *C, wmOperator *op, const wmEvent *event)
521{
522 /* NOTE: the "text" property is always set from key-map,
523 * so we can't use #RNA_struct_property_is_set, check the length instead. */
524 if (!RNA_string_length(op->ptr, "text")) {
525 /* If alt/control/super are pressed pass through except for UTF8 character event
526 * (when input method are used for UTF8 inputs, the user may assign key event
527 * including alt/control/super like control-m to commit UTF8 string.
528 * in such case, the modifiers in the UTF8 character event make no sense.) */
529 if ((event->modifier & (KM_CTRL | KM_OSKEY)) && !event->utf8_buf[0]) {
531 }
532
533 char str[BLI_UTF8_MAX + 1];
534 const size_t len = BLI_str_utf8_size_safe(event->utf8_buf);
535 memcpy(str, event->utf8_buf, len);
536 str[len] = '\0';
537 RNA_string_set(op->ptr, "text", str);
538 }
539 return console_insert_exec(C, op);
540}
541
543{
544 PropertyRNA *prop;
545
546 /* identifiers */
547 ot->name = "Insert";
548 ot->description = "Insert text at cursor position";
549 ot->idname = "CONSOLE_OT_insert";
550
551 /* api callbacks */
555
556 /* properties */
557 prop = RNA_def_string(
558 ot->srna, "text", nullptr, 0, "Text", "Text to insert at the cursor position");
560}
561
562/* -------------------------------------------------------------------- */
567{
569 bool text_before_cursor = false;
570
571 /* Check any text before cursor (not just the previous character) as is done for
572 * #TEXT_OT_indent_or_autocomplete because Python auto-complete operates on import
573 * statements such as completing possible sub-modules: `from bpy import `. */
574 for (int i = 0; i < ci->cursor; i += BLI_str_utf8_size_safe(&ci->line[i])) {
575 if (!ELEM(ci->line[i], ' ', '\t')) {
576 text_before_cursor = true;
577 break;
578 }
579 }
580
581 if (text_before_cursor) {
582 WM_operator_name_call(C, "CONSOLE_OT_autocomplete", WM_OP_INVOKE_DEFAULT, nullptr, nullptr);
583 }
584 else {
585 WM_operator_name_call(C, "CONSOLE_OT_indent", WM_OP_EXEC_DEFAULT, nullptr, nullptr);
586 }
587 return OPERATOR_FINISHED;
588}
589
591{
592 /* identifiers */
593 ot->name = "Indent or Autocomplete";
594 ot->idname = "CONSOLE_OT_indent_or_autocomplete";
595 ot->description = "Indent selected text or autocomplete";
596
597 /* api callbacks */
600
601 /* flags */
602 ot->flag = 0;
603}
604
607/* -------------------------------------------------------------------- */
612{
615 ScrArea *area = CTX_wm_area(C);
617
618 int spaces;
619 int len;
620
621 for (spaces = 0; spaces < ci->len; spaces++) {
622 if (ci->line[spaces] != ' ') {
623 break;
624 }
625 }
626
627 len = TAB_LENGTH - spaces % TAB_LENGTH;
628
630
631 memmove(ci->line + len, ci->line, ci->len + 1);
632 memset(ci->line, ' ', len);
633 ci->len += len;
634 BLI_assert(ci->len >= 0);
637
639 ED_area_tag_redraw(area);
640
641 console_scroll_bottom(region);
642
643 return OPERATOR_FINISHED;
644}
645
647{
648 /* identifiers */
649 ot->name = "Indent";
650 ot->description = "Add 4 spaces at line beginning";
651 ot->idname = "CONSOLE_OT_indent";
652
653 /* api callbacks */
656}
657
661{
664 ScrArea *area = CTX_wm_area(C);
666
667 int spaces;
668 int len;
669
670 for (spaces = 0; spaces < ci->len; spaces++) {
671 if (ci->line[spaces] != ' ') {
672 break;
673 }
674 }
675
676 if (spaces == 0) {
677 return OPERATOR_CANCELLED;
678 }
679
680 len = spaces % TAB_LENGTH;
681 if (len == 0) {
682 len = TAB_LENGTH;
683 }
684
686
687 memmove(ci->line, ci->line + len, (ci->len - len) + 1);
688 ci->len -= len;
689 BLI_assert(ci->len >= 0);
690
693
695 ED_area_tag_redraw(area);
696
697 console_scroll_bottom(region);
698
699 return OPERATOR_FINISHED;
700}
701
703{
704 /* identifiers */
705 ot->name = "Unindent";
706 ot->description = "Delete 4 spaces from line beginning";
707 ot->idname = "CONSOLE_OT_unindent";
708
709 /* api callbacks */
712}
713
715 {DEL_NEXT_CHAR, "NEXT_CHARACTER", 0, "Next Character", ""},
716 {DEL_PREV_CHAR, "PREVIOUS_CHARACTER", 0, "Previous Character", ""},
717 {DEL_NEXT_WORD, "NEXT_WORD", 0, "Next Word", ""},
718 {DEL_PREV_WORD, "PREVIOUS_WORD", 0, "Previous Word", ""},
719 {0, nullptr, 0, nullptr, nullptr},
720};
721
723{
726 ScrArea *area = CTX_wm_area(C);
728
729 int pos;
730 int stride;
731
732 const short type = RNA_enum_get(op->ptr, "type");
733 bool done = false;
734
735 if (ci->len == 0) {
736 return OPERATOR_CANCELLED;
737 }
738
739 /* If there is a selection just delete it and nothing else. */
740 if (sc->sel_start != sc->sel_end && console_delete_editable_selection(sc) > 0) {
742 ED_area_tag_redraw(area);
743 console_scroll_bottom(region);
744 return OPERATOR_FINISHED;
745 }
746
747 switch (type) {
748 case DEL_NEXT_CHAR:
749 case DEL_NEXT_WORD:
750 if (ci->cursor < ci->len) {
751 pos = ci->cursor;
753 ci->len,
754 &pos,
757 true);
758 stride = pos - ci->cursor;
759 if (stride) {
760 memmove(ci->line + ci->cursor,
761 ci->line + ci->cursor + stride,
762 (ci->len - (ci->cursor + stride)) + 1);
763 ci->len -= stride;
764 BLI_assert(ci->len >= 0);
765 done = true;
766 }
767 }
768 break;
769 case DEL_PREV_CHAR:
770 case DEL_PREV_WORD:
771 if (ci->cursor > 0) {
772 pos = ci->cursor;
774 ci->len,
775 &pos,
778 true);
779 stride = ci->cursor - pos;
780 if (stride) {
781 ci->cursor -= stride; /* same as above */
782 memmove(ci->line + ci->cursor,
783 ci->line + ci->cursor + stride,
784 (ci->len - (ci->cursor + stride)) + 1);
785 ci->len -= stride;
786 BLI_assert(ci->len >= 0);
787 done = true;
788 }
789 }
790 break;
791 }
792
793 if (!done) {
794 return OPERATOR_CANCELLED;
795 }
796
797 console_select_offset(sc, -stride);
798
800 ED_area_tag_redraw(area);
801
802 console_scroll_bottom(region);
803
804 return OPERATOR_FINISHED;
805}
806
808{
809 /* identifiers */
810 ot->name = "Delete";
811 ot->description = "Delete text by cursor position";
812 ot->idname = "CONSOLE_OT_delete";
813
814 /* api callbacks */
817
818 /* properties */
820 "type",
823 "Type",
824 "Which part of the text to delete");
825}
826
828{
831 ScrArea *area = CTX_wm_area(C);
833
834 if (ci->len == 0) {
835 return OPERATOR_CANCELLED;
836 }
837
838 console_history_add(sc, ci);
839 console_history_add(sc, nullptr);
840 console_select_offset(sc, -ci->len);
841
843
844 ED_area_tag_redraw(area);
845
846 console_scroll_bottom(region);
847
848 return OPERATOR_FINISHED;
849}
850
852{
853 /* identifiers */
854 ot->name = "Clear Line";
855 ot->description = "Clear the line and store in history";
856 ot->idname = "CONSOLE_OT_clear_line";
857
858 /* api callbacks */
861}
862
863/* the python exec operator uses this */
865{
867 ScrArea *area = CTX_wm_area(C);
869
870 const bool scrollback = RNA_boolean_get(op->ptr, "scrollback");
871 const bool history = RNA_boolean_get(op->ptr, "history");
872
873 /* ConsoleLine *ci = */ console_history_verify(C);
874
875 if (scrollback) { /* Last item in history. */
876 while (sc->scrollback.first) {
877 console_scrollback_free(sc, static_cast<ConsoleLine *>(sc->scrollback.first));
878 }
879 }
880
881 if (history) {
882 while (sc->history.first) {
883 console_history_free(sc, static_cast<ConsoleLine *>(sc->history.first));
884 }
886 }
887
889 ED_area_tag_redraw(area);
890
891 return OPERATOR_FINISHED;
892}
893
895{
896 /* identifiers */
897 ot->name = "Clear All";
898 ot->description = "Clear text by type";
899 ot->idname = "CONSOLE_OT_clear";
900
901 /* api callbacks */
904
905 /* properties */
906 RNA_def_boolean(ot->srna, "scrollback", true, "Scrollback", "Clear the scrollback history");
907 RNA_def_boolean(ot->srna, "history", false, "History", "Clear the command history");
908}
909
910/* the python exec operator uses this */
912{
914 ScrArea *area = CTX_wm_area(C);
916
917 /* TODO: stupid, just prevents crashes when no command line. */
919 const bool reverse = RNA_boolean_get(op->ptr, "reverse"); /* assumes down, reverse is up */
920 int prev_len = ci->len;
921
922 int old_index = sc->history_index;
923 int new_index;
924 if (reverse) {
925 if (old_index <= 0) {
926 new_index = 1;
927 }
928 else {
929 new_index = old_index + 1;
930 }
931 }
932 else {
933 if (old_index <= 0) { /* Down-arrow after exec. */
934 new_index = -old_index;
935 }
936 else {
937 new_index = old_index - 1;
938 }
939 }
940
941 /* Find the history item. */
942 ConsoleLine *ci_prev = ci;
943 if (old_index > 0) {
944 /* Skip a previous copy of history item. */
945 if (ci_prev->prev) {
946 ci_prev = ci_prev->prev;
947 }
948 else { /* Just in case the duplicate item got deleted. */
949 old_index = 0;
950 }
951 }
952 for (int i = 0; i < new_index; i++) {
953 if (!ci_prev->prev) {
954 new_index = i;
955 break;
956 }
957 ci_prev = ci_prev->prev;
958 }
959
960 sc->history_index = new_index;
961
962 if (old_index > 0) { /* Remove old copy. */
963 console_history_free(sc, ci);
964 ci = ci_prev;
965 }
966 if (new_index > 0) { /* Copy history item to the end. */
967 ci = console_history_add(sc, ci_prev);
968 }
969
970 console_select_offset(sc, ci->len - prev_len);
971
972 /* could be wrapped so update scroll rect */
974 ED_area_tag_redraw(area);
975
976 console_scroll_bottom(region);
977
978 return OPERATOR_FINISHED;
979}
980
982{
983 /* identifiers */
984 ot->name = "History Cycle";
985 ot->description = "Cycle through history";
986 ot->idname = "CONSOLE_OT_history_cycle";
987
988 /* api callbacks */
991
992 /* properties */
993 RNA_def_boolean(ot->srna, "reverse", false, "Reverse", "Reverse cycle history");
994}
995
996/* the python exec operator uses this */
998{
1000 ScrArea *area = CTX_wm_area(C);
1002
1004 /* own this text in the new line, don't free */
1005 char *str = RNA_string_get_alloc(op->ptr, "text", nullptr, 0, nullptr);
1006 int cursor = RNA_int_get(op->ptr, "current_character");
1007 const bool rem_dupes = RNA_boolean_get(op->ptr, "remove_duplicates");
1008 int prev_len = ci->len;
1009
1010 if (sc->history_index > 0) {
1011 /* Keep the copy of history item, remove the saved "history 0". */
1012 ConsoleLine *cl = ci->prev;
1013 if (cl) {
1014 console_history_free(sc, cl);
1015 }
1016 /* Negative number makes down-arrow go to same item as before. */
1017 sc->history_index = -sc->history_index;
1018 }
1019
1020 if (rem_dupes) {
1021 /* Remove a repeated command. */
1022 ConsoleLine *cl = ci->prev;
1023 if (cl && STREQ(cl->line, ci->line)) {
1024 console_history_free(sc, cl);
1025 }
1026 /* Remove blank command. */
1027 if (STREQ(str, ci->line)) {
1028 MEM_freeN(str);
1029 return OPERATOR_FINISHED;
1030 }
1031 }
1032
1033 ci = console_history_add_str(sc, str, true); /* own the string */
1034 console_select_offset(sc, ci->len - prev_len);
1035 console_line_cursor_set(ci, cursor);
1036
1037 ED_area_tag_redraw(area);
1038 console_scroll_bottom(region);
1039
1040 return OPERATOR_FINISHED;
1041}
1042
1044{
1045 /* identifiers */
1046 ot->name = "History Append";
1047 ot->description = "Append history at cursor position";
1048 ot->idname = "CONSOLE_OT_history_append";
1049
1050 /* api callbacks */
1053
1054 /* properties */
1055 RNA_def_string(ot->srna, "text", nullptr, 0, "Text", "Text to insert at the cursor position");
1057 ot->srna, "current_character", 0, 0, INT_MAX, "Cursor", "The index of the cursor", 0, 10000);
1059 "remove_duplicates",
1060 false,
1061 "Remove Duplicates",
1062 "Remove duplicate items in the history");
1063}
1064
1065/* the python exec operator uses this */
1067{
1069 ConsoleLine *ci;
1070 ScrArea *area = CTX_wm_area(C);
1072
1073 /* own this text in the new line, don't free */
1074 char *str = RNA_string_get_alloc(op->ptr, "text", nullptr, 0, nullptr);
1075 int type = RNA_enum_get(op->ptr, "type");
1076
1078
1079 ci = console_scrollback_add_str(sc, str, true); /* own the string */
1080 ci->type = type;
1081
1083
1084 console_textview_update_rect(sc, region);
1085 ED_area_tag_redraw(area);
1086
1087 return OPERATOR_FINISHED;
1088}
1089
1091{
1092 /* defined in DNA_space_types.h */
1093 static const EnumPropertyItem console_line_type_items[] = {
1094 {CONSOLE_LINE_OUTPUT, "OUTPUT", 0, "Output", ""},
1095 {CONSOLE_LINE_INPUT, "INPUT", 0, "Input", ""},
1096 {CONSOLE_LINE_INFO, "INFO", 0, "Information", ""},
1097 {CONSOLE_LINE_ERROR, "ERROR", 0, "Error", ""},
1098 {0, nullptr, 0, nullptr, nullptr},
1099 };
1100
1101 /* identifiers */
1102 ot->name = "Scrollback Append";
1103 ot->description = "Append scrollback text by type";
1104 ot->idname = "CONSOLE_OT_scrollback_append";
1105
1106 /* api callbacks */
1109
1110 /* properties */
1111 RNA_def_string(ot->srna, "text", nullptr, 0, "Text", "Text to insert at the cursor position");
1113 "type",
1114 console_line_type_items,
1116 "Type",
1117 "Console output type");
1118}
1119
1121{
1123 char *buf = console_select_to_buffer(sc);
1124 if (buf == nullptr) {
1125 return OPERATOR_CANCELLED;
1126 }
1127
1128 WM_clipboard_text_set(buf, false);
1129
1130 if (RNA_boolean_get(op->ptr, "delete")) {
1133 }
1134
1135 MEM_freeN(buf);
1136 return OPERATOR_FINISHED;
1137}
1138
1140{
1142 return ED_operator_console_active(C) && sc && (sc->sel_start != sc->sel_end);
1143}
1144
1146{
1147 /* identifiers */
1148 ot->name = "Copy to Clipboard";
1149 ot->description = "Copy selected text to clipboard";
1150 ot->idname = "CONSOLE_OT_copy";
1151
1152 /* api callbacks */
1155
1156 /* properties */
1158 "delete",
1159 false,
1160 "Delete Selection",
1161 "Whether to delete the selection after copying");
1163}
1164
1166{
1167 const bool selection = RNA_boolean_get(op->ptr, "selection");
1170 ScrArea *area = CTX_wm_area(C);
1172
1173 int buf_str_len;
1174
1175 char *buf_str = WM_clipboard_text_get(selection, true, &buf_str_len);
1176 if (buf_str == nullptr) {
1177 return OPERATOR_CANCELLED;
1178 }
1179 if (*buf_str == '\0') {
1180 MEM_freeN(buf_str);
1181 return OPERATOR_CANCELLED;
1182 }
1183 const char *buf_step = buf_str;
1184 do {
1185 const char *buf = buf_step;
1186 buf_step = (char *)BLI_strchr_or_end(buf, '\n');
1187 const int buf_len = buf_step - buf;
1188 if (buf != buf_str) {
1189 WM_operator_name_call(C, "CONSOLE_OT_execute", WM_OP_EXEC_DEFAULT, nullptr, nullptr);
1190 ci = console_history_verify(C);
1191 }
1193 console_line_insert(ci, buf, buf_len);
1194 console_select_offset(sc, buf_len);
1195 } while (*buf_step ? ((void)buf_step++, true) : false);
1196
1197 MEM_freeN(buf_str);
1198
1199 console_textview_update_rect(sc, region);
1200 ED_area_tag_redraw(area);
1201
1202 console_scroll_bottom(region);
1203
1204 return OPERATOR_FINISHED;
1205}
1206
1208{
1209 /* identifiers */
1210 ot->name = "Paste from Clipboard";
1211 ot->description = "Paste text from clipboard";
1212 ot->idname = "CONSOLE_OT_paste";
1213
1214 /* api callbacks */
1217
1218 /* properties */
1219 PropertyRNA *prop;
1220 prop = RNA_def_boolean(ot->srna,
1221 "selection",
1222 false,
1223 "Selection",
1224 "Paste text selected elsewhere rather than copied (X11/Wayland only)");
1226}
1227
1229 int sel_old[2];
1231};
1232
1234 ARegion *region,
1235 SetConsoleCursor *scu,
1236 const wmEvent *event)
1237{
1238 int pos = console_char_pick(sc, region, event->mval);
1239 bool dragging = event->type == MOUSEMOVE;
1240
1241 if (scu->sel_init == INT_MAX) {
1242 scu->sel_init = pos;
1243 sc->sel_start = sc->sel_end = pos;
1244 return;
1245 }
1246
1247 if (pos < scu->sel_init) {
1248 sc->sel_start = pos;
1249 sc->sel_end = scu->sel_init;
1250 }
1251 else if (pos > sc->sel_start) {
1252 sc->sel_start = scu->sel_init;
1253 sc->sel_end = pos;
1254 }
1255 else {
1256 sc->sel_start = sc->sel_end = pos;
1257 }
1258
1259 /* Move text cursor to the last selection point. */
1260 ConsoleLine *cl = static_cast<ConsoleLine *>(sc->history.last);
1261
1262 if (cl != nullptr) {
1263 if (dragging && sc->sel_end > cl->len && pos <= cl->len) {
1264 /* Do not move cursor while dragging into the editable area. */
1265 }
1266 else if (pos <= cl->len) {
1267 console_line_cursor_set(cl, cl->len - pos);
1268 }
1269 else if (pos > cl->len && sc->sel_start < cl->len) {
1270 /* Dragging out of editable area, move cursor to start of selection. */
1271 console_line_cursor_set(cl, cl->len - sc->sel_start);
1272 }
1273 }
1274}
1275
1276static void console_modal_select_apply(bContext *C, wmOperator *op, const wmEvent *event)
1277{
1279 ScrArea *area = CTX_wm_area(C);
1281
1282 SetConsoleCursor *scu = static_cast<SetConsoleCursor *>(op->customdata);
1283 const int sel_prev[2] = {sc->sel_start, sc->sel_end};
1284
1285 console_cursor_set_to_pos(sc, region, scu, event);
1286
1287 /* only redraw if the selection changed */
1288 if (sel_prev[0] != sc->sel_start || sel_prev[1] != sc->sel_end) {
1289 ED_area_tag_redraw(area);
1290 }
1291}
1292
1294{
1296 SetConsoleCursor *scu = static_cast<SetConsoleCursor *>(op->customdata);
1297
1299
1300 MEM_freeN(scu);
1301}
1302
1304{
1306 ScrArea *area = CTX_wm_area(C);
1308
1309 SetConsoleCursor *scu;
1310
1311 ConsoleLine *cl = static_cast<ConsoleLine *>(sc->history.last);
1312 if (cl != nullptr) {
1313 const int pos = console_char_pick(sc, region, event->mval);
1314 if (pos >= 0 && pos <= cl->len) {
1315 /* Set text cursor immediately. */
1316 console_line_cursor_set(cl, cl->len - pos);
1317 }
1318 }
1319
1320 op->customdata = MEM_callocN(sizeof(SetConsoleCursor), "SetConsoleCursor");
1321 scu = static_cast<SetConsoleCursor *>(op->customdata);
1322
1323 scu->sel_old[0] = sc->sel_start;
1324 scu->sel_old[1] = sc->sel_end;
1325
1326 scu->sel_init = INT_MAX;
1327
1329
1330 console_modal_select_apply(C, op, event);
1331
1333}
1334
1335static int console_modal_select(bContext *C, wmOperator *op, const wmEvent *event)
1336{
1337 /* Move text cursor to the last selection point. */
1338 switch (event->type) {
1339 case LEFTMOUSE:
1340 case MIDDLEMOUSE:
1341 case RIGHTMOUSE:
1342 if (event->val == KM_PRESS) {
1343 console_modal_select_apply(C, op, event);
1344 break;
1345 }
1346 else if (event->val == KM_RELEASE) {
1347 console_modal_select_apply(C, op, event);
1350 return OPERATOR_FINISHED;
1351 }
1352 break;
1353 case MOUSEMOVE:
1354 console_modal_select_apply(C, op, event);
1355 break;
1356 }
1357
1359}
1360
1362{
1364}
1365
1367{
1368 /* identifiers */
1369 ot->name = "Set Selection";
1370 ot->idname = "CONSOLE_OT_select_set";
1371 ot->description = "Set the console selection";
1372
1373 /* api callbacks */
1378}
1379
1381 wmOperator * /*op*/,
1382 const wmEvent * /*event*/)
1383{
1384 ScrArea *area = CTX_wm_area(C);
1386
1387 int offset = strlen(sc->prompt);
1388
1390 offset += cl->len + 1;
1391 }
1392
1393 ConsoleLine *cl = static_cast<ConsoleLine *>(sc->history.last);
1394 if (cl) {
1395 offset += cl->len + 1;
1396 }
1397
1398 sc->sel_start = 0;
1399 sc->sel_end = offset;
1400
1401 ED_area_tag_redraw(area);
1402
1403 return OPERATOR_FINISHED;
1404}
1405
1407{
1408 /* identifiers */
1409 ot->name = "Select All";
1410 ot->idname = "CONSOLE_OT_select_all";
1411 ot->description = "Select all the text";
1412
1413 /* api callbacks */
1416}
1417
1418static int console_selectword_invoke(bContext *C, wmOperator * /*op*/, const wmEvent *event)
1419{
1421 ScrArea *area = CTX_wm_area(C);
1423
1424 ConsoleLine cl_dummy = {nullptr};
1425 ConsoleLine *cl;
1426 int ret = OPERATOR_CANCELLED;
1427 int pos, offset, n;
1428
1429 pos = console_char_pick(sc, region, event->mval);
1430
1431 console_scrollback_prompt_begin(sc, &cl_dummy);
1432
1433 if (console_line_column_from_index(sc, pos, &cl, &offset, &n)) {
1434 int sel[2] = {n, n};
1435
1436 BLI_str_cursor_step_bounds_utf8(cl->line, cl->len, n, &sel[1], &sel[0]);
1437
1438 sel[0] = offset - sel[0];
1439 sel[1] = offset - sel[1];
1440
1441 if ((sel[0] != sc->sel_start) || (sel[1] != sc->sel_end)) {
1442 sc->sel_start = sel[0];
1443 sc->sel_end = sel[1];
1444 ED_area_tag_redraw(area);
1446 }
1447 }
1448
1449 console_scrollback_prompt_end(sc, &cl_dummy);
1450
1451 ConsoleLine *ci = static_cast<ConsoleLine *>(sc->history.last);
1452 if (ci && sc->sel_start <= ci->len) {
1453 console_line_cursor_set(ci, ci->len - sc->sel_start);
1454 }
1455
1456 if (ret & OPERATOR_FINISHED) {
1458 }
1459
1460 return ret;
1461}
1462
1464{
1465 /* identifiers */
1466 ot->name = "Select Word";
1467 ot->description = "Select word at cursor position";
1468 ot->idname = "CONSOLE_OT_select_word";
1469
1470 /* api callbacks */
1473}
SpaceConsole * CTX_wm_space_console(const bContext *C)
ScrArea * CTX_wm_area(const bContext *C)
void BKE_report(ReportList *reports, eReportType type, const char *message)
Definition report.cc:125
ARegion * BKE_area_find_region_type(const ScrArea *area, int region_type)
Definition screen.cc:815
#define BLI_assert(a)
Definition BLI_assert.h:50
A dynamically sized string ADT.
char * BLI_dynstr_get_cstring(const DynStr *ds) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition BLI_dynstr.c:149
void BLI_dynstr_nappend(DynStr *__restrict ds, const char *cstr, int len) ATTR_NONNULL()
Definition BLI_dynstr.c:81
int BLI_dynstr_get_len(const DynStr *ds) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition BLI_dynstr.c:128
DynStr * BLI_dynstr_new(void) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
Definition BLI_dynstr.c:37
void BLI_dynstr_free(DynStr *ds) ATTR_NONNULL()
Definition BLI_dynstr.c:174
void BLI_dynstr_append(DynStr *__restrict ds, const char *cstr) ATTR_NONNULL()
Definition BLI_dynstr.c:62
#define LISTBASE_FOREACH(type, var, list)
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:110
void BLI_remlink(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:130
int BLI_listbase_count(const struct ListBase *listbase) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
MINLINE int min_ii(int a, int b)
MINLINE int max_ii(int a, int b)
char * BLI_strdupn(const char *str, size_t len) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition string.c:29
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)
Definition string.c:927
@ STRCUR_DIR_NEXT
@ STRCUR_DIR_PREV
void BLI_str_cursor_step_utf8(const char *str, int str_maxlen, int *pos, eStrCursorJumpDirection direction, eStrCursorJumpType jump, bool use_init_step)
void BLI_str_cursor_step_bounds_utf8(const char *str, int str_maxlen, int pos, int *r_start, int *r_end)
@ STRCUR_JUMP_ALL
@ STRCUR_JUMP_NONE
@ STRCUR_JUMP_DELIM
#define BLI_UTF8_MAX
int BLI_str_utf8_size_safe(const char *p) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
#define ELEM(...)
#define STREQ(a, b)
@ RGN_TYPE_WINDOW
@ CONSOLE_LINE_INFO
@ CONSOLE_LINE_ERROR
@ CONSOLE_LINE_INPUT
@ CONSOLE_LINE_OUTPUT
@ OPERATOR_RUNNING_MODAL
@ OPERATOR_PASS_THROUGH
void ED_area_tag_redraw(ScrArea *area)
Definition area.cc:708
bool ED_operator_console_active(bContext *C)
Read Guarded memory(de)allocation.
@ PROP_SKIP_SAVE
Definition RNA_types.hh:245
void UI_view2d_totRect_set(View2D *v2d, int width, int height)
Definition view2d.cc:1032
@ WM_CAPABILITY_PRIMARY_CLIPBOARD
Definition WM_api.hh:176
@ KM_PRESS
Definition WM_types.hh:284
@ KM_RELEASE
Definition WM_types.hh:285
@ WM_OP_INVOKE_DEFAULT
Definition WM_types.hh:218
@ WM_OP_EXEC_DEFAULT
Definition WM_types.hh:225
@ KM_CTRL
Definition WM_types.hh:256
@ KM_OSKEY
Definition WM_types.hh:259
#define NEXT_CHAR(fmt)
unsigned int U
Definition btGjkEpa3.h:78
void console_scrollback_prompt_end(SpaceConsole *sc, ConsoleLine *cl_dummy)
int console_textview_height(SpaceConsole *sc, const ARegion *region)
void console_scrollback_prompt_begin(SpaceConsole *sc, ConsoleLine *cl_dummy)
int console_char_pick(SpaceConsole *sc, const ARegion *region, const int mval[2])
static int console_indent_exec(bContext *C, wmOperator *)
static bool console_line_cursor_set(ConsoleLine *cl, int cursor)
void CONSOLE_OT_select_all(wmOperatorType *ot)
static int console_unindent_exec(bContext *C, wmOperator *)
static ConsoleLine * console_history_add(SpaceConsole *sc, ConsoleLine *from)
static void console_modal_select_apply(bContext *C, wmOperator *op, const wmEvent *event)
static void console_select_update_primary_clipboard(SpaceConsole *sc)
static void console_modal_select_cancel(bContext *C, wmOperator *op)
static void console_line_verify_length(ConsoleLine *ci, int len)
static int console_selectword_invoke(bContext *C, wmOperator *, const wmEvent *event)
void CONSOLE_OT_copy(wmOperatorType *ot)
void CONSOLE_OT_clear(wmOperatorType *ot)
static const EnumPropertyItem console_move_type_items[]
static const EnumPropertyItem console_delete_type_items[]
static bool console_line_column_from_index(SpaceConsole *sc, const int pos, ConsoleLine **r_cl, int *r_cl_offset, int *r_col)
void console_textview_update_rect(SpaceConsole *sc, ARegion *region)
#define TAB_LENGTH
static void console_cursor_set_exit(bContext *C, wmOperator *op)
void CONSOLE_OT_select_word(wmOperatorType *ot)
void CONSOLE_OT_delete(wmOperatorType *ot)
static char * console_select_to_buffer(SpaceConsole *sc)
void CONSOLE_OT_indent(wmOperatorType *ot)
void CONSOLE_OT_select_set(wmOperatorType *ot)
static int console_history_append_exec(bContext *C, wmOperator *op)
static int console_clear_line_exec(bContext *C, wmOperator *)
static void console_scrollback_limit(SpaceConsole *sc)
static int console_history_cycle_exec(bContext *C, wmOperator *op)
static int console_insert_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static int console_scrollback_append_exec(bContext *C, wmOperator *op)
static int console_copy_exec(bContext *C, wmOperator *op)
static int console_move_exec(bContext *C, wmOperator *op)
void CONSOLE_OT_indent_or_autocomplete(wmOperatorType *ot)
void CONSOLE_OT_move(wmOperatorType *ot)
static int console_modal_select(bContext *C, wmOperator *op, const wmEvent *event)
static void console_scroll_bottom(ARegion *region)
void console_history_free(SpaceConsole *sc, ConsoleLine *cl)
void console_scrollback_free(SpaceConsole *sc, ConsoleLine *cl)
void CONSOLE_OT_clear_line(wmOperatorType *ot)
static int console_insert_exec(bContext *C, wmOperator *op)
void CONSOLE_OT_scrollback_append(wmOperatorType *ot)
void CONSOLE_OT_insert(wmOperatorType *ot)
static ConsoleLine * console_lb_add__internal(ListBase *lb, ConsoleLine *from)
ConsoleLine * console_history_add_str(SpaceConsole *sc, char *str, bool own)
static void console_line_insert(ConsoleLine *ci, const char *str, int len)
static ConsoleLine * console_lb_add_str__internal(ListBase *lb, char *str, bool own)
static bool console_copy_poll(bContext *C)
void CONSOLE_OT_history_cycle(wmOperatorType *ot)
void CONSOLE_OT_unindent(wmOperatorType *ot)
static int console_delete_exec(bContext *C, wmOperator *op)
static int console_indent_or_autocomplete_exec(bContext *C, wmOperator *)
void CONSOLE_OT_history_append(wmOperatorType *ot)
static int console_delete_editable_selection(SpaceConsole *sc)
static int console_clear_exec(bContext *C, wmOperator *op)
void CONSOLE_OT_paste(wmOperatorType *ot)
static int console_modal_select_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static int console_modal_select_all_invoke(bContext *C, wmOperator *, const wmEvent *)
ConsoleLine * console_history_verify(const bContext *C)
static void console_cursor_set_to_pos(SpaceConsole *sc, ARegion *region, SetConsoleCursor *scu, const wmEvent *event)
static void console_select_offset(SpaceConsole *sc, const int offset)
static int console_paste_exec(bContext *C, wmOperator *op)
ConsoleLine * console_scrollback_add_str(SpaceConsole *sc, char *str, bool own)
#define printf
@ DEL_PREV_WORD
@ DEL_PREV_CHAR
@ DEL_NEXT_WORD
@ DEL_NEXT_CHAR
@ LINE_BEGIN
@ PREV_WORD
@ PREV_CHAR
@ LINE_END
@ NEXT_WORD
int len
draw_view in_light_buf[] float
#define str(s)
void *(* MEM_recallocN_id)(void *vmemh, size_t len, const char *str)
Definition mallocn.cc:41
void MEM_freeN(void *vmemh)
Definition mallocn.cc:105
void *(* MEM_callocN)(size_t len, const char *str)
Definition mallocn.cc:42
ccl_device_inline float4 select(const int4 mask, const float4 a, const float4 b)
return ret
void RNA_string_set(PointerRNA *ptr, const char *name, const char *value)
int RNA_int_get(PointerRNA *ptr, const char *name)
char * RNA_string_get_alloc(PointerRNA *ptr, const char *name, char *fixedbuf, int fixedlen, int *r_len)
int RNA_string_length(PointerRNA *ptr, const char *name)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
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)
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
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)
struct ConsoleLine * next
struct ConsoleLine * prev
void * last
void * first
float ymax
float ymin
short val
Definition WM_types.hh:724
char utf8_buf[6]
Definition WM_types.hh:736
int mval[2]
Definition WM_types.hh:728
uint8_t modifier
Definition WM_types.hh:739
short type
Definition WM_types.hh:722
const char * name
Definition WM_types.hh:990
bool(* poll)(bContext *C) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1042
const char * idname
Definition WM_types.hh:992
int(* modal)(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1036
int(* invoke)(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1022
int(* exec)(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1006
const char * description
Definition WM_types.hh:996
StructRNA * srna
Definition WM_types.hh:1080
void(* cancel)(bContext *C, wmOperator *op)
Definition WM_types.hh:1028
struct ReportList * reports
struct PointerRNA * ptr
wmEventHandler_Op * WM_event_add_modal_handler(bContext *C, wmOperator *op)
int WM_operator_name_call(bContext *C, const char *opstring, wmOperatorCallContext context, PointerRNA *properties, const wmEvent *event)
@ RIGHTMOUSE
@ MOUSEMOVE
@ LEFTMOUSE
@ MIDDLEMOUSE
wmOperatorType * ot
Definition wm_files.cc:4125
void WM_clipboard_text_set(const char *buf, bool selection)
char * WM_clipboard_text_get(bool selection, bool ensure_utf8, int *r_len)
eWM_CapabilitiesFlag WM_capabilities_flag()