// Allow codefolding in code cells // // This extension enables the CodeMirror feature // It works by adding a gutter area to each code cell. // Fold-able code is marked using small triangles in the gutter. // // The current folding state is saved in the cell metadata as an array // of line numbers. // Format: cell.metadata.code_folding = [ line1, line2, line3, ...] // define([ 'base/js/namespace', 'jquery', "base/js/events", ], function(IPython, $, events) { "use strict"; var foldingKey = { "Alt-F" : toggleFolding }; /* * Toggle folding on/off at current line * * @method toggleFolding * @param cm CodeMirror instance * */ function toggleFolding(cm) { var pos = cm.getCursor(); var opts = cm.state.foldGutter.options; cm.foldCode(pos, opts.rangeFinder); } /** * Concatenate associative array objects * * Source: http://stackoverflow.com/questions/2454295/javascript-concatenate-properties-from-multiple-objects-associative-array */ function collect() { var ret = {}; var len = arguments.length; for (var i=0; i