forked from neomantra/lua_ipython_kernel
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Heartbeat is executed in an independent thread, out cells can be high…
…lighted when its html element has id=ipylua_static_code
- Loading branch information
Showing
4 changed files
with
123 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* disable smoothing on images (needed to visualize filters) */ | ||
img { | ||
image-rendering: optimizeSpeed; | ||
image-rendering: -moz-crisp-edges; /* Firefox */ | ||
image-rendering: -o-crisp-edges; /* Opera */ | ||
image-rendering: -webkit-optimize-contrast; /* Chrome (and eventually Safari) */ | ||
image-rendering: optimize-contrast; /* CSS3 Proposed */ | ||
-ms-interpolation-mode: nearest-neighbor; /* IE8+ */ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
function checkDOMChange() { | ||
$("#ipylua_static_code").each( | ||
function() { | ||
var $this = $(this), | ||
$code = $this.html(); | ||
$this.empty(); | ||
var myCodeMirror = CodeMirror(this, { | ||
value: $code, | ||
mode: 'lua', | ||
lineNumbers: false, | ||
readOnly: true | ||
}); | ||
}).attr("id", "highlighted_ipylua_static_code"); | ||
setTimeout( checkDOMChange, 500 ); | ||
} | ||
checkDOMChange(); | ||
|
||
$([IPython.events]).on('notebook_loaded.Notebook', function(){ | ||
// add here logic that should be run once per **notebook load** | ||
// (!= page load), like restarting a checkpoint | ||
var md = IPython.notebook.metadata | ||
if(md.language){ | ||
console.log('language already defined and is :', md.language); | ||
} else { | ||
md.language = 'lua' ; | ||
console.log('add metadata hint that language is lua'); | ||
} | ||
}); | ||
|
||
// logic per page-refresh | ||
$([IPython.events]).on("app_initialized.NotebookApp", function () { | ||
$('head').append('<link rel="stylesheet" type="text/css" href="custom.css">'); | ||
|
||
|
||
IPython.CodeCell.options_default['cm_config']['mode'] = 'lua'; | ||
|
||
CodeMirror.requireMode('lua', function() { | ||
IPython.OutputArea.prototype._should_scroll = function(){return false} | ||
cells = IPython.notebook.get_cells(); | ||
for(var i in cells){ | ||
c = cells[i]; | ||
if (c.cell_type === 'code') { | ||
c.auto_highlight() | ||
} | ||
} | ||
}); | ||
}); |