isearch-backspace, isearch-done: docstrings
[conkeror.git] / modules / universal-argument.js
blob69ec8b2ddcfa55b6d11660dc56a0edf554f6d929
1 /**
2  * (C) Copyright 2004-2007 Shawn Betts
3  * (C) Copyright 2007-2008 Jeremy Maitin-Shepard
4  * (C) Copyright 2008 John Foerch
5  *
6  * Use, modification, and distribution are subject to the terms specified in the
7  * COPYING file.
8 **/
10 define_keymap("universal_argument_keymap");
12 interactive("universal-argument",
13     "Begin a numeric argument for the following command.",
14     function (I) {
15         if (I.prefix_argument) {
16             if (typeof I.prefix_argument == "object") // must be array
17                 I.prefix_argument = [I.prefix_argument[0] * 4];
18         } else
19             I.prefix_argument = [4];
20         I.overlay_keymap = universal_argument_keymap;
21     },
22     $prefix = true);
24 interactive("universal-digit",
25     "Part of the numeric argument for the next command.",
26     function (I) {
27         var digit = I.event.charCode - 48;
28         if (I.prefix_argument == null)
29             I.prefix_argument = digit;
30         else if (typeof I.prefix_argument == "object") { // array
31             if (I.prefix_argument[0] < 0)
32                 I.prefix_argument = -digit;
33             else
34                 I.prefix_argument = digit;
35         }
36         else if (I.prefix_argument < 0)
37             I.prefix_argument = I.prefix_argument * 10 - digit;
38         else
39             I.prefix_argument = I.prefix_argument * 10 + digit;
40     },
41     $prefix = true);
43 interactive("universal-negate",
44     "Part of the numeric argument for the next command.  "+
45     "This command negates the numeric argument.",
46     function universal_negate (I) {
47         if (typeof I.prefix_argument == "object")
48             I.prefix_argument[0] = 0 - I.prefix_argument[0];
49         else
50             I.prefix_argument = 0 - I.prefix_argument;
51     },
52     $prefix = true);
54 provide("universal-argument");