mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2024-11-24 12:31:25 +00:00
add highlight=<start>,<end> option in query string
This commit is contained in:
parent
be679ecc10
commit
e1b6a2397d
@ -30,6 +30,9 @@
|
|||||||
.currentpc-marker-blocked {
|
.currentpc-marker-blocked {
|
||||||
color: #ffee33;
|
color: #ffee33;
|
||||||
}
|
}
|
||||||
|
.hilite-span {
|
||||||
|
background-color: #003399;
|
||||||
|
}
|
||||||
.mark-error {
|
.mark-error {
|
||||||
text-decoration-line: underline;
|
text-decoration-line: underline;
|
||||||
text-decoration-style: wavy;
|
text-decoration-style: wavy;
|
||||||
|
@ -43,6 +43,7 @@ interface UIQueryString {
|
|||||||
embed? : string;
|
embed? : string;
|
||||||
ignore? : string;
|
ignore? : string;
|
||||||
force? : string;
|
force? : string;
|
||||||
|
highlight? : string;
|
||||||
file0_name? : string;
|
file0_name? : string;
|
||||||
file0_data? : string;
|
file0_data? : string;
|
||||||
file0_type? : string;
|
file0_type? : string;
|
||||||
@ -386,6 +387,16 @@ function refreshWindowList() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function highlightLines(path:string, hispec:string) {
|
||||||
|
if (hispec) {
|
||||||
|
var toks = qs.highlight.split(',');
|
||||||
|
var start = parseInt(toks[0]) - 1;
|
||||||
|
var end = parseInt(toks[1]) - 1;
|
||||||
|
var editor = projectWindows.createOrShow(path) as SourceEditor;
|
||||||
|
editor.highlightLines(start, end);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function loadMainWindow(preset_id:string) {
|
function loadMainWindow(preset_id:string) {
|
||||||
// we need this to build create functions for the editor
|
// we need this to build create functions for the editor
|
||||||
refreshWindowList();
|
refreshWindowList();
|
||||||
@ -393,6 +404,8 @@ function loadMainWindow(preset_id:string) {
|
|||||||
projectWindows.createOrShow(preset_id);
|
projectWindows.createOrShow(preset_id);
|
||||||
// build project
|
// build project
|
||||||
current_project.setMainFile(preset_id);
|
current_project.setMainFile(preset_id);
|
||||||
|
// highlighting?
|
||||||
|
highlightLines(preset_id, qs.highlight);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function loadProject(preset_id:string) {
|
async function loadProject(preset_id:string) {
|
||||||
|
@ -50,10 +50,12 @@ export class SourceEditor implements ProjectView {
|
|||||||
path : string;
|
path : string;
|
||||||
mode : string;
|
mode : string;
|
||||||
editor;
|
editor;
|
||||||
|
updateTimer = null;
|
||||||
dirtylisting = true;
|
dirtylisting = true;
|
||||||
sourcefile : SourceFile;
|
sourcefile : SourceFile;
|
||||||
currentDebugLine : SourceLocation;
|
currentDebugLine : SourceLocation;
|
||||||
markCurrentPC; // TextMarker
|
markCurrentPC; // TextMarker
|
||||||
|
markHighlight; // TextMarker
|
||||||
errormsgs = [];
|
errormsgs = [];
|
||||||
errorwidgets = [];
|
errorwidgets = [];
|
||||||
errormarks = [];
|
errormarks = [];
|
||||||
@ -98,25 +100,25 @@ export class SourceEditor implements ProjectView {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
setupEditor() {
|
editorChanged() {
|
||||||
var timer;
|
clearTimeout(this.updateTimer);
|
||||||
// update file in project (and recompile) when edits made
|
this.updateTimer = setTimeout( () => {
|
||||||
this.editor.on('changes', (ed, changeobj) => {
|
|
||||||
clearTimeout(timer);
|
|
||||||
timer = setTimeout( () => {
|
|
||||||
current_project.updateFile(this.path, this.editor.getValue());
|
current_project.updateFile(this.path, this.editor.getValue());
|
||||||
}, 300);
|
}, 300);
|
||||||
|
if (this.markHighlight) {
|
||||||
|
this.markHighlight.clear();
|
||||||
|
this.markHighlight = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
setupEditor() {
|
||||||
|
// update file in project (and recompile) when edits made
|
||||||
|
this.editor.on('changes', (ed, changeobj) => {
|
||||||
|
this.editorChanged();
|
||||||
});
|
});
|
||||||
// inspect symbol when it's highlighted (double-click)
|
// inspect symbol when it's highlighted (double-click)
|
||||||
this.editor.on('cursorActivity', (ed) => {
|
this.editor.on('cursorActivity', (ed) => {
|
||||||
var start = this.editor.getCursor(true);
|
this.inspectUnderCursor();
|
||||||
var end = this.editor.getCursor(false);
|
|
||||||
if (start.line == end.line && start.ch < end.ch && end.ch-start.ch < 80) {
|
|
||||||
var name = this.editor.getSelection();
|
|
||||||
this.inspect(name);
|
|
||||||
} else {
|
|
||||||
this.inspect(null);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
// gutter clicked
|
// gutter clicked
|
||||||
this.editor.on("gutterClick", (cm, n) => {
|
this.editor.on("gutterClick", (cm, n) => {
|
||||||
@ -130,6 +132,16 @@ export class SourceEditor implements ProjectView {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inspectUnderCursor() {
|
||||||
|
var start = this.editor.getCursor(true);
|
||||||
|
var end = this.editor.getCursor(false);
|
||||||
|
if (start.line == end.line && start.ch < end.ch && end.ch-start.ch < 80) {
|
||||||
|
var name = this.editor.getSelection();
|
||||||
|
this.inspect(name);
|
||||||
|
} else {
|
||||||
|
this.inspect(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
inspect(ident : string) : void {
|
inspect(ident : string) : void {
|
||||||
var result;
|
var result;
|
||||||
@ -171,6 +183,14 @@ export class SourceEditor implements ProjectView {
|
|||||||
this.editor.replaceRange(text, cur, cur);
|
this.editor.replaceRange(text, cur, cur);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
highlightLines(start:number, end:number) {
|
||||||
|
//this.editor.setSelection({line:start, ch:0}, {line:end, ch:0});
|
||||||
|
var cls = 'hilite-span'
|
||||||
|
var markOpts = {className:cls, inclusiveLeft:true};
|
||||||
|
this.markHighlight = this.editor.markText({line:start,ch:0}, {line:end,ch:0}, markOpts);
|
||||||
|
this.editor.scrollIntoView({from:{line:start,ch:0}, to:{line:end,ch:0}});
|
||||||
|
}
|
||||||
|
|
||||||
replaceSelection(start:number, end:number, text:string) {
|
replaceSelection(start:number, end:number, text:string) {
|
||||||
this.editor.setSelection(this.editor.posFromIndex(start), this.editor.posFromIndex(end));
|
this.editor.setSelection(this.editor.posFromIndex(start), this.editor.posFromIndex(end));
|
||||||
this.editor.replaceSelection(text);
|
this.editor.replaceSelection(text);
|
||||||
|
@ -21,15 +21,23 @@ exports['test embed iframe'] = function(browser) {
|
|||||||
.waitForElementVisible('#emuscreen')
|
.waitForElementVisible('#emuscreen')
|
||||||
.waitForElementVisible('.emuvideo')
|
.waitForElementVisible('.emuvideo')
|
||||||
|
|
||||||
|
browser.url(IDEURL + QS + "&highlight=2,4")
|
||||||
|
.waitForElementNotVisible('#compile_spinner', time=10000)
|
||||||
|
.waitForElementNotVisible('#error_alert')
|
||||||
|
.waitForElementVisible('#emuscreen')
|
||||||
|
.waitForElementVisible('.emuvideo')
|
||||||
|
.waitForElementVisible('.hilite-span')
|
||||||
|
|
||||||
browser.url(IDEURL + "?embed=1")
|
browser.url(IDEURL + "?embed=1")
|
||||||
.waitForElementVisible('.bootbox-alert')
|
.waitForElementVisible('.bootbox-alert')
|
||||||
|
|
||||||
|
/* TODO
|
||||||
browser.url(IDEURL + "?embed=1&platform=nes&githubURL=https://github.com/sehugg/NES-ca65-example")
|
browser.url(IDEURL + "?embed=1&platform=nes&githubURL=https://github.com/sehugg/NES-ca65-example")
|
||||||
.waitForElementNotVisible('#compile_spinner', time=10000)
|
.waitForElementNotVisible('#compile_spinner', time=10000)
|
||||||
.waitForElementNotVisible('#error_alert')
|
.waitForElementNotVisible('#error_alert')
|
||||||
.waitForElementVisible('#emuscreen')
|
.waitForElementVisible('#emuscreen')
|
||||||
.waitForElementVisible('.emuvideo')
|
.waitForElementVisible('.emuvideo')
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
exports['test embed.html'] = function(browser) {
|
exports['test embed.html'] = function(browser) {
|
||||||
|
Loading…
Reference in New Issue
Block a user