From 06cc810b80378a2d4a87a3fdf489149d0d9fcb30 Mon Sep 17 00:00:00 2001 From: Brian Granger Date: Thu, 12 Jan 2012 15:37:01 -0800 Subject: [PATCH] Adding keyboard sortcuts for cut/copy/paste. --- .../html/notebook/static/js/notebook.js | 19 +++++++++++++++++-- .../html/notebook/static/js/quickhelp.js | 5 ++++- .../html/notebook/templates/notebook.html | 4 ++-- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/IPython/frontend/html/notebook/static/js/notebook.js b/IPython/frontend/html/notebook/static/js/notebook.js index a3507f442..6324f171a 100644 --- a/IPython/frontend/html/notebook/static/js/notebook.js +++ b/IPython/frontend/html/notebook/static/js/notebook.js @@ -88,6 +88,21 @@ var IPython = (function (IPython) { } else if (event.which === 77 && event.ctrlKey) { that.control_key_active = true; return false; + } else if (event.which === 88 && that.control_key_active) { + // Cut selected cell = x + that.cut_cell(); + that.control_key_active = false; + return false; + } else if (event.which === 67 && that.control_key_active) { + // Copy selected cell = c + that.copy_cell(); + that.control_key_active = false; + return false; + } else if (event.which === 86 && that.control_key_active) { + // Paste selected cell = v + that.paste_cell(); + that.control_key_active = false; + return false; } else if (event.which === 68 && that.control_key_active) { // Delete selected cell = d that.delete_cell(); @@ -103,8 +118,8 @@ var IPython = (function (IPython) { that.insert_code_cell_below(); that.control_key_active = false; return false; - } else if (event.which === 67 && that.control_key_active) { - // To code = c + } else if (event.which === 89 && that.control_key_active) { + // To code = y that.to_code(); that.control_key_active = false; return false; diff --git a/IPython/frontend/html/notebook/static/js/quickhelp.js b/IPython/frontend/html/notebook/static/js/quickhelp.js index aa86abd6b..8e2954158 100644 --- a/IPython/frontend/html/notebook/static/js/quickhelp.js +++ b/IPython/frontend/html/notebook/static/js/quickhelp.js @@ -28,6 +28,9 @@ var IPython = (function (IPython) { var shortcuts = [ {key: 'Shift-Enter', help: 'run cell'}, {key: 'Ctrl-Enter', help: 'run cell in-place'}, + {key: 'Ctrl-m x', help: 'cut cell'}, + {key: 'Ctrl-m c', help: 'copy cell'}, + {key: 'Ctrl-m v', help: 'paste cell'}, {key: 'Ctrl-m d', help: 'delete cell'}, {key: 'Ctrl-m a', help: 'insert cell above'}, {key: 'Ctrl-m b', help: 'insert cell below'}, @@ -36,7 +39,7 @@ var IPython = (function (IPython) { {key: 'Ctrl-m s', help: 'save notebook'}, {key: 'Ctrl-m j', help: 'move cell down'}, {key: 'Ctrl-m k', help: 'move cell up'}, - {key: 'Ctrl-m c', help: 'code cell'}, + {key: 'Ctrl-m y', help: 'code cell'}, {key: 'Ctrl-m m', help: 'markdown cell'}, {key: 'Ctrl-m p', help: 'select previous'}, {key: 'Ctrl-m n', help: 'select next'}, diff --git a/IPython/frontend/html/notebook/templates/notebook.html b/IPython/frontend/html/notebook/templates/notebook.html index 206f16e3b..a9570c4b1 100644 --- a/IPython/frontend/html/notebook/templates/notebook.html +++ b/IPython/frontend/html/notebook/templates/notebook.html @@ -91,8 +91,8 @@
  • Paste Below
  • Delete

  • -
  • Move Cell Up
  • -
  • Move Cell Down
  • +
  • Move Up
  • +
  • Move Down

  • Select Previous
  • Select Next