Centralise generation of the control sequences for arrow keys into a
[u/mdw/putty] / macosx / osxwin.m
index f61e6bf..7c9118b 100644 (file)
          case NSLeftArrowFunctionKey: xkey = 'D'; break;
        }
        if (xkey) {
-           /*
-            * The arrow keys normally do ESC [ A and so on. In
-            * app cursor keys mode they do ESC O A instead.
-            * Ctrl toggles the two modes.
-            */
-           if (term->vt52_mode) {
-               output[end++] = '\033';
-               output[end++] = xkey;
-           } else if (!term->app_cursor_keys ^ !(m & NSControlKeyMask)) {
-               output[end++] = '\033';
-               output[end++] = 'O';
-               output[end++] = xkey;
-           } else {
-               output[end++] = '\033';
-               output[end++] = '[';
-               output[end++] = xkey;
-           }
+           end += format_arrow_key(output+end, term, xkey,
+                                   m & NSControlKeyMask);
            goto done;
        }
     }