Allow for trailing '\0' in game_text_format() in various games.
[sgt/puzzles] / osx.m
diff --git a/osx.m b/osx.m
index f444a9f..a27c840 100644 (file)
--- a/osx.m
+++ b/osx.m
@@ -581,10 +581,28 @@ struct frontend {
        NSBeep();
 }
 
+- (void)solveGame:(id)sender
+{
+    char *msg;
+    NSAlert *alert;
+
+    msg = midend_solve(me);
+
+    if (msg) {
+       alert = [[[NSAlert alloc] init] autorelease];
+       [alert addButtonWithTitle:@"Bah"];
+       [alert setInformativeText:[NSString stringWithCString:msg]];
+       [alert beginSheetModalForWindow:self modalDelegate:nil
+        didEndSelector:nil contextInfo:nil];
+    }
+}
+
 - (BOOL)validateMenuItem:(NSMenuItem *)item
 {
     if ([item action] == @selector(copy:))
        return (ourgame->can_format_as_text ? YES : NO);
+    else if ([item action] == @selector(solveGame:))
+       return (ourgame->can_solve ? YES : NO);
     else
        return [super validateMenuItem:item];
 }
@@ -1236,7 +1254,11 @@ int main(int argc, char **argv)
     item = newitem(menu, "Undo", "z", NULL, @selector(undoMove:));
     item = newitem(menu, "Redo", "S-z", NULL, @selector(redoMove:));
     [menu addItem:[NSMenuItem separatorItem]];
+    item = newitem(menu, "Cut", "x", NULL, @selector(cut:));
     item = newitem(menu, "Copy", "c", NULL, @selector(copy:));
+    item = newitem(menu, "Paste", "v", NULL, @selector(paste:));
+    [menu addItem:[NSMenuItem separatorItem]];
+    item = newitem(menu, "Solve", "S-s", NULL, @selector(solveGame:));
 
     menu = newsubmenu([NSApp mainMenu], "Type");
     typemenu = menu;