Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a simulator to the editor #49

Open
wants to merge 46 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
236f918
Add auto redirect from index to editor
WilliamMayor Mar 27, 2017
45544ce
Create CNAME
WilliamMayor Mar 27, 2017
f06df07
Merge pull request #15 from WilliamMayor/master
WilliamMayor Mar 27, 2017
4d84186
Add Vagrantfile so development can happen in VM
WilliamMayor Mar 27, 2017
be58016
Add codeguild instructions
WilliamMayor Mar 27, 2017
687d6c9
Merge branch 'master' of https://github.com/CodeGuild-co/PythonEditor
WilliamMayor Mar 27, 2017
4c3521f
Merge pull request #16 from WilliamMayor/master
WilliamMayor Mar 27, 2017
0484744
Added name and description functionality to save button
JordanCaseyHale Mar 29, 2017
04f100b
Add simulator, strip out code
JordanCaseyHale Mar 29, 2017
124aab7
Add simulator to editor page
JordanCaseyHale Mar 30, 2017
c553710
Revert "Add simulator to editor page"
JordanCaseyHale Mar 30, 2017
d403073
Working simulator
JordanCaseyHale Mar 30, 2017
0464bd6
Merge pull request #17 from jamesblissett/master
WilliamMayor Mar 30, 2017
a25297b
Revert "Revert "Add simulator to editor page""
WilliamMayor Mar 30, 2017
8f9ea9a
Tidy imports?
WilliamMayor Mar 30, 2017
bad5785
Remove extra copy
WilliamMayor Mar 30, 2017
3b4348a
Convert line endings to unix
WilliamMayor Mar 30, 2017
b269e6a
Add no Jekyll file so that __ini__.js files are included
WilliamMayor Mar 30, 2017
8ea5b51
Don’t browse to #
WilliamMayor Mar 30, 2017
57c2541
Add gitter badge
WilliamMayor Apr 1, 2017
d34f49f
Merge branch 'master' of https://github.com/bbcmicrobit/PythonEditor
WilliamMayor Apr 30, 2018
0edb8ed
Feature flag added for simulator
BPenhey May 1, 2018
b50899b
Merge pull request #18 from BPenhey/master
WilliamMayor May 1, 2018
4fe9fc7
Replace codeguild and vagrant files with dockerfile
WilliamMayor May 1, 2018
d878367
Merge branch 'master' of https://github.com/CodeGuild-co/PythonEditor
WilliamMayor May 1, 2018
53e3d02
Add port publish to dockerfile
WilliamMayor May 1, 2018
1a6de9e
Thermometer
adeba-io May 2, 2018
dbacaca
Merge branch 'master' of https://github.com/codeguild-co/pythoneditor
adeba-io May 2, 2018
fd076c6
Functioning accelerometer button added to simulator
lucasbebell May 3, 2018
f088e62
Merge pull request #20 from lucasbebell/master
WilliamMayor May 3, 2018
9a14fde
Merge branch 'master' of https://github.com/CodeGuild-co/PythonEditor
WilliamMayor May 3, 2018
6933852
Pins Added
adeba-io May 3, 2018
18a1646
Final Touches
adeba-io May 3, 2018
db9be46
Merge pull request #19 from TiGBS/master
WilliamMayor May 4, 2018
dea5530
Merge branch 'master' of https://github.com/CodeGuild-co/PythonEditor
WilliamMayor May 4, 2018
4630bbf
Added Collaberators
UniversityMaxCoder Apr 9, 2019
0a6ec99
Merge pull request #21 from UniversityMaxCoder/master
WilliamMayor Apr 9, 2019
6859edf
Merged CodeGuild-co/PythonEditor and bbcmicrobit/PythonEditor
truejasonliu Apr 10, 2019
dbaa87c
Added toggle to simulator
truejasonliu Apr 10, 2019
c8aa158
Fixed chevrons
truejasonliu Apr 10, 2019
7f39f71
Removed animated buttons
truejasonliu Apr 10, 2019
aec6e17
Merge pull request #25 from ducklord420/master
WilliamMayor Apr 10, 2019
f6cf30f
Update README.rst
truejasonliu Apr 11, 2019
376b1c0
Improved UI
truejasonliu Apr 11, 2019
e1a68da
Merge branch 'master' of https://github.com/ducklord420/PythonEditor
truejasonliu Apr 11, 2019
ee9d5b8
Merge pull request #26 from ducklord420/master
WilliamMayor Apr 11, 2019
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ Thumbs.db
Desktop.ini
$RECYCLE.BIN/
*.swp
.vagrant
Empty file added .nojekyll
Empty file.
1 change: 1 addition & 0 deletions CNAME
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
micro-edit.codeguild.co
23 changes: 23 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Don't use this dockerfile in production. It's useful for getting a
# development environment working quickly. It's not a good way to serve the
# editor files.
#
# To run a container using this image first build the image:
#
# $ docker build -t pythoneditor .
#
# Then run the image:
#
# $ docker run --interactive --tty --publish 8000:8000 pythoneditor
#
# Now open your browser at http://localhost:8000
#
FROM python:3.6

WORKDIR /usr/src/app

EXPOSE 8000

COPY . /usr/src/app/

CMD python -m http.server --bind 0.0.0.0
11 changes: 7 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,15 @@ This editor works with any modern web browser.
In addition to cloning the repository it is required to retrieve the GIT
submodules::

git clone https://github.com/bbcmicrobit/PythonEditor
git clone https://github.com/ducklord420/PythonEditor.git
cd PythonEditor
git submodule update --init --recursive

**THIS NEEDS TO BE DONE BEFORE ANYTHING ELSE, OR IT WILL NOT WORK.**

Assuming you have Python 3 installed you can serve the editor like this::

$ ./bin/show
http://localhost:8000/editor.html
Serving HTTP on 0.0.0.0 port 8000 ...
py -m http.server --bind 0.0.0.0

As the script tells us, point your browser to http://localhost:8000/editor.html.

Expand Down Expand Up @@ -179,3 +177,8 @@ Legacy
This project was born from a TouchDevelop based editor created by Nicholas
H.Tollervey for the BBC. This is no longer maintained, although you can find it
still on the ``touch-develop-legacy`` branch in this repository.

Villiers Park
-------------

Max Curtis-England
20 changes: 10 additions & 10 deletions ace/ace.js

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions ace/ext-spellcheck.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 32 additions & 5 deletions editor.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!DOCTYPE html>
<html lang="en">
<!--
.:://++++++//:-.
Expand Down Expand Up @@ -68,6 +68,7 @@
<link rel="icon" href="static/img/favicon.ico">
</head>
<body>
<iframe id="sim-iframe" src="about:blank" frameborder="0" scrolling="no"></iframe>
<script type="application/javascript">
if (navigator.appVersion.indexOf("MSIE 9") !== -1 || navigator.appVersion.indexOf("MSIE 8") !== -1 || navigator.appVersion.indexOf("MSIE 7") !== -1)
{
Expand All @@ -90,7 +91,7 @@ <h2><i class="fa fa-upload"></i> <strong>{{ title }}</strong></h2>
<form id="load-form-form">
<input type="file" name="load-form-file-upload"/><br/>
<input type="submit" value="{{ submit }}"/>
</form>
</form>
</div>
<div id="load-alt">
<p><a href="#" class="load-form load-toggle">{{ toggle-drop }}</a></p>
Expand Down Expand Up @@ -129,6 +130,22 @@ <h2><i class="fa fa-share-alt"></i> <strong>{{ title }}</strong></h2>
<p id="shortener" style="display: none;">{{ shortener }} <a href="#" id="short-link"></a></p>
</div>
</script>
<script id="save-name-template" type="x-tmpl-mustache">
<h2><i class="fa fa-download"></i> <strong>{{ title }}</strong></h2>
<div id="make-link">
<p>{{ instructions }}</p>
<p><label for="passphrase" class="share-label">{{ passphrase }}</label> <input id="filename-input" type="text" value="{{ currentfilename }}"/>
</p>
<p><label for="passphrase" class="share-label">{{ passphrase2 }}</label> <input id="desc-input" type="text" value="{{ currentdesc }}"/>
</p>
<p><button id="button-save-file">{{ button }}</button></p>
</div>
<div id="share-link">
<p>{{ description }}</p>
<textarea id="direct-link" readonly style="width:100%; height:200px;border:0;"></textarea>
<p id="shortener" style="display: none;">{{ shortener }} <a href="#" id="short-link"></a></p>
</div>
</script>
<script id="decrypt-template" type="x-tmpl-mustache">
<h2><i class="fa fa-unlock-alt"></i> <strong>{{ title }}</strong></h2>
<p>{{ instructions }}</p>
Expand Down Expand Up @@ -181,6 +198,13 @@ <h2><i class="fa fa-unlock-alt"></i> <strong>{{ title }}</strong></h2>
</div>
<div class="roundlabel">Blockly</div>
</a>
<a href="#" class="roundbutton hidden" id="command-sim"
tabindex="12">
<div class="roundsymbol">
<i class="fa fa-arrow-circle-right"></i>
</div>
<div class="roundlabel">Sim</div>
</a>
<a href="#" class="roundbutton hidden" id="command-snippet"
tabindex="5"
title="Click to select a snippet (code shortcut)">
Expand Down Expand Up @@ -234,10 +258,10 @@ <h2><i class="fa fa-unlock-alt"></i> <strong>{{ title }}</strong></h2>
</div>
</div>
<div class="vbox" id="script-box">
<div id="script-name" class="flex1" contenteditable
<div id="script-name" class="flex1"
tabindex="10">
</div>
<div id="script-description" contenteditable
<div id="script-description"
tabindex="11">
</div>
</div>
Expand Down Expand Up @@ -365,11 +389,13 @@ <h2><i class="fa fa-unlock-alt"></i> <strong>{{ title }}</strong></h2>
'flags': {
'blocks': false,
'snippets': true,
'share': false,
'experimental': false,
'share': false
'sim': true
},
});
</script>

<xml id="blockly-toolbox" style="display: none">
<category name="Accelerometer" colour="0">
<block type="microbit_accelerometer_get_x"></block>
Expand Down Expand Up @@ -700,6 +726,7 @@ <h2><i class="fa fa-unlock-alt"></i> <strong>{{ title }}</strong></h2>
<sep></sep>
<category name="Variables" colour="330" custom="VARIABLE"></category>
</xml>
:1040A0000123037210BDC046ACCF020008B5043036
<div id="firmware" style="display: none;">:020000040000FA
:1000000000400020218E01005D8E01005F8E010006
:1000100000000000000000000000000000000000E0
Expand Down
14 changes: 14 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<meta http-equiv="refresh" content="1; url=/editor.html">
<script type="text/javascript">
window.location.href = "/editor.html"
</script>
<title>Page Redirection</title>
</head>
<body>
If you are not redirected automatically, follow this <a href='/editor.html'>link to example</a>.
</body>
</html>
72 changes: 72 additions & 0 deletions lib/cm/active-line.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE

(function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS
mod(require("../../lib/codemirror"));
else if (typeof define == "function" && define.amd) // AMD
define(["../../lib/codemirror"], mod);
else // Plain browser env
mod(CodeMirror);
})(function(CodeMirror) {
"use strict";
var WRAP_CLASS = "CodeMirror-activeline";
var BACK_CLASS = "CodeMirror-activeline-background";
var GUTT_CLASS = "CodeMirror-activeline-gutter";

CodeMirror.defineOption("styleActiveLine", false, function(cm, val, old) {
var prev = old == CodeMirror.Init ? false : old;
if (val == prev) return
if (prev) {
cm.off("beforeSelectionChange", selectionChange);
clearActiveLines(cm);
delete cm.state.activeLines;
}
if (val) {
cm.state.activeLines = [];
updateActiveLines(cm, cm.listSelections());
cm.on("beforeSelectionChange", selectionChange);
}
});

function clearActiveLines(cm) {
for (var i = 0; i < cm.state.activeLines.length; i++) {
cm.removeLineClass(cm.state.activeLines[i], "wrap", WRAP_CLASS);
cm.removeLineClass(cm.state.activeLines[i], "background", BACK_CLASS);
cm.removeLineClass(cm.state.activeLines[i], "gutter", GUTT_CLASS);
}
}

function sameArray(a, b) {
if (a.length != b.length) return false;
for (var i = 0; i < a.length; i++)
if (a[i] != b[i]) return false;
return true;
}

function updateActiveLines(cm, ranges) {
var active = [];
for (var i = 0; i < ranges.length; i++) {
var range = ranges[i];
var option = cm.getOption("styleActiveLine");
if (typeof option == "object" && option.nonEmpty ? range.anchor.line != range.head.line : !range.empty())
continue
var line = cm.getLineHandleVisualStart(range.head.line);
if (active[active.length - 1] != line) active.push(line);
}
if (sameArray(cm.state.activeLines, active)) return;
cm.operation(function() {
clearActiveLines(cm);
for (var i = 0; i < active.length; i++) {
cm.addLineClass(active[i], "wrap", WRAP_CLASS);
cm.addLineClass(active[i], "background", BACK_CLASS);
cm.addLineClass(active[i], "gutter", GUTT_CLASS);
}
cm.state.activeLines = active;
});
}

function selectionChange(cm, sel) {
updateActiveLines(cm, sel.ranges);
}
});
32 changes: 32 additions & 0 deletions lib/cm/blackboard.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/* Port of TextMate's Blackboard theme */

.cm-s-blackboard.CodeMirror { background: #0C1021; color: #F8F8F8; }
.cm-s-blackboard div.CodeMirror-selected { background: #253B76; }
.cm-s-blackboard .CodeMirror-line::selection, .cm-s-blackboard .CodeMirror-line > span::selection, .cm-s-blackboard .CodeMirror-line > span > span::selection { background: rgba(37, 59, 118, .99); }
.cm-s-blackboard .CodeMirror-line::-moz-selection, .cm-s-blackboard .CodeMirror-line > span::-moz-selection, .cm-s-blackboard .CodeMirror-line > span > span::-moz-selection { background: rgba(37, 59, 118, .99); }
.cm-s-blackboard .CodeMirror-gutters { background: #0C1021; border-right: 0; }
.cm-s-blackboard .CodeMirror-guttermarker { color: #FBDE2D; }
.cm-s-blackboard .CodeMirror-guttermarker-subtle { color: #888; }
.cm-s-blackboard .CodeMirror-linenumber { color: #888; }
.cm-s-blackboard .CodeMirror-cursor { border-left: 1px solid #A7A7A7; }

.cm-s-blackboard .cm-keyword { color: #FBDE2D; }
.cm-s-blackboard .cm-atom { color: #D8FA3C; }
.cm-s-blackboard .cm-number { color: #D8FA3C; }
.cm-s-blackboard .cm-def { color: #8DA6CE; }
.cm-s-blackboard .cm-variable { color: #FF6400; }
.cm-s-blackboard .cm-operator { color: #FBDE2D; }
.cm-s-blackboard .cm-comment { color: #AEAEAE; }
.cm-s-blackboard .cm-string { color: #61CE3C; }
.cm-s-blackboard .cm-string-2 { color: #61CE3C; }
.cm-s-blackboard .cm-meta { color: #D8FA3C; }
.cm-s-blackboard .cm-builtin { color: #8DA6CE; }
.cm-s-blackboard .cm-tag { color: #8DA6CE; }
.cm-s-blackboard .cm-attribute { color: #8DA6CE; }
.cm-s-blackboard .cm-header { color: #FF6400; }
.cm-s-blackboard .cm-hr { color: #AEAEAE; }
.cm-s-blackboard .cm-link { color: #8DA6CE; }
.cm-s-blackboard .cm-error { background: #9D1E15; color: #F8F8F8; }

.cm-s-blackboard .CodeMirror-activeline-background { background: #3C3636; }
.cm-s-blackboard .CodeMirror-matchingbracket { outline:1px solid grey;color:white !important; }
25 changes: 25 additions & 0 deletions lib/cm/cobalt.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
.cm-s-cobalt.CodeMirror { background: #002240; color: white; }
.cm-s-cobalt div.CodeMirror-selected { background: #b36539; }
.cm-s-cobalt .CodeMirror-line::selection, .cm-s-cobalt .CodeMirror-line > span::selection, .cm-s-cobalt .CodeMirror-line > span > span::selection { background: rgba(179, 101, 57, .99); }
.cm-s-cobalt .CodeMirror-line::-moz-selection, .cm-s-cobalt .CodeMirror-line > span::-moz-selection, .cm-s-cobalt .CodeMirror-line > span > span::-moz-selection { background: rgba(179, 101, 57, .99); }
.cm-s-cobalt .CodeMirror-gutters { background: #002240; border-right: 1px solid #aaa; }
.cm-s-cobalt .CodeMirror-guttermarker { color: #ffee80; }
.cm-s-cobalt .CodeMirror-guttermarker-subtle { color: #d0d0d0; }
.cm-s-cobalt .CodeMirror-linenumber { color: #d0d0d0; }
.cm-s-cobalt .CodeMirror-cursor { border-left: 1px solid white; }

.cm-s-cobalt span.cm-comment { color: #08f; }
.cm-s-cobalt span.cm-atom { color: #845dc4; }
.cm-s-cobalt span.cm-number, .cm-s-cobalt span.cm-attribute { color: #ff80e1; }
.cm-s-cobalt span.cm-keyword { color: #ffee80; }
.cm-s-cobalt span.cm-string { color: #3ad900; }
.cm-s-cobalt span.cm-meta { color: #ff9d00; }
.cm-s-cobalt span.cm-variable-2, .cm-s-cobalt span.cm-tag { color: #9effff; }
.cm-s-cobalt span.cm-variable-3, .cm-s-cobalt span.cm-def { color: white; }
.cm-s-cobalt span.cm-bracket { color: #d8d8d8; }
.cm-s-cobalt span.cm-builtin, .cm-s-cobalt span.cm-special { color: #ff9e59; }
.cm-s-cobalt span.cm-link { color: #845dc4; }
.cm-s-cobalt span.cm-error { color: #9d1e15; }

.cm-s-cobalt .CodeMirror-activeline-background { background: #002D57; }
.cm-s-cobalt .CodeMirror-matchingbracket { outline:1px solid grey;color:white !important; }
Loading