Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_text/text_autocomplete.c
| Show All 24 Lines | |||||
| #include "DNA_text_types.h" | #include "DNA_text_types.h" | ||||
| #include "BLI_blenlib.h" | #include "BLI_blenlib.h" | ||||
| #include "BLI_ghash.h" | #include "BLI_ghash.h" | ||||
| #include "BKE_context.h" | #include "BKE_context.h" | ||||
| #include "BKE_text.h" | #include "BKE_text.h" | ||||
| #include "BKE_text_suggestions.h" | |||||
| #include "BKE_screen.h" | #include "BKE_screen.h" | ||||
| #include "BKE_suggestions.h" | |||||
| #include "WM_api.h" | #include "WM_api.h" | ||||
| #include "WM_types.h" | #include "WM_types.h" | ||||
| #include "ED_text.h" | #include "ED_text.h" | ||||
| #include "ED_undo.h" | #include "ED_undo.h" | ||||
| #include "ED_screen.h" | #include "ED_screen.h" | ||||
| #include "UI_interface.h" | #include "UI_interface.h" | ||||
| #include "text_format.h" | #include "text_format.h" | ||||
| #include "text_intern.h" /* own include */ | #include "text_intern.h" /* own include */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /* Public API */ | /** \name Public API | ||||
| * \{ */ | |||||
| int text_do_suggest_select(SpaceText *st, ARegion *ar) | int text_do_suggest_select(SpaceText *st, ARegion *ar) | ||||
| { | { | ||||
| SuggItem *item, *first, *last /* , *sel */ /* UNUSED */; | SuggItem *item, *first, *last /* , *sel */ /* UNUSED */; | ||||
| TextLine *tmp; | TextLine *tmp; | ||||
| int l, x, y, w, h, i; | int l, x, y, w, h, i; | ||||
| int tgti, *top; | int tgti, *top; | ||||
| int mval[2] = {0, 0}; | int mval[2] = {0, 0}; | ||||
| ▲ Show 20 Lines • Show All 73 Lines • ▼ Show 20 Lines | void text_pop_suggest_list(void) | ||||
| if (i > *top + SUGG_LIST_SIZE - 1) { | if (i > *top + SUGG_LIST_SIZE - 1) { | ||||
| *top = i - SUGG_LIST_SIZE + 1; | *top = i - SUGG_LIST_SIZE + 1; | ||||
| } | } | ||||
| else if (i < *top) { | else if (i < *top) { | ||||
| *top = i; | *top = i; | ||||
| } | } | ||||
| } | } | ||||
| /** \} */ | |||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /* Private API */ | /** \name Private API | ||||
| * \{ */ | |||||
| static void text_autocomplete_free(bContext *C, wmOperator *op); | static void text_autocomplete_free(bContext *C, wmOperator *op); | ||||
| static GHash *text_autocomplete_build(Text *text) | static GHash *text_autocomplete_build(Text *text) | ||||
| { | { | ||||
| GHash *gh; | GHash *gh; | ||||
| int seek_len = 0; | int seek_len = 0; | ||||
| const char *seek; | const char *seek; | ||||
| ▲ Show 20 Lines • Show All 134 Lines • ▼ Show 20 Lines | static void confirm_suggestion(Text *text) | ||||
| txt_insert_buf(text, sel->name + over); | txt_insert_buf(text, sel->name + over); | ||||
| // for (i = 0; i < skipleft; i++) | // for (i = 0; i < skipleft; i++) | ||||
| // txt_move_right(text, 0); | // txt_move_right(text, 0); | ||||
| texttool_text_clear(); | texttool_text_clear(); | ||||
| } | } | ||||
| /* -- */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | |||||
| /** \name Auto Complete Operator | |||||
| * | |||||
| * \{ */ | |||||
| static int text_autocomplete_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) | static int text_autocomplete_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) | ||||
| { | { | ||||
| SpaceText *st = CTX_wm_space_text(C); | SpaceText *st = CTX_wm_space_text(C); | ||||
| Text *text = CTX_data_edit_text(C); | Text *text = CTX_data_edit_text(C); | ||||
| st->doplugins = true; | st->doplugins = true; | ||||
| op->customdata = text_autocomplete_build(text); | op->customdata = text_autocomplete_build(text); | ||||
| ▲ Show 20 Lines • Show All 320 Lines • ▼ Show 20 Lines | void TEXT_OT_autocomplete(wmOperatorType *ot) | ||||
| ot->cancel = text_autocomplete_cancel; | ot->cancel = text_autocomplete_cancel; | ||||
| ot->modal = text_autocomplete_modal; | ot->modal = text_autocomplete_modal; | ||||
| ot->poll = text_space_edit_poll; | ot->poll = text_space_edit_poll; | ||||
| /* flags */ | /* flags */ | ||||
| /* Undo is handled conditionally by this operator. */ | /* Undo is handled conditionally by this operator. */ | ||||
| ot->flag = OPTYPE_BLOCKING; | ot->flag = OPTYPE_BLOCKING; | ||||
| } | } | ||||
| /** \} */ | |||||