From 11d165f794b4d3c5dde3c1119187f3ab108a5805 Mon Sep 17 00:00:00 2001 From: Andy Bunce Date: Fri, 26 Sep 2025 15:18:14 +0100 Subject: [PATCH] [add] text record --- webapp/lsp/text.xq | 9 + webapp/lsp/text.xqm | 16 ++ webapp/static/clients/codemirror/index.html | 224 ++++++++++++-------- 3 files changed, 156 insertions(+), 93 deletions(-) create mode 100644 webapp/lsp/text.xq create mode 100644 webapp/lsp/text.xqm diff --git a/webapp/lsp/text.xq b/webapp/lsp/text.xq new file mode 100644 index 0000000..ea8f000 --- /dev/null +++ b/webapp/lsp/text.xq @@ -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() \ No newline at end of file diff --git a/webapp/lsp/text.xqm b/webapp/lsp/text.xqm new file mode 100644 index 0000000..ecb496e --- /dev/null +++ b/webapp/lsp/text.xqm @@ -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) +}; \ No newline at end of file diff --git a/webapp/static/clients/codemirror/index.html b/webapp/static/clients/codemirror/index.html index ccee92b..384c687 100644 --- a/webapp/static/clients/codemirror/index.html +++ b/webapp/static/clients/codemirror/index.html @@ -6,42 +6,100 @@ Codemirror6 example using BaseX LSP - - - + - + +
+ + + +
+ +
+
+ +
+ -
- - -
-
- + @@ -134,24 +165,31 @@ - hhhh + -
Editor configuration - -
- - -
+
+
Editor configuration + +
+ + +
+ +