[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,42 +6,100 @@
|
|||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Codemirror6 example using BaseX LSP</title>
|
||||
<link rel="icon" type="image/png" href="../favicon.png" />
|
||||
|
||||
<link href="../bootstrap@5.3.7.css" rel="stylesheet" />
|
||||
<link rel="stylesheet" href="styles.css" />
|
||||
<script src="popover.js" defer></script>
|
||||
<link rel="stylesheet" href="grail.css" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<nav class="navbar bg-body-tertiary">
|
||||
<div class="container-fluid">
|
||||
<a id="help" class="navbar-brand">XQuery 4.0 LSP client
|
||||
<button popovertarget="popHelp"><i class="bi bi-info-circle"></i></button></a>
|
||||
<ul class="nav nav-pills">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" aria-current="page" href="#">Editor</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#">Msgs</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/dba/logs" target="dba">Dba</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Disabled</a>
|
||||
</li>
|
||||
</ul>
|
||||
<button id="popcon" popovertarget="popConnect" class="btn btn-danger">
|
||||
<i class="bi bi-router"></i>
|
||||
</button>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<div class="page-wrap">
|
||||
<header class="page-header">
|
||||
<nav class="navbar bg-body-tertiary">
|
||||
<div class="container-fluid">
|
||||
<a id="help" class="navbar-brand">XQuery 4.0 LSP client
|
||||
<button id="popcon" popovertarget="popConnect" class="btn btn-danger">
|
||||
<i class="codicon codicon-vm-outline"></i>
|
||||
</button>
|
||||
</a>
|
||||
<ul class="nav nav-pills">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" aria-current="page" href="#">Editor</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#">Msgs</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/dba/logs" target="dba">Dba</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Disabled</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</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 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>
|
||||
|
||||
|
||||
<div class="container-fluid">
|
||||
<div class="row " style="overflow:hidden;">
|
||||
<div class="col-2">
|
||||
<div id="msg">(msgs)</div>
|
||||
<button id="unused3" type="button" class="btn btn-light" title="unused3">
|
||||
<i>3</i></button>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<main class="page-main" style="overflow: auto;">
|
||||
<!-- Editor goes in here -->
|
||||
<div id="editor"></div>
|
||||
</main>
|
||||
|
||||
<aside class="page-sidebar">
|
||||
|
||||
<details id="workspacePanel" open="open" >
|
||||
<summary class='bg-info'>Workspace <b>0</b></summary>
|
||||
<select id="load">
|
||||
<option selected value="">load..</option>
|
||||
<optgroup label="XQuery3">
|
||||
|
@ -56,69 +114,42 @@
|
|||
<option
|
||||
value="https://git.quodatum.duckdns.org/quodatum/basex-lsp/raw/branch/main/webapp/lsp/lsp-text.xqm">
|
||||
lsp-text.xqm</option>
|
||||
|
||||
<option value="../../../lsp/lsp-text.xqm">
|
||||
lsp-text.xqm</option>
|
||||
</optgroup>
|
||||
|
||||
<optgroup label="xpath">
|
||||
<option
|
||||
value="https://raw.githubusercontent.com/dnovatchev/Articles/refs/heads/main/Generators/Code/generator.xpath">
|
||||
generator.xpath</option>
|
||||
|
||||
value="https://raw.githubusercontent.com/dnovatchev/Articles/refs/heads/main/Generators/Code/generator.xq">
|
||||
generator.xquery</option>
|
||||
</optgroup>
|
||||
</select>
|
||||
|
||||
<ul id="traffic" style="overflow: scroll;">
|
||||
<li>-</li>
|
||||
</ul>
|
||||
</div>
|
||||
</details>
|
||||
|
||||
<div class="col flex-grow-1" style="overflow: auto;">
|
||||
<div class="navbar py-0 bg-light">
|
||||
<details id="symPanel">
|
||||
<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">
|
||||
<label for="file">File:</label>
|
||||
<input id="iFile" type="url" value="file:///some/file.xqm" />
|
||||
<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="symbols">Symbols:</label><select id="symbols" disabled="disabled"></select>
|
||||
</div>
|
||||
<div class="btn-group btn-group-sm " role="group" aria-label="Second group">
|
||||
<details id="msgPanel" >
|
||||
<summary >Messages <b>0</b></summary>
|
||||
<div id="msg">(msgs)<i class='codicon codicon-symbol-method'></i></div>
|
||||
</details>
|
||||
</aside>
|
||||
|
||||
<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>
|
||||
<footer class="page-footer">
|
||||
Footer <select id="language">
|
||||
<option selected>Language</option>
|
||||
<option value="plaintext">plaintext</option>
|
||||
<option value="xquery">xquery</option>
|
||||
<option value="xml">xml</option>
|
||||
</select>
|
||||
<button popovertarget="popHelp"><i class="codicon codicon-info"></i></button>
|
||||
</footer>
|
||||
</div>
|
||||
<!-- Popovers -->
|
||||
<dialog id="popConnect" popover>
|
||||
|
@ -134,24 +165,31 @@
|
|||
</div>
|
||||
</dialog>
|
||||
|
||||
<popup-info id="popHelp">hhhh</popup-info>
|
||||
<!-- <popup-info id="popHelp">hhhh</popup-info> -->
|
||||
|
||||
<dialog id="popSettings" popover>
|
||||
<header>Editor configuration
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"
|
||||
onclick="$('popSettings').hidePopover(); "></button>
|
||||
</header>
|
||||
<div class="modal-body">
|
||||
@TODO
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button id="connect">ok</button>
|
||||
</div>
|
||||
</dialog>
|
||||
<form id="fSettings">
|
||||
<header>Editor configuration
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"
|
||||
onclick="$('popSettings').hidePopover(); "></button>
|
||||
</header>
|
||||
<div class="modal-body">
|
||||
|
||||
<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 class="modal-footer">
|
||||
<button type="submit" class="btn btn-primary">Apply</button>
|
||||
</div>
|
||||
</form>
|
||||
</dialog>
|
||||
<!-- CodeMirror 6 -->
|
||||
<script src="./lsp.bundle.js"></script>
|
||||
<script src="./script.js"></script>
|
||||
<script src="./list.js"></script>
|
||||
|
||||
</body>
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue