File: testmessage.c

package info (click to toggle)
fcitx 1%3A4.2.9.9-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 19,800 kB
  • sloc: ansic: 134,151; cpp: 7,280; sh: 2,778; python: 800; xml: 345; makefile: 42
file content (52 lines) | stat: -rw-r--r-- 1,777 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include <assert.h>
#include "fcitx/instance.h"
#include "fcitx/candidate.h"
#include "fcitx/instance-internal.h"
#include "fcitx/ime-internal.h"

int main()
{
    char* words[] = { "a", "b", "c" , "d", "e" };
    char* extras[] = { "A", "B", "C" , "D", "E" };
    FcitxCandidateWordList* candList = FcitxCandidateWordNewList();
    FcitxInstance* instance = fcitx_utils_malloc0(sizeof(FcitxInstance));
    instance->input = fcitx_utils_malloc0(sizeof(FcitxInputState));
    instance->input->candList = FcitxCandidateWordNewList();
    instance->config = fcitx_utils_malloc0(sizeof(FcitxGlobalConfig));
    instance->config->bPointAfterNumber = true;
    FcitxCandidateWord word;
    word.callback = NULL;
    word.owner = NULL;
    word.priv = NULL;
    int i = 0;
    for (i = 0; i < 5; i ++) {
        word.strWord = strdup(words[i]);
        word.strExtra = strdup(extras[i]);
        FcitxCandidateWordAppend(instance->input->candList, &word);
    }
    for (i = 0; i < 4; i ++) {
        word.strWord = strdup(words[i]);
        word.strExtra = strdup(extras[i]);
        FcitxCandidateWordAppend(candList, &word);
    }

    char* result = FcitxUICandidateWordToCString(instance);
    assert (strcmp(result, "1.aA 2.bB 3.cC 4.dD 5.eE ") == 0);
    free(result);

    FcitxCandidateWordSetPageSize(instance->input->candList, 10);
    FcitxCandidateWordMerge(instance->input->candList, candList, 2);
    result = FcitxUICandidateWordToCString(instance);
    assert (strcmp(result, "1.aA 2.bB 3.aA 4.bB 5.cC 6.dD "
                   "7.cC 8.dD 9.eE ") == 0);
    free(result);

    FcitxCandidateWordFreeList(instance->input->candList);
    FcitxCandidateWordFreeList(candList);
    free(instance->config);
    free(instance->input);
    free(instance);


    return 0;
}