Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
9612a03
Fixed IntelliSense and syntax highlighting
Oct 20, 2015
d401422
Added git-excluded files
Oct 20, 2015
98d8ce8
Added missing file
Oct 20, 2015
62c7162
Implemented message signing
Oct 20, 2015
af8b6a5
Proper handling of unsigned messages.
Oct 20, 2015
6db4242
linux kernel spec paths corrected
npmurphy Oct 20, 2015
199454f
merging with master
npmurphy Oct 20, 2015
ff83e69
remove old 0zmq comment
npmurphy Oct 20, 2015
57e845f
Merge pull request #1 from npmurphy/filippo_fork
FilippoPolo Oct 21, 2015
ccc7345
Merge pull request #2 from npmurphy/merge_filippo_fork
FilippoPolo Oct 21, 2015
491edf0
Fixed automerge mistake
Oct 21, 2015
41b93bf
Added InspectRequest dummy implementation
Oct 27, 2015
d134d24
Added dummy answer to inspect_request
Oct 27, 2015
1e7d25f
Wrapped logging in an exception handler
Oct 28, 2015
479c618
Added GenericChartsWithSize, for outputting multiple charts.
Oct 28, 2015
d91f800
Extending MultiplePlots to use different numbers of columns
ndalchau Oct 30, 2015
bfedd74
Reverting to packages version of FSharp.Charting.
ndalchau Nov 4, 2015
6f8b84d
Added the ability to prepare temporary files to serve.
Nov 4, 2015
6a9130f
Added some helpers to allow arranging multiple images in an output.
Nov 4, 2015
93dd982
Added SVG moving and merging functions.
Nov 5, 2015
2c4bf70
NuGet package installation will now copy content files to a "content"…
Nov 5, 2015
b3bbeb0
Substitute in F# 3.1 for later versions
cgravill Dec 2, 2015
0ca6e27
Merge pull request #3 from cgravill/master
FilippoPolo Dec 2, 2015
e0637fa
Updated documentation file
Feb 5, 2016
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
5 changes: 3 additions & 2 deletions IfSharp.sln
Original file line numberDiff line numberDiff line change
Expand Up@@ -52,6 +52,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ipython-profile", "ipython-
ProjectSection(SolutionItems) = preProject
ipython-profile\static\custom\ifsharp_logo.png = ipython-profile\static\custom\ifsharp_logo.png
ipython-profile\ipython_config.py = ipython-profile\ipython_config.py
ipython-profile\ipython_qtconsole_config.py = ipython-profile\ipython_qtconsole_config.py
ipython-profile\kernel.js = ipython-profile\kernel.js
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IfSharpConsole", "src\IfSharpConsole\IfSharpConsole.csproj", "{6BD0E996-0AEE-4FC7-8FB9-46E033D0C7F1}"
Expand All@@ -60,8 +62,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "static", "static", "{45519D
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "custom", "custom", "{3AAFA64D-CBB6-488E-B395-6A1E7CB554CE}"
ProjectSection(SolutionItems) = preProject
ipython-profile\static\custom\custom.css = ipython-profile\static\custom\custom.css
ipython-profile\static\custom\custom.js = ipython-profile\static\custom\custom.js
ipython-profile\static\custom\fsharp.css = ipython-profile\static\custom\fsharp.css
ipython-profile\static\custom\fsharp.js = ipython-profile\static\custom\fsharp.js
ipython-profile\static\custom\ifsharp_logo.png = ipython-profile\static\custom\ifsharp_logo.png
ipython-profile\static\custom\webintellisense-codemirror.js = ipython-profile\static\custom\webintellisense-codemirror.js
Expand Down
43 changes: 25 additions & 18 deletions README.md
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,48 @@
# IfSharp
F# implementation for [iPython](http://ipython.org). View the [Feature Notebook](http://nbviewer.ipython.org/github/BayardRock/IfSharp/blob/master/Feature%20Notebook.ipynb) for some of the features that are included.
For more information view the [documenation](http://bayardrock.github.io/IfSharp/). IfSharp is 64-bit *ONLY*.
F# implementation for [Jupyter](http://jupyter.org/). View the [Feature Notebook](http://nbviewer.jupyter.org/github/fsprojects/IfSharp/blob/master/Feature%20Notebook.ipynb) for some of the features that are included.
For more information view the [documentation](http://fsprojects.github.io/IfSharp/). IfSharp is 64-bit *ONLY*.

# Compatibility
IfSharp works with iPython Notebook 1.x and 2.x
IfSharp works with Jupyter 4.0 and 4.1 and works with both Python 2.X and Python 3.X

# Automatic Installation
See our [release repository](https://github.com/BayardRock/IfSharp/releases). Also, [installation documentation](http://bayardrock.github.io/IfSharp/installation.html).
Previous releases for the IPython notebook are here: [release repository](https://github.com/fsprojects/IfSharp/releases).
Automatic installs for Jupyter will be provided in the future.

# Manual Installation
# Manual Installation (Windows)
1. Install [Anaconda](http://continuum.io/downloads)
2. Install [IPython](http://ipython.org/install.html)
3. Run: "ipython profile create ifsharp" in your user directory
4. Open the iF# solution file, restore nuget packages, and compile it
5. Copy the files from IfSharp\ipython-profile to the iFSharp profile directory
6. Open up the copied "ipython_config.py" file and replace "%s" with the path of your compiled ifsharp executable. E.g. "C:\\git\\ifsharp\\bin\\Release\\ifsharp.exe"
7. Run: "ipython notebook --profile ifsharp" to launch the notebook process with the F# kernel.
2. Install [Jupyter](http://jupyter.readthedocs.org/en/latest/install.html)
3. Checkout the repository
4. Open the IfSharp solution file, restore nuget packages, and compile it
5. Run the IfSharpConsole project, this will register IfSharp and launch Jupyter

Jupyter with IfSharp can be run via "jupyter notebook" in future

# Manual Installation (Mac)
TODO

# Manual Installation (Ubuntu)
TODO

# Screens
## Intellisense
![Intellisense Example #1](https://raw.github.com/BayardRock/IfSharp/master/docs/files/img/intellisense-1.png "Intellisense Example #1")
![Intellisense Example #1](/docs/files/img/intellisense-1.png?raw=true "Intellisense Example #1")
***

![Intellisense Example #2](https://raw.github.com/BayardRock/IfSharp/master/docs/files/img/intellisense-2.png "Intellisense Example #2")
![Intellisense Example #2](docs/files/img/intellisense-2.png?raw=true "Intellisense Example #2")
***

![Intellisense Example #3 With Chart](https://raw.github.com/BayardRock/IfSharp/master/docs/files/img/intellisense-3.png "Intellisense Example #3 With Chart")
![Intellisense Example #3 With Chart](docs/files/img/intellisense-3.png?raw=true "Intellisense Example #3 With Chart")
***

![Intellisense Example #4 #r Directive](https://raw.github.com/BayardRock/IfSharp/master/docs/files/img/intellisense-reference.gif "Intellisense Example #3 #r Directive")
![Intellisense Example #4 #r Directive](docs/files/img/intellisense-reference.gif?raw=true "Intellisense Example #3 #r Directive")
***

![Intellisense Example #5 #load Directive](https://raw.github.com/BayardRock/IfSharp/master/docs/files/img/intellisense-5.png "Intellisense Example #load Directive")
![Intellisense Example #5 #load Directive](docs/files/img/intellisense-5.png?raw=true "Intellisense Example #load Directive")
***

## Integrated NuGet
![NuGet Example](https://raw.github.com/BayardRock/IfSharp/master/docs/files/img/NuGet-1.png "NuGet example")
![NuGet Example](docs/files/img/NuGet-1.png?raw=true "NuGet example")

## Inline Error Messages
![Inline Error Message](https://raw.github.com/BayardRock/IfSharp/master/docs/files/img/errors-1.png "Inline error message")
![Inline Error Message](docs/files/img/errors-1.png?raw=true "Inline error message")
5 changes: 2 additions & 3 deletions ipython-profile/ipython_config.py
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
c = get_config()
c.KernelManager.kernel_spec = [r"%s", "{connection_file}"]
c.Session.key = b''
c.Session.keyfile = ''
c.KernelManager.kernel_spec = [ "mono", r"%kexe", "{connection_file}"]
c.NotebookApp.extra_static_paths = [ r"%kstatic" ]
164 changes: 164 additions & 0 deletions ipython-profile/kernel.js
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
define(function () {

var link = document.createElement("link");
link.type = "text/css";
link.rel = "stylesheet";
link.href = "/static/custom/fsharp.css";
document.getElementsByTagName("head")[0].appendChild(link);

require(['codemirror/addon/mode/loadmode']);

var onload = function () {

var md = IPython.notebook.metadata;
if (md.language) {
console.log('language already defined and is :', md.language);
}
else {
md.language = 'fsharp';
console.log('add metadata hint that language is fsharp...');
}

require(['/static/custom/fsharp.js']);

IPython.CodeCell.options_default.cm_config.mode = 'fsharp';

// callback called by the end-user
function updateMarkers(data) {
// applies intellisense hooks onto all cells
var cells = getCodeCells();
data.forEach(function (err) {
var cell = cells.cells[err.CellNumber]
var editor = cell.code_mirror;

// clear our error marks
editor.doc.getAllMarks()
.forEach(function (m) {
if (m.className === 'br-errormarker') {
m.clear();
}
});

var from = { line: err.StartLine, ch: err.StartColumn };
var to = { line: err.EndLine, ch: err.EndColumn };
editor.doc.markText(from, to, { title: err.Message, className: 'br-errormarker' });
});
}

function getCodeCells() {
var results = { codes: [], cells: [], selectedCell: null, selectedIndex: 0 };
IPython.notebook.get_cells()
.forEach(function (c) {
if (c.cell_type === 'code') {
if (c.selected === true) {
results.selectedCell = c;
results.selectedIndex = results.cells.length;
}
results.cells.push(c);
results.codes.push(c.code_mirror.getValue());
}
});

return results;
}

require(['/static/custom/webintellisense.js', '/static/custom/webintellisense-codemirror.js'], function () {
// applies intellisense hooks onto a cell
function applyIntellisense(cell) {
if (cell.cell_type !== 'code') { return; }

var editor = cell.code_mirror;
if (editor.intellisense == null) {
var intellisense = new CodeMirrorIntellisense(editor);
cell.force_highlight('fsharp');
cell.code_mirror.setOption('theme', 'neat');
editor.intellisense = intellisense;

intellisense.addDeclarationTrigger({ keyCode: 190 }); // `.`
intellisense.addDeclarationTrigger({ keyCode: 32, ctrlKey: true, preventDefault: true, type: 'down' }); // `ctrl+space`
intellisense.addDeclarationTrigger({ keyCode: 191 }); // `/`
intellisense.addDeclarationTrigger({ keyCode: 220 }); // `\`
intellisense.addDeclarationTrigger({ keyCode: 222 }); // `"`
intellisense.addDeclarationTrigger({ keyCode: 222, shiftKey: true }); // `"`
intellisense.addMethodsTrigger({ keyCode: 57, shiftKey: true }); // `(`
intellisense.addMethodsTrigger({ keyCode: 48, shiftKey: true });// `)`
intellisense.onMethod(function (item, position) {

});
intellisense.onDeclaration(function (item, position) {
var cells = getCodeCells();
var codes = cells.codes;
var cursor = cells.selectedCell.code_mirror.doc.getCursor();
var callbacks = { shell: {}, iopub: {} };
var line = editor.getLine(cursor.line);
var isSlash = item.keyCode === 191 || item.keyCode === 220;
var isQuote = item.keyCode === 222;

var isLoadOrRef = line.indexOf('#load') === 0
|| line.indexOf('#r') === 0;

var isStartLoadOrRef = line === '#load "'
|| line === '#r "'
|| line === '#load @"'
|| line === '#r @"';

if (isSlash && !isLoadOrRef) {
return;
}
if (isQuote && !isStartLoadOrRef) {
return;
}

// v2
callbacks.shell.reply = function (msg) {
intellisense.setDeclarations(msg.content.matches);
if (msg.content.filter_start_index)
intellisense.setStartColumnIndex(msg.content.filter_start_index);
};

callbacks.iopub.output = function (msg) {
updateMarkers(msg.content.data.errors);
};

// v1
callbacks.complete_reply = function (data) {
intellisense.setDeclarations(data.matches);
intellisense.setStartColumnIndex(data.filter_start_index);
};

callbacks.output = function (msgType, content, metadata) {
updateMarkers(content.data.errors);
};

var content = {
text: JSON.stringify(codes),
line: '',
block: JSON.stringify({ selectedIndex: cells.selectedIndex, ch: cursor.ch, line: cursor.line }),
cursor_pos: cursor.ch
};

IPython.notebook.kernel.send_shell_message("intellisense_request", content, callbacks, null, null);
});
}
}

// applies intellisense hooks onto all cells
IPython.notebook.get_cells()
.forEach(function (cell) {
applyIntellisense(cell);
});

// applies intellisense hooks onto cells that are selected
$([IPython.events]).on('create.Cell', function (event, data) {
applyIntellisense(data.cell);
});
});

// replace the image
var img = $('.container img')[0];
img.src = "/static/custom/ifsharp_logo.png";

}

return { onload: onload }
})
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
9612a03
Fixed IntelliSense and syntax highlighting
Oct 20, 2015
d401422
Added git-excluded files
Oct 20, 2015
98d8ce8
Added missing file
Oct 20, 2015
62c7162
Implemented message signing
Oct 20, 2015
af8b6a5
Proper handling of unsigned messages.
Oct 20, 2015
6db4242
linux kernel spec paths corrected
npmurphy Oct 20, 2015
199454f
merging with master
npmurphy Oct 20, 2015
ff83e69
remove old 0zmq comment
npmurphy Oct 20, 2015
57e845f
Merge pull request #1 from npmurphy/filippo_fork
FilippoPolo Oct 21, 2015
ccc7345
Merge pull request #2 from npmurphy/merge_filippo_fork
FilippoPolo Oct 21, 2015
491edf0
Fixed automerge mistake
Oct 21, 2015
41b93bf
Added InspectRequest dummy implementation
Oct 27, 2015
d134d24
Added dummy answer to inspect_request
Oct 27, 2015
1e7d25f
Wrapped logging in an exception handler
Oct 28, 2015
479c618
Added GenericChartsWithSize, for outputting multiple charts.
Oct 28, 2015
d91f800
Extending MultiplePlots to use different numbers of columns
ndalchau Oct 30, 2015
bfedd74
Reverting to packages version of FSharp.Charting.
ndalchau Nov 4, 2015
6f8b84d
Added the ability to prepare temporary files to serve.
Nov 4, 2015
6a9130f
Added some helpers to allow arranging multiple images in an output.
Nov 4, 2015
93dd982
Added SVG moving and merging functions.
Nov 5, 2015
2c4bf70
NuGet package installation will now copy content files to a "content"…
Nov 5, 2015
b3bbeb0
Substitute in F# 3.1 for later versions
cgravill Dec 2, 2015
0ca6e27
Merge pull request #3 from cgravill/master
FilippoPolo Dec 2, 2015
e0637fa
Updated documentation file
Feb 5, 2016
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
5 changes: 3 additions & 2 deletions IfSharp.sln
Original file line numberDiff line numberDiff line change
Expand Up@@ -52,6 +52,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ipython-profile", "ipython-
ProjectSection(SolutionItems) = preProject
ipython-profile\static\custom\ifsharp_logo.png = ipython-profile\static\custom\ifsharp_logo.png
ipython-profile\ipython_config.py = ipython-profile\ipython_config.py
ipython-profile\ipython_qtconsole_config.py = ipython-profile\ipython_qtconsole_config.py
ipython-profile\kernel.js = ipython-profile\kernel.js
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IfSharpConsole", "src\IfSharpConsole\IfSharpConsole.csproj", "{6BD0E996-0AEE-4FC7-8FB9-46E033D0C7F1}"
Expand All@@ -60,8 +62,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "static", "static", "{45519D
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "custom", "custom", "{3AAFA64D-CBB6-488E-B395-6A1E7CB554CE}"
ProjectSection(SolutionItems) = preProject
ipython-profile\static\custom\custom.css = ipython-profile\static\custom\custom.css
ipython-profile\static\custom\custom.js = ipython-profile\static\custom\custom.js
ipython-profile\static\custom\fsharp.css = ipython-profile\static\custom\fsharp.css
ipython-profile\static\custom\fsharp.js = ipython-profile\static\custom\fsharp.js
ipython-profile\static\custom\ifsharp_logo.png = ipython-profile\static\custom\ifsharp_logo.png
ipython-profile\static\custom\webintellisense-codemirror.js = ipython-profile\static\custom\webintellisense-codemirror.js
Expand Down
43 changes: 25 additions & 18 deletions README.md
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,48 @@
# IfSharp
F# implementation for [iPython](http://ipython.org). View the [Feature Notebook](http://nbviewer.ipython.org/github/BayardRock/IfSharp/blob/master/Feature%20Notebook.ipynb) for some of the features that are included.
For more information view the [documenation](http://bayardrock.github.io/IfSharp/). IfSharp is 64-bit *ONLY*.
F# implementation for [Jupyter](http://jupyter.org/). View the [Feature Notebook](http://nbviewer.jupyter.org/github/fsprojects/IfSharp/blob/master/Feature%20Notebook.ipynb) for some of the features that are included.
For more information view the [documentation](http://fsprojects.github.io/IfSharp/). IfSharp is 64-bit *ONLY*.

# Compatibility
IfSharp works with iPython Notebook 1.x and 2.x
IfSharp works with Jupyter 4.0 and 4.1 and works with both Python 2.X and Python 3.X

# Automatic Installation
See our [release repository](https://github.com/BayardRock/IfSharp/releases). Also, [installation documentation](http://bayardrock.github.io/IfSharp/installation.html).
Previous releases for the IPython notebook are here: [release repository](https://github.com/fsprojects/IfSharp/releases).
Automatic installs for Jupyter will be provided in the future.

# Manual Installation
# Manual Installation (Windows)
1. Install [Anaconda](http://continuum.io/downloads)
2. Install [IPython](http://ipython.org/install.html)
3. Run: "ipython profile create ifsharp" in your user directory
4. Open the iF# solution file, restore nuget packages, and compile it
5. Copy the files from IfSharp\ipython-profile to the iFSharp profile directory
6. Open up the copied "ipython_config.py" file and replace "%s" with the path of your compiled ifsharp executable. E.g. "C:\\git\\ifsharp\\bin\\Release\\ifsharp.exe"
7. Run: "ipython notebook --profile ifsharp" to launch the notebook process with the F# kernel.
2. Install [Jupyter](http://jupyter.readthedocs.org/en/latest/install.html)
3. Checkout the repository
4. Open the IfSharp solution file, restore nuget packages, and compile it
5. Run the IfSharpConsole project, this will register IfSharp and launch Jupyter

Jupyter with IfSharp can be run via "jupyter notebook" in future

# Manual Installation (Mac)
TODO

# Manual Installation (Ubuntu)
TODO

# Screens
## Intellisense
![Intellisense Example #1](https://raw.github.com/BayardRock/IfSharp/master/docs/files/img/intellisense-1.png "Intellisense Example #1")
![Intellisense Example #1](/docs/files/img/intellisense-1.png?raw=true "Intellisense Example #1")
***

![Intellisense Example #2](https://raw.github.com/BayardRock/IfSharp/master/docs/files/img/intellisense-2.png "Intellisense Example #2")
![Intellisense Example #2](docs/files/img/intellisense-2.png?raw=true "Intellisense Example #2")
***

![Intellisense Example #3 With Chart](https://raw.github.com/BayardRock/IfSharp/master/docs/files/img/intellisense-3.png "Intellisense Example #3 With Chart")
![Intellisense Example #3 With Chart](docs/files/img/intellisense-3.png?raw=true "Intellisense Example #3 With Chart")
***

![Intellisense Example #4 #r Directive](https://raw.github.com/BayardRock/IfSharp/master/docs/files/img/intellisense-reference.gif "Intellisense Example #3 #r Directive")
![Intellisense Example #4 #r Directive](docs/files/img/intellisense-reference.gif?raw=true "Intellisense Example #3 #r Directive")
***

![Intellisense Example #5 #load Directive](https://raw.github.com/BayardRock/IfSharp/master/docs/files/img/intellisense-5.png "Intellisense Example #load Directive")
![Intellisense Example #5 #load Directive](docs/files/img/intellisense-5.png?raw=true "Intellisense Example #load Directive")
***

## Integrated NuGet
![NuGet Example](https://raw.github.com/BayardRock/IfSharp/master/docs/files/img/NuGet-1.png "NuGet example")
![NuGet Example](docs/files/img/NuGet-1.png?raw=true "NuGet example")

## Inline Error Messages
![Inline Error Message](https://raw.github.com/BayardRock/IfSharp/master/docs/files/img/errors-1.png "Inline error message")
![Inline Error Message](docs/files/img/errors-1.png?raw=true "Inline error message")
5 changes: 2 additions & 3 deletions ipython-profile/ipython_config.py
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
c = get_config()
c.KernelManager.kernel_spec = [r"%s", "{connection_file}"]
c.Session.key = b''
c.Session.keyfile = ''
c.KernelManager.kernel_spec = [ "mono", r"%kexe", "{connection_file}"]
c.NotebookApp.extra_static_paths = [ r"%kstatic" ]
164 changes: 164 additions & 0 deletions ipython-profile/kernel.js
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
define(function () {

var link = document.createElement("link");
link.type = "text/css";
link.rel = "stylesheet";
link.href = "/static/custom/fsharp.css";
document.getElementsByTagName("head")[0].appendChild(link);

require(['codemirror/addon/mode/loadmode']);

var onload = function () {

var md = IPython.notebook.metadata;
if (md.language) {
console.log('language already defined and is :', md.language);
}
else {
md.language = 'fsharp';
console.log('add metadata hint that language is fsharp...');
}

require(['/static/custom/fsharp.js']);

IPython.CodeCell.options_default.cm_config.mode = 'fsharp';

// callback called by the end-user
function updateMarkers(data) {
// applies intellisense hooks onto all cells
var cells = getCodeCells();
data.forEach(function (err) {
var cell = cells.cells[err.CellNumber]
var editor = cell.code_mirror;

// clear our error marks
editor.doc.getAllMarks()
.forEach(function (m) {
if (m.className === 'br-errormarker') {
m.clear();
}
});

var from = { line: err.StartLine, ch: err.StartColumn };
var to = { line: err.EndLine, ch: err.EndColumn };
editor.doc.markText(from, to, { title: err.Message, className: 'br-errormarker' });
});
}

function getCodeCells() {
var results = { codes: [], cells: [], selectedCell: null, selectedIndex: 0 };
IPython.notebook.get_cells()
.forEach(function (c) {
if (c.cell_type === 'code') {
if (c.selected === true) {
results.selectedCell = c;
results.selectedIndex = results.cells.length;
}
results.cells.push(c);
results.codes.push(c.code_mirror.getValue());
}
});

return results;
}

require(['/static/custom/webintellisense.js', '/static/custom/webintellisense-codemirror.js'], function () {
// applies intellisense hooks onto a cell
function applyIntellisense(cell) {
if (cell.cell_type !== 'code') { return; }

var editor = cell.code_mirror;
if (editor.intellisense == null) {
var intellisense = new CodeMirrorIntellisense(editor);
cell.force_highlight('fsharp');
cell.code_mirror.setOption('theme', 'neat');
editor.intellisense = intellisense;

intellisense.addDeclarationTrigger({ keyCode: 190 }); // `.`
intellisense.addDeclarationTrigger({ keyCode: 32, ctrlKey: true, preventDefault: true, type: 'down' }); // `ctrl+space`
intellisense.addDeclarationTrigger({ keyCode: 191 }); // `/`
intellisense.addDeclarationTrigger({ keyCode: 220 }); // `\`
intellisense.addDeclarationTrigger({ keyCode: 222 }); // `"`
intellisense.addDeclarationTrigger({ keyCode: 222, shiftKey: true }); // `"`
intellisense.addMethodsTrigger({ keyCode: 57, shiftKey: true }); // `(`
intellisense.addMethodsTrigger({ keyCode: 48, shiftKey: true });// `)`
intellisense.onMethod(function (item, position) {

});
intellisense.onDeclaration(function (item, position) {
var cells = getCodeCells();
var codes = cells.codes;
var cursor = cells.selectedCell.code_mirror.doc.getCursor();
var callbacks = { shell: {}, iopub: {} };
var line = editor.getLine(cursor.line);
var isSlash = item.keyCode === 191 || item.keyCode === 220;
var isQuote = item.keyCode === 222;

var isLoadOrRef = line.indexOf('#load') === 0
|| line.indexOf('#r') === 0;

var isStartLoadOrRef = line === '#load "'
|| line === '#r "'
|| line === '#load @"'
|| line === '#r @"';

if (isSlash && !isLoadOrRef) {
return;
}
if (isQuote && !isStartLoadOrRef) {
return;
}

// v2
callbacks.shell.reply = function (msg) {
intellisense.setDeclarations(msg.content.matches);
if (msg.content.filter_start_index)
intellisense.setStartColumnIndex(msg.content.filter_start_index);
};

callbacks.iopub.output = function (msg) {
updateMarkers(msg.content.data.errors);
};

// v1
callbacks.complete_reply = function (data) {
intellisense.setDeclarations(data.matches);
intellisense.setStartColumnIndex(data.filter_start_index);
};

callbacks.output = function (msgType, content, metadata) {
updateMarkers(content.data.errors);
};

var content = {
text: JSON.stringify(codes),
line: '',
block: JSON.stringify({ selectedIndex: cells.selectedIndex, ch: cursor.ch, line: cursor.line }),
cursor_pos: cursor.ch
};

IPython.notebook.kernel.send_shell_message("intellisense_request", content, callbacks, null, null);
});
}
}

// applies intellisense hooks onto all cells
IPython.notebook.get_cells()
.forEach(function (cell) {
applyIntellisense(cell);
});

// applies intellisense hooks onto cells that are selected
$([IPython.events]).on('create.Cell', function (event, data) {
applyIntellisense(data.cell);
});
});

// replace the image
var img = $('.container img')[0];
img.src = "/static/custom/ifsharp_logo.png";

}

return { onload: onload }
})
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
9612a03
Fixed IntelliSense and syntax highlighting
Oct 20, 2015
d401422
Added git-excluded files
Oct 20, 2015
98d8ce8
Added missing file
Oct 20, 2015
62c7162
Implemented message signing
Oct 20, 2015
af8b6a5
Proper handling of unsigned messages.
Oct 20, 2015
6db4242
linux kernel spec paths corrected
npmurphy Oct 20, 2015
199454f
merging with master
npmurphy Oct 20, 2015
ff83e69
remove old 0zmq comment
npmurphy Oct 20, 2015
57e845f
Merge pull request #1 from npmurphy/filippo_fork
FilippoPolo Oct 21, 2015
ccc7345
Merge pull request #2 from npmurphy/merge_filippo_fork
FilippoPolo Oct 21, 2015
491edf0
Fixed automerge mistake
Oct 21, 2015
41b93bf
Added InspectRequest dummy implementation
Oct 27, 2015
d134d24
Added dummy answer to inspect_request
Oct 27, 2015
1e7d25f
Wrapped logging in an exception handler
Oct 28, 2015
479c618
Added GenericChartsWithSize, for outputting multiple charts.
Oct 28, 2015
d91f800
Extending MultiplePlots to use different numbers of columns
ndalchau Oct 30, 2015
bfedd74
Reverting to packages version of FSharp.Charting.
ndalchau Nov 4, 2015
6f8b84d
Added the ability to prepare temporary files to serve.
Nov 4, 2015
6a9130f
Added some helpers to allow arranging multiple images in an output.
Nov 4, 2015
93dd982
Added SVG moving and merging functions.
Nov 5, 2015
2c4bf70
NuGet package installation will now copy content files to a "content"…
Nov 5, 2015
b3bbeb0
Substitute in F# 3.1 for later versions
cgravill Dec 2, 2015
0ca6e27
Merge pull request #3 from cgravill/master
FilippoPolo Dec 2, 2015
e0637fa
Updated documentation file
Feb 5, 2016
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
5 changes: 3 additions & 2 deletions IfSharp.sln
Original file line numberDiff line numberDiff line change
Expand Up@@ -52,6 +52,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ipython-profile", "ipython-
ProjectSection(SolutionItems) = preProject
ipython-profile\static\custom\ifsharp_logo.png = ipython-profile\static\custom\ifsharp_logo.png
ipython-profile\ipython_config.py = ipython-profile\ipython_config.py
ipython-profile\ipython_qtconsole_config.py = ipython-profile\ipython_qtconsole_config.py
ipython-profile\kernel.js = ipython-profile\kernel.js
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IfSharpConsole", "src\IfSharpConsole\IfSharpConsole.csproj", "{6BD0E996-0AEE-4FC7-8FB9-46E033D0C7F1}"
Expand All@@ -60,8 +62,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "static", "static", "{45519D
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "custom", "custom", "{3AAFA64D-CBB6-488E-B395-6A1E7CB554CE}"
ProjectSection(SolutionItems) = preProject
ipython-profile\static\custom\custom.css = ipython-profile\static\custom\custom.css
ipython-profile\static\custom\custom.js = ipython-profile\static\custom\custom.js
ipython-profile\static\custom\fsharp.css = ipython-profile\static\custom\fsharp.css
ipython-profile\static\custom\fsharp.js = ipython-profile\static\custom\fsharp.js
ipython-profile\static\custom\ifsharp_logo.png = ipython-profile\static\custom\ifsharp_logo.png
ipython-profile\static\custom\webintellisense-codemirror.js = ipython-profile\static\custom\webintellisense-codemirror.js
Expand Down
43 changes: 25 additions & 18 deletions README.md
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,48 @@
# IfSharp
F# implementation for [iPython](http://ipython.org). View the [Feature Notebook](http://nbviewer.ipython.org/github/BayardRock/IfSharp/blob/master/Feature%20Notebook.ipynb) for some of the features that are included.
For more information view the [documenation](http://bayardrock.github.io/IfSharp/). IfSharp is 64-bit *ONLY*.
F# implementation for [Jupyter](http://jupyter.org/). View the [Feature Notebook](http://nbviewer.jupyter.org/github/fsprojects/IfSharp/blob/master/Feature%20Notebook.ipynb) for some of the features that are included.
For more information view the [documentation](http://fsprojects.github.io/IfSharp/). IfSharp is 64-bit *ONLY*.

# Compatibility
IfSharp works with iPython Notebook 1.x and 2.x
IfSharp works with Jupyter 4.0 and 4.1 and works with both Python 2.X and Python 3.X

# Automatic Installation
See our [release repository](https://github.com/BayardRock/IfSharp/releases). Also, [installation documentation](http://bayardrock.github.io/IfSharp/installation.html).
Previous releases for the IPython notebook are here: [release repository](https://github.com/fsprojects/IfSharp/releases).
Automatic installs for Jupyter will be provided in the future.

# Manual Installation
# Manual Installation (Windows)
1. Install [Anaconda](http://continuum.io/downloads)
2. Install [IPython](http://ipython.org/install.html)
3. Run: "ipython profile create ifsharp" in your user directory
4. Open the iF# solution file, restore nuget packages, and compile it
5. Copy the files from IfSharp\ipython-profile to the iFSharp profile directory
6. Open up the copied "ipython_config.py" file and replace "%s" with the path of your compiled ifsharp executable. E.g. "C:\\git\\ifsharp\\bin\\Release\\ifsharp.exe"
7. Run: "ipython notebook --profile ifsharp" to launch the notebook process with the F# kernel.
2. Install [Jupyter](http://jupyter.readthedocs.org/en/latest/install.html)
3. Checkout the repository
4. Open the IfSharp solution file, restore nuget packages, and compile it
5. Run the IfSharpConsole project, this will register IfSharp and launch Jupyter

Jupyter with IfSharp can be run via "jupyter notebook" in future

# Manual Installation (Mac)
TODO

# Manual Installation (Ubuntu)
TODO

# Screens
## Intellisense
![Intellisense Example #1](https://raw.github.com/BayardRock/IfSharp/master/docs/files/img/intellisense-1.png "Intellisense Example #1")
![Intellisense Example #1](/docs/files/img/intellisense-1.png?raw=true "Intellisense Example #1")
***

![Intellisense Example #2](https://raw.github.com/BayardRock/IfSharp/master/docs/files/img/intellisense-2.png "Intellisense Example #2")
![Intellisense Example #2](docs/files/img/intellisense-2.png?raw=true "Intellisense Example #2")
***

![Intellisense Example #3 With Chart](https://raw.github.com/BayardRock/IfSharp/master/docs/files/img/intellisense-3.png "Intellisense Example #3 With Chart")
![Intellisense Example #3 With Chart](docs/files/img/intellisense-3.png?raw=true "Intellisense Example #3 With Chart")
***

![Intellisense Example #4 #r Directive](https://raw.github.com/BayardRock/IfSharp/master/docs/files/img/intellisense-reference.gif "Intellisense Example #3 #r Directive")
![Intellisense Example #4 #r Directive](docs/files/img/intellisense-reference.gif?raw=true "Intellisense Example #3 #r Directive")
***

![Intellisense Example #5 #load Directive](https://raw.github.com/BayardRock/IfSharp/master/docs/files/img/intellisense-5.png "Intellisense Example #load Directive")
![Intellisense Example #5 #load Directive](docs/files/img/intellisense-5.png?raw=true "Intellisense Example #load Directive")
***

## Integrated NuGet
![NuGet Example](https://raw.github.com/BayardRock/IfSharp/master/docs/files/img/NuGet-1.png "NuGet example")
![NuGet Example](docs/files/img/NuGet-1.png?raw=true "NuGet example")

## Inline Error Messages
![Inline Error Message](https://raw.github.com/BayardRock/IfSharp/master/docs/files/img/errors-1.png "Inline error message")
![Inline Error Message](docs/files/img/errors-1.png?raw=true "Inline error message")
5 changes: 2 additions & 3 deletions ipython-profile/ipython_config.py
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
c = get_config()
c.KernelManager.kernel_spec = [r"%s", "{connection_file}"]
c.Session.key = b''
c.Session.keyfile = ''
c.KernelManager.kernel_spec = [ "mono", r"%kexe", "{connection_file}"]
c.NotebookApp.extra_static_paths = [ r"%kstatic" ]
164 changes: 164 additions & 0 deletions ipython-profile/kernel.js
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
define(function () {

var link = document.createElement("link");
link.type = "text/css";
link.rel = "stylesheet";
link.href = "/static/custom/fsharp.css";
document.getElementsByTagName("head")[0].appendChild(link);

require(['codemirror/addon/mode/loadmode']);

var onload = function () {

var md = IPython.notebook.metadata;
if (md.language) {
console.log('language already defined and is :', md.language);
}
else {
md.language = 'fsharp';
console.log('add metadata hint that language is fsharp...');
}

require(['/static/custom/fsharp.js']);

IPython.CodeCell.options_default.cm_config.mode = 'fsharp';

// callback called by the end-user
function updateMarkers(data) {
// applies intellisense hooks onto all cells
var cells = getCodeCells();
data.forEach(function (err) {
var cell = cells.cells[err.CellNumber]
var editor = cell.code_mirror;

// clear our error marks
editor.doc.getAllMarks()
.forEach(function (m) {
if (m.className === 'br-errormarker') {
m.clear();
}
});

var from = { line: err.StartLine, ch: err.StartColumn };
var to = { line: err.EndLine, ch: err.EndColumn };
editor.doc.markText(from, to, { title: err.Message, className: 'br-errormarker' });
});
}

function getCodeCells() {
var results = { codes: [], cells: [], selectedCell: null, selectedIndex: 0 };
IPython.notebook.get_cells()
.forEach(function (c) {
if (c.cell_type === 'code') {
if (c.selected === true) {
results.selectedCell = c;
results.selectedIndex = results.cells.length;
}
results.cells.push(c);
results.codes.push(c.code_mirror.getValue());
}
});

return results;
}

require(['/static/custom/webintellisense.js', '/static/custom/webintellisense-codemirror.js'], function () {
// applies intellisense hooks onto a cell
function applyIntellisense(cell) {
if (cell.cell_type !== 'code') { return; }

var editor = cell.code_mirror;
if (editor.intellisense == null) {
var intellisense = new CodeMirrorIntellisense(editor);
cell.force_highlight('fsharp');
cell.code_mirror.setOption('theme', 'neat');
editor.intellisense = intellisense;

intellisense.addDeclarationTrigger({ keyCode: 190 }); // `.`
intellisense.addDeclarationTrigger({ keyCode: 32, ctrlKey: true, preventDefault: true, type: 'down' }); // `ctrl+space`
intellisense.addDeclarationTrigger({ keyCode: 191 }); // `/`
intellisense.addDeclarationTrigger({ keyCode: 220 }); // `\`
intellisense.addDeclarationTrigger({ keyCode: 222 }); // `"`
intellisense.addDeclarationTrigger({ keyCode: 222, shiftKey: true }); // `"`
intellisense.addMethodsTrigger({ keyCode: 57, shiftKey: true }); // `(`
intellisense.addMethodsTrigger({ keyCode: 48, shiftKey: true });// `)`
intellisense.onMethod(function (item, position) {

});
intellisense.onDeclaration(function (item, position) {
var cells = getCodeCells();
var codes = cells.codes;
var cursor = cells.selectedCell.code_mirror.doc.getCursor();
var callbacks = { shell: {}, iopub: {} };
var line = editor.getLine(cursor.line);
var isSlash = item.keyCode === 191 || item.keyCode === 220;
var isQuote = item.keyCode === 222;

var isLoadOrRef = line.indexOf('#load') === 0
|| line.indexOf('#r') === 0;

var isStartLoadOrRef = line === '#load "'
|| line === '#r "'
|| line === '#load @"'
|| line === '#r @"';

if (isSlash && !isLoadOrRef) {
return;
}
if (isQuote && !isStartLoadOrRef) {
return;
}

// v2
callbacks.shell.reply = function (msg) {
intellisense.setDeclarations(msg.content.matches);
if (msg.content.filter_start_index)
intellisense.setStartColumnIndex(msg.content.filter_start_index);
};

callbacks.iopub.output = function (msg) {
updateMarkers(msg.content.data.errors);
};

// v1
callbacks.complete_reply = function (data) {
intellisense.setDeclarations(data.matches);
intellisense.setStartColumnIndex(data.filter_start_index);
};

callbacks.output = function (msgType, content, metadata) {
updateMarkers(content.data.errors);
};

var content = {
text: JSON.stringify(codes),
line: '',
block: JSON.stringify({ selectedIndex: cells.selectedIndex, ch: cursor.ch, line: cursor.line }),
cursor_pos: cursor.ch
};

IPython.notebook.kernel.send_shell_message("intellisense_request", content, callbacks, null, null);
});
}
}

// applies intellisense hooks onto all cells
IPython.notebook.get_cells()
.forEach(function (cell) {
applyIntellisense(cell);
});

// applies intellisense hooks onto cells that are selected
$([IPython.events]).on('create.Cell', function (event, data) {
applyIntellisense(data.cell);
});
});

// replace the image
var img = $('.container img')[0];
img.src = "/static/custom/ifsharp_logo.png";

}

return { onload: onload }
})
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
9612a03
Fixed IntelliSense and syntax highlighting
Oct 20, 2015
d401422
Added git-excluded files
Oct 20, 2015
98d8ce8
Added missing file
Oct 20, 2015
62c7162
Implemented message signing
Oct 20, 2015
af8b6a5
Proper handling of unsigned messages.
Oct 20, 2015
6db4242
linux kernel spec paths corrected
npmurphy Oct 20, 2015
199454f
merging with master
npmurphy Oct 20, 2015
ff83e69
remove old 0zmq comment
npmurphy Oct 20, 2015
57e845f
Merge pull request #1 from npmurphy/filippo_fork
FilippoPolo Oct 21, 2015
ccc7345
Merge pull request #2 from npmurphy/merge_filippo_fork
FilippoPolo Oct 21, 2015
491edf0
Fixed automerge mistake
Oct 21, 2015
41b93bf
Added InspectRequest dummy implementation
Oct 27, 2015
d134d24
Added dummy answer to inspect_request
Oct 27, 2015
1e7d25f
Wrapped logging in an exception handler
Oct 28, 2015
479c618
Added GenericChartsWithSize, for outputting multiple charts.
Oct 28, 2015
d91f800
Extending MultiplePlots to use different numbers of columns
ndalchau Oct 30, 2015
bfedd74
Reverting to packages version of FSharp.Charting.
ndalchau Nov 4, 2015
6f8b84d
Added the ability to prepare temporary files to serve.
Nov 4, 2015
6a9130f
Added some helpers to allow arranging multiple images in an output.
Nov 4, 2015
93dd982
Added SVG moving and merging functions.
Nov 5, 2015
2c4bf70
NuGet package installation will now copy content files to a "content"…
Nov 5, 2015
b3bbeb0
Substitute in F# 3.1 for later versions
cgravill Dec 2, 2015
0ca6e27
Merge pull request #3 from cgravill/master
FilippoPolo Dec 2, 2015
e0637fa
Updated documentation file
Feb 5, 2016
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
5 changes: 3 additions & 2 deletions IfSharp.sln
Original file line numberDiff line numberDiff line change
Expand Up@@ -52,6 +52,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ipython-profile", "ipython-
ProjectSection(SolutionItems) = preProject
ipython-profile\static\custom\ifsharp_logo.png = ipython-profile\static\custom\ifsharp_logo.png
ipython-profile\ipython_config.py = ipython-profile\ipython_config.py
ipython-profile\ipython_qtconsole_config.py = ipython-profile\ipython_qtconsole_config.py
ipython-profile\kernel.js = ipython-profile\kernel.js
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IfSharpConsole", "src\IfSharpConsole\IfSharpConsole.csproj", "{6BD0E996-0AEE-4FC7-8FB9-46E033D0C7F1}"
Expand All@@ -60,8 +62,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "static", "static", "{45519D
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "custom", "custom", "{3AAFA64D-CBB6-488E-B395-6A1E7CB554CE}"
ProjectSection(SolutionItems) = preProject
ipython-profile\static\custom\custom.css = ipython-profile\static\custom\custom.css
ipython-profile\static\custom\custom.js = ipython-profile\static\custom\custom.js
ipython-profile\static\custom\fsharp.css = ipython-profile\static\custom\fsharp.css
ipython-profile\static\custom\fsharp.js = ipython-profile\static\custom\fsharp.js
ipython-profile\static\custom\ifsharp_logo.png = ipython-profile\static\custom\ifsharp_logo.png
ipython-profile\static\custom\webintellisense-codemirror.js = ipython-profile\static\custom\webintellisense-codemirror.js
Expand Down
43 changes: 25 additions & 18 deletions README.md
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,48 @@
# IfSharp
F# implementation for [iPython](http://ipython.org). View the [Feature Notebook](http://nbviewer.ipython.org/github/BayardRock/IfSharp/blob/master/Feature%20Notebook.ipynb) for some of the features that are included.
For more information view the [documenation](http://bayardrock.github.io/IfSharp/). IfSharp is 64-bit *ONLY*.
F# implementation for [Jupyter](http://jupyter.org/). View the [Feature Notebook](http://nbviewer.jupyter.org/github/fsprojects/IfSharp/blob/master/Feature%20Notebook.ipynb) for some of the features that are included.
For more information view the [documentation](http://fsprojects.github.io/IfSharp/). IfSharp is 64-bit *ONLY*.

# Compatibility
IfSharp works with iPython Notebook 1.x and 2.x
IfSharp works with Jupyter 4.0 and 4.1 and works with both Python 2.X and Python 3.X

# Automatic Installation
See our [release repository](https://github.com/BayardRock/IfSharp/releases). Also, [installation documentation](http://bayardrock.github.io/IfSharp/installation.html).
Previous releases for the IPython notebook are here: [release repository](https://github.com/fsprojects/IfSharp/releases).
Automatic installs for Jupyter will be provided in the future.

# Manual Installation
# Manual Installation (Windows)
1. Install [Anaconda](http://continuum.io/downloads)
2. Install [IPython](http://ipython.org/install.html)
3. Run: "ipython profile create ifsharp" in your user directory
4. Open the iF# solution file, restore nuget packages, and compile it
5. Copy the files from IfSharp\ipython-profile to the iFSharp profile directory
6. Open up the copied "ipython_config.py" file and replace "%s" with the path of your compiled ifsharp executable. E.g. "C:\\git\\ifsharp\\bin\\Release\\ifsharp.exe"
7. Run: "ipython notebook --profile ifsharp" to launch the notebook process with the F# kernel.
2. Install [Jupyter](http://jupyter.readthedocs.org/en/latest/install.html)
3. Checkout the repository
4. Open the IfSharp solution file, restore nuget packages, and compile it
5. Run the IfSharpConsole project, this will register IfSharp and launch Jupyter

Jupyter with IfSharp can be run via "jupyter notebook" in future

# Manual Installation (Mac)
TODO

# Manual Installation (Ubuntu)
TODO

# Screens
## Intellisense
![Intellisense Example #1](https://raw.github.com/BayardRock/IfSharp/master/docs/files/img/intellisense-1.png "Intellisense Example #1")
![Intellisense Example #1](/docs/files/img/intellisense-1.png?raw=true "Intellisense Example #1")
***

![Intellisense Example #2](https://raw.github.com/BayardRock/IfSharp/master/docs/files/img/intellisense-2.png "Intellisense Example #2")
![Intellisense Example #2](docs/files/img/intellisense-2.png?raw=true "Intellisense Example #2")
***

![Intellisense Example #3 With Chart](https://raw.github.com/BayardRock/IfSharp/master/docs/files/img/intellisense-3.png "Intellisense Example #3 With Chart")
![Intellisense Example #3 With Chart](docs/files/img/intellisense-3.png?raw=true "Intellisense Example #3 With Chart")
***

![Intellisense Example #4 #r Directive](https://raw.github.com/BayardRock/IfSharp/master/docs/files/img/intellisense-reference.gif "Intellisense Example #3 #r Directive")
![Intellisense Example #4 #r Directive](docs/files/img/intellisense-reference.gif?raw=true "Intellisense Example #3 #r Directive")
***

![Intellisense Example #5 #load Directive](https://raw.github.com/BayardRock/IfSharp/master/docs/files/img/intellisense-5.png "Intellisense Example #load Directive")
![Intellisense Example #5 #load Directive](docs/files/img/intellisense-5.png?raw=true "Intellisense Example #load Directive")
***

## Integrated NuGet
![NuGet Example](https://raw.github.com/BayardRock/IfSharp/master/docs/files/img/NuGet-1.png "NuGet example")
![NuGet Example](docs/files/img/NuGet-1.png?raw=true "NuGet example")

## Inline Error Messages
![Inline Error Message](https://raw.github.com/BayardRock/IfSharp/master/docs/files/img/errors-1.png "Inline error message")
![Inline Error Message](docs/files/img/errors-1.png?raw=true "Inline error message")
5 changes: 2 additions & 3 deletions ipython-profile/ipython_config.py
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
c = get_config()
c.KernelManager.kernel_spec = [r"%s", "{connection_file}"]
c.Session.key = b''
c.Session.keyfile = ''
c.KernelManager.kernel_spec = [ "mono", r"%kexe", "{connection_file}"]
c.NotebookApp.extra_static_paths = [ r"%kstatic" ]
164 changes: 164 additions & 0 deletions ipython-profile/kernel.js
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
define(function () {

var link = document.createElement("link");
link.type = "text/css";
link.rel = "stylesheet";
link.href = "/static/custom/fsharp.css";
document.getElementsByTagName("head")[0].appendChild(link);

require(['codemirror/addon/mode/loadmode']);

var onload = function () {

var md = IPython.notebook.metadata;
if (md.language) {
console.log('language already defined and is :', md.language);
}
else {
md.language = 'fsharp';
console.log('add metadata hint that language is fsharp...');
}

require(['/static/custom/fsharp.js']);

IPython.CodeCell.options_default.cm_config.mode = 'fsharp';

// callback called by the end-user
function updateMarkers(data) {
// applies intellisense hooks onto all cells
var cells = getCodeCells();
data.forEach(function (err) {
var cell = cells.cells[err.CellNumber]
var editor = cell.code_mirror;

// clear our error marks
editor.doc.getAllMarks()
.forEach(function (m) {
if (m.className === 'br-errormarker') {
m.clear();
}
});

var from = { line: err.StartLine, ch: err.StartColumn };
var to = { line: err.EndLine, ch: err.EndColumn };
editor.doc.markText(from, to, { title: err.Message, className: 'br-errormarker' });
});
}

function getCodeCells() {
var results = { codes: [], cells: [], selectedCell: null, selectedIndex: 0 };
IPython.notebook.get_cells()
.forEach(function (c) {
if (c.cell_type === 'code') {
if (c.selected === true) {
results.selectedCell = c;
results.selectedIndex = results.cells.length;
}
results.cells.push(c);
results.codes.push(c.code_mirror.getValue());
}
});

return results;
}

require(['/static/custom/webintellisense.js', '/static/custom/webintellisense-codemirror.js'], function () {
// applies intellisense hooks onto a cell
function applyIntellisense(cell) {
if (cell.cell_type !== 'code') { return; }

var editor = cell.code_mirror;
if (editor.intellisense == null) {
var intellisense = new CodeMirrorIntellisense(editor);
cell.force_highlight('fsharp');
cell.code_mirror.setOption('theme', 'neat');
editor.intellisense = intellisense;

intellisense.addDeclarationTrigger({ keyCode: 190 }); // `.`
intellisense.addDeclarationTrigger({ keyCode: 32, ctrlKey: true, preventDefault: true, type: 'down' }); // `ctrl+space`
intellisense.addDeclarationTrigger({ keyCode: 191 }); // `/`
intellisense.addDeclarationTrigger({ keyCode: 220 }); // `\`
intellisense.addDeclarationTrigger({ keyCode: 222 }); // `"`
intellisense.addDeclarationTrigger({ keyCode: 222, shiftKey: true }); // `"`
intellisense.addMethodsTrigger({ keyCode: 57, shiftKey: true }); // `(`
intellisense.addMethodsTrigger({ keyCode: 48, shiftKey: true });// `)`
intellisense.onMethod(function (item, position) {

});
intellisense.onDeclaration(function (item, position) {
var cells = getCodeCells();
var codes = cells.codes;
var cursor = cells.selectedCell.code_mirror.doc.getCursor();
var callbacks = { shell: {}, iopub: {} };
var line = editor.getLine(cursor.line);
var isSlash = item.keyCode === 191 || item.keyCode === 220;
var isQuote = item.keyCode === 222;

var isLoadOrRef = line.indexOf('#load') === 0
|| line.indexOf('#r') === 0;

var isStartLoadOrRef = line === '#load "'
|| line === '#r "'
|| line === '#load @"'
|| line === '#r @"';

if (isSlash && !isLoadOrRef) {
return;
}
if (isQuote && !isStartLoadOrRef) {
return;
}

// v2
callbacks.shell.reply = function (msg) {
intellisense.setDeclarations(msg.content.matches);
if (msg.content.filter_start_index)
intellisense.setStartColumnIndex(msg.content.filter_start_index);
};

callbacks.iopub.output = function (msg) {
updateMarkers(msg.content.data.errors);
};

// v1
callbacks.complete_reply = function (data) {
intellisense.setDeclarations(data.matches);
intellisense.setStartColumnIndex(data.filter_start_index);
};

callbacks.output = function (msgType, content, metadata) {
updateMarkers(content.data.errors);
};

var content = {
text: JSON.stringify(codes),
line: '',
block: JSON.stringify({ selectedIndex: cells.selectedIndex, ch: cursor.ch, line: cursor.line }),
cursor_pos: cursor.ch
};

IPython.notebook.kernel.send_shell_message("intellisense_request", content, callbacks, null, null);
});
}
}

// applies intellisense hooks onto all cells
IPython.notebook.get_cells()
.forEach(function (cell) {
applyIntellisense(cell);
});

// applies intellisense hooks onto cells that are selected
$([IPython.events]).on('create.Cell', function (event, data) {
applyIntellisense(data.cell);
});
});

// replace the image
var img = $('.container img')[0];
img.src = "/static/custom/ifsharp_logo.png";

}

return { onload: onload }
})
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
9612a03
Fixed IntelliSense and syntax highlighting
Oct 20, 2015
d401422
Added git-excluded files
Oct 20, 2015
98d8ce8
Added missing file
Oct 20, 2015
62c7162
Implemented message signing
Oct 20, 2015
af8b6a5
Proper handling of unsigned messages.
Oct 20, 2015
6db4242
linux kernel spec paths corrected
npmurphy Oct 20, 2015
199454f
merging with master
npmurphy Oct 20, 2015
ff83e69
remove old 0zmq comment
npmurphy Oct 20, 2015
57e845f
Merge pull request #1 from npmurphy/filippo_fork
FilippoPolo Oct 21, 2015
ccc7345
Merge pull request #2 from npmurphy/merge_filippo_fork
FilippoPolo Oct 21, 2015
491edf0
Fixed automerge mistake
Oct 21, 2015
41b93bf
Added InspectRequest dummy implementation
Oct 27, 2015
d134d24
Added dummy answer to inspect_request
Oct 27, 2015
1e7d25f
Wrapped logging in an exception handler
Oct 28, 2015
479c618
Added GenericChartsWithSize, for outputting multiple charts.
Oct 28, 2015
d91f800
Extending MultiplePlots to use different numbers of columns
ndalchau Oct 30, 2015
bfedd74
Reverting to packages version of FSharp.Charting.
ndalchau Nov 4, 2015
6f8b84d
Added the ability to prepare temporary files to serve.
Nov 4, 2015
6a9130f
Added some helpers to allow arranging multiple images in an output.
Nov 4, 2015
93dd982
Added SVG moving and merging functions.
Nov 5, 2015
2c4bf70
NuGet package installation will now copy content files to a "content"…
Nov 5, 2015
b3bbeb0
Substitute in F# 3.1 for later versions
cgravill Dec 2, 2015
0ca6e27
Merge pull request #3 from cgravill/master
FilippoPolo Dec 2, 2015
e0637fa
Updated documentation file
Feb 5, 2016
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
5 changes: 3 additions & 2 deletions IfSharp.sln
Original file line numberDiff line numberDiff line change
Expand Up@@ -52,6 +52,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ipython-profile", "ipython-
ProjectSection(SolutionItems) = preProject
ipython-profile\static\custom\ifsharp_logo.png = ipython-profile\static\custom\ifsharp_logo.png
ipython-profile\ipython_config.py = ipython-profile\ipython_config.py
ipython-profile\ipython_qtconsole_config.py = ipython-profile\ipython_qtconsole_config.py
ipython-profile\kernel.js = ipython-profile\kernel.js
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IfSharpConsole", "src\IfSharpConsole\IfSharpConsole.csproj", "{6BD0E996-0AEE-4FC7-8FB9-46E033D0C7F1}"
Expand All@@ -60,8 +62,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "static", "static", "{45519D
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "custom", "custom", "{3AAFA64D-CBB6-488E-B395-6A1E7CB554CE}"
ProjectSection(SolutionItems) = preProject
ipython-profile\static\custom\custom.css = ipython-profile\static\custom\custom.css
ipython-profile\static\custom\custom.js = ipython-profile\static\custom\custom.js
ipython-profile\static\custom\fsharp.css = ipython-profile\static\custom\fsharp.css
ipython-profile\static\custom\fsharp.js = ipython-profile\static\custom\fsharp.js
ipython-profile\static\custom\ifsharp_logo.png = ipython-profile\static\custom\ifsharp_logo.png
ipython-profile\static\custom\webintellisense-codemirror.js = ipython-profile\static\custom\webintellisense-codemirror.js
Expand Down
43 changes: 25 additions & 18 deletions README.md
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,48 @@
# IfSharp
F# implementation for [iPython](http://ipython.org). View the [Feature Notebook](http://nbviewer.ipython.org/github/BayardRock/IfSharp/blob/master/Feature%20Notebook.ipynb) for some of the features that are included.
For more information view the [documenation](http://bayardrock.github.io/IfSharp/). IfSharp is 64-bit *ONLY*.
F# implementation for [Jupyter](http://jupyter.org/). View the [Feature Notebook](http://nbviewer.jupyter.org/github/fsprojects/IfSharp/blob/master/Feature%20Notebook.ipynb) for some of the features that are included.
For more information view the [documentation](http://fsprojects.github.io/IfSharp/). IfSharp is 64-bit *ONLY*.

# Compatibility
IfSharp works with iPython Notebook 1.x and 2.x
IfSharp works with Jupyter 4.0 and 4.1 and works with both Python 2.X and Python 3.X

# Automatic Installation
See our [release repository](https://github.com/BayardRock/IfSharp/releases). Also, [installation documentation](http://bayardrock.github.io/IfSharp/installation.html).
Previous releases for the IPython notebook are here: [release repository](https://github.com/fsprojects/IfSharp/releases).
Automatic installs for Jupyter will be provided in the future.

# Manual Installation
# Manual Installation (Windows)
1. Install [Anaconda](http://continuum.io/downloads)
2. Install [IPython](http://ipython.org/install.html)
3. Run: "ipython profile create ifsharp" in your user directory
4. Open the iF# solution file, restore nuget packages, and compile it
5. Copy the files from IfSharp\ipython-profile to the iFSharp profile directory
6. Open up the copied "ipython_config.py" file and replace "%s" with the path of your compiled ifsharp executable. E.g. "C:\\git\\ifsharp\\bin\\Release\\ifsharp.exe"
7. Run: "ipython notebook --profile ifsharp" to launch the notebook process with the F# kernel.
2. Install [Jupyter](http://jupyter.readthedocs.org/en/latest/install.html)
3. Checkout the repository
4. Open the IfSharp solution file, restore nuget packages, and compile it
5. Run the IfSharpConsole project, this will register IfSharp and launch Jupyter

Jupyter with IfSharp can be run via "jupyter notebook" in future

# Manual Installation (Mac)
TODO

# Manual Installation (Ubuntu)
TODO

# Screens
## Intellisense
![Intellisense Example #1](https://raw.github.com/BayardRock/IfSharp/master/docs/files/img/intellisense-1.png "Intellisense Example #1")
![Intellisense Example #1](/docs/files/img/intellisense-1.png?raw=true "Intellisense Example #1")
***

![Intellisense Example #2](https://raw.github.com/BayardRock/IfSharp/master/docs/files/img/intellisense-2.png "Intellisense Example #2")
![Intellisense Example #2](docs/files/img/intellisense-2.png?raw=true "Intellisense Example #2")
***

![Intellisense Example #3 With Chart](https://raw.github.com/BayardRock/IfSharp/master/docs/files/img/intellisense-3.png "Intellisense Example #3 With Chart")
![Intellisense Example #3 With Chart](docs/files/img/intellisense-3.png?raw=true "Intellisense Example #3 With Chart")
***

![Intellisense Example #4 #r Directive](https://raw.github.com/BayardRock/IfSharp/master/docs/files/img/intellisense-reference.gif "Intellisense Example #3 #r Directive")
![Intellisense Example #4 #r Directive](docs/files/img/intellisense-reference.gif?raw=true "Intellisense Example #3 #r Directive")
***

![Intellisense Example #5 #load Directive](https://raw.github.com/BayardRock/IfSharp/master/docs/files/img/intellisense-5.png "Intellisense Example #load Directive")
![Intellisense Example #5 #load Directive](docs/files/img/intellisense-5.png?raw=true "Intellisense Example #load Directive")
***

## Integrated NuGet
![NuGet Example](https://raw.github.com/BayardRock/IfSharp/master/docs/files/img/NuGet-1.png "NuGet example")
![NuGet Example](docs/files/img/NuGet-1.png?raw=true "NuGet example")

## Inline Error Messages
![Inline Error Message](https://raw.github.com/BayardRock/IfSharp/master/docs/files/img/errors-1.png "Inline error message")
![Inline Error Message](docs/files/img/errors-1.png?raw=true "Inline error message")
5 changes: 2 additions & 3 deletions ipython-profile/ipython_config.py
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
c = get_config()
c.KernelManager.kernel_spec = [r"%s", "{connection_file}"]
c.Session.key = b''
c.Session.keyfile = ''
c.KernelManager.kernel_spec = [ "mono", r"%kexe", "{connection_file}"]
c.NotebookApp.extra_static_paths = [ r"%kstatic" ]
164 changes: 164 additions & 0 deletions ipython-profile/kernel.js
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
define(function () {

var link = document.createElement("link");
link.type = "text/css";
link.rel = "stylesheet";
link.href = "/static/custom/fsharp.css";
document.getElementsByTagName("head")[0].appendChild(link);

require(['codemirror/addon/mode/loadmode']);

var onload = function () {

var md = IPython.notebook.metadata;
if (md.language) {
console.log('language already defined and is :', md.language);
}
else {
md.language = 'fsharp';
console.log('add metadata hint that language is fsharp...');
}

require(['/static/custom/fsharp.js']);

IPython.CodeCell.options_default.cm_config.mode = 'fsharp';

// callback called by the end-user
function updateMarkers(data) {
// applies intellisense hooks onto all cells
var cells = getCodeCells();
data.forEach(function (err) {
var cell = cells.cells[err.CellNumber]
var editor = cell.code_mirror;

// clear our error marks
editor.doc.getAllMarks()
.forEach(function (m) {
if (m.className === 'br-errormarker') {
m.clear();
}
});

var from = { line: err.StartLine, ch: err.StartColumn };
var to = { line: err.EndLine, ch: err.EndColumn };
editor.doc.markText(from, to, { title: err.Message, className: 'br-errormarker' });
});
}

function getCodeCells() {
var results = { codes: [], cells: [], selectedCell: null, selectedIndex: 0 };
IPython.notebook.get_cells()
.forEach(function (c) {
if (c.cell_type === 'code') {
if (c.selected === true) {
results.selectedCell = c;
results.selectedIndex = results.cells.length;
}
results.cells.push(c);
results.codes.push(c.code_mirror.getValue());
}
});

return results;
}

require(['/static/custom/webintellisense.js', '/static/custom/webintellisense-codemirror.js'], function () {
// applies intellisense hooks onto a cell
function applyIntellisense(cell) {
if (cell.cell_type !== 'code') { return; }

var editor = cell.code_mirror;
if (editor.intellisense == null) {
var intellisense = new CodeMirrorIntellisense(editor);
cell.force_highlight('fsharp');
cell.code_mirror.setOption('theme', 'neat');
editor.intellisense = intellisense;

intellisense.addDeclarationTrigger({ keyCode: 190 }); // `.`
intellisense.addDeclarationTrigger({ keyCode: 32, ctrlKey: true, preventDefault: true, type: 'down' }); // `ctrl+space`
intellisense.addDeclarationTrigger({ keyCode: 191 }); // `/`
intellisense.addDeclarationTrigger({ keyCode: 220 }); // `\`
intellisense.addDeclarationTrigger({ keyCode: 222 }); // `"`
intellisense.addDeclarationTrigger({ keyCode: 222, shiftKey: true }); // `"`
intellisense.addMethodsTrigger({ keyCode: 57, shiftKey: true }); // `(`
intellisense.addMethodsTrigger({ keyCode: 48, shiftKey: true });// `)`
intellisense.onMethod(function (item, position) {

});
intellisense.onDeclaration(function (item, position) {
var cells = getCodeCells();
var codes = cells.codes;
var cursor = cells.selectedCell.code_mirror.doc.getCursor();
var callbacks = { shell: {}, iopub: {} };
var line = editor.getLine(cursor.line);
var isSlash = item.keyCode === 191 || item.keyCode === 220;
var isQuote = item.keyCode === 222;

var isLoadOrRef = line.indexOf('#load') === 0
|| line.indexOf('#r') === 0;

var isStartLoadOrRef = line === '#load "'
|| line === '#r "'
|| line === '#load @"'
|| line === '#r @"';

if (isSlash && !isLoadOrRef) {
return;
}
if (isQuote && !isStartLoadOrRef) {
return;
}

// v2
callbacks.shell.reply = function (msg) {
intellisense.setDeclarations(msg.content.matches);
if (msg.content.filter_start_index)
intellisense.setStartColumnIndex(msg.content.filter_start_index);
};

callbacks.iopub.output = function (msg) {
updateMarkers(msg.content.data.errors);
};

// v1
callbacks.complete_reply = function (data) {
intellisense.setDeclarations(data.matches);
intellisense.setStartColumnIndex(data.filter_start_index);
};

callbacks.output = function (msgType, content, metadata) {
updateMarkers(content.data.errors);
};

var content = {
text: JSON.stringify(codes),
line: '',
block: JSON.stringify({ selectedIndex: cells.selectedIndex, ch: cursor.ch, line: cursor.line }),
cursor_pos: cursor.ch
};

IPython.notebook.kernel.send_shell_message("intellisense_request", content, callbacks, null, null);
});
}
}

// applies intellisense hooks onto all cells
IPython.notebook.get_cells()
.forEach(function (cell) {
applyIntellisense(cell);
});

// applies intellisense hooks onto cells that are selected
$([IPython.events]).on('create.Cell', function (event, data) {
applyIntellisense(data.cell);
});
});

// replace the image
var img = $('.container img')[0];
img.src = "/static/custom/ifsharp_logo.png";

}

return { onload: onload }
})
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
9612a03
Fixed IntelliSense and syntax highlighting
Oct 20, 2015
d401422
Added git-excluded files
Oct 20, 2015
98d8ce8
Added missing file
Oct 20, 2015
62c7162
Implemented message signing
Oct 20, 2015
af8b6a5
Proper handling of unsigned messages.
Oct 20, 2015
6db4242
linux kernel spec paths corrected
npmurphy Oct 20, 2015
199454f
merging with master
npmurphy Oct 20, 2015
ff83e69
remove old 0zmq comment
npmurphy Oct 20, 2015
57e845f
Merge pull request #1 from npmurphy/filippo_fork
FilippoPolo Oct 21, 2015
ccc7345
Merge pull request #2 from npmurphy/merge_filippo_fork
FilippoPolo Oct 21, 2015
491edf0
Fixed automerge mistake
Oct 21, 2015
41b93bf
Added InspectRequest dummy implementation
Oct 27, 2015
d134d24
Added dummy answer to inspect_request
Oct 27, 2015
1e7d25f
Wrapped logging in an exception handler
Oct 28, 2015
479c618
Added GenericChartsWithSize, for outputting multiple charts.
Oct 28, 2015
d91f800
Extending MultiplePlots to use different numbers of columns
ndalchau Oct 30, 2015
bfedd74
Reverting to packages version of FSharp.Charting.
ndalchau Nov 4, 2015
6f8b84d
Added the ability to prepare temporary files to serve.
Nov 4, 2015
6a9130f
Added some helpers to allow arranging multiple images in an output.
Nov 4, 2015
93dd982
Added SVG moving and merging functions.
Nov 5, 2015
2c4bf70
NuGet package installation will now copy content files to a "content"…
Nov 5, 2015
b3bbeb0
Substitute in F# 3.1 for later versions
cgravill Dec 2, 2015
0ca6e27
Merge pull request #3 from cgravill/master
FilippoPolo Dec 2, 2015
e0637fa
Updated documentation file
Feb 5, 2016
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
5 changes: 3 additions & 2 deletions IfSharp.sln
Original file line numberDiff line numberDiff line change
Expand Up@@ -52,6 +52,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ipython-profile", "ipython-
ProjectSection(SolutionItems) = preProject
ipython-profile\static\custom\ifsharp_logo.png = ipython-profile\static\custom\ifsharp_logo.png
ipython-profile\ipython_config.py = ipython-profile\ipython_config.py
ipython-profile\ipython_qtconsole_config.py = ipython-profile\ipython_qtconsole_config.py
ipython-profile\kernel.js = ipython-profile\kernel.js
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IfSharpConsole", "src\IfSharpConsole\IfSharpConsole.csproj", "{6BD0E996-0AEE-4FC7-8FB9-46E033D0C7F1}"
Expand All@@ -60,8 +62,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "static", "static", "{45519D
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "custom", "custom", "{3AAFA64D-CBB6-488E-B395-6A1E7CB554CE}"
ProjectSection(SolutionItems) = preProject
ipython-profile\static\custom\custom.css = ipython-profile\static\custom\custom.css
ipython-profile\static\custom\custom.js = ipython-profile\static\custom\custom.js
ipython-profile\static\custom\fsharp.css = ipython-profile\static\custom\fsharp.css
ipython-profile\static\custom\fsharp.js = ipython-profile\static\custom\fsharp.js
ipython-profile\static\custom\ifsharp_logo.png = ipython-profile\static\custom\ifsharp_logo.png
ipython-profile\static\custom\webintellisense-codemirror.js = ipython-profile\static\custom\webintellisense-codemirror.js
Expand Down
43 changes: 25 additions & 18 deletions README.md
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,48 @@
# IfSharp
F# implementation for [iPython](http://ipython.org). View the [Feature Notebook](http://nbviewer.ipython.org/github/BayardRock/IfSharp/blob/master/Feature%20Notebook.ipynb) for some of the features that are included.
For more information view the [documenation](http://bayardrock.github.io/IfSharp/). IfSharp is 64-bit *ONLY*.
F# implementation for [Jupyter](http://jupyter.org/). View the [Feature Notebook](http://nbviewer.jupyter.org/github/fsprojects/IfSharp/blob/master/Feature%20Notebook.ipynb) for some of the features that are included.
For more information view the [documentation](http://fsprojects.github.io/IfSharp/). IfSharp is 64-bit *ONLY*.

# Compatibility
IfSharp works with iPython Notebook 1.x and 2.x
IfSharp works with Jupyter 4.0 and 4.1 and works with both Python 2.X and Python 3.X

# Automatic Installation
See our [release repository](https://github.com/BayardRock/IfSharp/releases). Also, [installation documentation](http://bayardrock.github.io/IfSharp/installation.html).
Previous releases for the IPython notebook are here: [release repository](https://github.com/fsprojects/IfSharp/releases).
Automatic installs for Jupyter will be provided in the future.

# Manual Installation
# Manual Installation (Windows)
1. Install [Anaconda](http://continuum.io/downloads)
2. Install [IPython](http://ipython.org/install.html)
3. Run: "ipython profile create ifsharp" in your user directory
4. Open the iF# solution file, restore nuget packages, and compile it
5. Copy the files from IfSharp\ipython-profile to the iFSharp profile directory
6. Open up the copied "ipython_config.py" file and replace "%s" with the path of your compiled ifsharp executable. E.g. "C:\\git\\ifsharp\\bin\\Release\\ifsharp.exe"
7. Run: "ipython notebook --profile ifsharp" to launch the notebook process with the F# kernel.
2. Install [Jupyter](http://jupyter.readthedocs.org/en/latest/install.html)
3. Checkout the repository
4. Open the IfSharp solution file, restore nuget packages, and compile it
5. Run the IfSharpConsole project, this will register IfSharp and launch Jupyter

Jupyter with IfSharp can be run via "jupyter notebook" in future

# Manual Installation (Mac)
TODO

# Manual Installation (Ubuntu)
TODO

# Screens
## Intellisense
![Intellisense Example #1](https://raw.github.com/BayardRock/IfSharp/master/docs/files/img/intellisense-1.png "Intellisense Example #1")
![Intellisense Example #1](/docs/files/img/intellisense-1.png?raw=true "Intellisense Example #1")
***

![Intellisense Example #2](https://raw.github.com/BayardRock/IfSharp/master/docs/files/img/intellisense-2.png "Intellisense Example #2")
![Intellisense Example #2](docs/files/img/intellisense-2.png?raw=true "Intellisense Example #2")
***

![Intellisense Example #3 With Chart](https://raw.github.com/BayardRock/IfSharp/master/docs/files/img/intellisense-3.png "Intellisense Example #3 With Chart")
![Intellisense Example #3 With Chart](docs/files/img/intellisense-3.png?raw=true "Intellisense Example #3 With Chart")
***

![Intellisense Example #4 #r Directive](https://raw.github.com/BayardRock/IfSharp/master/docs/files/img/intellisense-reference.gif "Intellisense Example #3 #r Directive")
![Intellisense Example #4 #r Directive](docs/files/img/intellisense-reference.gif?raw=true "Intellisense Example #3 #r Directive")
***

![Intellisense Example #5 #load Directive](https://raw.github.com/BayardRock/IfSharp/master/docs/files/img/intellisense-5.png "Intellisense Example #load Directive")
![Intellisense Example #5 #load Directive](docs/files/img/intellisense-5.png?raw=true "Intellisense Example #load Directive")
***

## Integrated NuGet
![NuGet Example](https://raw.github.com/BayardRock/IfSharp/master/docs/files/img/NuGet-1.png "NuGet example")
![NuGet Example](docs/files/img/NuGet-1.png?raw=true "NuGet example")

## Inline Error Messages
![Inline Error Message](https://raw.github.com/BayardRock/IfSharp/master/docs/files/img/errors-1.png "Inline error message")
![Inline Error Message](docs/files/img/errors-1.png?raw=true "Inline error message")
5 changes: 2 additions & 3 deletions ipython-profile/ipython_config.py
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
c = get_config()
c.KernelManager.kernel_spec = [r"%s", "{connection_file}"]
c.Session.key = b''
c.Session.keyfile = ''
c.KernelManager.kernel_spec = [ "mono", r"%kexe", "{connection_file}"]
c.NotebookApp.extra_static_paths = [ r"%kstatic" ]
164 changes: 164 additions & 0 deletions ipython-profile/kernel.js
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
define(function () {

var link = document.createElement("link");
link.type = "text/css";
link.rel = "stylesheet";
link.href = "/static/custom/fsharp.css";
document.getElementsByTagName("head")[0].appendChild(link);

require(['codemirror/addon/mode/loadmode']);

var onload = function () {

var md = IPython.notebook.metadata;
if (md.language) {
console.log('language already defined and is :', md.language);
}
else {
md.language = 'fsharp';
console.log('add metadata hint that language is fsharp...');
}

require(['/static/custom/fsharp.js']);

IPython.CodeCell.options_default.cm_config.mode = 'fsharp';

// callback called by the end-user
function updateMarkers(data) {
// applies intellisense hooks onto all cells
var cells = getCodeCells();
data.forEach(function (err) {
var cell = cells.cells[err.CellNumber]
var editor = cell.code_mirror;

// clear our error marks
editor.doc.getAllMarks()
.forEach(function (m) {
if (m.className === 'br-errormarker') {
m.clear();
}
});

var from = { line: err.StartLine, ch: err.StartColumn };
var to = { line: err.EndLine, ch: err.EndColumn };
editor.doc.markText(from, to, { title: err.Message, className: 'br-errormarker' });
});
}

function getCodeCells() {
var results = { codes: [], cells: [], selectedCell: null, selectedIndex: 0 };
IPython.notebook.get_cells()
.forEach(function (c) {
if (c.cell_type === 'code') {
if (c.selected === true) {
results.selectedCell = c;
results.selectedIndex = results.cells.length;
}
results.cells.push(c);
results.codes.push(c.code_mirror.getValue());
}
});

return results;
}

require(['/static/custom/webintellisense.js', '/static/custom/webintellisense-codemirror.js'], function () {
// applies intellisense hooks onto a cell
function applyIntellisense(cell) {
if (cell.cell_type !== 'code') { return; }

var editor = cell.code_mirror;
if (editor.intellisense == null) {
var intellisense = new CodeMirrorIntellisense(editor);
cell.force_highlight('fsharp');
cell.code_mirror.setOption('theme', 'neat');
editor.intellisense = intellisense;

intellisense.addDeclarationTrigger({ keyCode: 190 }); // `.`
intellisense.addDeclarationTrigger({ keyCode: 32, ctrlKey: true, preventDefault: true, type: 'down' }); // `ctrl+space`
intellisense.addDeclarationTrigger({ keyCode: 191 }); // `/`
intellisense.addDeclarationTrigger({ keyCode: 220 }); // `\`
intellisense.addDeclarationTrigger({ keyCode: 222 }); // `"`
intellisense.addDeclarationTrigger({ keyCode: 222, shiftKey: true }); // `"`
intellisense.addMethodsTrigger({ keyCode: 57, shiftKey: true }); // `(`
intellisense.addMethodsTrigger({ keyCode: 48, shiftKey: true });// `)`
intellisense.onMethod(function (item, position) {

});
intellisense.onDeclaration(function (item, position) {
var cells = getCodeCells();
var codes = cells.codes;
var cursor = cells.selectedCell.code_mirror.doc.getCursor();
var callbacks = { shell: {}, iopub: {} };
var line = editor.getLine(cursor.line);
var isSlash = item.keyCode === 191 || item.keyCode === 220;
var isQuote = item.keyCode === 222;

var isLoadOrRef = line.indexOf('#load') === 0
|| line.indexOf('#r') === 0;

var isStartLoadOrRef = line === '#load "'
|| line === '#r "'
|| line === '#load @"'
|| line === '#r @"';

if (isSlash && !isLoadOrRef) {
return;
}
if (isQuote && !isStartLoadOrRef) {
return;
}

// v2
callbacks.shell.reply = function (msg) {
intellisense.setDeclarations(msg.content.matches);
if (msg.content.filter_start_index)
intellisense.setStartColumnIndex(msg.content.filter_start_index);
};

callbacks.iopub.output = function (msg) {
updateMarkers(msg.content.data.errors);
};

// v1
callbacks.complete_reply = function (data) {
intellisense.setDeclarations(data.matches);
intellisense.setStartColumnIndex(data.filter_start_index);
};

callbacks.output = function (msgType, content, metadata) {
updateMarkers(content.data.errors);
};

var content = {
text: JSON.stringify(codes),
line: '',
block: JSON.stringify({ selectedIndex: cells.selectedIndex, ch: cursor.ch, line: cursor.line }),
cursor_pos: cursor.ch
};

IPython.notebook.kernel.send_shell_message("intellisense_request", content, callbacks, null, null);
});
}
}

// applies intellisense hooks onto all cells
IPython.notebook.get_cells()
.forEach(function (cell) {
applyIntellisense(cell);
});

// applies intellisense hooks onto cells that are selected
$([IPython.events]).on('create.Cell', function (event, data) {
applyIntellisense(data.cell);
});
});

// replace the image
var img = $('.container img')[0];
img.src = "/static/custom/ifsharp_logo.png";

}

return { onload: onload }
})
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
9612a03
Fixed IntelliSense and syntax highlighting
Oct 20, 2015
d401422
Added git-excluded files
Oct 20, 2015
98d8ce8
Added missing file
Oct 20, 2015
62c7162
Implemented message signing
Oct 20, 2015
af8b6a5
Proper handling of unsigned messages.
Oct 20, 2015
6db4242
linux kernel spec paths corrected
npmurphy Oct 20, 2015
199454f
merging with master
npmurphy Oct 20, 2015
ff83e69
remove old 0zmq comment
npmurphy Oct 20, 2015
57e845f
Merge pull request #1 from npmurphy/filippo_fork
FilippoPolo Oct 21, 2015
ccc7345
Merge pull request #2 from npmurphy/merge_filippo_fork
FilippoPolo Oct 21, 2015
491edf0
Fixed automerge mistake
Oct 21, 2015
41b93bf
Added InspectRequest dummy implementation
Oct 27, 2015
d134d24
Added dummy answer to inspect_request
Oct 27, 2015
1e7d25f
Wrapped logging in an exception handler
Oct 28, 2015
479c618
Added GenericChartsWithSize, for outputting multiple charts.
Oct 28, 2015
d91f800
Extending MultiplePlots to use different numbers of columns
ndalchau Oct 30, 2015
bfedd74
Reverting to packages version of FSharp.Charting.
ndalchau Nov 4, 2015
6f8b84d
Added the ability to prepare temporary files to serve.
Nov 4, 2015
6a9130f
Added some helpers to allow arranging multiple images in an output.
Nov 4, 2015
93dd982
Added SVG moving and merging functions.
Nov 5, 2015
2c4bf70
NuGet package installation will now copy content files to a "content"…
Nov 5, 2015
b3bbeb0
Substitute in F# 3.1 for later versions
cgravill Dec 2, 2015
0ca6e27
Merge pull request #3 from cgravill/master
FilippoPolo Dec 2, 2015
e0637fa
Updated documentation file
Feb 5, 2016
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
5 changes: 3 additions & 2 deletions IfSharp.sln
Original file line numberDiff line numberDiff line change
Expand Up@@ -52,6 +52,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ipython-profile", "ipython-
ProjectSection(SolutionItems) = preProject
ipython-profile\static\custom\ifsharp_logo.png = ipython-profile\static\custom\ifsharp_logo.png
ipython-profile\ipython_config.py = ipython-profile\ipython_config.py
ipython-profile\ipython_qtconsole_config.py = ipython-profile\ipython_qtconsole_config.py
ipython-profile\kernel.js = ipython-profile\kernel.js
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IfSharpConsole", "src\IfSharpConsole\IfSharpConsole.csproj", "{6BD0E996-0AEE-4FC7-8FB9-46E033D0C7F1}"
Expand All@@ -60,8 +62,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "static", "static", "{45519D
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "custom", "custom", "{3AAFA64D-CBB6-488E-B395-6A1E7CB554CE}"
ProjectSection(SolutionItems) = preProject
ipython-profile\static\custom\custom.css = ipython-profile\static\custom\custom.css
ipython-profile\static\custom\custom.js = ipython-profile\static\custom\custom.js
ipython-profile\static\custom\fsharp.css = ipython-profile\static\custom\fsharp.css
ipython-profile\static\custom\fsharp.js = ipython-profile\static\custom\fsharp.js
ipython-profile\static\custom\ifsharp_logo.png = ipython-profile\static\custom\ifsharp_logo.png
ipython-profile\static\custom\webintellisense-codemirror.js = ipython-profile\static\custom\webintellisense-codemirror.js
Expand Down
43 changes: 25 additions & 18 deletions README.md
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,48 @@
# IfSharp
F# implementation for [iPython](http://ipython.org). View the [Feature Notebook](http://nbviewer.ipython.org/github/BayardRock/IfSharp/blob/master/Feature%20Notebook.ipynb) for some of the features that are included.
For more information view the [documenation](http://bayardrock.github.io/IfSharp/). IfSharp is 64-bit *ONLY*.
F# implementation for [Jupyter](http://jupyter.org/). View the [Feature Notebook](http://nbviewer.jupyter.org/github/fsprojects/IfSharp/blob/master/Feature%20Notebook.ipynb) for some of the features that are included.
For more information view the [documentation](http://fsprojects.github.io/IfSharp/). IfSharp is 64-bit *ONLY*.

# Compatibility
IfSharp works with iPython Notebook 1.x and 2.x
IfSharp works with Jupyter 4.0 and 4.1 and works with both Python 2.X and Python 3.X

# Automatic Installation
See our [release repository](https://github.com/BayardRock/IfSharp/releases). Also, [installation documentation](http://bayardrock.github.io/IfSharp/installation.html).
Previous releases for the IPython notebook are here: [release repository](https://github.com/fsprojects/IfSharp/releases).
Automatic installs for Jupyter will be provided in the future.

# Manual Installation
# Manual Installation (Windows)
1. Install [Anaconda](http://continuum.io/downloads)
2. Install [IPython](http://ipython.org/install.html)
3. Run: "ipython profile create ifsharp" in your user directory
4. Open the iF# solution file, restore nuget packages, and compile it
5. Copy the files from IfSharp\ipython-profile to the iFSharp profile directory
6. Open up the copied "ipython_config.py" file and replace "%s" with the path of your compiled ifsharp executable. E.g. "C:\\git\\ifsharp\\bin\\Release\\ifsharp.exe"
7. Run: "ipython notebook --profile ifsharp" to launch the notebook process with the F# kernel.
2. Install [Jupyter](http://jupyter.readthedocs.org/en/latest/install.html)
3. Checkout the repository
4. Open the IfSharp solution file, restore nuget packages, and compile it
5. Run the IfSharpConsole project, this will register IfSharp and launch Jupyter

Jupyter with IfSharp can be run via "jupyter notebook" in future

# Manual Installation (Mac)
TODO

# Manual Installation (Ubuntu)
TODO

# Screens
## Intellisense
![Intellisense Example #1](https://raw.github.com/BayardRock/IfSharp/master/docs/files/img/intellisense-1.png "Intellisense Example #1")
![Intellisense Example #1](/docs/files/img/intellisense-1.png?raw=true "Intellisense Example #1")
***

![Intellisense Example #2](https://raw.github.com/BayardRock/IfSharp/master/docs/files/img/intellisense-2.png "Intellisense Example #2")
![Intellisense Example #2](docs/files/img/intellisense-2.png?raw=true "Intellisense Example #2")
***

![Intellisense Example #3 With Chart](https://raw.github.com/BayardRock/IfSharp/master/docs/files/img/intellisense-3.png "Intellisense Example #3 With Chart")
![Intellisense Example #3 With Chart](docs/files/img/intellisense-3.png?raw=true "Intellisense Example #3 With Chart")
***

![Intellisense Example #4 #r Directive](https://raw.github.com/BayardRock/IfSharp/master/docs/files/img/intellisense-reference.gif "Intellisense Example #3 #r Directive")
![Intellisense Example #4 #r Directive](docs/files/img/intellisense-reference.gif?raw=true "Intellisense Example #3 #r Directive")
***

![Intellisense Example #5 #load Directive](https://raw.github.com/BayardRock/IfSharp/master/docs/files/img/intellisense-5.png "Intellisense Example #load Directive")
![Intellisense Example #5 #load Directive](docs/files/img/intellisense-5.png?raw=true "Intellisense Example #load Directive")
***

## Integrated NuGet
![NuGet Example](https://raw.github.com/BayardRock/IfSharp/master/docs/files/img/NuGet-1.png "NuGet example")
![NuGet Example](docs/files/img/NuGet-1.png?raw=true "NuGet example")

## Inline Error Messages
![Inline Error Message](https://raw.github.com/BayardRock/IfSharp/master/docs/files/img/errors-1.png "Inline error message")
![Inline Error Message](docs/files/img/errors-1.png?raw=true "Inline error message")
5 changes: 2 additions & 3 deletions ipython-profile/ipython_config.py
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
c = get_config()
c.KernelManager.kernel_spec = [r"%s", "{connection_file}"]
c.Session.key = b''
c.Session.keyfile = ''
c.KernelManager.kernel_spec = [ "mono", r"%kexe", "{connection_file}"]
c.NotebookApp.extra_static_paths = [ r"%kstatic" ]
164 changes: 164 additions & 0 deletions ipython-profile/kernel.js
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
define(function () {

var link = document.createElement("link");
link.type = "text/css";
link.rel = "stylesheet";
link.href = "/static/custom/fsharp.css";
document.getElementsByTagName("head")[0].appendChild(link);

require(['codemirror/addon/mode/loadmode']);

var onload = function () {

var md = IPython.notebook.metadata;
if (md.language) {
console.log('language already defined and is :', md.language);
}
else {
md.language = 'fsharp';
console.log('add metadata hint that language is fsharp...');
}

require(['/static/custom/fsharp.js']);

IPython.CodeCell.options_default.cm_config.mode = 'fsharp';

// callback called by the end-user
function updateMarkers(data) {
// applies intellisense hooks onto all cells
var cells = getCodeCells();
data.forEach(function (err) {
var cell = cells.cells[err.CellNumber]
var editor = cell.code_mirror;

// clear our error marks
editor.doc.getAllMarks()
.forEach(function (m) {
if (m.className === 'br-errormarker') {
m.clear();
}
});

var from = { line: err.StartLine, ch: err.StartColumn };
var to = { line: err.EndLine, ch: err.EndColumn };
editor.doc.markText(from, to, { title: err.Message, className: 'br-errormarker' });
});
}

function getCodeCells() {
var results = { codes: [], cells: [], selectedCell: null, selectedIndex: 0 };
IPython.notebook.get_cells()
.forEach(function (c) {
if (c.cell_type === 'code') {
if (c.selected === true) {
results.selectedCell = c;
results.selectedIndex = results.cells.length;
}
results.cells.push(c);
results.codes.push(c.code_mirror.getValue());
}
});

return results;
}

require(['/static/custom/webintellisense.js', '/static/custom/webintellisense-codemirror.js'], function () {
// applies intellisense hooks onto a cell
function applyIntellisense(cell) {
if (cell.cell_type !== 'code') { return; }

var editor = cell.code_mirror;
if (editor.intellisense == null) {
var intellisense = new CodeMirrorIntellisense(editor);
cell.force_highlight('fsharp');
cell.code_mirror.setOption('theme', 'neat');
editor.intellisense = intellisense;

intellisense.addDeclarationTrigger({ keyCode: 190 }); // `.`
intellisense.addDeclarationTrigger({ keyCode: 32, ctrlKey: true, preventDefault: true, type: 'down' }); // `ctrl+space`
intellisense.addDeclarationTrigger({ keyCode: 191 }); // `/`
intellisense.addDeclarationTrigger({ keyCode: 220 }); // `\`
intellisense.addDeclarationTrigger({ keyCode: 222 }); // `"`
intellisense.addDeclarationTrigger({ keyCode: 222, shiftKey: true }); // `"`
intellisense.addMethodsTrigger({ keyCode: 57, shiftKey: true }); // `(`
intellisense.addMethodsTrigger({ keyCode: 48, shiftKey: true });// `)`
intellisense.onMethod(function (item, position) {

});
intellisense.onDeclaration(function (item, position) {
var cells = getCodeCells();
var codes = cells.codes;
var cursor = cells.selectedCell.code_mirror.doc.getCursor();
var callbacks = { shell: {}, iopub: {} };
var line = editor.getLine(cursor.line);
var isSlash = item.keyCode === 191 || item.keyCode === 220;
var isQuote = item.keyCode === 222;

var isLoadOrRef = line.indexOf('#load') === 0
|| line.indexOf('#r') === 0;

var isStartLoadOrRef = line === '#load "'
|| line === '#r "'
|| line === '#load @"'
|| line === '#r @"';

if (isSlash && !isLoadOrRef) {
return;
}
if (isQuote && !isStartLoadOrRef) {
return;
}

// v2
callbacks.shell.reply = function (msg) {
intellisense.setDeclarations(msg.content.matches);
if (msg.content.filter_start_index)
intellisense.setStartColumnIndex(msg.content.filter_start_index);
};

callbacks.iopub.output = function (msg) {
updateMarkers(msg.content.data.errors);
};

// v1
callbacks.complete_reply = function (data) {
intellisense.setDeclarations(data.matches);
intellisense.setStartColumnIndex(data.filter_start_index);
};

callbacks.output = function (msgType, content, metadata) {
updateMarkers(content.data.errors);
};

var content = {
text: JSON.stringify(codes),
line: '',
block: JSON.stringify({ selectedIndex: cells.selectedIndex, ch: cursor.ch, line: cursor.line }),
cursor_pos: cursor.ch
};

IPython.notebook.kernel.send_shell_message("intellisense_request", content, callbacks, null, null);
});
}
}

// applies intellisense hooks onto all cells
IPython.notebook.get_cells()
.forEach(function (cell) {
applyIntellisense(cell);
});

// applies intellisense hooks onto cells that are selected
$([IPython.events]).on('create.Cell', function (event, data) {
applyIntellisense(data.cell);
});
});

// replace the image
var img = $('.container img')[0];
img.src = "/static/custom/ifsharp_logo.png";

}

return { onload: onload }
})
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
9612a03
Fixed IntelliSense and syntax highlighting
Oct 20, 2015
d401422
Added git-excluded files
Oct 20, 2015
98d8ce8
Added missing file
Oct 20, 2015
62c7162
Implemented message signing
Oct 20, 2015
af8b6a5
Proper handling of unsigned messages.
Oct 20, 2015
6db4242
linux kernel spec paths corrected
npmurphy Oct 20, 2015
199454f
merging with master
npmurphy Oct 20, 2015
ff83e69
remove old 0zmq comment
npmurphy Oct 20, 2015
57e845f
Merge pull request #1 from npmurphy/filippo_fork
FilippoPolo Oct 21, 2015
ccc7345
Merge pull request #2 from npmurphy/merge_filippo_fork
FilippoPolo Oct 21, 2015
491edf0
Fixed automerge mistake
Oct 21, 2015
41b93bf
Added InspectRequest dummy implementation
Oct 27, 2015
d134d24
Added dummy answer to inspect_request
Oct 27, 2015
1e7d25f
Wrapped logging in an exception handler
Oct 28, 2015
479c618
Added GenericChartsWithSize, for outputting multiple charts.
Oct 28, 2015
d91f800
Extending MultiplePlots to use different numbers of columns
ndalchau Oct 30, 2015
bfedd74
Reverting to packages version of FSharp.Charting.
ndalchau Nov 4, 2015
6f8b84d
Added the ability to prepare temporary files to serve.
Nov 4, 2015
6a9130f
Added some helpers to allow arranging multiple images in an output.
Nov 4, 2015
93dd982
Added SVG moving and merging functions.
Nov 5, 2015
2c4bf70
NuGet package installation will now copy content files to a "content"…
Nov 5, 2015
b3bbeb0
Substitute in F# 3.1 for later versions
cgravill Dec 2, 2015
0ca6e27
Merge pull request #3 from cgravill/master
FilippoPolo Dec 2, 2015
e0637fa
Updated documentation file
Feb 5, 2016
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
5 changes: 3 additions & 2 deletions IfSharp.sln
Original file line numberDiff line numberDiff line change
Expand Up@@ -52,6 +52,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ipython-profile", "ipython-
ProjectSection(SolutionItems) = preProject
ipython-profile\static\custom\ifsharp_logo.png = ipython-profile\static\custom\ifsharp_logo.png
ipython-profile\ipython_config.py = ipython-profile\ipython_config.py
ipython-profile\ipython_qtconsole_config.py = ipython-profile\ipython_qtconsole_config.py
ipython-profile\kernel.js = ipython-profile\kernel.js
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IfSharpConsole", "src\IfSharpConsole\IfSharpConsole.csproj", "{6BD0E996-0AEE-4FC7-8FB9-46E033D0C7F1}"
Expand All@@ -60,8 +62,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "static", "static", "{45519D
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "custom", "custom", "{3AAFA64D-CBB6-488E-B395-6A1E7CB554CE}"
ProjectSection(SolutionItems) = preProject
ipython-profile\static\custom\custom.css = ipython-profile\static\custom\custom.css
ipython-profile\static\custom\custom.js = ipython-profile\static\custom\custom.js
ipython-profile\static\custom\fsharp.css = ipython-profile\static\custom\fsharp.css
ipython-profile\static\custom\fsharp.js = ipython-profile\static\custom\fsharp.js
ipython-profile\static\custom\ifsharp_logo.png = ipython-profile\static\custom\ifsharp_logo.png
ipython-profile\static\custom\webintellisense-codemirror.js = ipython-profile\static\custom\webintellisense-codemirror.js
Expand Down
43 changes: 25 additions & 18 deletions README.md
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,48 @@
# IfSharp
F# implementation for [iPython](http://ipython.org). View the [Feature Notebook](http://nbviewer.ipython.org/github/BayardRock/IfSharp/blob/master/Feature%20Notebook.ipynb) for some of the features that are included.
For more information view the [documenation](http://bayardrock.github.io/IfSharp/). IfSharp is 64-bit *ONLY*.
F# implementation for [Jupyter](http://jupyter.org/). View the [Feature Notebook](http://nbviewer.jupyter.org/github/fsprojects/IfSharp/blob/master/Feature%20Notebook.ipynb) for some of the features that are included.
For more information view the [documentation](http://fsprojects.github.io/IfSharp/). IfSharp is 64-bit *ONLY*.

# Compatibility
IfSharp works with iPython Notebook 1.x and 2.x
IfSharp works with Jupyter 4.0 and 4.1 and works with both Python 2.X and Python 3.X

# Automatic Installation
See our [release repository](https://github.com/BayardRock/IfSharp/releases). Also, [installation documentation](http://bayardrock.github.io/IfSharp/installation.html).
Previous releases for the IPython notebook are here: [release repository](https://github.com/fsprojects/IfSharp/releases).
Automatic installs for Jupyter will be provided in the future.

# Manual Installation
# Manual Installation (Windows)
1. Install [Anaconda](http://continuum.io/downloads)
2. Install [IPython](http://ipython.org/install.html)
3. Run: "ipython profile create ifsharp" in your user directory
4. Open the iF# solution file, restore nuget packages, and compile it
5. Copy the files from IfSharp\ipython-profile to the iFSharp profile directory
6. Open up the copied "ipython_config.py" file and replace "%s" with the path of your compiled ifsharp executable. E.g. "C:\\git\\ifsharp\\bin\\Release\\ifsharp.exe"
7. Run: "ipython notebook --profile ifsharp" to launch the notebook process with the F# kernel.
2. Install [Jupyter](http://jupyter.readthedocs.org/en/latest/install.html)
3. Checkout the repository
4. Open the IfSharp solution file, restore nuget packages, and compile it
5. Run the IfSharpConsole project, this will register IfSharp and launch Jupyter

Jupyter with IfSharp can be run via "jupyter notebook" in future

# Manual Installation (Mac)
TODO

# Manual Installation (Ubuntu)
TODO

# Screens
## Intellisense
![Intellisense Example #1](https://raw.github.com/BayardRock/IfSharp/master/docs/files/img/intellisense-1.png "Intellisense Example #1")
![Intellisense Example #1](/docs/files/img/intellisense-1.png?raw=true "Intellisense Example #1")
***

![Intellisense Example #2](https://raw.github.com/BayardRock/IfSharp/master/docs/files/img/intellisense-2.png "Intellisense Example #2")
![Intellisense Example #2](docs/files/img/intellisense-2.png?raw=true "Intellisense Example #2")
***

![Intellisense Example #3 With Chart](https://raw.github.com/BayardRock/IfSharp/master/docs/files/img/intellisense-3.png "Intellisense Example #3 With Chart")
![Intellisense Example #3 With Chart](docs/files/img/intellisense-3.png?raw=true "Intellisense Example #3 With Chart")
***

![Intellisense Example #4 #r Directive](https://raw.github.com/BayardRock/IfSharp/master/docs/files/img/intellisense-reference.gif "Intellisense Example #3 #r Directive")
![Intellisense Example #4 #r Directive](docs/files/img/intellisense-reference.gif?raw=true "Intellisense Example #3 #r Directive")
***

![Intellisense Example #5 #load Directive](https://raw.github.com/BayardRock/IfSharp/master/docs/files/img/intellisense-5.png "Intellisense Example #load Directive")
![Intellisense Example #5 #load Directive](docs/files/img/intellisense-5.png?raw=true "Intellisense Example #load Directive")
***

## Integrated NuGet
![NuGet Example](https://raw.github.com/BayardRock/IfSharp/master/docs/files/img/NuGet-1.png "NuGet example")
![NuGet Example](docs/files/img/NuGet-1.png?raw=true "NuGet example")

## Inline Error Messages
![Inline Error Message](https://raw.github.com/BayardRock/IfSharp/master/docs/files/img/errors-1.png "Inline error message")
![Inline Error Message](docs/files/img/errors-1.png?raw=true "Inline error message")
5 changes: 2 additions & 3 deletions ipython-profile/ipython_config.py
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
c = get_config()
c.KernelManager.kernel_spec = [r"%s", "{connection_file}"]
c.Session.key = b''
c.Session.keyfile = ''
c.KernelManager.kernel_spec = [ "mono", r"%kexe", "{connection_file}"]
c.NotebookApp.extra_static_paths = [ r"%kstatic" ]
164 changes: 164 additions & 0 deletions ipython-profile/kernel.js
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
define(function () {

var link = document.createElement("link");
link.type = "text/css";
link.rel = "stylesheet";
link.href = "/static/custom/fsharp.css";
document.getElementsByTagName("head")[0].appendChild(link);

require(['codemirror/addon/mode/loadmode']);

var onload = function () {

var md = IPython.notebook.metadata;
if (md.language) {
console.log('language already defined and is :', md.language);
}
else {
md.language = 'fsharp';
console.log('add metadata hint that language is fsharp...');
}

require(['/static/custom/fsharp.js']);

IPython.CodeCell.options_default.cm_config.mode = 'fsharp';

// callback called by the end-user
function updateMarkers(data) {
// applies intellisense hooks onto all cells
var cells = getCodeCells();
data.forEach(function (err) {
var cell = cells.cells[err.CellNumber]
var editor = cell.code_mirror;

// clear our error marks
editor.doc.getAllMarks()
.forEach(function (m) {
if (m.className === 'br-errormarker') {
m.clear();
}
});

var from = { line: err.StartLine, ch: err.StartColumn };
var to = { line: err.EndLine, ch: err.EndColumn };
editor.doc.markText(from, to, { title: err.Message, className: 'br-errormarker' });
});
}

function getCodeCells() {
var results = { codes: [], cells: [], selectedCell: null, selectedIndex: 0 };
IPython.notebook.get_cells()
.forEach(function (c) {
if (c.cell_type === 'code') {
if (c.selected === true) {
results.selectedCell = c;
results.selectedIndex = results.cells.length;
}
results.cells.push(c);
results.codes.push(c.code_mirror.getValue());
}
});

return results;
}

require(['/static/custom/webintellisense.js', '/static/custom/webintellisense-codemirror.js'], function () {
// applies intellisense hooks onto a cell
function applyIntellisense(cell) {
if (cell.cell_type !== 'code') { return; }

var editor = cell.code_mirror;
if (editor.intellisense == null) {
var intellisense = new CodeMirrorIntellisense(editor);
cell.force_highlight('fsharp');
cell.code_mirror.setOption('theme', 'neat');
editor.intellisense = intellisense;

intellisense.addDeclarationTrigger({ keyCode: 190 }); // `.`
intellisense.addDeclarationTrigger({ keyCode: 32, ctrlKey: true, preventDefault: true, type: 'down' }); // `ctrl+space`
intellisense.addDeclarationTrigger({ keyCode: 191 }); // `/`
intellisense.addDeclarationTrigger({ keyCode: 220 }); // `\`
intellisense.addDeclarationTrigger({ keyCode: 222 }); // `"`
intellisense.addDeclarationTrigger({ keyCode: 222, shiftKey: true }); // `"`
intellisense.addMethodsTrigger({ keyCode: 57, shiftKey: true }); // `(`
intellisense.addMethodsTrigger({ keyCode: 48, shiftKey: true });// `)`
intellisense.onMethod(function (item, position) {

});
intellisense.onDeclaration(function (item, position) {
var cells = getCodeCells();
var codes = cells.codes;
var cursor = cells.selectedCell.code_mirror.doc.getCursor();
var callbacks = { shell: {}, iopub: {} };
var line = editor.getLine(cursor.line);
var isSlash = item.keyCode === 191 || item.keyCode === 220;
var isQuote = item.keyCode === 222;

var isLoadOrRef = line.indexOf('#load') === 0
|| line.indexOf('#r') === 0;

var isStartLoadOrRef = line === '#load "'
|| line === '#r "'
|| line === '#load @"'
|| line === '#r @"';

if (isSlash && !isLoadOrRef) {
return;
}
if (isQuote && !isStartLoadOrRef) {
return;
}

// v2
callbacks.shell.reply = function (msg) {
intellisense.setDeclarations(msg.content.matches);
if (msg.content.filter_start_index)
intellisense.setStartColumnIndex(msg.content.filter_start_index);
};

callbacks.iopub.output = function (msg) {
updateMarkers(msg.content.data.errors);
};

// v1
callbacks.complete_reply = function (data) {
intellisense.setDeclarations(data.matches);
intellisense.setStartColumnIndex(data.filter_start_index);
};

callbacks.output = function (msgType, content, metadata) {
updateMarkers(content.data.errors);
};

var content = {
text: JSON.stringify(codes),
line: '',
block: JSON.stringify({ selectedIndex: cells.selectedIndex, ch: cursor.ch, line: cursor.line }),
cursor_pos: cursor.ch
};

IPython.notebook.kernel.send_shell_message("intellisense_request", content, callbacks, null, null);
});
}
}

// applies intellisense hooks onto all cells
IPython.notebook.get_cells()
.forEach(function (cell) {
applyIntellisense(cell);
});

// applies intellisense hooks onto cells that are selected
$([IPython.events]).on('create.Cell', function (event, data) {
applyIntellisense(data.cell);
});
});

// replace the image
var img = $('.container img')[0];
img.src = "/static/custom/ifsharp_logo.png";

}

return { onload: onload }
})
Loading