mirror of
https://github.com/glfw/glfw.git
synced 2025-06-14 19:52:14 +00:00
macOS: Fix coding style
* brace position * space * length of one line
This commit is contained in:
parent
28ea48ea38
commit
2e976c01ed
@ -331,7 +331,8 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
|
||||
window->ns.occluded = GLFW_TRUE;
|
||||
}
|
||||
|
||||
- (void)imeStatusChangeNotified:(NSNotification *)notification {
|
||||
- (void)imeStatusChangeNotified:(NSNotification *)notification
|
||||
{
|
||||
_glfwInputIMEStatus(window);
|
||||
}
|
||||
|
||||
@ -696,14 +697,16 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
|
||||
|
||||
NSUInteger i, length = [markedTextString length];
|
||||
int ctext = window->ctext;
|
||||
while (ctext < length+1) {
|
||||
ctext = (ctext == 0) ? 1 : ctext*2;
|
||||
while (ctext < length + 1)
|
||||
{
|
||||
ctext = ctext == 0 ? 1 : ctext * 2;
|
||||
}
|
||||
if (ctext != window->ctext) {
|
||||
unsigned int* preeditText = realloc(window->preeditText, sizeof(unsigned int)*ctext);
|
||||
if (preeditText == NULL) {
|
||||
if (ctext != window->ctext)
|
||||
{
|
||||
unsigned int* preeditText = realloc(window->preeditText,
|
||||
sizeof(unsigned int) * ctext);
|
||||
if (preeditText == NULL)
|
||||
return;
|
||||
}
|
||||
window->preeditText = preeditText;
|
||||
window->ctext = ctext;
|
||||
}
|
||||
@ -717,28 +720,29 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
|
||||
int focusedBlock = 0;
|
||||
NSInteger offset = 0;
|
||||
window->nblocks = 0;
|
||||
while (offset < length) {
|
||||
while (offset < length)
|
||||
{
|
||||
NSRange effectiveRange;
|
||||
NSDictionary *attributes = [markedText attributesAtIndex:offset effectiveRange:&effectiveRange];
|
||||
NSDictionary* attributes = [markedText attributesAtIndex:offset
|
||||
effectiveRange:&effectiveRange];
|
||||
|
||||
if (window->nblocks == window->cblocks) {
|
||||
if (window->nblocks == window->cblocks)
|
||||
{
|
||||
int cblocks = window->cblocks * 2;
|
||||
int* blocks = realloc(window->preeditAttributeBlocks, sizeof(int)*cblocks);
|
||||
if (blocks == NULL) {
|
||||
int* blocks = realloc(window->preeditAttributeBlocks,
|
||||
sizeof(int) * cblocks);
|
||||
if (blocks == NULL)
|
||||
return;
|
||||
}
|
||||
window->preeditAttributeBlocks = blocks;
|
||||
window->cblocks = cblocks;
|
||||
}
|
||||
window->preeditAttributeBlocks[window->nblocks] = effectiveRange.length;
|
||||
offset += effectiveRange.length;
|
||||
if (effectiveRange.length == 0) {
|
||||
if (effectiveRange.length == 0)
|
||||
break;
|
||||
}
|
||||
NSNumber* underline = (NSNumber*) [attributes objectForKey:@"NSUnderline"];
|
||||
if ([underline intValue] != 1) {
|
||||
if ([underline intValue] != 1)
|
||||
focusedBlock = window->nblocks;
|
||||
}
|
||||
window->nblocks++;
|
||||
}
|
||||
_glfwInputPreedit(window, focusedBlock);
|
||||
@ -2004,22 +2008,35 @@ void _glfwPlatformSetIMEStatus(_GLFWwindow* window, int active)
|
||||
{
|
||||
// Mac OS has several input sources.
|
||||
// this code assumes input methods not in ascii capable inputs using IME.
|
||||
NSArray* asciiInputSources = CFBridgingRelease(TISCreateASCIICapableInputSourceList());
|
||||
TISInputSourceRef asciiSource = (__bridge TISInputSourceRef)([asciiInputSources firstObject]);
|
||||
if (active) {
|
||||
NSArray* allInputSources = CFBridgingRelease(TISCreateInputSourceList(NULL, false));
|
||||
NSString* asciiSourceID = (__bridge NSString *)(TISGetInputSourceProperty(asciiSource, kTISPropertyInputSourceID));
|
||||
NSArray* asciiInputSources =
|
||||
CFBridgingRelease(TISCreateASCIICapableInputSourceList());
|
||||
TISInputSourceRef asciiSource =
|
||||
(__bridge TISInputSourceRef) [asciiInputSources firstObject];
|
||||
if (active)
|
||||
{
|
||||
NSArray* allInputSources =
|
||||
CFBridgingRelease(TISCreateInputSourceList(NULL, false));
|
||||
NSString* asciiSourceID =
|
||||
(__bridge NSString *) TISGetInputSourceProperty(asciiSource,
|
||||
kTISPropertyInputSourceID);
|
||||
int i;
|
||||
int count = [allInputSources count];
|
||||
for (i = 0; i < count; i++) {
|
||||
TISInputSourceRef source = (__bridge TISInputSourceRef)([allInputSources objectAtIndex: i]);
|
||||
NSString* sourceID = (__bridge NSString *)(TISGetInputSourceProperty(source, kTISPropertyInputSourceID));
|
||||
if ([asciiSourceID compare: sourceID] != NSOrderedSame) {
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
TISInputSourceRef source =
|
||||
(__bridge TISInputSourceRef) [allInputSources objectAtIndex:i];
|
||||
NSString* sourceID =
|
||||
(__bridge NSString *) TISGetInputSourceProperty(source,
|
||||
kTISPropertyInputSourceID);
|
||||
if ([asciiSourceID compare:sourceID] != NSOrderedSame)
|
||||
{
|
||||
TISSelectInputSource(source);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (asciiSource) {
|
||||
}
|
||||
else if (asciiSource)
|
||||
{
|
||||
TISSelectInputSource(asciiSource);
|
||||
}
|
||||
}
|
||||
@ -2027,12 +2044,20 @@ void _glfwPlatformSetIMEStatus(_GLFWwindow* window, int active)
|
||||
int _glfwPlatformGetIMEStatus(_GLFWwindow* window)
|
||||
{
|
||||
TISInputSourceRef currentSource = TISCopyCurrentKeyboardInputSource();
|
||||
NSString* currentSourceID = (__bridge NSString *)(TISGetInputSourceProperty(currentSource, kTISPropertyInputSourceID));
|
||||
NSArray* asciiInputSources = CFBridgingRelease(TISCreateASCIICapableInputSourceList());
|
||||
TISInputSourceRef asciiSource = (__bridge TISInputSourceRef)([asciiInputSources firstObject]);
|
||||
if (asciiSource) {
|
||||
NSString* asciiSourceID = (__bridge NSString *)(TISGetInputSourceProperty(asciiSource, kTISPropertyInputSourceID));
|
||||
return ([asciiSourceID compare: currentSourceID] == NSOrderedSame) ? GLFW_FALSE : GLFW_TRUE;
|
||||
NSString* currentSourceID =
|
||||
(__bridge NSString *) TISGetInputSourceProperty(currentSource,
|
||||
kTISPropertyInputSourceID);
|
||||
NSArray* asciiInputSources =
|
||||
CFBridgingRelease(TISCreateASCIICapableInputSourceList());
|
||||
TISInputSourceRef asciiSource =
|
||||
(__bridge TISInputSourceRef) [asciiInputSources firstObject];
|
||||
if (asciiSource)
|
||||
{
|
||||
NSString* asciiSourceID =
|
||||
(__bridge NSString *) TISGetInputSourceProperty(asciiSource,
|
||||
kTISPropertyInputSourceID);
|
||||
return [asciiSourceID compare:currentSourceID] == NSOrderedSame
|
||||
? GLFW_FALSE : GLFW_TRUE;
|
||||
}
|
||||
return GLFW_FALSE;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user