diff options
Diffstat (limited to 'apps/plugins/puzzles/src/osx.m')
-rw-r--r-- | apps/plugins/puzzles/src/osx.m | 47 |
1 files changed, 26 insertions, 21 deletions
diff --git a/apps/plugins/puzzles/src/osx.m b/apps/plugins/puzzles/src/osx.m index be29819b62..daa4af1f09 100644 --- a/apps/plugins/puzzles/src/osx.m +++ b/apps/plugins/puzzles/src/osx.m | |||
@@ -111,7 +111,7 @@ NSApplication *app; | |||
111 | * clearly defined subsystem. | 111 | * clearly defined subsystem. |
112 | */ | 112 | */ |
113 | 113 | ||
114 | void fatal(char *fmt, ...) | 114 | void fatal(const char *fmt, ...) |
115 | { | 115 | { |
116 | va_list ap; | 116 | va_list ap; |
117 | char errorbuf[2048]; | 117 | char errorbuf[2048]; |
@@ -152,7 +152,7 @@ void get_random_seed(void **randseed, int *randseedsize) | |||
152 | *randseedsize = sizeof(time_t); | 152 | *randseedsize = sizeof(time_t); |
153 | } | 153 | } |
154 | 154 | ||
155 | static void savefile_write(void *wctx, void *buf, int len) | 155 | static void savefile_write(void *wctx, const void *buf, int len) |
156 | { | 156 | { |
157 | FILE *fp = (FILE *)wctx; | 157 | FILE *fp = (FILE *)wctx; |
158 | fwrite(buf, 1, len, fp); | 158 | fwrite(buf, 1, len, fp); |
@@ -275,7 +275,7 @@ id initnewitem(NSMenuItem *item, NSMenu *parent, const char *title, | |||
275 | return item; | 275 | return item; |
276 | } | 276 | } |
277 | 277 | ||
278 | NSMenuItem *newitem(NSMenu *parent, char *title, char *key, | 278 | NSMenuItem *newitem(NSMenu *parent, const char *title, const char *key, |
279 | id target, SEL action) | 279 | id target, SEL action) |
280 | { | 280 | { |
281 | return initnewitem([NSMenuItem allocWithZone:[NSMenu menuZone]], | 281 | return initnewitem([NSMenuItem allocWithZone:[NSMenu menuZone]], |
@@ -437,7 +437,7 @@ struct frontend { | |||
437 | - (void)keyDown:(NSEvent *)ev; | 437 | - (void)keyDown:(NSEvent *)ev; |
438 | - (void)activateTimer; | 438 | - (void)activateTimer; |
439 | - (void)deactivateTimer; | 439 | - (void)deactivateTimer; |
440 | - (void)setStatusLine:(char *)text; | 440 | - (void)setStatusLine:(const char *)text; |
441 | - (void)resizeForNewGameParams; | 441 | - (void)resizeForNewGameParams; |
442 | - (void)updateTypeMenuTick; | 442 | - (void)updateTypeMenuTick; |
443 | @end | 443 | @end |
@@ -726,7 +726,7 @@ struct frontend { | |||
726 | last_time = now; | 726 | last_time = now; |
727 | } | 727 | } |
728 | 728 | ||
729 | - (void)showError:(char *)message | 729 | - (void)showError:(const char *)message |
730 | { | 730 | { |
731 | NSAlert *alert; | 731 | NSAlert *alert; |
732 | 732 | ||
@@ -789,7 +789,7 @@ struct frontend { | |||
789 | const char *name = [[[op filenames] objectAtIndex:0] | 789 | const char *name = [[[op filenames] objectAtIndex:0] |
790 | cStringUsingEncoding: | 790 | cStringUsingEncoding: |
791 | [NSString defaultCStringEncoding]]; | 791 | [NSString defaultCStringEncoding]]; |
792 | char *err; | 792 | const char *err; |
793 | 793 | ||
794 | FILE *fp = fopen(name, "r"); | 794 | FILE *fp = fopen(name, "r"); |
795 | 795 | ||
@@ -836,7 +836,7 @@ struct frontend { | |||
836 | 836 | ||
837 | - (void)solveGame:(id)sender | 837 | - (void)solveGame:(id)sender |
838 | { | 838 | { |
839 | char *msg; | 839 | const char *msg; |
840 | 840 | ||
841 | msg = midend_solve(me); | 841 | msg = midend_solve(me); |
842 | 842 | ||
@@ -1103,7 +1103,8 @@ struct frontend { | |||
1103 | [tf setEditable:YES]; | 1103 | [tf setEditable:YES]; |
1104 | [tf setSelectable:YES]; | 1104 | [tf setSelectable:YES]; |
1105 | [tf setBordered:YES]; | 1105 | [tf setBordered:YES]; |
1106 | [[tf cell] setTitle:[NSString stringWithUTF8String:i->sval]]; | 1106 | [[tf cell] setTitle:[NSString |
1107 | stringWithUTF8String:i->u.string.sval]]; | ||
1107 | [tf sizeToFit]; | 1108 | [tf sizeToFit]; |
1108 | rect = [tf frame]; | 1109 | rect = [tf frame]; |
1109 | /* | 1110 | /* |
@@ -1132,7 +1133,7 @@ struct frontend { | |||
1132 | [b setButtonType:NSSwitchButton]; | 1133 | [b setButtonType:NSSwitchButton]; |
1133 | [b setTitle:[NSString stringWithUTF8String:i->name]]; | 1134 | [b setTitle:[NSString stringWithUTF8String:i->name]]; |
1134 | [b sizeToFit]; | 1135 | [b sizeToFit]; |
1135 | [b setState:(i->ival ? NSOnState : NSOffState)]; | 1136 | [b setState:(i->u.boolean.bval ? NSOnState : NSOffState)]; |
1136 | rect = [b frame]; | 1137 | rect = [b frame]; |
1137 | if (totalw < rect.size.width + 1) totalw = rect.size.width + 1; | 1138 | if (totalw < rect.size.width + 1) totalw = rect.size.width + 1; |
1138 | if (thish < rect.size.height + 1) thish = rect.size.height + 1; | 1139 | if (thish < rect.size.height + 1) thish = rect.size.height + 1; |
@@ -1161,12 +1162,14 @@ struct frontend { | |||
1161 | pb = [[NSPopUpButton alloc] initWithFrame:tmprect pullsDown:NO]; | 1162 | pb = [[NSPopUpButton alloc] initWithFrame:tmprect pullsDown:NO]; |
1162 | [pb setBezelStyle:NSRoundedBezelStyle]; | 1163 | [pb setBezelStyle:NSRoundedBezelStyle]; |
1163 | { | 1164 | { |
1164 | char c, *p; | 1165 | char c; |
1166 | const char *p; | ||
1165 | 1167 | ||
1166 | p = i->sval; | 1168 | p = i->u.choices.choicenames; |
1167 | c = *p++; | 1169 | c = *p++; |
1168 | while (*p) { | 1170 | while (*p) { |
1169 | char *q, *copy; | 1171 | const char *q; |
1172 | char *copy; | ||
1170 | 1173 | ||
1171 | q = p; | 1174 | q = p; |
1172 | while (*p && *p != c) p++; | 1175 | while (*p && *p != c) p++; |
@@ -1180,7 +1183,7 @@ struct frontend { | |||
1180 | if (*p) p++; | 1183 | if (*p) p++; |
1181 | } | 1184 | } |
1182 | } | 1185 | } |
1183 | [pb selectItemAtIndex:i->ival]; | 1186 | [pb selectItemAtIndex:i->u.choices.selected]; |
1184 | [pb sizeToFit]; | 1187 | [pb sizeToFit]; |
1185 | 1188 | ||
1186 | rect = [pb frame]; | 1189 | rect = [pb frame]; |
@@ -1297,23 +1300,24 @@ struct frontend { | |||
1297 | if (update) { | 1300 | if (update) { |
1298 | int k; | 1301 | int k; |
1299 | config_item *i; | 1302 | config_item *i; |
1300 | char *error; | 1303 | const char *error; |
1301 | 1304 | ||
1302 | k = 0; | 1305 | k = 0; |
1303 | for (i = cfg; i->type != C_END; i++) { | 1306 | for (i = cfg; i->type != C_END; i++) { |
1304 | switch (i->type) { | 1307 | switch (i->type) { |
1305 | case C_STRING: | 1308 | case C_STRING: |
1306 | sfree(i->sval); | 1309 | sfree(i->u.string.sval); |
1307 | i->sval = dupstr([[[(id)cfg_controls[k+1] cell] | 1310 | i->u.string.sval = dupstr([[[(id)cfg_controls[k+1] cell] |
1308 | title] UTF8String]); | 1311 | title] UTF8String]); |
1309 | k += 2; | 1312 | k += 2; |
1310 | break; | 1313 | break; |
1311 | case C_BOOLEAN: | 1314 | case C_BOOLEAN: |
1312 | i->ival = [(id)cfg_controls[k] state] == NSOnState; | 1315 | i->u.boolean.bval = [(id)cfg_controls[k] state] == NSOnState; |
1313 | k++; | 1316 | k++; |
1314 | break; | 1317 | break; |
1315 | case C_CHOICES: | 1318 | case C_CHOICES: |
1316 | i->ival = [(id)cfg_controls[k+1] indexOfSelectedItem]; | 1319 | i->u.choices.selected = |
1320 | [(id)cfg_controls[k+1] indexOfSelectedItem]; | ||
1317 | k += 2; | 1321 | k += 2; |
1318 | break; | 1322 | break; |
1319 | } | 1323 | } |
@@ -1344,7 +1348,7 @@ struct frontend { | |||
1344 | [self sheetEndWithStatus:NO]; | 1348 | [self sheetEndWithStatus:NO]; |
1345 | } | 1349 | } |
1346 | 1350 | ||
1347 | - (void)setStatusLine:(char *)text | 1351 | - (void)setStatusLine:(const char *)text |
1348 | { | 1352 | { |
1349 | [[status cell] setTitle:[NSString stringWithUTF8String:text]]; | 1353 | [[status cell] setTitle:[NSString stringWithUTF8String:text]]; |
1350 | } | 1354 | } |
@@ -1457,7 +1461,8 @@ static void osx_draw_rect(void *handle, int x, int y, int w, int h, int colour) | |||
1457 | NSRectFill(r); | 1461 | NSRectFill(r); |
1458 | } | 1462 | } |
1459 | static void osx_draw_text(void *handle, int x, int y, int fonttype, | 1463 | static void osx_draw_text(void *handle, int x, int y, int fonttype, |
1460 | int fontsize, int align, int colour, char *text) | 1464 | int fontsize, int align, int colour, |
1465 | const char *text) | ||
1461 | { | 1466 | { |
1462 | frontend *fe = (frontend *)handle; | 1467 | frontend *fe = (frontend *)handle; |
1463 | NSString *string = [NSString stringWithUTF8String:text]; | 1468 | NSString *string = [NSString stringWithUTF8String:text]; |
@@ -1608,7 +1613,7 @@ static void osx_end_draw(void *handle) | |||
1608 | frontend *fe = (frontend *)handle; | 1613 | frontend *fe = (frontend *)handle; |
1609 | [fe->image unlockFocus]; | 1614 | [fe->image unlockFocus]; |
1610 | } | 1615 | } |
1611 | static void osx_status_bar(void *handle, char *text) | 1616 | static void osx_status_bar(void *handle, const char *text) |
1612 | { | 1617 | { |
1613 | frontend *fe = (frontend *)handle; | 1618 | frontend *fe = (frontend *)handle; |
1614 | [fe->window setStatusLine:text]; | 1619 | [fe->window setStatusLine:text]; |