|
|
@ -46,10 +46,13 @@ window.addEventListener('message', function (ev) { |
|
|
|
var run = function () { |
|
|
|
var run = function () { |
|
|
|
var self = this |
|
|
|
var self = this |
|
|
|
this.event = new EventManager() |
|
|
|
this.event = new EventManager() |
|
|
|
var storage = new Storage() |
|
|
|
var fileStorage = new Storage('sol:') |
|
|
|
var files = new Files(storage) |
|
|
|
var files = new Files(fileStorage) |
|
|
|
var config = new Config(storage) |
|
|
|
var config = new Config(fileStorage) |
|
|
|
var currentFile |
|
|
|
var uiStorage = new Storage('sol-ui:') |
|
|
|
|
|
|
|
var ui = new Files(uiStorage) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ui.set('currentFile', '') |
|
|
|
|
|
|
|
|
|
|
|
// return all the files, except the temporary/readonly ones
|
|
|
|
// return all the files, except the temporary/readonly ones
|
|
|
|
function packageFiles () { |
|
|
|
function packageFiles () { |
|
|
@ -183,7 +186,8 @@ var run = function () { |
|
|
|
filepanel.className = css.filepanel |
|
|
|
filepanel.className = css.filepanel |
|
|
|
var FilePanelAPI = { |
|
|
|
var FilePanelAPI = { |
|
|
|
createName: createNonClashingName, |
|
|
|
createName: createNonClashingName, |
|
|
|
switchToFile: switchToFile |
|
|
|
switchToFile: switchToFile, |
|
|
|
|
|
|
|
ui: ui.event |
|
|
|
} |
|
|
|
} |
|
|
|
var el = new FilePanel(FilePanelAPI, files) |
|
|
|
var el = new FilePanel(FilePanelAPI, files) |
|
|
|
filepanel.appendChild(el) |
|
|
|
filepanel.appendChild(el) |
|
|
@ -220,7 +224,7 @@ var run = function () { |
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
files.event.register('fileRemoved', function (path) { |
|
|
|
files.event.register('fileRemoved', function (path) { |
|
|
|
if (path === currentFile) currentFile = null |
|
|
|
if (path === ui.get('currentFile')) ui.set('currentFile', '') |
|
|
|
}) |
|
|
|
}) |
|
|
|
// ------------------ gist publish --------------
|
|
|
|
// ------------------ gist publish --------------
|
|
|
|
|
|
|
|
|
|
|
@ -318,7 +322,7 @@ var run = function () { |
|
|
|
if (!files.rename(originalName, newName)) { |
|
|
|
if (!files.rename(originalName, newName)) { |
|
|
|
alert('Error while renaming file') |
|
|
|
alert('Error while renaming file') |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
currentFile = null |
|
|
|
ui.set('currentFile', '') |
|
|
|
switchToFile(newName) |
|
|
|
switchToFile(newName) |
|
|
|
editor.discard(originalName) |
|
|
|
editor.discard(originalName) |
|
|
|
} |
|
|
|
} |
|
|
@ -339,7 +343,7 @@ var run = function () { |
|
|
|
if (!files.remove(name)) { |
|
|
|
if (!files.remove(name)) { |
|
|
|
alert('Error while removing file') |
|
|
|
alert('Error while removing file') |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
currentFile = null |
|
|
|
ui.set('currentFile', '') |
|
|
|
switchToNextFile() |
|
|
|
switchToNextFile() |
|
|
|
editor.discard(name) |
|
|
|
editor.discard(name) |
|
|
|
} |
|
|
|
} |
|
|
@ -352,9 +356,7 @@ var run = function () { |
|
|
|
function switchToFile (file) { |
|
|
|
function switchToFile (file) { |
|
|
|
editorSyncFile() |
|
|
|
editorSyncFile() |
|
|
|
|
|
|
|
|
|
|
|
currentFile = file |
|
|
|
ui.set('currentFile', file) |
|
|
|
|
|
|
|
|
|
|
|
files.event.trigger('fileFocus', [file]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (files.isReadOnly(file)) { |
|
|
|
if (files.isReadOnly(file)) { |
|
|
|
editor.openReadOnly(file, files.get(file)) |
|
|
|
editor.openReadOnly(file, files.get(file)) |
|
|
@ -385,10 +387,10 @@ var run = function () { |
|
|
|
$filesEl.append($('<li class="file"><span class="name">' + name + '</span><span class="remove"><i class="fa fa-close"></i></span></li>')) |
|
|
|
$filesEl.append($('<li class="file"><span class="name">' + name + '</span><span class="remove"><i class="fa fa-close"></i></span></li>')) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var currentFileOpen = !!currentFile |
|
|
|
var currentFileOpen = !!ui.get('currentFile') |
|
|
|
|
|
|
|
|
|
|
|
if (currentFileOpen) { |
|
|
|
if (currentFileOpen) { |
|
|
|
var active = $('#files .file').filter(function () { return $(this).find('.name').text() === currentFile }) |
|
|
|
var active = $('#files .file').filter(function () { return $(this).find('.name').text() === ui.get('currentFile') }) |
|
|
|
active.addClass('active') |
|
|
|
active.addClass('active') |
|
|
|
} |
|
|
|
} |
|
|
|
$('#input').toggle(currentFileOpen) |
|
|
|
$('#input').toggle(currentFileOpen) |
|
|
@ -636,7 +638,7 @@ var run = function () { |
|
|
|
this.fullLineMarker = null |
|
|
|
this.fullLineMarker = null |
|
|
|
if (lineColumnPos) { |
|
|
|
if (lineColumnPos) { |
|
|
|
var source = compiler.lastCompilationResult.data.sourceList[location.file] // auto switch to that tab
|
|
|
|
var source = compiler.lastCompilationResult.data.sourceList[location.file] // auto switch to that tab
|
|
|
|
if (currentFile !== source) { |
|
|
|
if (ui.get('currentFile') !== source) { |
|
|
|
switchToFile(source) |
|
|
|
switchToFile(source) |
|
|
|
} |
|
|
|
} |
|
|
|
this.statementMarker = editor.addMarker(lineColumnPos, 'highlightcode') |
|
|
|
this.statementMarker = editor.addMarker(lineColumnPos, 'highlightcode') |
|
|
@ -760,12 +762,12 @@ var run = function () { |
|
|
|
|
|
|
|
|
|
|
|
var rendererAPI = { |
|
|
|
var rendererAPI = { |
|
|
|
error: (file, error) => { |
|
|
|
error: (file, error) => { |
|
|
|
if (file === currentFile) { |
|
|
|
if (file === ui.get('currentFile')) { |
|
|
|
editor.addAnnotation(error) |
|
|
|
editor.addAnnotation(error) |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
errorClick: (errFile, errLine, errCol) => { |
|
|
|
errorClick: (errFile, errLine, errCol) => { |
|
|
|
if (errFile !== currentFile && files.exists(errFile)) { |
|
|
|
if (errFile !== ui.get('currentFile') && files.exists(errFile)) { |
|
|
|
switchToFile(errFile) |
|
|
|
switchToFile(errFile) |
|
|
|
} |
|
|
|
} |
|
|
|
editor.gotoLine(errLine, errCol) |
|
|
|
editor.gotoLine(errLine, errCol) |
|
|
@ -814,6 +816,7 @@ var run = function () { |
|
|
|
|
|
|
|
|
|
|
|
function runCompiler () { |
|
|
|
function runCompiler () { |
|
|
|
editorSyncFile() |
|
|
|
editorSyncFile() |
|
|
|
|
|
|
|
var currentFile = ui.get('currentFile') |
|
|
|
if (currentFile) { |
|
|
|
if (currentFile) { |
|
|
|
var target = currentFile |
|
|
|
var target = currentFile |
|
|
|
var sources = {} |
|
|
|
var sources = {} |
|
|
@ -823,6 +826,7 @@ var run = function () { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function editorSyncFile () { |
|
|
|
function editorSyncFile () { |
|
|
|
|
|
|
|
var currentFile = ui.get('currentFile') |
|
|
|
if (currentFile) { |
|
|
|
if (currentFile) { |
|
|
|
var input = editor.get(currentFile) |
|
|
|
var input = editor.get(currentFile) |
|
|
|
files.set(currentFile, input) |
|
|
|
files.set(currentFile, input) |
|
|
@ -834,6 +838,7 @@ var run = function () { |
|
|
|
var saveTimeout = null |
|
|
|
var saveTimeout = null |
|
|
|
|
|
|
|
|
|
|
|
function editorOnChange () { |
|
|
|
function editorOnChange () { |
|
|
|
|
|
|
|
var currentFile = ui.get('currentFile') |
|
|
|
if (!currentFile) { |
|
|
|
if (!currentFile) { |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|