function onGutterClick(cm, line, gutter, event) {
        var opts = cm.state.foldGutter.options, pos = CodeMirror.Pos(line);
        if (gutter !== opts.gutter) { return; }
        var range;
        var _lineFolds = cm._lineFolds;
        if (cm.isFolded(line)) {
            if (event.altKey) { // unfold code including children
                range = _lineFolds[line];
                CodeMirror.commands.unfoldAll(cm, range.from.line, range.to.line);
            } else {
                cm.unfoldCode(line, {range: _lineFolds[line]});
            }
        } else {
            if (event.altKey) {
                range = CodeMirror.fold.auto(cm, pos);
                if (range) {
                    CodeMirror.commands.foldToLevel(cm, range.from.line, range.to.line);
                }
            } else {
                cm.foldCode(line);
            }
        }
    }
Event handler for gutter click. Manages folding and unfolding code regions. If the Alt key
is pressed while clicking the fold gutter, child code fragments are also folded/unfolded
up to a level defined in the `maxFoldLevel' preference.
@param {!CodeMirror} cm the CodeMirror object
@param {number} line the line number for the clicked gutter
@param {string} gutter the name of the gutter element clicked
@param {!KeyboardEvent} event the underlying dom event triggered for the gutter click