Пример #1
0
UString*
ustring_dup(const UString* str)
{
    UString* dup;
    dup = ustring_new();
    ustring_append(dup, str);
    return dup;
}
Пример #2
0
static void
ibus_hangul_engine_init (IBusHangulEngine *hangul)
{
    IBusProperty* prop;
    IBusText* label;
    IBusText* tooltip;

    hangul->context = hangul_ic_new (hangul_keyboard->str);
    hangul_ic_connect_callback (hangul->context, "transition",
                                ibus_hangul_engine_on_transition, hangul);

    hangul->preedit = ustring_new();
    hangul->hanja_list = NULL;
    hangul->hangul_mode = TRUE;
    hangul->hanja_mode = FALSE;
    hangul->last_lookup_method = LOOKUP_METHOD_PREFIX;

    hangul->prop_list = ibus_prop_list_new ();
    g_object_ref_sink (hangul->prop_list);

    label = ibus_text_new_from_string (_("Hanja lock"));
    tooltip = ibus_text_new_from_string (_("Enable/Disable Hanja mode"));
    prop = ibus_property_new ("hanja_mode",
                              PROP_TYPE_TOGGLE,
                              label,
                              NULL,
                              tooltip,
                              TRUE, TRUE, PROP_STATE_UNCHECKED, NULL);
    g_object_ref_sink (prop);
    ibus_prop_list_append (hangul->prop_list, prop);
    hangul->prop_hanja_mode = prop;

    label = ibus_text_new_from_string (_("Setup"));
    tooltip = ibus_text_new_from_string (_("Configure hangul engine"));
    prop = ibus_property_new ("setup",
                              PROP_TYPE_NORMAL,
                              label,
                              "gtk-preferences",
                              tooltip,
                              TRUE, TRUE, PROP_STATE_UNCHECKED, NULL);
    ibus_prop_list_append (hangul->prop_list, prop);

    hangul->table = ibus_lookup_table_new (9, 0, TRUE, FALSE);
    g_object_ref_sink (hangul->table);

    g_signal_connect (config, "value-changed",
                      G_CALLBACK(ibus_config_value_changed), hangul);
}
Пример #3
0
Файл: bin.c Проект: julp/ugrep
static void *engine_bin_compile(error_t **error, UString *ustr, uint32_t flags)
{
    UErrorCode status;
    bin_pattern_t *p;

    p = mem_new(*p);
    p->pattern = ustr;
    p->flags = flags;
    p->ubrk = NULL;
    p->tmp = NULL;
    status = U_ZERO_ERROR;
    if (ustring_empty(ustr)) {
        if (IS_WORD_BOUNDED(flags)) {
            p->ubrk = ubrk_open(UBRK_WORD, NULL, NULL, 0, &status);
        }
    } else {
        /**
         * Whole line matches are simplified:
         * 1) we don't need to check graphemes boundaries,
         * 2) case insensitivity is done directly by the whole_line_match callback
         **/
        if (!IS_WHOLE_LINE(flags)) {
            if (IS_WORD_BOUNDED(flags)) {
                p->ubrk = ubrk_open(UBRK_WORD, NULL, NULL, 0, &status);
            } else if (WITH_GRAPHEME()) {
                p->ubrk = ubrk_open(UBRK_CHARACTER, NULL, NULL, 0, &status);
            }
            if (U_FAILURE(status)) {
                bin_pattern_destroy(p);
                icu_error_set(error, FATAL, status, "ubrk_open");
                return NULL;
            }
            if (IS_CASE_INSENSITIVE(flags)) {
                p->tmp = ustring_new();
                p->pattern = ustring_sized_new(ustr->len);
                if (!ustring_fullcase(p->pattern, ustr->ptr, ustr->len, UCASE_FOLD, error)) {
                    bin_pattern_destroy(p);
                    return NULL;
                }
                ustring_destroy(ustr); /* no more needed, throw (free) it now */
            }
        }
    }

    return p;
}