Document the mouse control method for Cube.
[sgt/puzzles] / osx.m
diff --git a/osx.m b/osx.m
index dfed94c..039f081 100644 (file)
--- a/osx.m
+++ b/osx.m
@@ -383,7 +383,7 @@ struct frontend {
 - (void)keyDown:(NSEvent *)ev;
 - (void)activateTimer;
 - (void)deactivateTimer;
-- (void)setStatusLine:(NSString *)text;
+- (void)setStatusLine:(char *)text;
 @end
 
 @implementation MyImageView
@@ -589,22 +589,34 @@ struct frontend {
         * function key codes.
         */
        if (c >= 0x80) {
+           int mods = FALSE;
            switch (c) {
              case NSUpArrowFunctionKey:
                c = CURSOR_UP;
+               mods = TRUE;
                break;
              case NSDownArrowFunctionKey:
                c = CURSOR_DOWN;
+               mods = TRUE;
                break;
              case NSLeftArrowFunctionKey:
                c = CURSOR_LEFT;
+               mods = TRUE;
                break;
              case NSRightArrowFunctionKey:
                c = CURSOR_RIGHT;
+               mods = TRUE;
                break;
              default:
                continue;
            }
+
+           if (mods) {
+               if ([ev modifierFlags] & NSShiftKeyMask)
+                   c |= MOD_SHFT;
+               if ([ev modifierFlags] & NSControlKeyMask)
+                   c |= MOD_CTRL;
+           }
        }
 
        if (c >= '0' && c <= '9' && ([ev modifierFlags] & NSNumericPadKeyMask))
@@ -1119,9 +1131,11 @@ struct frontend {
     [self sheetEndWithStatus:NO];
 }
 
-- (void)setStatusLine:(NSString *)text
+- (void)setStatusLine:(char *)text
 {
-    [[status cell] setTitle:text];
+    char *rewritten = midend_rewrite_statusbar(me, text);
+    [[status cell] setTitle:[NSString stringWithCString:rewritten]];
+    sfree(rewritten);
 }
 
 @end
@@ -1255,7 +1269,7 @@ void activate_timer(frontend *fe)
 
 void status_bar(frontend *fe, char *text)
 {
-    [fe->window setStatusLine:[NSString stringWithCString:text]];
+    [fe->window setStatusLine:text];
 }
 
 /* ----------------------------------------------------------------------