Blender  V2.93
text_autocomplete.c
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  */
16 
21 #include <ctype.h>
22 #include <string.h>
23 
24 #include "MEM_guardedalloc.h"
25 
26 #include "DNA_text_types.h"
27 
28 #include "BLI_blenlib.h"
29 #include "BLI_ghash.h"
30 
31 #include "BKE_context.h"
32 #include "BKE_screen.h"
33 #include "BKE_text.h"
34 #include "BKE_text_suggestions.h"
35 
36 #include "WM_api.h"
37 #include "WM_types.h"
38 
39 #include "ED_screen.h"
40 #include "ED_text.h"
41 #include "ED_undo.h"
42 
43 #include "UI_interface.h"
44 
45 #include "text_format.h"
46 #include "text_intern.h" /* own include */
47 
48 /* -------------------------------------------------------------------- */
52 bool text_do_suggest_select(SpaceText *st, ARegion *region, const int mval[2])
53 {
54  const int lheight = TXT_LINE_HEIGHT(st);
55  SuggItem *item, *first, *last /* , *sel */ /* UNUSED */;
56  TextLine *tmp;
57  int l, x, y, w, h, i;
58  int tgti, *top;
59 
60  if (!st->text) {
61  return 0;
62  }
63  if (!texttool_text_is_active(st->text)) {
64  return 0;
65  }
66 
67  first = texttool_suggest_first();
68  last = texttool_suggest_last();
69  /* sel = texttool_suggest_selected(); */ /* UNUSED */
71 
72  if (!last || !first) {
73  return 0;
74  }
75 
76  /* Count the visible lines to the cursor */
77  for (tmp = st->text->curl, l = -st->top; tmp; tmp = tmp->prev, l++) {
78  /* pass */
79  }
80  if (l < 0) {
81  return 0;
82  }
83 
85 
86  x = TXT_BODY_LEFT(st) + (st->runtime.cwidth_px * (st->text->curc - st->left));
87  y = region->winy - lheight * l - 2;
88 
89  w = SUGG_LIST_WIDTH * st->runtime.cwidth_px + U.widget_unit;
90  h = SUGG_LIST_SIZE * lheight + 0.4f * U.widget_unit;
91 
92  if (mval[0] < x || x + w < mval[0] || mval[1] < y - h || y < mval[1]) {
93  return 0;
94  }
95 
96  /* Work out which of the items is at the top of the visible list */
97  for (i = 0, item = first; i < *top && item->next; i++, item = item->next) {
98  /* pass */
99  }
100 
101  /* Work out the target item index in the visible list */
102  tgti = (y - mval[1] - 4) / lheight;
103  if (tgti < 0 || tgti > SUGG_LIST_SIZE) {
104  return 1;
105  }
106 
107  for (i = tgti; i > 0 && item->next; i--, item = item->next) {
108  /* pass */
109  }
110  if (item) {
112  }
113  return 1;
114 }
115 
117 {
118  SuggItem *item, *sel;
119  int *top, i;
120 
121  item = texttool_suggest_first();
124 
125  i = 0;
126  while (item && item != sel) {
127  item = item->next;
128  i++;
129  }
130  if (i > *top + SUGG_LIST_SIZE - 1) {
131  *top = i - SUGG_LIST_SIZE + 1;
132  }
133  else if (i < *top) {
134  *top = i;
135  }
136 }
137 
140 /* -------------------------------------------------------------------- */
144 static void text_autocomplete_free(bContext *C, wmOperator *op);
145 
147 {
148  GHash *gh;
149  int seek_len = 0;
150  const char *seek;
152 
154 
155  /* first get the word we're at */
156  {
157  const int i = text_find_identifier_start(text->curl->line, text->curc);
158  seek_len = text->curc - i;
159  seek = text->curl->line + i;
160 
161  // BLI_strncpy(seek, seek_ptr, seek_len);
162  }
163 
164  /* now walk over entire doc and suggest words */
165  {
166  TextLine *linep;
167 
168  gh = BLI_ghash_str_new(__func__);
169 
170  for (linep = text->lines.first; linep; linep = linep->next) {
171  size_t i_start = 0;
172  size_t i_end = 0;
173  size_t i_pos = 0;
174 
175  while (i_start < linep->len) {
176  /* seek identifier beginning */
177  i_pos = i_start;
178  while ((i_start < linep->len) &&
180  BLI_str_utf8_as_unicode_and_size_safe(&linep->line[i_start], &i_pos)))) {
181  i_start = i_pos;
182  }
183  i_pos = i_end = i_start;
184  while ((i_end < linep->len) &&
186  BLI_str_utf8_as_unicode_and_size_safe(&linep->line[i_end], &i_pos)))) {
187  i_end = i_pos;
188  }
189 
190  if ((i_start != i_end) &&
191  /* Check we're at the beginning of a line or that the previous char is not an
192  * identifier this prevents digits from being added. */
193  ((i_start < 1) ||
195  char *str_sub = &linep->line[i_start];
196  const int choice_len = i_end - i_start;
197 
198  if ((choice_len > seek_len) && (seek_len == 0 || STREQLEN(seek, str_sub, seek_len)) &&
199  (seek != str_sub)) {
200  // printf("Adding: %s\n", s);
201  char str_sub_last = str_sub[choice_len];
202  str_sub[choice_len] = '\0';
203  if (!BLI_ghash_lookup(gh, str_sub)) {
204  char *str_dup = BLI_strdupn(str_sub, choice_len);
205  /* A 'set' would make more sense here */
206  BLI_ghash_insert(gh, str_dup, str_dup);
207  }
208  str_sub[choice_len] = str_sub_last;
209  }
210  }
211  if (i_end != i_start) {
212  i_start = i_end;
213  }
214  else {
215  /* highly unlikely, but prevent eternal loop */
216  i_start++;
217  }
218  }
219  }
220 
221  {
222  GHashIterator gh_iter;
223 
224  /* get the formatter for highlighting */
225  TextFormatType *tft;
226  tft = ED_text_format_get(text);
227 
228  GHASH_ITER (gh_iter, gh) {
229  const char *s = BLI_ghashIterator_getValue(&gh_iter);
231  }
232  }
233  }
234 
235  texttool_suggest_prefix(seek, seek_len);
236 
237  return gh;
238 }
239 
240 /* -- */
241 
242 static void get_suggest_prefix(Text *text, int offset)
243 {
244  int i, len;
245  const char *line;
246 
247  if (!text) {
248  return;
249  }
250  if (!texttool_text_is_active(text)) {
251  return;
252  }
253 
254  line = text->curl->line;
255  i = text_find_identifier_start(line, text->curc + offset);
256  len = text->curc - i + offset;
257  texttool_suggest_prefix(line + i, len);
258 }
259 
260 static void confirm_suggestion(Text *text)
261 {
262  SuggItem *sel;
263  int i, over = 0;
264  const char *line;
265 
266  if (!text) {
267  return;
268  }
269  if (!texttool_text_is_active(text)) {
270  return;
271  }
272 
274  if (!sel) {
275  return;
276  }
277 
278  line = text->curl->line;
279  i = text_find_identifier_start(line, text->curc /* - skipleft */);
280  over = text->curc - i;
281 
282  // for (i = 0; i < skipleft; i++)
283  // txt_move_left(text, 0);
284  BLI_assert(memcmp(sel->name, &line[i], over) == 0);
285  txt_insert_buf(text, sel->name + over);
286 
287  // for (i = 0; i < skipleft; i++)
288  // txt_move_right(text, 0);
289 
291 }
292 
295 /* -------------------------------------------------------------------- */
299 static int text_autocomplete_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
300 {
302  Text *text = CTX_data_edit_text(C);
303 
304  st->doplugins = true;
306 
307  if (texttool_suggest_first()) {
308 
310 
316  ED_undo_push(C, op->type->name);
317  return OPERATOR_FINISHED;
318  }
319 
321  return OPERATOR_RUNNING_MODAL;
322  }
324  return OPERATOR_CANCELLED;
325 }
326 
327 static int doc_scroll = 0;
328 
329 static int text_autocomplete_modal(bContext *C, wmOperator *op, const wmEvent *event)
330 {
331  /* NOTE(campbell): this code could be refactored or rewritten. */
335 
336  int draw = 0, tools = 0, swallow = 0, scroll = 1;
337  int retval = OPERATOR_RUNNING_MODAL;
338 
339  if (st->doplugins && texttool_text_is_active(st->text)) {
340  if (texttool_suggest_first()) {
341  tools |= TOOL_SUGG_LIST;
342  }
343  if (texttool_docs_get()) {
344  tools |= TOOL_DOCUMENT;
345  }
346  }
347 
348  switch (event->type) {
349  case MOUSEMOVE: {
350  if (text_do_suggest_select(st, region, event->mval)) {
351  draw = 1;
352  }
353  swallow = 1;
354  break;
355  }
356  case LEFTMOUSE:
357  if (event->val == KM_PRESS) {
358  if (text_do_suggest_select(st, region, event->mval)) {
359  if (tools & TOOL_SUGG_LIST) {
363  ED_undo_push(C, op->type->name);
364  swallow = 1;
365  draw = 1;
366  }
367  if (tools & TOOL_DOCUMENT) {
369  doc_scroll = 0;
370  draw = 1;
371  }
372  retval = OPERATOR_FINISHED;
373  }
374  else {
375  if (tools & TOOL_SUGG_LIST) {
377  }
378  if (tools & TOOL_DOCUMENT) {
380  doc_scroll = 0;
381  }
382  retval = OPERATOR_CANCELLED;
383  }
384  draw = 1;
385  }
386  break;
387  case EVT_ESCKEY:
388  if (event->val == KM_PRESS) {
389  draw = swallow = 1;
390  if (tools & TOOL_SUGG_LIST) {
392  }
393  else if (tools & TOOL_DOCUMENT) {
395  doc_scroll = 0;
396  }
397  else {
398  draw = swallow = 0;
399  }
400  retval = OPERATOR_CANCELLED;
401  }
402  break;
403  case EVT_RETKEY:
404  case EVT_PADENTER:
405  if (event->val == KM_PRESS) {
406  if (tools & TOOL_SUGG_LIST) {
410  ED_undo_push(C, op->type->name);
411  swallow = 1;
412  draw = 1;
413  }
414  if (tools & TOOL_DOCUMENT) {
416  doc_scroll = 0;
417  draw = 1;
418  }
419  retval = OPERATOR_FINISHED;
420  }
421  break;
422  case EVT_LEFTARROWKEY:
423  case EVT_BACKSPACEKEY:
424  if (event->val == KM_PRESS) {
425  if (tools & TOOL_SUGG_LIST) {
426  if (event->ctrl) {
428  retval = OPERATOR_CANCELLED;
429  draw = 1;
430  }
431  else {
432  /* Work out which char we are about to delete/pass */
433  if (st->text->curl && st->text->curc > 0) {
434  char ch = st->text->curl->line[st->text->curc - 1];
435  if ((ch == '_' || !ispunct(ch)) && !text_check_whitespace(ch)) {
436  get_suggest_prefix(st->text, -1);
438  txt_move_left(st->text, false);
439  draw = 1;
440  }
441  else {
443  retval = OPERATOR_CANCELLED;
444  draw = 1;
445  }
446  }
447  else {
449  retval = OPERATOR_CANCELLED;
450  draw = 1;
451  }
452  }
453  }
454  if (tools & TOOL_DOCUMENT) {
456  doc_scroll = 0;
457  }
458  }
459  break;
460  case EVT_RIGHTARROWKEY:
461  if (event->val == KM_PRESS) {
462  if (tools & TOOL_SUGG_LIST) {
463  if (event->ctrl) {
465  retval = OPERATOR_CANCELLED;
466  draw = 1;
467  }
468  else {
469  /* Work out which char we are about to pass */
470  if (st->text->curl && st->text->curc < st->text->curl->len) {
471  char ch = st->text->curl->line[st->text->curc];
472  if ((ch == '_' || !ispunct(ch)) && !text_check_whitespace(ch)) {
473  get_suggest_prefix(st->text, 1);
475  txt_move_right(st->text, false);
476  draw = 1;
477  }
478  else {
480  retval = OPERATOR_CANCELLED;
481  draw = 1;
482  }
483  }
484  else {
486  retval = OPERATOR_CANCELLED;
487  draw = 1;
488  }
489  }
490  }
491  if (tools & TOOL_DOCUMENT) {
493  doc_scroll = 0;
494  }
495  }
496  break;
497  case EVT_PAGEDOWNKEY:
498  scroll = SUGG_LIST_SIZE - 1;
500  case WHEELDOWNMOUSE:
501  case EVT_DOWNARROWKEY:
502  if (event->val == KM_PRESS) {
503  if (tools & TOOL_DOCUMENT) {
504  doc_scroll++;
505  swallow = 1;
506  draw = 1;
507  }
508  else if (tools & TOOL_SUGG_LIST) {
510  if (!sel) {
512  }
513  else {
514  while (sel && scroll--) {
515  if (sel != texttool_suggest_last() && sel->next) {
517  sel = sel->next;
518  }
519  else {
521  sel = texttool_suggest_first();
522  }
523  }
524  }
526  swallow = 1;
527  draw = 1;
528  }
529  }
530  break;
531  case EVT_PAGEUPKEY:
532  scroll = SUGG_LIST_SIZE - 1;
534  case WHEELUPMOUSE:
535  case EVT_UPARROWKEY:
536  if (event->val == KM_PRESS) {
537  if (tools & TOOL_DOCUMENT) {
538  if (doc_scroll > 0) {
539  doc_scroll--;
540  }
541  swallow = 1;
542  draw = 1;
543  }
544  else if (tools & TOOL_SUGG_LIST) {
546  while (sel && scroll--) {
547  if (sel != texttool_suggest_first() && sel->prev) {
549  sel = sel->prev;
550  }
551  else {
553  sel = texttool_suggest_last();
554  }
555  }
557  swallow = 1;
558  draw = 1;
559  }
560  }
561  break;
562  case EVT_RIGHTSHIFTKEY:
563  case EVT_LEFTSHIFTKEY:
564  break;
565 #if 0
566  default:
567  if (tools & TOOL_SUGG_LIST) {
569  draw = 1;
570  }
571  if (tools & TOOL_DOCUMENT) {
573  doc_scroll = 0;
574  draw = 1;
575  }
576 #endif
577  }
578 
579  if (draw) {
581  }
582 
583  // if (swallow) {
584  // retval = OPERATOR_RUNNING_MODAL;
585  // }
586 
587  if (texttool_suggest_first()) {
588  if (retval != OPERATOR_RUNNING_MODAL) {
590  }
591  return retval;
592  }
594  return OPERATOR_FINISHED;
595 }
596 
598 {
599  GHash *gh = op->customdata;
600  if (gh) {
602  op->customdata = NULL;
603  }
604 
605  /* other stuff */
606  {
608  st->doplugins = false;
610  }
611 }
612 
614 {
616 }
617 
619 {
620  /* identifiers */
621  ot->name = "Text Auto Complete";
622  ot->description = "Show a list of used text in the open document";
623  ot->idname = "TEXT_OT_autocomplete";
624 
625  /* api callbacks */
630 
631  /* flags */
632  /* Undo is handled conditionally by this operator. */
634 }
635 
struct ScrArea * CTX_wm_area(const bContext *C)
Definition: context.c:714
struct SpaceText * CTX_wm_space_text(const bContext *C)
Definition: context.c:782
struct Text * CTX_data_edit_text(const bContext *C)
Definition: context.c:1306
struct ARegion * BKE_area_find_region_type(const struct ScrArea *area, int type)
void txt_move_left(struct Text *text, const bool sel)
Definition: text.c:905
void txt_move_right(struct Text *text, const bool sel)
Definition: text.c:949
int text_check_identifier_unicode(const unsigned int ch)
Definition: text.c:2470
void txt_insert_buf(struct Text *text, const char *in_buffer)
Definition: text.c:1647
int text_check_identifier_nodigit_unicode(const unsigned int ch)
Definition: text.c:2475
bool text_check_whitespace(const char ch)
Definition: text.c:2481
int text_find_identifier_start(const char *str, int i)
Definition: text.c:2489
short texttool_text_is_active(struct Text *text)
void texttool_text_clear(void)
SuggItem * texttool_suggest_last(void)
char * texttool_docs_get(void)
void texttool_suggest_select(SuggItem *sel)
void texttool_docs_clear(void)
void texttool_suggest_prefix(const char *prefix, const int prefix_len)
void texttool_suggest_add(const char *name, char type)
void texttool_text_set_active(struct Text *text)
SuggItem * texttool_suggest_selected(void)
void texttool_suggest_clear(void)
SuggItem * texttool_suggest_first(void)
int * texttool_suggest_top(void)
#define BLI_assert(a)
Definition: BLI_assert.h:58
#define ATTR_FALLTHROUGH
BLI_INLINE void * BLI_ghashIterator_getValue(GHashIterator *ghi) ATTR_WARN_UNUSED_RESULT
Definition: BLI_ghash.h:150
GHash * BLI_ghash_str_new(const char *info) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
#define GHASH_ITER(gh_iter_, ghash_)
Definition: BLI_ghash.h:169
void BLI_ghash_insert(GHash *gh, void *key, void *val)
Definition: BLI_ghash.c:756
void BLI_ghash_free(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
Definition: BLI_ghash.c:1008
void * BLI_ghash_lookup(GHash *gh, const void *key) ATTR_WARN_UNUSED_RESULT
Definition: BLI_ghash.c:803
char * BLI_strdupn(const char *str, const size_t len) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition: string.c:54
unsigned int BLI_str_utf8_as_unicode_and_size_safe(const char *__restrict p, size_t *__restrict index) ATTR_NONNULL()
Definition: string_utf8.c:566
unsigned int BLI_str_utf8_as_unicode(const char *p) ATTR_NONNULL()
Definition: string_utf8.c:533
#define STREQLEN(a, b, n)
#define UNUSED(x)
@ RGN_TYPE_WINDOW
@ OPERATOR_CANCELLED
@ OPERATOR_FINISHED
@ OPERATOR_RUNNING_MODAL
void ED_area_tag_redraw(ScrArea *area)
Definition: area.c:745
struct UndoStep * ED_text_undo_push_init(struct bContext *C)
Definition: text_undo.c:280
void ED_undo_push(struct bContext *C, const char *str)
Definition: ed_undo.c:117
_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 y
_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 top
Read Guarded memory(de)allocation.
#define C
Definition: RandGen.cpp:39
@ OPTYPE_BLOCKING
Definition: WM_types.h:157
#define KM_PRESS
Definition: WM_types.h:242
ATTR_WARN_UNUSED_RESULT const BMLoop * l
unsigned int U
Definition: btGjkEpa3.h:78
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
Definition: btQuadWord.h:119
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:41
static void area(int d1, int d2, int e1, int e2, float weights[2])
void * first
Definition: DNA_listBase.h:47
SpaceText_Runtime runtime
struct Text * text
struct SuggItem * prev
struct SuggItem * next
char(* format_identifier)(const char *string)
Definition: text_format.h:61
char * line
struct TextLine * prev
struct TextLine * next
ListBase lines
TextLine * curl
int curc
short ctrl
Definition: WM_types.h:618
short val
Definition: WM_types.h:579
int mval[2]
Definition: WM_types.h:583
short type
Definition: WM_types.h:577
int(* invoke)(struct bContext *, struct wmOperator *, const struct wmEvent *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:752
const char * name
Definition: WM_types.h:721
int(* modal)(struct bContext *, struct wmOperator *, const struct wmEvent *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:768
const char * idname
Definition: WM_types.h:723
bool(* poll)(struct bContext *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:776
void(* cancel)(struct bContext *, struct wmOperator *)
Definition: WM_types.h:760
const char * description
Definition: WM_types.h:726
struct wmOperatorType * type
void text_pop_suggest_list(void)
void TEXT_OT_autocomplete(wmOperatorType *ot)
bool text_do_suggest_select(SpaceText *st, ARegion *region, const int mval[2])
static int text_autocomplete_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
static void text_autocomplete_free(bContext *C, wmOperator *op)
static GHash * text_autocomplete_build(Text *text)
static int doc_scroll
static void confirm_suggestion(Text *text)
static int text_autocomplete_modal(bContext *C, wmOperator *op, const wmEvent *event)
static void get_suggest_prefix(Text *text, int offset)
static void text_autocomplete_cancel(bContext *C, wmOperator *op)
TextFormatType * ED_text_format_get(Text *text)
Definition: text_format.c:200
#define SUGG_LIST_WIDTH
Definition: text_intern.h:68
#define TOOL_DOCUMENT
Definition: text_intern.h:73
void text_update_line_edited(struct TextLine *line)
Definition: text_ops.c:232
#define TXT_LINE_HEIGHT(st)
Definition: text_intern.h:65
#define SUGG_LIST_SIZE
Definition: text_intern.h:67
bool text_space_edit_poll(struct bContext *C)
Definition: text_ops.c:187
#define TXT_BODY_LEFT(st)
Definition: text_intern.h:54
#define TOOL_SUGG_LIST
Definition: text_intern.h:72
void text_update_character_width(struct SpaceText *st)
uint len
wmEventHandler_Op * WM_event_add_modal_handler(bContext *C, wmOperator *op)
@ EVT_DOWNARROWKEY
@ WHEELUPMOUSE
@ EVT_PAGEUPKEY
@ EVT_PAGEDOWNKEY
@ EVT_RIGHTARROWKEY
@ EVT_PADENTER
@ WHEELDOWNMOUSE
@ MOUSEMOVE
@ EVT_UPARROWKEY
@ LEFTMOUSE
@ EVT_LEFTARROWKEY
@ EVT_ESCKEY
@ EVT_BACKSPACEKEY
@ EVT_RIGHTSHIFTKEY
@ EVT_LEFTSHIFTKEY
@ EVT_RETKEY
wmOperatorType * ot
Definition: wm_files.c:3156