[add] text record
This commit is contained in:
parent
f6dbec0b4c
commit
11d165f794
3 changed files with 156 additions and 93 deletions
9
webapp/lsp/text.xq
Normal file
9
webapp/lsp/text.xq
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
import module namespace text = 'text' at "text.xqm";
|
||||||
|
|
||||||
|
declare variable $long:=file:read-text(file:resolve-path("../../test/sample.docs/pdfbox.xqm",file:base-dir()));
|
||||||
|
declare variable $text:=`ABV
|
||||||
|
ddddd
|
||||||
|
`;
|
||||||
|
|
||||||
|
|
||||||
|
text:build($long)?text()
|
16
webapp/lsp/text.xqm
Normal file
16
webapp/lsp/text.xqm
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
(:~ handle textDocument
|
||||||
|
: @author andy bunce
|
||||||
|
:)
|
||||||
|
module namespace text = 'text';
|
||||||
|
|
||||||
|
declare record text:rec(
|
||||||
|
lines as xs:string+,
|
||||||
|
separator? as xs:string:=file:line-separator(),
|
||||||
|
text? as fn() as xs:string:= %method fn () { string-join(?lines,?separator) },
|
||||||
|
line? := %method fn($line) {?lines[$line]}
|
||||||
|
);
|
||||||
|
|
||||||
|
declare function text:build($text as xs:string){
|
||||||
|
let $lines:=tokenize($text, '(\r\n?|\n\r?)')
|
||||||
|
return text:rec($lines)
|
||||||
|
};
|
|
@ -6,17 +6,21 @@
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>Codemirror6 example using BaseX LSP</title>
|
<title>Codemirror6 example using BaseX LSP</title>
|
||||||
<link rel="icon" type="image/png" href="../favicon.png" />
|
<link rel="icon" type="image/png" href="../favicon.png" />
|
||||||
|
|
||||||
<link href="../bootstrap@5.3.7.css" rel="stylesheet" />
|
<link href="../bootstrap@5.3.7.css" rel="stylesheet" />
|
||||||
<link rel="stylesheet" href="styles.css" />
|
<link rel="stylesheet" href="grail.css" />
|
||||||
<script src="popover.js" defer></script>
|
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
|
<div class="page-wrap">
|
||||||
|
<header class="page-header">
|
||||||
<nav class="navbar bg-body-tertiary">
|
<nav class="navbar bg-body-tertiary">
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<a id="help" class="navbar-brand">XQuery 4.0 LSP client
|
<a id="help" class="navbar-brand">XQuery 4.0 LSP client
|
||||||
<button popovertarget="popHelp"><i class="bi bi-info-circle"></i></button></a>
|
<button id="popcon" popovertarget="popConnect" class="btn btn-danger">
|
||||||
|
<i class="codicon codicon-vm-outline"></i>
|
||||||
|
</button>
|
||||||
|
</a>
|
||||||
<ul class="nav nav-pills">
|
<ul class="nav nav-pills">
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link active" aria-current="page" href="#">Editor</a>
|
<a class="nav-link active" aria-current="page" href="#">Editor</a>
|
||||||
|
@ -31,17 +35,71 @@
|
||||||
<a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Disabled</a>
|
<a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Disabled</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<button id="popcon" popovertarget="popConnect" class="btn btn-danger">
|
|
||||||
<i class="bi bi-router"></i>
|
</div>
|
||||||
|
</nav>
|
||||||
|
</header>
|
||||||
|
<nav class="page-nav">
|
||||||
|
<div class="navbar py-0 bg-light">
|
||||||
|
|
||||||
|
<div class="btn-group mr-2" role="group" aria-label="First group">
|
||||||
|
<label for="file">File:</label>
|
||||||
|
<input id="iFile" type="url" value="file:///some/file.xqm" />
|
||||||
|
|
||||||
|
<label for="symbols">Symbols:</label><select id="symbols" disabled="disabled"></select>
|
||||||
|
</div>
|
||||||
|
<div class="btn-group btn-group-sm " role="group" aria-label="Second group">
|
||||||
|
|
||||||
|
<button id="search" title="Search" type="button" class="btn btn-light"><i
|
||||||
|
class="codicon codicon-search"></i></button>
|
||||||
|
|
||||||
|
<button id="lint" title="Display diagnostics" type="button" class="btn btn-light"><i
|
||||||
|
class="codicon codicon-report"></i></button>
|
||||||
|
|
||||||
|
<button id="symbols2" type="button" class="btn btn-light" title="symbols">
|
||||||
|
<i class="codicon codicon-symbol-misc"></i></button>
|
||||||
|
|
||||||
|
<button id="format" type="button" class="btn btn-light" title="Format (Shift-Alt-f)"><i
|
||||||
|
class="codicon codicon-list-flat"></i></button>
|
||||||
|
|
||||||
|
<button id="sync" title="Sync changes to server" type="button" class="btn btn-light">
|
||||||
|
<i class="codicon codicon-sync"></i>
|
||||||
</button>
|
</button>
|
||||||
|
<button id="fullscreen" title="Full screen editor" type="button" class="btn btn-light">
|
||||||
|
<i class="codicon codicon-screen-full"></i>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<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="syntax" type="button" class="btn btn-light" title="Unused"><i
|
||||||
|
class="codicon codicon-comment"></i></button>
|
||||||
|
|
||||||
|
<button id="cmd" type="button" class="btn btn-light" title="Cmd list to console">
|
||||||
|
<i class="codicon codicon-debug-console"></i>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<button id="wordAt" type="button" class="btn btn-light" title="word at">
|
||||||
|
<i>1</i></button>
|
||||||
|
|
||||||
|
|
||||||
|
<button id="unused3" type="button" class="btn btn-light" title="unused3">
|
||||||
|
<i>3</i></button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
|
<main class="page-main" style="overflow: auto;">
|
||||||
|
<!-- Editor goes in here -->
|
||||||
|
<div id="editor"></div>
|
||||||
|
</main>
|
||||||
|
|
||||||
<div class="container-fluid">
|
<aside class="page-sidebar">
|
||||||
<div class="row " style="overflow:hidden;">
|
|
||||||
<div class="col-2">
|
<details id="workspacePanel" open="open" >
|
||||||
<div id="msg">(msgs)</div>
|
<summary class='bg-info'>Workspace <b>0</b></summary>
|
||||||
<select id="load">
|
<select id="load">
|
||||||
<option selected value="">load..</option>
|
<option selected value="">load..</option>
|
||||||
<optgroup label="XQuery3">
|
<optgroup label="XQuery3">
|
||||||
|
@ -56,69 +114,42 @@
|
||||||
<option
|
<option
|
||||||
value="https://git.quodatum.duckdns.org/quodatum/basex-lsp/raw/branch/main/webapp/lsp/lsp-text.xqm">
|
value="https://git.quodatum.duckdns.org/quodatum/basex-lsp/raw/branch/main/webapp/lsp/lsp-text.xqm">
|
||||||
lsp-text.xqm</option>
|
lsp-text.xqm</option>
|
||||||
|
<option value="../../../lsp/lsp-text.xqm">
|
||||||
|
lsp-text.xqm</option>
|
||||||
</optgroup>
|
</optgroup>
|
||||||
|
|
||||||
<optgroup label="xpath">
|
<optgroup label="xpath">
|
||||||
<option
|
<option
|
||||||
value="https://raw.githubusercontent.com/dnovatchev/Articles/refs/heads/main/Generators/Code/generator.xpath">
|
value="https://raw.githubusercontent.com/dnovatchev/Articles/refs/heads/main/Generators/Code/generator.xq">
|
||||||
generator.xpath</option>
|
generator.xquery</option>
|
||||||
|
|
||||||
</optgroup>
|
</optgroup>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<ul id="traffic" style="overflow: scroll;">
|
<ul id="traffic" style="overflow: scroll;">
|
||||||
<li>-</li>
|
<li>-</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</details>
|
||||||
|
|
||||||
<div class="col flex-grow-1" style="overflow: auto;">
|
<details id="symPanel">
|
||||||
<div class="navbar py-0 bg-light">
|
<summary >OutLine <b>0</b></summary>
|
||||||
|
<json-list id="symList" ></json-list>
|
||||||
|
</details>
|
||||||
|
|
||||||
<div class="btn-group mr-2" role="group" aria-label="First group">
|
<details id="msgPanel" >
|
||||||
<label for="file">File:</label>
|
<summary >Messages <b>0</b></summary>
|
||||||
<input id="iFile" type="url" value="file:///some/file.xqm" />
|
<div id="msg">(msgs)<i class='codicon codicon-symbol-method'></i></div>
|
||||||
<select id="language">
|
</details>
|
||||||
|
</aside>
|
||||||
|
|
||||||
|
<footer class="page-footer">
|
||||||
|
Footer <select id="language">
|
||||||
<option selected>Language</option>
|
<option selected>Language</option>
|
||||||
<option value="plaintext">plaintext</option>
|
<option value="plaintext">plaintext</option>
|
||||||
<option value="xquery">xquery</option>
|
<option value="xquery">xquery</option>
|
||||||
<option value="xml">xml</option>
|
<option value="xml">xml</option>
|
||||||
</select>
|
</select>
|
||||||
<label for="symbols">Symbols:</label><select id="symbols" disabled="disabled"></select>
|
<button popovertarget="popHelp"><i class="codicon codicon-info"></i></button>
|
||||||
</div>
|
</footer>
|
||||||
<div class="btn-group btn-group-sm " role="group" aria-label="Second group">
|
|
||||||
|
|
||||||
<button id="search" title="Search" type="button" class="btn btn-light"><i
|
|
||||||
class="bi bi-search"></i></button>
|
|
||||||
|
|
||||||
<button id="lint" title="Diagnostics" type="button" class="btn btn-light"><i
|
|
||||||
class="bi bi-info-square"></i></button>
|
|
||||||
|
|
||||||
<button id="sync" title="Sync changes to server" type="button" class="btn btn-light">
|
|
||||||
<i class="bi bi-arrow-repeat"></i>
|
|
||||||
</button>
|
|
||||||
<button id="fullscreen" title="Full screen" type="button" class="btn btn-light">
|
|
||||||
<i class="bi bi-arrows-fullscreen"></i>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
<div class="btn-group" role="group" aria-label="Third group">
|
|
||||||
|
|
||||||
<button id="syntax" type="button" class="btn btn-light" title="Syntax"><i
|
|
||||||
class="bi bi-chat"></i></button>
|
|
||||||
|
|
||||||
<button id="format" type="button" class="btn btn-light" title="Format (Shift-Alt-f)"><i
|
|
||||||
class="bi bi-justify-left"></i></button>
|
|
||||||
|
|
||||||
<button id="cmd" type="button" class="btn btn-light" title="Cmd ">
|
|
||||||
<i class="bi bi-hammer"></i>
|
|
||||||
</button>
|
|
||||||
<button type="button" class="btn btn-light" popovertarget="popSettings" title="Settings">
|
|
||||||
<i class="bi bi-gear"></i></button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<!-- Editor goes in here -->
|
|
||||||
<div id="editor"></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<!-- Popovers -->
|
<!-- Popovers -->
|
||||||
<dialog id="popConnect" popover>
|
<dialog id="popConnect" popover>
|
||||||
|
@ -134,24 +165,31 @@
|
||||||
</div>
|
</div>
|
||||||
</dialog>
|
</dialog>
|
||||||
|
|
||||||
<popup-info id="popHelp">hhhh</popup-info>
|
<!-- <popup-info id="popHelp">hhhh</popup-info> -->
|
||||||
|
|
||||||
<dialog id="popSettings" popover>
|
<dialog id="popSettings" popover>
|
||||||
|
<form id="fSettings">
|
||||||
<header>Editor configuration
|
<header>Editor configuration
|
||||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"
|
||||||
onclick="$('popSettings').hidePopover(); "></button>
|
onclick="$('popSettings').hidePopover(); "></button>
|
||||||
</header>
|
</header>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
@TODO
|
|
||||||
|
<div class="mb-3 form-check">
|
||||||
|
<input name="wrap-lines" type="checkbox" class="form-check-input" id="exampleCheck1">
|
||||||
|
<label class="form-check-label" for="exampleCheck1">Wrap lines</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button id="connect">ok</button>
|
<button type="submit" class="btn btn-primary">Apply</button>
|
||||||
</div>
|
</div>
|
||||||
|
</form>
|
||||||
</dialog>
|
</dialog>
|
||||||
|
|
||||||
<!-- CodeMirror 6 -->
|
<!-- CodeMirror 6 -->
|
||||||
<script src="./lsp.bundle.js"></script>
|
<script src="./lsp.bundle.js"></script>
|
||||||
<script src="./script.js"></script>
|
<script src="./script.js"></script>
|
||||||
|
<script src="./list.js"></script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue