mirror of
https://github.com/glfw/glfw.git
synced 2025-06-14 19:52:14 +00:00
Win32: Fix style
* Remove needless braces * Add spaces * Use C89 style variable declarations
This commit is contained in:
parent
169da05c53
commit
599a1a98ec
@ -854,25 +854,30 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l
|
|||||||
LONG preeditTextLength = ImmGetCompositionStringW(hIMC, GCS_COMPSTR, NULL, 0);
|
LONG preeditTextLength = ImmGetCompositionStringW(hIMC, GCS_COMPSTR, NULL, 0);
|
||||||
LONG attrLength = ImmGetCompositionString(hIMC, GCS_COMPATTR, NULL, 0);
|
LONG attrLength = ImmGetCompositionString(hIMC, GCS_COMPATTR, NULL, 0);
|
||||||
LONG clauseLength = ImmGetCompositionString(hIMC, GCS_COMPCLAUSE, NULL, 0);
|
LONG clauseLength = ImmGetCompositionString(hIMC, GCS_COMPCLAUSE, NULL, 0);
|
||||||
|
|
||||||
if (preeditTextLength > 0)
|
if (preeditTextLength > 0)
|
||||||
{
|
{
|
||||||
// get preedit data
|
int i;
|
||||||
|
int ctext = window->ctext;
|
||||||
|
int cblocks = window->cblocks;
|
||||||
|
int focusedBlock = 0;
|
||||||
int length = preeditTextLength / sizeof(WCHAR);
|
int length = preeditTextLength / sizeof(WCHAR);
|
||||||
LPWSTR buffer = (LPWSTR) _glfw_calloc(preeditTextLength, 1);
|
LPWSTR buffer = (LPWSTR) _glfw_calloc(preeditTextLength, 1);
|
||||||
LPSTR attributes = (LPSTR) _glfw_calloc(attrLength, 1);
|
LPSTR attributes = (LPSTR) _glfw_calloc(attrLength, 1);
|
||||||
DWORD *clauses = (DWORD*) _glfw_calloc(clauseLength, 1);
|
DWORD *clauses = (DWORD*) _glfw_calloc(clauseLength, 1);
|
||||||
|
|
||||||
|
// get preedit data
|
||||||
ImmGetCompositionStringW(hIMC, GCS_COMPSTR, buffer, preeditTextLength);
|
ImmGetCompositionStringW(hIMC, GCS_COMPSTR, buffer, preeditTextLength);
|
||||||
ImmGetCompositionString(hIMC, GCS_COMPATTR, attributes, attrLength);
|
ImmGetCompositionString(hIMC, GCS_COMPATTR, attributes, attrLength);
|
||||||
ImmGetCompositionString(hIMC, GCS_COMPCLAUSE, clauses, clauseLength);
|
ImmGetCompositionString(hIMC, GCS_COMPCLAUSE, clauses, clauseLength);
|
||||||
|
|
||||||
// store preedit text
|
// store preedit text
|
||||||
int ctext = window->ctext;
|
|
||||||
while (ctext < length + 1)
|
while (ctext < length + 1)
|
||||||
{
|
|
||||||
ctext = (ctext == 0) ? 1 : ctext * 2;
|
ctext = (ctext == 0) ? 1 : ctext * 2;
|
||||||
}
|
|
||||||
if (ctext != window->ctext)
|
if (ctext != window->ctext)
|
||||||
{
|
{
|
||||||
unsigned int* preeditText = _glfw_realloc(window->preeditText, sizeof(unsigned int) * ctext);
|
unsigned int* preeditText = _glfw_realloc(window->preeditText, sizeof(unsigned int) * ctext);
|
||||||
|
|
||||||
if (preeditText == NULL)
|
if (preeditText == NULL)
|
||||||
{
|
{
|
||||||
_glfw_free(buffer);
|
_glfw_free(buffer);
|
||||||
@ -885,24 +890,20 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l
|
|||||||
}
|
}
|
||||||
window->ntext = length;
|
window->ntext = length;
|
||||||
window->preeditText[length] = 0;
|
window->preeditText[length] = 0;
|
||||||
int i;
|
for (i = 0; i < length; i++)
|
||||||
for (i=0; i < length; i++)
|
|
||||||
{
|
|
||||||
window->preeditText[i] = buffer[i];
|
window->preeditText[i] = buffer[i];
|
||||||
}
|
|
||||||
// store blocks
|
// store blocks
|
||||||
window->nblocks = clauseLength / sizeof(DWORD) - 1;
|
window->nblocks = clauseLength / sizeof(DWORD) - 1;
|
||||||
// last element of clauses is a block count, but
|
// last element of clauses is a block count, but
|
||||||
// text length is convenient.
|
// text length is convenient.
|
||||||
clauses[window->nblocks] = length;
|
clauses[window->nblocks] = length;
|
||||||
int cblocks = window->cblocks;
|
|
||||||
while (cblocks < window->nblocks)
|
while (cblocks < window->nblocks)
|
||||||
{
|
|
||||||
cblocks = (cblocks == 0) ? 1 : cblocks * 2;
|
cblocks = (cblocks == 0) ? 1 : cblocks * 2;
|
||||||
}
|
|
||||||
if (cblocks != window->cblocks)
|
if (cblocks != window->cblocks)
|
||||||
{
|
{
|
||||||
int* blocks = _glfw_realloc(window->preeditAttributeBlocks, sizeof(int) * cblocks);
|
int* blocks = _glfw_realloc(window->preeditAttributeBlocks, sizeof(int) * cblocks);
|
||||||
|
|
||||||
if (blocks == NULL)
|
if (blocks == NULL)
|
||||||
{
|
{
|
||||||
_glfw_free(buffer);
|
_glfw_free(buffer);
|
||||||
@ -913,21 +914,21 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l
|
|||||||
window->preeditAttributeBlocks = blocks;
|
window->preeditAttributeBlocks = blocks;
|
||||||
window->cblocks = cblocks;
|
window->cblocks = cblocks;
|
||||||
}
|
}
|
||||||
int focusedBlock = 0;
|
|
||||||
for (i = 0; i < window->nblocks; i++)
|
for (i = 0; i < window->nblocks; i++)
|
||||||
{
|
{
|
||||||
window->preeditAttributeBlocks[i] = clauses[i + 1] - clauses[i];
|
window->preeditAttributeBlocks[i] = clauses[i + 1] - clauses[i];
|
||||||
if (attributes[clauses[i]] != ATTR_CONVERTED)
|
if (attributes[clauses[i]] != ATTR_CONVERTED)
|
||||||
{
|
|
||||||
focusedBlock = i;
|
focusedBlock = i;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_glfw_free(buffer);
|
_glfw_free(buffer);
|
||||||
_glfw_free(attributes);
|
_glfw_free(attributes);
|
||||||
_glfw_free(clauses);
|
_glfw_free(clauses);
|
||||||
|
|
||||||
_glfwInputPreedit(window, focusedBlock);
|
_glfwInputPreedit(window, focusedBlock);
|
||||||
_win32ChangeCursorPosition(hIMC, window);
|
_win32ChangeCursorPosition(hIMC, window);
|
||||||
}
|
}
|
||||||
|
|
||||||
ImmReleaseContext(hWnd, hIMC);
|
ImmReleaseContext(hWnd, hIMC);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user