tests: Fix coding style

* brace position
* length of one line
This commit is contained in:
Daijiro Fukuda 2022-04-22 10:38:36 +09:00
parent 0d8627121c
commit e7a1099a7b
2 changed files with 45 additions and 28 deletions

View File

@ -454,42 +454,48 @@ 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) { static void preedit_callback(GLFWwindow* window, int strLength,
unsigned int* string, int blockLength,
int* blocks, int focusedBlock)
{
Slot* slot = glfwGetWindowUserPointer(window); Slot* slot = glfwGetWindowUserPointer(window);
int i, blockIndex = -1, blockCount = 0; int i, blockIndex = -1, blockCount = 0;
int width, height; int width, height;
char encoded[5] = ""; char encoded[5] = "";
printf("%08x to %i at %0.3f: Preedit text ", printf("%08x to %i at %0.3f: Preedit text ",
counter++, slot->number, glfwGetTime()); counter++, slot->number, glfwGetTime());
if (strLength == 0 || blockLength == 0) { if (strLength == 0 || blockLength == 0)
{
printf("(empty)\n"); printf("(empty)\n");
} else { }
for (i = 0; i < strLength; i++) { else
if (blockCount == 0) { {
if (blockIndex == focusedBlock) { for (i = 0; i < strLength; i++)
{
if (blockCount == 0)
{
if (blockIndex == focusedBlock)
printf("]"); printf("]");
}
blockIndex++; blockIndex++;
blockCount = blocks[blockIndex]; blockCount = blocks[blockIndex];
printf("\n block %d: ", blockIndex); printf("\n block %d: ", blockIndex);
if (blockIndex == focusedBlock) { if (blockIndex == focusedBlock)
printf("["); printf("[");
}
} }
encode_utf8(encoded, string[i]); encode_utf8(encoded, string[i]);
printf("%s", encoded); printf("%s", encoded);
blockCount--; blockCount--;
} }
if (blockIndex == focusedBlock) { if (blockIndex == focusedBlock)
printf("]"); printf("]");
}
printf("\n"); printf("\n");
glfwGetWindowSize(window, &width, &height); glfwGetWindowSize(window, &width, &height);
glfwSetPreeditCursorPos(window, width/2, height/2, 20); glfwSetPreeditCursorPos(window, width/2, height/2, 20);
} }
} }
static void ime_callback(GLFWwindow* window) { static void ime_callback(GLFWwindow* window)
{
Slot* slot = glfwGetWindowUserPointer(window); Slot* slot = glfwGetWindowUserPointer(window);
printf("%08x to %i at %0.3f: IME switched\n", printf("%08x to %i at %0.3f: IME switched\n",
counter++, slot->number, glfwGetTime()); counter++, slot->number, glfwGetTime());

View File

@ -82,13 +82,18 @@ static void error_callback(int error, const char* description)
static void mouse_button_callback(GLFWwindow* window, int button, int action, int mods) static void mouse_button_callback(GLFWwindow* window, int button, int action, int mods)
{ {
if (action == GLFW_PRESS) { if (action == GLFW_PRESS)
if (button == GLFW_MOUSE_BUTTON_LEFT) { {
if (button == GLFW_MOUSE_BUTTON_LEFT)
{
int currentIMEstatus = glfwGetInputMode(window, GLFW_IME); int currentIMEstatus = glfwGetInputMode(window, GLFW_IME);
glfwSetInputMode(window, GLFW_IME, !currentIMEstatus); glfwSetInputMode(window, GLFW_IME, !currentIMEstatus);
glfwResetPreeditText(window); glfwResetPreeditText(window);
printf("Reset preedit text and IME status -> %s\n", currentIMEstatus ? "OFF" : "ON"); printf("Reset preedit text and IME status -> %s\n",
} else if (button == GLFW_MOUSE_BUTTON_RIGHT) { currentIMEstatus ? "OFF" : "ON");
}
else if (button == GLFW_MOUSE_BUTTON_RIGHT)
{
int preX, preY; int preX, preY;
double curX, curY; double curX, curY;
glfwGetPreeditCursorPos(window, &preX, &preY, NULL); glfwGetPreeditCursorPos(window, &preX, &preY, NULL);
@ -108,38 +113,44 @@ static void char_callback(GLFWwindow* window, unsigned int codepoint)
printf("Character 0x%08x (%s) input\n", codepoint, string); printf("Character 0x%08x (%s) input\n", codepoint, string);
} }
static void preedit_callback(GLFWwindow* window, int strLength, unsigned int* string, int blockLength, int* blocks, int focusedBlock) { static void preedit_callback(GLFWwindow* window, int strLength,
unsigned int* string, int blockLength,
int* blocks, int focusedBlock)
{
int i, blockIndex = -1, blockCount = 0; int i, blockIndex = -1, blockCount = 0;
int width, height; int width, height;
char encoded[5] = ""; char encoded[5] = "";
printf("Preedit text "); printf("Preedit text ");
if (strLength == 0 || blockLength == 0) { if (strLength == 0 || blockLength == 0)
{
printf("(empty)\n"); printf("(empty)\n");
} else { }
for (i = 0; i < strLength; i++) { else
if (blockCount == 0) { {
if (blockIndex == focusedBlock) { for (i = 0; i < strLength; i++)
{
if (blockCount == 0)
{
if (blockIndex == focusedBlock)
printf("]"); printf("]");
}
blockIndex++; blockIndex++;
blockCount = blocks[blockIndex]; blockCount = blocks[blockIndex];
printf("\n block %d: ", blockIndex); printf("\n block %d: ", blockIndex);
if (blockIndex == focusedBlock) { if (blockIndex == focusedBlock)
printf("["); printf("[");
}
} }
encode_utf8(encoded, string[i]); encode_utf8(encoded, string[i]);
printf("%s", encoded); printf("%s", encoded);
blockCount--; blockCount--;
} }
if (blockIndex == focusedBlock) { if (blockIndex == focusedBlock)
printf("]"); printf("]");
}
printf("\n"); printf("\n");
} }
} }
static void ime_callback(GLFWwindow* window) { static void ime_callback(GLFWwindow* window)
{
int currentIMEstatus = glfwGetInputMode(window, GLFW_IME); int currentIMEstatus = glfwGetInputMode(window, GLFW_IME);
printf("IME switched: %s\n", currentIMEstatus ? "ON" : "OFF"); printf("IME switched: %s\n", currentIMEstatus ? "ON" : "OFF");
} }