static strCursorDelimType cursor_delim_type_utf8(const char *ch_utf8) { /* for full unicode support we really need to have large lookup tables to figure * out whats what in every possible char set - and python, glib both have these. */ unsigned int uch = BLI_str_utf8_as_unicode(ch_utf8); return cursor_delim_type_unicode(uch); }
static strCursorDelimType cursor_delim_type(const char *ch_utf8) { /* for full unicode support we really need to have large lookup tables to figure * out whats what in every possible char set - and python, glib both have these. */ unsigned int uch = BLI_str_utf8_as_unicode(ch_utf8); switch (uch) { case ',': case '.': return STRCUR_DELIM_PUNCT; case '{': case '}': case '[': case ']': case '(': case ')': return STRCUR_DELIM_BRACE; case '+': case '-': case '=': case '~': case '%': case '/': case '<': case '>': case '^': case '*': case '&': case '|': return STRCUR_DELIM_OPERATOR; case '\'': case '\"': return STRCUR_DELIM_QUOTE; case ' ': case '\t': return STRCUR_DELIM_WHITESPACE; case '\\': case '@': case '#': case '$': case ':': case ';': case '?': case '!': case 0xA3: /* pound */ case 0x80: /* euro */ /* case '_': *//* special case, for python */ return STRCUR_DELIM_OTHER; default: break; } return STRCUR_DELIM_ALPHANUMERIC; /* Not quite true, but ok for now */ }
bool GPG_Application::handleKey(GHOST_IEvent* event, bool isDown) { bool handled = false; MT_assert(event); if (m_keyboard) { GHOST_TEventDataPtr eventData = ((GHOST_IEvent*)event)->getData(); GHOST_TEventKeyData* keyData = static_cast<GHOST_TEventKeyData*>(eventData); unsigned int unicode = keyData->utf8_buf[0] ? BLI_str_utf8_as_unicode(keyData->utf8_buf) : keyData->ascii; if (m_keyboard->ToNative(keyData->key) == KX_KetsjiEngine::GetExitKey() && !m_keyboard->m_hookesc && !m_isEmbedded) { m_exitRequested = KX_EXIT_REQUEST_OUTSIDE; } m_keyboard->ConvertEvent(keyData->key, isDown, unicode); handled = true; } return handled; }
static int BL_KetsjiNextFrame(KX_KetsjiEngine *ketsjiengine, bContext *C, wmWindow *win, Scene *scene, ARegion *ar, KX_BlenderKeyboardDevice* keyboarddevice, KX_BlenderMouseDevice* mousedevice, int draw_letterbox) { int exitrequested; // first check if we want to exit exitrequested = ketsjiengine->GetExitCode(); // kick the engine bool render = ketsjiengine->NextFrame(); if (render) { if (draw_letterbox) { // Clear screen to border color // We do this here since we set the canvas to be within the frames. This means the engine // itself is unaware of the extra space, so we clear the whole region for it. glClearColor(scene->gm.framing.col[0], scene->gm.framing.col[1], scene->gm.framing.col[2], 1.0f); glViewport(ar->winrct.xmin, ar->winrct.ymin, BLI_rcti_size_x(&ar->winrct), BLI_rcti_size_y(&ar->winrct)); glClear(GL_COLOR_BUFFER_BIT); } // render the frame ketsjiengine->Render(); } wm_window_process_events_nosleep(); // test for the ESC key //XXX while (qtest()) while (wmEvent *event= (wmEvent *)win->queue.first) { short val = 0; //unsigned short event = 0; //XXX extern_qread(&val); unsigned int unicode = event->utf8_buf[0] ? BLI_str_utf8_as_unicode(event->utf8_buf) : event->ascii; if (keyboarddevice->ConvertBlenderEvent(event->type, event->val, unicode)) exitrequested = KX_EXIT_REQUEST_BLENDER_ESC; /* Coordinate conversion... where * should this really be? */ if (event->type == MOUSEMOVE) { /* Note, not nice! XXX 2.5 event hack */ val = event->x - ar->winrct.xmin; mousedevice->ConvertBlenderEvent(MOUSEX, val, 0); val = ar->winy - (event->y - ar->winrct.ymin) - 1; mousedevice->ConvertBlenderEvent(MOUSEY, val, 0); } else { mousedevice->ConvertBlenderEvent(event->type, event->val, 0); } BLI_remlink(&win->queue, event); wm_event_free(event); } if (win != CTX_wm_window(C)) { exitrequested= KX_EXIT_REQUEST_OUTSIDE; /* window closed while bge runs */ } return exitrequested; }
static GHash *text_autocomplete_build(Text *text) { GHash *gh; int seek_len = 0; const char *seek; texttool_text_clear(); texttool_text_set_active(text); /* first get the word we're at */ { const int i = text_find_identifier_start(text->curl->line, text->curc); seek_len = text->curc - i; seek = text->curl->line + i; // BLI_strncpy(seek, seek_ptr, seek_len); } /* now walk over entire doc and suggest words */ { TextLine *linep; gh = BLI_ghash_str_new(__func__); for (linep = text->lines.first; linep; linep = linep->next) { size_t i_start = 0; size_t i_end = 0; size_t i_pos = 0; while (i_start < linep->len) { /* seek identifier beginning */ i_pos = i_start; while ((i_start < linep->len) && (!text_check_identifier_nodigit_unicode(BLI_str_utf8_as_unicode_and_size_safe(&linep->line[i_start], &i_pos)))) { i_start = i_pos; } i_pos = i_end = i_start; while ((i_end < linep->len) && (text_check_identifier_unicode(BLI_str_utf8_as_unicode_and_size_safe(&linep->line[i_end], &i_pos)))) { i_end = i_pos; } if ((i_start != i_end) && /* check we're at the beginning of a line or that the previous char is not an identifier * this prevents digits from being added */ ((i_start < 1) || !text_check_identifier_unicode(BLI_str_utf8_as_unicode(&linep->line[i_start - 1])))) { char *str_sub = &linep->line[i_start]; const int choice_len = i_end - i_start; if ((choice_len > seek_len) && (seek_len == 0 || STREQLEN(seek, str_sub, seek_len)) && (seek != str_sub)) { // printf("Adding: %s\n", s); char str_sub_last = str_sub[choice_len]; str_sub[choice_len] = '\0'; if (!BLI_ghash_lookup(gh, str_sub)) { char *str_dup = BLI_strdupn(str_sub, choice_len); BLI_ghash_insert(gh, str_dup, str_dup); /* A 'set' would make more sense here */ } str_sub[choice_len] = str_sub_last; } } if (i_end != i_start) { i_start = i_end; } else { /* highly unlikely, but prevent eternal loop */ i_start++; } } } { GHashIterator gh_iter; /* get the formatter for highlighting */ TextFormatType *tft; tft = ED_text_format_get(text); GHASH_ITER (gh_iter, gh) { const char *s = BLI_ghashIterator_getValue(&gh_iter); texttool_suggest_add(s, tft->format_identifier(s)); } } } texttool_suggest_prefix(seek, seek_len); return gh; }
void DEV_EventConsumer::HandleKeyEvent(GHOST_TEventDataPtr data, bool down) { GHOST_TEventKeyData *keyData = (GHOST_TEventKeyData *)data; unsigned int unicode = keyData->utf8_buf[0] ? BLI_str_utf8_as_unicode(keyData->utf8_buf) : keyData->ascii; m_device->ConvertKeyEvent(keyData->key, down, unicode); }