mirror of
https://github.com/compiler-explorer/compiler-explorer.git
synced 2026-12-02 15:37:31 -06:00
Merge pull request #800 from mattgodbolt/jw/webpack
This switches us off the legacy of bower and into a brave new world of yarn and webpack.
This commit is contained in:
+4
-1
@@ -2,7 +2,6 @@
|
||||
/node_modules
|
||||
newrelic_agent.log
|
||||
/.npm-updated
|
||||
/.bower-updated
|
||||
*.vscode
|
||||
/out
|
||||
*.heapsnapshot
|
||||
@@ -10,3 +9,7 @@ etc/config/*.local.properties
|
||||
.travis-compilers
|
||||
/nbproject
|
||||
/package-lock.json
|
||||
*.bundle*.js
|
||||
*.map
|
||||
static/dist
|
||||
static/vs
|
||||
|
||||
+4
-3
@@ -5,7 +5,8 @@ Before we go too far, an apology: Compiler Explorer grew out of a bit of hacky J
|
||||
well-used project pretty quickly. Not all the code was originally well-written or well-tested. Please be forgiving of that,
|
||||
and be ready to help in improving that.
|
||||
|
||||
Note that Compiler Explorer targets the latest Node.js LTS, so it's better if you do so as well when testing your changes locally. (But it will run in everything post-Node.js 8)
|
||||
Note that Compiler Explorer targets the latest Node.js LTS, so it's better if you do so as well when testing your changes locally.
|
||||
(But it *should* run in everything post-Node.js 8)
|
||||
|
||||
## In brief
|
||||
* Make your changes, trying to stick to the style and code format where possible. We use default IntelliJ settings,
|
||||
@@ -22,8 +23,8 @@ every commit, ensuring that they pass before commiting your changes. _You can di
|
||||
|
||||
## Basic code layout
|
||||
|
||||
Code is separated into server-side code and client-side code. Server packages are installed via `package.json` and client-side via
|
||||
`bower.json`. Server code is in `app.js` and in the `lib` directory. Client code is all in the `static` directory.
|
||||
Code is separated into server-side code and client-side code. All dependencies (server and client side) are installed via `package.json`.
|
||||
Server code is in `app.js` and in the `lib` directory. Client code is all in the `static` directory.
|
||||
|
||||
In the server code, the `app.js` sets up a basic `express` middleware-driven web server, delegating to the various compiler
|
||||
backends in `lib/compilers`. Most inherit (loosely) from `lib/base-compiler.js` which does most of the work of running
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
NODE_DIR?=/opt/compiler-explorer/node
|
||||
NPM:= $(shell env PATH="$(NODE_DIR)/bin:$$PATH" which npm)
|
||||
NODE:= $(shell env PATH="$(NODE_DIR)/bin:$$PATH" which node || env PATH="$(NODE_DIR)/bin:$$PATH" which nodejs)
|
||||
YARN_DIR?=/opt/compiler-explorer/yarn
|
||||
YARN_EXE:=$(shell env PATH="$(NODE_DIR)/bin:$(YARN_DIR)/bin:$(PATH)" which yarn)
|
||||
NODE:=$(shell env PATH="$(NODE_DIR)/bin:$(PATH)" which node || env PATH="$(NODE_DIR)/bin:$(PATH)" which nodejs)
|
||||
YARN:=$(NODE) $(YARN_EXE).js
|
||||
default: run
|
||||
|
||||
NODE_VERSION_USED:=8
|
||||
@@ -21,9 +23,8 @@ endif
|
||||
endif
|
||||
|
||||
.PHONY: clean run test run-amazon c-preload optional-haskell-support optional-d-support optional-rust-support
|
||||
.PHONY: dist lint prereqs node_modules bower_modules travis-dist
|
||||
prereqs: optional-haskell-support optional-d-support optional-rust-support node_modules c-preload bower_modules
|
||||
|
||||
.PHONY: dist lint prereqs node_modules travis-dist
|
||||
prereqs: optional-haskell-support optional-d-support optional-rust-support node_modules webpack c-preload
|
||||
GDC?=gdc
|
||||
DMD?=dmd
|
||||
LDC?=ldc2
|
||||
@@ -56,24 +57,18 @@ endif
|
||||
|
||||
NODE_MODULES=.npm-updated
|
||||
$(NODE_MODULES): package.json
|
||||
$(NPM) install
|
||||
$(YARN) install
|
||||
@touch $@
|
||||
|
||||
BOWER_MODULES=.bower-updated
|
||||
$(BOWER_MODULES): bower.json $(NODE_MODULES)
|
||||
if ! test -f "${BOWER_MODULES}"; then rm -rf static/ext; fi
|
||||
$(NODE) ./node_modules/bower/bin/bower install
|
||||
@touch $@
|
||||
# Workaround for lack of versioned monaco-editor in bower
|
||||
rm -rf static/ext/monaco-editor
|
||||
cp -r node_modules/monaco-editor static/ext/
|
||||
webpack:
|
||||
$(NODE) node_modules/webpack/bin/webpack.js ${WEBPACK_ARGS}
|
||||
|
||||
lint: $(NODE_MODULES)
|
||||
$(NODE) ./node_modules/.bin/jshint --config etc/jshintrc.server app.js $(shell find lib test -name '*.js')
|
||||
$(NODE) ./node_modules/.bin/jshint --config etc/jshintrc.client $(shell find static -name '*.js' -not -path 'static/ext/*' -not -path static/analytics.js)
|
||||
$(NODE) ./node_modules/.bin/jshint --config etc/jshintrc.server app.js $(shell find lib -name '*.js')
|
||||
$(NODE) ./node_modules/.bin/jshint --config etc/jshintrc.client $(shell find static -name '*.js' -not -path 'static/dist/*' -not -path static/analytics.js -not -path 'static/vs/*' -not -path 'static/ext/*')
|
||||
|
||||
node_modules: $(NODE_MODULES)
|
||||
bower_modules: $(BOWER_MODULES)
|
||||
webpack: $(WEBPACK)
|
||||
|
||||
test: $(NODE_MODULES) lint
|
||||
$(MAKE) -C c-preload test
|
||||
@@ -83,37 +78,31 @@ check: $(NODE_MODULES) lint
|
||||
$(NODE) ./node_modules/.bin/mocha --recursive
|
||||
|
||||
clean:
|
||||
rm -rf bower_modules node_modules .npm-updated .bower-updated out static/ext
|
||||
rm -rf node_modules .npm-updated out static/dist static/vs
|
||||
$(MAKE) -C d clean
|
||||
$(MAKE) -C c-preload clean
|
||||
|
||||
run: export NODE_ENV=LOCAL WEBPACK_ARGS="-p"
|
||||
run: prereqs
|
||||
$(NODE) ./node_modules/.bin/supervisor -w app.js,lib,etc/config -e 'js|node|properties' --exec $(NODE) $(NODE_ARGS) -- ./app.js $(EXTRA_ARGS)
|
||||
|
||||
dev: export NODE_ENV=DEV
|
||||
dev: prereqs
|
||||
$(NODE) ./node_modules/.bin/supervisor -w app.js,lib,etc/config -e 'js|node|properties' --exec $(NODE) $(NODE_ARGS) -- ./app.js $(EXTRA_ARGS)
|
||||
|
||||
|
||||
|
||||
HASH := $(shell git rev-parse HEAD)
|
||||
dist: export WEBPACK_ARGS=-p
|
||||
dist: prereqs
|
||||
rm -rf out/dist
|
||||
$(NODE) ./node_modules/requirejs/bin/r.js -o app.build.js
|
||||
# Move all assets to a versioned directory
|
||||
echo $(HASH) > out/dist/git_hash
|
||||
mkdir -p out/dist/v/$(HASH)
|
||||
mv out/dist/main.js* out/dist/v/$(HASH)/
|
||||
mv out/dist/explorer.css out/dist/v/$(HASH)/
|
||||
mv out/dist/assets/ out/dist/v/$(HASH)/
|
||||
mv out/dist/themes/ out/dist/v/$(HASH)/
|
||||
# copy any external references into the directory too
|
||||
cp -r $(shell pwd)/out/dist/ext out/dist/v/$(HASH)/ext
|
||||
# uglify requirejs itself
|
||||
$(NODE) ./node_modules/.bin/uglifyjs out/dist/v/$(HASH)/ext/requirejs/require.js \
|
||||
-c \
|
||||
--output out/dist/v/$(HASH)/ext/requirejs/require.js \
|
||||
--source-map out/dist/v/$(HASH)/ext/requirejs/require.js.map \
|
||||
--source-map-url require.js.map \
|
||||
--source-map-root //v/$(HASH)/ext/requirejs \
|
||||
--prefix 6
|
||||
rm -rf out/dist/
|
||||
mkdir -p out/dist
|
||||
mkdir -p out/dist/vs
|
||||
cp -r static/dist/ out/dist/
|
||||
cp -r static/vs/ out/dist/
|
||||
|
||||
travis-dist: dist
|
||||
tar --exclude './.travis-compilers' --exclude './.git' --exclude './static' --exclude './out/dist/ext' -Jcf /tmp/ce-build.tar.xz .
|
||||
tar --exclude './.travis-compilers' --exclude './.git' --exclude './static' -Jcf /tmp/ce-build.tar.xz .
|
||||
rm -rf out/dist-bin
|
||||
mkdir -p out/dist-bin
|
||||
mv /tmp/ce-build.tar.xz out/dist-bin/${TRAVIS_BUILD_NUMBER}.tar.xz
|
||||
|
||||
@@ -26,10 +26,10 @@ Compiler Explorer is written in node.js.
|
||||
Assuming you have a compatible version of `node` installed, simply running `make` ought to get you up and running with an Explorer
|
||||
running on port 10240 on your local machine: http://localhost:10240/. Currently Compiler Explorer requires `node` v8 installed, either on the path or at `NODE_PATH` (an environment variable or `make` parameter).
|
||||
|
||||
Running with `make EXTRA_ARGS='--language LANG'` will allow you to load `LANG` exclusively, where `LANG` is one for the language ids/aliases defined in `lib/languages.js`
|
||||
|
||||
The `Makefile` will automatically install all the third party libraries needed to run; using `npm` to install server-side
|
||||
components and `bower` to install all the client-facing libraries.
|
||||
Running with `make EXTRA_ARGS='--language LANG'` will allow you to load `LANG` exclusively, where `LANG` is one for the language ids/aliases defined in `lib/languages.js`
|
||||
The `Makefile` will automatically install all the third party libraries needed to run; using `yarn` to install server-side and client side components
|
||||
|
||||
|
||||
If you want to point it at your own GCC or similar binaries, either edit the `etc/config/compiler-explorer.defaults.properties` or else make a new one with the name
|
||||
`compiler-explorer.local.properties`. `*.local.properties` files have the highest priority when loading properties.
|
||||
|
||||
@@ -36,8 +36,10 @@ const nopt = require('nopt'),
|
||||
url = require('url'),
|
||||
_ = require('underscore-node'),
|
||||
express = require('express'),
|
||||
Raven = require('raven'),
|
||||
logger = require('./lib/logger').logger,
|
||||
Raven = require('raven');
|
||||
webpackDevMiddleware = require("webpack-dev-middleware");
|
||||
|
||||
|
||||
// Parse arguments from command line 'node ./app.js args...'
|
||||
const opts = nopt({
|
||||
@@ -86,19 +88,30 @@ const port = opts.port || 10240;
|
||||
const staticDir = opts.static || 'static';
|
||||
const archivedVersions = opts.archivedVersions;
|
||||
let gitReleaseName = "";
|
||||
let versionedRootPrefix = "";
|
||||
const wantedLanguage = opts.language || null;
|
||||
|
||||
|
||||
|
||||
const webpackConfig = require('./webpack.config.js')[1],
|
||||
webpackCompiler = require('webpack')(webpackConfig),
|
||||
manifestName = 'manifest.json',
|
||||
staticManifestPath = path.join(__dirname, staticDir, webpackConfig.output.publicPath),
|
||||
assetManifestPath = path.join(staticManifestPath, 'assets'),
|
||||
staticManifest = require(path.join(staticManifestPath, manifestName)),
|
||||
assetManifest = require(path.join(assetManifestPath, manifestName));
|
||||
|
||||
// Use the canned git_hash if provided
|
||||
if (opts.static && fs.existsSync(opts.static + "/git_hash")) {
|
||||
gitReleaseName = fs.readFileSync(opts.static + "/git_hash").toString().trim();
|
||||
} else if (fs.existsSync('.git/')) { // Just if we have been cloned and not downloaded (Thanks David!)
|
||||
gitReleaseName = child_process.execSync('git rev-parse HEAD').toString().trim();
|
||||
}
|
||||
if (opts.static && fs.existsSync(opts.static + '/v/' + gitReleaseName))
|
||||
versionedRootPrefix = "v/" + gitReleaseName + "/";
|
||||
|
||||
// Don't treat @ in paths as remote adresses
|
||||
const fetchCompilersFromRemote = !opts.noRemoteFetch;
|
||||
|
||||
const isDevMode = () => process.env.NODE_ENV === "DEV";
|
||||
|
||||
const propHierarchy = _.flatten([
|
||||
'defaults',
|
||||
env,
|
||||
@@ -559,14 +572,25 @@ Promise.all([findCompilers(), aws.initConfig(awsProps)])
|
||||
|
||||
logger.info("=======================================");
|
||||
logger.info(`Listening on http://${hostname || 'localhost'}:${port}/`);
|
||||
logger.info(` serving static files from '${staticDir}'`);
|
||||
if (gitReleaseName) logger.info(` git release ${gitReleaseName}`);
|
||||
|
||||
function renderConfig(extra) {
|
||||
const options = _.extend(extra, clientOptionsHandler.get());
|
||||
options.compilerExplorerOptions = JSON.stringify(options);
|
||||
options.root = versionedRootPrefix;
|
||||
options.extraBodyClass = extraBodyClass;
|
||||
options.require = function (path) {
|
||||
if (isDevMode()) {
|
||||
//this will break assets in dev mode for now
|
||||
return '/dist/' + path;
|
||||
}
|
||||
if(staticManifest.hasOwnProperty(path)) {
|
||||
return "dist/" + staticManifest[path];
|
||||
}
|
||||
if(assetManifest.hasOwnProperty(path)) {
|
||||
return "dist/assets/" + assetManifest[path];
|
||||
}
|
||||
logger.warn("Requested an asset I don't know about");
|
||||
};
|
||||
return options;
|
||||
}
|
||||
|
||||
@@ -575,8 +599,26 @@ Promise.all([findCompilers(), aws.initConfig(awsProps)])
|
||||
contentPolicyHeader(res);
|
||||
res.render('embed', renderConfig({embedded: true}));
|
||||
};
|
||||
const router = express.Router();
|
||||
router
|
||||
const healthCheck = require('./lib/handlers/health-check');
|
||||
|
||||
if (isDevMode()) {
|
||||
webServer.use(webpackDevMiddleware(webpackCompiler, {
|
||||
publicPath: webpackConfig.output.publicPath
|
||||
}));
|
||||
webServer.use(express.static(staticDir));
|
||||
} else {
|
||||
//assume that anything not dev is just production this gives sane defaults for anyone who isn't messing with this
|
||||
logger.info(" serving static files from '" + staticDir + "'");
|
||||
webServer.use(express.static(staticDir, {maxAge: staticMaxAgeSecs * 1000}));
|
||||
}
|
||||
|
||||
webServer
|
||||
.use(Raven.requestHandler())
|
||||
.set('trust proxy', true)
|
||||
.set('view engine', 'pug')
|
||||
.use('/healthcheck', new healthCheck.HealthCheckHandler().handle) // before morgan so healthchecks aren't logged
|
||||
.use(morgan('combined', {stream: logger.stream}))
|
||||
.use(compression())
|
||||
.get('/', (req, res) => {
|
||||
staticHeaders(res);
|
||||
contentPolicyHeader(res);
|
||||
@@ -598,39 +640,18 @@ Promise.all([findCompilers(), aws.initConfig(awsProps)])
|
||||
res.set('Content-Type', 'application/xml');
|
||||
res.render('sitemap');
|
||||
})
|
||||
.use(sFavicon(`${staticDir}/favicon.ico`))
|
||||
.use('/v', express.static(`${staticDir}/v`, {maxAge: Infinity, index: false}))
|
||||
.use(express.static(staticDir, {maxAge: staticMaxAgeSecs * 1000}));
|
||||
if (archivedVersions) {
|
||||
// The archived versions directory is used to serve "old" versioned data during updates. It's expected
|
||||
// to contain all the SHA-hashed directories from previous versions of Compiler Explorer.
|
||||
logger.info(" serving archived versions from", archivedVersions);
|
||||
router.use('/v', express.static(archivedVersions, {maxAge: Infinity, index: false}));
|
||||
}
|
||||
router
|
||||
.use(sFavicon(path.join(staticDir, webpackConfig.output.publicPath, 'favicon.ico')));
|
||||
|
||||
webServer
|
||||
.use(bodyParser.json({limit: ceProps('bodyParserLimit', maxUploadSize)}))
|
||||
.use(bodyParser.text({limit: ceProps('bodyParserLimit', maxUploadSize), type: () => true}))
|
||||
.use(restreamer())
|
||||
.use('/source', sourceHandler.handle.bind(sourceHandler))
|
||||
.use('/api', apiHandler.handle)
|
||||
.use('/g', shortUrlHandler);
|
||||
|
||||
const healthCheck = require('./lib/handlers/health-check');
|
||||
webServer
|
||||
.use(Raven.requestHandler())
|
||||
.set('trust proxy', true)
|
||||
.set('view engine', 'pug')
|
||||
.use('/healthcheck', new healthCheck.HealthCheckHandler().handle) // before morgan so healthchecks aren't logged
|
||||
.use(morgan('combined', {stream: logger.stream}))
|
||||
.use(compression())
|
||||
.use(router)
|
||||
.use(Raven.errorHandler())
|
||||
.on('error', err => logger.error('Caught error:', err, "(in web error handler; continuing)"));
|
||||
|
||||
const webAlias = ceProps("web-alias", "");
|
||||
if (webAlias) webServer.use(webAlias, router);
|
||||
_.each(env, e => webServer.use(`/${e}`, router));
|
||||
logger.info("=======================================");
|
||||
webServer.use(Raven.errorHandler());
|
||||
webServer.on('error', err => logger.error('Caught error:', err, "(in web error handler; continuing)"));
|
||||
webServer.listen(port, hostname);
|
||||
})
|
||||
.catch(err => {
|
||||
|
||||
-36
@@ -1,36 +0,0 @@
|
||||
{
|
||||
"name": "compiler-explorer",
|
||||
"description": "Interactively investigate compiler output",
|
||||
"main": "./app.js",
|
||||
"authors": [
|
||||
"Matt Godbolt"
|
||||
],
|
||||
"license": "BSD-2-Clause",
|
||||
"homepage": "https://github.com/mattgodbolt/compiler-explorer",
|
||||
"private": true,
|
||||
"ignore": [
|
||||
"**/.*",
|
||||
"node_modules",
|
||||
"bower_components",
|
||||
"test",
|
||||
"tests"
|
||||
],
|
||||
"dependencies": {
|
||||
"requirejs": "^2.3.2",
|
||||
"underscore": "^1.8.3",
|
||||
"golden-layout": "^1.5.9",
|
||||
"jquery": "^3.1.1",
|
||||
"bootstrap": "^3.3.7",
|
||||
"selectize": "RabsRincon/selectize.js#master",
|
||||
"eventEmitter": "^5.1.0",
|
||||
"lz-string": "^1.4.4",
|
||||
"clipboard": "^1.5.12",
|
||||
"raven-js": "^3.10.0",
|
||||
"es6-promise": "^4.0.5",
|
||||
"lru-cache": "2.7.3",
|
||||
"seiyria-bootstrap-slider": "9.7.x",
|
||||
"big-integer": "https://github.com/peterolson/BigInteger.js.git#^1.6.22",
|
||||
"file-saver": "filesaver#^1.3.3",
|
||||
"vis": "4.20.1"
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -2,6 +2,7 @@
|
||||
"strict": true,
|
||||
"undef": true,
|
||||
"browser": true,
|
||||
"globals": {"define": false},
|
||||
"node": true,
|
||||
"globals": {"define": false, "monaco": true, "__webpack_public_path__": true},
|
||||
"esversion": 5
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/bin/bash
|
||||
FORBIDDEN='console.log'
|
||||
FORBIDDEN='console.(log|warn)'
|
||||
FILES_PATTERN='\.(js)(\..+)?$'
|
||||
|
||||
printf "\033[0;32mRunning tests...\033[0m\n"
|
||||
|
||||
@@ -101,9 +101,9 @@ CompilationEnvironment.prototype.enqueue = function (job) {
|
||||
try {
|
||||
return job();
|
||||
} catch (e) {
|
||||
Raven.captureException(e);
|
||||
logger.error("Caught promise exception " + e);
|
||||
if (e.stack) logger.info(e.stack);
|
||||
logger.error("Caught promise exception " + e);
|
||||
Raven.captureException(e);
|
||||
return Promise.resolve(null);
|
||||
}
|
||||
};
|
||||
|
||||
+28
-3
@@ -17,41 +17,66 @@
|
||||
"main": "./app.js",
|
||||
"dependencies": {
|
||||
"aws-sdk": "^2.177.0",
|
||||
"big-integer": "^1.6.25",
|
||||
"body-parser": "^1.18.2",
|
||||
"bootstrap": "^3.3.7",
|
||||
"bootstrap-slider": "^9.9.0",
|
||||
"clipboard": "^1.7.1",
|
||||
"compiler-opt-info": "0.0.4",
|
||||
"compression": "^1.7.1",
|
||||
"denodeify": "^1.2.1",
|
||||
"es6-promise": "^4.1.1",
|
||||
"express": "4.16.x",
|
||||
"file-saver": "^1.3.3",
|
||||
"fs-extra": "0.26.x",
|
||||
"golden-layout": "^1.5.9",
|
||||
"html-loader": "^0.5.5",
|
||||
"http-proxy": "^1.16.2",
|
||||
"jquery": "^3.2.1",
|
||||
"lru-cache": "4.1.1",
|
||||
"lz-string": "^1.4.4",
|
||||
"monaco-editor": "0.10.1",
|
||||
"morgan": "^1.9.0",
|
||||
"nopt": "3.0.x",
|
||||
"promise-queue": "2.2.3",
|
||||
"pug": "^2.0.0-beta11",
|
||||
"raven": "^2.2.1",
|
||||
"raven-js": "^3.19.1",
|
||||
"selectize": "^0.12.4",
|
||||
"serve-favicon": "^2.4.5",
|
||||
"shell-quote": "1.6.x",
|
||||
"temp": "0.8.x",
|
||||
"tree-kill": "^1.2.0",
|
||||
"uglifyjs-webpack-plugin": "^1.1.8",
|
||||
"underscore": "^1.8.3",
|
||||
"underscore-node": "*",
|
||||
"winston": "^2.4.0"
|
||||
"vis": "4.20.1",
|
||||
"winston": "^2.4.0",
|
||||
"wolfy87-eventemitter": "^5.2.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"aws-sdk-mock": "^1.7.0",
|
||||
"bower": "*",
|
||||
"chai": "3.5.x",
|
||||
"chai-as-promised": "^7.1.1",
|
||||
"chai-http": "^3.0.0",
|
||||
"codecov": "^3.0.0",
|
||||
"copy-webpack-plugin": "^4.1.1",
|
||||
"css-loader": "^0.28.7",
|
||||
"extract-text-webpack-plugin": "^3.0.1",
|
||||
"file-loader": "^1.1.5",
|
||||
"istanbul": "^0.4.5",
|
||||
"jshint": "^2.9.5",
|
||||
"mocha": "^3.3.0",
|
||||
"nock": "^9.1.4",
|
||||
"requirejs": "*",
|
||||
"style-loader": "^0.19.0",
|
||||
"supervisor": "*",
|
||||
"uglify-js": "*"
|
||||
"uglify-js": "*",
|
||||
"url-loader": "^0.6.2",
|
||||
"webpack": "^3.6.0",
|
||||
"webpack-dev-middleware": "^1.12.0",
|
||||
"webpack-dev-server": "^2.9.4",
|
||||
"webpack-manifest-plugin": "^1.3.2"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha --recursive && make test",
|
||||
|
||||
+68
-70
@@ -22,79 +22,77 @@
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
"use strict";
|
||||
|
||||
define(function (require) {
|
||||
"use strict";
|
||||
var _ = require('underscore');
|
||||
var $ = require('jquery');
|
||||
var _ = require('underscore');
|
||||
var $ = require('jquery');
|
||||
|
||||
function Alert() {
|
||||
this.yesHandler = null;
|
||||
this.noHandler = null;
|
||||
var yesNo = $('#yes-no');
|
||||
yesNo.find('button.yes').click(_.bind(function () {
|
||||
if (this.yesHandler) this.yesHandler();
|
||||
}, this));
|
||||
yesNo.find('button.no').click(_.bind(function () {
|
||||
if (this.noHandler) this.noHandler();
|
||||
}, this));
|
||||
function Alert() {
|
||||
this.yesHandler = null;
|
||||
this.noHandler = null;
|
||||
var yesNo = $('#yes-no');
|
||||
yesNo.find('button.yes').click(_.bind(function () {
|
||||
if (this.yesHandler) this.yesHandler();
|
||||
}, this));
|
||||
yesNo.find('button.no').click(_.bind(function () {
|
||||
if (this.noHandler) this.noHandler();
|
||||
}, this));
|
||||
}
|
||||
|
||||
Alert.prototype.alert = function (title, body, onClose) {
|
||||
var modal = $('#alert');
|
||||
modal.find('.modal-title').html(title);
|
||||
modal.find('.modal-body').html(body);
|
||||
modal.modal();
|
||||
if (onClose) {
|
||||
modal.off('hidden.bs.modal');
|
||||
modal.on('hidden.bs.modal', onClose);
|
||||
}
|
||||
};
|
||||
|
||||
Alert.prototype.alert = function (title, body, onClose) {
|
||||
var modal = $('#alert');
|
||||
modal.find('.modal-title').html(title);
|
||||
modal.find('.modal-body').html(body);
|
||||
modal.modal();
|
||||
if (onClose) {
|
||||
modal.off('hidden.bs.modal');
|
||||
modal.on('hidden.bs.modal', onClose);
|
||||
}
|
||||
};
|
||||
Alert.prototype.ask = function (title, question, handlers) {
|
||||
var modal = $('#yes-no');
|
||||
this.yesHandler = handlers.yes;
|
||||
this.noHandler = handlers.no;
|
||||
modal.find('.modal-title').html(title);
|
||||
modal.find('.modal-body').html(question);
|
||||
modal.modal();
|
||||
};
|
||||
|
||||
Alert.prototype.ask = function (title, question, handlers) {
|
||||
var modal = $('#yes-no');
|
||||
this.yesHandler = handlers.yes;
|
||||
this.noHandler = handlers.no;
|
||||
modal.find('.modal-title').html(title);
|
||||
modal.find('.modal-body').html(question);
|
||||
modal.modal();
|
||||
};
|
||||
/* Options parameter:
|
||||
* group: What group this notification is from. Sets data-group's value. Default: none
|
||||
* collapseSimilar: If set to true, other notifications with the same group will be removed before sending this. (Note that this only has any effect if group is set). Default: true
|
||||
* alertClass: Space separated classes to give to the notification div element. Default: none
|
||||
* autoDismiss: If set to true, the notification will fade out and be removed automatically. Default: true
|
||||
* dismissTime: If allowed by autoDismiss, controls how long the notification will be visible before being automatically removed. Default: 5000ms. Min: 1000ms
|
||||
*/
|
||||
Alert.prototype.notify = function (body, options) {
|
||||
var container = $('#notifications');
|
||||
if (!container) return;
|
||||
var newElement = $('<div class="alert notification" tabindex="-1" role="dialog"><button type="button" class="close" style="float:left;margin-right: 5px;" data-dismiss="alert">×</button><span id="msg">' + body + '</span></div>');
|
||||
if (!options) options = {};
|
||||
// Set defaults
|
||||
options.collapseSimilar = ("collapseSimilar" in options) ? options.collapseSimilar : true; // Collapse similars by default
|
||||
options.autoDismiss = ("autoDismiss" in options) ? options.autoDismiss : true; // autoDismiss by default
|
||||
options.dismissTime = options.dismissTime ? Math.max(1000, options.dismissTime) : 5000; // Dismiss this after 5000ms by default
|
||||
if (options.group) {
|
||||
if (options.collapseSimilar) {
|
||||
// Only collapsing if a group has been specified
|
||||
container.find('[data-group="' + options.group + '"]').remove();
|
||||
}
|
||||
newElement.attr('data-group', options.group); // Add the group to the data-group
|
||||
}
|
||||
if (options.alertClass) { // If we want a custom class, apply it
|
||||
newElement.addClass(options.alertClass);
|
||||
}
|
||||
if (options.autoDismiss) { // Dismiss this after dismissTime
|
||||
setTimeout(function () {
|
||||
newElement.fadeOut('slow', function () {
|
||||
newElement.remove();
|
||||
});
|
||||
}, options.dismissTime);
|
||||
}
|
||||
container.append(newElement); // Add the new notification to the container
|
||||
};
|
||||
|
||||
/* Options parameter:
|
||||
* group: What group this notification is from. Sets data-group's value. Default: none
|
||||
* collapseSimilar: If set to true, other notifications with the same group will be removed before sending this. (Note that this only has any effect if group is set). Default: true
|
||||
* alertClass: Space separated classes to give to the notification div element. Default: none
|
||||
* autoDismiss: If set to true, the notification will fade out and be removed automatically. Default: true
|
||||
* dismissTime: If allowed by autoDismiss, controls how long the notification will be visible before being automatically removed. Default: 5000ms. Min: 1000ms
|
||||
*/
|
||||
Alert.prototype.notify = function (body, options) {
|
||||
var container = $('#notifications');
|
||||
if (!container) return;
|
||||
var newElement = $('<div class="alert notification" tabindex="-1" role="dialog"><button type="button" class="close" style="float:left;margin-right: 5px;" data-dismiss="alert">×</button><span id="msg">' + body + '</span></div>');
|
||||
if (!options) options = {};
|
||||
// Set defaults
|
||||
options.collapseSimilar = ("collapseSimilar" in options) ? options.collapseSimilar : true; // Collapse similars by default
|
||||
options.autoDismiss = ("autoDismiss" in options) ? options.autoDismiss : true; // autoDismiss by default
|
||||
options.dismissTime = options.dismissTime ? Math.max(1000, options.dismissTime) : 5000; // Dismiss this after 5000ms by default
|
||||
if (options.group) {
|
||||
if (options.collapseSimilar) {
|
||||
// Only collapsing if a group has been specified
|
||||
container.find('[data-group="' + options.group + '"]').remove();
|
||||
}
|
||||
newElement.attr('data-group', options.group); // Add the group to the data-group
|
||||
}
|
||||
if (options.alertClass) { // If we want a custom class, apply it
|
||||
newElement.addClass(options.alertClass);
|
||||
}
|
||||
if (options.autoDismiss) { // Dismiss this after dismissTime
|
||||
setTimeout(function () {
|
||||
newElement.fadeOut('slow', function () {
|
||||
newElement.remove();
|
||||
});
|
||||
}, options.dismissTime);
|
||||
}
|
||||
container.append(newElement); // Add the new notification to the container
|
||||
};
|
||||
|
||||
return Alert;
|
||||
});
|
||||
module.exports = Alert;
|
||||
|
||||
+100
-102
@@ -23,109 +23,107 @@
|
||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
define(function (require) {
|
||||
"use strict";
|
||||
var options = require('options');
|
||||
var Raven = require('raven-js');
|
||||
var $ = require('jquery');
|
||||
"use strict";
|
||||
var options = require('options');
|
||||
var Raven = require('raven-js');
|
||||
var $ = require('jquery');
|
||||
|
||||
if (options.raven) {
|
||||
Raven.config(options.raven, {
|
||||
release: options.release,
|
||||
environment: options.environment.join("/")
|
||||
}).install();
|
||||
}
|
||||
if (options.raven) {
|
||||
Raven.config(options.raven, {
|
||||
release: options.release,
|
||||
environment: options.environment.join("/")
|
||||
}).install();
|
||||
}
|
||||
|
||||
var gaProxy;
|
||||
if (options.googleAnalyticsEnabled) {
|
||||
(function (i, s, o, g, r, a, m) {
|
||||
i.GoogleAnalyticsObject = r;
|
||||
i[r] = i[r] || function () {
|
||||
(i[r].q = i[r].q || []).push(arguments);
|
||||
};
|
||||
i[r].l = 1 * new Date();
|
||||
a = s.createElement(o);
|
||||
m = s.getElementsByTagName(o)[0];
|
||||
a.async = 1;
|
||||
a.src = g;
|
||||
m.parentNode.insertBefore(a, m);
|
||||
})(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');
|
||||
ga('create', options.googleAnalyticsAccount, 'auto');
|
||||
ga('send', 'pageview');
|
||||
gaProxy = function () {
|
||||
window.ga.apply(window.ga, arguments);
|
||||
var gaProxy;
|
||||
if (options.googleAnalyticsEnabled) {
|
||||
(function (i, s, o, g, r, a, m) {
|
||||
i.GoogleAnalyticsObject = r;
|
||||
i[r] = i[r] || function () {
|
||||
(i[r].q = i[r].q || []).push(arguments);
|
||||
};
|
||||
// fullstory stuff:
|
||||
window['_fs_debug'] = false;
|
||||
window['_fs_host'] = 'www.fullstory.com';
|
||||
window['_fs_org'] = '2F4NV';
|
||||
window['_fs_namespace'] = 'FS';
|
||||
(function (m, n, e, t, l, o, g, y) {
|
||||
if (e in m && m.console && m.console.log) {
|
||||
m.console.log('FullStory namespace conflict. Please set window["_fs_namespace"].');
|
||||
return;
|
||||
}
|
||||
g = m[e] = function (a, b) {
|
||||
g.q ? g.q.push([a, b]) : g._api(a, b);
|
||||
};
|
||||
g.q = [];
|
||||
o = n.createElement(t);
|
||||
o.async = 1;
|
||||
o.src = 'https://' + _fs_host + '/s/fs.js';
|
||||
y = n.getElementsByTagName(t)[0];
|
||||
y.parentNode.insertBefore(o, y);
|
||||
g.identify = function (i, v) {
|
||||
g(l, {uid: i});
|
||||
if (v) g(l, v)
|
||||
};
|
||||
g.setUserVars = function (v) {
|
||||
g(l, v)
|
||||
};
|
||||
g.identifyAccount = function (i, v) {
|
||||
o = 'account';
|
||||
v = v || {};
|
||||
v.acctId = i;
|
||||
g(o, v)
|
||||
};
|
||||
g.clearUserCookie = function (c, d, i) {
|
||||
if (!c || document.cookie.match('fs_uid=[`;`]*`[`;`]*`[`;`]*`')) {
|
||||
d = n.domain;
|
||||
while (1) {
|
||||
n.cookie = 'fs_uid=;domain=' + d +
|
||||
';path=/;expires=' + new Date(0).toUTCString();
|
||||
i = d.indexOf('.');
|
||||
if (i < 0) break;
|
||||
d = d.slice(i + 1)
|
||||
}
|
||||
}
|
||||
};
|
||||
})(window, document, window['_fs_namespace'], 'script', 'user');
|
||||
} else {
|
||||
gaProxy = function () {
|
||||
};
|
||||
}
|
||||
|
||||
function initialise() {
|
||||
if (options.embedded) return;
|
||||
$(function () {
|
||||
function create_script_element(id, url) {
|
||||
var el = document.createElement('script');
|
||||
el.type = 'text/javascript';
|
||||
el.async = true;
|
||||
el.id = id;
|
||||
el.src = url;
|
||||
var s = document.getElementsByTagName('script')[0];
|
||||
s.parentNode.insertBefore(el, s);
|
||||
}
|
||||
|
||||
if (options.sharingEnabled) {
|
||||
create_script_element('twitter-wjs', 'https://platform.twitter.com/widgets.js');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
ga: gaProxy,
|
||||
initialise: initialise
|
||||
i[r].l = 1 * new Date();
|
||||
a = s.createElement(o);
|
||||
m = s.getElementsByTagName(o)[0];
|
||||
a.async = 1;
|
||||
a.src = g;
|
||||
m.parentNode.insertBefore(a, m);
|
||||
})(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');
|
||||
ga('create', options.googleAnalyticsAccount, 'auto');
|
||||
ga('send', 'pageview');
|
||||
gaProxy = function () {
|
||||
window.ga.apply(window.ga, arguments);
|
||||
};
|
||||
});
|
||||
// fullstory stuff:
|
||||
window['_fs_debug'] = false;
|
||||
window['_fs_host'] = 'www.fullstory.com';
|
||||
window['_fs_org'] = '2F4NV';
|
||||
window['_fs_namespace'] = 'FS';
|
||||
(function (m, n, e, t, l, o, g, y) {
|
||||
if (e in m && m.console && m.console.log) {
|
||||
m.console.log('FullStory namespace conflict. Please set window["_fs_namespace"].');
|
||||
return;
|
||||
}
|
||||
g = m[e] = function (a, b) {
|
||||
g.q ? g.q.push([a, b]) : g._api(a, b);
|
||||
};
|
||||
g.q = [];
|
||||
o = n.createElement(t);
|
||||
o.async = 1;
|
||||
o.src = 'https://' + _fs_host + '/s/fs.js';
|
||||
y = n.getElementsByTagName(t)[0];
|
||||
y.parentNode.insertBefore(o, y);
|
||||
g.identify = function (i, v) {
|
||||
g(l, {uid: i});
|
||||
if (v) g(l, v)
|
||||
};
|
||||
g.setUserVars = function (v) {
|
||||
g(l, v)
|
||||
};
|
||||
g.identifyAccount = function (i, v) {
|
||||
o = 'account';
|
||||
v = v || {};
|
||||
v.acctId = i;
|
||||
g(o, v)
|
||||
};
|
||||
g.clearUserCookie = function (c, d, i) {
|
||||
if (!c || document.cookie.match('fs_uid=[`;`]*`[`;`]*`[`;`]*`')) {
|
||||
d = n.domain;
|
||||
while (1) {
|
||||
n.cookie = 'fs_uid=;domain=' + d +
|
||||
';path=/;expires=' + new Date(0).toUTCString();
|
||||
i = d.indexOf('.');
|
||||
if (i < 0) break;
|
||||
d = d.slice(i + 1)
|
||||
}
|
||||
}
|
||||
};
|
||||
})(window, document, window['_fs_namespace'], 'script', 'user');
|
||||
} else {
|
||||
gaProxy = function () {
|
||||
};
|
||||
}
|
||||
|
||||
function initialise() {
|
||||
if (options.embedded) return;
|
||||
$(function () {
|
||||
function create_script_element(id, url) {
|
||||
var el = document.createElement('script');
|
||||
el.type = 'text/javascript';
|
||||
el.async = true;
|
||||
el.id = id;
|
||||
el.src = url;
|
||||
var s = document.getElementsByTagName('script')[0];
|
||||
s.parentNode.insertBefore(el, s);
|
||||
}
|
||||
|
||||
if (options.sharingEnabled) {
|
||||
create_script_element('twitter-wjs', 'https://platform.twitter.com/widgets.js');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
ga: gaProxy,
|
||||
initialise: initialise
|
||||
};
|
||||
|
||||
+78
-81
@@ -22,103 +22,100 @@
|
||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
define(function (require) {
|
||||
"use strict";
|
||||
var monaco = require('monaco');
|
||||
"use strict";
|
||||
|
||||
function definition() {
|
||||
return {
|
||||
// Set defaultToken to invalid to see what you do not tokenize yet
|
||||
defaultToken: 'invalid',
|
||||
function definition() {
|
||||
return {
|
||||
// Set defaultToken to invalid to see what you do not tokenize yet
|
||||
defaultToken: 'invalid',
|
||||
|
||||
// C# style strings
|
||||
escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,
|
||||
// C# style strings
|
||||
escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,
|
||||
|
||||
registers: /%?\b(r[0-9]+[dbw]?|([er]?([abcd][xhl]|cs|fs|ds|ss|sp|bp|ip|sil?|dil?))|[xyz]mm[0-9]+|sp|fp|lr)\b/,
|
||||
registers: /%?\b(r[0-9]+[dbw]?|([er]?([abcd][xhl]|cs|fs|ds|ss|sp|bp|ip|sil?|dil?))|[xyz]mm[0-9]+|sp|fp|lr)\b/,
|
||||
|
||||
intelOperators: /PTR|(D|Q|[XYZ]MM)?WORD/,
|
||||
intelOperators: /PTR|(D|Q|[XYZ]MM)?WORD/,
|
||||
|
||||
tokenizer: {
|
||||
root: [
|
||||
// Error document
|
||||
[/^<.*>$/, {token: 'annotation'}],
|
||||
// Label definition
|
||||
[/^[.a-zA-Z0-9_$?@].*:/, {token: 'type.identifier', next: '@rest'}],
|
||||
// Label definition (ARM style)
|
||||
[/^\s*[|][^|]*[|]/, {token: 'type.identifier', next: '@rest'}],
|
||||
// Label definition (CL style)
|
||||
[/^\s*[.a-zA-Z0-9_$|]*\s*(PROC|ENDP|DB|DD)/, {token: 'type.identifier', next: '@rest'}],
|
||||
// Constant definition
|
||||
[/^[.a-zA-Z0-9_$?@][^=]*=/, {token: 'type.identifier', next: '@rest'}],
|
||||
// opcode
|
||||
[/[.a-zA-Z_][.a-zA-Z_0-9]*/, {token: 'keyword', next: '@rest'}],
|
||||
tokenizer: {
|
||||
root: [
|
||||
// Error document
|
||||
[/^<.*>$/, {token: 'annotation'}],
|
||||
// Label definition
|
||||
[/^[.a-zA-Z0-9_$?@].*:/, {token: 'type.identifier', next: '@rest'}],
|
||||
// Label definition (ARM style)
|
||||
[/^\s*[|][^|]*[|]/, {token: 'type.identifier', next: '@rest'}],
|
||||
// Label definition (CL style)
|
||||
[/^\s*[.a-zA-Z0-9_$|]*\s*(PROC|ENDP|DB|DD)/, {token: 'type.identifier', next: '@rest'}],
|
||||
// Constant definition
|
||||
[/^[.a-zA-Z0-9_$?@][^=]*=/, {token: 'type.identifier', next: '@rest'}],
|
||||
// opcode
|
||||
[/[.a-zA-Z_][.a-zA-Z_0-9]*/, {token: 'keyword', next: '@rest'}],
|
||||
|
||||
// whitespace
|
||||
{include: '@whitespace'}
|
||||
],
|
||||
// whitespace
|
||||
{include: '@whitespace'}
|
||||
],
|
||||
|
||||
rest: [
|
||||
// pop at the beginning of the next line and rematch
|
||||
[/^.*$/, {token: '@rematch', next: '@pop'}],
|
||||
rest: [
|
||||
// pop at the beginning of the next line and rematch
|
||||
[/^.*$/, {token: '@rematch', next: '@pop'}],
|
||||
|
||||
[/@registers/, 'variable.predefined'],
|
||||
[/@intelOperators/, 'annotation'],
|
||||
// brackets
|
||||
[/[{}<>()\[\]]/, '@brackets'],
|
||||
[/@registers/, 'variable.predefined'],
|
||||
[/@intelOperators/, 'annotation'],
|
||||
// brackets
|
||||
[/[{}<>()\[\]]/, '@brackets'],
|
||||
|
||||
// ARM-style label reference
|
||||
[/[|][^|]*[|]*/, 'type.identifier'],
|
||||
// ARM-style label reference
|
||||
[/[|][^|]*[|]*/, 'type.identifier'],
|
||||
|
||||
// numbers
|
||||
[/\d*\.\d+([eE][\-+]?\d+)?/, 'number.float'],
|
||||
[/([$]|0[xX])[0-9a-fA-F]+/, 'number.hex'],
|
||||
[/\d+/, 'number'],
|
||||
// ARM-style immediate numbers (which otherwise look like comments)
|
||||
[/#-?\d+/, 'number'],
|
||||
// numbers
|
||||
[/\d*\.\d+([eE][\-+]?\d+)?/, 'number.float'],
|
||||
[/([$]|0[xX])[0-9a-fA-F]+/, 'number.hex'],
|
||||
[/\d+/, 'number'],
|
||||
// ARM-style immediate numbers (which otherwise look like comments)
|
||||
[/#-?\d+/, 'number'],
|
||||
|
||||
// operators
|
||||
[/[-+,*\/!:&]/, 'operator'],
|
||||
// operators
|
||||
[/[-+,*\/!:&]/, 'operator'],
|
||||
|
||||
// strings
|
||||
[/"([^"\\]|\\.)*$/, 'string.invalid'], // non-terminated string
|
||||
[/"/, {token: 'string.quote', bracket: '@open', next: '@string'}],
|
||||
// strings
|
||||
[/"([^"\\]|\\.)*$/, 'string.invalid'], // non-terminated string
|
||||
[/"/, {token: 'string.quote', bracket: '@open', next: '@string'}],
|
||||
|
||||
// characters
|
||||
[/'[^\\']'/, 'string'],
|
||||
[/(')(@escapes)(')/, ['string', 'string.escape', 'string']],
|
||||
[/'/, 'string.invalid'],
|
||||
// characters
|
||||
[/'[^\\']'/, 'string'],
|
||||
[/(')(@escapes)(')/, ['string', 'string.escape', 'string']],
|
||||
[/'/, 'string.invalid'],
|
||||
|
||||
// Assume anything else is a label reference
|
||||
[/%?[.?_$a-zA-Z@][.?_$a-zA-Z0-9@]*/, 'type.identifier'],
|
||||
// Assume anything else is a label reference
|
||||
[/%?[.?_$a-zA-Z@][.?_$a-zA-Z0-9@]*/, 'type.identifier'],
|
||||
|
||||
// whitespace
|
||||
{include: '@whitespace'}
|
||||
],
|
||||
// whitespace
|
||||
{include: '@whitespace'}
|
||||
],
|
||||
|
||||
comment: [
|
||||
[/[^\/*]+/, 'comment'],
|
||||
[/\/\*/, 'comment', '@push'], // nested comment
|
||||
["\\*/", 'comment', '@pop'],
|
||||
[/[\/*]/, 'comment']
|
||||
],
|
||||
comment: [
|
||||
[/[^\/*]+/, 'comment'],
|
||||
[/\/\*/, 'comment', '@push'], // nested comment
|
||||
["\\*/", 'comment', '@pop'],
|
||||
[/[\/*]/, 'comment']
|
||||
],
|
||||
|
||||
string: [
|
||||
[/[^\\"]+/, 'string'],
|
||||
[/@escapes/, 'string.escape'],
|
||||
[/\\./, 'string.escape.invalid'],
|
||||
[/"/, {token: 'string.quote', bracket: '@close', next: '@pop'}]
|
||||
],
|
||||
string: [
|
||||
[/[^\\"]+/, 'string'],
|
||||
[/@escapes/, 'string.escape'],
|
||||
[/\\./, 'string.escape.invalid'],
|
||||
[/"/, {token: 'string.quote', bracket: '@close', next: '@pop'}]
|
||||
],
|
||||
|
||||
whitespace: [
|
||||
[/[ \t\r\n]+/, 'white'],
|
||||
[/\/\*/, 'comment', '@comment'],
|
||||
[/\/\/.*$/, 'comment'],
|
||||
[/[#;\\@].*$/, 'comment']
|
||||
]
|
||||
}
|
||||
};
|
||||
}
|
||||
whitespace: [
|
||||
[/[ \t\r\n]+/, 'white'],
|
||||
[/\/\*/, 'comment', '@comment'],
|
||||
[/\/\/.*$/, 'comment'],
|
||||
[/[#;\\@].*$/, 'comment']
|
||||
]
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
monaco.languages.register({id: 'asm'});
|
||||
monaco.languages.setMonarchTokensProvider('asm', definition());
|
||||
});
|
||||
monaco.languages.register({id: 'asm'});
|
||||
monaco.languages.setMonarchTokensProvider('asm', definition());
|
||||
|
||||
+119
-112
@@ -22,131 +22,138 @@
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
"use strict";
|
||||
|
||||
define(function (require) {
|
||||
"use strict";
|
||||
var FontScale = require('fontscale');
|
||||
var monaco = require('monaco');
|
||||
var _ = require('underscore');
|
||||
var $ = require('jquery');
|
||||
|
||||
var FontScale = require('fontscale');
|
||||
var monaco = require('monaco');
|
||||
var _ = require('underscore');
|
||||
var $ = require('jquery');
|
||||
function Ast(hub, container, state) {
|
||||
this.container = container;
|
||||
this.eventHub = hub.createEventHub();
|
||||
this.domRoot = container.getElement();
|
||||
this.domRoot.html($('#ast').html());
|
||||
this._currentDecorations = [];
|
||||
this.astEditor = monaco.editor.create(this.domRoot.find(".monaco-placeholder")[0], {
|
||||
value: "",
|
||||
scrollBeyondLastLine: false,
|
||||
language: 'cppp', //we only support cpp for now
|
||||
readOnly: true,
|
||||
glyphMargin: true,
|
||||
fontFamily: 'monospace',
|
||||
quickSuggestions: false,
|
||||
fixedOverflowWidgets: true,
|
||||
minimap: {
|
||||
maxColumn: 80
|
||||
},
|
||||
lineNumbersMinChars: 3
|
||||
});
|
||||
|
||||
function Ast(hub, container, state) {
|
||||
this.container = container;
|
||||
this.eventHub = hub.createEventHub();
|
||||
this.domRoot = container.getElement();
|
||||
this.domRoot.html($('#ast').html());
|
||||
this._currentDecorations = [];
|
||||
this.astEditor = monaco.editor.create(this.domRoot.find(".monaco-placeholder")[0], {
|
||||
value: "",
|
||||
scrollBeyondLastLine: false,
|
||||
language: 'cppp', //we only support cpp for now
|
||||
readOnly: true,
|
||||
glyphMargin: true,
|
||||
fontFamily: 'monospace',
|
||||
quickSuggestions: false,
|
||||
fixedOverflowWidgets: true,
|
||||
minimap: {
|
||||
maxColumn: 80
|
||||
},
|
||||
lineNumbersMinChars: 3
|
||||
});
|
||||
this._compilerid = state.id;
|
||||
this._compilerName = state.compilerName;
|
||||
this._editorid = state.editorid;
|
||||
this.fontScale = new FontScale(this.domRoot, state, this.astEditor);
|
||||
this.fontScale.on('change', _.bind(this.updateState, this));
|
||||
|
||||
this._compilerid = state.id;
|
||||
this._compilerName = state.compilerName;
|
||||
this._editorid = state.editorid;
|
||||
this.fontScale = new FontScale(this.domRoot, state, this.astEditor);
|
||||
this.fontScale.on('change', _.bind(this.updateState, this));
|
||||
this.container.on('destroy', this.close, this);
|
||||
|
||||
this.container.on('destroy', this.close, this);
|
||||
this.eventHub.on('compileResult', this.onCompileResult, this);
|
||||
this.eventHub.on('compiler', this.onCompiler, this);
|
||||
this.eventHub.on('compilerClose', this.onCompilerClose, this);
|
||||
this.eventHub.on('editorChange', this.onEditorChange, this);
|
||||
this.eventHub.on('settingsChange', this.onSettingsChange, this);
|
||||
this.eventHub.emit('astViewOpened', this._compilerid);
|
||||
this.eventHub.emit('requestSettings');
|
||||
|
||||
this.eventHub.on('compileResult', this.onCompileResult, this);
|
||||
this.eventHub.on('compiler', this.onCompiler, this);
|
||||
this.eventHub.on('compilerClose', this.onCompilerClose, this);
|
||||
this.eventHub.on('editorChange', this.onEditorChange, this);
|
||||
this.eventHub.on('settingsChange', this.onSettingsChange, this);
|
||||
this.eventHub.emit('astViewOpened', this._compilerid);
|
||||
this.eventHub.emit('requestSettings');
|
||||
container.on('resize', this.resize, this);
|
||||
container.on('shown', this.resize, this);
|
||||
if (state && state.astOutput) {
|
||||
this.showAstResults(state.astOutput);
|
||||
}
|
||||
this.setTitle();
|
||||
}
|
||||
|
||||
container.on('resize', this.resize, this);
|
||||
container.on('shown', this.resize, this);
|
||||
if (state && state.astOutput) {
|
||||
this.showAstResults(state.astOutput);
|
||||
// TODO: de-dupe with compiler etc
|
||||
Ast.prototype.resize = function () {
|
||||
var topBarHeight = this.domRoot.find(".top-bar").outerHeight(true);
|
||||
this.astEditor.layout({
|
||||
width: this.domRoot.width(),
|
||||
height: this.domRoot.height() - topBarHeight
|
||||
});
|
||||
};
|
||||
|
||||
Ast.prototype.onEditorChange = function (id, source) {
|
||||
};
|
||||
|
||||
Ast.prototype.onCompileResult = function (id, compiler, result) {
|
||||
if (this._compilerid == id) {
|
||||
if (result.hasAstOutput) {
|
||||
this.showAstResults(result.astOutput);
|
||||
}
|
||||
else {
|
||||
this.showAstResults("<No output>");
|
||||
}
|
||||
}
|
||||
};
|
||||
Ast.prototype.setTitle = function () {
|
||||
this.container.setTitle(this._compilerName + " Ast Viewer (Editor #" + this._editorid + ", Compiler #" + this._compilerid + ")");
|
||||
};
|
||||
|
||||
Ast.prototype.getDisplayableAst = function (astResult) {
|
||||
return "**" + astResult.astType + "** - " + astResult.displayString;
|
||||
};
|
||||
|
||||
Ast.prototype.showAstResults = function (results) {
|
||||
this.astEditor.setValue(results);
|
||||
};
|
||||
|
||||
Ast.prototype.onCompiler = function (id, compiler, options, editorid) {
|
||||
if (id == this._compilerid) {
|
||||
this._compilerName = compiler ? compiler.name : '';
|
||||
this._editorid = editorid;
|
||||
this.setTitle();
|
||||
}
|
||||
};
|
||||
|
||||
// TODO: de-dupe with compiler etc
|
||||
Ast.prototype.resize = function () {
|
||||
var topBarHeight = this.domRoot.find(".top-bar").outerHeight(true);
|
||||
this.astEditor.layout({
|
||||
width: this.domRoot.width(),
|
||||
height: this.domRoot.height() - topBarHeight
|
||||
});
|
||||
};
|
||||
Ast.prototype.onCompilerClose = function (id) {
|
||||
if (id === this._compilerid) {
|
||||
// We can't immediately close as an outer loop somewhere in GoldenLayout is iterating over
|
||||
// the hierarchy. We can't modify while it's being iterated over.
|
||||
_.defer(function (self) {
|
||||
self.container.close();
|
||||
}, this);
|
||||
}
|
||||
};
|
||||
|
||||
Ast.prototype.onEditorChange = function (id, source) {
|
||||
};
|
||||
Ast.prototype.updateState = function () {
|
||||
};
|
||||
|
||||
Ast.prototype.onCompileResult = function (id, compiler, result) {
|
||||
if (this._compilerid == id) {
|
||||
if (result.hasAstOutput) {
|
||||
this.showAstResults(result.astOutput);
|
||||
}
|
||||
else {
|
||||
this.showAstResults("<No output>");
|
||||
}
|
||||
Ast.prototype.onCompilerClose = function (id) {
|
||||
if (id === this._compilerid) {
|
||||
// We can't immediately close as an outer loop somewhere in GoldenLayout is iterating over
|
||||
// the hierarchy. We can't modify while it's being iterated over.
|
||||
this.close();
|
||||
_.defer(function (self) {
|
||||
self.container.close();
|
||||
}, this);
|
||||
}
|
||||
};
|
||||
|
||||
Ast.prototype.onSettingsChange = function (newSettings) {
|
||||
this.astEditor.updateOptions({
|
||||
minimap: {
|
||||
enabled: newSettings.showMinimap
|
||||
}
|
||||
};
|
||||
Ast.prototype.setTitle = function () {
|
||||
this.container.setTitle(this._compilerName + " Ast Viewer (Editor #" + this._editorid + ", Compiler #" + this._compilerid + ")");
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
Ast.prototype.getDisplayableAst = function (astResult) {
|
||||
return "**" + astResult.astType + "** - " + astResult.displayString;
|
||||
};
|
||||
Ast.prototype.close = function () {
|
||||
this.eventHub.unsubscribe();
|
||||
this.eventHub.emit("astViewClosed", this._compilerid);
|
||||
this.astEditor.dispose();
|
||||
};
|
||||
|
||||
Ast.prototype.showAstResults = function (results) {
|
||||
this.astEditor.setValue(results);
|
||||
};
|
||||
|
||||
Ast.prototype.onCompiler = function (id, compiler, options, editorid) {
|
||||
if (id == this._compilerid) {
|
||||
this._compilerName = compiler ? compiler.name : '';
|
||||
this._editorid = editorid;
|
||||
this.setTitle();
|
||||
}
|
||||
};
|
||||
|
||||
Ast.prototype.onCompilerClose = function (id) {
|
||||
if (id === this._compilerid) {
|
||||
// We can't immediately close as an outer loop somewhere in GoldenLayout is iterating over
|
||||
// the hierarchy. We can't modify while it's being iterated over.
|
||||
this.close();
|
||||
_.defer(function (self) {
|
||||
self.container.close();
|
||||
}, this);
|
||||
}
|
||||
};
|
||||
|
||||
Ast.prototype.updateState = function () {
|
||||
};
|
||||
|
||||
Ast.prototype.onSettingsChange = function (newSettings) {
|
||||
this.astEditor.updateOptions({
|
||||
minimap: {
|
||||
enabled: newSettings.showMinimap
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
Ast.prototype.close = function () {
|
||||
this.eventHub.unsubscribe();
|
||||
this.eventHub.emit("astViewClosed", this._compilerid);
|
||||
this.astEditor.dispose();
|
||||
};
|
||||
|
||||
return {
|
||||
Ast: Ast
|
||||
};
|
||||
});
|
||||
module.exports = {
|
||||
Ast: Ast
|
||||
};
|
||||
|
||||
+179
-176
@@ -23,154 +23,146 @@
|
||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
define(function (require) {
|
||||
'use strict';
|
||||
'use strict';
|
||||
|
||||
var $ = require('jquery');
|
||||
var vis = require('vis');
|
||||
var _ = require('underscore');
|
||||
require('selectize');
|
||||
var $ = require('jquery');
|
||||
var vis = require('vis');
|
||||
var _ = require('underscore');
|
||||
|
||||
function Cfg(hub, container, state) {
|
||||
this.container = container;
|
||||
this.eventHub = hub.createEventHub();
|
||||
this.domRoot = container.getElement();
|
||||
this.domRoot.html($('#cfg').html());
|
||||
this.defaultCfgOutput = {nodes: [{id: 0, shape: 'box', label: 'No Output'}], edges: []};
|
||||
this.binaryModeSupport = {
|
||||
nodes: [{
|
||||
id: 0,
|
||||
shape: 'box',
|
||||
label: 'Cfg mode cannot be used when the binary filter is set'
|
||||
}], edges: []
|
||||
};
|
||||
// Note that this might be outdated if no functions were present when creating the link, but that's handled
|
||||
// by selectize
|
||||
this.currentFunc = state.selectedFn || '';
|
||||
this.functions = [];
|
||||
this.networkOpts = {
|
||||
autoResize: true,
|
||||
locale: 'en',
|
||||
edges: {
|
||||
arrows: {to: {enabled: true}},
|
||||
smooth: {enabled: true},
|
||||
physics: false
|
||||
},
|
||||
nodes: {
|
||||
font: {face: 'monospace', align: 'left'}
|
||||
},
|
||||
layout: {
|
||||
improvedLayout: true,
|
||||
hierarchical: {
|
||||
enabled: true,
|
||||
sortMethod: 'directed',
|
||||
direction: 'UD',
|
||||
nodeSpacing: 100,
|
||||
levelSeparation: 150
|
||||
}
|
||||
},
|
||||
physics: {
|
||||
hierarchicalRepulsion: {
|
||||
nodeDistance: 125
|
||||
}
|
||||
},
|
||||
interaction: {
|
||||
navigationButtons: false,
|
||||
keyboard: {
|
||||
enabled: true,
|
||||
speed: {x: 10, y: 10, zoom: 0.03},
|
||||
bindToWindow: false
|
||||
}
|
||||
require('selectize');
|
||||
require("vis/dist/vis.css");
|
||||
|
||||
function Cfg(hub, container, state) {
|
||||
this.container = container;
|
||||
this.eventHub = hub.createEventHub();
|
||||
this.domRoot = container.getElement();
|
||||
this.domRoot.html($('#cfg').html());
|
||||
this.defaultCfgOutput = {nodes: [{id: 0, shape: 'box', label: 'No Output'}], edges: []};
|
||||
this.binaryModeSupport = {
|
||||
nodes: [{
|
||||
id: 0,
|
||||
shape: 'box',
|
||||
label: 'Cfg mode cannot be used when the binary filter is set'
|
||||
}], edges: []
|
||||
};
|
||||
// Note that this might be outdated if no functions were present when creating the link, but that's handled
|
||||
// by selectize
|
||||
this.currentFunc = state.selectedFn || '';
|
||||
this.functions = [];
|
||||
this.networkOpts = {
|
||||
autoResize: true,
|
||||
locale: 'en',
|
||||
edges: {
|
||||
arrows: {to: {enabled: true}},
|
||||
smooth: {enabled: true},
|
||||
physics: false
|
||||
},
|
||||
nodes: {
|
||||
font: {face: 'monospace', align: 'left'}
|
||||
},
|
||||
layout: {
|
||||
improvedLayout: true,
|
||||
hierarchical: {
|
||||
enabled: true,
|
||||
sortMethod: 'directed',
|
||||
direction: 'UD',
|
||||
nodeSpacing: 100,
|
||||
levelSeparation: 150
|
||||
}
|
||||
};
|
||||
|
||||
this.cfgVisualiser = new vis.Network(this.domRoot.find('.graph-placeholder')[0],
|
||||
this.defaultCfgOutput, this.networkOpts);
|
||||
this.domRoot.find('.show-hide-btn').on('click', _.bind(function () {
|
||||
this.networkOpts.interaction.navigationButtons = !this.networkOpts.interaction.navigationButtons;
|
||||
this.cfgVisualiser.setOptions(this.networkOpts);
|
||||
}, this));
|
||||
|
||||
this.compilerId = state.id;
|
||||
this._editorid = state.editorid;
|
||||
this._binaryFilter = false;
|
||||
|
||||
this.functionPicker = $(this.domRoot).find('.function-picker').selectize({
|
||||
sortField: 'name',
|
||||
valueField: 'name',
|
||||
labelField: 'name',
|
||||
searchField: ['name']
|
||||
}).on('change', _.bind(function (e) {
|
||||
var selectedFn = this.functions[e.target.value];
|
||||
if (selectedFn) {
|
||||
this.currentFunc = e.target.value;
|
||||
this.showCfgResults({
|
||||
nodes: selectedFn.nodes,
|
||||
edges: selectedFn.edges
|
||||
});
|
||||
this.cfgVisualiser.selectNodes([selectedFn.nodes[0].id]);
|
||||
this.saveState();
|
||||
},
|
||||
physics: {
|
||||
hierarchicalRepulsion: {
|
||||
nodeDistance: 125
|
||||
}
|
||||
}, this));
|
||||
|
||||
this.eventHub.on('compilerClose', this.onCompilerClose, this);
|
||||
this.eventHub.on('compileResult', this.onCompileResult, this);
|
||||
this.eventHub.on('compiler', this.onCompiler, this);
|
||||
this.eventHub.on('filtersChange', this.onFiltersChange, this);
|
||||
|
||||
this.container.on('destroy', this.close, this);
|
||||
this.container.on('resize', this.resize, this);
|
||||
this.container.on('shown', this.resize, this);
|
||||
this.eventHub.emit('cfgViewOpened', this.compilerId);
|
||||
this.eventHub.emit('requestFilters', this.compilerId);
|
||||
this.eventHub.emit('requestCompiler', this.compilerId);
|
||||
|
||||
this.adaptStructure = function (names) {
|
||||
return _.map(names, function (name) {return {name: name};});
|
||||
};
|
||||
|
||||
this.setTitle();
|
||||
}
|
||||
|
||||
Cfg.prototype.onCompileResult = function (id, compiler, result) {
|
||||
if (this.compilerId === id) {
|
||||
var functionNames = [];
|
||||
if (this.supportsCfg && !$.isEmptyObject(result.cfg)) {
|
||||
this.functions = result.cfg;
|
||||
functionNames = Object.keys(this.functions);
|
||||
if (functionNames.indexOf(this.currentFunc) === -1) {
|
||||
this.currentFunc = functionNames[0];
|
||||
}
|
||||
this.showCfgResults({
|
||||
nodes: this.functions[this.currentFunc].nodes,
|
||||
edges: this.functions[this.currentFunc].edges
|
||||
});
|
||||
this.cfgVisualiser.selectNodes([this.functions[this.currentFunc].nodes[0].id]);
|
||||
} else {
|
||||
// We don't reset the current function here as we would lose the saved one if this happened at the begining
|
||||
// (Hint: It *does* happen)
|
||||
this.showCfgResults(this._binaryFilter ? this.binaryModeSupport : this.defaultCfgOutput);
|
||||
},
|
||||
interaction: {
|
||||
navigationButtons: false,
|
||||
keyboard: {
|
||||
enabled: true,
|
||||
speed: {x: 10, y: 10, zoom: 0.03},
|
||||
bindToWindow: false
|
||||
}
|
||||
|
||||
this.functionPicker[0].selectize.clearOptions();
|
||||
this.functionPicker[0].selectize.addOption(functionNames.length ? this.adaptStructure(functionNames) : {name: 'The input does not contain functions'});
|
||||
this.functionPicker[0].selectize.refreshOptions(false);
|
||||
|
||||
this.functionPicker[0].selectize.clear();
|
||||
this.functionPicker[0].selectize.addItem(functionNames.length ? this.currentFunc : 'The input does not contain functions', true);
|
||||
this.saveState();
|
||||
}
|
||||
};
|
||||
|
||||
Cfg.prototype.setTitle = function () {
|
||||
this.container.setTitle((this._compilerName || '') + ' Graph Viewer (Editor #' + this._editorid + ', Compiler #' + this.compilerId + ')');
|
||||
this.cfgVisualiser = new vis.Network(this.domRoot.find('.graph-placeholder')[0],
|
||||
this.defaultCfgOutput, this.networkOpts);
|
||||
this.domRoot.find('.show-hide-btn').on('click', _.bind(function () {
|
||||
this.networkOpts.interaction.navigationButtons = !this.networkOpts.interaction.navigationButtons;
|
||||
this.cfgVisualiser.setOptions(this.networkOpts);
|
||||
}, this));
|
||||
|
||||
this.compilerId = state.id;
|
||||
this._editorid = state.editorid;
|
||||
this._binaryFilter = false;
|
||||
|
||||
this.functionPicker = $(this.domRoot).find('.function-picker').selectize({
|
||||
sortField: 'name',
|
||||
valueField: 'name',
|
||||
labelField: 'name',
|
||||
searchField: ['name']
|
||||
}).on('change', _.bind(function (e) {
|
||||
var selectedFn = this.functions[e.target.value];
|
||||
if (selectedFn) {
|
||||
this.currentFunc = e.target.value;
|
||||
this.showCfgResults({
|
||||
nodes: selectedFn.nodes,
|
||||
edges: selectedFn.edges
|
||||
});
|
||||
this.cfgVisualiser.selectNodes([selectedFn.nodes[0].id]);
|
||||
this.saveState();
|
||||
}
|
||||
}, this));
|
||||
|
||||
this.eventHub.on('compilerClose', this.onCompilerClose, this);
|
||||
this.eventHub.on('compileResult', this.onCompileResult, this);
|
||||
this.eventHub.on('compiler', this.onCompiler, this);
|
||||
this.eventHub.on('filtersChange', this.onFiltersChange, this);
|
||||
|
||||
this.container.on('destroy', this.close, this);
|
||||
this.container.on('resize', this.resize, this);
|
||||
this.container.on('shown', this.resize, this);
|
||||
this.eventHub.emit('cfgViewOpened', this.compilerId);
|
||||
this.eventHub.emit('requestFilters', this.compilerId);
|
||||
this.eventHub.emit('requestCompiler', this.compilerId);
|
||||
|
||||
this.adaptStructure = function (names) {
|
||||
return _.map(names, function (name) {return {name: name};});
|
||||
};
|
||||
|
||||
Cfg.prototype.showCfgResults = function (data) {
|
||||
this.cfgVisualiser.setData(data);
|
||||
};
|
||||
this.setTitle();
|
||||
}
|
||||
|
||||
Cfg.prototype.onCompiler = function (id, compiler) {
|
||||
Cfg.prototype.onCompileResult = function (id, compiler, result) {
|
||||
if (this._compilerid === id) {
|
||||
var functionNames = [];
|
||||
if (result.supportsCfg && !$.isEmptyObject(result.cfg)) {
|
||||
this.functions = result.cfg;
|
||||
functionNames = Object.keys(this.functions);
|
||||
if (functionNames.indexOf(this.currentFunc) === -1) {
|
||||
this.currentFunc = functionNames[0];
|
||||
}
|
||||
this.showCfgResults({
|
||||
nodes: this.functions[this.currentFunc].nodes,
|
||||
edges: this.functions[this.currentFunc].edges
|
||||
});
|
||||
this.cfgVisualiser.selectNodes([this.functions[this.currentFunc].nodes[0].id]);
|
||||
} else {
|
||||
// We don't reset the current function here as we would lose the saved one if this happened at the begining
|
||||
// (Hint: It *does* happen)
|
||||
this.showCfgResults(this._binaryFilter ? this.binaryModeSupport : this.defaultCfgOutput);
|
||||
}
|
||||
|
||||
this.functionPicker[0].selectize.clearOptions();
|
||||
this.functionPicker[0].selectize.addOption(functionNames.length ? this.adaptStructure(functionNames) : {name: 'The input does not contain functions'});
|
||||
this.functionPicker[0].selectize.refreshOptions(false);
|
||||
|
||||
this.functionPicker[0].selectize.clear();
|
||||
this.functionPicker[0].selectize.addItem(functionNames.length ? this.currentFunc : 'The input does not contain any function', true);
|
||||
this.saveState();
|
||||
}
|
||||
};
|
||||
Cfg.prototype.onCompiler = function (id, compiler) {
|
||||
if (id === this.compilerId) {
|
||||
this._compilerName = compiler ? compiler.name : '';
|
||||
this.supportsCfg = compiler.supportsCfg;
|
||||
@@ -178,51 +170,62 @@ define(function (require) {
|
||||
}
|
||||
};
|
||||
|
||||
Cfg.prototype.onFiltersChange = function (id, filters) {
|
||||
if (this.compilerId === id) {
|
||||
this._binaryFilter = filters.binary;
|
||||
}
|
||||
};
|
||||
Cfg.prototype.onFiltersChange = function (id, filters) {
|
||||
if (this.compilerId === id) {
|
||||
this._binaryFilter = filters.binary;
|
||||
}
|
||||
};
|
||||
|
||||
Cfg.prototype.resize = function () {
|
||||
if (this.cfgVisualiser.canvas) {
|
||||
var height = this.domRoot.height() - this.domRoot.find('.top-bar').outerHeight(true);
|
||||
this.cfgVisualiser.setSize('100%', height.toString());
|
||||
this.cfgVisualiser.redraw();
|
||||
}
|
||||
};
|
||||
Cfg.prototype.resize = function () {
|
||||
if (this.cfgVisualiser.canvas) {
|
||||
var height = this.domRoot.height() - this.domRoot.find('.top-bar').outerHeight(true);
|
||||
this.cfgVisualiser.setSize('100%', height.toString());
|
||||
this.cfgVisualiser.redraw();
|
||||
}
|
||||
};
|
||||
|
||||
Cfg.prototype.saveState = function () {
|
||||
this.container.setState(this.currentState());
|
||||
};
|
||||
Cfg.prototype.setTitle = function () {
|
||||
this.container.setTitle(this._compilerName + ' Graph Viewer (Editor #' + this._editorid + ', Compiler #' + this._compilerid + ')');
|
||||
};
|
||||
|
||||
Cfg.prototype.currentState = function () {
|
||||
return {
|
||||
id: this.compilerId,
|
||||
editorid: this._editorid,
|
||||
selectedFn: this.currentFunc
|
||||
};
|
||||
};
|
||||
Cfg.prototype.showCfgResults = function (data) {
|
||||
this.cfgVisualiser.setData(data);
|
||||
};
|
||||
|
||||
Cfg.prototype.onCompilerClose = function (compilerId) {
|
||||
if (this.compilerId === compilerId) {
|
||||
// We can't immediately close as an outer loop somewhere in GoldenLayout is iterating over
|
||||
// the hierarchy. We can't modify while it's being iterated over.
|
||||
this.close();
|
||||
_.defer(function (self) {
|
||||
self.container.close();
|
||||
}, this);
|
||||
}
|
||||
};
|
||||
|
||||
Cfg.prototype.close = function () {
|
||||
this.eventHub.unsubscribe();
|
||||
this.eventHub.emit('cfgViewClosed', this.compilerId);
|
||||
this.cfgVisualiser.destroy();
|
||||
};
|
||||
Cfg.prototype.onCompilerClose = function (compilerId) {
|
||||
if (this.compilerId === compilerId) {
|
||||
// We can't immediately close as an outer loop somewhere in GoldenLayout is iterating over
|
||||
// the hierarchy. We can't modify while it's being iterated over.
|
||||
this.close();
|
||||
_.defer(function (self) {
|
||||
self.container.close();
|
||||
}, this);
|
||||
}
|
||||
};
|
||||
|
||||
Cfg.prototype.close = function () {
|
||||
this.eventHub.unsubscribe();
|
||||
this.eventHub.emit('cfgViewClosed', this.compilerId);
|
||||
this.cfgVisualiser.destroy();
|
||||
};
|
||||
|
||||
|
||||
|
||||
Cfg.prototype.saveState = function () {
|
||||
this.container.setState(this.currentState());
|
||||
};
|
||||
|
||||
Cfg.prototype.currentState = function () {
|
||||
return {
|
||||
Cfg: Cfg
|
||||
id: this.compilerId,
|
||||
editorid: this._editorid,
|
||||
selectedFn: this.currentFunc
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
module.exports = {
|
||||
Cfg: Cfg
|
||||
};
|
||||
|
||||
|
||||
+30
-34
@@ -22,42 +22,38 @@
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
"use strict";
|
||||
|
||||
define(function (require) {
|
||||
"use strict";
|
||||
var _ = require('underscore');
|
||||
|
||||
var _ = require('underscore');
|
||||
var monaco = require('monaco');
|
||||
// themes is an array so one scheme can be used in multiple places. If you want to use it everywhere, ['all'] should suffice
|
||||
var schemes = [
|
||||
{name: 'rainbow', desc: 'Rainbow 1', count: 12, themes: ['default']},
|
||||
{name: 'rainbow2', desc: 'Rainbow 2', count: 12, themes: ['default']},
|
||||
{name: 'earth', desc: 'Earth tones (colourblind safe)', count: 9, themes: ['default']},
|
||||
{name: 'green-blue', desc: 'Greens and blues (colourblind safe)', count: 4, themes: ['default']},
|
||||
{name: 'gray-shade', desc: 'Gray shades', count: 4, themes: ['dark']}
|
||||
];
|
||||
|
||||
// themes is an array so one scheme can be used in multiple places. If you want to use it everywhere, ['all'] should suffice
|
||||
var schemes = [
|
||||
{name: 'rainbow', desc: 'Rainbow 1', count: 12, themes: ['default']},
|
||||
{name: 'rainbow2', desc: 'Rainbow 2', count: 12, themes: ['default']},
|
||||
{name: 'earth', desc: 'Earth tones (colourblind safe)', count: 9, themes: ['default']},
|
||||
{name: 'green-blue', desc: 'Greens and blues (colourblind safe)', count: 4, themes: ['default']},
|
||||
{name: 'gray-shade', desc: 'Gray shades', count: 4, themes: ['dark']}
|
||||
];
|
||||
|
||||
function applyColours(editor, colours, schemeName, prevDecorations) {
|
||||
var scheme = _.findWhere(schemes, {name: schemeName});
|
||||
if (!scheme) {
|
||||
scheme = schemes[0];
|
||||
}
|
||||
var newDecorations = _.map(colours, function (ordinal, line) {
|
||||
line = parseInt(line) + 1;
|
||||
return {
|
||||
range: new monaco.Range(line, 1, line, 1),
|
||||
options: {
|
||||
isWholeLine: true,
|
||||
className: scheme.name + "-" + (ordinal % scheme.count)
|
||||
}
|
||||
};
|
||||
});
|
||||
return editor.deltaDecorations(prevDecorations, newDecorations);
|
||||
function applyColours(editor, colours, schemeName, prevDecorations) {
|
||||
var scheme = _.findWhere(schemes, {name: schemeName});
|
||||
if (!scheme) {
|
||||
scheme = schemes[0];
|
||||
}
|
||||
var newDecorations = _.map(colours, function (ordinal, line) {
|
||||
line = parseInt(line) + 1;
|
||||
return {
|
||||
range: new monaco.Range(line, 1, line, 1),
|
||||
options: {
|
||||
isWholeLine: true,
|
||||
className: scheme.name + "-" + (ordinal % scheme.count)
|
||||
}
|
||||
};
|
||||
});
|
||||
return editor.deltaDecorations(prevDecorations, newDecorations);
|
||||
}
|
||||
|
||||
return {
|
||||
applyColours: applyColours,
|
||||
schemes: schemes
|
||||
};
|
||||
});
|
||||
module.exports = {
|
||||
applyColours: applyColours,
|
||||
schemes: schemes
|
||||
};
|
||||
|
||||
+109
-111
@@ -23,122 +23,120 @@
|
||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
define(function (require) {
|
||||
"use strict";
|
||||
var $ = require('jquery');
|
||||
var _ = require('underscore');
|
||||
var LruCache = require('lru-cache');
|
||||
var options = require('options');
|
||||
var Promise = require('es6-promise').Promise;
|
||||
"use strict";
|
||||
var $ = require('jquery');
|
||||
var _ = require('underscore');
|
||||
var LruCache = require('lru-cache');
|
||||
var options = require('options');
|
||||
var Promise = require('es6-promise').Promise;
|
||||
|
||||
function CompilerService() {
|
||||
this.cache = new LruCache({
|
||||
max: 200 * 1024,
|
||||
length: function (n) {
|
||||
return JSON.stringify(n).length;
|
||||
}
|
||||
});
|
||||
this.compilersByLang = {};
|
||||
_.each(options.compilers, function (compiler) {
|
||||
if (!this.compilersByLang[compiler.lang]) this.compilersByLang[compiler.lang] = {};
|
||||
this.compilersByLang[compiler.lang][compiler.id] = compiler;
|
||||
if (compiler.alias) {
|
||||
this.compilersByLang[compiler.lang][compiler.alias] = compiler;
|
||||
}
|
||||
}, this);
|
||||
function CompilerService() {
|
||||
this.cache = new LruCache({
|
||||
max: 200 * 1024,
|
||||
length: function (n) {
|
||||
return JSON.stringify(n).length;
|
||||
}
|
||||
});
|
||||
this.compilersByLang = {};
|
||||
_.each(options.compilers, function (compiler) {
|
||||
if (!this.compilersByLang[compiler.lang]) this.compilersByLang[compiler.lang] = {};
|
||||
this.compilersByLang[compiler.lang][compiler.id] = compiler;
|
||||
if (compiler.alias) {
|
||||
this.compilersByLang[compiler.lang][compiler.alias] = compiler;
|
||||
}
|
||||
}, this);
|
||||
}
|
||||
|
||||
CompilerService.prototype.getCompilersForLang = function (langId) {
|
||||
return this.compilersByLang[langId] || {};
|
||||
};
|
||||
|
||||
CompilerService.prototype.findCompiler = function (langId, compilerId) {
|
||||
if (!compilerId) return null;
|
||||
var compilers = this.getCompilersForLang(langId);
|
||||
if (compilers && compilers[compilerId]) {
|
||||
return compilers[compilerId];
|
||||
}
|
||||
return _.find(compilers, function (compiler) {
|
||||
return compiler.alias === compilerId;
|
||||
});
|
||||
};
|
||||
|
||||
CompilerService.prototype.getCompilersForLang = function (langId) {
|
||||
return this.compilersByLang[langId] || {};
|
||||
};
|
||||
|
||||
CompilerService.prototype.findCompiler = function (langId, compilerId) {
|
||||
if (!compilerId) return null;
|
||||
var compilers = this.getCompilersForLang(langId);
|
||||
if (compilers && compilers[compilerId]) {
|
||||
return compilers[compilerId];
|
||||
}
|
||||
return _.find(compilers, function (compiler) {
|
||||
return compiler.alias === compilerId;
|
||||
CompilerService.prototype.submit = function (request) {
|
||||
var jsonRequest = JSON.stringify(request);
|
||||
var cachedResult = this.cache.get(jsonRequest);
|
||||
if (cachedResult) {
|
||||
return Promise.resolve({
|
||||
request: request,
|
||||
result: cachedResult,
|
||||
localCacheHit: true
|
||||
});
|
||||
};
|
||||
|
||||
CompilerService.prototype.submit = function (request) {
|
||||
var jsonRequest = JSON.stringify(request);
|
||||
var cachedResult = this.cache.get(jsonRequest);
|
||||
if (cachedResult) {
|
||||
return Promise.resolve({
|
||||
request: request,
|
||||
result: cachedResult,
|
||||
localCacheHit: true
|
||||
});
|
||||
}
|
||||
return new Promise(_.bind(function (resolve, reject) {
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: 'api/compiler/' + encodeURIComponent(request.compiler) + '/compile',
|
||||
dataType: 'json',
|
||||
contentType: 'application/json',
|
||||
data: jsonRequest,
|
||||
success: _.bind(function (result) {
|
||||
if (result && result.okToCache) {
|
||||
this.cache.set(jsonRequest, result);
|
||||
}
|
||||
resolve({
|
||||
request: request,
|
||||
result: result,
|
||||
localCacheHit: false
|
||||
});
|
||||
}, this),
|
||||
error: function (xhr, textStatus, errorThrown) {
|
||||
var error = errorThrown;
|
||||
if (!error) {
|
||||
switch (textStatus) {
|
||||
case "timeout":
|
||||
error = "Request timed out";
|
||||
break;
|
||||
case "abort":
|
||||
error = "Request was aborted";
|
||||
break;
|
||||
default:
|
||||
error = "Error sending request";
|
||||
break;
|
||||
}
|
||||
}
|
||||
reject({
|
||||
request: request,
|
||||
error: error
|
||||
});
|
||||
}
|
||||
return new Promise(_.bind(function (resolve, reject) {
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: 'api/compiler/' + encodeURIComponent(request.compiler) + '/compile',
|
||||
dataType: 'json',
|
||||
contentType: 'application/json',
|
||||
data: jsonRequest,
|
||||
success: _.bind(function (result) {
|
||||
if (result && result.okToCache) {
|
||||
this.cache.set(jsonRequest, result);
|
||||
}
|
||||
});
|
||||
}, this));
|
||||
};
|
||||
|
||||
CompilerService.prototype.expand = function (source) {
|
||||
var includeFind = /^\s*#include\s*["<](https?:\/\/[^>"]+)[>"]/;
|
||||
var lines = source.split("\n");
|
||||
var promises = [];
|
||||
_.each(lines, function (line, lineNumZeroBased) {
|
||||
var match = line.match(includeFind);
|
||||
if (match) {
|
||||
promises.push(new Promise(function (resolve, reject) {
|
||||
var req = $.get(match[1], function (data) {
|
||||
data = '#line 1 "' + match[1] + '"\n' + data + '\n\n#line ' +
|
||||
(lineNumZeroBased + 1) + ' "<stdin>"\n';
|
||||
|
||||
lines[lineNumZeroBased] = data;
|
||||
resolve();
|
||||
});
|
||||
req.fail(function () {
|
||||
resolve();
|
||||
});
|
||||
}));
|
||||
resolve({
|
||||
request: request,
|
||||
result: result,
|
||||
localCacheHit: false
|
||||
});
|
||||
}, this),
|
||||
error: function (xhr, textStatus, errorThrown) {
|
||||
var error = errorThrown;
|
||||
if (!error) {
|
||||
switch (textStatus) {
|
||||
case "timeout":
|
||||
error = "Request timed out";
|
||||
break;
|
||||
case "abort":
|
||||
error = "Request was aborted";
|
||||
break;
|
||||
default:
|
||||
error = "Error sending request";
|
||||
break;
|
||||
}
|
||||
}
|
||||
reject({
|
||||
request: request,
|
||||
error: error
|
||||
});
|
||||
}
|
||||
});
|
||||
return Promise.all(promises).then(function () {
|
||||
return lines.join("\n");
|
||||
});
|
||||
};
|
||||
}, this));
|
||||
};
|
||||
|
||||
return CompilerService;
|
||||
});
|
||||
CompilerService.prototype.expand = function (source) {
|
||||
var includeFind = /^\s*#include\s*["<](https?:\/\/[^>"]+)[>"]/;
|
||||
var lines = source.split("\n");
|
||||
var promises = [];
|
||||
_.each(lines, function (line, lineNumZeroBased) {
|
||||
var match = line.match(includeFind);
|
||||
if (match) {
|
||||
promises.push(new Promise(function (resolve, reject) {
|
||||
var req = $.get(match[1], function (data) {
|
||||
data = '#line 1 "' + match[1] + '"\n' + data + '\n\n#line ' +
|
||||
(lineNumZeroBased + 1) + ' "<stdin>"\n';
|
||||
|
||||
lines[lineNumZeroBased] = data;
|
||||
resolve();
|
||||
});
|
||||
req.fail(function () {
|
||||
resolve();
|
||||
});
|
||||
}));
|
||||
}
|
||||
});
|
||||
return Promise.all(promises).then(function () {
|
||||
return lines.join("\n");
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = CompilerService;
|
||||
|
||||
+1194
-1195
File diff suppressed because it is too large
Load Diff
+286
-277
@@ -23,291 +23,300 @@
|
||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
define(function (require) {
|
||||
"use strict";
|
||||
"use strict";
|
||||
|
||||
var options = require('options');
|
||||
var _ = require('underscore');
|
||||
var $ = require('jquery');
|
||||
var options = require('options');
|
||||
var _ = require('underscore');
|
||||
var $ = require('jquery');
|
||||
|
||||
require('selectize');
|
||||
require('selectize');
|
||||
|
||||
function Conformance(hub, container, state) {
|
||||
this.container = container;
|
||||
this.eventHub = hub.createEventHub();
|
||||
this.compilerService = hub.compilerService;
|
||||
this.domRoot = container.getElement();
|
||||
this.domRoot.html($('#conformance').html());
|
||||
this.selectorList = this.domRoot.find('.compiler-list');
|
||||
this.addCompilerButton = this.domRoot.find('.add-compiler');
|
||||
this.selectorTemplate = $('#compiler-selector .compiler-row');
|
||||
this.editorId = state.editorid;
|
||||
this.nextSelectorId = 0;
|
||||
this.maxCompilations = options.cvCompilerCountMax || 6;
|
||||
this.langId = state.langId || _.keys(options.languages)[0];
|
||||
this.source = state.source || "";
|
||||
function Conformance(hub, container, state) {
|
||||
this.container = container;
|
||||
this.eventHub = hub.createEventHub();
|
||||
this.compilerService = hub.compilerService;
|
||||
this.domRoot = container.getElement();
|
||||
this.domRoot.html($('#conformance').html());
|
||||
this.selectorList = this.domRoot.find('.compiler-list');
|
||||
this.addCompilerButton = this.domRoot.find('.add-compiler');
|
||||
this.selectorTemplate = $('#compiler-selector .compiler-row');
|
||||
this.editorId = state.editorid;
|
||||
this.nextSelectorId = 0;
|
||||
this.maxCompilations = options.cvCompilerCountMax || 6;
|
||||
this.langId = state.langId || _.keys(options.languages)[0];
|
||||
this.source = state.source || "";
|
||||
|
||||
this.status = {
|
||||
allowCompile: false,
|
||||
allowAdd: true
|
||||
};
|
||||
this.stateByLang = {};
|
||||
|
||||
this.container.on('destroy', this.close, this);
|
||||
|
||||
this.container.on('open', function () {
|
||||
this.eventHub.emit("conformanceViewOpen", this.editorId);
|
||||
}, this);
|
||||
|
||||
this.eventHub.on('resize', this.resize, this);
|
||||
this.container.on('resize', this.resize, this);
|
||||
|
||||
this.container.on('shown', this.resize, this);
|
||||
|
||||
this.eventHub.on('editorChange', this.onEditorChange, this);
|
||||
this.eventHub.on('editorClose', this.onEditorClose, this);
|
||||
this.eventHub.on('languageChange', this.onLanguageChange, this);
|
||||
|
||||
this.addCompilerButton.on('click', _.bind(function () {
|
||||
this.addCompilerSelector();
|
||||
this.saveState();
|
||||
}, this));
|
||||
|
||||
this.initFromState(state);
|
||||
this.handleToolbarUI();
|
||||
}
|
||||
|
||||
Conformance.prototype.setTitle = function (compilerCount) {
|
||||
this.container.setTitle(options.languages[this.langId].name + " Conformance viewer (Editor #" + this.editorId + ") " + (
|
||||
compilerCount !== 0 ? (compilerCount + "/" + this.maxCompilations) : ""
|
||||
));
|
||||
this.status = {
|
||||
allowCompile: false,
|
||||
allowAdd: true
|
||||
};
|
||||
this.stateByLang = {};
|
||||
|
||||
Conformance.prototype.addCompilerSelector = function (config) {
|
||||
if (!config) {
|
||||
config = {
|
||||
// Code we have
|
||||
cv: this.nextSelectorId,
|
||||
// Compiler id which is being used
|
||||
compilerId: "",
|
||||
// Options which are in use
|
||||
options: "",
|
||||
};
|
||||
this.nextSelectorId++;
|
||||
}
|
||||
|
||||
config.cv = Number(config.cv);
|
||||
|
||||
var newEntry = this.selectorTemplate.clone();
|
||||
|
||||
newEntry.attr("data-cv", config.cv);
|
||||
|
||||
var onOptionsChange = _.debounce(_.bind(function () {
|
||||
this.saveState();
|
||||
this.compileAll();
|
||||
}, this), 800);
|
||||
|
||||
newEntry.find('.options')
|
||||
.attr("data-cv", config.cv)
|
||||
.val(config.options)
|
||||
.on("click", onOptionsChange)
|
||||
.on("keyup", onOptionsChange);
|
||||
|
||||
newEntry.find('.close')
|
||||
.attr("data-cv", config.cv)
|
||||
.on("click", _.bind(function () {
|
||||
this.removeCompilerSelector(config.cv);
|
||||
}, this));
|
||||
|
||||
this.selectorList.append(newEntry);
|
||||
|
||||
var status = newEntry.find('.status').attr("data-cv", config.cv);
|
||||
var langId = this.langId;
|
||||
var isVisible = function (compiler) {
|
||||
return compiler.lang === langId;
|
||||
};
|
||||
|
||||
newEntry.find('.compiler-picker')
|
||||
.attr("data-cv", config.cv)
|
||||
.selectize({
|
||||
sortField: 'name',
|
||||
valueField: 'id',
|
||||
labelField: 'name',
|
||||
searchField: ['name'],
|
||||
options: _.filter(options.compilers, isVisible),
|
||||
items: config.compilerId ? [config.compilerId] : []
|
||||
})
|
||||
.on('change', _.bind(function () {
|
||||
// Hide the results button when a new compiler is selected
|
||||
this.handleStatusIcon(status, {code: 0, text: ""});
|
||||
// We could narrow the compilation to only this compiler!
|
||||
this.compileAll();
|
||||
// We're not saving state here. It's done after compiling
|
||||
}, this));
|
||||
this.handleStatusIcon(status, {code: 0, text: ""});
|
||||
this.handleToolbarUI();
|
||||
this.saveState();
|
||||
};
|
||||
|
||||
Conformance.prototype.removeCompilerSelector = function (cv) {
|
||||
_.each(this.selectorList.children(), function (row) {
|
||||
var child = $(row);
|
||||
if (child.attr("data-cv") == cv) {
|
||||
child.remove();
|
||||
}
|
||||
}, this);
|
||||
this.handleToolbarUI();
|
||||
this.saveState();
|
||||
};
|
||||
|
||||
Conformance.prototype.onEditorChange = function (editorId, newSource, langId) {
|
||||
if (editorId == this.editorId) {
|
||||
this.langId = langId;
|
||||
this.source = newSource;
|
||||
this.compileAll();
|
||||
}
|
||||
};
|
||||
|
||||
Conformance.prototype.onEditorClose = function (editorId) {
|
||||
if (editorId === this.editorId) {
|
||||
this.close();
|
||||
_.defer(function (self) {
|
||||
self.container.close();
|
||||
}, this);
|
||||
}
|
||||
};
|
||||
|
||||
Conformance.prototype.onCompileResponse = function (cv, result) {
|
||||
var allText = _.pluck((result.stdout || []).concat(result.stderr || []), 'text').join("\n");
|
||||
var failed = result.code !== 0;
|
||||
var warns = !failed && !!allText;
|
||||
var status = {
|
||||
text: allText.replace(/\x1b\\[[0-9;]*m/, ''),
|
||||
code: failed ? 3 : (warns ? 2 : 1)
|
||||
};
|
||||
this.handleStatusIcon(this.selectorList.find('[data-cv="' + cv + '"] .status'), status);
|
||||
this.saveState();
|
||||
};
|
||||
|
||||
Conformance.prototype.compileAll = function () {
|
||||
if (!this.source) return;
|
||||
// Hide previous status icons
|
||||
this.selectorList.find('.status').css("visibility", "hidden");
|
||||
this.compilerService.expand(this.source).then(_.bind(function (expanded) {
|
||||
var compileCount = 0;
|
||||
_.each(this.selectorList.children(), _.bind(function (child) {
|
||||
var picker = $(child).find('.compiler-picker');
|
||||
// We make sure we are not over our limit
|
||||
if (picker && compileCount < this.maxCompilations) {
|
||||
compileCount++;
|
||||
if (picker.val()) {
|
||||
var cv = Number(picker.attr("data-cv"));
|
||||
var request = {
|
||||
source: expanded || "",
|
||||
compiler: picker.val(),
|
||||
options: {
|
||||
userArguments: $(child).find(".options[data-cv='" + cv + "']").val(),
|
||||
filters: {},
|
||||
compilerOptions: {produceAst: false, produceOptInfo: false}
|
||||
}
|
||||
};
|
||||
// This error function ensures that the user will know we had a problem (As we don't save asm)
|
||||
this.compilerService.submit(request)
|
||||
.then(_.bind(function (x) {
|
||||
this.onCompileResponse(cv, x.result);
|
||||
}, this))
|
||||
.catch(_.bind(function (x) {
|
||||
this.onCompileResponse(cv, {
|
||||
asm: "",
|
||||
code: -1,
|
||||
stdout: "",
|
||||
stderr: x.error
|
||||
});
|
||||
}, this));
|
||||
}
|
||||
}
|
||||
}, this));
|
||||
}, this));
|
||||
};
|
||||
|
||||
Conformance.prototype.handleToolbarUI = function () {
|
||||
var compilerCount = this.selectorList.children().length;
|
||||
|
||||
// Only allow new compilers if we allow for more
|
||||
this.addCompilerButton.attr("disabled", compilerCount >= this.maxCompilations);
|
||||
|
||||
this.setTitle(compilerCount);
|
||||
};
|
||||
|
||||
Conformance.prototype.handleStatusIcon = function (element, status) {
|
||||
if (!element) return;
|
||||
element.attr("class", "status glyphicon glyphicon-" + (status.code === 3 ? "remove-sign" : (status.code === 2 ? "info-sign" : "ok-sign")))
|
||||
.css("visibility", status.code === 0 ? "hidden" : "visible")
|
||||
.css("color", status.code === 3 ? "red" : (status.code === 2 ? "yellow" : "green"))
|
||||
.attr("title", status.text)
|
||||
.attr("aria-label", status.code === 3 ? "Compilation failed!" : (status.code === 2 ? "Compiled with warnings" : "Compiled without warnings"))
|
||||
.attr("data-status", status.code);
|
||||
};
|
||||
|
||||
Conformance.prototype.currentState = function () {
|
||||
var state = {
|
||||
editorid: this.editorId,
|
||||
langId: this.langId,
|
||||
compilers: []
|
||||
};
|
||||
_.each(this.selectorList.children(), _.bind(function (child) {
|
||||
state.compilers.push({
|
||||
// Code we have
|
||||
cv: $(child).attr("data-cv"),
|
||||
// Compiler which is being used
|
||||
compilerId: $(child).find('.compiler-picker').val(),
|
||||
// Options which are in use
|
||||
options: $(child).find(".options").val(),
|
||||
});
|
||||
}, this));
|
||||
return state;
|
||||
};
|
||||
|
||||
Conformance.prototype.saveState = function () {
|
||||
this.container.setState(this.currentState());
|
||||
};
|
||||
|
||||
Conformance.prototype.resize = function () {
|
||||
this.selectorList.css("height", this.domRoot.height() - this.domRoot.find('.top-bar').outerHeight(true));
|
||||
};
|
||||
|
||||
Conformance.prototype.onLanguageChange = function (editorId, newLangId) {
|
||||
if (editorId === this.editorId && this.langId !== newLangId) {
|
||||
var oldLangId = this.langId;
|
||||
this.stateByLang[oldLangId] = this.currentState();
|
||||
|
||||
this.langId = newLangId;
|
||||
this.selectorList.children().remove();
|
||||
this.nextSelectorId = 0;
|
||||
if (this.stateByLang[newLangId]) {
|
||||
this.initFromState(this.stateByLang[newLangId]);
|
||||
}
|
||||
this.handleToolbarUI();
|
||||
this.saveState();
|
||||
}
|
||||
};
|
||||
|
||||
Conformance.prototype.initFromState = function (state) {
|
||||
if (state.compilers) {
|
||||
_.each(state.compilers, _.bind(function (config) {
|
||||
config.cv = this.nextSelectorId;
|
||||
this.nextSelectorId++;
|
||||
this.addCompilerSelector(config);
|
||||
}, this));
|
||||
}
|
||||
};
|
||||
|
||||
Conformance.prototype.close = function () {
|
||||
this.container.on('destroy', function () {
|
||||
this.eventHub.unsubscribe();
|
||||
this.eventHub.emit("conformanceViewClose", this.editorId);
|
||||
}, this);
|
||||
|
||||
this.container.on('destroy', this.close, this);
|
||||
this.container.on('open', function () {
|
||||
this.eventHub.emit("conformanceViewOpen", this.editorId);
|
||||
}, this);
|
||||
|
||||
this.eventHub.on('resize', this.resize, this);
|
||||
this.container.on('resize', this.resize, this);
|
||||
this.eventHub.on('editorChange', this.onEditorChange, this);
|
||||
this.eventHub.on('editorClose', this.onEditorClose, this);
|
||||
this.eventHub.on('languageChange', this.onLanguageChange, this);
|
||||
this.container.on('shown', this.resize, this);
|
||||
|
||||
this.eventHub.on('editorChange', this.onEditorChange, this);
|
||||
this.eventHub.on('editorClose', this.onEditorClose, this);
|
||||
|
||||
this.addCompilerButton.on('click', _.bind(function () {
|
||||
this.addCompilerSelector();
|
||||
this.saveState();
|
||||
}, this));
|
||||
|
||||
if (state.compilers) {
|
||||
_.each(state.compilers, _.bind(function (config) {
|
||||
config.cv = this.nextSelectorId;
|
||||
this.nextSelectorId++;
|
||||
this.addCompilerSelector(config);
|
||||
}, this));
|
||||
}
|
||||
|
||||
this.handleToolbarUI();
|
||||
}
|
||||
|
||||
Conformance.prototype.setTitle = function (compilerCount) {
|
||||
this.container.setTitle("Conformance viewer (Editor #" + this.editorId + ") " + (
|
||||
compilerCount !== 0 ? (compilerCount + "/" + this.maxCompilations) : ""
|
||||
));
|
||||
};
|
||||
|
||||
|
||||
Conformance.prototype.addCompilerSelector = function (config) {
|
||||
if (!config) {
|
||||
config = {
|
||||
// Code we have
|
||||
cv: this.nextSelectorId,
|
||||
// Compiler id which is being used
|
||||
compilerId: "",
|
||||
// Options which are in use
|
||||
options: "",
|
||||
};
|
||||
this.nextSelectorId++;
|
||||
}
|
||||
|
||||
config.cv = Number(config.cv);
|
||||
|
||||
var newEntry = this.selectorTemplate.clone();
|
||||
|
||||
newEntry.attr("data-cv", config.cv);
|
||||
|
||||
var onOptionsChange = _.debounce(_.bind(function () {
|
||||
this.saveState();
|
||||
this.compileAll();
|
||||
}, this), 800);
|
||||
|
||||
newEntry.find('.options')
|
||||
.attr("data-cv", config.cv)
|
||||
.val(config.options)
|
||||
.on("click", onOptionsChange)
|
||||
.on("keyup", onOptionsChange);
|
||||
|
||||
newEntry.find('.close')
|
||||
.attr("data-cv", config.cv)
|
||||
.on("click", _.bind(function () {
|
||||
this.removeCompilerSelector(config.cv);
|
||||
}, this));
|
||||
|
||||
this.selectorList.append(newEntry);
|
||||
|
||||
var status = newEntry.find('.status').attr("data-cv", config.cv);
|
||||
var langId = this.langId;
|
||||
var isVisible = function (compiler) {
|
||||
return compiler.lang === langId;
|
||||
};
|
||||
|
||||
return {
|
||||
Conformance: Conformance
|
||||
newEntry.find('.compiler-picker')
|
||||
.attr("data-cv", config.cv)
|
||||
.selectize({
|
||||
sortField: 'name',
|
||||
valueField: 'id',
|
||||
labelField: 'name',
|
||||
searchField: ['name'],
|
||||
options: _.filter(options.compilers, isVisible),
|
||||
items: config.compilerId ? [config.compilerId] : []
|
||||
})
|
||||
.on('change', _.bind(function () {
|
||||
// Hide the results button when a new compiler is selected
|
||||
this.handleStatusIcon(status, {code: 0, text: ""});
|
||||
// We could narrow the compilation to only this compiler!
|
||||
this.compileAll();
|
||||
// We're not saving state here. It's done after compiling
|
||||
}, this));
|
||||
this.handleStatusIcon(status, {code: 0, text: ""});
|
||||
this.handleToolbarUI();
|
||||
this.saveState();
|
||||
};
|
||||
Conformance.prototype.removeCompilerSelector = function (cv) {
|
||||
_.each(this.selectorList.children(), function (row) {
|
||||
var child = $(row);
|
||||
if (child.attr("data-cv") == cv) {
|
||||
child.remove();
|
||||
}
|
||||
}, this);
|
||||
this.handleToolbarUI();
|
||||
this.saveState();
|
||||
};
|
||||
|
||||
Conformance.prototype.onEditorChange = function (editorId, newSource, langId) {
|
||||
if (editorId == this.editorId) {
|
||||
this.langId = langId;
|
||||
this.source = newSource;
|
||||
this.compileAll();
|
||||
}
|
||||
};
|
||||
|
||||
Conformance.prototype.onEditorClose = function (editorId) {
|
||||
if (editorId == this.editorId) {
|
||||
this.close();
|
||||
_.defer(function (self) {
|
||||
self.container.close();
|
||||
}, this);
|
||||
}
|
||||
};
|
||||
|
||||
Conformance.prototype.onCompileResponse = function (cv, result) {
|
||||
var allText = _.pluck((result.stdout || []).concat(result.stderr || []), 'text').join("\n");
|
||||
var failed = result.code !== 0;
|
||||
var warns = !failed && !!allText;
|
||||
var status = {
|
||||
text: allText.replace(/\x1b\\[[0-9;]*m/, ''),
|
||||
code: failed ? 3 : (warns ? 2 : 1)
|
||||
};
|
||||
});
|
||||
this.handleStatusIcon(this.selectorList.find('[data-cv="' + cv + '"] .status'), status);
|
||||
this.saveState();
|
||||
};
|
||||
|
||||
Conformance.prototype.compileAll = function () {
|
||||
if (!this.source) return;
|
||||
// Hide previous status icons
|
||||
this.selectorList.find('.status').css("visibility", "hidden");
|
||||
this.compilerService.expand(this.source).then(_.bind(function (expanded) {
|
||||
var compileCount = 0;
|
||||
_.each(this.selectorList.children(), _.bind(function (child) {
|
||||
var picker = $(child).find('.compiler-picker');
|
||||
// We make sure we are not over our limit
|
||||
if (picker && compileCount < this.maxCompilations) {
|
||||
compileCount++;
|
||||
if (picker.val()) {
|
||||
var cv = Number(picker.attr("data-cv"));
|
||||
var request = {
|
||||
source: expanded || "",
|
||||
compiler: picker.val(),
|
||||
options: {
|
||||
userArguments: $(child).find(".options[data-cv='" + cv + "']").val(),
|
||||
filters: {},
|
||||
compilerOptions: {produceAst: false, produceOptInfo: false}
|
||||
}
|
||||
};
|
||||
// This error function ensures that the user will know we had a problem (As we don't save asm)
|
||||
this.compilerService.submit(request)
|
||||
.then(_.bind(function (x) {
|
||||
this.onCompileResponse(cv, x.result);
|
||||
}, this))
|
||||
.catch(_.bind(function (x) {
|
||||
this.onCompileResponse(cv, {
|
||||
asm: "",
|
||||
code: -1,
|
||||
stdout: "",
|
||||
stderr: x.error
|
||||
});
|
||||
}, this));
|
||||
}
|
||||
}
|
||||
}, this));
|
||||
}, this));
|
||||
};
|
||||
|
||||
Conformance.prototype.handleToolbarUI = function () {
|
||||
var compilerCount = this.selectorList.children().length;
|
||||
|
||||
// Only allow new compilers if we allow for more
|
||||
this.addCompilerButton.attr("disabled", compilerCount >= this.maxCompilations);
|
||||
|
||||
this.setTitle(compilerCount);
|
||||
};
|
||||
|
||||
Conformance.prototype.handleStatusIcon = function (element, status) {
|
||||
if (!element) return;
|
||||
element.attr("class", "status glyphicon glyphicon-" + (status.code === 3 ? "remove-sign" : (status.code === 2 ? "info-sign" : "ok-sign")))
|
||||
.css("visibility", status.code === 0 ? "hidden" : "visible")
|
||||
.css("color", status.code === 3 ? "red" : (status.code === 2 ? "yellow" : "green"))
|
||||
.attr("title", status.text)
|
||||
.attr("aria-label", status.code === 3 ? "Compilation failed!" : (status.code === 2 ? "Compiled with warnings" : "Compiled without warnings"))
|
||||
.attr("data-status", status.code);
|
||||
};
|
||||
|
||||
Conformance.prototype.currentState = function () {
|
||||
var state = {
|
||||
editorid: this.editorId,
|
||||
langId: this.langId,
|
||||
compilers: []
|
||||
};
|
||||
_.each(this.selectorList.children(), _.bind(function (child) {
|
||||
state.compilers.push({
|
||||
// Code we have
|
||||
cv: $(child).attr("data-cv"),
|
||||
// Compiler which is being used
|
||||
compilerId: $(child).find('.compiler-picker').val(),
|
||||
// Options which are in use
|
||||
options: $(child).find(".options").val(),
|
||||
});
|
||||
}, this));
|
||||
return state;
|
||||
};
|
||||
|
||||
Conformance.prototype.saveState = function () {
|
||||
this.container.setState(this.currentState());
|
||||
};
|
||||
|
||||
Conformance.prototype.resize = function () {
|
||||
this.selectorList.css("height", this.domRoot.height() - this.domRoot.find('.top-bar').outerHeight(true));
|
||||
};
|
||||
|
||||
Conformance.prototype.onLanguageChange = function (editorId, newLangId) {
|
||||
if (editorId === this.editorId && this.langId !== newLangId) {
|
||||
var oldLangId = this.langId;
|
||||
this.stateByLang[oldLangId] = this.currentState();
|
||||
|
||||
this.langId = newLangId;
|
||||
this.selectorList.children().remove();
|
||||
this.nextSelectorId = 0;
|
||||
if (this.stateByLang[newLangId]) {
|
||||
this.initFromState(this.stateByLang[newLangId]);
|
||||
}
|
||||
this.handleToolbarUI();
|
||||
this.saveState();
|
||||
}
|
||||
};
|
||||
|
||||
Conformance.prototype.close = function () {
|
||||
this.eventHub.unsubscribe();
|
||||
this.eventHub.emit("conformanceViewClose", this.editorId);
|
||||
};
|
||||
|
||||
Conformance.prototype.initFromState = function (state) {
|
||||
if (state.compilers) {
|
||||
_.each(state.compilers, _.bind(function (config) {
|
||||
config.cv = this.nextSelectorId;
|
||||
this.nextSelectorId++;
|
||||
this.addCompilerSelector(config);
|
||||
}, this));
|
||||
}
|
||||
};
|
||||
module.exports = {
|
||||
Conformance: Conformance
|
||||
};
|
||||
|
||||
+39
-42
@@ -1,48 +1,45 @@
|
||||
define(function (require) {
|
||||
'use strict';
|
||||
var $ = require('jquery');
|
||||
var monaco = require('monaco');
|
||||
var cpp = require('vs/basic-languages/src/cpp');
|
||||
'use strict';
|
||||
var $ = require('jquery');
|
||||
var cpp = require('vs/basic-languages/src/cpp');
|
||||
|
||||
// We need to create a new definition for cpp so we can remove invalid keywords
|
||||
// We need to create a new definition for cpp so we can remove invalid keywords
|
||||
|
||||
function definition() {
|
||||
var cppp = $.extend(true, {}, cpp.language); // deep copy
|
||||
function definition() {
|
||||
var cppp = $.extend(true, {}, cpp.language); // deep copy
|
||||
|
||||
function removeKeyword(keyword) {
|
||||
var index = cppp.keywords.indexOf(keyword);
|
||||
if (index > -1) {
|
||||
cppp.keywords.splice(index, 1);
|
||||
}
|
||||
function removeKeyword(keyword) {
|
||||
var index = cppp.keywords.indexOf(keyword);
|
||||
if (index > -1) {
|
||||
cppp.keywords.splice(index, 1);
|
||||
}
|
||||
|
||||
function removeKeywords(keywords) {
|
||||
for (var i = 0; i < keywords.length; ++i) {
|
||||
removeKeyword(keywords[i]);
|
||||
}
|
||||
}
|
||||
|
||||
function addKeywords(keywords) {
|
||||
// (Ruben) Done one by one as if you just push them all, Monaco complains that they're not strings, but as
|
||||
// far as I can tell, they indeed are all strings. This somehow fixes it. If you know how to fix it, plz go
|
||||
for (var i = 0; i < keywords.length; ++i) {
|
||||
cppp.keywords.push(keywords[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// We remove everything that's not an identifier, underscore reserved name and not an official C++ keyword...
|
||||
// Regarding #617, final is a identifier with special meaning, not a fully qualified keyword
|
||||
removeKeywords(["abstract", "amp", "array", "cpu", "delegate", "each", "event", "finally", "gcnew",
|
||||
"generic", "in", "initonly", "interface", "interior_ptr", "internal", "literal", "partial", "pascal",
|
||||
"pin_ptr", "property", "ref", "restrict", "safe_cast", "sealed", "title_static", "where"]);
|
||||
|
||||
addKeywords(["alignas", "alignof", "and", "and_eq", "asm", "bitand", "bitor", "char16_t", "char32_t", "compl",
|
||||
"not", "not_eq", "or", "or_eq", "xor", "xor_eq"]);
|
||||
|
||||
return cppp;
|
||||
}
|
||||
|
||||
monaco.languages.register({id: 'cppp'});
|
||||
monaco.languages.setLanguageConfiguration('cppp', cpp.conf);
|
||||
monaco.languages.setMonarchTokensProvider('cppp', definition());
|
||||
});
|
||||
function removeKeywords(keywords) {
|
||||
for (var i = 0; i < keywords.length; ++i) {
|
||||
removeKeyword(keywords[i]);
|
||||
}
|
||||
}
|
||||
|
||||
function addKeywords(keywords) {
|
||||
// (Ruben) Done one by one as if you just push them all, Monaco complains that they're not strings, but as
|
||||
// far as I can tell, they indeed are all strings. This somehow fixes it. If you know how to fix it, plz go
|
||||
for (var i = 0; i < keywords.length; ++i) {
|
||||
cppp.keywords.push(keywords[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// We remove everything that's not an identifier, underscore reserved name and not an official C++ keyword...
|
||||
// Regarding #617, final is a identifier with special meaning, not a fully qualified keyword
|
||||
removeKeywords(["abstract", "amp", "array", "cpu", "delegate", "each", "event", "finally", "gcnew",
|
||||
"generic", "in", "initonly", "interface", "interior_ptr", "internal", "literal", "partial", "pascal",
|
||||
"pin_ptr", "property", "ref", "restrict", "safe_cast", "sealed", "title_static", "where"]);
|
||||
|
||||
addKeywords(["alignas", "alignof", "and", "and_eq", "asm", "bitand", "bitor", "char16_t", "char32_t", "compl",
|
||||
"not", "not_eq", "or", "or_eq", "xor", "xor_eq"]);
|
||||
|
||||
return cppp;
|
||||
}
|
||||
|
||||
monaco.languages.register({id: 'cppp'});
|
||||
monaco.languages.setLanguageConfiguration('cppp', cpp.conf);
|
||||
monaco.languages.setMonarchTokensProvider('cppp', definition());
|
||||
|
||||
+243
-247
@@ -21,263 +21,259 @@
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
"use strict";
|
||||
|
||||
define(function (require) {
|
||||
"use strict";
|
||||
var monaco = require('monaco');
|
||||
function definition() {
|
||||
return {
|
||||
defaultToken: 'invalid',
|
||||
|
||||
function definition() {
|
||||
return {
|
||||
defaultToken: 'invalid',
|
||||
keywords: [
|
||||
'abstract',
|
||||
'alias',
|
||||
'align',
|
||||
'asm',
|
||||
'assert',
|
||||
'auto',
|
||||
'body',
|
||||
'bool',
|
||||
'break',
|
||||
'byte',
|
||||
'case',
|
||||
'cast',
|
||||
'catch',
|
||||
'cdouble',
|
||||
'cent',
|
||||
'cfloat',
|
||||
'char',
|
||||
'class',
|
||||
'const',
|
||||
'continue',
|
||||
'creal',
|
||||
'dchar',
|
||||
'debug',
|
||||
'default',
|
||||
'delegate',
|
||||
'delete ',
|
||||
'deprecated',
|
||||
'do',
|
||||
'double',
|
||||
'else',
|
||||
'enum',
|
||||
'export',
|
||||
'extern',
|
||||
'false',
|
||||
'final',
|
||||
'finally',
|
||||
'float',
|
||||
'for',
|
||||
'foreach',
|
||||
'foreach_reverse',
|
||||
'function',
|
||||
'goto',
|
||||
'idouble',
|
||||
'if',
|
||||
'ifloat',
|
||||
'immutable',
|
||||
'import',
|
||||
'in',
|
||||
'inout',
|
||||
'int',
|
||||
'interface',
|
||||
'invariant',
|
||||
'ireal',
|
||||
'is',
|
||||
'lazy',
|
||||
'long',
|
||||
'macro',
|
||||
'mixin',
|
||||
'module',
|
||||
'new',
|
||||
'nothrow',
|
||||
'null',
|
||||
'out',
|
||||
'override',
|
||||
'package',
|
||||
'pragma',
|
||||
'private',
|
||||
'protected',
|
||||
'public',
|
||||
'pure',
|
||||
'real',
|
||||
'ref',
|
||||
'return',
|
||||
'scope',
|
||||
'shared',
|
||||
'short',
|
||||
'static',
|
||||
'struct',
|
||||
'super',
|
||||
'switch',
|
||||
'synchronized',
|
||||
'template',
|
||||
'this',
|
||||
'throw',
|
||||
'true',
|
||||
'try',
|
||||
'typedef',
|
||||
'typeid',
|
||||
'typeof',
|
||||
'ubyte',
|
||||
'ucent',
|
||||
'uint',
|
||||
'ulong',
|
||||
'union',
|
||||
'unittest',
|
||||
'ushort',
|
||||
'version',
|
||||
'void',
|
||||
'volatile',
|
||||
'wchar',
|
||||
'while',
|
||||
'with',
|
||||
'__FILE__',
|
||||
'__FILE_FULL_PATH__',
|
||||
'__MODULE__',
|
||||
'__LINE__',
|
||||
'__FUNCTION__',
|
||||
'__PRETTY_FUNCTION__',
|
||||
'__gshared',
|
||||
'__traits',
|
||||
'__vector',
|
||||
'__parameters'],
|
||||
|
||||
keywords: [
|
||||
'abstract',
|
||||
'alias',
|
||||
'align',
|
||||
'asm',
|
||||
'assert',
|
||||
'auto',
|
||||
'body',
|
||||
'bool',
|
||||
'break',
|
||||
'byte',
|
||||
'case',
|
||||
'cast',
|
||||
'catch',
|
||||
'cdouble',
|
||||
'cent',
|
||||
'cfloat',
|
||||
'char',
|
||||
'class',
|
||||
'const',
|
||||
'continue',
|
||||
'creal',
|
||||
'dchar',
|
||||
'debug',
|
||||
'default',
|
||||
'delegate',
|
||||
'delete ',
|
||||
'deprecated',
|
||||
'do',
|
||||
'double',
|
||||
'else',
|
||||
'enum',
|
||||
'export',
|
||||
'extern',
|
||||
'false',
|
||||
'final',
|
||||
'finally',
|
||||
'float',
|
||||
'for',
|
||||
'foreach',
|
||||
'foreach_reverse',
|
||||
'function',
|
||||
'goto',
|
||||
'idouble',
|
||||
'if',
|
||||
'ifloat',
|
||||
'immutable',
|
||||
'import',
|
||||
'in',
|
||||
'inout',
|
||||
'int',
|
||||
'interface',
|
||||
'invariant',
|
||||
'ireal',
|
||||
'is',
|
||||
'lazy',
|
||||
'long',
|
||||
'macro',
|
||||
'mixin',
|
||||
'module',
|
||||
'new',
|
||||
'nothrow',
|
||||
'null',
|
||||
'out',
|
||||
'override',
|
||||
'package',
|
||||
'pragma',
|
||||
'private',
|
||||
'protected',
|
||||
'public',
|
||||
'pure',
|
||||
'real',
|
||||
'ref',
|
||||
'return',
|
||||
'scope',
|
||||
'shared',
|
||||
'short',
|
||||
'static',
|
||||
'struct',
|
||||
'super',
|
||||
'switch',
|
||||
'synchronized',
|
||||
'template',
|
||||
'this',
|
||||
'throw',
|
||||
'true',
|
||||
'try',
|
||||
'typedef',
|
||||
'typeid',
|
||||
'typeof',
|
||||
'ubyte',
|
||||
'ucent',
|
||||
'uint',
|
||||
'ulong',
|
||||
'union',
|
||||
'unittest',
|
||||
'ushort',
|
||||
'version',
|
||||
'void',
|
||||
'volatile',
|
||||
'wchar',
|
||||
'while',
|
||||
'with',
|
||||
'__FILE__',
|
||||
'__FILE_FULL_PATH__',
|
||||
'__MODULE__',
|
||||
'__LINE__',
|
||||
'__FUNCTION__',
|
||||
'__PRETTY_FUNCTION__',
|
||||
'__gshared',
|
||||
'__traits',
|
||||
'__vector',
|
||||
'__parameters'],
|
||||
typeKeywords: [
|
||||
'bool', 'byte', 'ubyte', 'short', 'ushort', 'int', 'uint', 'long', 'ulong', 'char', 'wchar', 'dchar',
|
||||
'float', 'double', 'real', 'ifloat', 'idouble', 'ireal', 'cfloat', 'cdouble', 'creal', 'void'
|
||||
],
|
||||
|
||||
typeKeywords: [
|
||||
'bool', 'byte', 'ubyte', 'short', 'ushort', 'int', 'uint', 'long', 'ulong', 'char', 'wchar', 'dchar',
|
||||
'float', 'double', 'real', 'ifloat', 'idouble', 'ireal', 'cfloat', 'cdouble', 'creal', 'void'
|
||||
operators: [
|
||||
'=', '>', '<', '!', '~', '?', ':',
|
||||
'==', '<=', '>=', '!=', '&&', '||', '++', '--',
|
||||
'+', '-', '*', '/', '&', '|', '^', '%', '<<',
|
||||
'>>', '>>>', '+=', '-=', '*=', '/=', '&=', '|=',
|
||||
'^=', '%=', '<<=', '>>=', '>>>='
|
||||
],
|
||||
|
||||
// we include these common regular expressions
|
||||
symbols: /[=><!~?:&|+\-*\/^%]+/,
|
||||
escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,
|
||||
|
||||
// The main tokenizer for our languages
|
||||
tokenizer: {
|
||||
root: [
|
||||
// identifiers and keywords
|
||||
[/[a-z_$][\w$]*/, {
|
||||
cases: {
|
||||
'@typeKeywords': 'keyword',
|
||||
'@keywords': 'keyword',
|
||||
'@default': 'identifier'
|
||||
}
|
||||
}],
|
||||
[/[A-Z][\w$]*/, 'type.identifier'], // to show class names nicely
|
||||
|
||||
// whitespace
|
||||
{include: '@whitespace'},
|
||||
|
||||
// delimiters and operators
|
||||
[/[{}()\[\]]/, '@brackets'],
|
||||
[/[<>](?!@symbols)/, '@brackets'],
|
||||
[/@symbols/, {
|
||||
cases: {
|
||||
'@operators': 'operator',
|
||||
'@default': ''
|
||||
}
|
||||
}],
|
||||
|
||||
// numbers
|
||||
[/\d*\.\d+([eE][\-+]?\d+)?[fFdD]?/, 'number.float'],
|
||||
[/0[xX][0-9a-fA-F_]*[0-9a-fA-F][Ll]?/, 'number.hex'],
|
||||
[/0[0-7_]*[0-7][Ll]?/, 'number.octal'],
|
||||
[/0[bB][0-1_]*[0-1][Ll]?/, 'number.binary'],
|
||||
[/\d+[lL]?/, 'number'],
|
||||
|
||||
// delimiter: after number because of .\d floats
|
||||
[/[;,.]/, 'delimiter'],
|
||||
|
||||
// strings
|
||||
[/"([^"\\]|\\.)*$/, 'string.invalid'], // non-teminated string
|
||||
[/"/, 'string', '@string'],
|
||||
[/`/, 'string', '@rawstring'],
|
||||
|
||||
// characters
|
||||
[/'[^\\']'/, 'string'],
|
||||
[/(')(@escapes)(')/, ['string', 'string.escape', 'string']],
|
||||
[/'/, 'string.invalid']
|
||||
],
|
||||
|
||||
operators: [
|
||||
'=', '>', '<', '!', '~', '?', ':',
|
||||
'==', '<=', '>=', '!=', '&&', '||', '++', '--',
|
||||
'+', '-', '*', '/', '&', '|', '^', '%', '<<',
|
||||
'>>', '>>>', '+=', '-=', '*=', '/=', '&=', '|=',
|
||||
'^=', '%=', '<<=', '>>=', '>>>='
|
||||
whitespace: [
|
||||
[/[ \t\r\n]+/, 'white'],
|
||||
[/\/\*/, 'comment', '@comment'],
|
||||
[/\/\+/, 'comment', '@nestingcomment'],
|
||||
[/\/\/.*$/, 'comment'],
|
||||
],
|
||||
|
||||
// we include these common regular expressions
|
||||
symbols: /[=><!~?:&|+\-*\/^%]+/,
|
||||
escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,
|
||||
|
||||
// The main tokenizer for our languages
|
||||
tokenizer: {
|
||||
root: [
|
||||
// identifiers and keywords
|
||||
[/[a-z_$][\w$]*/, {
|
||||
cases: {
|
||||
'@typeKeywords': 'keyword',
|
||||
'@keywords': 'keyword',
|
||||
'@default': 'identifier'
|
||||
}
|
||||
}],
|
||||
[/[A-Z][\w$]*/, 'type.identifier'], // to show class names nicely
|
||||
|
||||
// whitespace
|
||||
{include: '@whitespace'},
|
||||
|
||||
// delimiters and operators
|
||||
[/[{}()\[\]]/, '@brackets'],
|
||||
[/[<>](?!@symbols)/, '@brackets'],
|
||||
[/@symbols/, {
|
||||
cases: {
|
||||
'@operators': 'operator',
|
||||
'@default': ''
|
||||
}
|
||||
}],
|
||||
|
||||
// numbers
|
||||
[/\d*\.\d+([eE][\-+]?\d+)?[fFdD]?/, 'number.float'],
|
||||
[/0[xX][0-9a-fA-F_]*[0-9a-fA-F][Ll]?/, 'number.hex'],
|
||||
[/0[0-7_]*[0-7][Ll]?/, 'number.octal'],
|
||||
[/0[bB][0-1_]*[0-1][Ll]?/, 'number.binary'],
|
||||
[/\d+[lL]?/, 'number'],
|
||||
|
||||
// delimiter: after number because of .\d floats
|
||||
[/[;,.]/, 'delimiter'],
|
||||
|
||||
// strings
|
||||
[/"([^"\\]|\\.)*$/, 'string.invalid'], // non-teminated string
|
||||
[/"/, 'string', '@string'],
|
||||
[/`/, 'string', '@rawstring'],
|
||||
|
||||
// characters
|
||||
[/'[^\\']'/, 'string'],
|
||||
[/(')(@escapes)(')/, ['string', 'string.escape', 'string']],
|
||||
[/'/, 'string.invalid']
|
||||
],
|
||||
|
||||
whitespace: [
|
||||
[/[ \t\r\n]+/, 'white'],
|
||||
[/\/\*/, 'comment', '@comment'],
|
||||
[/\/\+/, 'comment', '@nestingcomment'],
|
||||
[/\/\/.*$/, 'comment'],
|
||||
],
|
||||
|
||||
comment: [
|
||||
[/[^\/*]+/, 'comment'],
|
||||
[/\*\//, 'comment', '@pop'],
|
||||
[/[\/*]/, 'comment']
|
||||
],
|
||||
|
||||
nestingcomment: [
|
||||
[/[^\/+]+/, 'comment'],
|
||||
[/\/\+/, 'comment', '@push'],
|
||||
[/\/\+/, 'comment.invalid'],
|
||||
[/\+\//, 'comment', '@pop'],
|
||||
[/[\/+]/, 'comment']
|
||||
],
|
||||
|
||||
string: [
|
||||
[/[^\\"]+/, 'string'],
|
||||
[/@escapes/, 'string.escape'],
|
||||
[/\\./, 'string.escape.invalid'],
|
||||
[/"/, 'string', '@pop']
|
||||
],
|
||||
|
||||
rawstring: [
|
||||
[/[^\`]/, "string"],
|
||||
[/`/, "string", "@pop"]
|
||||
],
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function configuration() {
|
||||
return {
|
||||
comments: {
|
||||
lineComment: '//',
|
||||
blockComment: ['/*', '*/'],
|
||||
},
|
||||
|
||||
brackets: [
|
||||
['{', '}'],
|
||||
['[', ']'],
|
||||
['(', ')']
|
||||
comment: [
|
||||
[/[^\/*]+/, 'comment'],
|
||||
[/\*\//, 'comment', '@pop'],
|
||||
[/[\/*]/, 'comment']
|
||||
],
|
||||
|
||||
autoClosingPairs: [
|
||||
{ open: '{', close: '}' },
|
||||
{ open: '[', close: ']' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '`', close: '`', notIn: ['string'] },
|
||||
{ open: '"', close: '"', notIn: ['string'] },
|
||||
{ open: '\'', close: '\'', notIn: ['string', 'comment'] },
|
||||
nestingcomment: [
|
||||
[/[^\/+]+/, 'comment'],
|
||||
[/\/\+/, 'comment', '@push'],
|
||||
[/\/\+/, 'comment.invalid'],
|
||||
[/\+\//, 'comment', '@pop'],
|
||||
[/[\/+]/, 'comment']
|
||||
],
|
||||
|
||||
surroundingPairs: [
|
||||
{ open: '{', close: '}' },
|
||||
{ open: '[', close: ']' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '`', close: '`' },
|
||||
{ open: '"', close: '"' },
|
||||
{ open: '\'', close: '\'' },
|
||||
]
|
||||
};
|
||||
}
|
||||
string: [
|
||||
[/[^\\"]+/, 'string'],
|
||||
[/@escapes/, 'string.escape'],
|
||||
[/\\./, 'string.escape.invalid'],
|
||||
[/"/, 'string', '@pop']
|
||||
],
|
||||
|
||||
monaco.languages.register({id: 'd'});
|
||||
monaco.languages.setMonarchTokensProvider('d', definition());
|
||||
monaco.languages.setLanguageConfiguration('d', configuration());
|
||||
});
|
||||
rawstring: [
|
||||
[/[^\`]/, "string"],
|
||||
[/`/, "string", "@pop"]
|
||||
],
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function configuration() {
|
||||
return {
|
||||
comments: {
|
||||
lineComment: '//',
|
||||
blockComment: ['/*', '*/'],
|
||||
},
|
||||
|
||||
brackets: [
|
||||
['{', '}'],
|
||||
['[', ']'],
|
||||
['(', ')']
|
||||
],
|
||||
|
||||
autoClosingPairs: [
|
||||
{ open: '{', close: '}' },
|
||||
{ open: '[', close: ']' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '`', close: '`', notIn: ['string'] },
|
||||
{ open: '"', close: '"', notIn: ['string'] },
|
||||
{ open: '\'', close: '\'', notIn: ['string', 'comment'] },
|
||||
],
|
||||
|
||||
surroundingPairs: [
|
||||
{ open: '{', close: '}' },
|
||||
{ open: '[', close: ']' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '`', close: '`' },
|
||||
{ open: '"', close: '"' },
|
||||
{ open: '\'', close: '\'' },
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
monaco.languages.register({id: 'd'});
|
||||
monaco.languages.setMonarchTokensProvider('d', definition());
|
||||
monaco.languages.setLanguageConfiguration('d', configuration());
|
||||
|
||||
+192
-194
@@ -23,209 +23,207 @@
|
||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
define(function (require) {
|
||||
"use strict";
|
||||
"use strict";
|
||||
|
||||
var FontScale = require('fontscale');
|
||||
var monaco = require('monaco');
|
||||
var _ = require('underscore');
|
||||
var $ = require('jquery');
|
||||
var FontScale = require('fontscale');
|
||||
var monaco = require('monaco');
|
||||
var _ = require('underscore');
|
||||
var $ = require('jquery');
|
||||
|
||||
require('asm-mode');
|
||||
require('selectize');
|
||||
require('asm-mode');
|
||||
require('selectize');
|
||||
|
||||
function State(id, model) {
|
||||
this.id = id;
|
||||
this.model = model;
|
||||
this.compiler = null;
|
||||
this.result = null;
|
||||
}
|
||||
function State(id, model) {
|
||||
this.id = id;
|
||||
this.model = model;
|
||||
this.compiler = null;
|
||||
this.result = null;
|
||||
}
|
||||
|
||||
State.prototype.update = function (id, compiler, result) {
|
||||
if (this.id !== id) return false;
|
||||
this.compiler = compiler;
|
||||
this.result = result;
|
||||
var asm = result.asm || [];
|
||||
this.model.setValue(_.pluck(asm, 'text').join("\n"));
|
||||
return true;
|
||||
};
|
||||
State.prototype.update = function (id, compiler, result) {
|
||||
if (this.id !== id) return false;
|
||||
this.compiler = compiler;
|
||||
this.result = result;
|
||||
var asm = result.asm || [];
|
||||
this.model.setValue(_.pluck(asm, 'text').join("\n"));
|
||||
return true;
|
||||
};
|
||||
|
||||
function Diff(hub, container, state) {
|
||||
this.container = container;
|
||||
this.eventHub = hub.createEventHub();
|
||||
this.domRoot = container.getElement();
|
||||
this.domRoot.html($('#diff').html());
|
||||
this.compilers = {};
|
||||
function Diff(hub, container, state) {
|
||||
this.container = container;
|
||||
this.eventHub = hub.createEventHub();
|
||||
this.domRoot = container.getElement();
|
||||
this.domRoot.html($('#diff').html());
|
||||
this.compilers = {};
|
||||
|
||||
this.outputEditor = monaco.editor.createDiffEditor(this.domRoot.find(".monaco-placeholder")[0], {
|
||||
fontFamily: 'monospace',
|
||||
scrollBeyondLastLine: false,
|
||||
readOnly: true,
|
||||
language: 'asm'
|
||||
});
|
||||
this.outputEditor = monaco.editor.createDiffEditor(this.domRoot.find(".monaco-placeholder")[0], {
|
||||
fontFamily: 'monospace',
|
||||
scrollBeyondLastLine: false,
|
||||
readOnly: true,
|
||||
language: 'asm'
|
||||
});
|
||||
|
||||
this.lhs = new State(state.lhs, monaco.editor.createModel('', 'asm'));
|
||||
this.rhs = new State(state.rhs, monaco.editor.createModel('', 'asm'));
|
||||
this.outputEditor.setModel({original: this.lhs.model, modified: this.rhs.model});
|
||||
this.lhs = new State(state.lhs, monaco.editor.createModel('', 'asm'));
|
||||
this.rhs = new State(state.rhs, monaco.editor.createModel('', 'asm'));
|
||||
this.outputEditor.setModel({original: this.lhs.model, modified: this.rhs.model});
|
||||
|
||||
var selectize = this.domRoot.find(".diff-picker").selectize({
|
||||
sortField: 'name',
|
||||
valueField: 'id',
|
||||
labelField: 'name',
|
||||
searchField: ['name'],
|
||||
options: [],
|
||||
items: [],
|
||||
render: {
|
||||
option: function (item, escape) {
|
||||
return '<div>' +
|
||||
'<span class="compiler">' + escape(item.compiler.name) + '</span>' +
|
||||
'<span class="options">' + escape(item.options) + '</span>' +
|
||||
'<ul class="meta">' +
|
||||
'<li class="editor">Editor #' + escape(item.editorId) + '</li>' +
|
||||
'<li class="compilerId">Compiler #' + escape(item.id) + '</li>' +
|
||||
'</ul></div>';
|
||||
}
|
||||
var selectize = this.domRoot.find(".diff-picker").selectize({
|
||||
sortField: 'name',
|
||||
valueField: 'id',
|
||||
labelField: 'name',
|
||||
searchField: ['name'],
|
||||
options: [],
|
||||
items: [],
|
||||
render: {
|
||||
option: function (item, escape) {
|
||||
return '<div>' +
|
||||
'<span class="compiler">' + escape(item.compiler.name) + '</span>' +
|
||||
'<span class="options">' + escape(item.options) + '</span>' +
|
||||
'<ul class="meta">' +
|
||||
'<li class="editor">Editor #' + escape(item.editorId) + '</li>' +
|
||||
'<li class="compilerId">Compiler #' + escape(item.id) + '</li>' +
|
||||
'</ul></div>';
|
||||
}
|
||||
}).on('change', _.bind(function (e) {
|
||||
var target = $(e.target);
|
||||
var compiler = this.compilers[target.val()];
|
||||
if (!compiler) return;
|
||||
if (target.hasClass('lhs')) {
|
||||
this.lhs.compiler = compiler;
|
||||
this.lhs.id = compiler.id;
|
||||
} else {
|
||||
this.rhs.compiler = compiler;
|
||||
this.rhs.id = compiler.id;
|
||||
}
|
||||
this.onDiffSelect(compiler.id);
|
||||
}, this));
|
||||
this.selectize = {lhs: selectize[0].selectize, rhs: selectize[1].selectize};
|
||||
|
||||
this.fontScale = new FontScale(this.domRoot, state, this.outputEditor);
|
||||
this.fontScale.on('change', _.bind(this.updateState, this));
|
||||
|
||||
this.eventHub.on('compileResult', this.onCompileResult, this);
|
||||
this.eventHub.on('compiler', this.onCompiler, this);
|
||||
this.eventHub.on('compilerClose', this.onCompilerClose, this);
|
||||
this.eventHub.on('themeChange', this.onThemeChange, this);
|
||||
this.container.on('destroy', function () {
|
||||
this.eventHub.unsubscribe();
|
||||
this.outputEditor.dispose();
|
||||
}, this);
|
||||
container.on('resize', this.resize, this);
|
||||
container.on('shown', this.resize, this);
|
||||
|
||||
this.eventHub.emit('resendCompilation', this.lhs.id);
|
||||
this.eventHub.emit('resendCompilation', this.rhs.id);
|
||||
this.eventHub.emit('findCompilers');
|
||||
this.eventHub.emit('requestTheme');
|
||||
|
||||
this.updateCompilerNames();
|
||||
this.updateCompilers();
|
||||
}
|
||||
|
||||
// TODO: de-dupe with compiler etc
|
||||
Diff.prototype.resize = function () {
|
||||
var topBarHeight = this.domRoot.find(".top-bar").outerHeight(true);
|
||||
this.outputEditor.layout({
|
||||
width: this.domRoot.width(),
|
||||
height: this.domRoot.height() - topBarHeight
|
||||
});
|
||||
};
|
||||
|
||||
Diff.prototype.onDiffSelect = function (id) {
|
||||
this.eventHub.emit('resendCompilation', id);
|
||||
this.updateCompilerNames();
|
||||
this.updateState();
|
||||
};
|
||||
|
||||
Diff.prototype.onCompileResult = function (id, compiler, result) {
|
||||
// both sides must be updated, don't be tempted to rewrite this as
|
||||
// var changes = lhs.update() || rhs.update();
|
||||
var lhsChanged = this.lhs.update(id, compiler, result);
|
||||
var rhsChanged = this.rhs.update(id, compiler, result);
|
||||
if (lhsChanged || rhsChanged) {
|
||||
this.updateCompilerNames();
|
||||
}
|
||||
};
|
||||
|
||||
Diff.prototype.onCompiler = function (id, compiler, options, editorId) {
|
||||
}).on('change', _.bind(function (e) {
|
||||
var target = $(e.target);
|
||||
var compiler = this.compilers[target.val()];
|
||||
if (!compiler) return;
|
||||
options = options || "";
|
||||
var name = compiler.name + " " + options;
|
||||
// TODO: selectize doesn't play nicely with CSS tricks for truncation; this is the best I can do
|
||||
// There's a plugin at: http://www.benbybenjacobs.com/blog/2014/04/09/no-wrap-plugin-for-selectize-dot-js
|
||||
// but it doesn't look easy to integrate.
|
||||
var maxLength = 30;
|
||||
if (name.length > maxLength - 3) name = name.substr(0, maxLength - 3) + "...";
|
||||
this.compilers[id] = {
|
||||
id: id,
|
||||
name: name,
|
||||
options: options,
|
||||
editorId: editorId,
|
||||
compiler: compiler
|
||||
if (target.hasClass('lhs')) {
|
||||
this.lhs.compiler = compiler;
|
||||
this.lhs.id = compiler.id;
|
||||
} else {
|
||||
this.rhs.compiler = compiler;
|
||||
this.rhs.id = compiler.id;
|
||||
}
|
||||
this.onDiffSelect(compiler.id);
|
||||
}, this));
|
||||
this.selectize = {lhs: selectize[0].selectize, rhs: selectize[1].selectize};
|
||||
|
||||
this.fontScale = new FontScale(this.domRoot, state, this.outputEditor);
|
||||
this.fontScale.on('change', _.bind(this.updateState, this));
|
||||
|
||||
this.eventHub.on('compileResult', this.onCompileResult, this);
|
||||
this.eventHub.on('compiler', this.onCompiler, this);
|
||||
this.eventHub.on('compilerClose', this.onCompilerClose, this);
|
||||
this.eventHub.on('themeChange', this.onThemeChange, this);
|
||||
this.container.on('destroy', function () {
|
||||
this.eventHub.unsubscribe();
|
||||
this.outputEditor.dispose();
|
||||
}, this);
|
||||
container.on('resize', this.resize, this);
|
||||
container.on('shown', this.resize, this);
|
||||
|
||||
this.eventHub.emit('resendCompilation', this.lhs.id);
|
||||
this.eventHub.emit('resendCompilation', this.rhs.id);
|
||||
this.eventHub.emit('findCompilers');
|
||||
this.eventHub.emit('requestTheme');
|
||||
|
||||
this.updateCompilerNames();
|
||||
this.updateCompilers();
|
||||
}
|
||||
|
||||
// TODO: de-dupe with compiler etc
|
||||
Diff.prototype.resize = function () {
|
||||
var topBarHeight = this.domRoot.find(".top-bar").outerHeight(true);
|
||||
this.outputEditor.layout({
|
||||
width: this.domRoot.width(),
|
||||
height: this.domRoot.height() - topBarHeight
|
||||
});
|
||||
};
|
||||
|
||||
Diff.prototype.onDiffSelect = function (id) {
|
||||
this.eventHub.emit('resendCompilation', id);
|
||||
this.updateCompilerNames();
|
||||
this.updateState();
|
||||
};
|
||||
|
||||
Diff.prototype.onCompileResult = function (id, compiler, result) {
|
||||
// both sides must be updated, don't be tempted to rewrite this as
|
||||
// var changes = lhs.update() || rhs.update();
|
||||
var lhsChanged = this.lhs.update(id, compiler, result);
|
||||
var rhsChanged = this.rhs.update(id, compiler, result);
|
||||
if (lhsChanged || rhsChanged) {
|
||||
this.updateCompilerNames();
|
||||
}
|
||||
};
|
||||
|
||||
Diff.prototype.onCompiler = function (id, compiler, options, editorId) {
|
||||
if (!compiler) return;
|
||||
options = options || "";
|
||||
var name = compiler.name + " " + options;
|
||||
// TODO: selectize doesn't play nicely with CSS tricks for truncation; this is the best I can do
|
||||
// There's a plugin at: http://www.benbybenjacobs.com/blog/2014/04/09/no-wrap-plugin-for-selectize-dot-js
|
||||
// but it doesn't look easy to integrate.
|
||||
var maxLength = 30;
|
||||
if (name.length > maxLength - 3) name = name.substr(0, maxLength - 3) + "...";
|
||||
this.compilers[id] = {
|
||||
id: id,
|
||||
name: name,
|
||||
options: options,
|
||||
editorId: editorId,
|
||||
compiler: compiler
|
||||
};
|
||||
if (!this.lhs.id) {
|
||||
this.lhs.compiler = this.compilers[id];
|
||||
this.lhs.id = id;
|
||||
this.onDiffSelect(id);
|
||||
} else if (!this.rhs.id) {
|
||||
this.rhs.compiler = this.compilers[id];
|
||||
this.rhs.id = id;
|
||||
this.onDiffSelect(id);
|
||||
}
|
||||
this.updateCompilers();
|
||||
};
|
||||
|
||||
Diff.prototype.onCompilerClose = function (id) {
|
||||
delete this.compilers[id];
|
||||
this.updateCompilers();
|
||||
};
|
||||
|
||||
Diff.prototype.updateCompilerNames = function () {
|
||||
var name = "Diff";
|
||||
if (this.lhs.compiler && this.rhs.compiler)
|
||||
name += " " + this.lhs.compiler.name + " vs " + this.rhs.compiler.name;
|
||||
this.container.setTitle(name);
|
||||
};
|
||||
|
||||
Diff.prototype.updateCompilersFor = function (selectize, id) {
|
||||
selectize.clearOptions();
|
||||
_.each(this.compilers, function (compiler) {
|
||||
selectize.addOption(compiler);
|
||||
}, this);
|
||||
if (this.compilers[id]) {
|
||||
selectize.setValue(id);
|
||||
}
|
||||
};
|
||||
|
||||
Diff.prototype.updateCompilers = function () {
|
||||
this.updateCompilersFor(this.selectize.lhs, this.lhs.id);
|
||||
this.updateCompilersFor(this.selectize.rhs, this.rhs.id);
|
||||
};
|
||||
|
||||
Diff.prototype.updateState = function () {
|
||||
var state = {
|
||||
lhs: this.lhs.id,
|
||||
rhs: this.rhs.id
|
||||
};
|
||||
this.fontScale.addState(state);
|
||||
this.container.setState(state);
|
||||
};
|
||||
|
||||
Diff.prototype.onThemeChange = function (newTheme) {
|
||||
if (this.outputEditor)
|
||||
this.outputEditor.updateOptions({theme: newTheme.monaco});
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
Diff: Diff,
|
||||
getComponent: function (lhs, rhs) {
|
||||
return {
|
||||
type: 'component',
|
||||
componentName: 'diff',
|
||||
componentState: {lhs: lhs, rhs: rhs},
|
||||
};
|
||||
if (!this.lhs.id) {
|
||||
this.lhs.compiler = this.compilers[id];
|
||||
this.lhs.id = id;
|
||||
this.onDiffSelect(id);
|
||||
} else if (!this.rhs.id) {
|
||||
this.rhs.compiler = this.compilers[id];
|
||||
this.rhs.id = id;
|
||||
this.onDiffSelect(id);
|
||||
}
|
||||
this.updateCompilers();
|
||||
};
|
||||
|
||||
Diff.prototype.onCompilerClose = function (id) {
|
||||
delete this.compilers[id];
|
||||
this.updateCompilers();
|
||||
};
|
||||
|
||||
Diff.prototype.updateCompilerNames = function () {
|
||||
var name = "Diff";
|
||||
if (this.lhs.compiler && this.rhs.compiler)
|
||||
name += " " + this.lhs.compiler.name + " vs " + this.rhs.compiler.name;
|
||||
this.container.setTitle(name);
|
||||
};
|
||||
|
||||
Diff.prototype.updateCompilersFor = function (selectize, id) {
|
||||
selectize.clearOptions();
|
||||
_.each(this.compilers, function (compiler) {
|
||||
selectize.addOption(compiler);
|
||||
}, this);
|
||||
if (this.compilers[id]) {
|
||||
selectize.setValue(id);
|
||||
}
|
||||
};
|
||||
|
||||
Diff.prototype.updateCompilers = function () {
|
||||
this.updateCompilersFor(this.selectize.lhs, this.lhs.id);
|
||||
this.updateCompilersFor(this.selectize.rhs, this.rhs.id);
|
||||
};
|
||||
|
||||
Diff.prototype.updateState = function () {
|
||||
var state = {
|
||||
lhs: this.lhs.id,
|
||||
rhs: this.rhs.id
|
||||
};
|
||||
this.fontScale.addState(state);
|
||||
this.container.setState(state);
|
||||
};
|
||||
|
||||
Diff.prototype.onThemeChange = function (newTheme) {
|
||||
if (this.outputEditor)
|
||||
this.outputEditor.updateOptions({theme: newTheme.monaco});
|
||||
};
|
||||
|
||||
return {
|
||||
Diff: Diff,
|
||||
getComponent: function (lhs, rhs) {
|
||||
return {
|
||||
type: 'component',
|
||||
componentName: 'diff',
|
||||
componentState: {lhs: lhs, rhs: rhs},
|
||||
};
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
+526
-529
File diff suppressed because it is too large
Load Diff
@@ -1,10 +1,3 @@
|
||||
@import url("ext/bootstrap/dist/css/bootstrap.min.css");
|
||||
@import url("ext/golden-layout/src/css/goldenlayout-base.css");
|
||||
@import url("ext/selectize/dist/css/selectize.bootstrap2.css");
|
||||
@import url("ext/seiyria-bootstrap-slider/dist/css/bootstrap-slider.css");
|
||||
@import url("ext/vis/dist/vis.css");
|
||||
@import url("colours.css");
|
||||
|
||||
/* TEMP HACK: https://github.com/Microsoft/monaco-editor/issues/349 */
|
||||
.quick-open-tree .row {
|
||||
margin-left: 0;
|
||||
|
||||
+74
-76
@@ -23,92 +23,90 @@
|
||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
define(function (require) {
|
||||
"use strict";
|
||||
var _ = require('underscore');
|
||||
var $ = require('jquery');
|
||||
var EventEmitter = require('events');
|
||||
var options = require('./options');
|
||||
"use strict";
|
||||
var _ = require('underscore');
|
||||
var $ = require('jquery');
|
||||
var EventEmitter = require('events');
|
||||
var options = require('./options');
|
||||
|
||||
function makeFontSizeDropdown(elem, interval, obj, buttonDropdown) {
|
||||
var factor = obj.isFontOfStr ? 10 : 14;
|
||||
var step = 0.05;
|
||||
var found = false;
|
||||
function makeFontSizeDropdown(elem, interval, obj, buttonDropdown) {
|
||||
var factor = obj.isFontOfStr ? 10 : 14;
|
||||
var step = 0.05;
|
||||
var found = false;
|
||||
|
||||
var onWheelEvent = function(e) {
|
||||
e.preventDefault();
|
||||
var selectedId = elem.find('.font-option-active').index();
|
||||
if (e.originalEvent.deltaY >= 0 && selectedId < elem.children().length - 1) {
|
||||
selectedId++;
|
||||
} else if (e.originalEvent.deltaY < 0 && selectedId > 0) {
|
||||
selectedId--;
|
||||
}
|
||||
elem.children().eq(selectedId).trigger('click');
|
||||
};
|
||||
|
||||
var onClickEvent = function() {
|
||||
// Toggle off the selection of the others
|
||||
elem.children().removeClass('font-option-active');
|
||||
// Toggle us on
|
||||
$(this).addClass("font-option-active");
|
||||
// Send the data
|
||||
obj.scale = $(this).data("value");
|
||||
obj.apply();
|
||||
obj.emit('change');
|
||||
};
|
||||
|
||||
for (var i = interval[0]; i <= interval[1]; i += step) {
|
||||
step *= 1.2;
|
||||
var newElement = $('<li></li>');
|
||||
newElement.attr('data-value', i);
|
||||
newElement.addClass('font-option');
|
||||
if (!found && (i === obj.scale || Math.floor(i) == obj.scale)) {
|
||||
found = true;
|
||||
newElement.addClass('font-option-active');
|
||||
}
|
||||
newElement.text(Math.round(i * factor));
|
||||
newElement
|
||||
.appendTo(elem)
|
||||
.click(onClickEvent)
|
||||
.on('wheel', onWheelEvent);
|
||||
var onWheelEvent = function(e) {
|
||||
e.preventDefault();
|
||||
var selectedId = elem.find('.font-option-active').index();
|
||||
if (e.originalEvent.deltaY >= 0 && selectedId < elem.children().length - 1) {
|
||||
selectedId++;
|
||||
} else if (e.originalEvent.deltaY < 0 && selectedId > 0) {
|
||||
selectedId--;
|
||||
}
|
||||
elem.children().eq(selectedId).trigger('click');
|
||||
};
|
||||
|
||||
if (buttonDropdown) {
|
||||
buttonDropdown.on('wheel', onWheelEvent);
|
||||
var onClickEvent = function() {
|
||||
// Toggle off the selection of the others
|
||||
elem.children().removeClass('font-option-active');
|
||||
// Toggle us on
|
||||
$(this).addClass("font-option-active");
|
||||
// Send the data
|
||||
obj.scale = $(this).data("value");
|
||||
obj.apply();
|
||||
obj.emit('change');
|
||||
};
|
||||
|
||||
for (var i = interval[0]; i <= interval[1]; i += step) {
|
||||
step *= 1.2;
|
||||
var newElement = $('<li></li>');
|
||||
newElement.attr('data-value', i);
|
||||
newElement.addClass('font-option');
|
||||
if (!found && (i === obj.scale || Math.floor(i) == obj.scale)) {
|
||||
found = true;
|
||||
newElement.addClass('font-option-active');
|
||||
}
|
||||
newElement.text(Math.round(i * factor));
|
||||
newElement
|
||||
.appendTo(elem)
|
||||
.click(onClickEvent)
|
||||
.on('wheel', onWheelEvent);
|
||||
}
|
||||
|
||||
function FontScale(domRoot, state, fontSelectorOrEditor) {
|
||||
EventEmitter.call(this);
|
||||
this.domRoot = domRoot;
|
||||
this.scale = state.fontScale || options.defaultFontScale;
|
||||
this.fontSelectorOrEditor = fontSelectorOrEditor;
|
||||
this.isFontOfStr = typeof(this.fontSelectorOrEditor) === "string";
|
||||
this.apply();
|
||||
makeFontSizeDropdown(this.domRoot.find('.font-size-list'), [0.3, 3], this, this.domRoot.find('.fs-button'));
|
||||
if (buttonDropdown) {
|
||||
buttonDropdown.on('wheel', onWheelEvent);
|
||||
}
|
||||
}
|
||||
|
||||
_.extend(FontScale.prototype, EventEmitter.prototype);
|
||||
function FontScale(domRoot, state, fontSelectorOrEditor) {
|
||||
EventEmitter.call(this);
|
||||
this.domRoot = domRoot;
|
||||
this.scale = state.fontScale || options.defaultFontScale;
|
||||
this.fontSelectorOrEditor = fontSelectorOrEditor;
|
||||
this.isFontOfStr = typeof(this.fontSelectorOrEditor) === "string";
|
||||
this.apply();
|
||||
makeFontSizeDropdown(this.domRoot.find('.font-size-list'), [0.3, 3], this, this.domRoot.find('.fs-button'));
|
||||
}
|
||||
|
||||
FontScale.prototype.apply = function () {
|
||||
if (this.isFontOfStr) {
|
||||
this.domRoot.find(this.fontSelectorOrEditor).css('font-size', (10 * this.scale) + "pt");
|
||||
} else {
|
||||
this.fontSelectorOrEditor.updateOptions({
|
||||
fontSize: 14 * this.scale
|
||||
});
|
||||
}
|
||||
};
|
||||
_.extend(FontScale.prototype, EventEmitter.prototype);
|
||||
|
||||
FontScale.prototype.addState = function (state) {
|
||||
if (this.scale != 1.0)
|
||||
state.fontScale = this.scale;
|
||||
};
|
||||
FontScale.prototype.apply = function () {
|
||||
if (this.isFontOfStr) {
|
||||
this.domRoot.find(this.fontSelectorOrEditor).css('font-size', (10 * this.scale) + "pt");
|
||||
} else {
|
||||
this.fontSelectorOrEditor.updateOptions({
|
||||
fontSize: 14 * this.scale
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
FontScale.prototype.setScale = function (scale) {
|
||||
this.scale = scale;
|
||||
this.apply();
|
||||
};
|
||||
FontScale.prototype.addState = function (state) {
|
||||
if (this.scale != 1.0)
|
||||
state.fontScale = this.scale;
|
||||
};
|
||||
|
||||
return FontScale;
|
||||
});
|
||||
FontScale.prototype.setScale = function (scale) {
|
||||
this.scale = scale;
|
||||
this.apply();
|
||||
};
|
||||
|
||||
module.exports = FontScale;
|
||||
|
||||
+349
-351
@@ -22,385 +22,383 @@
|
||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
define(function (require) {
|
||||
"use strict";
|
||||
var monaco = require('monaco');
|
||||
|
||||
// From https://github.com/byteally/monaco-haskell
|
||||
// It does not work right now. Here as a reminder until the author fixes it
|
||||
function definition() {
|
||||
return {
|
||||
module: /^(module)\b/,
|
||||
import: /^(import)\b/,
|
||||
module_name: /([A-Z][\w']*)(\.[A-Z][\w']*)*/,
|
||||
module_exports:/([A-Z][\w']*)(\.[A-Z][\w']*)*/,
|
||||
target:/([A-Z][\w']*)(\.[A-Z][\w']*)*/,
|
||||
invalid:/[a-z]+/,
|
||||
datatype:/[A-Z][\w]+/,
|
||||
datatypekey:/Int|Float|Text/,
|
||||
functions:/[a-z]+/,
|
||||
datacons:/[A-Z][\w]+/,
|
||||
typcons:/\s*[A-Z][\w]+/,
|
||||
text:/[A-Z][\w]+/,
|
||||
classname:/\s*[A-Z][\w]+/,
|
||||
arguments:/[a-z][\w]*/,
|
||||
reservedid:/qualified|hiding|case|default|deriving|do|else|if|import|in|infix|infixr|let|of|then|type|where|show|_/,
|
||||
tokenizer: {
|
||||
root: [
|
||||
[/(@module)/, 'keyword.module.haskell', '@module'],
|
||||
[/@import/, 'keyword.module.haskell', '@import'],
|
||||
[/\bdata\b(?=@typcons)/,'keyword','@typcons'],
|
||||
[/\bnewtype\b(?=\s*@typcons)/,'keyword','@typcons'],
|
||||
[/\bclass\b(?=\s*@classname)/,'keyword','@classname'],
|
||||
[/\bclass\b(?=\s*\()/,'keyword','@classname'],
|
||||
[/@reservedid/,'keyword'],
|
||||
[/[a-z][\w]+(?=\s*?=)/,'binderas','@binder'],
|
||||
[/[a-z][\w]+(?=\s*::)/,'binderad','@typconss'],
|
||||
[/[a-z][\w]+(?=\s*?[a-z]\w*)/,'binder','@typconss'],
|
||||
[/[a-z][\w]+(?=\s*?::\s*?@datatypekey)/,'bind','@binder'],
|
||||
[/[a-z][\w]+(?=\s*?=\s*?@datacons)/,'bindings'],
|
||||
{include:'@whitespace'},
|
||||
{include:'@comment'}
|
||||
],
|
||||
import: [
|
||||
[/@module_name/,'storage.module,haskell'],
|
||||
[/(@module_name)(?=\s*as)/, 'storage.module.haskell'],
|
||||
[/\b(qualified)\b(?=\s*@module_name)/, 'keyword'],
|
||||
[/(@module_name)(?=\s*?\()/, 'storage.module.haskell'],
|
||||
[/(@module_name)(?=\s*\bhiding\b)/, 'storage.module.haskell'],
|
||||
[/\b(hiding)\b(?=\s*?\()/, 'keyword'],
|
||||
[/\b(as)\b(?=\s*@module_name)/,'keyword'],
|
||||
[/\(/,'openbracketss','@functions'],
|
||||
{include:'@comment'}
|
||||
//{include:'@blockComment'}
|
||||
],
|
||||
module: [
|
||||
[/(@module_name)/, 'storage.module.haskell'],
|
||||
[/\(/, 'openbracket','@module_exports'],
|
||||
[/@reservedid/,'keyword','@pop'],
|
||||
[/@invalid/,'invalid'],
|
||||
[/,/,'commas'],
|
||||
{include:'@whitespace'},
|
||||
{include:'@comment'}
|
||||
//{include:'@blockComment'}
|
||||
],
|
||||
functions: [
|
||||
[/@datatype/,'dcataype','@datatype'],
|
||||
[/@functions/,'functions'],
|
||||
[/,/,'commas'],
|
||||
[/\)(?=\))/,'closebracket'],
|
||||
[/\)/,'closebracketalla','@popall'],
|
||||
{include:'@comment'}
|
||||
//{include:'@blockComment'}
|
||||
],
|
||||
typconss: [
|
||||
[/=/,'eqals'],
|
||||
[/\bundefined\b/,'val','@all'],
|
||||
[/\bclass\b(?=\s*@classname)/,'keyword','@classname'],
|
||||
[/\bclass\b(?=\s*\()/,'keyword','@classname'],
|
||||
[/\binstance\b/,'keyword','@classname'],
|
||||
[/\bdata\b(?=@typcons)/,'keyword','@typcons'],
|
||||
[/\bnewtype\b(?=\s*@typcons)/,'keyword','@typcons'],
|
||||
[/@reservedid/,'keyword','@function'],
|
||||
[/[a-z]\w*/,'arguments121'],
|
||||
[/[a-z][\w]+(?=\s*=)/,'binderad','@datacons'],
|
||||
[/[a-z][\w]+(?=\s*::)/,'binderad','@typconss'],
|
||||
[/[a-z][\w]+(?=\s*[a-z]\w*)/,'binderad','@typconss'],
|
||||
[/[a-z]\w*/,'arguments121'],
|
||||
[/::/,'dcol','@datacons'],
|
||||
[/->/,'pipes','@binder'],
|
||||
{include:'@whitespace'},
|
||||
{include:'@comment'}
|
||||
//{include:'@blockComment'}
|
||||
],
|
||||
"use strict";
|
||||
|
||||
function: [
|
||||
[/@reservedid/,'keyword'],
|
||||
[/@datatypekey/,'dtype'],
|
||||
[/[a-z][\w]+(?=\s*::)/,'binderad','@typconss'],
|
||||
[/[a-z][\w]+(?=\s*?[a-z]\w*)/,'binder','@typconss'],
|
||||
[/[a-z]\w*/,'arguments12'],
|
||||
[/::/,'dcol'],
|
||||
[/->/,'pipe'],
|
||||
[/\bclass\b(?=\s*@classname)/,'keyword','@classname'],
|
||||
[/\bclass\b(?=\s*\()/,'keyword','@classname'],
|
||||
[/\binstance\b/,'keyword','@classname'],
|
||||
[/\bdata\b(?=@typcons)/,'keyword','@typcons'],
|
||||
[/\bnewtype\b(?=\s*@typcons)/,'keyword'],
|
||||
{include:'@comment'}
|
||||
//{include:'@blockComment'}
|
||||
],
|
||||
typcons: [
|
||||
[/=>/,'pipes'],
|
||||
[/->/,'pipe','@bind'],
|
||||
[/\bclass\b(?=\s*@classname)/,'keyword','@classname'],
|
||||
[/\bclass\b(?=\s*\()/,'keyword','@classname'],
|
||||
[/\binstance\b/,'keyword','@classname'],
|
||||
[/\bdata\b(?=@typcons)/,'keyword','@typcons'],
|
||||
[/\bnewtype\b(?=\s*@typcons)/,'keyword'],
|
||||
[/@reservedid(?=\s*\()/,'keyword','@typcons'],
|
||||
[/@reservedid(?=\s*[A-Z][\w]+)/,'keyword','@typcons'],
|
||||
[/@reservedid/,'keyword','@binder'],
|
||||
[/@datatypekey/,'dtypes2'],
|
||||
[/[A-Z][\w]+(?=\s*,)/,'classname','@types'],
|
||||
[/[A-Z][\w]+(?=\s*[a-z][\w]*\s*,)/,'classname','@types'],
|
||||
[/@arguments(?=\s*,\s*)/,'argument','@types'],
|
||||
// From https://github.com/byteally/monaco-haskell
|
||||
// It does not work right now. Here as a reminder until the author fixes it
|
||||
function definition() {
|
||||
return {
|
||||
module: /^(module)\b/,
|
||||
import: /^(import)\b/,
|
||||
module_name: /([A-Z][\w']*)(\.[A-Z][\w']*)*/,
|
||||
module_exports:/([A-Z][\w']*)(\.[A-Z][\w']*)*/,
|
||||
target:/([A-Z][\w']*)(\.[A-Z][\w']*)*/,
|
||||
invalid:/[a-z]+/,
|
||||
datatype:/[A-Z][\w]+/,
|
||||
datatypekey:/Int|Float|Text/,
|
||||
functions:/[a-z]+/,
|
||||
datacons:/[A-Z][\w]+/,
|
||||
typcons:/\s*[A-Z][\w]+/,
|
||||
text:/[A-Z][\w]+/,
|
||||
classname:/\s*[A-Z][\w]+/,
|
||||
arguments:/[a-z][\w]*/,
|
||||
reservedid:/qualified|hiding|case|default|deriving|do|else|if|import|in|infix|infixr|let|of|then|type|where|show|_/,
|
||||
tokenizer: {
|
||||
root: [
|
||||
[/(@module)/, 'keyword.module.haskell', '@module'],
|
||||
[/@import/, 'keyword.module.haskell', '@import'],
|
||||
[/\bdata\b(?=@typcons)/,'keyword','@typcons'],
|
||||
[/\bnewtype\b(?=\s*@typcons)/,'keyword','@typcons'],
|
||||
[/\bclass\b(?=\s*@classname)/,'keyword','@classname'],
|
||||
[/\bclass\b(?=\s*\()/,'keyword','@classname'],
|
||||
[/@reservedid/,'keyword'],
|
||||
[/[a-z][\w]+(?=\s*?=)/,'binderas','@binder'],
|
||||
[/[a-z][\w]+(?=\s*::)/,'binderad','@typconss'],
|
||||
[/[a-z][\w]+(?=\s*?[a-z]\w*)/,'binder','@typconss'],
|
||||
[/[a-z][\w]+(?=\s*?::\s*?@datatypekey)/,'bind','@binder'],
|
||||
[/[a-z][\w]+(?=\s*?=\s*?@datacons)/,'bindings'],
|
||||
{include:'@whitespace'},
|
||||
{include:'@comment'}
|
||||
],
|
||||
import: [
|
||||
[/@module_name/,'storage.module,haskell'],
|
||||
[/(@module_name)(?=\s*as)/, 'storage.module.haskell'],
|
||||
[/\b(qualified)\b(?=\s*@module_name)/, 'keyword'],
|
||||
[/(@module_name)(?=\s*?\()/, 'storage.module.haskell'],
|
||||
[/(@module_name)(?=\s*\bhiding\b)/, 'storage.module.haskell'],
|
||||
[/\b(hiding)\b(?=\s*?\()/, 'keyword'],
|
||||
[/\b(as)\b(?=\s*@module_name)/,'keyword'],
|
||||
[/\(/,'openbracketss','@functions'],
|
||||
{include:'@comment'}
|
||||
//{include:'@blockComment'}
|
||||
],
|
||||
module: [
|
||||
[/(@module_name)/, 'storage.module.haskell'],
|
||||
[/\(/, 'openbracket','@module_exports'],
|
||||
[/@reservedid/,'keyword','@pop'],
|
||||
[/@invalid/,'invalid'],
|
||||
[/,/,'commas'],
|
||||
{include:'@whitespace'},
|
||||
{include:'@comment'}
|
||||
//{include:'@blockComment'}
|
||||
],
|
||||
functions: [
|
||||
[/@datatype/,'dcataype','@datatype'],
|
||||
[/@functions/,'functions'],
|
||||
[/,/,'commas'],
|
||||
[/\)(?=\))/,'closebracket'],
|
||||
[/\)/,'closebracketalla','@popall'],
|
||||
{include:'@comment'}
|
||||
//{include:'@blockComment'}
|
||||
],
|
||||
typconss: [
|
||||
[/=/,'eqals'],
|
||||
[/\bundefined\b/,'val','@all'],
|
||||
[/\bclass\b(?=\s*@classname)/,'keyword','@classname'],
|
||||
[/\bclass\b(?=\s*\()/,'keyword','@classname'],
|
||||
[/\binstance\b/,'keyword','@classname'],
|
||||
[/\bdata\b(?=@typcons)/,'keyword','@typcons'],
|
||||
[/\bnewtype\b(?=\s*@typcons)/,'keyword','@typcons'],
|
||||
[/@reservedid/,'keyword','@function'],
|
||||
[/[a-z]\w*/,'arguments121'],
|
||||
[/[a-z][\w]+(?=\s*=)/,'binderad','@datacons'],
|
||||
[/[a-z][\w]+(?=\s*::)/,'binderad','@typconss'],
|
||||
[/[a-z][\w]+(?=\s*[a-z]\w*)/,'binderad','@typconss'],
|
||||
[/[a-z]\w*/,'arguments121'],
|
||||
[/::/,'dcol','@datacons'],
|
||||
[/->/,'pipes','@binder'],
|
||||
{include:'@whitespace'},
|
||||
{include:'@comment'}
|
||||
//{include:'@blockComment'}
|
||||
],
|
||||
|
||||
[/[A-Z][\w]+/,'typecons'],
|
||||
[/[a-z][\w]+(?=\s*?=)/,'binderas','@binder'],
|
||||
[/[a-z][\w]+(?=\s*::)/,'binderad','@typconss'],
|
||||
[/[a-z][\w]+(?=\s*?[a-z]\w*)/,'bind','@typconss'],
|
||||
[/[a-z][\w]+(?=\s*?::\s*?@datatypekey)/,'bind','@binder'],
|
||||
[/[a-z][\w]+(?=\s*?=\s*?@datacons)/,'bindings'],
|
||||
[/{/,'oopen','@initialise'],
|
||||
[/[a-z]\w*/,'arguments13'],
|
||||
function: [
|
||||
[/@reservedid/,'keyword'],
|
||||
[/@datatypekey/,'dtype'],
|
||||
[/[a-z][\w]+(?=\s*::)/,'binderad','@typconss'],
|
||||
[/[a-z][\w]+(?=\s*?[a-z]\w*)/,'binder','@typconss'],
|
||||
[/[a-z]\w*/,'arguments12'],
|
||||
[/::/,'dcol'],
|
||||
[/->/,'pipe'],
|
||||
[/\bclass\b(?=\s*@classname)/,'keyword','@classname'],
|
||||
[/\bclass\b(?=\s*\()/,'keyword','@classname'],
|
||||
[/\binstance\b/,'keyword','@classname'],
|
||||
[/\bdata\b(?=@typcons)/,'keyword','@typcons'],
|
||||
[/\bnewtype\b(?=\s*@typcons)/,'keyword'],
|
||||
{include:'@comment'}
|
||||
//{include:'@blockComment'}
|
||||
],
|
||||
typcons: [
|
||||
[/=>/,'pipes'],
|
||||
[/->/,'pipe','@bind'],
|
||||
[/\bclass\b(?=\s*@classname)/,'keyword','@classname'],
|
||||
[/\bclass\b(?=\s*\()/,'keyword','@classname'],
|
||||
[/\binstance\b/,'keyword','@classname'],
|
||||
[/\bdata\b(?=@typcons)/,'keyword','@typcons'],
|
||||
[/\bnewtype\b(?=\s*@typcons)/,'keyword'],
|
||||
[/@reservedid(?=\s*\()/,'keyword','@typcons'],
|
||||
[/@reservedid(?=\s*[A-Z][\w]+)/,'keyword','@typcons'],
|
||||
[/@reservedid/,'keyword','@binder'],
|
||||
[/@datatypekey/,'dtypes2'],
|
||||
[/[A-Z][\w]+(?=\s*,)/,'classname','@types'],
|
||||
[/[A-Z][\w]+(?=\s*[a-z][\w]*\s*,)/,'classname','@types'],
|
||||
[/@arguments(?=\s*,\s*)/,'argument','@types'],
|
||||
|
||||
[/\(/,'open_bracket'],
|
||||
[/=/,'Equalss','@datacons'],
|
||||
[/,/,'commaa'],
|
||||
[/::/,'colondouble','@datacons'],
|
||||
[/\)/,'closebrak','@initialise'],
|
||||
[/\)(?=\s* \t\r\n\bdata\b)/,'closed','@popall'],
|
||||
{include:'@whitespace'},
|
||||
{include:'@comment'}
|
||||
[/[A-Z][\w]+/,'typecons'],
|
||||
[/[a-z][\w]+(?=\s*?=)/,'binderas','@binder'],
|
||||
[/[a-z][\w]+(?=\s*::)/,'binderad','@typconss'],
|
||||
[/[a-z][\w]+(?=\s*?[a-z]\w*)/,'bind','@typconss'],
|
||||
[/[a-z][\w]+(?=\s*?::\s*?@datatypekey)/,'bind','@binder'],
|
||||
[/[a-z][\w]+(?=\s*?=\s*?@datacons)/,'bindings'],
|
||||
[/{/,'oopen','@initialise'],
|
||||
[/[a-z]\w*/,'arguments13'],
|
||||
|
||||
[/\(/,'open_bracket'],
|
||||
[/=/,'Equalss','@datacons'],
|
||||
[/,/,'commaa'],
|
||||
[/::/,'colondouble','@datacons'],
|
||||
[/\)/,'closebrak','@initialise'],
|
||||
[/\)(?=\s* \t\r\n\bdata\b)/,'closed','@popall'],
|
||||
{include:'@whitespace'},
|
||||
{include:'@comment'}
|
||||
// {include:'@blockComment'}
|
||||
],
|
||||
bind: [
|
||||
[/@datatypekey/,'dtyp','@typconss'],
|
||||
[/[a-z][\w]*/,'typvar','@typconss'],
|
||||
[/\(/,'opens','@typcons'],
|
||||
{include:'@whitespace'},
|
||||
],
|
||||
types: [
|
||||
[/[a-z][\w]*/,'argument123'],
|
||||
[/,/,'commaa'],
|
||||
[/[A-Z][\w]*/,'classname'],
|
||||
[/\)/,'closex'],
|
||||
[/=>/,'pipe','@type'],
|
||||
{include:'@whitespace'},
|
||||
{include:'@comment'}
|
||||
],
|
||||
bind: [
|
||||
[/@datatypekey/,'dtyp','@typconss'],
|
||||
[/[a-z][\w]*/,'typvar','@typconss'],
|
||||
[/\(/,'opens','@typcons'],
|
||||
{include:'@whitespace'},
|
||||
],
|
||||
types: [
|
||||
[/[a-z][\w]*/,'argument123'],
|
||||
[/,/,'commaa'],
|
||||
[/[A-Z][\w]*/,'classname'],
|
||||
[/\)/,'closex'],
|
||||
[/=>/,'pipe','@type'],
|
||||
{include:'@whitespace'},
|
||||
{include:'@comment'}
|
||||
// {include:'@blockComment'}
|
||||
],
|
||||
datacons: [
|
||||
[/=/,'Equalst'],
|
||||
[/\bclass\b(?=\s*@classname)/,'keyword','@classname'],
|
||||
[/\bclass\b(?=\s*\()/,'keyword','@classname'],
|
||||
],
|
||||
datacons: [
|
||||
[/=/,'Equalst'],
|
||||
[/\bclass\b(?=\s*@classname)/,'keyword','@classname'],
|
||||
[/\bclass\b(?=\s*\()/,'keyword','@classname'],
|
||||
|
||||
[/\bundefined\b/,'val','@all'],
|
||||
[/\bnewtype\b(?=\s*@typcons)/,'keyword','@typcons'],
|
||||
[/\binstance\b/,'keyword','@classname'],
|
||||
[/[a-z][\w]*(?=\s*?->)/,'typvar','@typcons'],
|
||||
[/\bundefined\b/,'val','@all'],
|
||||
[/\bnewtype\b(?=\s*@typcons)/,'keyword','@typcons'],
|
||||
[/\binstance\b/,'keyword','@classname'],
|
||||
[/[a-z][\w]*(?=\s*?->)/,'typvar','@typcons'],
|
||||
|
||||
[/@reservedid(?=\s*\()/,'keyword','@typcons'],
|
||||
[/@datatypekey(?=\s*[a-z]\w*)/,'dtypess1','@typcons'],
|
||||
[/@datatypekey/,'dtypes1'],
|
||||
[/@reservedid(?=\s*[A-Z][\w]+)/,'keyword','@typcons'],
|
||||
[/@reservedid/,'keyword'],
|
||||
[/[A-Z][\w]+(?=\s*=>)/,'classname','@type'],
|
||||
[/[A-Z][\w]+(?=\s*[a-z][\w]*\s*=>)/,'classnames','@type'],
|
||||
[/[a-z][\w]+(?=\s*?::)/,'bindera','@typconss'],
|
||||
[/[a-z][\w]+(?=\s*?[a-z]\w*)/,'binde','@typconss'],
|
||||
[/@reservedid(?=\s*\()/,'keyword','@typcons'],
|
||||
[/@datatypekey(?=\s*[a-z]\w*)/,'dtypess1','@typcons'],
|
||||
[/@datatypekey/,'dtypes1'],
|
||||
[/@reservedid(?=\s*[A-Z][\w]+)/,'keyword','@typcons'],
|
||||
[/@reservedid/,'keyword'],
|
||||
[/[A-Z][\w]+(?=\s*=>)/,'classname','@type'],
|
||||
[/[A-Z][\w]+(?=\s*[a-z][\w]*\s*=>)/,'classnames','@type'],
|
||||
[/[a-z][\w]+(?=\s*?::)/,'bindera','@typconss'],
|
||||
[/[a-z][\w]+(?=\s*?[a-z]\w*)/,'binde','@typconss'],
|
||||
|
||||
[/[a-z][\w]+/,'binder','@typconss'],
|
||||
[/[a-z][\w]+/,'binder','@typconss'],
|
||||
|
||||
[/\bdata\b(?=@typcons)/,'keyword','@typcons'],
|
||||
[/\bdata\b(?=@typcons)/,'keyword','@typcons'],
|
||||
|
||||
[/@datacons/,'datacon'],
|
||||
[/@reservedid/,'keyword','@binder'],
|
||||
[/@datacons(?=\s*@datatypekey)/,'datacons'],
|
||||
[/@datacons/,'datacon'],
|
||||
[/@reservedid/,'keyword','@binder'],
|
||||
[/@datacons(?=\s*@datatypekey)/,'datacons'],
|
||||
|
||||
[/[a-z][\w]+(?=\s*?::\s*@datatype,)/,'bindera','@binder'],
|
||||
[/[a-z][\w]+(?=\s*?::\s*@datatype,)/,'bindera','@binder'],
|
||||
[/[a-z][\w]+(?=\s*?=\s*(\d)+,)/,'binderb','@binder'],
|
||||
[/[a-z][\w]+(?=\s*?=\s*(\d)+)/,'binderc','@binder'],
|
||||
[/[a-z][\w]+(?=\s*?=\s*"(\w)+.+?")/,'binderd','@binder'],
|
||||
[/[a-z][\w]+(?=\s*?=\s*"(\w)+.+?",)/,'bindere','@binder'],
|
||||
[/{/,'openbracketd','@initialise'],
|
||||
[/"\w+.+"/,'type'],
|
||||
[/\d+/,'type'],
|
||||
[/->/,'pip','@binder'],
|
||||
[/,/,'commas33','@initialise'],
|
||||
[/\|/,'alternate'],
|
||||
[/\(/,'open','@typcons'],
|
||||
[/}/,'clos','@initialise'],
|
||||
{include:'@whitespace'},
|
||||
{include:'@comment'}
|
||||
[/[a-z][\w]+(?=\s*?::\s*@datatype,)/,'bindera','@binder'],
|
||||
[/[a-z][\w]+(?=\s*?::\s*@datatype,)/,'bindera','@binder'],
|
||||
[/[a-z][\w]+(?=\s*?=\s*(\d)+,)/,'binderb','@binder'],
|
||||
[/[a-z][\w]+(?=\s*?=\s*(\d)+)/,'binderc','@binder'],
|
||||
[/[a-z][\w]+(?=\s*?=\s*"(\w)+.+?")/,'binderd','@binder'],
|
||||
[/[a-z][\w]+(?=\s*?=\s*"(\w)+.+?",)/,'bindere','@binder'],
|
||||
[/{/,'openbracketd','@initialise'],
|
||||
[/"\w+.+"/,'type'],
|
||||
[/\d+/,'type'],
|
||||
[/->/,'pip','@binder'],
|
||||
[/,/,'commas33','@initialise'],
|
||||
[/\|/,'alternate'],
|
||||
[/\(/,'open','@typcons'],
|
||||
[/}/,'clos','@initialise'],
|
||||
{include:'@whitespace'},
|
||||
{include:'@comment'}
|
||||
// {include:'@blockComment'}
|
||||
],
|
||||
type: [
|
||||
[/[a-z][\w]*/,'argument'],
|
||||
[/,/,'commas'],
|
||||
[/=>/,'pipe'],
|
||||
[/[A-Z][\w]*/,'typcons'],
|
||||
[/->/,'pipe','@binder'],
|
||||
{include:'@whitespace'},
|
||||
{include:'@comment'}
|
||||
],
|
||||
type: [
|
||||
[/[a-z][\w]*/,'argument'],
|
||||
[/,/,'commas'],
|
||||
[/=>/,'pipe'],
|
||||
[/[A-Z][\w]*/,'typcons'],
|
||||
[/->/,'pipe','@binder'],
|
||||
{include:'@whitespace'},
|
||||
{include:'@comment'}
|
||||
// {include:'@blockComment'}
|
||||
],
|
||||
all: [
|
||||
[/=/,'equals'],
|
||||
],
|
||||
all: [
|
||||
[/=/,'equals'],
|
||||
|
||||
[/\binstance\b/,'keyword','@classname'],
|
||||
[/\bclass\b(?=\s*@classname)/,'keyword','@classname'],
|
||||
[/\bclass\b(?=\s*\()/,'keyword','@classname'],
|
||||
[/\bdata\b(?=@typcons)/,'keyword','@typcons'],
|
||||
[/\binstance\b/,'keyword','@classname'],
|
||||
[/\bclass\b(?=\s*@classname)/,'keyword','@classname'],
|
||||
[/\bclass\b(?=\s*\()/,'keyword','@classname'],
|
||||
[/\bdata\b(?=@typcons)/,'keyword','@typcons'],
|
||||
|
||||
[/\bnewtype\b(?=\s*@typcons)/,'keyword'],
|
||||
[/@reservedid/,'keyword','@typconss'],
|
||||
[/[A-Z][\w]+/,'typecons','@typcons'],
|
||||
[/[a-z][\w]+(?=\s*=)/,'binderad','@typconss'],
|
||||
[/[a-z][\w]+(?=\s*::)/,'binderad','@typconss'],
|
||||
[/[a-z][\w]+(?=\s*?[a-z]\w*)/,'binder','@typconss'],
|
||||
{include:'@comment'}
|
||||
[/\bnewtype\b(?=\s*@typcons)/,'keyword'],
|
||||
[/@reservedid/,'keyword','@typconss'],
|
||||
[/[A-Z][\w]+/,'typecons','@typcons'],
|
||||
[/[a-z][\w]+(?=\s*=)/,'binderad','@typconss'],
|
||||
[/[a-z][\w]+(?=\s*::)/,'binderad','@typconss'],
|
||||
[/[a-z][\w]+(?=\s*?[a-z]\w*)/,'binder','@typconss'],
|
||||
{include:'@comment'}
|
||||
// {include:'@blockComment'}
|
||||
],
|
||||
selectors: [
|
||||
[/[a-z][\w]+/,'selectors'],
|
||||
[/=/,'Equalsto','@datacons'],
|
||||
[/"(\w)+.+"/,'type'],
|
||||
[/\d+/,'type'],
|
||||
[/}/,'closeS'],
|
||||
{include:'@comment'}
|
||||
],
|
||||
selectors: [
|
||||
[/[a-z][\w]+/,'selectors'],
|
||||
[/=/,'Equalsto','@datacons'],
|
||||
[/"(\w)+.+"/,'type'],
|
||||
[/\d+/,'type'],
|
||||
[/}/,'closeS'],
|
||||
{include:'@comment'}
|
||||
// {include:'@blockComment'}
|
||||
],
|
||||
initialise: [
|
||||
[/\binstance\b/,'keyword','@classname'],
|
||||
[/\bdata\b(?=\s*@typcons)/,'keyword','@typcons'],
|
||||
[/\bnewtype\b(?=\s*@typcons)/,'keyword','@typcons'],
|
||||
[/\bclass\b(?=\s*@classname)/,'keyword','@classname'],
|
||||
[/\bclass\b(?=\s*\()/,'keyword','@classname'],
|
||||
[/@datatypekey(?=\s*)/,'datatype'],
|
||||
[/{/,'open'],
|
||||
[/@reservedid/,'keyword'],
|
||||
[/\(/,'opn','@typcons'],
|
||||
[/\|/,'alternates','@datacons'],
|
||||
[/,/,'comma3'],
|
||||
],
|
||||
initialise: [
|
||||
[/\binstance\b/,'keyword','@classname'],
|
||||
[/\bdata\b(?=\s*@typcons)/,'keyword','@typcons'],
|
||||
[/\bnewtype\b(?=\s*@typcons)/,'keyword','@typcons'],
|
||||
[/\bclass\b(?=\s*@classname)/,'keyword','@classname'],
|
||||
[/\bclass\b(?=\s*\()/,'keyword','@classname'],
|
||||
[/@datatypekey(?=\s*)/,'datatype'],
|
||||
[/{/,'open'],
|
||||
[/@reservedid/,'keyword'],
|
||||
[/\(/,'opn','@typcons'],
|
||||
[/\|/,'alternates','@datacons'],
|
||||
[/,/,'comma3'],
|
||||
|
||||
[/[a-z][\w]+(?=\s*?=\s*?\b@reservedid\b)/,'binder','@all'],
|
||||
[/[a-z][\w]+(?=\s*?=\s*?\bundefined\b)/,'binder','@binder'],
|
||||
[/[a-z][\w]+(?=\s*?=\s*?@datacons)/,'bindings'],
|
||||
[/[a-z][\w]+(?=\s*?::\s*@datatypekey)/,'bindera','@binder'],
|
||||
[/[a-z][\w]+(?=\s*::)/,'binder','@binder'],
|
||||
[/[a-z][\w]+(?=\s*?=\s*?\b@reservedid\b)/,'binder','@all'],
|
||||
[/[a-z][\w]+(?=\s*?=\s*?\bundefined\b)/,'binder','@binder'],
|
||||
[/[a-z][\w]+(?=\s*?=\s*?@datacons)/,'bindings'],
|
||||
[/[a-z][\w]+(?=\s*?::\s*@datatypekey)/,'bindera','@binder'],
|
||||
[/[a-z][\w]+(?=\s*::)/,'binder','@binder'],
|
||||
|
||||
[/[a-z][\w]+(?=\s*?::\s*@datatypekey,)/,'binderb','@binder'],
|
||||
[/[a-z][\w]+(?=\s*?=\s*(\d)+,)/,'binderc','@binder'],
|
||||
[/[a-z][\w]+(?=\s*?=\s*(\d)+)/,'binderd','@binder'],
|
||||
[/[a-z][\w]+(?=\s*?=\s*"(\w)+.+?",)/,'binders','@binder'],
|
||||
[/[a-z][\w]+(?=\s*?=\s*"(\w)+.+?")/,'bindere','@binder'],
|
||||
[/[a-z][\w]+(?=\s*?::\s*@datatypekey,)/,'binderb','@binder'],
|
||||
[/[a-z][\w]+(?=\s*?=\s*(\d)+,)/,'binderc','@binder'],
|
||||
[/[a-z][\w]+(?=\s*?=\s*(\d)+)/,'binderd','@binder'],
|
||||
[/[a-z][\w]+(?=\s*?=\s*"(\w)+.+?",)/,'binders','@binder'],
|
||||
[/[a-z][\w]+(?=\s*?=\s*"(\w)+.+?")/,'bindere','@binder'],
|
||||
|
||||
[/[a-z][\w]+(?=\s*[a-z]\w*)/,'binder','@typconss'],
|
||||
[/::/,'doublecolons','@datacons'],
|
||||
[/=/,'Equalsto','@datacons'],
|
||||
{include:'@whitespace'},
|
||||
{include:'@comment'}
|
||||
[/[a-z][\w]+(?=\s*[a-z]\w*)/,'binder','@typconss'],
|
||||
[/::/,'doublecolons','@datacons'],
|
||||
[/=/,'Equalsto','@datacons'],
|
||||
{include:'@whitespace'},
|
||||
{include:'@comment'}
|
||||
// {include:'@blockComment'}
|
||||
],
|
||||
classname: [
|
||||
[/\binstance\b/,'keyword','@classname'],
|
||||
[/\bclass\b(?=\s*@classname)/,'keyword','@classname'],
|
||||
[/\bclass\b(?=\s*\()/,'keyword','@classname'],
|
||||
[/\bdata\b(?=\s*?@typcons)/,'keyword','@typcons'],
|
||||
[/\bnewtype\b(?=\s*@typcons)/,'keyword','@typcons'],
|
||||
[/[a-z][\w]+(?=\s*?=)/,'binderas','@binder'],
|
||||
[/[a-z][\w]+(?=\s*?::\s*?@datatypekey)/,'binderas','@binder'],
|
||||
[/@datatypekey/,'dtype'],
|
||||
[/[A-Z][\w]*/,'classname'],
|
||||
[/@reservedid/,'keyword','@typcons'],
|
||||
[/[a-z]\w*/,'arguments'],
|
||||
[/,/,'commas'],
|
||||
[/\(/, 'openbracket'],
|
||||
[/\)/,'closebracket'],
|
||||
[/=>/,'pipe','@superclass'],
|
||||
{include:'@whitespace'},
|
||||
{include:'@comment'}
|
||||
],
|
||||
classname: [
|
||||
[/\binstance\b/,'keyword','@classname'],
|
||||
[/\bclass\b(?=\s*@classname)/,'keyword','@classname'],
|
||||
[/\bclass\b(?=\s*\()/,'keyword','@classname'],
|
||||
[/\bdata\b(?=\s*?@typcons)/,'keyword','@typcons'],
|
||||
[/\bnewtype\b(?=\s*@typcons)/,'keyword','@typcons'],
|
||||
[/[a-z][\w]+(?=\s*?=)/,'binderas','@binder'],
|
||||
[/[a-z][\w]+(?=\s*?::\s*?@datatypekey)/,'binderas','@binder'],
|
||||
[/@datatypekey/,'dtype'],
|
||||
[/[A-Z][\w]*/,'classname'],
|
||||
[/@reservedid/,'keyword','@typcons'],
|
||||
[/[a-z]\w*/,'arguments'],
|
||||
[/,/,'commas'],
|
||||
[/\(/, 'openbracket'],
|
||||
[/\)/,'closebracket'],
|
||||
[/=>/,'pipe','@superclass'],
|
||||
{include:'@whitespace'},
|
||||
{include:'@comment'}
|
||||
// {include:'@blockComment'}
|
||||
],
|
||||
binder: [
|
||||
[/\binstance\b/,'keyword','@classname'],
|
||||
[/\bclass\b(?=\s*@classname)/,'keyword','@classname'],
|
||||
[/\bclass\b(?=\s*\()/,'keyword','@classname'],
|
||||
[/\bdata\b(?=\s*?@typcons)/,'keyword','@typcons'],
|
||||
[/@reservedid/,'keyword'],
|
||||
[/[a-z][\w]+(?=\s*::)/,'binder'],
|
||||
[/[a-z][\w]+(?=\s*=)/,'binder'],
|
||||
[/::/,'doublecolons','@datacons'],
|
||||
[/@datatypekey(?=\s*[a-z]\w*)/,'dtypes','@typcons'],
|
||||
[/@datatypekey/,'dtypess'],
|
||||
[/\bnewtype\b(?=\s*@typcons)/,'keyword','@typcons'],
|
||||
[/->/,'pipe'],
|
||||
[/\d+/,'digit'],
|
||||
[/{/,'open'],
|
||||
[/=/,'Equalsto','@datacons'],
|
||||
],
|
||||
binder: [
|
||||
[/\binstance\b/,'keyword','@classname'],
|
||||
[/\bclass\b(?=\s*@classname)/,'keyword','@classname'],
|
||||
[/\bclass\b(?=\s*\()/,'keyword','@classname'],
|
||||
[/\bdata\b(?=\s*?@typcons)/,'keyword','@typcons'],
|
||||
[/@reservedid/,'keyword'],
|
||||
[/[a-z][\w]+(?=\s*::)/,'binder'],
|
||||
[/[a-z][\w]+(?=\s*=)/,'binder'],
|
||||
[/::/,'doublecolons','@datacons'],
|
||||
[/@datatypekey(?=\s*[a-z]\w*)/,'dtypes','@typcons'],
|
||||
[/@datatypekey/,'dtypess'],
|
||||
[/\bnewtype\b(?=\s*@typcons)/,'keyword','@typcons'],
|
||||
[/->/,'pipe'],
|
||||
[/\d+/,'digit'],
|
||||
[/{/,'open'],
|
||||
[/=/,'Equalsto','@datacons'],
|
||||
|
||||
[/\(/,'opn','@typcons'],
|
||||
[/\|/,'alternates','@datacons'],
|
||||
[/,/,'comma3'],
|
||||
[/\(/,'opn','@typcons'],
|
||||
[/\|/,'alternates','@datacons'],
|
||||
[/,/,'comma3'],
|
||||
|
||||
[/[a-z][\w]*/,'typvar','@typconss'],
|
||||
[/\bclass\b(?=\s*@classname)/,'keyword','@classname'],
|
||||
[/\bclass\b(?=\s*\()/,'keyword','@classname'],
|
||||
[/\binstance\b/,'keyword','@classname'],
|
||||
[/\bundefined\b/,'value'],
|
||||
{include:'@whitespace'},
|
||||
{include:'@comment'}
|
||||
[/[a-z][\w]*/,'typvar','@typconss'],
|
||||
[/\bclass\b(?=\s*@classname)/,'keyword','@classname'],
|
||||
[/\bclass\b(?=\s*\()/,'keyword','@classname'],
|
||||
[/\binstance\b/,'keyword','@classname'],
|
||||
[/\bundefined\b/,'value'],
|
||||
{include:'@whitespace'},
|
||||
{include:'@comment'}
|
||||
// {include:'@blockComment'}
|
||||
],
|
||||
superclass: [
|
||||
[/[A-Z][\w]+/,'typeclass'],
|
||||
[/@reservedid/,'keyword','@typcons'],
|
||||
[/[a-z][\w]*/,'typearguments'],
|
||||
{include:'@whitespace'},
|
||||
{include:'@comment'}
|
||||
//{include:'@blockComment'}
|
||||
],
|
||||
argument: [
|
||||
[/[a-z][\w]*(?=\s*->)/,'argument'],
|
||||
[/->/,'pipea','@binder'],
|
||||
{include:'@whitespace'},
|
||||
{include:'@comment'}
|
||||
],
|
||||
superclass: [
|
||||
[/[A-Z][\w]+/,'typeclass'],
|
||||
[/@reservedid/,'keyword','@typcons'],
|
||||
[/[a-z][\w]*/,'typearguments'],
|
||||
{include:'@whitespace'},
|
||||
{include:'@comment'}
|
||||
//{include:'@blockComment'}
|
||||
],
|
||||
argument: [
|
||||
[/[a-z][\w]*(?=\s*->)/,'argument'],
|
||||
[/->/,'pipea','@binder'],
|
||||
{include:'@whitespace'},
|
||||
{include:'@comment'}
|
||||
// {include:'@blockComment'}
|
||||
],
|
||||
datatype: [
|
||||
[/\(/,'openbracketd','@pop'],
|
||||
{include:'@comment'}
|
||||
//{include:'@blockComment'}
|
||||
],
|
||||
module_exports: [
|
||||
[/(@module_exports)/,'storage.module.haskell'],
|
||||
[/\(/,'openbracket','@target'],
|
||||
[/\)/,'closebracket','@popall'],
|
||||
[/,/,'comma1'],
|
||||
[/@invalid/,'invalid'],
|
||||
{include:'@whitespace'},
|
||||
{include:'@comment'}
|
||||
],
|
||||
datatype: [
|
||||
[/\(/,'openbracketd','@pop'],
|
||||
{include:'@comment'}
|
||||
//{include:'@blockComment'}
|
||||
],
|
||||
module_exports: [
|
||||
[/(@module_exports)/,'storage.module.haskell'],
|
||||
[/\(/,'openbracket','@target'],
|
||||
[/\)/,'closebracket','@popall'],
|
||||
[/,/,'comma1'],
|
||||
[/@invalid/,'invalid'],
|
||||
{include:'@whitespace'},
|
||||
{include:'@comment'}
|
||||
// {include:'@blockcomment'}
|
||||
],
|
||||
target: [
|
||||
[/(@target)/,'target'],
|
||||
[/,/,'comma2'],
|
||||
[/\)/,'closebracket','@pop'],
|
||||
{include:'@comment'}
|
||||
],
|
||||
target: [
|
||||
[/(@target)/,'target'],
|
||||
[/,/,'comma2'],
|
||||
[/\)/,'closebracket','@pop'],
|
||||
{include:'@comment'}
|
||||
// {include:'@blockComment'}
|
||||
],
|
||||
whitespace: [
|
||||
[/\t\r\n/,'whitespace'],
|
||||
[/\s*/,'whitespace']
|
||||
],
|
||||
whitespace: [
|
||||
[/\t\r\n/,'whitespace'],
|
||||
[/\s*/,'whitespace']
|
||||
|
||||
],
|
||||
comment: [
|
||||
[/--/,'punctuation.comment.haskell'],
|
||||
{include:'@whitespace'},
|
||||
],
|
||||
Block_comment: [
|
||||
[/{-/,'punctuation.comment.haskell'],
|
||||
[/-}/,'comment.block.haskell'],
|
||||
{include:'@whitespace'}
|
||||
],
|
||||
}
|
||||
};
|
||||
}
|
||||
],
|
||||
comment: [
|
||||
[/--/,'punctuation.comment.haskell'],
|
||||
{include:'@whitespace'},
|
||||
],
|
||||
Block_comment: [
|
||||
[/{-/,'punctuation.comment.haskell'],
|
||||
[/-}/,'comment.block.haskell'],
|
||||
{include:'@whitespace'}
|
||||
],
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
monaco.languages.register({id: 'haskell'});
|
||||
// TODO: Currently not working. Here as a reminder
|
||||
/*monaco.languages.setMonarchTokensProvider('haskell', definition());*/
|
||||
});
|
||||
monaco.languages.register({id: 'haskell'});
|
||||
// TODO: Currently not working. Here as a reminder
|
||||
/*monaco.languages.setMonarchTokensProvider('haskell', definition());*/
|
||||
+203
-204
@@ -23,224 +23,223 @@
|
||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
define(function (require) {
|
||||
'use strict';
|
||||
|
||||
var _ = require('underscore');
|
||||
var Raven = require('raven-js');
|
||||
var editor = require('editor');
|
||||
var compiler = require('compiler');
|
||||
var output = require('output');
|
||||
var Components = require('components');
|
||||
var diff = require('diff');
|
||||
var optView = require('opt-view');
|
||||
var astView = require('ast-view');
|
||||
var gccDumpView = require('gccdump-view');
|
||||
var cfgView = require('cfg-view');
|
||||
var conformanceView = require('conformance-view');
|
||||
var CompilerService = require('compiler-service');
|
||||
'use strict';
|
||||
|
||||
function Ids() {
|
||||
this.used = {};
|
||||
}
|
||||
var _ = require('underscore');
|
||||
var Raven = require('raven-js');
|
||||
var editor = require('editor');
|
||||
var compiler = require('compiler');
|
||||
var output = require('output');
|
||||
var Components = require('components');
|
||||
var diff = require('diff');
|
||||
var optView = require('opt-view');
|
||||
var astView = require('ast-view');
|
||||
var gccDumpView = require('gccdump-view');
|
||||
var cfgView = require('cfg-view');
|
||||
var conformanceView = require('conformance-view');
|
||||
var CompilerService = require('compiler-service');
|
||||
|
||||
Ids.prototype.add = function (id) {
|
||||
this.used[id] = true;
|
||||
};
|
||||
Ids.prototype.remove = function (id) {
|
||||
delete this.used[id];
|
||||
};
|
||||
Ids.prototype.next = function () {
|
||||
for (var i = 1; i < 100000; ++i) {
|
||||
if (!this.used[i]) {
|
||||
this.used[i] = true;
|
||||
return i;
|
||||
}
|
||||
function Ids() {
|
||||
this.used = {};
|
||||
}
|
||||
|
||||
Ids.prototype.add = function (id) {
|
||||
this.used[id] = true;
|
||||
};
|
||||
Ids.prototype.remove = function (id) {
|
||||
delete this.used[id];
|
||||
};
|
||||
Ids.prototype.next = function () {
|
||||
for (var i = 1; i < 100000; ++i) {
|
||||
if (!this.used[i]) {
|
||||
this.used[i] = true;
|
||||
return i;
|
||||
}
|
||||
throw 'Ran out of ids!?';
|
||||
};
|
||||
|
||||
function Hub(layout, subLangId) {
|
||||
this.layout = layout;
|
||||
this.editorIds = new Ids();
|
||||
this.compilerIds = new Ids();
|
||||
this.compilerService = new CompilerService();
|
||||
this.deferred = true;
|
||||
this.deferredEmissions = [];
|
||||
this.lastOpenedLangId = null;
|
||||
this.subdomainLangId = subLangId || null;
|
||||
|
||||
// FIXME
|
||||
// We can't avoid this self as _ is undefined at this point
|
||||
var self = this;
|
||||
|
||||
layout.registerComponent(Components.getEditor().componentName,
|
||||
function (container, state) {
|
||||
return self.codeEditorFactory(container, state);
|
||||
});
|
||||
layout.registerComponent(Components.getCompiler().componentName,
|
||||
function (container, state) {
|
||||
return self.compilerFactory(container, state);
|
||||
});
|
||||
layout.registerComponent(Components.getOutput().componentName,
|
||||
function (container, state) {
|
||||
return self.outputFactory(container, state);
|
||||
});
|
||||
layout.registerComponent(diff.getComponent().componentName,
|
||||
function (container, state) {
|
||||
return self.diffFactory(container, state);
|
||||
});
|
||||
layout.registerComponent(Components.getOptView().componentName,
|
||||
function (container, state) {
|
||||
return self.optViewFactory(container, state);
|
||||
});
|
||||
layout.registerComponent(Components.getAstView().componentName,
|
||||
function (container, state) {
|
||||
return self.astViewFactory(container, state);
|
||||
});
|
||||
layout.registerComponent(Components.getGccDumpView().componentName,
|
||||
function (container, state) {
|
||||
return self.gccDumpViewFactory(container, state);
|
||||
});
|
||||
layout.registerComponent(Components.getCfgView().componentName,
|
||||
function (container, state) {
|
||||
return self.cfgViewFactory(container, state);
|
||||
});
|
||||
layout.registerComponent(Components.getConformanceView().componentName,
|
||||
function (container, state) {
|
||||
return self.confomanceFactory(container, state);
|
||||
});
|
||||
|
||||
layout.eventHub.on('editorOpen', function (id) {
|
||||
this.editorIds.add(id);
|
||||
}, this);
|
||||
layout.eventHub.on('editorClose', function (id) {
|
||||
this.editorIds.remove(id);
|
||||
}, this);
|
||||
layout.eventHub.on('compilerOpen', function (id) {
|
||||
this.compilerIds.add(id);
|
||||
}, this);
|
||||
layout.eventHub.on('compilerClose', function (id) {
|
||||
this.compilerIds.remove(id);
|
||||
}, this);
|
||||
layout.eventHub.on('languageChange', function (editorId, langId) {
|
||||
this.lastOpenedLangId = langId;
|
||||
}, this);
|
||||
layout.init();
|
||||
this.undefer();
|
||||
layout.eventHub.emit('initialised');
|
||||
}
|
||||
throw 'Ran out of ids!?';
|
||||
};
|
||||
|
||||
Hub.prototype.undefer = function () {
|
||||
this.deferred = false;
|
||||
var eventHub = this.layout.eventHub;
|
||||
_.each(this.deferredEmissions, function (args) {
|
||||
eventHub.emit.apply(eventHub, args);
|
||||
function Hub(layout, subLangId) {
|
||||
this.layout = layout;
|
||||
this.editorIds = new Ids();
|
||||
this.compilerIds = new Ids();
|
||||
this.compilerService = new CompilerService();
|
||||
this.deferred = true;
|
||||
this.deferredEmissions = [];
|
||||
this.lastOpenedLangId = null;
|
||||
this.subdomainLangId = subLangId || null;
|
||||
|
||||
// FIXME
|
||||
// We can't avoid this self as _ is undefined at this point
|
||||
var self = this;
|
||||
|
||||
layout.registerComponent(Components.getEditor().componentName,
|
||||
function (container, state) {
|
||||
return self.codeEditorFactory(container, state);
|
||||
});
|
||||
layout.registerComponent(Components.getCompiler().componentName,
|
||||
function (container, state) {
|
||||
return self.compilerFactory(container, state);
|
||||
});
|
||||
layout.registerComponent(Components.getOutput().componentName,
|
||||
function (container, state) {
|
||||
return self.outputFactory(container, state);
|
||||
});
|
||||
layout.registerComponent(diff.getComponent().componentName,
|
||||
function (container, state) {
|
||||
return self.diffFactory(container, state);
|
||||
});
|
||||
layout.registerComponent(Components.getOptView().componentName,
|
||||
function (container, state) {
|
||||
return self.optViewFactory(container, state);
|
||||
});
|
||||
layout.registerComponent(Components.getAstView().componentName,
|
||||
function (container, state) {
|
||||
return self.astViewFactory(container, state);
|
||||
});
|
||||
layout.registerComponent(Components.getGccDumpView().componentName,
|
||||
function (container, state) {
|
||||
return self.gccDumpViewFactory(container, state);
|
||||
});
|
||||
layout.registerComponent(Components.getCfgView().componentName,
|
||||
function (container, state) {
|
||||
return self.cfgViewFactory(container, state);
|
||||
});
|
||||
layout.registerComponent(Components.getConformanceView().componentName,
|
||||
function (container, state) {
|
||||
return self.confomanceFactory(container, state);
|
||||
});
|
||||
this.deferredEmissions = [];
|
||||
};
|
||||
|
||||
Hub.prototype.nextEditorId = function () {
|
||||
return this.editorIds.next();
|
||||
};
|
||||
Hub.prototype.nextCompilerId = function () {
|
||||
return this.compilerIds.next();
|
||||
};
|
||||
layout.eventHub.on('editorOpen', function (id) {
|
||||
this.editorIds.add(id);
|
||||
}, this);
|
||||
layout.eventHub.on('editorClose', function (id) {
|
||||
this.editorIds.remove(id);
|
||||
}, this);
|
||||
layout.eventHub.on('compilerOpen', function (id) {
|
||||
this.compilerIds.add(id);
|
||||
}, this);
|
||||
layout.eventHub.on('compilerClose', function (id) {
|
||||
this.compilerIds.remove(id);
|
||||
}, this);
|
||||
layout.eventHub.on('languageChange', function (editorId, langId) {
|
||||
this.lastOpenedLangId = langId;
|
||||
}, this);
|
||||
layout.init();
|
||||
this.undefer();
|
||||
layout.eventHub.emit('initialised');
|
||||
}
|
||||
|
||||
Hub.prototype.codeEditorFactory = function (container, state) {
|
||||
// Ensure editors are closable: some older versions had 'isClosable' false.
|
||||
// NB there doesn't seem to be a better way to do this than reach into the config and rely on the fact nothing
|
||||
// has used it yet.
|
||||
container.parent.config.isClosable = true;
|
||||
return new editor.Editor(this, state, container);
|
||||
};
|
||||
Hub.prototype.undefer = function () {
|
||||
this.deferred = false;
|
||||
var eventHub = this.layout.eventHub;
|
||||
_.each(this.deferredEmissions, function (args) {
|
||||
eventHub.emit.apply(eventHub, args);
|
||||
});
|
||||
this.deferredEmissions = [];
|
||||
};
|
||||
|
||||
Hub.prototype.compilerFactory = function (container, state) {
|
||||
return new compiler.Compiler(this, container, state);
|
||||
};
|
||||
Hub.prototype.nextEditorId = function () {
|
||||
return this.editorIds.next();
|
||||
};
|
||||
Hub.prototype.nextCompilerId = function () {
|
||||
return this.compilerIds.next();
|
||||
};
|
||||
|
||||
Hub.prototype.outputFactory = function (container, state) {
|
||||
return new output.Output(this, container, state);
|
||||
};
|
||||
Hub.prototype.diffFactory = function (container, state) {
|
||||
return new diff.Diff(this, container, state);
|
||||
};
|
||||
Hub.prototype.optViewFactory = function (container, state) {
|
||||
return new optView.Opt(this, container, state);
|
||||
};
|
||||
Hub.prototype.astViewFactory = function (container, state) {
|
||||
return new astView.Ast(this, container, state);
|
||||
};
|
||||
Hub.prototype.gccDumpViewFactory = function (container, state) {
|
||||
return new gccDumpView.GccDump(this, container, state);
|
||||
};
|
||||
Hub.prototype.cfgViewFactory = function (container, state) {
|
||||
return new cfgView.Cfg(this, container, state);
|
||||
};
|
||||
Hub.prototype.confomanceFactory = function (container, state) {
|
||||
return new conformanceView.Conformance(this, container, state);
|
||||
};
|
||||
Hub.prototype.codeEditorFactory = function (container, state) {
|
||||
// Ensure editors are closable: some older versions had 'isClosable' false.
|
||||
// NB there doesn't seem to be a better way to do this than reach into the config and rely on the fact nothing
|
||||
// has used it yet.
|
||||
container.parent.config.isClosable = true;
|
||||
return new editor.Editor(this, state, container);
|
||||
};
|
||||
|
||||
function WrappedEventHub(hub, eventHub) {
|
||||
this.hub = hub;
|
||||
this.eventHub = eventHub;
|
||||
this.subscriptions = [];
|
||||
Hub.prototype.compilerFactory = function (container, state) {
|
||||
return new compiler.Compiler(this, container, state);
|
||||
};
|
||||
|
||||
Hub.prototype.outputFactory = function (container, state) {
|
||||
return new output.Output(this, container, state);
|
||||
};
|
||||
Hub.prototype.diffFactory = function (container, state) {
|
||||
return new diff.Diff(this, container, state);
|
||||
};
|
||||
Hub.prototype.optViewFactory = function (container, state) {
|
||||
return new optView.Opt(this, container, state);
|
||||
};
|
||||
Hub.prototype.astViewFactory = function (container, state) {
|
||||
return new astView.Ast(this, container, state);
|
||||
};
|
||||
Hub.prototype.gccDumpViewFactory = function (container, state) {
|
||||
return new gccDumpView.GccDump(this, container, state);
|
||||
};
|
||||
Hub.prototype.cfgViewFactory = function (container, state) {
|
||||
return new cfgView.Cfg(this, container, state);
|
||||
};
|
||||
Hub.prototype.confomanceFactory = function (container, state) {
|
||||
return new conformanceView.Conformance(this, container, state);
|
||||
};
|
||||
|
||||
function WrappedEventHub(hub, eventHub) {
|
||||
this.hub = hub;
|
||||
this.eventHub = eventHub;
|
||||
this.subscriptions = [];
|
||||
}
|
||||
|
||||
WrappedEventHub.prototype.emit = function () {
|
||||
// Events are deferred during initialisation to allow all the components to install their listeners before
|
||||
// all the emits are done. This fixes some ordering issues.
|
||||
if (this.hub.deferred) {
|
||||
this.hub.deferredEmissions.push(arguments);
|
||||
} else {
|
||||
this.eventHub.emit.apply(this.eventHub, arguments);
|
||||
}
|
||||
};
|
||||
WrappedEventHub.prototype.on = function (event, callback, context) {
|
||||
this.eventHub.on(event, callback, context);
|
||||
this.subscriptions.push({evt: event, fn: callback, ctx: context});
|
||||
};
|
||||
WrappedEventHub.prototype.unsubscribe = function () {
|
||||
_.each(this.subscriptions, _.bind(function (obj) {
|
||||
try {
|
||||
this.eventHub.off(obj.evt, obj.fn, obj.ctx);
|
||||
} catch (e) {
|
||||
Raven.captureMessage('Can not unsubscribe from ' + obj.evt.toString() + ' :"' + e.msg + '"');
|
||||
}
|
||||
}, this));
|
||||
this.subscriptions = [];
|
||||
};
|
||||
|
||||
WrappedEventHub.prototype.emit = function () {
|
||||
// Events are deferred during initialisation to allow all the components to install their listeners before
|
||||
// all the emits are done. This fixes some ordering issues.
|
||||
if (this.hub.deferred) {
|
||||
this.hub.deferredEmissions.push(arguments);
|
||||
Hub.prototype.createEventHub = function () {
|
||||
return new WrappedEventHub(this, this.layout.eventHub);
|
||||
};
|
||||
|
||||
Hub.prototype.findParentRowOrColumn = function (elem) {
|
||||
while (elem) {
|
||||
if (elem.isRow || elem.isColumn) return elem;
|
||||
elem = elem.parent;
|
||||
}
|
||||
return elem;
|
||||
};
|
||||
|
||||
Hub.prototype.addAtRoot = function (newElem) {
|
||||
var rootFirstItem = this.layout.root.contentItems[0];
|
||||
if (rootFirstItem) {
|
||||
if (rootFirstItem.isRow || rootFirstItem.isColumn) {
|
||||
rootFirstItem.addChild(newElem);
|
||||
} else {
|
||||
this.eventHub.emit.apply(this.eventHub, arguments);
|
||||
var newRow = this.layout.createContentItem({type: 'row'}, this.layout.root);
|
||||
this.layout.root.replaceChild(rootFirstItem, newRow);
|
||||
newRow.addChild(rootFirstItem);
|
||||
newRow.addChild(newElem);
|
||||
}
|
||||
};
|
||||
WrappedEventHub.prototype.on = function (event, callback, context) {
|
||||
this.eventHub.on(event, callback, context);
|
||||
this.subscriptions.push({evt: event, fn: callback, ctx: context});
|
||||
};
|
||||
WrappedEventHub.prototype.unsubscribe = function () {
|
||||
_.each(this.subscriptions, _.bind(function (obj) {
|
||||
try {
|
||||
this.eventHub.off(obj.evt, obj.fn, obj.ctx);
|
||||
} catch (e) {
|
||||
Raven.captureMessage('Can not unsubscribe from ' + obj.evt.toString() + ' :"' + e.msg + '"');
|
||||
}
|
||||
}, this));
|
||||
this.subscriptions = [];
|
||||
};
|
||||
} else {
|
||||
this.layout.root.addChild({
|
||||
type: 'row',
|
||||
content: [newElem]
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Hub.prototype.createEventHub = function () {
|
||||
return new WrappedEventHub(this, this.layout.eventHub);
|
||||
};
|
||||
|
||||
Hub.prototype.findParentRowOrColumn = function (elem) {
|
||||
while (elem) {
|
||||
if (elem.isRow || elem.isColumn) return elem;
|
||||
elem = elem.parent;
|
||||
}
|
||||
return elem;
|
||||
};
|
||||
|
||||
Hub.prototype.addAtRoot = function (newElem) {
|
||||
var rootFirstItem = this.layout.root.contentItems[0];
|
||||
if (rootFirstItem) {
|
||||
if (rootFirstItem.isRow || rootFirstItem.isColumn) {
|
||||
rootFirstItem.addChild(newElem);
|
||||
} else {
|
||||
var newRow = this.layout.createContentItem({type: 'row'}, this.layout.root);
|
||||
this.layout.root.replaceChild(rootFirstItem, newRow);
|
||||
newRow.addChild(rootFirstItem);
|
||||
newRow.addChild(newElem);
|
||||
}
|
||||
} else {
|
||||
this.layout.root.addChild({
|
||||
type: 'row',
|
||||
content: [newElem]
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
return Hub;
|
||||
});
|
||||
module.exports = Hub;
|
||||
|
||||
+53
-55
@@ -1,60 +1,58 @@
|
||||
define(function (require) {
|
||||
'use strict';
|
||||
var jquery = require('jquery');
|
||||
var monaco = require('monaco');
|
||||
var cpp = require('vs/basic-languages/src/cpp');
|
||||
'use strict';
|
||||
|
||||
function definition() {
|
||||
var ispc = jquery.extend(true, {}, cpp.language); // deep copy
|
||||
var jquery = require('jquery');
|
||||
var cpp = require('vs/basic-languages/src/cpp');
|
||||
|
||||
ispc.tokenPostfix = '.ispc';
|
||||
function definition() {
|
||||
var ispc = jquery.extend(true, {}, cpp.language); // deep copy
|
||||
|
||||
ispc.keywords.push(
|
||||
'cbreak',
|
||||
'ccontinue',
|
||||
'cdo',
|
||||
'cfor',
|
||||
'cif',
|
||||
'creturn',
|
||||
'cwhile',
|
||||
'delete',
|
||||
'export',
|
||||
'foreach',
|
||||
'foreach_active',
|
||||
'foreach_tiled',
|
||||
'foreach_unique',
|
||||
'int16',
|
||||
'int32',
|
||||
'int64',
|
||||
'int8',
|
||||
'launch',
|
||||
'new',
|
||||
'operator',
|
||||
'programCount',
|
||||
'programIndex',
|
||||
'reference',
|
||||
'soa',
|
||||
'sync',
|
||||
'task',
|
||||
'taskCount',
|
||||
'taskCount0',
|
||||
'taskCount1',
|
||||
'taskCount2',
|
||||
'taskIndex',
|
||||
'taskIndex0',
|
||||
'taskIndex1',
|
||||
'taskIndex2',
|
||||
'threadCount',
|
||||
'threadIndex',
|
||||
'uniform',
|
||||
'unmasked',
|
||||
'varying'
|
||||
);
|
||||
ispc.tokenPostfix = '.ispc';
|
||||
|
||||
return ispc;
|
||||
}
|
||||
ispc.keywords.push(
|
||||
'cbreak',
|
||||
'ccontinue',
|
||||
'cdo',
|
||||
'cfor',
|
||||
'cif',
|
||||
'creturn',
|
||||
'cwhile',
|
||||
'delete',
|
||||
'export',
|
||||
'foreach',
|
||||
'foreach_active',
|
||||
'foreach_tiled',
|
||||
'foreach_unique',
|
||||
'int16',
|
||||
'int32',
|
||||
'int64',
|
||||
'int8',
|
||||
'launch',
|
||||
'new',
|
||||
'operator',
|
||||
'programCount',
|
||||
'programIndex',
|
||||
'reference',
|
||||
'soa',
|
||||
'sync',
|
||||
'task',
|
||||
'taskCount',
|
||||
'taskCount0',
|
||||
'taskCount1',
|
||||
'taskCount2',
|
||||
'taskIndex',
|
||||
'taskIndex0',
|
||||
'taskIndex1',
|
||||
'taskIndex2',
|
||||
'threadCount',
|
||||
'threadIndex',
|
||||
'uniform',
|
||||
'unmasked',
|
||||
'varying'
|
||||
);
|
||||
return ispc;
|
||||
}
|
||||
|
||||
monaco.languages.register({id: 'ispc'});
|
||||
monaco.languages.setLanguageConfiguration('ispc', cpp.conf);
|
||||
monaco.languages.setMonarchTokensProvider('ispc', definition());
|
||||
|
||||
monaco.languages.register({id: 'ispc'});
|
||||
monaco.languages.setLanguageConfiguration('ispc', cpp.conf);
|
||||
monaco.languages.setMonarchTokensProvider('ispc', definition());
|
||||
});
|
||||
|
||||
+147
-148
@@ -23,165 +23,164 @@
|
||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
define(function (require) {
|
||||
"use strict";
|
||||
var $ = require('jquery');
|
||||
var _ = require('underscore');
|
||||
var saveAs = require('filesaver');
|
||||
var Alert = require('./alert');
|
||||
var local = require('./local');
|
||||
var Promise = require('es6-promise').Promise;
|
||||
"use strict";
|
||||
var $ = require('jquery');
|
||||
var _ = require('underscore');
|
||||
var saveAs = require('filesaver');
|
||||
var Alert = require('./alert');
|
||||
var local = require('./local');
|
||||
var Promise = require('es6-promise').Promise;
|
||||
|
||||
function getLocalFiles() {
|
||||
return JSON.parse(local.get('files', "{}"));
|
||||
}
|
||||
function getLocalFiles() {
|
||||
return JSON.parse(local.get('files', "{}"));
|
||||
}
|
||||
|
||||
function setLocalFile(name, file) {
|
||||
var files = getLocalFiles();
|
||||
files[name] = file;
|
||||
local.set('files', JSON.stringify(files));
|
||||
}
|
||||
function setLocalFile(name, file) {
|
||||
var files = getLocalFiles();
|
||||
files[name] = file;
|
||||
local.set('files', JSON.stringify(files));
|
||||
}
|
||||
|
||||
function LoadSave() {
|
||||
this.modal = $('#load-save');
|
||||
this.alert = new Alert();
|
||||
this.onLoad = _.identity;
|
||||
this.editorText = '';
|
||||
this.extension = '.txt';
|
||||
this.modal.find('.local-file').change(_.bind(this.onLocalFile, this));
|
||||
function LoadSave() {
|
||||
this.modal = $('#load-save');
|
||||
this.alert = new Alert();
|
||||
this.onLoad = _.identity;
|
||||
this.editorText = '';
|
||||
this.extension = '.txt';
|
||||
this.modal.find('.local-file').change(_.bind(this.onLocalFile, this));
|
||||
|
||||
this.modal.find('.save-button').click(_.bind(this.onSaveToBrowserStorage, this));
|
||||
this.modal.find('.save-file').click(_.bind(this.onSaveToFile, this));
|
||||
this.modal.find('.save-button').click(_.bind(this.onSaveToBrowserStorage, this));
|
||||
this.modal.find('.save-file').click(_.bind(this.onSaveToFile, this));
|
||||
|
||||
this.fetchBuiltins();
|
||||
}
|
||||
this.fetchBuiltins();
|
||||
}
|
||||
|
||||
LoadSave.prototype.fetchBuiltins = function () {
|
||||
return new Promise(_.bind(function (resolve, reject) {
|
||||
$.getJSON('source/builtin/list', function (list) {
|
||||
resolve(list);
|
||||
});
|
||||
LoadSave.prototype.fetchBuiltins = function () {
|
||||
return new Promise(_.bind(function (resolve, reject) {
|
||||
$.getJSON('source/builtin/list', function (list) {
|
||||
resolve(list);
|
||||
});
|
||||
}, this));
|
||||
};
|
||||
|
||||
LoadSave.prototype.populateBuiltins = function () {
|
||||
var isVisible = _.bind(function (entry) {
|
||||
return this.currentLanguage && this.currentLanguage.id === entry.lang;
|
||||
}, this);
|
||||
return this.fetchBuiltins()
|
||||
.then(_.bind(function (builtins) {
|
||||
this.populate(this.modal.find('.examples'),
|
||||
_.map(_.filter(builtins, isVisible), _.bind(function (elem) {
|
||||
return {
|
||||
name: elem.name,
|
||||
load: _.bind(function () {
|
||||
this.doLoad(elem);
|
||||
}, this)
|
||||
};
|
||||
}, this))
|
||||
);
|
||||
}, this));
|
||||
};
|
||||
};
|
||||
|
||||
LoadSave.prototype.populateBuiltins = function () {
|
||||
var isVisible = _.bind(function (entry) {
|
||||
return this.currentLanguage && this.currentLanguage.id === entry.lang;
|
||||
}, this);
|
||||
return this.fetchBuiltins()
|
||||
.then(_.bind(function (builtins) {
|
||||
this.populate(this.modal.find('.examples'),
|
||||
_.map(_.filter(builtins, isVisible), _.bind(function (elem) {
|
||||
return {
|
||||
name: elem.name,
|
||||
load: _.bind(function () {
|
||||
this.doLoad(elem);
|
||||
}, this)
|
||||
};
|
||||
}, this))
|
||||
);
|
||||
}, this));
|
||||
};
|
||||
LoadSave.prototype.populateLocalStorage = function () {
|
||||
this.populate(
|
||||
this.modal.find('.local-storage'),
|
||||
_.map(getLocalFiles(), _.bind(function (data, name) {
|
||||
return {
|
||||
name: name,
|
||||
load: _.bind(function () {
|
||||
this.onLoad(data);
|
||||
this.modal.modal('hide');
|
||||
}, this)
|
||||
};
|
||||
}, this)));
|
||||
};
|
||||
|
||||
LoadSave.prototype.populateLocalStorage = function () {
|
||||
this.populate(
|
||||
this.modal.find('.local-storage'),
|
||||
_.map(getLocalFiles(), _.bind(function (data, name) {
|
||||
return {
|
||||
name: name,
|
||||
load: _.bind(function () {
|
||||
this.onLoad(data);
|
||||
this.modal.modal('hide');
|
||||
}, this)
|
||||
};
|
||||
}, this)));
|
||||
};
|
||||
LoadSave.prototype.populate = function (root, list) {
|
||||
root.find('li:not(.template)').remove();
|
||||
var template = root.find('.template');
|
||||
_.each(list, _.bind(function (elem) {
|
||||
template
|
||||
.clone()
|
||||
.removeClass('template')
|
||||
.appendTo(root)
|
||||
.find('a')
|
||||
.text(elem.name)
|
||||
.click(elem.load);
|
||||
}, this));
|
||||
};
|
||||
|
||||
LoadSave.prototype.populate = function (root, list) {
|
||||
root.find('li:not(.template)').remove();
|
||||
var template = root.find('.template');
|
||||
_.each(list, _.bind(function (elem) {
|
||||
template
|
||||
.clone()
|
||||
.removeClass('template')
|
||||
.appendTo(root)
|
||||
.find('a')
|
||||
.text(elem.name)
|
||||
.click(elem.load);
|
||||
}, this));
|
||||
};
|
||||
LoadSave.prototype.onLocalFile = function (event) {
|
||||
var files = event.target.files;
|
||||
var file = files[0];
|
||||
var reader = new FileReader();
|
||||
reader.onload = _.bind(function () {
|
||||
this.onLoad(reader.result);
|
||||
}, this);
|
||||
reader.readAsText(file);
|
||||
this.modal.modal('hide');
|
||||
};
|
||||
|
||||
LoadSave.prototype.onLocalFile = function (event) {
|
||||
var files = event.target.files;
|
||||
var file = files[0];
|
||||
var reader = new FileReader();
|
||||
reader.onload = _.bind(function () {
|
||||
this.onLoad(reader.result);
|
||||
}, this);
|
||||
reader.readAsText(file);
|
||||
LoadSave.prototype.run = function (onLoad, editorText, currentLanguage) {
|
||||
this.populateLocalStorage();
|
||||
this.onLoad = onLoad;
|
||||
this.editorText = editorText;
|
||||
// In case we don't send anything...
|
||||
this.currentLanguage = currentLanguage;
|
||||
this.extension = currentLanguage.extensions[0] || '.txt';
|
||||
this.modal.find('.local-file').attr('accept', _.map(currentLanguage.extensions, function (extension) {
|
||||
return extension + ', ';
|
||||
}, this));
|
||||
this.populateBuiltins().then(_.bind(function () {
|
||||
this.modal.modal();
|
||||
}, this));
|
||||
};
|
||||
|
||||
LoadSave.prototype.onSaveToBrowserStorage = function () {
|
||||
var name = this.modal.find('.save-name').val();
|
||||
if (!name) {
|
||||
this.alert.alert("Save name", "Invalid save name");
|
||||
return;
|
||||
}
|
||||
name += " (" + this.currentLanguage.name + ")";
|
||||
var done = _.bind(function () {
|
||||
setLocalFile(name, this.editorText);
|
||||
}, this);
|
||||
if (getLocalFiles()[name] !== undefined) {
|
||||
this.modal.modal('hide');
|
||||
};
|
||||
|
||||
LoadSave.prototype.run = function (onLoad, editorText, currentLanguage) {
|
||||
this.populateLocalStorage();
|
||||
this.onLoad = onLoad;
|
||||
this.editorText = editorText;
|
||||
// In case we don't send anything...
|
||||
this.currentLanguage = currentLanguage;
|
||||
this.extension = currentLanguage.extensions[0] || '.txt';
|
||||
this.modal.find('.local-file').attr('accept', _.map(currentLanguage.extensions, function (extension) {
|
||||
return extension + ', ';
|
||||
}, this));
|
||||
this.populateBuiltins().then(_.bind(function () {
|
||||
this.modal.modal();
|
||||
}, this));
|
||||
};
|
||||
|
||||
LoadSave.prototype.onSaveToBrowserStorage = function () {
|
||||
var name = this.modal.find('.save-name').val();
|
||||
if (!name) {
|
||||
this.alert.alert("Save name", "Invalid save name");
|
||||
return;
|
||||
}
|
||||
name += " (" + this.currentLanguage.name + ")";
|
||||
var done = _.bind(function () {
|
||||
setLocalFile(name, this.editorText);
|
||||
}, this);
|
||||
if (getLocalFiles()[name] !== undefined) {
|
||||
this.modal.modal('hide');
|
||||
this.alert.ask(
|
||||
"Replace current?",
|
||||
"Do you want to replace the existing saved file '" + name + "'?",
|
||||
{yes: done});
|
||||
} else {
|
||||
done();
|
||||
this.modal.modal('hide');
|
||||
}
|
||||
};
|
||||
|
||||
LoadSave.prototype.onSaveToFile = function () {
|
||||
try {
|
||||
saveAs(new Blob(
|
||||
[this.editorText],
|
||||
{type: "text/plain;charset=utf-8"}),
|
||||
"Compiler Explorer Code" + this.extension);
|
||||
} catch (e) {
|
||||
new Alert().notify('Error while saving your code. Use the clipboard instead.', {
|
||||
group: "savelocalerror",
|
||||
alertClass: "notification-error",
|
||||
dismissTime: 5000
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
LoadSave.prototype.doLoad = function (element) {
|
||||
// TODO: handle errors. consider promises...
|
||||
$.getJSON('source/builtin/load/' + element.lang + '/' + element.file,
|
||||
_.bind(function (response) {
|
||||
this.onLoad(response.file);
|
||||
}, this));
|
||||
this.alert.ask(
|
||||
"Replace current?",
|
||||
"Do you want to replace the existing saved file '" + name + "'?",
|
||||
{yes: done});
|
||||
} else {
|
||||
done();
|
||||
this.modal.modal('hide');
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
return {LoadSave: LoadSave};
|
||||
});
|
||||
LoadSave.prototype.onSaveToFile = function () {
|
||||
try {
|
||||
saveAs(new Blob(
|
||||
[this.editorText],
|
||||
{type: "text/plain;charset=utf-8"}),
|
||||
"Compiler Explorer Code" + this.extension);
|
||||
} catch (e) {
|
||||
new Alert().notify('Error while saving your code. Use the clipboard instead.', {
|
||||
group: "savelocalerror",
|
||||
alertClass: "notification-error",
|
||||
dismissTime: 5000
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
LoadSave.prototype.doLoad = function (element) {
|
||||
// TODO: handle errors. consider promises...
|
||||
$.getJSON('source/builtin/load/' + element.lang + '/' + element.file,
|
||||
_.bind(function (response) {
|
||||
this.onLoad(response.file);
|
||||
}, this));
|
||||
this.modal.modal('hide');
|
||||
};
|
||||
|
||||
|
||||
module.exports = {LoadSave: LoadSave};
|
||||
|
||||
+32
-34
@@ -23,44 +23,42 @@
|
||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
define(function (require) {
|
||||
"use strict";
|
||||
var options = require('./options');
|
||||
var prefix = options.localStoragePrefix || '';
|
||||
"use strict";
|
||||
var options = require('./options');
|
||||
var prefix = options.localStoragePrefix || '';
|
||||
|
||||
function get(key, ifNotPresent) {
|
||||
var result;
|
||||
try {
|
||||
result = window.localStorage.getItem(prefix + key);
|
||||
} catch (e) {
|
||||
// Swallow up any security exceptions...
|
||||
return ifNotPresent;
|
||||
}
|
||||
if (result === null) return ifNotPresent;
|
||||
return result;
|
||||
function get(key, ifNotPresent) {
|
||||
var result;
|
||||
try {
|
||||
result = window.localStorage.getItem(prefix + key);
|
||||
} catch (e) {
|
||||
// Swallow up any security exceptions...
|
||||
return ifNotPresent;
|
||||
}
|
||||
if (result === null) return ifNotPresent;
|
||||
return result;
|
||||
}
|
||||
|
||||
function set(key, value) {
|
||||
try {
|
||||
window.localStorage.setItem(prefix + key, value);
|
||||
return true;
|
||||
} catch (e) {
|
||||
// Swallow up any security exceptions...
|
||||
}
|
||||
return false;
|
||||
function set(key, value) {
|
||||
try {
|
||||
window.localStorage.setItem(prefix + key, value);
|
||||
return true;
|
||||
} catch (e) {
|
||||
// Swallow up any security exceptions...
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function remove(key) {
|
||||
try {
|
||||
window.localStorage.removeItem(prefix + key);
|
||||
} catch (e) {
|
||||
// Swallow up any security exceptions...
|
||||
}
|
||||
function remove(key) {
|
||||
try {
|
||||
window.localStorage.removeItem(prefix + key);
|
||||
} catch (e) {
|
||||
// Swallow up any security exceptions...
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
set: set,
|
||||
get: get,
|
||||
remove: remove
|
||||
};
|
||||
});
|
||||
module.exports = {
|
||||
set: set,
|
||||
get: get,
|
||||
remove: remove
|
||||
};
|
||||
|
||||
+157
-181
@@ -21,203 +21,179 @@
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
// POSSIBILITY OF SUCH DAMAGE
|
||||
"use strict";
|
||||
|
||||
require.config({ // jshint ignore:line
|
||||
paths: {
|
||||
bootstrap: 'ext/bootstrap/dist/js/bootstrap',
|
||||
jquery: 'ext/jquery/dist/jquery',
|
||||
underscore: 'ext/underscore/underscore',
|
||||
goldenlayout: 'ext/golden-layout/dist/goldenlayout',
|
||||
selectize: 'ext/selectize/dist/js/selectize',
|
||||
sifter: 'ext/sifter/sifter',
|
||||
microplugin: 'ext/microplugin/src/microplugin',
|
||||
events: 'ext/eventEmitter/EventEmitter',
|
||||
lzstring: 'ext/lz-string/libs/lz-string',
|
||||
clipboard: 'ext/clipboard/dist/clipboard',
|
||||
'big-integer': 'ext/big-integer/BigInteger.min',
|
||||
'raven-js': 'ext/raven-js/dist/raven',
|
||||
'es6-promise': 'ext/es6-promise/es6-promise',
|
||||
'lru-cache': 'ext/lru-cache/lib/lru-cache',
|
||||
vs: "ext/monaco-editor/min/vs",
|
||||
'bootstrap-slider': 'ext/seiyria-bootstrap-slider/dist/bootstrap-slider',
|
||||
filesaver: 'ext/file-saver/FileSaver',
|
||||
vis: 'ext/vis/dist/vis.min'
|
||||
},
|
||||
shim: {
|
||||
underscore: {exports: '_'},
|
||||
filesaver: {exports: 'saveAs'},
|
||||
'lru-cache': {exports: 'LRUCache'},
|
||||
bootstrap: ['jquery'],
|
||||
'bootstrap-slider': ['bootstrap']
|
||||
},
|
||||
waitSeconds: 60
|
||||
});
|
||||
require("monaco-loader")().then(function() {
|
||||
|
||||
require('bootstrap');
|
||||
require('bootstrap-slider');
|
||||
|
||||
define(function (require) {
|
||||
"use strict";
|
||||
require('bootstrap');
|
||||
require('bootstrap-slider');
|
||||
var analytics = require('analytics');
|
||||
var sharing = require('sharing');
|
||||
var _ = require('underscore');
|
||||
var $ = require('jquery');
|
||||
var GoldenLayout = require('goldenlayout');
|
||||
var Components = require('components');
|
||||
var url = require('url');
|
||||
var clipboard = require('clipboard');
|
||||
var Hub = require('hub');
|
||||
var Raven = require('raven-js');
|
||||
var settings = require('./settings');
|
||||
var local = require('./local');
|
||||
var Alert = require('./alert');
|
||||
var themer = require('./themes');
|
||||
var analytics = require('analytics');
|
||||
var sharing = require('sharing');
|
||||
var _ = require('underscore');
|
||||
var $ = require('jquery');
|
||||
var GoldenLayout = require('goldenlayout');
|
||||
var Components = require('components');
|
||||
var url = require('./url');
|
||||
var clipboard = require('clipboard');
|
||||
var Hub = require('hub');
|
||||
var Raven = require('raven-js');
|
||||
var settings = require('./settings');
|
||||
var local = require('./local');
|
||||
var Alert = require('./alert');
|
||||
var themer = require('./themes');
|
||||
|
||||
function setupSettings(hub) {
|
||||
var eventHub = hub.layout.eventHub;
|
||||
var defaultSettings = {
|
||||
defaultLanguage: hub.subdomainLangId
|
||||
};
|
||||
var currentSettings = JSON.parse(local.get('settings', null)) || defaultSettings;
|
||||
//css
|
||||
require("bootstrap/dist/css/bootstrap.min.css");
|
||||
require("goldenlayout/src/css/goldenlayout-base.css");
|
||||
require("selectize/dist/css/selectize.bootstrap2.css");
|
||||
require("bootstrap-slider/dist/css/bootstrap-slider.css");
|
||||
require("./colours.css");
|
||||
require("./explorer.css");
|
||||
|
||||
function onChange(settings) {
|
||||
currentSettings = settings;
|
||||
local.set('settings', JSON.stringify(settings));
|
||||
eventHub.emit('settingsChange', settings);
|
||||
}
|
||||
function setupSettings(hub) {
|
||||
var eventHub = hub.layout.eventHub;
|
||||
var defaultSettings = {
|
||||
defaultLanguage: hub.subdomainLangId
|
||||
};
|
||||
var currentSettings = JSON.parse(local.get('settings', null)) || defaultSettings;
|
||||
|
||||
new themer.Themer(eventHub, currentSettings);
|
||||
|
||||
eventHub.on('requestSettings', function () {
|
||||
eventHub.emit('settingsChange', currentSettings);
|
||||
});
|
||||
|
||||
var setSettings = settings($('#settings'), currentSettings, onChange, hub.subdomainLangId);
|
||||
eventHub.on('modifySettings', function (newSettings) {
|
||||
setSettings(_.extend(currentSettings, newSettings));
|
||||
});
|
||||
function onChange(settings) {
|
||||
currentSettings = settings;
|
||||
local.set('settings', JSON.stringify(settings));
|
||||
eventHub.emit('settingsChange', settings);
|
||||
}
|
||||
|
||||
function start() {
|
||||
analytics.initialise();
|
||||
new themer.Themer(eventHub, currentSettings);
|
||||
|
||||
var options = require('options');
|
||||
eventHub.on('requestSettings', function () {
|
||||
eventHub.emit('settingsChange', currentSettings);
|
||||
});
|
||||
|
||||
var subdomainPart = window.location.hostname.split('.')[0];
|
||||
var langBySubdomain = _.find(options.languages, function (lang) {
|
||||
return lang.id === subdomainPart || lang.alias.indexOf(subdomainPart) >= 0;
|
||||
});
|
||||
var subLangId = langBySubdomain ? langBySubdomain.id : null;
|
||||
var setSettings = settings($('#settings'), currentSettings, onChange, hub.subdomainLangId);
|
||||
eventHub.on('modifySettings', function (newSettings) {
|
||||
setSettings(_.extend(currentSettings, newSettings));
|
||||
});
|
||||
}
|
||||
|
||||
var defaultConfig = {
|
||||
settings: {showPopoutIcon: false},
|
||||
content: [{
|
||||
type: 'row',
|
||||
content: [
|
||||
Components.getEditor(1, subLangId),
|
||||
Components.getCompiler(1, subLangId)
|
||||
]
|
||||
}]
|
||||
};
|
||||
|
||||
$(window).bind('hashchange', function () {
|
||||
// punt on hash events and just reload the page if there's a hash
|
||||
if (window.location.hash.substr(1))
|
||||
window.location.reload();
|
||||
});
|
||||
function start() {
|
||||
analytics.initialise();
|
||||
|
||||
var config;
|
||||
if (!options.embedded) {
|
||||
config = url.deserialiseState(window.location.hash.substr(1));
|
||||
if (config) {
|
||||
// replace anything in the default config with that from the hash
|
||||
config = _.extend(defaultConfig, config);
|
||||
}
|
||||
var options = require('options');
|
||||
|
||||
if (!config) {
|
||||
var savedState = local.get('gl', null);
|
||||
config = savedState !== null ? JSON.parse(savedState) : defaultConfig;
|
||||
}
|
||||
} else {
|
||||
config = _.extend(defaultConfig,
|
||||
{
|
||||
settings: {
|
||||
showMaximiseIcon: false,
|
||||
showCloseIcon: false,
|
||||
hasHeaders: false
|
||||
}
|
||||
},
|
||||
sharing.configFromEmbedded(window.location.hash.substr(1)));
|
||||
}
|
||||
var subdomainPart = window.location.hostname.split('.')[0];
|
||||
var langBySubdomain = _.find(options.languages, function (lang) {
|
||||
return lang.id === subdomainPart || lang.alias.indexOf(subdomainPart) >= 0;
|
||||
});
|
||||
var subLangId = langBySubdomain ? langBySubdomain.id : null;
|
||||
|
||||
var root = $("#root");
|
||||
|
||||
var layout;
|
||||
var hub;
|
||||
try {
|
||||
layout = new GoldenLayout(config, root);
|
||||
hub = new Hub(layout, subLangId);
|
||||
} catch (e) {
|
||||
Raven.captureException(e);
|
||||
layout = new GoldenLayout(defaultConfig, root);
|
||||
hub = new Hub(layout, subLangId);
|
||||
}
|
||||
layout.on('stateChanged', function () {
|
||||
var config = layout.toConfig();
|
||||
// Only preserve state in localStorage in non-embedded mode.
|
||||
if (!options.embedded) {
|
||||
local.set('gl', JSON.stringify(config));
|
||||
} else {
|
||||
var strippedToLast = window.location.pathname;
|
||||
strippedToLast = strippedToLast.substr(0,
|
||||
strippedToLast.lastIndexOf('/') + 1);
|
||||
$('a.link').attr('href', strippedToLast + '#' + url.serialiseState(config));
|
||||
}
|
||||
});
|
||||
|
||||
function sizeRoot() {
|
||||
var height = $(window).height() - root.position().top;
|
||||
root.height(height);
|
||||
layout.updateSize();
|
||||
}
|
||||
|
||||
$(window).resize(sizeRoot);
|
||||
sizeRoot();
|
||||
|
||||
new clipboard('.btn.clippy');
|
||||
|
||||
setupSettings(hub);
|
||||
|
||||
sharing.initShareButton($('#share'), layout);
|
||||
|
||||
function setupAdd(thing, func) {
|
||||
layout.createDragSource(thing, func);
|
||||
thing.click(function () {
|
||||
hub.addAtRoot(func());
|
||||
});
|
||||
}
|
||||
|
||||
setupAdd($('#add-diff'), function () {
|
||||
return Components.getDiff();
|
||||
});
|
||||
setupAdd($('#add-editor'), function () {
|
||||
return Components.getEditor();
|
||||
});
|
||||
$('#ui-reset').click(function () {
|
||||
local.remove('gl');
|
||||
var defaultConfig = {
|
||||
settings: {showPopoutIcon: false},
|
||||
content: [{
|
||||
type: 'row',
|
||||
content: [
|
||||
Components.getEditor(1, subLangId),
|
||||
Components.getCompiler(1, subLangId)
|
||||
]
|
||||
}]
|
||||
};
|
||||
|
||||
$(window).bind('hashchange', function () {
|
||||
// punt on hash events and just reload the page if there's a hash
|
||||
if (window.location.hash.substr(1))
|
||||
window.location.reload();
|
||||
});
|
||||
$('#thanks-to').click(function () {
|
||||
$.get('thanks.html', function (result) {
|
||||
new Alert().alert("Special thanks to", $(result));
|
||||
});
|
||||
});
|
||||
$('#changes').click(function () {
|
||||
$.get('changelog.html', function (result) {
|
||||
new Alert().alert("Changelog", $(result));
|
||||
});
|
||||
});
|
||||
|
||||
var config;
|
||||
if (!options.embedded) {
|
||||
config = url.deserialiseState(window.location.hash.substr(1));
|
||||
if (config) {
|
||||
// replace anything in the default config with that from the hash
|
||||
config = _.extend(defaultConfig, config);
|
||||
}
|
||||
|
||||
if (!config) {
|
||||
var savedState = local.get('gl', null);
|
||||
config = savedState !== null ? JSON.parse(savedState) : defaultConfig;
|
||||
}
|
||||
} else {
|
||||
config = _.extend(defaultConfig,
|
||||
{
|
||||
settings: {
|
||||
showMaximiseIcon: false,
|
||||
showCloseIcon: false,
|
||||
hasHeaders: false
|
||||
}
|
||||
},
|
||||
sharing.configFromEmbedded(window.location.hash.substr(1)));
|
||||
}
|
||||
|
||||
var root = $("#root");
|
||||
|
||||
var layout;
|
||||
var hub;
|
||||
try {
|
||||
layout = new GoldenLayout(config, root);
|
||||
hub = new Hub(layout, subLangId);
|
||||
} catch (e) {
|
||||
Raven.captureException(e);
|
||||
layout = new GoldenLayout(defaultConfig, root);
|
||||
hub = new Hub(layout, subLangId);
|
||||
}
|
||||
layout.on('stateChanged', function () {
|
||||
var config = layout.toConfig();
|
||||
// Only preserve state in localStorage in non-embedded mode.
|
||||
if (!options.embedded) {
|
||||
local.set('gl', JSON.stringify(config));
|
||||
} else {
|
||||
var strippedToLast = window.location.pathname;
|
||||
strippedToLast = strippedToLast.substr(0,
|
||||
strippedToLast.lastIndexOf('/') + 1);
|
||||
$('a.link').attr('href', strippedToLast + '#' + url.serialiseState(config));
|
||||
}
|
||||
});
|
||||
|
||||
function sizeRoot() {
|
||||
var height = $(window).height() - root.position().top;
|
||||
root.height(height);
|
||||
layout.updateSize();
|
||||
}
|
||||
|
||||
$(window).resize(sizeRoot);
|
||||
sizeRoot();
|
||||
|
||||
new clipboard('.btn.clippy');
|
||||
|
||||
setupSettings(hub);
|
||||
|
||||
sharing.initShareButton($('#share'), layout);
|
||||
|
||||
function setupAdd(thing, func) {
|
||||
layout.createDragSource(thing, func);
|
||||
thing.click(function () {
|
||||
hub.addAtRoot(func());
|
||||
});
|
||||
}
|
||||
|
||||
setupAdd($('#add-diff'), function () {
|
||||
return Components.getDiff();
|
||||
});
|
||||
setupAdd($('#add-editor'), function () {
|
||||
return Components.getEditor();
|
||||
});
|
||||
$('#ui-reset').click(function () {
|
||||
local.remove('gl');
|
||||
window.location.reload();
|
||||
});
|
||||
$('#thanks-to').click(function () {
|
||||
new Alert().alert("Special thanks to", $(require('./thanks.html')));
|
||||
});
|
||||
$('#changes').click(function () {
|
||||
new Alert().alert("Changelog", $(require('./changelog.html')));
|
||||
});
|
||||
}
|
||||
|
||||
$(start);
|
||||
});
|
||||
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
"use strict";
|
||||
|
||||
var Promise = require('es6-promise').Promise,
|
||||
_loaded = false,
|
||||
_loadPromise = null;
|
||||
|
||||
// Returns promise that will be fulfilled when monaco is available
|
||||
var waitForMonaco = function() {
|
||||
if (_loadPromise) {
|
||||
return _loadPromise;
|
||||
}
|
||||
|
||||
_loadPromise = new Promise(function(resolve, reject) {
|
||||
if (typeof(window.monaco) === 'object') {
|
||||
resolve(window.monaco);
|
||||
return window.monaco;
|
||||
}
|
||||
|
||||
window.require(['vs/editor/editor.main'], function() {
|
||||
_loaded = true;
|
||||
resolve(window.monaco);
|
||||
});
|
||||
});
|
||||
return _loadPromise;
|
||||
};
|
||||
|
||||
module.exports = waitForMonaco;
|
||||
+3
-5
@@ -23,9 +23,7 @@
|
||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
define(function (require) {
|
||||
"use strict";
|
||||
require('vs/editor/editor.main');
|
||||
|
||||
return monaco; // jshint ignore:line
|
||||
});
|
||||
|
||||
//until webpack can support monaco properly it exists on the window
|
||||
module.exports = monaco;
|
||||
+179
-146
@@ -22,169 +22,202 @@
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
"use strict";
|
||||
|
||||
define(function (require) {
|
||||
"use strict";
|
||||
var FontScale = require('fontscale');
|
||||
var monaco = require('monaco');
|
||||
var options = require('options');
|
||||
var _ = require('underscore');
|
||||
var $ = require('jquery');
|
||||
|
||||
var FontScale = require('fontscale');
|
||||
var monaco = require('monaco');
|
||||
var _ = require('underscore');
|
||||
var $ = require('jquery');
|
||||
require('asm-mode');
|
||||
require('selectize');
|
||||
|
||||
function Opt(hub, container, state) {
|
||||
state = state || {};
|
||||
this.container = container;
|
||||
this.eventHub = hub.createEventHub();
|
||||
this.domRoot = container.getElement();
|
||||
this.domRoot.html($('#opt').html());
|
||||
this.compilers = {};
|
||||
this.code = state.source || "";
|
||||
this._currentDecorations = [];
|
||||
this.optEditor = monaco.editor.create(this.domRoot.find(".monaco-placeholder")[0], {
|
||||
value: this.code,
|
||||
scrollBeyondLastLine: false,
|
||||
language: 'cppp', //we only support cpp(p) for now
|
||||
readOnly: true,
|
||||
glyphMargin: true,
|
||||
quickSuggestions: false,
|
||||
fontFamily: 'monospace',
|
||||
fixedOverflowWidgets: true,
|
||||
minimap: {
|
||||
maxColumn: 80
|
||||
},
|
||||
lineNumbersMinChars: 3
|
||||
});
|
||||
function Opt(hub, container, state) {
|
||||
state = state || {};
|
||||
this.container = container;
|
||||
this.eventHub = hub.createEventHub();
|
||||
this.domRoot = container.getElement();
|
||||
this.domRoot.html($('#opt').html());
|
||||
this.compilers = {};
|
||||
this.code = state.source || "";
|
||||
this._currentDecorations = [];
|
||||
this.optEditor = monaco.editor.create(this.domRoot.find(".monaco-placeholder")[0], {
|
||||
value: this.code,
|
||||
scrollBeyondLastLine: false,
|
||||
language: 'cppp', //we only support cpp(p) for now
|
||||
readOnly: true,
|
||||
glyphMargin: true,
|
||||
quickSuggestions: false,
|
||||
fixedOverflowWidgets: true,
|
||||
fontFamily: 'monospace',
|
||||
minimap: {
|
||||
maxColumn: 80
|
||||
},
|
||||
lineNumbersMinChars: 3
|
||||
});
|
||||
|
||||
this._compilerid = state.id;
|
||||
this._compilerName = state.compilerName;
|
||||
this._editorid = state.editorid;
|
||||
this.fontScale = new FontScale(this.domRoot, state, this.optEditor);
|
||||
this.fontScale.on('change', _.bind(this.updateState, this));
|
||||
this._compilerid = state.id;
|
||||
this._compilerName = state.compilerName;
|
||||
this._editorid = state.editorid;
|
||||
this.fontScale = new FontScale(this.domRoot, state, this.optEditor);
|
||||
this.fontScale.on('change', _.bind(this.updateState, this));
|
||||
|
||||
this.eventHub.on('compileResult', this.onCompileResult, this);
|
||||
this.eventHub.on('compiler', this.onCompiler, this);
|
||||
this.eventHub.on('compilerClose', this.onCompilerClose, this);
|
||||
this.eventHub.on('editorChange', this.onEditorChange, this);
|
||||
this.eventHub.on('settingsChange', this.onSettingsChange, this);
|
||||
this.eventHub.on('resize', this.resize, this);
|
||||
this.container.on('destroy', this.close, this);
|
||||
this.eventHub.emit('requestSettings');
|
||||
this.eventHub.on('compileResult', this.onCompileResult, this);
|
||||
this.eventHub.on('compiler', this.onCompiler, this);
|
||||
this.eventHub.on('compilerClose', this.onCompilerClose, this);
|
||||
this.eventHub.on('editorChange', this.onEditorChange, this);
|
||||
this.eventHub.on('settingsChange', this.onSettingsChange, this);
|
||||
this.eventHub.on('resize', this.resize, this);
|
||||
this.container.on('destroy', this.close, this);
|
||||
this.eventHub.emit('requestSettings');
|
||||
|
||||
container.on('resize', this.resize, this);
|
||||
container.on('shown', this.resize, this);
|
||||
if (state && state.optOutput) {
|
||||
this.showOptResults(state.optOutput);
|
||||
}
|
||||
this.setTitle();
|
||||
this.eventHub.emit("optViewOpened", this._compilerid);
|
||||
container.on('resize', this.resize, this);
|
||||
container.on('shown', this.resize, this);
|
||||
if (state && state.optOutput) {
|
||||
this.showOptResults(state.optOutput);
|
||||
}
|
||||
this.setTitle();
|
||||
this.eventHub.emit("optViewOpened", this._compilerid);
|
||||
}
|
||||
|
||||
// TODO: de-dupe with compiler etc
|
||||
Opt.prototype.resize = function () {
|
||||
var topBarHeight = this.domRoot.find(".top-bar").outerHeight(true);
|
||||
this.optEditor.layout({
|
||||
width: this.domRoot.width(),
|
||||
height: this.domRoot.height() - topBarHeight
|
||||
// TODO: de-dupe with compiler etc
|
||||
Opt.prototype.resize = function () {
|
||||
var topBarHeight = this.domRoot.find(".top-bar").outerHeight(true);
|
||||
this.optEditor.layout({
|
||||
width: this.domRoot.width(),
|
||||
height: this.domRoot.height() - topBarHeight
|
||||
});
|
||||
};
|
||||
|
||||
Opt.prototype.onEditorChange = function (id, source) {
|
||||
if (this._editorid == id) {
|
||||
this.code = source;
|
||||
this.optEditor.setValue(source);
|
||||
}
|
||||
};
|
||||
|
||||
Opt.prototype.onCompileResult = function (id, compiler, result) {
|
||||
if (result.hasOptOutput && this._compilerid == id) {
|
||||
this.showOptResults(result.optOutput);
|
||||
}
|
||||
};
|
||||
Opt.prototype.setTitle = function () {
|
||||
this.container.setTitle(this._compilerName + " Opt Viewer (Editor #" + this._editorid + ", Compiler #" + this._compilerid + ")");
|
||||
};
|
||||
|
||||
Opt.prototype.getDisplayableOpt = function (optResult) {
|
||||
return "**" + optResult.optType + "** - " + optResult.displayString;
|
||||
};
|
||||
|
||||
Opt.prototype.showOptResults = function (results) {
|
||||
var opt = [];
|
||||
|
||||
results = _.filter(results, function (x) {
|
||||
return x.DebugLoc !== undefined;
|
||||
});
|
||||
|
||||
results = _.groupBy(results, function (x) {
|
||||
return x.DebugLoc.Line;
|
||||
});
|
||||
|
||||
_.mapObject(results, function (value, key) {
|
||||
var linenumber = Number(key);
|
||||
var className = value.reduce(function (acc, x) {
|
||||
if (x.optType == "Missed" || acc == "Missed") {
|
||||
return "Missed";
|
||||
} else if (x.optType == "Passed" || acc == "Passed") {
|
||||
return "Passed";
|
||||
}
|
||||
return x.optType;
|
||||
}, "");
|
||||
var contents = _.map(value, this.getDisplayableOpt, this);
|
||||
opt.push({
|
||||
range: new monaco.Range(linenumber, 1, linenumber, Infinity),
|
||||
options: {
|
||||
isWholeLine: true,
|
||||
glyphMarginClassName: "opt-decoration." + className.toLowerCase(),
|
||||
hoverMessage: contents,
|
||||
glyphMarginHoverMessage: contents
|
||||
}
|
||||
});
|
||||
};
|
||||
}, this);
|
||||
|
||||
Opt.prototype.onEditorChange = function (id, source) {
|
||||
if (this._editorid === id) {
|
||||
this.code = source;
|
||||
this.optEditor.setValue(source);
|
||||
this._currentDecorations = this.optEditor.deltaDecorations(this._currentDecorations, opt);
|
||||
};
|
||||
|
||||
Opt.prototype.onCompiler = function (id, compiler, options, editorid) {
|
||||
if (id === this._compilerid) {
|
||||
this._compilerName = compiler ? compiler.name : '';
|
||||
this.setTitle();
|
||||
if (compiler && !compiler.supportsOptOutput) {
|
||||
this.code = this.optEditor.getValue();
|
||||
this.optEditor.setValue("<" + compiler.version + " does not support the optimisation view>");
|
||||
return;
|
||||
}
|
||||
};
|
||||
Opt.prototype.onCompileResult = function (id, compiler, result) {
|
||||
if (result.hasOptOutput && this._compilerid === id) {
|
||||
this.showOptResults(result.optOutput);
|
||||
}
|
||||
};
|
||||
Opt.prototype.setTitle = function () {
|
||||
this.container.setTitle(this._compilerName + " Opt Viewer (Editor #" + this._editorid + ", Compiler #" + this._compilerid + ")");
|
||||
};
|
||||
this._editorid = editorid;
|
||||
this.optEditor.setValue(this.code);
|
||||
}
|
||||
};
|
||||
|
||||
Opt.prototype.getDisplayableOpt = function (optResult) {
|
||||
return "**" + optResult.optType + "** - " + optResult.displayString;
|
||||
};
|
||||
// TODO: de-dupe with compiler etc
|
||||
Opt.prototype.resize = function () {
|
||||
var topBarHeight = this.domRoot.find(".top-bar").outerHeight(true);
|
||||
this.optEditor.layout({
|
||||
width: this.domRoot.width(),
|
||||
height: this.domRoot.height() - topBarHeight
|
||||
});
|
||||
};
|
||||
|
||||
Opt.prototype.showOptResults = function (results) {
|
||||
var opt = [];
|
||||
Opt.prototype.onEditorChange = function (id, source) {
|
||||
if (this._editorid === id) {
|
||||
this.code = source;
|
||||
this.optEditor.setValue(source);
|
||||
}
|
||||
};
|
||||
|
||||
results = _.filter(results, function (x) {
|
||||
return x.DebugLoc !== undefined;
|
||||
});
|
||||
Opt.prototype.onCompileResult = function (id, compiler, result) {
|
||||
if (result.hasOptOutput && this._compilerid === id) {
|
||||
this.showOptResults(result.optOutput);
|
||||
}
|
||||
};
|
||||
|
||||
results = _.groupBy(results, function (x) {
|
||||
return x.DebugLoc.Line;
|
||||
});
|
||||
Opt.prototype.setTitle = function () {
|
||||
this.container.setTitle(this._compilerName + " Opt Viewer (Editor #" + this._editorid + ", Compiler #" + this._compilerid + ")");
|
||||
};
|
||||
|
||||
_.mapObject(results, function (value, key) {
|
||||
var linenumber = Number(key);
|
||||
var className = value.reduce(function (acc, x) {
|
||||
if (x.optType === "Missed" || acc === "Missed") {
|
||||
return "Missed";
|
||||
} else if (x.optType === "Passed" || acc === "Passed") {
|
||||
return "Passed";
|
||||
}
|
||||
return x.optType;
|
||||
}, "");
|
||||
var contents = _.map(value, this.getDisplayableOpt, this);
|
||||
opt.push({
|
||||
range: new monaco.Range(linenumber, 1, linenumber, Infinity),
|
||||
options: {
|
||||
isWholeLine: true,
|
||||
glyphMarginClassName: "opt-decoration." + className.toLowerCase(),
|
||||
hoverMessage: contents,
|
||||
glyphMarginHoverMessage: contents
|
||||
}
|
||||
});
|
||||
Opt.prototype.getDisplayableOpt = function (optResult) {
|
||||
return "**" + optResult.optType + "** - " + optResult.displayString;
|
||||
};
|
||||
|
||||
Opt.prototype.updateState = function () {
|
||||
};
|
||||
|
||||
Opt.prototype.close = function () {
|
||||
this.eventHub.unsubscribe();
|
||||
this.eventHub.emit("optViewClosed", this._compilerid);
|
||||
this.optEditor.dispose();
|
||||
};
|
||||
|
||||
Opt.prototype.onCompilerClose = function (id) {
|
||||
if (id === this._compilerid) {
|
||||
// We can't immediately close as an outer loop somewhere in GoldenLayout is iterating over
|
||||
// the hierarchy. We can't modify while it's being iterated over.
|
||||
this.close();
|
||||
_.defer(function (self) {
|
||||
self.container.close();
|
||||
}, this);
|
||||
}
|
||||
};
|
||||
|
||||
this._currentDecorations = this.optEditor.deltaDecorations(this._currentDecorations, opt);
|
||||
};
|
||||
|
||||
Opt.prototype.onCompiler = function (id, compiler, options, editorid) {
|
||||
if (id === this._compilerid) {
|
||||
this._compilerName = compiler ? compiler.name : '';
|
||||
this.setTitle();
|
||||
if (compiler && !compiler.supportsOptOutput) {
|
||||
this.code = this.optEditor.getValue();
|
||||
this.optEditor.setValue("<" + compiler.version + " does not support the optimisation view>");
|
||||
return;
|
||||
}
|
||||
this._editorid = editorid;
|
||||
this.optEditor.setValue(this.code);
|
||||
Opt.prototype.onSettingsChange = function (newSettings) {
|
||||
this.optEditor.updateOptions({
|
||||
minimap: {
|
||||
enabled: newSettings.showMinimap
|
||||
}
|
||||
};
|
||||
Opt.prototype.onCompilerClose = function (id) {
|
||||
if (id === this._compilerid) {
|
||||
// We can't immediately close as an outer loop somewhere in GoldenLayout is iterating over
|
||||
// the hierarchy. We can't modify while it's being iterated over.
|
||||
this.close();
|
||||
_.defer(function (self) {
|
||||
self.container.close();
|
||||
}, this);
|
||||
}
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
Opt.prototype.updateState = function () {
|
||||
};
|
||||
|
||||
Opt.prototype.onSettingsChange = function (newSettings) {
|
||||
this.optEditor.updateOptions({
|
||||
minimap: {
|
||||
enabled: newSettings.showMinimap
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
Opt.prototype.close = function () {
|
||||
this.eventHub.unsubscribe();
|
||||
this.eventHub.emit("optViewClosed", this._compilerid);
|
||||
this.optEditor.dispose();
|
||||
};
|
||||
|
||||
return {
|
||||
Opt: Opt
|
||||
};
|
||||
});
|
||||
module.exports = {
|
||||
Opt: Opt
|
||||
};
|
||||
|
||||
+2
-3
@@ -23,8 +23,7 @@
|
||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
define(function (require) {
|
||||
"use strict";
|
||||
return window.compilerExplorerOptions;
|
||||
});
|
||||
module.exports = window.compilerExplorerOptions;
|
||||
|
||||
|
||||
|
||||
+109
-112
@@ -23,129 +23,126 @@
|
||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
define(function (require) {
|
||||
"use strict";
|
||||
"use strict";
|
||||
|
||||
var _ = require('underscore');
|
||||
var $ = require('jquery');
|
||||
var FontScale = require('fontscale');
|
||||
var AnsiToHtml = require('ansi-to-html');
|
||||
var _ = require('underscore');
|
||||
var $ = require('jquery');
|
||||
var FontScale = require('fontscale');
|
||||
var AnsiToHtml = require('ansi-to-html');
|
||||
|
||||
function makeAnsiToHtml(color) {
|
||||
return new AnsiToHtml({
|
||||
fg: color ? color : '#333',
|
||||
bg: '#f5f5f5',
|
||||
stream: true,
|
||||
escapeXML: true
|
||||
});
|
||||
}
|
||||
function makeAnsiToHtml(color) {
|
||||
return new AnsiToHtml({
|
||||
fg: color ? color : '#333',
|
||||
bg: '#f5f5f5',
|
||||
stream: true,
|
||||
escapeXML: true
|
||||
});
|
||||
}
|
||||
|
||||
function Output(hub, container, state) {
|
||||
this.container = container;
|
||||
this.compilerId = state.compiler;
|
||||
this.editorId = state.editor;
|
||||
this.eventHub = hub.createEventHub();
|
||||
this.domRoot = container.getElement();
|
||||
this.domRoot.html($('#compiler-output').html());
|
||||
this.contentRoot = this.domRoot.find(".content");
|
||||
this.compilerName = "";
|
||||
this.fontScale = new FontScale(this.domRoot, state, "pre");
|
||||
function Output(hub, container, state) {
|
||||
this.container = container;
|
||||
this.compilerId = state.compiler;
|
||||
this.editorId = state.editor;
|
||||
this.eventHub = hub.createEventHub();
|
||||
this.domRoot = container.getElement();
|
||||
this.domRoot.html($('#compiler-output').html());
|
||||
this.contentRoot = this.domRoot.find(".content");
|
||||
this.compilerName = "";
|
||||
this.fontScale = new FontScale(this.domRoot, state, "pre");
|
||||
|
||||
this.container.on('destroy', this.close, this);
|
||||
this.container.on('destroy', this.close, this);
|
||||
|
||||
this.eventHub.on('compileResult', this.onCompileResult, this);
|
||||
this.eventHub.on('compilerFontScale', this.onFontScale, this);
|
||||
this.eventHub.on('compilerClose', this.onCompilerClose, this);
|
||||
this.eventHub.emit('resendCompilation', this.compilerId);
|
||||
|
||||
this.updateCompilerName();
|
||||
}
|
||||
|
||||
this.eventHub.on('compileResult', this.onCompileResult, this);
|
||||
this.eventHub.on('compilerFontScale', this.onFontScale, this);
|
||||
this.eventHub.on('compilerClose', this.onCompilerClose, this);
|
||||
this.eventHub.emit('resendCompilation', this.compilerId);
|
||||
Output.prototype.onCompileResult = function (id, compiler, result) {
|
||||
if (id !== this.compilerId) return;
|
||||
if (compiler) this.compilerName = compiler.name;
|
||||
|
||||
this.updateCompilerName();
|
||||
}
|
||||
this.contentRoot.empty();
|
||||
|
||||
Output.prototype.onCompileResult = function (id, compiler, result) {
|
||||
if (id !== this.compilerId) return;
|
||||
if (compiler) this.compilerName = compiler.name;
|
||||
var ansiToHtml = makeAnsiToHtml();
|
||||
|
||||
this.contentRoot.empty();
|
||||
_.each((result.stdout || []).concat(result.stderr || []), function (obj) {
|
||||
this.add(ansiToHtml.toHtml(obj.text), obj.tag ? obj.tag.line : obj.line);
|
||||
}, this);
|
||||
|
||||
var ansiToHtml = makeAnsiToHtml();
|
||||
if (!result.execResult) {
|
||||
this.add("Compiler returned: " + result.code);
|
||||
} else {
|
||||
this.add("Program returned: " + result.execResult.code);
|
||||
if (result.execResult.stderr.length || result.execResult.stdout.length) {
|
||||
ansiToHtml = makeAnsiToHtml("red");
|
||||
_.each(result.execResult.stderr, function (obj) {
|
||||
this.programOutput(ansiToHtml.toHtml(obj.text), "red");
|
||||
}, this);
|
||||
|
||||
_.each((result.stdout || []).concat(result.stderr || []), function (obj) {
|
||||
this.add(ansiToHtml.toHtml(obj.text), obj.tag ? obj.tag.line : obj.line);
|
||||
}, this);
|
||||
|
||||
if (!result.execResult) {
|
||||
this.add("Compiler returned: " + result.code);
|
||||
} else {
|
||||
this.add("Program returned: " + result.execResult.code);
|
||||
if (result.execResult.stderr.length || result.execResult.stdout.length) {
|
||||
ansiToHtml = makeAnsiToHtml("red");
|
||||
_.each(result.execResult.stderr, function (obj) {
|
||||
this.programOutput(ansiToHtml.toHtml(obj.text), "red");
|
||||
}, this);
|
||||
|
||||
ansiToHtml = makeAnsiToHtml();
|
||||
_.each(result.execResult.stdout, function (obj) {
|
||||
this.programOutput(ansiToHtml.toHtml(obj.text));
|
||||
}, this);
|
||||
}
|
||||
}
|
||||
|
||||
this.updateCompilerName();
|
||||
};
|
||||
|
||||
Output.prototype.onFontScale = function (id, scale) {
|
||||
if (id === this.compilerId) this.fontScale.setScale(scale);
|
||||
};
|
||||
|
||||
Output.prototype.programOutput = function (msg, color) {
|
||||
var elem = $('<div></div>').appendTo(this.contentRoot)
|
||||
.html(msg)
|
||||
.css('font-family', '"Courier New", Courier, monospace');
|
||||
if (color)
|
||||
elem.css("color", color);
|
||||
};
|
||||
|
||||
Output.prototype.add = function (msg, lineNum) {
|
||||
var elem = $('<div></div>').appendTo(this.contentRoot);
|
||||
if (lineNum) {
|
||||
elem.html($('<a></a>').prop('href', '#').html(msg))
|
||||
.click(_.bind(function (e) {
|
||||
this.eventHub.emit('editorSetDecoration', this.editorId, lineNum, true);
|
||||
// do not bring user to the top of index.html
|
||||
// http://stackoverflow.com/questions/3252730
|
||||
e.preventDefault();
|
||||
return false;
|
||||
}, this))
|
||||
.on('mouseover', _.bind(function () {
|
||||
this.eventHub.emit('editorSetDecoration', this.editorId, lineNum, false);
|
||||
}, this));
|
||||
} else {
|
||||
elem.html(msg);
|
||||
}
|
||||
};
|
||||
|
||||
Output.prototype.updateCompilerName = function () {
|
||||
var name = "#" + this.compilerId;
|
||||
if (this.compilerName) name += " with " + this.compilerName;
|
||||
this.container.setTitle(name);
|
||||
};
|
||||
|
||||
Output.prototype.onCompilerClose = function (id) {
|
||||
if (id === this.compilerId) {
|
||||
// We can't immediately close as an outer loop somewhere in GoldenLayout is iterating over
|
||||
// the hierarchy. We can't modify while it's being iterated over.
|
||||
this.close();
|
||||
_.defer(function (self) {
|
||||
self.container.close();
|
||||
ansiToHtml = makeAnsiToHtml();
|
||||
_.each(result.execResult.stdout, function (obj) {
|
||||
this.programOutput(ansiToHtml.toHtml(obj.text));
|
||||
}, this);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Output.prototype.close = function () {
|
||||
this.eventHub.unsubscribe();
|
||||
};
|
||||
this.updateCompilerName();
|
||||
};
|
||||
|
||||
return {
|
||||
Output: Output
|
||||
};
|
||||
});
|
||||
Output.prototype.onFontScale = function (id, scale) {
|
||||
if (id === this.compilerId) this.fontScale.setScale(scale);
|
||||
};
|
||||
|
||||
Output.prototype.programOutput = function (msg, color) {
|
||||
var elem = $('<div></div>').appendTo(this.contentRoot)
|
||||
.html(msg)
|
||||
.css('font-family', '"Courier New", Courier, monospace');
|
||||
if (color)
|
||||
elem.css("color", color);
|
||||
};
|
||||
|
||||
Output.prototype.add = function (msg, lineNum) {
|
||||
var elem = $('<div></div>').appendTo(this.contentRoot);
|
||||
if (lineNum) {
|
||||
elem.html($('<a></a>').prop('href', '#').html(msg))
|
||||
.click(_.bind(function (e) {
|
||||
this.eventHub.emit('editorSetDecoration', this.editorId, lineNum, true);
|
||||
// do not bring user to the top of index.html
|
||||
// http://stackoverflow.com/questions/3252730
|
||||
e.preventDefault();
|
||||
return false;
|
||||
}, this))
|
||||
.on('mouseover', _.bind(function () {
|
||||
this.eventHub.emit('editorSetDecoration', this.editorId, lineNum, false);
|
||||
}, this));
|
||||
} else {
|
||||
elem.html(msg);
|
||||
}
|
||||
};
|
||||
|
||||
Output.prototype.updateCompilerName = function () {
|
||||
var name = "#" + this.compilerId;
|
||||
if (this.compilerName) name += " with " + this.compilerName;
|
||||
this.container.setTitle(name);
|
||||
};
|
||||
|
||||
Output.prototype.onCompilerClose = function (id) {
|
||||
if (id === this.compilerId) {
|
||||
// We can't immediately close as an outer loop somewhere in GoldenLayout is iterating over
|
||||
// the hierarchy. We can't modify while it's being iterated over.
|
||||
_.defer(function (self) {
|
||||
self.container.close();
|
||||
}, this);
|
||||
}
|
||||
};
|
||||
|
||||
Output.prototype.close = function () {
|
||||
this.eventHub.unsubscribe();
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
Output: Output
|
||||
};
|
||||
|
||||
+104
-106
@@ -22,118 +22,116 @@
|
||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
define(function (require) {
|
||||
"use strict";
|
||||
var monaco = require('monaco');
|
||||
|
||||
function definition() {
|
||||
return {
|
||||
defaultToken: 'invalid',
|
||||
"use strict";
|
||||
|
||||
keywords: [
|
||||
'abstract', 'alignof', 'as', 'become', 'box',
|
||||
'break', 'const', 'continue', 'crate', 'do',
|
||||
'else', 'enum', 'extern', 'false', 'final',
|
||||
'fn', 'for', 'if', 'impl', 'in',
|
||||
'let', 'loop', 'macro', 'match', 'mod',
|
||||
'move', 'mut', 'offsetof', 'override', 'priv',
|
||||
'proc', 'pub', 'pure', 'ref', 'return',
|
||||
'Self', 'self', 'sizeof', 'static', 'struct',
|
||||
'super', 'trait', 'true', 'type', 'typeof',
|
||||
'unsafe', 'unsized', 'use', 'virtual', 'where',
|
||||
'while', 'yield'
|
||||
function definition() {
|
||||
return {
|
||||
defaultToken: 'invalid',
|
||||
|
||||
keywords: [
|
||||
'abstract', 'alignof', 'as', 'become', 'box',
|
||||
'break', 'const', 'continue', 'crate', 'do',
|
||||
'else', 'enum', 'extern', 'false', 'final',
|
||||
'fn', 'for', 'if', 'impl', 'in',
|
||||
'let', 'loop', 'macro', 'match', 'mod',
|
||||
'move', 'mut', 'offsetof', 'override', 'priv',
|
||||
'proc', 'pub', 'pure', 'ref', 'return',
|
||||
'Self', 'self', 'sizeof', 'static', 'struct',
|
||||
'super', 'trait', 'true', 'type', 'typeof',
|
||||
'unsafe', 'unsized', 'use', 'virtual', 'where',
|
||||
'while', 'yield'
|
||||
],
|
||||
|
||||
typeKeywords: [
|
||||
'array', 'bool', 'char', 'f32', 'f64', 'i16', 'i32', 'i64', 'i8',
|
||||
'isize', 'pointer', 'slice', 'str', 'tuple', 'u16', 'u32', 'u64', 'u8',
|
||||
'usize'
|
||||
],
|
||||
|
||||
operators: [
|
||||
'=', '>', '<', '!', '~', '?', ':',
|
||||
'==', '<=', '>=', '!=', '&&', '||', '++', '--',
|
||||
'+', '-', '*', '/', '&', '|', '^', '%', '<<',
|
||||
'>>', '>>>', '+=', '-=', '*=', '/=', '&=', '|=',
|
||||
'^=', '%=', '<<=', '>>=', '>>>='
|
||||
],
|
||||
|
||||
symbols: /[=><!~?:&|+\-*\/^%]+/,
|
||||
escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,
|
||||
|
||||
// The main tokenizer for our languages
|
||||
tokenizer: {
|
||||
root: [
|
||||
// identifiers and keywords
|
||||
[/[a-z_$][\w$]*/, {
|
||||
cases: {
|
||||
'@typeKeywords': 'keyword',
|
||||
'@keywords': 'keyword',
|
||||
'@default': 'identifier'
|
||||
}
|
||||
}],
|
||||
[/[A-Z][\w$]*/, 'type.identifier'], // to show class names nicely
|
||||
|
||||
// whitespace
|
||||
{include: '@whitespace'},
|
||||
|
||||
// delimiters and operators
|
||||
[/[{}()\[\]]/, '@brackets'],
|
||||
[/[<>](?!@symbols)/, '@brackets'],
|
||||
[/@symbols/, {
|
||||
cases: {
|
||||
'@operators': 'operator',
|
||||
'@default': ''
|
||||
}
|
||||
}],
|
||||
|
||||
[/#!\[[^]*\]/, 'annotation'],
|
||||
[/#!.*$/, 'annotation.invalid'],
|
||||
|
||||
// numbers
|
||||
[/\d*\.\d+([eE][\-+]?\d+)?[fFdD]?/, 'number.float'],
|
||||
[/0[xX][0-9a-fA-F_]*[0-9a-fA-F][Ll]?/, 'number.hex'],
|
||||
[/0[0-7_]*[0-7][Ll]?/, 'number.octal'],
|
||||
[/0[bB][0-1_]*[0-1][Ll]?/, 'number.binary'],
|
||||
[/\d+[lL]?/, 'number'],
|
||||
|
||||
// delimiter: after number because of .\d floats
|
||||
[/[;,.]/, 'delimiter'],
|
||||
|
||||
// strings
|
||||
[/"([^"\\]|\\.)*$/, 'string.invalid'], // non-teminated string
|
||||
[/"/, 'string', '@string'],
|
||||
|
||||
// characters
|
||||
[/'[^\\']'/, 'string'],
|
||||
[/(')(@escapes)(')/, ['string', 'string.escape', 'string']],
|
||||
[/'/, 'string.invalid']
|
||||
],
|
||||
|
||||
typeKeywords: [
|
||||
'array', 'bool', 'char', 'f32', 'f64', 'i16', 'i32', 'i64', 'i8',
|
||||
'isize', 'pointer', 'slice', 'str', 'tuple', 'u16', 'u32', 'u64', 'u8',
|
||||
'usize'
|
||||
whitespace: [
|
||||
[/[ \t\r\n]+/, 'white'],
|
||||
[/\/\*/, 'comment', '@comment'],
|
||||
[/\/\/.*$/, 'comment'],
|
||||
],
|
||||
|
||||
operators: [
|
||||
'=', '>', '<', '!', '~', '?', ':',
|
||||
'==', '<=', '>=', '!=', '&&', '||', '++', '--',
|
||||
'+', '-', '*', '/', '&', '|', '^', '%', '<<',
|
||||
'>>', '>>>', '+=', '-=', '*=', '/=', '&=', '|=',
|
||||
'^=', '%=', '<<=', '>>=', '>>>='
|
||||
comment: [
|
||||
[/[^\/*]+/, 'comment'],
|
||||
[/\/\*/, 'comment', '@push'],
|
||||
[/\/\*/, 'comment.invalid'],
|
||||
["\\*/", 'comment', '@pop'],
|
||||
[/[\/*]/, 'comment']
|
||||
],
|
||||
|
||||
symbols: /[=><!~?:&|+\-*\/^%]+/,
|
||||
escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,
|
||||
string: [
|
||||
[/[^\\"]+/, 'string'],
|
||||
[/@escapes/, 'string.escape'],
|
||||
[/\\./, 'string.escape.invalid'],
|
||||
[/"/, 'string', '@pop']
|
||||
],
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
// The main tokenizer for our languages
|
||||
tokenizer: {
|
||||
root: [
|
||||
// identifiers and keywords
|
||||
[/[a-z_$][\w$]*/, {
|
||||
cases: {
|
||||
'@typeKeywords': 'keyword',
|
||||
'@keywords': 'keyword',
|
||||
'@default': 'identifier'
|
||||
}
|
||||
}],
|
||||
[/[A-Z][\w$]*/, 'type.identifier'], // to show class names nicely
|
||||
|
||||
// whitespace
|
||||
{include: '@whitespace'},
|
||||
|
||||
// delimiters and operators
|
||||
[/[{}()\[\]]/, '@brackets'],
|
||||
[/[<>](?!@symbols)/, '@brackets'],
|
||||
[/@symbols/, {
|
||||
cases: {
|
||||
'@operators': 'operator',
|
||||
'@default': ''
|
||||
}
|
||||
}],
|
||||
|
||||
[/#!\[[^]*\]/, 'annotation'],
|
||||
[/#!.*$/, 'annotation.invalid'],
|
||||
|
||||
// numbers
|
||||
[/\d*\.\d+([eE][\-+]?\d+)?[fFdD]?/, 'number.float'],
|
||||
[/0[xX][0-9a-fA-F_]*[0-9a-fA-F][Ll]?/, 'number.hex'],
|
||||
[/0[0-7_]*[0-7][Ll]?/, 'number.octal'],
|
||||
[/0[bB][0-1_]*[0-1][Ll]?/, 'number.binary'],
|
||||
[/\d+[lL]?/, 'number'],
|
||||
|
||||
// delimiter: after number because of .\d floats
|
||||
[/[;,.]/, 'delimiter'],
|
||||
|
||||
// strings
|
||||
[/"([^"\\]|\\.)*$/, 'string.invalid'], // non-teminated string
|
||||
[/"/, 'string', '@string'],
|
||||
|
||||
// characters
|
||||
[/'[^\\']'/, 'string'],
|
||||
[/(')(@escapes)(')/, ['string', 'string.escape', 'string']],
|
||||
[/'/, 'string.invalid']
|
||||
],
|
||||
|
||||
whitespace: [
|
||||
[/[ \t\r\n]+/, 'white'],
|
||||
[/\/\*/, 'comment', '@comment'],
|
||||
[/\/\/.*$/, 'comment'],
|
||||
],
|
||||
|
||||
comment: [
|
||||
[/[^\/*]+/, 'comment'],
|
||||
[/\/\*/, 'comment', '@push'],
|
||||
[/\/\*/, 'comment.invalid'],
|
||||
["\\*/", 'comment', '@pop'],
|
||||
[/[\/*]/, 'comment']
|
||||
],
|
||||
|
||||
string: [
|
||||
[/[^\\"]+/, 'string'],
|
||||
[/@escapes/, 'string.escape'],
|
||||
[/\\./, 'string.escape.invalid'],
|
||||
[/"/, 'string', '@pop']
|
||||
],
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
monaco.languages.register({id: 'rust'});
|
||||
monaco.languages.setMonarchTokensProvider('rust', definition());
|
||||
});
|
||||
monaco.languages.register({id: 'rust'});
|
||||
monaco.languages.setMonarchTokensProvider('rust', definition());
|
||||
|
||||
+170
-172
@@ -23,190 +23,188 @@
|
||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
define(function (require) {
|
||||
"use strict";
|
||||
var $ = require('jquery');
|
||||
var _ = require('underscore');
|
||||
var colour = require('./colour');
|
||||
var themes = require('./themes').themes;
|
||||
var options = require('./options');
|
||||
"use strict";
|
||||
var $ = require('jquery');
|
||||
var _ = require('underscore');
|
||||
var colour = require('./colour');
|
||||
var themes = require('./themes').themes;
|
||||
var options = require('./options');
|
||||
|
||||
function Setting(elem, name, Control, param) {
|
||||
this.elem = elem;
|
||||
this.name = name;
|
||||
this.control = new Control(elem, param);
|
||||
function Setting(elem, name, Control, param) {
|
||||
this.elem = elem;
|
||||
this.name = name;
|
||||
this.control = new Control(elem, param);
|
||||
}
|
||||
|
||||
Setting.prototype.getUi = function () {
|
||||
return this.control.getUi(this.elem);
|
||||
};
|
||||
Setting.prototype.putUi = function (value) {
|
||||
this.control.putUi(this.elem, value);
|
||||
};
|
||||
|
||||
function Checkbox() {
|
||||
}
|
||||
|
||||
Checkbox.prototype.getUi = function (elem) {
|
||||
return !!elem.prop('checked');
|
||||
};
|
||||
Checkbox.prototype.putUi = function (elem, value) {
|
||||
elem.prop('checked', !!value);
|
||||
};
|
||||
|
||||
function Select(elem, populate) {
|
||||
elem.empty();
|
||||
_.each(populate, function (e) {
|
||||
elem.append($('<option value="' + e.label + '">' + e.desc + "</option>"));
|
||||
});
|
||||
}
|
||||
|
||||
Select.prototype.getUi = function (elem) {
|
||||
return elem.val();
|
||||
};
|
||||
Select.prototype.putUi = function (elem, value) {
|
||||
elem.val(value);
|
||||
};
|
||||
|
||||
function Slider(elem, sliderSettings) {
|
||||
elem.slider(sliderSettings);
|
||||
}
|
||||
|
||||
Slider.prototype.getUi = function (elem) {
|
||||
return elem.slider('getValue');
|
||||
};
|
||||
|
||||
Slider.prototype.putUi = function (elem, value) {
|
||||
elem.slider('setValue', value);
|
||||
};
|
||||
|
||||
function setupSettings(root, settings, onChange, langId) {
|
||||
settings = settings || {};
|
||||
|
||||
var settingsObjs = [];
|
||||
|
||||
function onUiChange() {
|
||||
var settings = {};
|
||||
_.each(settingsObjs, function (s) {
|
||||
settings[s.name] = s.getUi();
|
||||
});
|
||||
onChange(settings);
|
||||
}
|
||||
|
||||
Setting.prototype.getUi = function () {
|
||||
return this.control.getUi(this.elem);
|
||||
};
|
||||
Setting.prototype.putUi = function (value) {
|
||||
this.control.putUi(this.elem, value);
|
||||
};
|
||||
|
||||
function Checkbox() {
|
||||
}
|
||||
|
||||
Checkbox.prototype.getUi = function (elem) {
|
||||
return !!elem.prop('checked');
|
||||
};
|
||||
Checkbox.prototype.putUi = function (elem, value) {
|
||||
elem.prop('checked', !!value);
|
||||
};
|
||||
|
||||
function Select(elem, populate) {
|
||||
elem.empty();
|
||||
_.each(populate, function (e) {
|
||||
elem.append($('<option value="' + e.label + '">' + e.desc + "</option>"));
|
||||
function onSettingsChange(settings) {
|
||||
_.each(settingsObjs, function (s) {
|
||||
s.putUi(settings[s.name]);
|
||||
});
|
||||
}
|
||||
|
||||
Select.prototype.getUi = function (elem) {
|
||||
return elem.val();
|
||||
};
|
||||
Select.prototype.putUi = function (elem, value) {
|
||||
elem.val(value);
|
||||
};
|
||||
|
||||
function Slider(elem, sliderSettings) {
|
||||
elem.slider(sliderSettings);
|
||||
function add(elem, key, defaultValue, Type, param) {
|
||||
if (settings[key] === undefined)
|
||||
settings[key] = defaultValue;
|
||||
settingsObjs.push(new Setting(elem, key, Type, param));
|
||||
elem.change(onUiChange);
|
||||
}
|
||||
|
||||
Slider.prototype.getUi = function (elem) {
|
||||
return elem.slider('getValue');
|
||||
};
|
||||
|
||||
Slider.prototype.putUi = function (elem, value) {
|
||||
elem.slider('setValue', value);
|
||||
};
|
||||
|
||||
function setupSettings(root, settings, onChange, langId) {
|
||||
settings = settings || {};
|
||||
|
||||
var settingsObjs = [];
|
||||
|
||||
function onUiChange() {
|
||||
var settings = {};
|
||||
_.each(settingsObjs, function (s) {
|
||||
settings[s.name] = s.getUi();
|
||||
});
|
||||
onChange(settings);
|
||||
add(root.find('.colourise'), 'colouriseAsm', true, Checkbox);
|
||||
add(root.find('.autoCloseBrackets'), 'autoCloseBrackets', true, Checkbox);
|
||||
var colourSchemeSelect = root.find('.colourScheme');
|
||||
add(colourSchemeSelect, 'colourScheme', colour.schemes[0].name, Select,
|
||||
_.map(colour.schemes, function (scheme) {
|
||||
return {label: scheme.name, desc: scheme.desc};
|
||||
})
|
||||
);
|
||||
// Handle older settings
|
||||
if (settings.delayAfterChange === 0) {
|
||||
settings.delayAfterChange = 750;
|
||||
settings.compileOnChange = false;
|
||||
}
|
||||
add(root.find('.compileOnChange'), 'compileOnChange', true, Checkbox);
|
||||
add(root.find('.delay'), 'delayAfterChange', 750, Slider, {
|
||||
max: 3000,
|
||||
step: 250,
|
||||
min: 250,
|
||||
formatter: function (x) {
|
||||
return (x / 1000.0).toFixed(2) + "s";
|
||||
}
|
||||
});
|
||||
add(root.find('.hoverShowSource'), 'hoverShowSource', true, Checkbox);
|
||||
add(root.find('.hoverShowAsmDoc'), 'hoverShowAsmDoc', true, Checkbox);
|
||||
var themeSelect = root.find('.theme');
|
||||
add(themeSelect, 'theme', themes.default.id, Select,
|
||||
_.map(themes, function (theme) {
|
||||
return {label: theme.id, desc: theme.name};
|
||||
})
|
||||
);
|
||||
add(root.find('.showQuickSuggestions'), 'showQuickSuggestions', false, Checkbox);
|
||||
add(root.find('.useCustomContextMenu'), 'useCustomContextMenu', true, Checkbox);
|
||||
add(root.find('.showMinimap'), 'showMinimap', true, Checkbox);
|
||||
|
||||
function onSettingsChange(settings) {
|
||||
_.each(settingsObjs, function (s) {
|
||||
s.putUi(settings[s.name]);
|
||||
});
|
||||
}
|
||||
|
||||
function add(elem, key, defaultValue, Type, param) {
|
||||
if (settings[key] === undefined)
|
||||
settings[key] = defaultValue;
|
||||
settingsObjs.push(new Setting(elem, key, Type, param));
|
||||
elem.change(onUiChange);
|
||||
}
|
||||
|
||||
add(root.find('.colourise'), 'colouriseAsm', true, Checkbox);
|
||||
add(root.find('.autoCloseBrackets'), 'autoCloseBrackets', true, Checkbox);
|
||||
var colourSchemeSelect = root.find('.colourScheme');
|
||||
add(colourSchemeSelect, 'colourScheme', colour.schemes[0].name, Select,
|
||||
_.map(colour.schemes, function (scheme) {
|
||||
return {label: scheme.name, desc: scheme.desc};
|
||||
})
|
||||
);
|
||||
// Handle older settings
|
||||
if (settings.delayAfterChange === 0) {
|
||||
settings.delayAfterChange = 750;
|
||||
settings.compileOnChange = false;
|
||||
}
|
||||
add(root.find('.compileOnChange'), 'compileOnChange', true, Checkbox);
|
||||
add(root.find('.delay'), 'delayAfterChange', 750, Slider, {
|
||||
max: 3000,
|
||||
step: 250,
|
||||
min: 250,
|
||||
formatter: function (x) {
|
||||
return (x / 1000.0).toFixed(2) + "s";
|
||||
}
|
||||
});
|
||||
add(root.find('.hoverShowSource'), 'hoverShowSource', true, Checkbox);
|
||||
add(root.find('.hoverShowAsmDoc'), 'hoverShowAsmDoc', true, Checkbox);
|
||||
var themeSelect = root.find('.theme');
|
||||
add(themeSelect, 'theme', themes.default.id, Select,
|
||||
_.map(themes, function (theme) {
|
||||
return {label: theme.id, desc: theme.name};
|
||||
})
|
||||
);
|
||||
add(root.find('.showQuickSuggestions'), 'showQuickSuggestions', false, Checkbox);
|
||||
add(root.find('.useCustomContextMenu'), 'useCustomContextMenu', true, Checkbox);
|
||||
add(root.find('.showMinimap'), 'showMinimap', true, Checkbox);
|
||||
|
||||
function handleThemes() {
|
||||
var newTheme = themeSelect.val();
|
||||
// Store the scheme of the old theme
|
||||
$.data(themeSelect, 'theme-' + $.data(themeSelect, 'last-theme'), colourSchemeSelect.val());
|
||||
// Get the scheme of the new theme
|
||||
var newThemeStoredScheme = $.data(themeSelect, 'theme-' + newTheme);
|
||||
var isStoredUsable = false;
|
||||
colourSchemeSelect.empty();
|
||||
_.each(colour.schemes, function (scheme) {
|
||||
if (!scheme.themes || scheme.themes.length === 0 || scheme.themes.indexOf(newTheme) !== -1 || scheme.themes.indexOf('all') !== -1) {
|
||||
colourSchemeSelect.append($('<option value="' + scheme.name + '">' + scheme.desc + "</option>"));
|
||||
if (newThemeStoredScheme === scheme.name) {
|
||||
isStoredUsable = true;
|
||||
}
|
||||
function handleThemes() {
|
||||
var newTheme = themeSelect.val();
|
||||
// Store the scheme of the old theme
|
||||
$.data(themeSelect, 'theme-' + $.data(themeSelect, 'last-theme'), colourSchemeSelect.val());
|
||||
// Get the scheme of the new theme
|
||||
var newThemeStoredScheme = $.data(themeSelect, 'theme-' + newTheme);
|
||||
var isStoredUsable = false;
|
||||
colourSchemeSelect.empty();
|
||||
_.each(colour.schemes, function (scheme) {
|
||||
if (!scheme.themes || scheme.themes.length === 0 || scheme.themes.indexOf(newTheme) !== -1 || scheme.themes.indexOf('all') !== -1) {
|
||||
colourSchemeSelect.append($('<option value="' + scheme.name + '">' + scheme.desc + "</option>"));
|
||||
if (newThemeStoredScheme === scheme.name) {
|
||||
isStoredUsable = true;
|
||||
}
|
||||
});
|
||||
if (colourSchemeSelect.children().length >= 1) {
|
||||
colourSchemeSelect.val(isStoredUsable ? newThemeStoredScheme : colourSchemeSelect.first().val());
|
||||
} else {
|
||||
// This should never happen. In case it does, lets use the default one
|
||||
colourSchemeSelect.append($('<option value="' + colour.schemes[0].name + '">' + colour.schemes[0].desc + "</option>"));
|
||||
colourSchemeSelect.val(colourSchemeSelect.first().val());
|
||||
}
|
||||
colourSchemeSelect.trigger('change');
|
||||
}
|
||||
|
||||
var langs = options.languages;
|
||||
|
||||
var defaultLanguageSelector = root.find('.defaultLanguage');
|
||||
var defLang = settings.defaultLanguage || _.keys(langs)[0] || 'c++';
|
||||
add(defaultLanguageSelector, 'defaultLanguage', defLang, Select,
|
||||
_.map(langs, function (lang) {
|
||||
return {label: lang.id, desc: lang.name};
|
||||
})
|
||||
);
|
||||
|
||||
defaultLanguageSelector.val(defLang);
|
||||
if (langId) {
|
||||
defaultLanguageSelector
|
||||
.prop('disabled', true)
|
||||
.prop('title', 'Default language inherited from subdomain')
|
||||
.css('cursor', 'not-allowed');
|
||||
}
|
||||
|
||||
add(root.find('.newEditorLastLang'), 'newEditorLastLang', true, Checkbox);
|
||||
|
||||
function setSettings(settings) {
|
||||
onSettingsChange(settings);
|
||||
onChange(settings);
|
||||
}
|
||||
|
||||
add(root.find('.tabWidth'), 'tabWidth', 4, Select,
|
||||
_.map([2, 4, 8], function (size) {
|
||||
return {label: size, desc: size};
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
setSettings(settings);
|
||||
handleThemes();
|
||||
themeSelect.change(function () {
|
||||
handleThemes();
|
||||
$.data(themeSelect, 'last-theme', themeSelect.val());
|
||||
});
|
||||
$.data(themeSelect, 'last-theme', themeSelect.val());
|
||||
return setSettings;
|
||||
if (colourSchemeSelect.children().length >= 1) {
|
||||
colourSchemeSelect.val(isStoredUsable ? newThemeStoredScheme : colourSchemeSelect.first().val());
|
||||
} else {
|
||||
// This should never happen. In case it does, lets use the default one
|
||||
colourSchemeSelect.append($('<option value="' + colour.schemes[0].name + '">' + colour.schemes[0].desc + "</option>"));
|
||||
colourSchemeSelect.val(colourSchemeSelect.first().val());
|
||||
}
|
||||
colourSchemeSelect.trigger('change');
|
||||
}
|
||||
|
||||
return setupSettings;
|
||||
});
|
||||
var langs = options.languages;
|
||||
|
||||
var defaultLanguageSelector = root.find('.defaultLanguage');
|
||||
var defLang = settings.defaultLanguage || _.keys(langs)[0] || 'c++';
|
||||
add(defaultLanguageSelector, 'defaultLanguage', defLang, Select,
|
||||
_.map(langs, function (lang) {
|
||||
return {label: lang.id, desc: lang.name};
|
||||
})
|
||||
);
|
||||
|
||||
defaultLanguageSelector.val(defLang);
|
||||
if (langId) {
|
||||
defaultLanguageSelector
|
||||
.prop('disabled', true)
|
||||
.prop('title', 'Default language inherited from subdomain')
|
||||
.css('cursor', 'not-allowed');
|
||||
}
|
||||
|
||||
add(root.find('.newEditorLastLang'), 'newEditorLastLang', true, Checkbox);
|
||||
|
||||
function setSettings(settings) {
|
||||
onSettingsChange(settings);
|
||||
onChange(settings);
|
||||
}
|
||||
|
||||
add(root.find('.tabWidth'), 'tabWidth', 4, Select,
|
||||
_.map([2, 4, 8], function (size) {
|
||||
return {label: size, desc: size};
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
setSettings(settings);
|
||||
handleThemes();
|
||||
themeSelect.change(function () {
|
||||
handleThemes();
|
||||
$.data(themeSelect, 'last-theme', themeSelect.val());
|
||||
});
|
||||
$.data(themeSelect, 'last-theme', themeSelect.val());
|
||||
return setSettings;
|
||||
}
|
||||
|
||||
module.exports = setupSettings;
|
||||
|
||||
+2
-4
@@ -23,14 +23,13 @@
|
||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
define(function (require) {
|
||||
"use strict";
|
||||
var $ = require('jquery');
|
||||
var _ = require('underscore');
|
||||
var options = require('options');
|
||||
var shortenURL = require('urlshorten-google');
|
||||
var Components = require('components');
|
||||
var url = require('url');
|
||||
var url = require('./url');
|
||||
|
||||
function configFromEmbedded(embeddedUrl) {
|
||||
// Old-style link?
|
||||
@@ -141,8 +140,7 @@ define(function (require) {
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
module.exports = {
|
||||
initShareButton: initShareButton,
|
||||
configFromEmbedded: configFromEmbedded
|
||||
};
|
||||
});
|
||||
|
||||
+47
-50
@@ -23,57 +23,54 @@
|
||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
define(function (require) {
|
||||
"use strict";
|
||||
var $ = require('jquery');
|
||||
var _ = require('underscore');
|
||||
var monaco = require('monaco');
|
||||
var themes = {
|
||||
default: {
|
||||
path: "./themes/explorer-default.css",
|
||||
id: "default",
|
||||
name: "Default",
|
||||
monaco: "vs" // Optional field
|
||||
},
|
||||
dark: {
|
||||
path: "./themes/dark/theme-dark.css",
|
||||
id: "dark",
|
||||
name: "Dark",
|
||||
monaco: "vs-dark"
|
||||
}
|
||||
};
|
||||
"use strict";
|
||||
var $ = require('jquery');
|
||||
var _ = require('underscore');
|
||||
|
||||
function Themer(eventHub, initialSettings) {
|
||||
this.currentTheme = null;
|
||||
this.eventHub = eventHub;
|
||||
|
||||
this.setTheme = function (theme) {
|
||||
if (this.currentTheme === theme) return;
|
||||
$.get(require.toUrl(theme.path), _.bind(function (cssData) {
|
||||
$('#theme').html(cssData);
|
||||
monaco.editor.setTheme(theme.monaco);
|
||||
this.eventHub.emit('resize');
|
||||
}, this));
|
||||
this.currentTheme = theme;
|
||||
};
|
||||
|
||||
this.onSettingsChange = function (newSettings) {
|
||||
var newTheme = themes[newSettings.theme] || themes.default;
|
||||
if (!newTheme.monaco)
|
||||
newTheme.monaco = "vs";
|
||||
this.setTheme(newTheme);
|
||||
};
|
||||
this.onSettingsChange(initialSettings);
|
||||
|
||||
this.eventHub.on('settingsChange', this.onSettingsChange, this);
|
||||
|
||||
this.eventHub.on('requestTheme', function () {
|
||||
this.eventHub.emit('themeChange', this.currentTheme);
|
||||
}, this);
|
||||
var themes = {
|
||||
default: {
|
||||
path: "default",
|
||||
id: "default",
|
||||
name: "Default",
|
||||
monaco: "vs" // Optional field
|
||||
},
|
||||
dark: {
|
||||
path: "dark",
|
||||
id: "dark",
|
||||
name: "Dark",
|
||||
monaco: "vs-dark"
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
themes: themes,
|
||||
Themer: Themer
|
||||
function Themer(eventHub, initialSettings) {
|
||||
this.currentTheme = null;
|
||||
this.eventHub = eventHub;
|
||||
|
||||
this.setTheme = function (theme) {
|
||||
if (this.currentTheme === theme) return;
|
||||
var cssData = require('./themes/' + theme.path + "-theme.css");
|
||||
$('#theme').html(cssData.toString());
|
||||
monaco.editor.setTheme(theme.monaco);
|
||||
this.eventHub.emit('resize');
|
||||
this.currentTheme = theme;
|
||||
};
|
||||
});
|
||||
|
||||
this.onSettingsChange = function (newSettings) {
|
||||
var newTheme = themes[newSettings.theme] || themes.default;
|
||||
if (!newTheme.monaco)
|
||||
newTheme.monaco = "vs";
|
||||
this.setTheme(newTheme);
|
||||
};
|
||||
this.onSettingsChange(initialSettings);
|
||||
|
||||
this.eventHub.on('settingsChange', this.onSettingsChange, this);
|
||||
|
||||
this.eventHub.on('requestTheme', function () {
|
||||
this.eventHub.emit('themeChange', this.currentTheme);
|
||||
}, this);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
themes: themes,
|
||||
Themer: Themer
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
@import url("../../ext/golden-layout/src/css/goldenlayout-dark-theme.css");
|
||||
@import url("~golden-layout/src/css/goldenlayout-dark-theme.css");
|
||||
|
||||
.navbar-inverse {
|
||||
background-color: #000;
|
||||
@@ -1,4 +1,4 @@
|
||||
@import url("../../ext/golden-layout/src/css/goldenlayout-dark-theme.css");
|
||||
@import url("~golden-layout/src/css/goldenlayout-dark-theme.css");
|
||||
|
||||
body {
|
||||
background-color: #333 !important;
|
||||
@@ -1,4 +1,4 @@
|
||||
@import url("../ext/golden-layout/src/css/goldenlayout-light-theme.css");
|
||||
@import url("~golden-layout/src/css/goldenlayout-light-theme.css");
|
||||
|
||||
.navbar-inverse {
|
||||
background-color: #226;
|
||||
+1
-3
@@ -23,7 +23,6 @@
|
||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
define(function (require) {
|
||||
"use strict";
|
||||
var _ = require('underscore');
|
||||
var $ = require('jquery');
|
||||
@@ -77,5 +76,4 @@ define(function (require) {
|
||||
}.bind(this));
|
||||
};
|
||||
|
||||
return Toggles;
|
||||
});
|
||||
module.exports = Toggles;
|
||||
|
||||
+89
-92
@@ -22,105 +22,102 @@
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
"use strict";
|
||||
var GoldenLayout = require('goldenlayout');
|
||||
var rison = require('rison');
|
||||
var $ = require('jquery');
|
||||
var Components = require('components');
|
||||
var lzstring = require('lzstring');
|
||||
var _ = require('underscore');
|
||||
|
||||
define(function (require) {
|
||||
"use strict";
|
||||
var GoldenLayout = require('goldenlayout');
|
||||
var rison = require('rison');
|
||||
var $ = require('jquery');
|
||||
var Components = require('components');
|
||||
var lzstring = require('lzstring');
|
||||
var _ = require('underscore');
|
||||
function convertOldState(state) {
|
||||
var sc = state.compilers[0];
|
||||
if (!sc) throw new Error("Unable to determine compiler from old state");
|
||||
var content = [];
|
||||
var source;
|
||||
if (sc.sourcez) {
|
||||
source = lzstring.decompressFromBase64(sc.sourcez);
|
||||
} else {
|
||||
source = sc.source;
|
||||
}
|
||||
var options = {compileOnChange: true, colouriseAsm: state.filterAsm.colouriseAsm};
|
||||
var filters = _.clone(state.filterAsm);
|
||||
delete filters.colouriseAsm;
|
||||
content.push(Components.getEditorWith(1, source, options));
|
||||
content.push(Components.getCompilerWith(1, filters, sc.options, sc.compiler));
|
||||
return {version: 4, content: [{type: 'row', content: content}]};
|
||||
}
|
||||
|
||||
function convertOldState(state) {
|
||||
var sc = state.compilers[0];
|
||||
if (!sc) throw new Error("Unable to determine compiler from old state");
|
||||
var content = [];
|
||||
var source;
|
||||
if (sc.sourcez) {
|
||||
source = lzstring.decompressFromBase64(sc.sourcez);
|
||||
} else {
|
||||
source = sc.source;
|
||||
function loadState(state) {
|
||||
if (!state || state.version === undefined) return false;
|
||||
switch (state.version) {
|
||||
case 1:
|
||||
state.filterAsm = {};
|
||||
state.version = 2;
|
||||
/* falls through */
|
||||
case 2:
|
||||
state.compilers = [state];
|
||||
state.version = 3;
|
||||
/* falls through */
|
||||
case 3:
|
||||
state = convertOldState(state);
|
||||
break; // no fall through
|
||||
case 4:
|
||||
state = GoldenLayout.unminifyConfig(state);
|
||||
break;
|
||||
default:
|
||||
throw new Error("Invalid version '" + state.version + "'");
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
function risonify(obj) {
|
||||
return rison.quote(rison.encode_object(obj));
|
||||
}
|
||||
|
||||
function unrisonify(text) {
|
||||
return rison.decode_object(decodeURIComponent(text.replace(/\+/g, '%20')));
|
||||
}
|
||||
|
||||
function deserialiseState(stateText) {
|
||||
var state;
|
||||
var exception;
|
||||
try {
|
||||
state = unrisonify(stateText);
|
||||
if (state && state.z) {
|
||||
state = unrisonify(lzstring.decompressFromBase64(state.z));
|
||||
}
|
||||
var options = {compileOnChange: true, colouriseAsm: state.filterAsm.colouriseAsm};
|
||||
var filters = _.clone(state.filterAsm);
|
||||
delete filters.colouriseAsm;
|
||||
content.push(Components.getEditorWith(1, source, options));
|
||||
content.push(Components.getCompilerWith(1, filters, sc.options, sc.compiler));
|
||||
return {version: 4, content: [{type: 'row', content: content}]};
|
||||
} catch (ex) {
|
||||
exception = ex;
|
||||
}
|
||||
|
||||
function loadState(state) {
|
||||
if (!state || state.version === undefined) return false;
|
||||
switch (state.version) {
|
||||
case 1:
|
||||
state.filterAsm = {};
|
||||
state.version = 2;
|
||||
/* falls through */
|
||||
case 2:
|
||||
state.compilers = [state];
|
||||
state.version = 3;
|
||||
/* falls through */
|
||||
case 3:
|
||||
state = convertOldState(state);
|
||||
break; // no fall through
|
||||
case 4:
|
||||
state = GoldenLayout.unminifyConfig(state);
|
||||
break;
|
||||
default:
|
||||
throw new Error("Invalid version '" + state.version + "'");
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
function risonify(obj) {
|
||||
return rison.quote(rison.encode_object(obj));
|
||||
}
|
||||
|
||||
function unrisonify(text) {
|
||||
return rison.decode_object(decodeURIComponent(text.replace(/\+/g, '%20')));
|
||||
}
|
||||
|
||||
function deserialiseState(stateText) {
|
||||
var state;
|
||||
var exception;
|
||||
if (!state) {
|
||||
try {
|
||||
state = unrisonify(stateText);
|
||||
if (state && state.z) {
|
||||
state = unrisonify(lzstring.decompressFromBase64(state.z));
|
||||
}
|
||||
state = $.parseJSON(decodeURIComponent(stateText));
|
||||
} catch (ex) {
|
||||
exception = ex;
|
||||
}
|
||||
|
||||
if (!state) {
|
||||
try {
|
||||
state = $.parseJSON(decodeURIComponent(stateText));
|
||||
} catch (ex) {
|
||||
if (!exception) exception = ex;
|
||||
}
|
||||
}
|
||||
if (!state && exception) throw exception;
|
||||
return loadState(state);
|
||||
}
|
||||
|
||||
function serialiseState(stateText) {
|
||||
var ctx = GoldenLayout.minifyConfig({content: stateText.content});
|
||||
ctx.version = 4;
|
||||
var uncompressed = risonify(ctx);
|
||||
var compressed = risonify({z: lzstring.compressToBase64(uncompressed)});
|
||||
var MinimalSavings = 0.20; // at least this ratio smaller
|
||||
if (compressed.length < uncompressed.length * (1.0 - MinimalSavings)) {
|
||||
return compressed;
|
||||
} else {
|
||||
return uncompressed;
|
||||
if (!exception) exception = ex;
|
||||
}
|
||||
}
|
||||
if (!state && exception) throw exception;
|
||||
return loadState(state);
|
||||
}
|
||||
|
||||
return {
|
||||
deserialiseState: deserialiseState,
|
||||
serialiseState: serialiseState,
|
||||
unrisonify: unrisonify,
|
||||
risonify: risonify
|
||||
};
|
||||
});
|
||||
function serialiseState(stateText) {
|
||||
var ctx = GoldenLayout.minifyConfig({content: stateText.content});
|
||||
ctx.version = 4;
|
||||
var uncompressed = risonify(ctx);
|
||||
var compressed = risonify({z: lzstring.compressToBase64(uncompressed)});
|
||||
var MinimalSavings = 0.20; // at least this ratio smaller
|
||||
if (compressed.length < uncompressed.length * (1.0 - MinimalSavings)) {
|
||||
return compressed;
|
||||
} else {
|
||||
return uncompressed;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
deserialiseState: deserialiseState,
|
||||
serialiseState: serialiseState,
|
||||
unrisonify: unrisonify,
|
||||
risonify: risonify
|
||||
};
|
||||
|
||||
+35
-37
@@ -23,45 +23,43 @@
|
||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
define(function (require) {
|
||||
"use strict";
|
||||
var options = require('options');
|
||||
var Alert = require('alert');
|
||||
var $ = require('jquery');
|
||||
"use strict";
|
||||
var options = require('options');
|
||||
var Alert = require('alert');
|
||||
var $ = require('jquery');
|
||||
|
||||
function googleJSClientLoaded() {
|
||||
var gapi = window.gapi;
|
||||
gapi.client.setApiKey(options.gapiKey);
|
||||
gapi.client.load('urlshortener', 'v1', googleJSClientLoaded.done);
|
||||
function googleJSClientLoaded() {
|
||||
var gapi = window.gapi;
|
||||
gapi.client.setApiKey(options.gapiKey);
|
||||
gapi.client.load('urlshortener', 'v1', googleJSClientLoaded.done);
|
||||
}
|
||||
|
||||
function shortenURL(url, done) {
|
||||
var gapi = window.gapi;
|
||||
if (!gapi || !gapi.client || !gapi.client.urlshortener) {
|
||||
// Load the Google APIs client library asynchronously, then the
|
||||
// urlshortener API, and finally come back here.
|
||||
window.googleJSClientLoaded = googleJSClientLoaded;
|
||||
googleJSClientLoaded.done = function () {
|
||||
shortenURL(url, done);
|
||||
};
|
||||
$(document.body).append('<script src="https://apis.google.com/js/client.js?onload=googleJSClientLoaded">');
|
||||
return;
|
||||
}
|
||||
|
||||
function shortenURL(url, done) {
|
||||
var gapi = window.gapi;
|
||||
if (!gapi || !gapi.client || !gapi.client.urlshortener) {
|
||||
// Load the Google APIs client library asynchronously, then the
|
||||
// urlshortener API, and finally come back here.
|
||||
window.googleJSClientLoaded = googleJSClientLoaded;
|
||||
googleJSClientLoaded.done = function () {
|
||||
shortenURL(url, done);
|
||||
};
|
||||
$(document.body).append('<script src="https://apis.google.com/js/client.js?onload=googleJSClientLoaded">');
|
||||
return;
|
||||
var request = gapi.client.urlshortener.url.insert({resource: {longUrl: url}});
|
||||
request.then(function (resp) {
|
||||
var id = resp.result.id;
|
||||
if (options.googleShortLinkRewrite.length === 2) {
|
||||
id = id.replace(new RegExp(options.googleShortLinkRewrite[0]), options.googleShortLinkRewrite[1]);
|
||||
}
|
||||
var request = gapi.client.urlshortener.url.insert({resource: {longUrl: url}});
|
||||
request.then(function (resp) {
|
||||
var id = resp.result.id;
|
||||
if (options.googleShortLinkRewrite.length === 2) {
|
||||
id = id.replace(new RegExp(options.googleShortLinkRewrite[0]), options.googleShortLinkRewrite[1]);
|
||||
}
|
||||
done(id);
|
||||
}, function () {
|
||||
new Alert().notify("The URL could not be shortened. It probaly exceeds the Google URL Shortener length limits.", {
|
||||
group: "urltoolong",
|
||||
alertClass: "notification-error"
|
||||
});
|
||||
done(url);
|
||||
done(id);
|
||||
}, function () {
|
||||
new Alert().notify("The URL could not be shortened. It probaly exceeds the Google URL Shortener length limits.", {
|
||||
group: "urltoolong",
|
||||
alertClass: "notification-error"
|
||||
});
|
||||
}
|
||||
done(url);
|
||||
});
|
||||
}
|
||||
|
||||
return shortenURL;
|
||||
});
|
||||
module.exports = shortenURL;
|
||||
+2
-2
@@ -5,7 +5,7 @@ meta(name="description" content="Compiler Explorer is an interactive online comp
|
||||
meta(name="author" content="Matt Godbolt")
|
||||
meta(name="google" content="nositelinkssearchbox")
|
||||
meta(name="google" content="notranslate")
|
||||
link(href=root + "explorer.css" rel="stylesheet")
|
||||
link(href=require("main.css") rel="stylesheet")
|
||||
style#theme
|
||||
script window.compilerExplorerOptions = !{compilerExplorerOptions}
|
||||
script(data-main=root + "main" src=root + "ext/requirejs/require.js")
|
||||
script(src=require("main.js"))
|
||||
|
||||
+5
-4
@@ -1,6 +1,7 @@
|
||||
doctype html
|
||||
html(lang="en")
|
||||
head
|
||||
include monaco.pug
|
||||
include head.pug
|
||||
body(class=extraBodyClass)
|
||||
.navbar.navbar-inverse
|
||||
@@ -31,18 +32,18 @@ html(lang="en")
|
||||
li
|
||||
a(href="https://www.patreon.com/bePatron?u=3691963"
|
||||
title="Help Compiler Explorer - become a Patron" target="_blank" rel="noopener")
|
||||
img(height="20" width="20" src=root + "assets/patreon_logo.png")
|
||||
img(height="20" width="20" src=require("patreon_logo.png"))
|
||||
| Become a Patron
|
||||
if githubEnabled
|
||||
li
|
||||
a(href="https://github.com/mattgodbolt/compiler-explorer"
|
||||
title="View the source on GitHub" target="_blank" rel="noopener")
|
||||
img(height="20" width="20" src=root + "assets/GitHub-Mark-20px.png")
|
||||
img(height="20" width="20" src=require("GitHub-Mark-20px.png"))
|
||||
| Source on GitHub
|
||||
li
|
||||
a(href="https://groups.google.com/forum/#!forum/compiler-explorer-discussion"
|
||||
title="Join Compiler Explorer Public Google Group" target="_blank" rel="noopener")
|
||||
img(height="20" width="20" src=root + "assets/Google-Groups-20px.png")
|
||||
img(height="20" width="20" src=require("Google-Groups-20px.png"))
|
||||
| Mailing list
|
||||
li: a(href="https://github.com/mattgodbolt/compiler-explorer/wiki/Installed-libraries" target="_blank" rel="noopener") Installed libraries
|
||||
li: a(href="https://github.com/mattgodbolt/compiler-explorer/wiki" target="_blank" rel="noopener") Wiki
|
||||
@@ -81,7 +82,7 @@ html(lang="en")
|
||||
type="button" data-clipboard-target=".popover .permalink"
|
||||
title="Copy to clipboard")
|
||||
img.clippy(
|
||||
src=root + "assets/clippy.svg" width="13px"
|
||||
src = require("clippy.svg") width="13px"
|
||||
alt="Copy to clipboard")
|
||||
.lang
|
||||
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
script(src="vs/loader.js")
|
||||
@@ -0,0 +1,136 @@
|
||||
const path = require('path'),
|
||||
webpack = require('webpack'),
|
||||
CopyWebpackPlugin = require('copy-webpack-plugin'),
|
||||
ExtractTextPlugin = require('extract-text-webpack-plugin'),
|
||||
ManifestPlugin = require('webpack-manifest-plugin'),
|
||||
glob = require("glob"),
|
||||
UglifyJsPlugin = require('uglifyjs-webpack-plugin');
|
||||
|
||||
const isDev = process.env.NODE_ENV === "DEV";
|
||||
|
||||
const outputPathRelative = 'dist/';
|
||||
const staticRelative = 'static/';
|
||||
const staticPath = path.resolve(__dirname, staticRelative);
|
||||
const distPath = path.join(staticPath, outputPathRelative);
|
||||
const vsPath = path.join(staticPath, 'vs/');
|
||||
const assetPath = path.join(staticPath, "assets");
|
||||
const manifestPath = 'manifest.json'; //if you change this, you also need to update it in the app.js
|
||||
const outputname =isDev ? 'main.js' : 'bundle.[hash].js';
|
||||
const cssName = isDev ? '[name].css' : "[name].[contenthash].css";
|
||||
const publicPath = isDev ? '/dist/' : 'dist/';
|
||||
const manifestPlugin = new ManifestPlugin({
|
||||
fileName: manifestPath
|
||||
});
|
||||
|
||||
|
||||
const assetEntries = glob.sync(`${assetPath}/**/*.*`).reduce((obj, p) => {
|
||||
const key = path.basename(p);
|
||||
obj[key] = p;
|
||||
return obj;
|
||||
}, {});
|
||||
|
||||
let plugins = [
|
||||
new CopyWebpackPlugin([{
|
||||
from: 'node_modules/monaco-editor/min/vs',
|
||||
to: vsPath,
|
||||
},
|
||||
{
|
||||
from: path.join(staticPath, "favicon.ico"),
|
||||
to: distPath,
|
||||
},
|
||||
]),
|
||||
new webpack.ProvidePlugin({
|
||||
$: 'jquery',
|
||||
jQuery: 'jquery'
|
||||
}),
|
||||
new ExtractTextPlugin(cssName),
|
||||
manifestPlugin
|
||||
];
|
||||
|
||||
if(!isDev) {
|
||||
plugins.push(new UglifyJsPlugin({
|
||||
sourceMap: true
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
module.exports = [
|
||||
//if you change the order of this, make sure to update the config variable in app.js
|
||||
//server side stuff
|
||||
// currently we just want to shove a cache path onto the static assets so we can get the hash onto the filename
|
||||
//this means we can set the cache for eternity
|
||||
{
|
||||
entry: assetEntries,
|
||||
output: {
|
||||
path: path.join(distPath, 'assets'),
|
||||
filename: '.[name].ignoreme',
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.(png|woff|woff2|eot|ttf|svg)$/,
|
||||
use: [{
|
||||
loader: 'file-loader',
|
||||
options: {
|
||||
name: '[name].[hash].[ext]'
|
||||
}
|
||||
}]
|
||||
},
|
||||
],
|
||||
},
|
||||
plugins:[
|
||||
manifestPlugin
|
||||
]
|
||||
},
|
||||
//this is the client side
|
||||
{
|
||||
entry: './static/main.js',
|
||||
output: {
|
||||
filename: outputname,
|
||||
path: distPath,
|
||||
publicPath: publicPath
|
||||
},
|
||||
resolve: {
|
||||
modules: ['./static', "./node_modules"],
|
||||
alias: {
|
||||
//is this safe?
|
||||
goldenlayout: path.resolve(__dirname, 'node_modules/golden-layout/'),
|
||||
lzstring: path.resolve(__dirname, 'node_modules/lz-string/'),
|
||||
filesaver: path.resolve(__dirname, 'node_modules/file-saver/'),
|
||||
vs: path.resolve(__dirname, 'node_modules/monaco-editor/min/vs')
|
||||
}
|
||||
},
|
||||
stats: "errors-only",
|
||||
devtool: 'source-map',
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.css$/,
|
||||
exclude: path.resolve(__dirname, 'static/themes/'),
|
||||
use: ExtractTextPlugin.extract({
|
||||
fallback: 'style-loader',
|
||||
use: 'css-loader',
|
||||
publicPath: './'
|
||||
})
|
||||
},
|
||||
{
|
||||
test: /\.css$/,
|
||||
include: path.resolve(__dirname, 'static/themes/'),
|
||||
use: ['css-loader']
|
||||
},
|
||||
{
|
||||
test: /\.(png|woff|woff2|eot|ttf|svg)$/,
|
||||
loader: 'url-loader?limit=8192'
|
||||
},
|
||||
{
|
||||
test: /\.(html)$/,
|
||||
loader: 'html-loader',
|
||||
options: {
|
||||
minimize: !isDev
|
||||
}
|
||||
}
|
||||
]},
|
||||
plugins: plugins
|
||||
},
|
||||
|
||||
];
|
||||
Reference in New Issue
Block a user