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
3ca98642
Commit
3ca98642
authored
Mar 18, 2014
by
Andrew Gibiansky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
parsec working! all cleaned up
parent
f07febc3
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
269 additions
and
144 deletions
+269
-144
Parsec.hs
ihaskell-display/ihaskell-parsec/IHaskell/Display/Parsec.hs
+1
-6
widget.html
ihaskell-display/ihaskell-parsec/widget.html
+85
-0
Test.ipynb
notebooks/Test.ipynb
+183
-137
Main.hs
src/Main.hs
+0
-1
No files found.
ihaskell-display/ihaskell-parsec/IHaskell/Display/Parsec.hs
View file @
3ca98642
...
...
@@ -18,12 +18,7 @@ import IHaskell.Display
instance
Show
a
=>
IHaskellDisplay
(
Parser
a
)
where
display
renderable
=
return
$
Display
[
html
dom
]
where
dom
=
[
i
|
<script src="/static/components/codemirror/addon/lint/lint.js" charset="utf-8"></script>
<form><textarea id="parsec-editor">Insert parser text here...</textarea></form>
<pre id="parsec-output"></pre>
|]
dom
=
[
hereFile
|
widget.html
|]
-- | Text to parse.
data
ParseText
=
ParseText
String
...
...
ihaskell-display/ihaskell-parsec/widget.html
0 → 100644
View file @
3ca98642
<!-- CodeMirror component -->
<link
rel=
"stylesheet"
href=
"/static/components/codemirror/addon/lint/lint.css"
>
<script
src=
"/static/components/codemirror/addon/lint/lint.js"
charset=
"utf-8"
></script>
<!-- Parsec widget -->
<script>
console
.
log
(
"Registered: "
,
window
.
parsecWidgetRegistered
);
var
kernel
=
IPython
.
notebook
.
kernel
;
var
initialized
=
kernel
!==
undefined
&&
kernel
!=
null
;
if
(
initialized
&&
window
.
parsecWidgetRegistered
===
undefined
)
{
window
.
parsecWidgetRegistered
=
true
;
console
.
log
(
"Initializing Parsec widget."
);
// Register the comm target.
var
ParsecWidget
=
function
(
comm
)
{
this
.
comm
=
comm
;
this
.
comm
.
on_msg
(
$
.
proxy
(
this
.
handler
,
this
));
// Get the cell that was probably executed.
// The msg_id:cell mapping will make this possible without guessing.
this
.
cell
=
IPython
.
notebook
.
get_cell
(
IPython
.
notebook
.
get_selected_index
()
-
1
);
// Store this widget so we can use it from callbacks.
var
widget
=
this
;
// Editor options.
var
options
=
{
lineNumbers
:
true
,
// Show parsec errors as lint errors.
gutters
:
[
"CodeMirror-lint-markers"
],
lintWith
:
{
"getAnnotations"
:
function
(
cm
,
update
,
opts
)
{
var
errs
=
[];
if
(
widget
.
hasError
)
{
var
col
=
widget
.
error
[
"col"
];
var
line
=
widget
.
error
[
"line"
];
errs
=
[{
from
:
CodeMirror
.
Pos
(
line
-
1
,
col
-
1
),
to
:
CodeMirror
.
Pos
(
line
-
1
,
col
),
message
:
widget
.
error
[
"msg"
],
severity
:
"error"
}];
}
update
(
cm
,
errs
);
},
"async"
:
true
,
}
};
// Create the editor.
var
out
=
this
.
cell
.
output_area
.
element
;
this
.
textarea
=
out
.
find
(
"#parsec-editor"
)[
0
];
this
.
output
=
out
.
find
(
"#parsec-output"
)[
0
];
var
editor
=
CodeMirror
.
fromTextArea
(
this
.
textarea
,
options
);
var
editor
=
editor
;
// Update every key press.
editor
.
on
(
"keyup"
,
function
()
{
var
text
=
editor
.
getDoc
().
getValue
();
comm
.
send
({
"text"
:
text
});
});
};
ParsecWidget
.
prototype
.
handler
=
function
(
msg
)
{
var
data
=
msg
.
content
.
data
;
this
.
hasError
=
data
[
"status"
]
==
"error"
;
if
(
this
.
hasError
)
{
out
=
data
[
"msg"
];
this
.
error
=
data
;
}
else
{
out
=
data
[
"result"
];
}
// Update viewed output.
this
.
output
.
innerHTML
=
out
;
};
// Register this widget.
IPython
.
notebook
.
kernel
.
comm_manager
.
register_target
(
'parsec'
,
IPython
.
utils
.
always_new
(
ParsecWidget
));
console
.
log
(
"Registering parsec widget."
);
}
</script>
<!-- Parsec widget DOM -->
<form><textarea
id=
"parsec-editor"
>
Insert parser text here...
</textarea></form>
<pre
id=
"parsec-output"
></pre>
notebooks/Test.ipynb
View file @
3ca98642
This diff is collapsed.
Click to expand it.
src/Main.hs
View file @
3ca98642
...
...
@@ -374,7 +374,6 @@ replyTo _ ObjectInfoRequest{objectName = oname} replyHeader state = do
handleComm
::
(
Message
->
IO
()
)
->
KernelState
->
Message
->
MessageHeader
->
IO
KernelState
handleComm
replier
kernelState
req
replyHeader
=
do
print
req
let
widgets
=
openComms
kernelState
uuid
=
commUuid
req
dat
=
commData
req
...
...
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