File: universal-argument.js

package info (click to toggle)
conkeror 1.0.3%2Bgit170123-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 1,988 kB
  • sloc: ansic: 280; sh: 255; xml: 173; makefile: 69
file content (54 lines) | stat: -rw-r--r-- 1,770 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/**
 * (C) Copyright 2004-2007 Shawn Betts
 * (C) Copyright 2007-2008 Jeremy Maitin-Shepard
 * (C) Copyright 2008 John Foerch
 *
 * Use, modification, and distribution are subject to the terms specified in the
 * COPYING file.
**/

define_keymap("universal_argument_keymap");

interactive("universal-argument",
    "Begin a numeric argument for the following command.",
    function (I) {
        if (I.prefix_argument) {
            if (typeof I.prefix_argument == "object") // must be array
                I.prefix_argument = [I.prefix_argument[0] * 4];
        } else
            I.prefix_argument = [4];
        I.overlay_keymap = universal_argument_keymap;
    },
    $prefix = true);

interactive("universal-digit",
    "Part of the numeric argument for the next command.",
    function (I) {
        var digit = I.event.charCode - 48;
        if (I.prefix_argument == null)
            I.prefix_argument = digit;
        else if (typeof I.prefix_argument == "object") { // array
            if (I.prefix_argument[0] < 0)
                I.prefix_argument = -digit;
            else
                I.prefix_argument = digit;
        }
        else if (I.prefix_argument < 0)
            I.prefix_argument = I.prefix_argument * 10 - digit;
        else
            I.prefix_argument = I.prefix_argument * 10 + digit;
    },
    $prefix = true);

interactive("universal-negate",
    "Part of the numeric argument for the next command.  "+
    "This command negates the numeric argument.",
    function universal_negate (I) {
        if (typeof I.prefix_argument == "object")
            I.prefix_argument[0] = 0 - I.prefix_argument[0];
        else
            I.prefix_argument = 0 - I.prefix_argument;
    },
    $prefix = true);

provide("universal-argument");