{ "metadata": { "name": "", "signature": "sha256:cf52e4e5b6babfdd6636814148812f10fcf73b5ade962f69b728c735ac95d33f" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ "Notebook javascript API" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "There is a 'pythonic' javascript API in the notebook. From this API you can access code mirror configuration, you can add buttons to the toolbar, enable or disable some code cells,..." ] }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Some examples" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "--------------------------------------" ] }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Add line numbers on each cell" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Add line number to new cells:\n", "\n", " IPython.Cell.options_default.cm_config.lineNumbers = true;\n", "\n", "or only to new ***code*** cells:\n", "\n", " IPython.CodeCell.options_default.cm_config.lineNumbers = true;" ] }, { "cell_type": "code", "collapsed": false, "input": [ "%%javascript\n", "IPython.CodeCell.options_default.cm_config.lineNumbers = false;" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "-----------------------------------------------------------------------------------------------------------------------------" ] }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Modify the cursor blink rate" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Cursor blink (extracted from http://pirsquared.org/blog/notebook-blink.html)" ] }, { "cell_type": "code", "collapsed": false, "input": [ "%%javascript\n", "var rate = 530; // default in codemirror is 530ms\n", "// apply setting to all current CodeMirror instances\n", "IPython.notebook.get_cells().map(\n", " function(c) { return c.code_mirror.options.cursorBlinkRate=rate; }\n", ");\n", "\n", "// make sure new CodeMirror instance also use this setting\n", "CodeMirror.defaults.cursorBlinkRate = rate;" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "--------------------------------------" ] }, { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ "Listening the content of cells using a shortcut and the new HTML5 SpeechAPI" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "