Skip to content
This repository was archived by the owner on Aug 22, 2023. It is now read-only.

Commit 0acf3d8

Browse files
committed
Improve UI
1 parent 9644df2 commit 0acf3d8

File tree

2 files changed

+55
-2
lines changed

2 files changed

+55
-2
lines changed

lib/jupyter/actions.js

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ define([
2828
var handler = action.handler;
2929
action.handler = function(env, event) {
3030
var cell = env.notebook.get_selected_cell();
31-
if (cell && isInInsertMode(cell.code_mirror)) {
31+
if (cell && (isInInsertMode(cell.code_mirror))) {
3232
// CodeMirror is in InsertMode, prevent any Jupyter action in
3333
// InsertMode and let CodeMirror to do things
3434
return;
@@ -49,6 +49,59 @@ define([
4949
}
5050
}
5151

52+
// vim-binding original actions (Insert mode)
53+
actions.register({
54+
'help': 'run cell, select below',
55+
'handler': function(env, event) {
56+
env.notebook.command_mode();
57+
actions.call('jupyter-notebook:run-cell-and-select-next', event, env);
58+
env.notebook.edit_mode();
59+
}
60+
}, 'run-cell-and-select-next', 'vim-binding');
61+
62+
actions.register({
63+
'help': 'run selected cells',
64+
'handler': function(env, event) {
65+
env.notebook.command_mode();
66+
actions.call('jupyter-notebook:run-cell', event, env);
67+
env.notebook.edit_mode();
68+
}
69+
}, 'run-cell', 'vim-binding');
70+
71+
actions.register({
72+
'help': 'run cell, insert below',
73+
'handler': function(env, event) {
74+
env.notebook.command_mode();
75+
actions.call('jupyter-notebook:run-cell-and-insert-below', event, env);
76+
env.notebook.edit_mode();
77+
}
78+
}, 'run-cell-and-insert-below', 'vim-binding');
79+
80+
actions.register({
81+
'help': 'run all cells',
82+
'handler': function(env, event) {
83+
env.notebook.command_mode();
84+
actions.call('jupyter-notebook:run-all-cells', event, env);
85+
env.notebook.edit_mode();
86+
}
87+
}, 'run-all-cells', 'vim-binding');
88+
89+
actions.register({
90+
'handler': function(env, event) {
91+
env.notebook.command_mode();
92+
actions.call('jupyter-notebook:run-all-cells-above', event, env);
93+
env.notebook.edit_mode();
94+
}
95+
}, 'run-all-cells-above', 'vim-binding');
96+
97+
actions.register({
98+
'handler': function(env, event) {
99+
env.notebook.command_mode();
100+
actions.call('jupyter-notebook:run-all-cells-below', event, env);
101+
env.notebook.edit_mode();
102+
}
103+
}, 'run-all-cells-below', 'vim-binding');
104+
52105
// vin-binding original actions (Command mode)
53106
actions.register({
54107
'help': 'scroll notebook up',

lib/jupyter/notebook.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ define([
3434
return Original.handle_command_mode.apply(this, arguments);
3535
};
3636
Notebook.prototype.handle_edit_mode = function handle_edit_mode(cell) {
37-
if (cell.code_mirror && was_in_insert_before_blur) {
37+
if (cell.code_mirror && !was_in_insert_before_blur) {
3838
cell.code_mirror.leaveInsertMode();
3939
}
4040
was_in_insert_before_blur = false;

0 commit comments

Comments
 (0)