Blender  V3.3
text_autocomplete.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
7 #include <ctype.h>
8 #include <string.h>
9 
10 #include "MEM_guardedalloc.h"
11 
12 #include "DNA_text_types.h"
13 
14 #include "BLI_blenlib.h"
15 #include "BLI_ghash.h"
16 
17 #include "BKE_context.h"
18 #include "BKE_screen.h"
19 #include "BKE_text.h"
20 #include "BKE_text_suggestions.h"
21 
22 #include "WM_api.h"
23 #include "WM_types.h"
24 
25 #include "ED_screen.h"
26 #include "ED_text.h"
27 #include "ED_undo.h"
28 
29 #include "UI_interface.h"
30 
31 #include "text_format.h"
32 #include "text_intern.h" /* own include */
33 
34 /* -------------------------------------------------------------------- */
38 bool text_do_suggest_select(SpaceText *st, ARegion *region, const int mval[2])
39 {
40  const int lheight = TXT_LINE_HEIGHT(st);
41  SuggItem *item, *first, *last /* , *sel */ /* UNUSED */;
42  TextLine *tmp;
43  int l, x, y, w, h, i;
44  int tgti, *top;
45 
46  if (!st->text) {
47  return 0;
48  }
49  if (!texttool_text_is_active(st->text)) {
50  return 0;
51  }
52 
53  first = texttool_suggest_first();
54  last = texttool_suggest_last();
55  /* sel = texttool_suggest_selected(); */ /* UNUSED */
57 
58  if (!last || !first) {
59  return 0;
60  }
61 
62  /* Count the visible lines to the cursor */
63  for (tmp = st->text->curl, l = -st->top; tmp; tmp = tmp->prev, l++) {
64  /* pass */
65  }
66  if (l < 0) {
67  return 0;
68  }
69 
71 
72  x = TXT_BODY_LEFT(st) + (st->runtime.cwidth_px * (st->text->curc - st->left));
73  y = region->winy - lheight * l - 2;
74 
75  w = SUGG_LIST_WIDTH * st->runtime.cwidth_px + U.widget_unit;
76  h = SUGG_LIST_SIZE * lheight + 0.4f * U.widget_unit;
77 
78  if (mval[0] < x || x + w < mval[0] || mval[1] < y - h || y < mval[1]) {
79  return 0;
80  }
81 
82  /* Work out which of the items is at the top of the visible list */
83  for (i = 0, item = first; i < *top && item->next; i++, item = item->next) {
84  /* pass */
85  }
86 
87  /* Work out the target item index in the visible list */
88  tgti = (y - mval[1] - 4) / lheight;
89  if (tgti < 0 || tgti > SUGG_LIST_SIZE) {
90  return 1;
91  }
92 
93  for (i = tgti; i > 0 && item->next; i--, item = item->next) {
94  /* pass */
95  }
96  if (item) {
98  }
99  return 1;
100 }
101 
103 {
104  SuggItem *item, *sel;
105  int *top, i;
106 
107  item = texttool_suggest_first();
110 
111  i = 0;
112  while (item && item != sel) {
113  item = item->next;
114  i++;
115  }
116  if (i > *top + SUGG_LIST_SIZE - 1) {
117  *top = i - SUGG_LIST_SIZE + 1;
118  }
119  else if (i < *top) {
120  *top = i;
121  }
122 }
123 
126 /* -------------------------------------------------------------------- */
130 static void text_autocomplete_free(bContext *C, wmOperator *op);
131 
133 {
134  GHash *gh;
135  int seek_len = 0;
136  const char *seek;
138 
140 
141  /* first get the word we're at */
142  {
143  const int i = text_find_identifier_start(text->curl->line, text->curc);
144  seek_len = text->curc - i;
145  seek = text->curl->line + i;
146 
147  // BLI_strncpy(seek, seek_ptr, seek_len);
148  }
149 
150  /* now walk over entire doc and suggest words */
151  {
152  TextLine *linep;
153 
154  gh = BLI_ghash_str_new(__func__);
155 
156  for (linep = text->lines.first; linep; linep = linep->next) {
157  size_t i_start = 0;
158  size_t i_end = 0;
159  size_t i_pos = 0;
160 
161  while (i_start < linep->len) {
162  /* seek identifier beginning */
163  i_pos = i_start;
164  while ((i_start < linep->len) &&
166  BLI_str_utf8_as_unicode_step(linep->line, linep->len, &i_pos)))) {
167  i_start = i_pos;
168  }
169  i_pos = i_end = i_start;
171  linep->line, linep->len, &i_pos)))) {
172  i_end = i_pos;
173  }
174 
175  if ((i_start != i_end) &&
176  /* Check we're at the beginning of a line or that the previous char is not an
177  * identifier this prevents digits from being added. */
178  ((i_start < 1) ||
180  char *str_sub = &linep->line[i_start];
181  const int choice_len = i_end - i_start;
182 
183  if ((choice_len > seek_len) && (seek_len == 0 || STREQLEN(seek, str_sub, seek_len)) &&
184  (seek != str_sub)) {
185  // printf("Adding: %s\n", s);
186  char str_sub_last = str_sub[choice_len];
187  str_sub[choice_len] = '\0';
188  if (!BLI_ghash_lookup(gh, str_sub)) {
189  char *str_dup = BLI_strdupn(str_sub, choice_len);
190  /* A 'set' would make more sense here */
191  BLI_ghash_insert(gh, str_dup, str_dup);
192  }
193  str_sub[choice_len] = str_sub_last;
194  }
195  }
196  if (i_end != i_start) {
197  i_start = i_end;
198  }
199  else {
200  /* highly unlikely, but prevent eternal loop */
201  i_start++;
202  }
203  }
204  }
205 
206  {
207  GHashIterator gh_iter;
208 
209  /* get the formatter for highlighting */
210  TextFormatType *tft;
211  tft = ED_text_format_get(text);
212 
213  GHASH_ITER (gh_iter, gh) {
214  const char *s = BLI_ghashIterator_getValue(&gh_iter);
216  }
217  }
218  }
219 
220  texttool_suggest_prefix(seek, seek_len);
221 
222  return gh;
223 }
224 
225 /* -- */
226 
227 static void get_suggest_prefix(Text *text, int offset)
228 {
229  int i, len;
230  const char *line;
231 
232  if (!text) {
233  return;
234  }
235  if (!texttool_text_is_active(text)) {
236  return;
237  }
238 
239  line = text->curl->line;
240  i = text_find_identifier_start(line, text->curc + offset);
241  len = text->curc - i + offset;
242  texttool_suggest_prefix(line + i, len);
243 }
244 
245 static void confirm_suggestion(Text *text)
246 {
247  SuggItem *sel;
248  int i, over = 0;
249  const char *line;
250 
251  if (!text) {
252  return;
253  }
254  if (!texttool_text_is_active(text)) {
255  return;
256  }
257 
259  if (!sel) {
260  return;
261  }
262 
263  line = text->curl->line;
264  i = text_find_identifier_start(line, text->curc /* - skipleft */);
265  over = text->curc - i;
266 
267  // for (i = 0; i < skipleft; i++)
268  // txt_move_left(text, 0);
269  BLI_assert(memcmp(sel->name, &line[i], over) == 0);
270  const char *buf = sel->name + over;
271  txt_insert_buf(text, buf, strlen(buf));
272 
273  // for (i = 0; i < skipleft; i++)
274  // txt_move_right(text, 0);
275 
277 }
278 
281 /* -------------------------------------------------------------------- */
285 static int text_autocomplete_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
286 {
288  Text *text = CTX_data_edit_text(C);
289 
290  st->doplugins = true;
292 
293  if (texttool_suggest_first()) {
294 
296 
299  confirm_suggestion(st->text);
300  text_update_line_edited(st->text->curl);
302  ED_undo_push(C, op->type->name);
303  return OPERATOR_FINISHED;
304  }
305 
307  return OPERATOR_RUNNING_MODAL;
308  }
310  return OPERATOR_CANCELLED;
311 }
312 
313 static int doc_scroll = 0;
314 
315 static int text_autocomplete_modal(bContext *C, wmOperator *op, const wmEvent *event)
316 {
317  /* NOTE(campbell): this code could be refactored or rewritten. */
321 
322  int draw = 0, tools = 0, swallow = 0, scroll = 1;
323  int retval = OPERATOR_RUNNING_MODAL;
324 
325  if (st->doplugins && texttool_text_is_active(st->text)) {
326  if (texttool_suggest_first()) {
327  tools |= TOOL_SUGG_LIST;
328  }
329  if (texttool_docs_get()) {
330  tools |= TOOL_DOCUMENT;
331  }
332  }
333 
334  switch (event->type) {
335  case MOUSEMOVE: {
336  if (text_do_suggest_select(st, region, event->mval)) {
337  draw = 1;
338  }
339  swallow = 1;
340  break;
341  }
342  case LEFTMOUSE:
343  if (event->val == KM_PRESS) {
344  if (text_do_suggest_select(st, region, event->mval)) {
345  if (tools & TOOL_SUGG_LIST) {
347  confirm_suggestion(st->text);
348  text_update_line_edited(st->text->curl);
349  ED_undo_push(C, op->type->name);
350  swallow = 1;
351  draw = 1;
352  }
353  if (tools & TOOL_DOCUMENT) {
355  doc_scroll = 0;
356  draw = 1;
357  }
358  retval = OPERATOR_FINISHED;
359  }
360  else {
361  if (tools & TOOL_SUGG_LIST) {
363  }
364  if (tools & TOOL_DOCUMENT) {
366  doc_scroll = 0;
367  }
368  retval = OPERATOR_CANCELLED;
369  }
370  draw = 1;
371  }
372  break;
373  case EVT_ESCKEY:
374  if (event->val == KM_PRESS) {
375  draw = swallow = 1;
376  if (tools & TOOL_SUGG_LIST) {
378  }
379  else if (tools & TOOL_DOCUMENT) {
381  doc_scroll = 0;
382  }
383  else {
384  draw = swallow = 0;
385  }
386  retval = OPERATOR_CANCELLED;
387  }
388  break;
389  case EVT_RETKEY:
390  case EVT_PADENTER:
391  if (event->val == KM_PRESS) {
392  if (tools & TOOL_SUGG_LIST) {
394  confirm_suggestion(st->text);
395  text_update_line_edited(st->text->curl);
396  ED_undo_push(C, op->type->name);
397  swallow = 1;
398  draw = 1;
399  }
400  if (tools & TOOL_DOCUMENT) {
402  doc_scroll = 0;
403  draw = 1;
404  }
405  retval = OPERATOR_FINISHED;
406  }
407  break;
408  case EVT_LEFTARROWKEY:
409  case EVT_BACKSPACEKEY:
410  if (event->val == KM_PRESS) {
411  if (tools & TOOL_SUGG_LIST) {
412  if (event->modifier & KM_CTRL) {
414  retval = OPERATOR_CANCELLED;
415  draw = 1;
416  }
417  else {
418  /* Work out which char we are about to delete/pass */
419  if (st->text->curl && st->text->curc > 0) {
420  char ch = st->text->curl->line[st->text->curc - 1];
421  if ((ch == '_' || !ispunct(ch)) && !text_check_whitespace(ch)) {
422  get_suggest_prefix(st->text, -1);
424  txt_move_left(st->text, false);
425  draw = 1;
426  }
427  else {
429  retval = OPERATOR_CANCELLED;
430  draw = 1;
431  }
432  }
433  else {
435  retval = OPERATOR_CANCELLED;
436  draw = 1;
437  }
438  }
439  }
440  if (tools & TOOL_DOCUMENT) {
442  doc_scroll = 0;
443  }
444  }
445  break;
446  case EVT_RIGHTARROWKEY:
447  if (event->val == KM_PRESS) {
448  if (tools & TOOL_SUGG_LIST) {
449  if (event->modifier & KM_CTRL) {
451  retval = OPERATOR_CANCELLED;
452  draw = 1;
453  }
454  else {
455  /* Work out which char we are about to pass */
456  if (st->text->curl && st->text->curc < st->text->curl->len) {
457  char ch = st->text->curl->line[st->text->curc];
458  if ((ch == '_' || !ispunct(ch)) && !text_check_whitespace(ch)) {
459  get_suggest_prefix(st->text, 1);
461  txt_move_right(st->text, false);
462  draw = 1;
463  }
464  else {
466  retval = OPERATOR_CANCELLED;
467  draw = 1;
468  }
469  }
470  else {
472  retval = OPERATOR_CANCELLED;
473  draw = 1;
474  }
475  }
476  }
477  if (tools & TOOL_DOCUMENT) {
479  doc_scroll = 0;
480  }
481  }
482  break;
483  case EVT_PAGEDOWNKEY:
484  scroll = SUGG_LIST_SIZE - 1;
486  case WHEELDOWNMOUSE:
487  case EVT_DOWNARROWKEY:
488  if (event->val == KM_PRESS) {
489  if (tools & TOOL_DOCUMENT) {
490  doc_scroll++;
491  swallow = 1;
492  draw = 1;
493  }
494  else if (tools & TOOL_SUGG_LIST) {
496  if (!sel) {
498  }
499  else {
500  while (sel && scroll--) {
501  if (sel != texttool_suggest_last() && sel->next) {
503  sel = sel->next;
504  }
505  else {
507  sel = texttool_suggest_first();
508  }
509  }
510  }
512  swallow = 1;
513  draw = 1;
514  }
515  }
516  break;
517  case EVT_PAGEUPKEY:
518  scroll = SUGG_LIST_SIZE - 1;
520  case WHEELUPMOUSE:
521  case EVT_UPARROWKEY:
522  if (event->val == KM_PRESS) {
523  if (tools & TOOL_DOCUMENT) {
524  if (doc_scroll > 0) {
525  doc_scroll--;
526  }
527  swallow = 1;
528  draw = 1;
529  }
530  else if (tools & TOOL_SUGG_LIST) {
532  while (sel && scroll--) {
533  if (sel != texttool_suggest_first() && sel->prev) {
535  sel = sel->prev;
536  }
537  else {
539  sel = texttool_suggest_last();
540  }
541  }
543  swallow = 1;
544  draw = 1;
545  }
546  }
547  break;
548  case EVT_RIGHTSHIFTKEY:
549  case EVT_LEFTSHIFTKEY:
550  break;
551 #if 0
552  default:
553  if (tools & TOOL_SUGG_LIST) {
555  draw = 1;
556  }
557  if (tools & TOOL_DOCUMENT) {
559  doc_scroll = 0;
560  draw = 1;
561  }
562 #endif
563  }
564 
565  if (draw) {
567  }
568 
569  // if (swallow) {
570  // retval = OPERATOR_RUNNING_MODAL;
571  // }
572 
573  if (texttool_suggest_first()) {
574  if (retval != OPERATOR_RUNNING_MODAL) {
576  }
577  return retval;
578  }
580  return OPERATOR_FINISHED;
581 }
582 
584 {
585  GHash *gh = op->customdata;
586  if (gh) {
588  op->customdata = NULL;
589  }
590 
591  /* other stuff */
592  {
594  st->doplugins = false;
596  }
597 }
598 
600 {
602 }
603 
605 {
606  /* identifiers */
607  ot->name = "Text Auto Complete";
608  ot->description = "Show a list of used text in the open document";
609  ot->idname = "TEXT_OT_autocomplete";
610 
611  /* api callbacks */
616 
617  /* flags */
618  /* Undo is handled conditionally by this operator. */
620 }
621 
struct ScrArea * CTX_wm_area(const bContext *C)
Definition: context.c:738
struct SpaceText * CTX_wm_space_text(const bContext *C)
Definition: context.c:806
struct Text * CTX_data_edit_text(const bContext *C)
Definition: context.c:1380
struct ARegion * BKE_area_find_region_type(const struct ScrArea *area, int type)
int text_check_identifier_unicode(unsigned int ch)
Definition: text.c:2364
void txt_move_left(struct Text *text, bool sel)
Definition: text.c:865
void txt_move_right(struct Text *text, bool sel)
Definition: text.c:909
int text_check_identifier_nodigit_unicode(unsigned int ch)
Definition: text.c:2369
bool text_check_whitespace(char ch)
Definition: text.c:2375
void txt_insert_buf(struct Text *text, const char *in_buffer, int in_buffer_len) ATTR_NONNULL(1
int text_find_identifier_start(const char *str, int i)
Definition: text.c:2383
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_prefix(const char *prefix, int prefix_len)
void texttool_suggest_select(SuggItem *sel)
void texttool_docs_clear(void)
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:46
#define ATTR_FALLTHROUGH
BLI_INLINE void * BLI_ghashIterator_getValue(GHashIterator *ghi) ATTR_WARN_UNUSED_RESULT
Definition: BLI_ghash.h:302
GHash * BLI_ghash_str_new(const char *info) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
#define GHASH_ITER(gh_iter_, ghash_)
Definition: BLI_ghash.h:321
void * BLI_ghash_lookup(const GHash *gh, const void *key) ATTR_WARN_UNUSED_RESULT
Definition: BLI_ghash.c:734
void BLI_ghash_insert(GHash *gh, void *key, void *val)
Definition: BLI_ghash.c:710
void BLI_ghash_free(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
Definition: BLI_ghash.c:863
char * BLI_strdupn(const char *str, size_t len) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition: string.c:33
unsigned int BLI_str_utf8_as_unicode(const char *p) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition: string_utf8.c:478
unsigned int BLI_str_utf8_as_unicode_step(const char *__restrict p, size_t p_len, size_t *__restrict index) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1
#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:729
struct UndoStep * ED_text_undo_push_init(struct bContext *C)
Definition: text_undo.c:263
void ED_undo_push(struct bContext *C, const char *str)
Definition: ed_undo.c:100
_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:25
@ KM_PRESS
Definition: WM_types.h:267
@ OPTYPE_BLOCKING
Definition: WM_types.h:150
@ KM_CTRL
Definition: WM_types.h:239
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
int len
Definition: draw_manager.c:108
ccl_gpu_kernel_postfix ccl_global float int int int int float bool int offset
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:27
static void area(int d1, int d2, int e1, int e2, float weights[2])
static const pxr::TfToken st("st", pxr::TfToken::Immortal)
void * first
Definition: DNA_listBase.h:31
struct SuggItem * prev
struct SuggItem * next
char(* format_identifier)(const char *string)
Definition: text_format.h:64
char * line
struct TextLine * prev
struct TextLine * next
ListBase lines
TextLine * curl
int curc
short val
Definition: WM_types.h:680
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
const char * description
Definition: WM_types.h:893
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:172
#define SUGG_LIST_WIDTH
Definition: text_intern.h:56
#define TOOL_DOCUMENT
Definition: text_intern.h:61
void text_update_line_edited(struct TextLine *line)
Definition: text_ops.c:243
#define TXT_LINE_HEIGHT(st)
Definition: text_intern.h:53
#define SUGG_LIST_SIZE
Definition: text_intern.h:55
bool text_space_edit_poll(struct bContext *C)
Definition: text_ops.c:198
#define TXT_BODY_LEFT(st)
Definition: text_intern.h:42
#define TOOL_SUGG_LIST
Definition: text_intern.h:60
void text_update_character_width(struct SpaceText *st)
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:3479