mirror of
https://github.com/glfw/glfw.git
synced 2025-06-15 12:12:16 +00:00
Apply shibukawa's fix of tests/events
This fix is based on shibukawa's fix:
https://github.com/glfw/glfw/pull/658
d36a164423
This code doesn't work because `get_character_string` is undefined.
We need further work.
This commit is contained in:
parent
59e192be6d
commit
3386299e1f
@ -454,6 +454,45 @@ static void char_callback(GLFWwindow* window, unsigned int codepoint)
|
|||||||
counter++, slot->number, glfwGetTime(), codepoint, string);
|
counter++, slot->number, glfwGetTime(), codepoint, string);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void preedit_callback(GLFWwindow* window, int strLength, unsigned int* string, int blockLength, int* blocks, int focusedBlock) {
|
||||||
|
Slot* slot = glfwGetWindowUserPointer(window);
|
||||||
|
int i, blockIndex = -1, blockCount = 0;
|
||||||
|
int width, height;
|
||||||
|
printf("%08x to %i at %0.3f: Preedit text ",
|
||||||
|
counter++, slot->number, glfwGetTime());
|
||||||
|
if (strLength == 0 || blockLength == 0) {
|
||||||
|
printf("(empty)\n");
|
||||||
|
} else {
|
||||||
|
for (i = 0; i < strLength; i++) {
|
||||||
|
if (blockCount == 0) {
|
||||||
|
if (blockIndex == focusedBlock) {
|
||||||
|
printf("]");
|
||||||
|
}
|
||||||
|
blockIndex++;
|
||||||
|
blockCount = blocks[blockIndex];
|
||||||
|
printf("\n block %d: ", blockIndex);
|
||||||
|
if (blockIndex == focusedBlock) {
|
||||||
|
printf("[");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
printf("%s", get_character_string(string[i]));
|
||||||
|
blockCount--;
|
||||||
|
}
|
||||||
|
if (blockIndex == focusedBlock) {
|
||||||
|
printf("]");
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
glfwGetWindowSize(window, &width, &height);
|
||||||
|
glfwSetPreeditCursorPos(window, width/2, height/2, 20);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ime_callback(GLFWwindow* window) {
|
||||||
|
Slot* slot = glfwGetWindowUserPointer(window);
|
||||||
|
printf("%08x to %i at %0.3f: IME switched\n",
|
||||||
|
counter++, slot->number, glfwGetTime());
|
||||||
|
}
|
||||||
|
|
||||||
static void drop_callback(GLFWwindow* window, int count, const char* paths[])
|
static void drop_callback(GLFWwindow* window, int count, const char* paths[])
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@ -638,6 +677,8 @@ int main(int argc, char** argv)
|
|||||||
glfwSetScrollCallback(slots[i].window, scroll_callback);
|
glfwSetScrollCallback(slots[i].window, scroll_callback);
|
||||||
glfwSetKeyCallback(slots[i].window, key_callback);
|
glfwSetKeyCallback(slots[i].window, key_callback);
|
||||||
glfwSetCharCallback(slots[i].window, char_callback);
|
glfwSetCharCallback(slots[i].window, char_callback);
|
||||||
|
glfwSetPreeditCallback(slots[i].window, preedit_callback);
|
||||||
|
glfwSetIMEStatusCallback(slots[i].window, ime_callback);
|
||||||
glfwSetDropCallback(slots[i].window, drop_callback);
|
glfwSetDropCallback(slots[i].window, drop_callback);
|
||||||
|
|
||||||
glfwMakeContextCurrent(slots[i].window);
|
glfwMakeContextCurrent(slots[i].window);
|
||||||
|
Loading…
Reference in New Issue
Block a user