Blender  V3.3
console_ops.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
7 #include <ctype.h> /* #ispunct */
8 #include <stdlib.h>
9 #include <string.h>
10 #include <sys/stat.h>
11 
12 #include "MEM_guardedalloc.h"
13 
14 #include "DNA_userdef_types.h"
15 
16 #include "BLI_dynstr.h"
17 #include "BLI_listbase.h"
18 #include "BLI_math.h"
19 #include "BLI_string.h"
20 #include "BLI_string_cursor_utf8.h"
21 #include "BLI_string_utf8.h"
22 #include "BLI_utildefines.h"
23 
24 #include "BKE_context.h"
25 
26 #include "WM_api.h"
27 #include "WM_types.h"
28 
29 #include "ED_screen.h"
30 #include "UI_view2d.h"
31 
32 #include "RNA_access.h"
33 #include "RNA_define.h"
34 
35 #include "console_intern.h"
36 
37 /* so when we type - the view scrolls to the bottom */
38 static void console_scroll_bottom(ARegion *region)
39 {
40  View2D *v2d = &region->v2d;
41  v2d->cur.ymin = 0.0;
42  v2d->cur.ymax = (float)v2d->winy;
43 }
44 
46 {
47  View2D *v2d = &region->v2d;
48 
49  UI_view2d_totRect_set(v2d, region->winx - 1, console_textview_height(sc, region));
50 }
51 
52 static void console_select_offset(SpaceConsole *sc, const int offset)
53 {
54  sc->sel_start += offset;
55  sc->sel_end += offset;
56 }
57 
59 {
60  BLI_remlink(&sc->history, cl);
61  MEM_freeN(cl->line);
62  MEM_freeN(cl);
63 }
65 {
66  BLI_remlink(&sc->scrollback, cl);
67  MEM_freeN(cl->line);
68  MEM_freeN(cl);
69 }
70 
72 {
73  int tot;
74 
75  for (tot = BLI_listbase_count(&sc->scrollback); tot > U.scrollback; tot--) {
77  }
78 }
79 
80 static ConsoleLine *console_history_find(SpaceConsole *sc, const char *str, ConsoleLine *cl_ignore)
81 {
82  ConsoleLine *cl;
83 
84  for (cl = sc->history.last; cl; cl = cl->prev) {
85  if (cl == cl_ignore) {
86  continue;
87  }
88 
89  if (STREQ(str, cl->line)) {
90  return cl;
91  }
92  }
93 
94  return NULL;
95 }
96 
97 /* return 0 if no change made, clamps the range */
98 static bool console_line_cursor_set(ConsoleLine *cl, int cursor)
99 {
100  int cursor_new;
101 
102  if (cursor < 0) {
103  cursor_new = 0;
104  }
105  else if (cursor > cl->len) {
106  cursor_new = cl->len;
107  }
108  else {
109  cursor_new = cursor;
110  }
111 
112  if (cursor_new == cl->cursor) {
113  return false;
114  }
115 
116  cl->cursor = cursor_new;
117  return true;
118 }
119 
120 #if 0 /* XXX unused */
121 static void console_lb_debug__internal(ListBase *lb)
122 {
123  ConsoleLine *cl;
124 
125  printf("%d: ", BLI_listbase_count(lb));
126  for (cl = lb->first; cl; cl = cl->next) {
127  printf("<%s> ", cl->line);
128  }
129  printf("\n");
130 }
131 
132 static void console_history_debug(const bContext *C)
133 {
135 
136  console_lb_debug__internal(&sc->history);
137 }
138 #endif
139 
141 {
142  ConsoleLine *ci = MEM_callocN(sizeof(ConsoleLine), "ConsoleLine Add");
143 
144  if (from) {
145  BLI_assert(strlen(from->line) == from->len);
146  ci->line = BLI_strdupn(from->line, from->len);
147  ci->len = ci->len_alloc = from->len;
148  ci->cursor = from->cursor;
149  ci->type = from->type;
150  }
151  else {
152  ci->line = MEM_callocN(64, "console-in-line");
153  ci->len_alloc = 64;
154  ci->len = 0;
155  }
156 
157  BLI_addtail(lb, ci);
158  return ci;
159 }
160 
162 {
163  return console_lb_add__internal(&sc->history, from);
164 }
165 
166 #if 0 /* may use later ? */
167 static ConsoleLine *console_scrollback_add(const bContext *C, ConsoleLine *from)
168 {
170 
172 }
173 #endif
174 
176 {
177  ConsoleLine *ci = MEM_callocN(sizeof(ConsoleLine), "ConsoleLine Add");
178  if (own) {
179  ci->line = str;
180  }
181  else {
182  ci->line = BLI_strdup(str);
183  }
184 
185  ci->len = ci->len_alloc = strlen(str);
186 
187  BLI_addtail(lb, ci);
188  return ci;
189 }
191 {
192  return console_lb_add_str__internal(&sc->history, str, own);
193 }
195 {
197  console_select_offset(sc, ci->len + 1);
198  return ci;
199 }
200 
202 {
204  ConsoleLine *ci = sc->history.last;
205  if (ci == NULL) {
206  ci = console_history_add(sc, NULL);
207  }
208 
209  return ci;
210 }
211 
213 {
214  /* resize the buffer if needed */
215  if (len >= ci->len_alloc) {
216  /* new length */
217 #ifndef NDEBUG
218  int new_len = len + 1;
219 #else
220  int new_len = (len + 1) * 2;
221 #endif
222  ci->line = MEM_recallocN_id(ci->line, new_len, "console line");
223  ci->len_alloc = new_len;
224  }
225 }
226 
227 static int console_line_insert(ConsoleLine *ci, char *str)
228 {
229  int len = strlen(str);
230 
231  if (len > 0 && str[len - 1] == '\n') { /* stop new lines being pasted at the end of lines */
232  str[len - 1] = '\0';
233  len--;
234  }
235 
236  if (len == 0) {
237  return 0;
238  }
239 
241 
242  memmove(ci->line + ci->cursor + len, ci->line + ci->cursor, (ci->len - ci->cursor) + 1);
243  memcpy(ci->line + ci->cursor, str, len);
244 
245  ci->len += len;
246  ci->cursor += len;
247 
248  return len;
249 }
250 
257  SpaceConsole *sc, const int pos, ConsoleLine **r_cl, int *r_cl_offset, int *r_col)
258 {
259  ConsoleLine *cl;
260  int offset = 0;
261 
262  for (cl = sc->scrollback.last; cl; cl = cl->prev) {
263  offset += cl->len + 1;
264  if (offset >= pos) {
265  break;
266  }
267  }
268 
269  if (cl) {
270  offset -= 1;
271  *r_cl = cl;
272  *r_cl_offset = offset;
273  *r_col = offset - pos;
274  return true;
275  }
276 
277  *r_cl = NULL;
278  *r_cl_offset = -1;
279  *r_col = -1;
280  return false;
281 }
282 
283 /* static funcs for text editing */
284 
285 /* similar to the text editor, with some not used. keep compatible */
287  {LINE_BEGIN, "LINE_BEGIN", 0, "Line Begin", ""},
288  {LINE_END, "LINE_END", 0, "Line End", ""},
289  {PREV_CHAR, "PREVIOUS_CHARACTER", 0, "Previous Character", ""},
290  {NEXT_CHAR, "NEXT_CHARACTER", 0, "Next Character", ""},
291  {PREV_WORD, "PREVIOUS_WORD", 0, "Previous Word", ""},
292  {NEXT_WORD, "NEXT_WORD", 0, "Next Word", ""},
293  {0, NULL, 0, NULL, NULL},
294 };
295 
297 {
299 
300  int type = RNA_enum_get(op->ptr, "type");
301  bool done = false;
302  int pos;
303 
304  switch (type) {
305  case LINE_BEGIN:
306  pos = ci->cursor;
308  done = console_line_cursor_set(ci, pos);
309  break;
310  case LINE_END:
311  pos = ci->cursor;
313  done = console_line_cursor_set(ci, pos);
314  break;
315  case PREV_CHAR:
316  pos = ci->cursor;
318  done = console_line_cursor_set(ci, pos);
319  break;
320  case NEXT_CHAR:
321  pos = ci->cursor;
323  done = console_line_cursor_set(ci, pos);
324  break;
325 
326  /* - if the character is a delimiter then skip delimiters (including white space)
327  * - when jump over the word */
328  case PREV_WORD:
329  pos = ci->cursor;
331  done = console_line_cursor_set(ci, pos);
332  break;
333  case NEXT_WORD:
334  pos = ci->cursor;
336  done = console_line_cursor_set(ci, pos);
337  break;
338  }
339 
340  if (done) {
342  ARegion *region = CTX_wm_region(C);
343 
345  console_scroll_bottom(region);
346  }
347 
348  return OPERATOR_FINISHED;
349 }
350 
352 {
353  /* identifiers */
354  ot->name = "Move Cursor";
355  ot->description = "Move cursor position";
356  ot->idname = "CONSOLE_OT_move";
357 
358  /* api callbacks */
361 
362  /* properties */
363  RNA_def_enum(
364  ot->srna, "type", console_move_type_items, LINE_BEGIN, "Type", "Where to move cursor to");
365 }
366 
367 #define TAB_LENGTH 4
369 {
371  ARegion *region = CTX_wm_region(C);
373  char *str = RNA_string_get_alloc(op->ptr, "text", NULL, 0, NULL);
374  int len;
375 
376  if (str[0] == '\t' && str[1] == '\0') {
377  len = TAB_LENGTH;
378  MEM_freeN(str);
379  str = MEM_mallocN(len + 1, "insert_exec");
380  memset(str, ' ', len);
381  str[len] = '\0';
382  }
383 
384  len = console_line_insert(ci, str);
385 
386  MEM_freeN(str);
387 
388  if (len == 0) {
389  return OPERATOR_CANCELLED;
390  }
391 
393 
394  console_textview_update_rect(sc, region);
396 
397  console_scroll_bottom(region);
398 
399  return OPERATOR_FINISHED;
400 }
401 
402 static int console_insert_invoke(bContext *C, wmOperator *op, const wmEvent *event)
403 {
404  /* NOTE: the "text" property is always set from key-map,
405  * so we can't use #RNA_struct_property_is_set, check the length instead. */
406  if (!RNA_string_length(op->ptr, "text")) {
407  /* if alt/ctrl/super are pressed pass through except for utf8 character event
408  * (when input method are used for utf8 inputs, the user may assign key event
409  * including alt/ctrl/super like ctrl+m to commit utf8 string. in such case,
410  * the modifiers in the utf8 character event make no sense.) */
411  if ((event->modifier & (KM_CTRL | KM_OSKEY)) && !event->utf8_buf[0]) {
412  return OPERATOR_PASS_THROUGH;
413  }
414 
415  char str[BLI_UTF8_MAX + 1];
416  const size_t len = BLI_str_utf8_size_safe(event->utf8_buf);
417  memcpy(str, event->utf8_buf, len);
418  str[len] = '\0';
419  RNA_string_set(op->ptr, "text", str);
420  }
421  return console_insert_exec(C, op);
422 }
423 
425 {
426  PropertyRNA *prop;
427 
428  /* identifiers */
429  ot->name = "Insert";
430  ot->description = "Insert text at cursor position";
431  ot->idname = "CONSOLE_OT_insert";
432 
433  /* api callbacks */
437 
438  /* properties */
439  prop = RNA_def_string(
440  ot->srna, "text", NULL, 0, "Text", "Text to insert at the cursor position");
442 }
443 
444 /* -------------------------------------------------------------------- */
449 {
451  bool text_before_cursor = false;
452 
453  /* Check any text before cursor (not just the previous character) as is done for
454  * #TEXT_OT_indent_or_autocomplete because Python auto-complete operates on import
455  * statements such as completing possible sub-modules: `from bpy import `. */
456  for (int i = 0; i < ci->cursor; i += BLI_str_utf8_size_safe(&ci->line[i])) {
457  if (!ELEM(ci->line[i], ' ', '\t')) {
458  text_before_cursor = true;
459  break;
460  }
461  }
462 
463  if (text_before_cursor) {
464  WM_operator_name_call(C, "CONSOLE_OT_autocomplete", WM_OP_INVOKE_DEFAULT, NULL, NULL);
465  }
466  else {
467  WM_operator_name_call(C, "CONSOLE_OT_indent", WM_OP_EXEC_DEFAULT, NULL, NULL);
468  }
469  return OPERATOR_FINISHED;
470 }
471 
473 {
474  /* identifiers */
475  ot->name = "Indent or Autocomplete";
476  ot->idname = "CONSOLE_OT_indent_or_autocomplete";
477  ot->description = "Indent selected text or autocomplete";
478 
479  /* api callbacks */
482 
483  /* flags */
484  ot->flag = 0;
485 }
486 
489 /* -------------------------------------------------------------------- */
494 {
496  ARegion *region = CTX_wm_region(C);
498  int spaces;
499  int len;
500 
501  for (spaces = 0; spaces < ci->len; spaces++) {
502  if (ci->line[spaces] != ' ') {
503  break;
504  }
505  }
506 
507  len = TAB_LENGTH - spaces % TAB_LENGTH;
508 
510 
511  memmove(ci->line + len, ci->line, ci->len + 1);
512  memset(ci->line, ' ', len);
513  ci->len += len;
514  BLI_assert(ci->len >= 0);
517 
518  console_textview_update_rect(sc, region);
520 
521  console_scroll_bottom(region);
522 
523  return OPERATOR_FINISHED;
524 }
525 
527 {
528  /* identifiers */
529  ot->name = "Indent";
530  ot->description = "Add 4 spaces at line beginning";
531  ot->idname = "CONSOLE_OT_indent";
532 
533  /* api callbacks */
536 }
537 
541 {
543  ARegion *region = CTX_wm_region(C);
545  int spaces;
546  int len;
547 
548  for (spaces = 0; spaces < ci->len; spaces++) {
549  if (ci->line[spaces] != ' ') {
550  break;
551  }
552  }
553 
554  if (spaces == 0) {
555  return OPERATOR_CANCELLED;
556  }
557 
558  len = spaces % TAB_LENGTH;
559  if (len == 0) {
560  len = TAB_LENGTH;
561  }
562 
564 
565  memmove(ci->line, ci->line + len, (ci->len - len) + 1);
566  ci->len -= len;
567  BLI_assert(ci->len >= 0);
568 
571 
572  console_textview_update_rect(sc, region);
574 
575  console_scroll_bottom(region);
576 
577  return OPERATOR_FINISHED;
578 }
579 
581 {
582  /* identifiers */
583  ot->name = "Unindent";
584  ot->description = "Delete 4 spaces from line beginning";
585  ot->idname = "CONSOLE_OT_unindent";
586 
587  /* api callbacks */
590 }
591 
593  {DEL_NEXT_CHAR, "NEXT_CHARACTER", 0, "Next Character", ""},
594  {DEL_PREV_CHAR, "PREVIOUS_CHARACTER", 0, "Previous Character", ""},
595  {DEL_NEXT_WORD, "NEXT_WORD", 0, "Next Word", ""},
596  {DEL_PREV_WORD, "PREVIOUS_WORD", 0, "Previous Word", ""},
597  {0, NULL, 0, NULL, NULL},
598 };
599 
601 {
603  ARegion *region = CTX_wm_region(C);
605  int pos;
606  int stride;
607 
608  const short type = RNA_enum_get(op->ptr, "type");
609  bool done = false;
610 
611  if (ci->len == 0) {
612  return OPERATOR_CANCELLED;
613  }
614 
615  switch (type) {
616  case DEL_NEXT_CHAR:
617  case DEL_NEXT_WORD:
618  if (ci->cursor < ci->len) {
619  pos = ci->cursor;
621  ci->len,
622  &pos,
625  true);
626  stride = pos - ci->cursor;
627  if (stride) {
628  memmove(ci->line + ci->cursor,
629  ci->line + ci->cursor + stride,
630  (ci->len - (ci->cursor + stride)) + 1);
631  ci->len -= stride;
632  BLI_assert(ci->len >= 0);
633  done = true;
634  }
635  }
636  break;
637  case DEL_PREV_CHAR:
638  case DEL_PREV_WORD:
639  if (ci->cursor > 0) {
640  pos = ci->cursor;
642  ci->len,
643  &pos,
646  true);
647  stride = ci->cursor - pos;
648  if (stride) {
649  ci->cursor -= stride; /* same as above */
650  memmove(ci->line + ci->cursor,
651  ci->line + ci->cursor + stride,
652  (ci->len - (ci->cursor + stride)) + 1);
653  ci->len -= stride;
654  BLI_assert(ci->len >= 0);
655  done = true;
656  }
657  }
658  break;
659  }
660 
661  if (!done) {
662  return OPERATOR_CANCELLED;
663  }
664 
666 
667  console_textview_update_rect(sc, region);
669 
670  console_scroll_bottom(region);
671 
672  return OPERATOR_FINISHED;
673 }
674 
676 {
677  /* identifiers */
678  ot->name = "Delete";
679  ot->description = "Delete text by cursor position";
680  ot->idname = "CONSOLE_OT_delete";
681 
682  /* api callbacks */
685 
686  /* properties */
688  "type",
691  "Type",
692  "Which part of the text to delete");
693 }
694 
696 {
698  ARegion *region = CTX_wm_region(C);
700 
701  if (ci->len == 0) {
702  return OPERATOR_CANCELLED;
703  }
704 
705  console_history_add(sc, ci);
707  console_select_offset(sc, -ci->len);
708 
709  console_textview_update_rect(sc, region);
710 
712 
713  console_scroll_bottom(region);
714 
715  return OPERATOR_FINISHED;
716 }
717 
719 {
720  /* identifiers */
721  ot->name = "Clear Line";
722  ot->description = "Clear the line and store in history";
723  ot->idname = "CONSOLE_OT_clear_line";
724 
725  /* api callbacks */
728 }
729 
730 /* the python exec operator uses this */
732 {
734  ARegion *region = CTX_wm_region(C);
735 
736  const bool scrollback = RNA_boolean_get(op->ptr, "scrollback");
737  const bool history = RNA_boolean_get(op->ptr, "history");
738 
739  /* ConsoleLine *ci = */ console_history_verify(C);
740 
741  if (scrollback) { /* Last item in history. */
742  while (sc->scrollback.first) {
744  }
745  }
746 
747  if (history) {
748  while (sc->history.first) {
750  }
752  }
753 
754  console_textview_update_rect(sc, region);
756 
757  return OPERATOR_FINISHED;
758 }
759 
761 {
762  /* identifiers */
763  ot->name = "Clear All";
764  ot->description = "Clear text by type";
765  ot->idname = "CONSOLE_OT_clear";
766 
767  /* api callbacks */
770 
771  /* properties */
772  RNA_def_boolean(ot->srna, "scrollback", 1, "Scrollback", "Clear the scrollback history");
773  RNA_def_boolean(ot->srna, "history", 0, "History", "Clear the command history");
774 }
775 
776 /* the python exec operator uses this */
778 {
780  ARegion *region = CTX_wm_region(C);
781 
782  /* TODO: stupid, just prevents crashes when no command line. */
784  const bool reverse = RNA_boolean_get(op->ptr, "reverse"); /* assumes down, reverse is up */
785  int prev_len = ci->len;
786 
787  /* keep a copy of the line above so when history is cycled
788  * this is the only function that needs to know about the double-up */
789  if (ci->prev) {
790  ConsoleLine *ci_prev = (ConsoleLine *)ci->prev;
791 
792  if (STREQ(ci->line, ci_prev->line)) {
793  console_history_free(sc, ci_prev);
794  }
795  }
796 
797  if (reverse) { /* last item in history */
798  ci = sc->history.last;
799  BLI_remlink(&sc->history, ci);
800  BLI_addhead(&sc->history, ci);
801  }
802  else {
803  ci = sc->history.first;
804  BLI_remlink(&sc->history, ci);
805  BLI_addtail(&sc->history, ci);
806  }
807 
808  { /* add a duplicate of the new arg and remove all other instances */
809  ConsoleLine *cl;
810  while ((cl = console_history_find(sc, ci->line, ci))) {
811  console_history_free(sc, cl);
812  }
813 
815  }
816 
817  ci = sc->history.last;
818  console_select_offset(sc, ci->len - prev_len);
819 
820  /* could be wrapped so update scroll rect */
821  console_textview_update_rect(sc, region);
823 
824  console_scroll_bottom(region);
825 
826  return OPERATOR_FINISHED;
827 }
828 
830 {
831  /* identifiers */
832  ot->name = "History Cycle";
833  ot->description = "Cycle through history";
834  ot->idname = "CONSOLE_OT_history_cycle";
835 
836  /* api callbacks */
839 
840  /* properties */
841  RNA_def_boolean(ot->srna, "reverse", 0, "Reverse", "Reverse cycle history");
842 }
843 
844 /* the python exec operator uses this */
846 {
848  ARegion *region = CTX_wm_region(C);
851  /* own this text in the new line, don't free */
852  char *str = RNA_string_get_alloc(op->ptr, "text", NULL, 0, NULL);
853  int cursor = RNA_int_get(op->ptr, "current_character");
854  const bool rem_dupes = RNA_boolean_get(op->ptr, "remove_duplicates");
855  int prev_len = ci->len;
856 
857  if (rem_dupes) {
858  ConsoleLine *cl;
859 
860  while ((cl = console_history_find(sc, ci->line, ci))) {
861  console_history_free(sc, cl);
862  }
863 
864  if (STREQ(str, ci->line)) {
865  MEM_freeN(str);
866  return OPERATOR_FINISHED;
867  }
868  }
869 
870  ci = console_history_add_str(sc, str, 1); /* own the string */
871  console_select_offset(sc, ci->len - prev_len);
872  console_line_cursor_set(ci, cursor);
873 
875 
876  /* when calling render modally this can be NULL when calling:
877  * bpy.ops.render.render('INVOKE_DEFAULT') */
878  if (region) {
879  console_scroll_bottom(region);
880  }
881 
882  return OPERATOR_FINISHED;
883 }
884 
886 {
887  /* identifiers */
888  ot->name = "History Append";
889  ot->description = "Append history at cursor position";
890  ot->idname = "CONSOLE_OT_history_append";
891 
892  /* api callbacks */
895 
896  /* properties */
897  RNA_def_string(ot->srna, "text", NULL, 0, "Text", "Text to insert at the cursor position");
898  RNA_def_int(
899  ot->srna, "current_character", 0, 0, INT_MAX, "Cursor", "The index of the cursor", 0, 10000);
901  "remove_duplicates",
902  0,
903  "Remove Duplicates",
904  "Remove duplicate items in the history");
905 }
906 
907 /* the python exec operator uses this */
909 {
911  ARegion *region = CTX_wm_region(C);
912  ConsoleLine *ci;
913 
914  /* own this text in the new line, don't free */
915  char *str = RNA_string_get_alloc(op->ptr, "text", NULL, 0, NULL);
916  int type = RNA_enum_get(op->ptr, "type");
917 
919 
920  ci = console_scrollback_add_str(sc, str, 1); /* own the string */
921  ci->type = type;
922 
924 
925  /* 'region' can be null depending on the operator that runs
926  * rendering with invoke default for eg causes this */
927  if (region) {
928  console_textview_update_rect(sc, region);
929  }
930 
932 
933  return OPERATOR_FINISHED;
934 }
935 
937 {
938  /* defined in DNA_space_types.h */
939  static const EnumPropertyItem console_line_type_items[] = {
940  {CONSOLE_LINE_OUTPUT, "OUTPUT", 0, "Output", ""},
941  {CONSOLE_LINE_INPUT, "INPUT", 0, "Input", ""},
942  {CONSOLE_LINE_INFO, "INFO", 0, "Information", ""},
943  {CONSOLE_LINE_ERROR, "ERROR", 0, "Error", ""},
944  {0, NULL, 0, NULL, NULL},
945  };
946 
947  /* identifiers */
948  ot->name = "Scrollback Append";
949  ot->description = "Append scrollback text by type";
950  ot->idname = "CONSOLE_OT_scrollback_append";
951 
952  /* api callbacks */
955 
956  /* properties */
957  RNA_def_string(ot->srna, "text", NULL, 0, "Text", "Text to insert at the cursor position");
959  "type",
960  console_line_type_items,
962  "Type",
963  "Console output type");
964 }
965 
967 {
969 
970  DynStr *buf_dyn;
971  char *buf_str;
972 
973  ConsoleLine *cl;
974  int sel[2];
975  int offset = 0;
976 
977  ConsoleLine cl_dummy = {NULL};
978 
979  if (sc->sel_start == sc->sel_end) {
980  return OPERATOR_CANCELLED;
981  }
982 
983  console_scrollback_prompt_begin(sc, &cl_dummy);
984 
985  for (cl = sc->scrollback.first; cl; cl = cl->next) {
986  offset += cl->len + 1;
987  }
988 
989  if (offset == 0) {
990  console_scrollback_prompt_end(sc, &cl_dummy);
991  return OPERATOR_CANCELLED;
992  }
993 
994  buf_dyn = BLI_dynstr_new();
995  offset -= 1;
996  sel[0] = offset - sc->sel_end;
997  sel[1] = offset - sc->sel_start;
998 
999  for (cl = sc->scrollback.first; cl; cl = cl->next) {
1000  if (sel[0] <= cl->len && sel[1] >= 0) {
1001  int sta = max_ii(sel[0], 0);
1002  int end = min_ii(sel[1], cl->len);
1003 
1004  if (BLI_dynstr_get_len(buf_dyn)) {
1005  BLI_dynstr_append(buf_dyn, "\n");
1006  }
1007 
1008  BLI_dynstr_nappend(buf_dyn, cl->line + sta, end - sta);
1009  }
1010 
1011  sel[0] -= cl->len + 1;
1012  sel[1] -= cl->len + 1;
1013  }
1014 
1015  buf_str = BLI_dynstr_get_cstring(buf_dyn);
1016 
1017  BLI_dynstr_free(buf_dyn);
1018  WM_clipboard_text_set(buf_str, 0);
1019 
1020  MEM_freeN(buf_str);
1021 
1022  console_scrollback_prompt_end(sc, &cl_dummy);
1023 
1024  return OPERATOR_FINISHED;
1025 }
1026 
1028 {
1029  /* identifiers */
1030  ot->name = "Copy to Clipboard";
1031  ot->description = "Copy selected text to clipboard";
1032  ot->idname = "CONSOLE_OT_copy";
1033 
1034  /* api callbacks */
1037 
1038  /* properties */
1039 }
1040 
1042 {
1044  ARegion *region = CTX_wm_region(C);
1046  int buf_len;
1047 
1048  char *buf_str = WM_clipboard_text_get(false, &buf_len);
1049  char *buf_step, *buf_next;
1050 
1051  if (buf_str == NULL) {
1052  return OPERATOR_CANCELLED;
1053  }
1054 
1055  buf_step = buf_str;
1056 
1057  while ((buf_next = buf_step) && buf_next[0] != '\0') {
1058  buf_step = strchr(buf_next, '\n');
1059  if (buf_step) {
1060  *buf_step = '\0';
1061  buf_step++;
1062  }
1063 
1064  if (buf_next != buf_str) {
1065  WM_operator_name_call(C, "CONSOLE_OT_execute", WM_OP_EXEC_DEFAULT, NULL, NULL);
1066  ci = console_history_verify(C);
1067  }
1068 
1069  console_select_offset(sc, console_line_insert(ci, buf_next));
1070  }
1071 
1072  MEM_freeN(buf_str);
1073 
1074  console_textview_update_rect(sc, region);
1076 
1077  console_scroll_bottom(region);
1078 
1079  return OPERATOR_FINISHED;
1080 }
1081 
1083 {
1084  /* identifiers */
1085  ot->name = "Paste from Clipboard";
1086  ot->description = "Paste text from clipboard";
1087  ot->idname = "CONSOLE_OT_paste";
1088 
1089  /* api callbacks */
1092 
1093  /* properties */
1094 }
1095 
1096 typedef struct SetConsoleCursor {
1097  int sel_old[2];
1100 
1101 /* TODO: cursor placement without selection. */
1103  SpaceConsole *sc, ARegion *region, SetConsoleCursor *scu, const int mval[2], int UNUSED(sel))
1104 {
1105  int pos;
1106  pos = console_char_pick(sc, region, mval);
1107 
1108  if (scu->sel_init == INT_MAX) {
1109  scu->sel_init = pos;
1110  sc->sel_start = sc->sel_end = pos;
1111  return;
1112  }
1113 
1114  if (pos < scu->sel_init) {
1115  sc->sel_start = pos;
1116  sc->sel_end = scu->sel_init;
1117  }
1118  else if (pos > sc->sel_start) {
1119  sc->sel_start = scu->sel_init;
1120  sc->sel_end = pos;
1121  }
1122  else {
1123  sc->sel_start = sc->sel_end = pos;
1124  }
1125 }
1126 
1127 static void console_modal_select_apply(bContext *C, wmOperator *op, const wmEvent *event)
1128 {
1130  ARegion *region = CTX_wm_region(C);
1131  SetConsoleCursor *scu = op->customdata;
1132  int mval[2];
1133  int sel_prev[2];
1134 
1135  mval[0] = event->mval[0];
1136  mval[1] = event->mval[1];
1137 
1138  sel_prev[0] = sc->sel_start;
1139  sel_prev[1] = sc->sel_end;
1140 
1141  console_cursor_set_to_pos(sc, region, scu, mval, true);
1142 
1143  /* only redraw if the selection changed */
1144  if (sel_prev[0] != sc->sel_start || sel_prev[1] != sc->sel_end) {
1146  }
1147 }
1148 
1150 {
1151  // SpaceConsole *sc = CTX_wm_space_console(C);
1152  SetConsoleCursor *scu = op->customdata;
1153 
1154 #if 0
1155  if (txt_has_sel(text)) {
1156  buffer = txt_sel_to_buf(text);
1158  MEM_freeN(buffer);
1159  }
1160 #endif
1161 
1162  MEM_freeN(scu);
1163 }
1164 
1166 {
1168  // ARegion *region = CTX_wm_region(C);
1169  SetConsoleCursor *scu;
1170 
1171  op->customdata = MEM_callocN(sizeof(SetConsoleCursor), "SetConsoleCursor");
1172  scu = op->customdata;
1173 
1174  scu->sel_old[0] = sc->sel_start;
1175  scu->sel_old[1] = sc->sel_end;
1176 
1177  scu->sel_init = INT_MAX;
1178 
1180 
1181  console_modal_select_apply(C, op, event);
1182 
1183  return OPERATOR_RUNNING_MODAL;
1184 }
1185 
1186 static int console_modal_select(bContext *C, wmOperator *op, const wmEvent *event)
1187 {
1188  switch (event->type) {
1189  case LEFTMOUSE:
1190  case MIDDLEMOUSE:
1191  case RIGHTMOUSE:
1192  if (event->val == KM_RELEASE) {
1194  return OPERATOR_FINISHED;
1195  }
1196  break;
1197  case MOUSEMOVE:
1198  console_modal_select_apply(C, op, event);
1199  break;
1200  }
1201 
1202  return OPERATOR_RUNNING_MODAL;
1203 }
1204 
1206 {
1208 }
1209 
1211 {
1212  /* identifiers */
1213  ot->name = "Set Selection";
1214  ot->idname = "CONSOLE_OT_select_set";
1215  ot->description = "Set the console selection";
1216 
1217  /* api callbacks */
1222 }
1223 
1225 {
1227  ARegion *region = CTX_wm_region(C);
1228 
1229  ConsoleLine cl_dummy = {NULL};
1230  ConsoleLine *cl;
1231  int ret = OPERATOR_CANCELLED;
1232  int pos, offset, n;
1233 
1234  pos = console_char_pick(sc, region, event->mval);
1235 
1236  console_scrollback_prompt_begin(sc, &cl_dummy);
1237 
1238  if (console_line_column_from_index(sc, pos, &cl, &offset, &n)) {
1239  int sel[2] = {n, n};
1240 
1242 
1244 
1245  sel[0] = offset - sel[0];
1246  sel[1] = offset - sel[1];
1247 
1248  if ((sel[0] != sc->sel_start) || (sel[1] != sc->sel_end)) {
1249  sc->sel_start = sel[0];
1250  sc->sel_end = sel[1];
1253  }
1254  }
1255 
1256  console_scrollback_prompt_end(sc, &cl_dummy);
1257  return ret;
1258 }
1259 
1261 {
1262  /* identifiers */
1263  ot->name = "Select Word";
1264  ot->description = "Select word at cursor position";
1265  ot->idname = "CONSOLE_OT_select_word";
1266 
1267  /* api callbacks */
1270 }
typedef float(TangentPoint)[2]
struct ScrArea * CTX_wm_area(const bContext *C)
Definition: context.c:738
struct ARegion * CTX_wm_region(const bContext *C)
Definition: context.c:749
struct SpaceConsole * CTX_wm_space_console(const bContext *C)
Definition: context.c:815
bool txt_has_sel(const struct Text *text)
char * txt_sel_to_buf(struct Text *text, size_t *r_buf_strlen)
Definition: text.c:1454
#define BLI_assert(a)
Definition: BLI_assert.h:46
A dynamically sized string ADT.
DynStr * BLI_dynstr_new(void) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
Definition: BLI_dynstr.c:50
void BLI_dynstr_nappend(DynStr *__restrict ds, const char *cstr, int len) ATTR_NONNULL()
Definition: BLI_dynstr.c:94
int BLI_dynstr_get_len(const DynStr *ds) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition: BLI_dynstr.c:235
char * BLI_dynstr_get_cstring(const DynStr *ds) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition: BLI_dynstr.c:256
void BLI_dynstr_free(DynStr *ds) ATTR_NONNULL()
Definition: BLI_dynstr.c:281
void BLI_dynstr_append(DynStr *__restrict ds, const char *cstr) ATTR_NONNULL()
Definition: BLI_dynstr.c:75
void BLI_addhead(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition: listbase.c:60
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition: listbase.c:80
void BLI_remlink(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition: listbase.c:100
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_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL() ATTR_MALLOC
Definition: string.c:42
char * BLI_strdupn(const char *str, size_t len) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition: string.c:33
void BLI_str_cursor_step_utf8(const char *str, size_t maxlen, int *pos, eStrCursorJumpDirection direction, eStrCursorJumpType jump, bool use_init_step)
@ STRCUR_DIR_NEXT
@ STRCUR_DIR_PREV
@ 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)
Definition: string_utf8.c:466
#define UNUSED(x)
#define ELEM(...)
#define STREQ(a, b)
@ CONSOLE_LINE_INFO
@ CONSOLE_LINE_ERROR
@ CONSOLE_LINE_INPUT
@ CONSOLE_LINE_OUTPUT
@ OPERATOR_CANCELLED
@ OPERATOR_FINISHED
@ OPERATOR_RUNNING_MODAL
@ OPERATOR_PASS_THROUGH
void ED_area_tag_redraw(ScrArea *area)
Definition: area.c:729
bool ED_operator_console_active(struct bContext *C)
Definition: screen_ops.c:359
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei stride
Read Guarded memory(de)allocation.
@ PROP_SKIP_SAVE
Definition: RNA_types.h:218
#define C
Definition: RandGen.cpp:25
void UI_view2d_totRect_set(struct View2D *v2d, int width, int height)
Definition: view2d.cc:1022
@ KM_RELEASE
Definition: WM_types.h:268
@ WM_OP_INVOKE_DEFAULT
Definition: WM_types.h:201
@ WM_OP_EXEC_DEFAULT
Definition: WM_types.h:208
@ KM_CTRL
Definition: WM_types.h:239
@ KM_OSKEY
Definition: WM_types.h:242
#define NEXT_CHAR(fmt)
unsigned int U
Definition: btGjkEpa3.h:78
void console_scrollback_prompt_end(SpaceConsole *sc, ConsoleLine *cl_dummy)
Definition: console_draw.c:70
int console_textview_height(SpaceConsole *sc, const ARegion *region)
Definition: console_draw.c:231
void console_scrollback_prompt_begin(SpaceConsole *sc, ConsoleLine *cl_dummy)
Definition: console_draw.c:56
int console_char_pick(SpaceConsole *sc, const ARegion *region, const int mval[2])
Definition: console_draw.c:237
static int console_selectword_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
Definition: console_ops.c:1224
static bool console_line_cursor_set(ConsoleLine *cl, int cursor)
Definition: console_ops.c:98
static int console_copy_exec(bContext *C, wmOperator *UNUSED(op))
Definition: console_ops.c:966
static int console_line_insert(ConsoleLine *ci, char *str)
Definition: console_ops.c:227
static void console_modal_select_apply(bContext *C, wmOperator *op, const wmEvent *event)
Definition: console_ops.c:1127
static void console_cursor_set_exit(bContext *UNUSED(C), wmOperator *op)
Definition: console_ops.c:1149
static void console_modal_select_cancel(bContext *C, wmOperator *op)
Definition: console_ops.c:1205
static void console_line_verify_length(ConsoleLine *ci, int len)
Definition: console_ops.c:212
static ConsoleLine * console_lb_add__internal(ListBase *lb, ConsoleLine *from)
Definition: console_ops.c:140
static int console_clear_line_exec(bContext *C, wmOperator *UNUSED(op))
Definition: console_ops.c:695
ConsoleLine * console_history_add_str(SpaceConsole *sc, char *str, bool own)
Definition: console_ops.c:190
static int console_indent_or_autocomplete_exec(bContext *C, wmOperator *UNUSED(op))
Definition: console_ops.c:448
static void console_cursor_set_to_pos(SpaceConsole *sc, ARegion *region, SetConsoleCursor *scu, const int mval[2], int UNUSED(sel))
Definition: console_ops.c:1102
static int console_unindent_exec(bContext *C, wmOperator *UNUSED(op))
Definition: console_ops.c:540
void CONSOLE_OT_copy(wmOperatorType *ot)
Definition: console_ops.c:1027
void CONSOLE_OT_clear(wmOperatorType *ot)
Definition: console_ops.c:760
static const EnumPropertyItem console_move_type_items[]
Definition: console_ops.c:286
static const EnumPropertyItem console_delete_type_items[]
Definition: console_ops.c:592
static bool console_line_column_from_index(SpaceConsole *sc, const int pos, ConsoleLine **r_cl, int *r_cl_offset, int *r_col)
Definition: console_ops.c:256
void console_textview_update_rect(SpaceConsole *sc, ARegion *region)
Definition: console_ops.c:45
#define TAB_LENGTH
Definition: console_ops.c:367
void CONSOLE_OT_select_word(wmOperatorType *ot)
Definition: console_ops.c:1260
void CONSOLE_OT_delete(wmOperatorType *ot)
Definition: console_ops.c:675
void CONSOLE_OT_indent(wmOperatorType *ot)
Definition: console_ops.c:526
void CONSOLE_OT_select_set(wmOperatorType *ot)
Definition: console_ops.c:1210
static int console_history_append_exec(bContext *C, wmOperator *op)
Definition: console_ops.c:845
static void console_scrollback_limit(SpaceConsole *sc)
Definition: console_ops.c:71
static int console_history_cycle_exec(bContext *C, wmOperator *op)
Definition: console_ops.c:777
static int console_insert_invoke(bContext *C, wmOperator *op, const wmEvent *event)
Definition: console_ops.c:402
struct SetConsoleCursor SetConsoleCursor
static int console_scrollback_append_exec(bContext *C, wmOperator *op)
Definition: console_ops.c:908
static int console_move_exec(bContext *C, wmOperator *op)
Definition: console_ops.c:296
void CONSOLE_OT_indent_or_autocomplete(wmOperatorType *ot)
Definition: console_ops.c:472
void CONSOLE_OT_move(wmOperatorType *ot)
Definition: console_ops.c:351
static int console_modal_select(bContext *C, wmOperator *op, const wmEvent *event)
Definition: console_ops.c:1186
static void console_scroll_bottom(ARegion *region)
Definition: console_ops.c:38
void console_history_free(SpaceConsole *sc, ConsoleLine *cl)
Definition: console_ops.c:58
void console_scrollback_free(SpaceConsole *sc, ConsoleLine *cl)
Definition: console_ops.c:64
void CONSOLE_OT_clear_line(wmOperatorType *ot)
Definition: console_ops.c:718
static int console_insert_exec(bContext *C, wmOperator *op)
Definition: console_ops.c:368
void CONSOLE_OT_scrollback_append(wmOperatorType *ot)
Definition: console_ops.c:936
static int console_paste_exec(bContext *C, wmOperator *UNUSED(op))
Definition: console_ops.c:1041
void CONSOLE_OT_insert(wmOperatorType *ot)
Definition: console_ops.c:424
ConsoleLine * console_scrollback_add_str(SpaceConsole *sc, char *str, bool own)
Definition: console_ops.c:194
static ConsoleLine * console_lb_add_str__internal(ListBase *lb, char *str, bool own)
Definition: console_ops.c:175
void CONSOLE_OT_history_cycle(wmOperatorType *ot)
Definition: console_ops.c:829
void CONSOLE_OT_unindent(wmOperatorType *ot)
Definition: console_ops.c:580
static int console_delete_exec(bContext *C, wmOperator *op)
Definition: console_ops.c:600
void CONSOLE_OT_history_append(wmOperatorType *ot)
Definition: console_ops.c:885
static ConsoleLine * console_history_add(SpaceConsole *sc, ConsoleLine *from)
Definition: console_ops.c:161
static int console_clear_exec(bContext *C, wmOperator *op)
Definition: console_ops.c:731
void CONSOLE_OT_paste(wmOperatorType *ot)
Definition: console_ops.c:1082
static int console_modal_select_invoke(bContext *C, wmOperator *op, const wmEvent *event)
Definition: console_ops.c:1165
ConsoleLine * console_history_verify(const bContext *C)
Definition: console_ops.c:201
static int console_indent_exec(bContext *C, wmOperator *UNUSED(op))
Definition: console_ops.c:493
static ConsoleLine * console_history_find(SpaceConsole *sc, const char *str, ConsoleLine *cl_ignore)
Definition: console_ops.c:80
static void console_select_offset(SpaceConsole *sc, const int offset)
Definition: console_ops.c:52
@ LINE_BEGIN
Definition: curve_intern.h:31
@ PREV_WORD
Definition: curve_intern.h:35
@ PREV_CHAR
Definition: curve_intern.h:33
@ LINE_END
Definition: curve_intern.h:32
@ NEXT_WORD
Definition: curve_intern.h:36
@ DEL_PREV_WORD
Definition: curve_intern.h:24
@ DEL_PREV_CHAR
Definition: curve_intern.h:22
@ DEL_NEXT_WORD
Definition: curve_intern.h:23
@ DEL_NEXT_CHAR
Definition: curve_intern.h:21
StackEntry * from
int len
Definition: draw_manager.c:108
#define str(s)
uint pos
ccl_global float * buffer
ccl_gpu_kernel_postfix ccl_global float int int int int float bool int offset
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:27
void *(* MEM_recallocN_id)(void *vmemh, size_t len, const char *str)
Definition: mallocn.c:30
void *(* MEM_callocN)(size_t len, const char *str)
Definition: mallocn.c:31
void *(* MEM_mallocN)(size_t len, const char *str)
Definition: mallocn.c:33
static void area(int d1, int d2, int e1, int e2, float weights[2])
return ret
void RNA_string_set(PointerRNA *ptr, const char *name, const char *value)
Definition: rna_access.c:5155
int RNA_int_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:4910
int RNA_string_length(PointerRNA *ptr, const char *name)
Definition: rna_access.c:5144
char * RNA_string_get_alloc(PointerRNA *ptr, const char *name, char *fixedbuf, int fixedlen, int *r_len)
Definition: rna_access.c:5129
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:4863
int RNA_enum_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:5004
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, bool default_value, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3493
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, int maxlen, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3687
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
Definition: rna_define.c:1490
PropertyRNA * RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, int default_value, int hardmin, int hardmax, const char *ui_name, const char *ui_description, int softmin, int softmax)
Definition: rna_define.c:3597
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, int default_value, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3783
struct ConsoleLine * next
struct ConsoleLine * prev
void * last
Definition: DNA_listBase.h:31
void * first
Definition: DNA_listBase.h:31
ListBase scrollback
short winy
float ymax
Definition: DNA_vec_types.h:70
float ymin
Definition: DNA_vec_types.h:70
short val
Definition: WM_types.h:680
char utf8_buf[6]
Definition: WM_types.h:690
int mval[2]
Definition: WM_types.h:684
uint8_t modifier
Definition: WM_types.h:693
short type
Definition: WM_types.h:678
int(* invoke)(struct bContext *, struct wmOperator *, const struct wmEvent *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:919
const char * name
Definition: WM_types.h:888
int(* modal)(struct bContext *, struct wmOperator *, const struct wmEvent *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:935
const char * idname
Definition: WM_types.h:890
bool(* poll)(struct bContext *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:943
void(* cancel)(struct bContext *, struct wmOperator *)
Definition: WM_types.h:927
struct StructRNA * srna
Definition: WM_types.h:969
const char * description
Definition: WM_types.h:893
int(* exec)(struct bContext *, struct wmOperator *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:903
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.c:3479
void WM_clipboard_text_set(const char *buf, bool selection)
Definition: wm_window.c:1780
char * WM_clipboard_text_get(bool selection, int *r_len)
Definition: wm_window.c:1770