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
Jump to file or symbol
Failed to load files and symbols.
+22 −0
Diff settings

Always

Just for now

@@ -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){
@@ -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',
@@ -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);
@@ -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;

This comment has been minimized.

@Carreau

Carreau Apr 7, 2016

Member

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

@Carreau

Carreau Apr 7, 2016

Member

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
@@ -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.
ProTip! Use n and p to navigate between commits in a pull request.