[add] file read
This commit is contained in:
parent
21c0eae056
commit
e63912740a
7 changed files with 316 additions and 26 deletions
|
|
@ -64,7 +64,10 @@
|
|||
|
||||
</nav>
|
||||
</header>
|
||||
<nav class="page-nav">
|
||||
|
||||
|
||||
<main class="page-main" style="overflow: auto;">
|
||||
<nav class="page-nav">
|
||||
<div class="navbar py-0 bg-light">
|
||||
|
||||
<div class="btn-group mr-2" role="group" aria-label="First group">
|
||||
|
|
@ -97,23 +100,29 @@
|
|||
<button type="button" class="btn btn-light" popovertarget="popSettings" title="Settings">
|
||||
<i class="codicon codicon-settings"></i></button>
|
||||
</div>
|
||||
|
||||
<div class="btn-group" role="group" aria-label="Third group">
|
||||
<button id="fullscreen" title="Full screen editor" type="button" class="btn btn-light">
|
||||
<i class="codicon codicon-screen-full"></i>
|
||||
</button>
|
||||
<button id="syntax" type="button" class="btn btn-light" title="Unused"><i
|
||||
class="codicon codicon-comment"></i></button>
|
||||
|
||||
<button id="wordAt" type="button" class="btn btn-light" title="word at">
|
||||
<i>1</i></button>
|
||||
<button id="bnNew" type="button" class="btn btn-light" title="New file"><i
|
||||
class="codicon codicon-new-file"></i></button>
|
||||
|
||||
<button id="unused3" type="button" class="btn btn-light" title="unused3">
|
||||
<i>3</i></button>
|
||||
<button id="bnRead" type="button" class="btn btn-light" title="LOad local file"><i
|
||||
class="codicon codicon-cloud-upload"></i></button>
|
||||
<input type="file" id="fileElem" multiple accept="*/*" style="display: none;"/>
|
||||
|
||||
<button id="bnSave" type="button" class="btn btn-light" title="save view">
|
||||
<i class="codicon codicon-git-stash"></i></button>
|
||||
|
||||
<button id="bnLoad" type="button" class="btn btn-light" title="load view">
|
||||
<i class="codicon codicon-git-stash-pop"></i></button>
|
||||
<button id="bnWordAt" type="button" class="btn btn-light" title="word at">
|
||||
<i class="codicon codicon-whole-word"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<main class="page-main" style="overflow: auto;">
|
||||
<!-- Editor goes in here -->
|
||||
<div id="editor"></div>
|
||||
</main>
|
||||
|
|
|
|||
|
|
@ -31365,7 +31365,7 @@ ${text}</tr>
|
|||
drawSelection(),
|
||||
dropCursor(),
|
||||
EditorState.allowMultipleSelections.of(true),
|
||||
tooltips({ }), // clipped
|
||||
tooltips({ }), // clipped
|
||||
keymap.of([indentWithTab]),
|
||||
indentOnInput(),
|
||||
syntaxHighlighting(defaultHighlightStyle, { fallback: true }),
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -5,7 +5,9 @@ const view = new lsp.EditorView({
|
|||
let doc = "xquery version '3.1';\n(:~ comment:)\nmodule namespace pdfbox='ns';\n";
|
||||
var client;
|
||||
var extLint;
|
||||
|
||||
var workspace={
|
||||
"file:///some/file.xqm":null
|
||||
};
|
||||
|
||||
function $(id) { return document.getElementById(id) };
|
||||
|
||||
|
|
@ -41,7 +43,7 @@ $("search").onclick = e => lsp.openSearchPanel(view);
|
|||
$("fullscreen").onclick = e => $("editor").requestFullscreen();
|
||||
|
||||
|
||||
$("wordAt").onclick = e => {
|
||||
$("bnWordAt").onclick = e => {
|
||||
let pos = view.state.selection.main.head;
|
||||
let w = view.state.wordAt(pos);
|
||||
alert("wordAt " + JSON.stringify(w));
|
||||
|
|
@ -82,10 +84,16 @@ $("lint").onclick = async e => {
|
|||
};
|
||||
|
||||
$("sync").onclick = e => { client.sync(); console.log("XXXsync"); };
|
||||
|
||||
$("format").onclick = e => {
|
||||
console.log("FMT", lsp.formatDocument(view));
|
||||
};
|
||||
$("bnSave").onclick = e => { workspace[iFile]=view.state; };
|
||||
$("bnLoad").onclick = e => { const v=workspace[iFile];if(v)view.setState(v)};
|
||||
$("bnRead").onclick = e => { const c=$("fileElem");
|
||||
c.click();
|
||||
const f=c.files[0];
|
||||
if(!f)return;
|
||||
c.value=null;
|
||||
alert(f.name);
|
||||
};
|
||||
$("format").onclick = e => { console.log("FMT", lsp.formatDocument(view));};
|
||||
|
||||
$("load").onchange = e => {
|
||||
const url = e.target.value;
|
||||
|
|
@ -112,6 +120,7 @@ $("msgIcon").onclick=e=>{
|
|||
alert("NOT YET")
|
||||
};
|
||||
|
||||
|
||||
function updateSettings(event) {
|
||||
event.preventDefault();
|
||||
|
||||
|
|
@ -178,7 +187,8 @@ function incoming(msg) {
|
|||
function log(rpc) {
|
||||
console.log("<-", rpc)
|
||||
if (rpc.id) return;
|
||||
const msg = {name:rpc.method, detail:JSON.stringify (rpc).slice(0,5), kind:23 /* event */ };
|
||||
const when=(new Date()).toISOString();
|
||||
const msg = {name:rpc.method, detail:when.substring(1+when.indexOf("T")), kind:23 /* event */ };
|
||||
//name,details,kind
|
||||
$("msgList").setData([msg],true)
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue