[fix] size linewrap
This commit is contained in:
parent
f1fecbdee8
commit
5b311838ba
13 changed files with 196 additions and 5480 deletions
|
@ -1,11 +1,11 @@
|
|||
<users>
|
||||
<user name="admin" permission="admin">
|
||||
<password algorithm="digest">
|
||||
<hash>60a56ebb6dcce833b7b25f1b30308230</hash>
|
||||
<hash>304bdfb0383c16f070a897fc1eb25cb4</hash>
|
||||
</password>
|
||||
<password algorithm="salted-sha256">
|
||||
<salt>1380009415456</salt>
|
||||
<hash>d05ace1a12d885eefaeeefaff9064b79dba66099e4b746ee670ee40740b59010</hash>
|
||||
<salt>75523049164421</salt>
|
||||
<hash>5c55c7b22d7ed8c64067932a753161ec5c198b020f015493de8ccf13afbb5db2</hash>
|
||||
</password>
|
||||
</user>
|
||||
</users>
|
1
docs/explore.xqbk
Normal file
1
docs/explore.xqbk
Normal file
|
@ -0,0 +1 @@
|
|||
{"cells":[{"kind":2,"language":"xquery","value":" db:system() "}]}
|
|
@ -20,8 +20,8 @@
|
|||
},
|
||||
"scripts": {
|
||||
"build": "rollup src/index.js -m true -f iife -o dist/cm6.bundle.js -p node-resolve,tla --output.name cm6",
|
||||
"build-cm": "rollup src/lsp.js -m true -f iife -o webapp/static/codemirror/lsp.bundle.js -p node-resolve,tla --output.name lsp",
|
||||
"min-cm": "cd webapp/static/codemirror && npx minify lsp.bundle.js > lsp.bundle.min.js ",
|
||||
"build-cm": "rollup src/lsp.js -m true -f iife -o webapp/static/clients/codemirror/lsp.bundle.js -p node-resolve,tla --output.name lsp",
|
||||
"min-cm": "cd webapp/static/clients/codemirror && npx minify lsp.bundle.js > lsp.bundle.min.js ",
|
||||
"min": "cd dist && npx minify cm6.bundle.js > cm6.bundle.min.js && npx minify lsp.bundle.js > lsp.bundle.min.js"
|
||||
}
|
||||
}
|
|
@ -16,6 +16,8 @@ import { xml } from "@codemirror/lang-xml";
|
|||
function simpleWebSocketTransport(uri) {
|
||||
let handlers = [];
|
||||
let sock = new WebSocket(uri);
|
||||
sock.addEventListener("close", (event) => { alert("sock gone!")})
|
||||
sock.addEventListener("error", (event) => { alert("sock error!")})
|
||||
sock.onmessage = e => { for (let h of handlers) h(e.data.toString()); };
|
||||
return new Promise(resolve => {
|
||||
sock.onopen = () => resolve({
|
||||
|
@ -42,6 +44,7 @@ const baseExts = [
|
|||
drawSelection(),
|
||||
indentUnit.of(" "),
|
||||
EditorState.allowMultipleSelections.of(true),
|
||||
EditorView.lineWrapping,
|
||||
indentOnInput(),
|
||||
bracketMatching(),
|
||||
closeBrackets(),
|
||||
|
@ -61,7 +64,6 @@ const baseExts = [
|
|||
...lintKeymap
|
||||
]),
|
||||
xml(),
|
||||
markdown(),
|
||||
syntaxHighlighting(defaultHighlightStyle, { fallback: true })
|
||||
];
|
||||
|
||||
|
|
Binary file not shown.
|
@ -6,11 +6,12 @@
|
|||
module namespace docs="lsp/docs";
|
||||
import module namespace p="xq4" at "xq4.xqm";
|
||||
|
||||
(:~
|
||||
@param line Line position in a document (zero-based).
|
||||
@param character Character offset on a line in a document (zero-based).
|
||||
:)
|
||||
declare record docs:Position(
|
||||
(: Line position in a document (zero-based). :)
|
||||
line as xs:integer,
|
||||
|
||||
(: Character offset on a line in a document (zero-based). :)
|
||||
character as xs:integer
|
||||
);
|
||||
|
||||
|
@ -34,23 +35,25 @@ declare function docs:get(
|
|||
(: save $textDocument data as session $socket properties :)
|
||||
declare function docs:save(
|
||||
$socket as xs:string,
|
||||
$textDocument as map(*)
|
||||
$params as map(*)
|
||||
)
|
||||
{
|
||||
let $text as xs:string:=$textDocument?text
|
||||
let $uri:=$textDocument?uri
|
||||
let $text as xs:string:=$params?textDocument?text
|
||||
let $uri:=$params?textDocument?uri
|
||||
let $files:=ws:get($socket,"files",{})
|
||||
let $files:=if(map:contains($files,$uri))
|
||||
then $files
|
||||
else map:put($files,$uri,{
|
||||
"textDocument":random:uuid(),
|
||||
"parse":random:uuid() })
|
||||
else
|
||||
let $uuid:=random:uuid()
|
||||
return map:put($files,$uri,{
|
||||
"textDocument": "file-" || $uuid,
|
||||
"parse": "parse-" || $uuid })
|
||||
let $keys:=$files($uri)
|
||||
let $xml:=p:parse-Module($text)
|
||||
let $xml:=prof:time(p:parse-Module($text),"⏱️ p:parse-Module ")
|
||||
|
||||
return (
|
||||
ws:set($socket,"files",$files),
|
||||
ws:set($socket,$keys?textDocument,$textDocument),
|
||||
ws:set($socket,$keys?textDocument,$params?textDocument),
|
||||
ws:set($socket,$keys?parse,$xml)
|
||||
)
|
||||
};
|
||||
|
|
|
@ -18,19 +18,19 @@ declare variable $lsp-text:methods:=map{
|
|||
:)
|
||||
declare
|
||||
function lsp-text:hover($json as map(*))
|
||||
as map(*)?
|
||||
as map(*)
|
||||
{
|
||||
let $doc:=$json?params?textDocument?uri
|
||||
return map{
|
||||
map{
|
||||
"jsonrpc": "2.0",
|
||||
"id": $json?id,
|
||||
"result":{
|
||||
"contents": [
|
||||
`markdown: this is **bold**
|
||||
a [link](http://google.com)
|
||||
The last line.`
|
||||
`markdown here, this is **bold**.
|
||||
A [link](http://google.com)
|
||||
The last line.`
|
||||
,
|
||||
"plaintext: A hover for " || json:serialize($json?params?position)
|
||||
`A hover for { json:serialize($json?params?position) }
|
||||
uri: {$json?params?textDocument?uri} `
|
||||
]
|
||||
}
|
||||
}
|
||||
|
@ -53,9 +53,9 @@ declare
|
|||
function lsp-text:didOpen($json as map(*))
|
||||
as empty-sequence()
|
||||
{
|
||||
let $textDoc:=$json?params?textDocument
|
||||
let $x:=job:eval(xs:anyURI("parse.xq"),
|
||||
{"textDocument":$textDoc,"webSocket":ws:id()},
|
||||
{"params" : $json?params,
|
||||
"webSocket":ws:id()},
|
||||
{ 'cache': true() }
|
||||
)
|
||||
|
||||
|
@ -67,9 +67,9 @@ declare
|
|||
function lsp-text:didChange($json as map(*))
|
||||
as map(*)?
|
||||
{
|
||||
let $textDoc:=$json?params?textDocument
|
||||
|
||||
let $x:=job:eval(xs:anyURI("parse.xq"),
|
||||
{"textDocument":$textDoc,"webSocket":ws:id()},
|
||||
{"params": $json?params,"webSocket":ws:id()},
|
||||
{ 'cache': true() }
|
||||
)
|
||||
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
(: Save an XQuery doc and it's parse :)
|
||||
import module namespace docs="lsp/docs" at "docs.xqm";
|
||||
|
||||
declare variable $textDocument external;
|
||||
(:~ from LSP didOpen or didChange msg:)
|
||||
declare variable $params as map(*) external;
|
||||
declare variable $webSocket as xs:string external;
|
||||
|
||||
docs:save(
|
||||
prof:time(docs:save(
|
||||
$webSocket,
|
||||
$textDocument
|
||||
),
|
||||
$params
|
||||
),"⏱️ doc:save "),
|
||||
|
||||
ws:send(
|
||||
{"jsonrpc": "2.0",
|
||||
|
|
|
@ -23,30 +23,33 @@
|
|||
<input id="iServer" type="text" value="ws://localhost:3000/ws/lsp" style="width:25em" />
|
||||
<button id="connect">connect</button>
|
||||
</form>
|
||||
<div class="row">
|
||||
<div>
|
||||
<select id="language">
|
||||
<option selected>Language</option>
|
||||
<option value="plaintext">plaintext</option>
|
||||
<option value="xquery">xquery</option>
|
||||
<option value="xml">xml</option>
|
||||
</select>
|
||||
<label for="file">File:</label>
|
||||
<input id="iFile" type="url" value="file:///some/file.xml" />
|
||||
<button id="search">🔍</button>
|
||||
<button id="lint">⚠️</button>
|
||||
|
||||
<label for="symbols">Symbols:</label><select id="symbols" disabled="disabled"></select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<div class="container-fluid">
|
||||
<div class="row ">
|
||||
<div class="row " style="overflow:hidden">
|
||||
<div class="col-2">
|
||||
something
|
||||
ggg
|
||||
<button id="load"> something</button>
|
||||
</div>
|
||||
<div class="col flex-grow-1">
|
||||
<div class="row">
|
||||
<div>
|
||||
<select id="language">
|
||||
<option selected>Language</option>
|
||||
<option value="plaintext">plaintext</option>
|
||||
<option value="xquery">xquery</option>
|
||||
<option value="xml">xml</option>
|
||||
</select>
|
||||
<label for="file">File:</label><input id="iFile" type="url" value="file:///some/file.xml" />
|
||||
<button id="search">🔍</button>
|
||||
<button id="lint">⚠️</button>
|
||||
|
||||
<label for="symbols">Symbols:</label><select id="symbols" disabled="disabled"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col flex-grow-1" style="overflow: auto;">
|
||||
|
||||
|
||||
<!-- Editor goes in here -->
|
||||
|
||||
|
@ -79,6 +82,7 @@
|
|||
localStorage.setItem('code', doc);
|
||||
});
|
||||
document.getElementById("connect").onclick = e => {
|
||||
e.preventDefault()
|
||||
connect()
|
||||
};
|
||||
document.getElementById("search").onclick = e => {
|
||||
|
@ -87,6 +91,20 @@
|
|||
document.getElementById("lint").onclick = e => {
|
||||
lsp.openLintPanel(view);
|
||||
};
|
||||
document.getElementById("load").onclick = e => {
|
||||
const url = "https://raw.githubusercontent.com/dnovatchev/Articles/refs/heads/main/Generators/Code/generator.xpath";
|
||||
fetch(url)
|
||||
.then(response => response.text())
|
||||
.then(t => {
|
||||
view.dispatch({
|
||||
changes: {
|
||||
from: 0,
|
||||
to: view.state.doc.length,
|
||||
insert: t
|
||||
}
|
||||
})
|
||||
});
|
||||
};
|
||||
function connect() {
|
||||
const server = document.getElementById("iServer").value;
|
||||
const file = document.getElementById("iFile").value;
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1,13 +1,16 @@
|
|||
/* Set editor dimensions */
|
||||
#editor {
|
||||
height: 400px;
|
||||
|
||||
max-width: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* Stretch editor to fit inside its containing div */
|
||||
.cm-editor {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
overflow: auto;
|
||||
|
||||
}
|
||||
/* header */
|
||||
nav {
|
||||
|
|
Loading…
Add table
Reference in a new issue