Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding toggle line numbers for all cells #1312

Merged
merged 1 commit into from
Aug 16, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions notebook/static/notebook/js/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,14 @@ define(function(require){
env.notebook.show_command_palette();
}
},
'toggle-all-line-numbers': {
help : 'toggles line numbers in all cells',
icon: 'fa-list-ol',
handler: function(env) {
console.log('calling function');
env.notebook.toggle_all_line_numbers();
}
},
'toggle-toolbar':{
help: 'hide/show the toolbar',
handler : function(env){
Expand Down
1 change: 1 addition & 0 deletions notebook/static/notebook/js/keyboardmanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ define([
'o' : 'jupyter-notebook:toggle-cell-output-collapsed',
's' : 'jupyter-notebook:save-notebook',
'l' : 'jupyter-notebook:toggle-cell-line-numbers',
'shift-l' : 'jupyter-notebook:toggle-all-line-numbers',
'h' : 'jupyter-notebook:show-keyboard-shortcuts',
'z' : 'jupyter-notebook:undo-cell-deletion',
'q' : 'jupyter-notebook:close-pager',
Expand Down
1 change: 1 addition & 0 deletions notebook/static/notebook/js/maintoolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ define([
'run_int'],
['<add_celltype_list>'],
[['jupyter-notebook:show-command-palette']],
[['jupyter-notebook:toggle-all-line-numbers']],
['<add_celltoolbar_reminder>']
];
this.construct(grps);
Expand Down
12 changes: 12 additions & 0 deletions notebook/static/notebook/js/notebook.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ define(function (require) {
this.ws_url = options.ws_url;
this._session_starting = false;
this.last_modified = null;
this.line_numbers = false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I would make that private with a leading underscore, so that we can change the implementation easily.

// debug 484
this._last_modified = 'init';
// Firefox workaround
Expand Down Expand Up @@ -552,6 +553,17 @@ define(function (require) {
}
return result;
};

/**
* Toggles the display of line numbers in all cells.
*/
Notebook.prototype.toggle_all_line_numbers = function () {
this.line_numbers = !this.line_numbers;
var display = this.line_numbers;
this.get_cells().map(function(c) {
c.code_mirror.setOption('lineNumbers', display);
})
}

/**
* Get the cell above a given cell.
Expand Down