Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
gargantext-ihaskell
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
gargantext-ihaskell
Commits
e193ee47
Commit
e193ee47
authored
Mar 19, 2014
by
Andrew Gibiansky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
First widget is done displaying!
parent
9de53030
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
244 additions
and
541 deletions
+244
-541
Test.ipynb
notebooks/Test.ipynb
+239
-15
custom.js
profile/static/custom/custom.js
+3
-0
codecell.js
profile/static/notebook/js/codecell.js
+0
-525
IPython.hs
src/IHaskell/IPython.hs
+1
-1
Types.hs
src/IHaskell/Types.hs
+1
-0
No files found.
notebooks/Test.ipynb
View file @
e193ee47
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
"metadata": {
"metadata": {
"language": "haskell",
"language": "haskell",
"name": "",
"name": "",
"signature": "sha256:7
873a6c9359f5b20e15e69afed5eebbaf984eaad2c41d5917c94c263fa2baef4
"
"signature": "sha256:7
e43374dff63c0e988f7702540c64afb3ef4237a5d2d32bf7f2782b0dd23a68f
"
},
},
"nbformat": 3,
"nbformat": 3,
"nbformat_minor": 0,
"nbformat_minor": 0,
...
@@ -13,18 +13,7 @@
...
@@ -13,18 +13,7 @@
"cell_type": "code",
"cell_type": "code",
"collapsed": false,
"collapsed": false,
"input": [
"input": [
"import IHaskell.Display\n",
"import IHaskell.Widgets"
"\n",
"-- My widget type\n",
"data Slider = Slider\n",
"\n",
"instance IHaskellDisplay Slider where\n",
" display Slider = return $ Display []\n",
" \n",
"instance IHaskellWidget Slider where\n",
" targetName _ = \"WidgetModel\"\n",
" open _ s = s undefined >> error \"what\"\n",
" "
],
],
"language": "python",
"language": "python",
"metadata": {},
"metadata": {},
...
@@ -89,7 +78,7 @@
...
@@ -89,7 +78,7 @@
"language": "python",
"language": "python",
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [],
"prompt_number":
1
"prompt_number":
5
},
},
{
{
"cell_type": "code",
"cell_type": "code",
...
@@ -194,7 +183,242 @@
...
@@ -194,7 +183,242 @@
"output_type": "display_data"
"output_type": "display_data"
}
}
],
],
"prompt_number": 2
"prompt_number": 6
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"float"
],
"language": "python",
"metadata": {},
"outputs": [
{
"html": [
"<!-- CodeMirror component -->\n",
"<link rel=\"stylesheet\" href=\"/static/components/codemirror/addon/lint/lint.css\">\n",
"<script src=\"/static/components/codemirror/addon/lint/lint.js\" charset=\"utf-8\"></script>\n",
"\n",
"<!-- Parsec widget -->\n",
"<script>\n",
"// Only load this script once.\n",
"var kernel = IPython.notebook.kernel;\n",
"var initialized = kernel !== undefined && kernel != null;\n",
"if (initialized && window.parsecWidgetRegistered === undefined) {\n",
"\n",
"// Do not load this script again.\n",
"window.parsecWidgetRegistered = true;\n",
"\n",
"// Register the comm target.\n",
"var ParsecWidget = function (comm) {\n",
" this.comm = comm;\n",
" this.comm.on_msg($.proxy(this.handler, this));\n",
"\n",
" // Get the cell that was probably executed.\n",
" // The msg_id:cell mapping will make this possible without guessing.\n",
" this.cell = IPython.notebook.get_cell(IPython.notebook.get_selected_index()-1);\n",
"\n",
" // Store this widget so we can use it from callbacks.\n",
" var widget = this;\n",
"\n",
" // Editor options.\n",
" var options = {\n",
" lineNumbers: true,\n",
" // Show parsec errors as lint errors.\n",
" gutters: [\"CodeMirror-lint-markers\"],\n",
" lintWith: {\n",
" \"getAnnotations\": function(cm, update, opts) {\n",
" var errs = [];\n",
" if (widget.hasError) {\n",
" var col = widget.error[\"col\"];\n",
" var line = widget.error[\"line\"];\n",
" errs = [{\n",
" from: CodeMirror.Pos(line - 1, col - 1),\n",
" to: CodeMirror.Pos(line - 1, col),\n",
" message: widget.error[\"msg\"],\n",
" severity: \"error\"\n",
" }];\n",
" }\n",
" update(cm, errs);\n",
" },\n",
" \"async\": true,\n",
" }\n",
" };\n",
"\n",
" // Create the editor.\n",
" var out = this.cell.output_area.element;\n",
" this.textarea = out.find(\"#parsec-editor\")[0];\n",
" this.output = out.find(\"#parsec-output\")[0];\n",
"\n",
" var editor = CodeMirror.fromTextArea(this.textarea, options);\n",
" var editor = editor;\n",
"\n",
" // Update every key press.\n",
" editor.on(\"keyup\", function() {\n",
" var text = editor.getDoc().getValue();\n",
" comm.send({\"text\": text});\n",
" });\n",
"};\n",
"\n",
"ParsecWidget.prototype.handler = function(msg) {\n",
" var data = msg.content.data;\n",
" this.hasError = data[\"status\"] == \"error\";\n",
" if (this.hasError) {\n",
" out = data[\"msg\"];\n",
" this.error = data;\n",
" } else {\n",
" out = data[\"result\"];\n",
" }\n",
" // Update viewed output.\n",
" this.output.innerHTML = out;\n",
"};\n",
"\n",
"// Register this widget.\n",
"IPython.notebook.kernel.comm_manager.register_target('parsec', IPython.utils.always_new(ParsecWidget));\n",
"console.log(\"Registering Parsec widget.\");\n",
"}\n",
"</script>\n",
"\n",
"<!-- Parsec widget DOM -->\n",
"<form><textarea id=\"parsec-editor\">Insert parser text here...</textarea></form>\n",
"<pre id=\"parsec-output\"></pre>\n"
],
"metadata": {},
"output_type": "display_data"
}
],
"prompt_number": 7
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"data Thing = Thing Int deriving Show"
],
"language": "python",
"metadata": {},
"outputs": []
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"thing :: Parser Thing\n",
"thing = do\n",
" xs <- many $ oneOf \"x\"\n",
" eof\n",
" return $ Thing $ length xs"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 11
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"thing"
],
"language": "python",
"metadata": {},
"outputs": [
{
"html": [
"<!-- CodeMirror component -->\n",
"<link rel=\"stylesheet\" href=\"/static/components/codemirror/addon/lint/lint.css\">\n",
"<script src=\"/static/components/codemirror/addon/lint/lint.js\" charset=\"utf-8\"></script>\n",
"\n",
"<!-- Parsec widget -->\n",
"<script>\n",
"// Only load this script once.\n",
"var kernel = IPython.notebook.kernel;\n",
"var initialized = kernel !== undefined && kernel != null;\n",
"if (initialized && window.parsecWidgetRegistered === undefined) {\n",
"\n",
"// Do not load this script again.\n",
"window.parsecWidgetRegistered = true;\n",
"\n",
"// Register the comm target.\n",
"var ParsecWidget = function (comm) {\n",
" this.comm = comm;\n",
" this.comm.on_msg($.proxy(this.handler, this));\n",
"\n",
" // Get the cell that was probably executed.\n",
" // The msg_id:cell mapping will make this possible without guessing.\n",
" this.cell = IPython.notebook.get_cell(IPython.notebook.get_selected_index()-1);\n",
"\n",
" // Store this widget so we can use it from callbacks.\n",
" var widget = this;\n",
"\n",
" // Editor options.\n",
" var options = {\n",
" lineNumbers: true,\n",
" // Show parsec errors as lint errors.\n",
" gutters: [\"CodeMirror-lint-markers\"],\n",
" lintWith: {\n",
" \"getAnnotations\": function(cm, update, opts) {\n",
" var errs = [];\n",
" if (widget.hasError) {\n",
" var col = widget.error[\"col\"];\n",
" var line = widget.error[\"line\"];\n",
" errs = [{\n",
" from: CodeMirror.Pos(line - 1, col - 1),\n",
" to: CodeMirror.Pos(line - 1, col),\n",
" message: widget.error[\"msg\"],\n",
" severity: \"error\"\n",
" }];\n",
" }\n",
" update(cm, errs);\n",
" },\n",
" \"async\": true,\n",
" }\n",
" };\n",
"\n",
" // Create the editor.\n",
" var out = this.cell.output_area.element;\n",
" this.textarea = out.find(\"#parsec-editor\")[0];\n",
" this.output = out.find(\"#parsec-output\")[0];\n",
"\n",
" var editor = CodeMirror.fromTextArea(this.textarea, options);\n",
" var editor = editor;\n",
"\n",
" // Update every key press.\n",
" editor.on(\"keyup\", function() {\n",
" var text = editor.getDoc().getValue();\n",
" comm.send({\"text\": text});\n",
" });\n",
"};\n",
"\n",
"ParsecWidget.prototype.handler = function(msg) {\n",
" var data = msg.content.data;\n",
" this.hasError = data[\"status\"] == \"error\";\n",
" if (this.hasError) {\n",
" out = data[\"msg\"];\n",
" this.error = data;\n",
" } else {\n",
" out = data[\"result\"];\n",
" }\n",
" // Update viewed output.\n",
" this.output.innerHTML = out;\n",
"};\n",
"\n",
"// Register this widget.\n",
"IPython.notebook.kernel.comm_manager.register_target('parsec', IPython.utils.always_new(ParsecWidget));\n",
"console.log(\"Registering Parsec widget.\");\n",
"}\n",
"</script>\n",
"\n",
"<!-- Parsec widget DOM -->\n",
"<form><textarea id=\"parsec-editor\">Insert parser text here...</textarea></form>\n",
"<pre id=\"parsec-output\"></pre>\n"
],
"metadata": {},
"output_type": "display_data"
}
],
"prompt_number": 12
},
},
{
{
"cell_type": "code",
"cell_type": "code",
...
...
profile/static/custom/custom.js
View file @
e193ee47
...
@@ -18,6 +18,9 @@ $([IPython.events]).on('app_initialized.NotebookApp', function(){
...
@@ -18,6 +18,9 @@ $([IPython.events]).on('app_initialized.NotebookApp', function(){
// Set tooltips to be triggered after 800ms
// Set tooltips to be triggered after 800ms
IPython
.
tooltip
.
time_before_tooltip
=
800
;
IPython
.
tooltip
.
time_before_tooltip
=
800
;
// IPython keycodes.
IPython
.
keyboard
.
keycodes
.
down
=
32
;
// space
CodeMirror
.
requireMode
(
'haskell'
,
function
(){
CodeMirror
.
requireMode
(
'haskell'
,
function
(){
// Create a multiplexing mode that uses Haskell highlighting by default but
// Create a multiplexing mode that uses Haskell highlighting by default but
...
...
profile/static/notebook/js/codecell.js
deleted
100644 → 0
View file @
9de53030
//----------------------------------------------------------------------------
// Copyright (C) 2008-2011 The IPython Development Team
//
// Distributed under the terms of the BSD License. The full license is in
// the file COPYING, distributed as part of this software.
//----------------------------------------------------------------------------
//============================================================================
// CodeCell
//============================================================================
/**
* An extendable module that provide base functionnality to create cell for notebook.
* @module IPython
* @namespace IPython
* @submodule CodeCell
*/
/* local util for codemirror */
var
posEq
=
function
(
a
,
b
)
{
return
a
.
line
==
b
.
line
&&
a
.
ch
==
b
.
ch
;};
/**
*
* function to delete until previous non blanking space character
* or first multiple of 4 tabstop.
* @private
*/
CodeMirror
.
commands
.
delSpaceToPrevTabStop
=
function
(
cm
){
var
from
=
cm
.
getCursor
(
true
),
to
=
cm
.
getCursor
(
false
),
sel
=
!
posEq
(
from
,
to
);
if
(
!
posEq
(
from
,
to
))
{
cm
.
replaceRange
(
""
,
from
,
to
);
return
;
}
var
cur
=
cm
.
getCursor
(),
line
=
cm
.
getLine
(
cur
.
line
);
var
tabsize
=
cm
.
getOption
(
'tabSize'
);
var
chToPrevTabStop
=
cur
.
ch
-
(
Math
.
ceil
(
cur
.
ch
/
tabsize
)
-
1
)
*
tabsize
;
from
=
{
ch
:
cur
.
ch
-
chToPrevTabStop
,
line
:
cur
.
line
};
var
select
=
cm
.
getRange
(
from
,
cur
);
if
(
select
.
match
(
/^
\
+$/
)
!==
null
){
cm
.
replaceRange
(
""
,
from
,
cur
);
}
else
{
cm
.
deleteH
(
-
1
,
"char"
);
}
};
var
IPython
=
(
function
(
IPython
)
{
"use strict"
;
var
utils
=
IPython
.
utils
;
var
key
=
IPython
.
utils
.
keycodes
;
/**
* A Cell conceived to write code.
*
* The kernel doesn't have to be set at creation time, in that case
* it will be null and set_kernel has to be called later.
* @class CodeCell
* @extends IPython.Cell
*
* @constructor
* @param {Object|null} kernel
* @param {object|undefined} [options]
* @param [options.cm_config] {object} config to pass to CodeMirror
*/
var
CodeCell
=
function
(
kernel
,
options
)
{
this
.
kernel
=
kernel
||
null
;
this
.
collapsed
=
false
;
// create all attributed in constructor function
// even if null for V8 VM optimisation
this
.
input_prompt_number
=
null
;
this
.
celltoolbar
=
null
;
this
.
output_area
=
null
;
this
.
last_msg_id
=
null
;
this
.
completer
=
null
;
var
cm_overwrite_options
=
{
onKeyEvent
:
$
.
proxy
(
this
.
handle_keyevent
,
this
)
};
options
=
this
.
mergeopt
(
CodeCell
,
options
,
{
cm_config
:
cm_overwrite_options
});
IPython
.
Cell
.
apply
(
this
,[
options
]);
// Attributes we want to override in this subclass.
this
.
cell_type
=
"code"
;
var
that
=
this
;
this
.
element
.
focusout
(
function
()
{
that
.
auto_highlight
();
}
);
};
CodeCell
.
options_default
=
{
cm_config
:
{
extraKeys
:
{
"Tab"
:
"indentMore"
,
"Shift-Tab"
:
"indentLess"
,
"Backspace"
:
"delSpaceToPrevTabStop"
,
"Cmd-/"
:
"toggleComment"
,
"Ctrl-/"
:
"toggleComment"
},
mode
:
'ipython'
,
theme
:
'ipython'
,
matchBrackets
:
true
}
};
CodeCell
.
prototype
=
new
IPython
.
Cell
();
/**
* @method auto_highlight
*/
CodeCell
.
prototype
.
auto_highlight
=
function
()
{
this
.
_auto_highlight
(
IPython
.
config
.
cell_magic_highlight
);
};
/** @method create_element */
CodeCell
.
prototype
.
create_element
=
function
()
{
IPython
.
Cell
.
prototype
.
create_element
.
apply
(
this
,
arguments
);
var
cell
=
$
(
'<div></div>'
).
addClass
(
'cell border-box-sizing code_cell'
);
cell
.
attr
(
'tabindex'
,
'2'
);
var
input
=
$
(
'<div></div>'
).
addClass
(
'input'
);
var
prompt
=
$
(
'<div/>'
).
addClass
(
'prompt input_prompt'
);
var
inner_cell
=
$
(
'<div/>'
).
addClass
(
'inner_cell'
);
this
.
celltoolbar
=
new
IPython
.
CellToolbar
(
this
);
inner_cell
.
append
(
this
.
celltoolbar
.
element
);
var
input_area
=
$
(
'<div/>'
).
addClass
(
'input_area'
);
this
.
code_mirror
=
CodeMirror
(
input_area
.
get
(
0
),
this
.
cm_config
);
$
(
this
.
code_mirror
.
getInputField
()).
attr
(
"spellcheck"
,
"false"
);
inner_cell
.
append
(
input_area
);
input
.
append
(
prompt
).
append
(
inner_cell
);
var
output
=
$
(
'<div></div>'
);
cell
.
append
(
input
).
append
(
output
);
this
.
element
=
cell
;
this
.
output_area
=
new
IPython
.
OutputArea
(
output
,
true
);
this
.
completer
=
new
IPython
.
Completer
(
this
);
};
/** @method bind_events */
CodeCell
.
prototype
.
bind_events
=
function
()
{
IPython
.
Cell
.
prototype
.
bind_events
.
apply
(
this
);
var
that
=
this
;
this
.
element
.
focusout
(
function
()
{
that
.
auto_highlight
();
}
);
};
CodeCell
.
prototype
.
handle_keyevent
=
function
(
editor
,
event
)
{
// console.log('CM', this.mode, event.which, event.type)
if
(
this
.
mode
===
'command'
)
{
return
true
;
}
else
if
(
this
.
mode
===
'edit'
)
{
return
this
.
handle_codemirror_keyevent
(
editor
,
event
);
}
};
/**
* This method gets called in CodeMirror's onKeyDown/onKeyPress
* handlers and is used to provide custom key handling. Its return
* value is used to determine if CodeMirror should ignore the event:
* true = ignore, false = don't ignore.
* @method handle_codemirror_keyevent
*/
CodeCell
.
prototype
.
handle_codemirror_keyevent
=
function
(
editor
,
event
)
{
var
that
=
this
;
// whatever key is pressed, first, cancel the tooltip request before
// they are sent, and remove tooltip if any, except for tab again
var
tooltip_closed
=
null
;
if
(
event
.
type
===
'keydown'
&&
event
.
which
!=
key
.
TAB
)
{
tooltip_closed
=
IPython
.
tooltip
.
remove_and_cancel_tooltip
();
}
var
cur
=
editor
.
getCursor
();
if
(
event
.
keyCode
===
key
.
ENTER
){
this
.
auto_highlight
();
}
if
(
event
.
keyCode
===
key
.
ENTER
&&
(
event
.
shiftKey
||
event
.
ctrlKey
||
event
.
altKey
))
{
// Always ignore shift-enter in CodeMirror as we handle it.
return
true
;
}
else
if
(
event
.
which
===
32
&&
event
.
type
===
'keypress'
&&
IPython
.
tooltip
.
time_before_tooltip
>=
0
)
{
// triger on keypress (!) otherwise inconsistent event.which depending on plateform
// browser and keyboard layout !
// Pressing space , request tooltip, don't forget to reappend it
// The second argument says to hide the tooltip if the docstring
// is actually empty
IPython
.
tooltip
.
pending
(
that
,
true
);
}
else
if
(
event
.
which
===
key
.
UPARROW
&&
event
.
type
===
'keydown'
)
{
// If we are not at the top, let CM handle the up arrow and
// prevent the global keydown handler from handling it.
if
(
!
that
.
at_top
())
{
event
.
stop
();
return
false
;
}
else
{
return
true
;
}
}
else
if
(
event
.
which
===
key
.
ESC
&&
event
.
type
===
'keydown'
)
{
// First see if the tooltip is active and if so cancel it.
if
(
tooltip_closed
)
{
// The call to remove_and_cancel_tooltip above in L177 doesn't pass
// force=true. Because of this it won't actually close the tooltip
// if it is in sticky mode. Thus, we have to check again if it is open
// and close it with force=true.
if
(
!
IPython
.
tooltip
.
_hidden
)
{
IPython
.
tooltip
.
remove_and_cancel_tooltip
(
true
);
}
// If we closed the tooltip, don't let CM or the global handlers
// handle this event.
event
.
stop
();
return
true
;
}
if
(
that
.
code_mirror
.
options
.
keyMap
===
"vim-insert"
)
{
// vim keyMap is active and in insert mode. In this case we leave vim
// insert mode, but remain in notebook edit mode.
// Let' CM handle this event and prevent global handling.
event
.
stop
();
return
false
;
}
else
{
// vim keyMap is not active. Leave notebook edit mode.
// Don't let CM handle the event, defer to global handling.
return
true
;
}
}
else
if
(
event
.
which
===
key
.
DOWNARROW
&&
event
.
type
===
'keydown'
)
{
// If we are not at the bottom, let CM handle the down arrow and
// prevent the global keydown handler from handling it.
if
(
!
that
.
at_bottom
())
{
event
.
stop
();
return
false
;
}
else
{
return
true
;
}
}
else
if
(
event
.
keyCode
===
key
.
TAB
&&
event
.
type
===
'keydown'
&&
event
.
shiftKey
)
{
if
(
editor
.
somethingSelected
()){
var
anchor
=
editor
.
getCursor
(
"anchor"
);
var
head
=
editor
.
getCursor
(
"head"
);
if
(
anchor
.
line
!=
head
.
line
){
return
false
;
}
}
IPython
.
tooltip
.
request
(
that
);
event
.
stop
();
return
true
;
}
else
if
(
event
.
keyCode
===
key
.
TAB
&&
event
.
type
==
'keydown'
)
{
// Tab completion.
IPython
.
tooltip
.
remove_and_cancel_tooltip
();
if
(
editor
.
somethingSelected
())
{
return
false
;
}
var
pre_cursor
=
editor
.
getRange
({
line
:
cur
.
line
,
ch
:
0
},
cur
);
if
(
pre_cursor
.
trim
()
===
""
)
{
// Don't autocomplete if the part of the line before the cursor
// is empty. In this case, let CodeMirror handle indentation.
return
false
;
}
else
{
event
.
stop
();
this
.
completer
.
startCompletion
();
return
true
;
}
}
else
{
// keypress/keyup also trigger on TAB press, and we don't want to
// use those to disable tab completion.
return
false
;
}
return
false
;
};
// Kernel related calls.
CodeCell
.
prototype
.
set_kernel
=
function
(
kernel
)
{
this
.
kernel
=
kernel
;
};
/**
* Execute current code cell to the kernel
* @method execute
*/
CodeCell
.
prototype
.
execute
=
function
()
{
this
.
output_area
.
clear_output
();
this
.
set_input_prompt
(
'*'
);
this
.
element
.
addClass
(
"running"
);
if
(
this
.
last_msg_id
)
{
this
.
kernel
.
clear_callbacks_for_msg
(
this
.
last_msg_id
);
}
var
callbacks
=
this
.
get_callbacks
();
this
.
last_msg_id
=
this
.
kernel
.
execute
(
this
.
get_text
(),
callbacks
,
{
silent
:
false
,
store_history
:
true
});
};
/**
* Construct the default callbacks for
* @method get_callbacks
*/
CodeCell
.
prototype
.
get_callbacks
=
function
()
{
return
{
shell
:
{
reply
:
$
.
proxy
(
this
.
_handle_execute_reply
,
this
),
payload
:
{
set_next_input
:
$
.
proxy
(
this
.
_handle_set_next_input
,
this
),
page
:
$
.
proxy
(
this
.
_open_with_pager
,
this
)
}
},
iopub
:
{
output
:
$
.
proxy
(
this
.
output_area
.
handle_output
,
this
.
output_area
),
clear_output
:
$
.
proxy
(
this
.
output_area
.
handle_clear_output
,
this
.
output_area
),
},
input
:
$
.
proxy
(
this
.
_handle_input_request
,
this
)
};
};
CodeCell
.
prototype
.
_open_with_pager
=
function
(
payload
)
{
$
([
IPython
.
events
]).
trigger
(
'open_with_text.Pager'
,
payload
);
};
/**
* @method _handle_execute_reply
* @private
*/
CodeCell
.
prototype
.
_handle_execute_reply
=
function
(
msg
)
{
this
.
set_input_prompt
(
msg
.
content
.
execution_count
);
this
.
element
.
removeClass
(
"running"
);
$
([
IPython
.
events
]).
trigger
(
'set_dirty.Notebook'
,
{
value
:
true
});
};
/**
* @method _handle_set_next_input
* @private
*/
CodeCell
.
prototype
.
_handle_set_next_input
=
function
(
payload
)
{
var
data
=
{
'cell'
:
this
,
'text'
:
payload
.
text
};
$
([
IPython
.
events
]).
trigger
(
'set_next_input.Notebook'
,
data
);
};
/**
* @method _handle_input_request
* @private
*/
CodeCell
.
prototype
.
_handle_input_request
=
function
(
msg
)
{
this
.
output_area
.
append_raw_input
(
msg
);
};
// Basic cell manipulation.
CodeCell
.
prototype
.
select
=
function
()
{
var
cont
=
IPython
.
Cell
.
prototype
.
select
.
apply
(
this
);
if
(
cont
)
{
this
.
code_mirror
.
refresh
();
this
.
auto_highlight
();
}
return
cont
;
};
CodeCell
.
prototype
.
render
=
function
()
{
var
cont
=
IPython
.
Cell
.
prototype
.
render
.
apply
(
this
);
// Always execute, even if we are already in the rendered state
return
cont
;
};
CodeCell
.
prototype
.
unrender
=
function
()
{
// CodeCell is always rendered
return
false
;
};
CodeCell
.
prototype
.
edit_mode
=
function
()
{
var
cont
=
IPython
.
Cell
.
prototype
.
edit_mode
.
apply
(
this
);
if
(
cont
)
{
this
.
focus_editor
();
}
return
cont
;
}
CodeCell
.
prototype
.
select_all
=
function
()
{
var
start
=
{
line
:
0
,
ch
:
0
};
var
nlines
=
this
.
code_mirror
.
lineCount
();
var
last_line
=
this
.
code_mirror
.
getLine
(
nlines
-
1
);
var
end
=
{
line
:
nlines
-
1
,
ch
:
last_line
.
length
};
this
.
code_mirror
.
setSelection
(
start
,
end
);
};
CodeCell
.
prototype
.
collapse
=
function
()
{
this
.
collapsed
=
true
;
this
.
output_area
.
collapse
();
};
CodeCell
.
prototype
.
expand
=
function
()
{
this
.
collapsed
=
false
;
this
.
output_area
.
expand
();
};
CodeCell
.
prototype
.
toggle_output
=
function
()
{
this
.
collapsed
=
Boolean
(
1
-
this
.
collapsed
);
this
.
output_area
.
toggle_output
();
};
CodeCell
.
prototype
.
toggle_output_scroll
=
function
()
{
this
.
output_area
.
toggle_scroll
();
};
CodeCell
.
input_prompt_classical
=
function
(
prompt_value
,
lines_number
)
{
var
ns
=
prompt_value
||
" "
;
return
'In ['
+
ns
+
']:'
;
};
CodeCell
.
input_prompt_continuation
=
function
(
prompt_value
,
lines_number
)
{
var
html
=
[
CodeCell
.
input_prompt_classical
(
prompt_value
,
lines_number
)];
for
(
var
i
=
1
;
i
<
lines_number
;
i
++
)
{
html
.
push
([
'...:'
]);
}
return
html
.
join
(
'<br/>'
);
};
CodeCell
.
input_prompt_function
=
CodeCell
.
input_prompt_classical
;
CodeCell
.
prototype
.
set_input_prompt
=
function
(
number
)
{
var
nline
=
1
;
if
(
this
.
code_mirror
!==
undefined
)
{
nline
=
this
.
code_mirror
.
lineCount
();
}
this
.
input_prompt_number
=
number
;
var
prompt_html
=
CodeCell
.
input_prompt_function
(
this
.
input_prompt_number
,
nline
);
this
.
element
.
find
(
'div.input_prompt'
).
html
(
prompt_html
);
};
CodeCell
.
prototype
.
clear_input
=
function
()
{
this
.
code_mirror
.
setValue
(
''
);
};
CodeCell
.
prototype
.
get_text
=
function
()
{
return
this
.
code_mirror
.
getValue
();
};
CodeCell
.
prototype
.
set_text
=
function
(
code
)
{
return
this
.
code_mirror
.
setValue
(
code
);
};
CodeCell
.
prototype
.
at_top
=
function
()
{
var
cursor
=
this
.
code_mirror
.
getCursor
();
if
(
cursor
.
line
===
0
&&
cursor
.
ch
===
0
)
{
return
true
;
}
else
{
return
false
;
}
};
CodeCell
.
prototype
.
at_bottom
=
function
()
{
var
cursor
=
this
.
code_mirror
.
getCursor
();
if
(
cursor
.
line
===
(
this
.
code_mirror
.
lineCount
()
-
1
)
&&
cursor
.
ch
===
this
.
code_mirror
.
getLine
(
cursor
.
line
).
length
)
{
return
true
;
}
else
{
return
false
;
}
};
CodeCell
.
prototype
.
clear_output
=
function
(
wait
)
{
this
.
output_area
.
clear_output
(
wait
);
};
// JSON serialization
CodeCell
.
prototype
.
fromJSON
=
function
(
data
)
{
IPython
.
Cell
.
prototype
.
fromJSON
.
apply
(
this
,
arguments
);
if
(
data
.
cell_type
===
'code'
)
{
if
(
data
.
input
!==
undefined
)
{
this
.
set_text
(
data
.
input
);
// make this value the starting point, so that we can only undo
// to this state, instead of a blank cell
this
.
code_mirror
.
clearHistory
();
this
.
auto_highlight
();
}
if
(
data
.
prompt_number
!==
undefined
)
{
this
.
set_input_prompt
(
data
.
prompt_number
);
}
else
{
this
.
set_input_prompt
();
}
this
.
output_area
.
fromJSON
(
data
.
outputs
);
if
(
data
.
collapsed
!==
undefined
)
{
if
(
data
.
collapsed
)
{
this
.
collapse
();
}
else
{
this
.
expand
();
}
}
}
};
CodeCell
.
prototype
.
toJSON
=
function
()
{
var
data
=
IPython
.
Cell
.
prototype
.
toJSON
.
apply
(
this
);
data
.
input
=
this
.
get_text
();
// is finite protect against undefined and '*' value
if
(
isFinite
(
this
.
input_prompt_number
))
{
data
.
prompt_number
=
this
.
input_prompt_number
;
}
var
outputs
=
this
.
output_area
.
toJSON
();
data
.
outputs
=
outputs
;
data
.
language
=
'python'
;
data
.
collapsed
=
this
.
collapsed
;
return
data
;
};
IPython
.
CodeCell
=
CodeCell
;
return
IPython
;
}(
IPython
));
src/IHaskell/IPython.hs
View file @
e193ee47
...
@@ -42,7 +42,7 @@ data WhichIPython
...
@@ -42,7 +42,7 @@ data WhichIPython
-- | Which commit of IPython we are on.
-- | Which commit of IPython we are on.
ipythonCommit
::
Text
ipythonCommit
::
Text
ipythonCommit
=
"
4a08574f74201ef7ca39a4e80d19a2d158ab6950
"
ipythonCommit
=
"
9c1c7a7e32118942a06eb39909c942e628090c14
"
-- | The IPython profile name.
-- | The IPython profile name.
ipythonProfile
::
String
ipythonProfile
::
String
...
...
src/IHaskell/Types.hs
View file @
e193ee47
...
@@ -115,6 +115,7 @@ instance IHaskellDisplay Widget where
...
@@ -115,6 +115,7 @@ instance IHaskellDisplay Widget where
instance
IHaskellWidget
Widget
where
instance
IHaskellWidget
Widget
where
targetName
(
Widget
widget
)
=
targetName
widget
targetName
(
Widget
widget
)
=
targetName
widget
open
(
Widget
widget
)
=
open
widget
comm
(
Widget
widget
)
=
comm
widget
comm
(
Widget
widget
)
=
comm
widget
close
(
Widget
widget
)
=
close
widget
close
(
Widget
widget
)
=
close
widget
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment