2 * (C) Copyright 2007-2008 Jeremy Maitin-Shepard
3 * (C) Copyright 2008 John Foerch
5 * Use, modification, and distribution are subject to the terms specified in the
9 define_keymap("universal_argument_keymap");
13 "Begin a numeric argument for the following command.",
16 if (ctx.prefix_argument) {
17 if (typeof(ctx.prefix_argument) == "object") // must be array
18 ctx.prefix_argument = [ctx.prefix_argument[0] * 4];
20 ctx.prefix_argument = [4];
21 ctx.overlay_keymap = universal_argument_keymap;
27 "Part of the numeric argument for the next command.",
30 var digit = ctx.event.charCode - 48;
31 if (ctx.prefix_argument == null)
32 ctx.prefix_argument = digit;
33 else if (typeof(ctx.prefix_argument) == "object") { // array
34 if (ctx.prefix_argument[0] < 0)
35 ctx.prefix_argument = -digit;
37 ctx.prefix_argument = digit;
39 else if (ctx.prefix_argument < 0)
40 ctx.prefix_argument = ctx.prefix_argument * 10 - digit;
42 ctx.prefix_argument = ctx.prefix_argument * 10 + digit;
48 "Part of the numeric argument for the next command. "+
49 "This command negates the numeric argument.",
50 function universal_negate(ctx)
52 if (typeof ctx.prefix_argument == "object")
53 ctx.prefix_argument[0] = 0 - ctx.prefix_argument[0];
55 ctx.prefix_argument = 0 - ctx.prefix_argument;