links to delete blocks in ktxt2
This commit is contained in:
@@ -1,16 +1,13 @@
|
||||
Stuff outside the thing is a comment
|
||||
|||Title: The First Fountain->Hollywoo Script
|
||||
Stuff outside the thing is a comment which you can edit to your heart's content|||Title: The First Fountain->Hollywoo Script
|
||||
Credit: written by
|
||||
Author: Nat Quayle Nelson (she/her)
|
||||
Contact: natquaylenelson@gmail.com
|
||||
|>||||testing editing another comment|||EXT. CABIN - DAY
|
||||
|>||||
|
||||
|||EXT. CABIN - DAY
|
||||
|>||||
|
||||
|
||||
|||A swanky cabin sits in a clearing in the Adirondacks. The Autumn colors are beautiful.
|
||||
|>||||
|
||||
|||INT. CABIN - SAME
|
||||
|>||||
|
||||
comment
|
||||
|||NAT NELSON (23, femme) sits by a tall window, typing on a laptop.
|
||||
|>||||
|
||||
Stuf at the end is a different ocmment
|
||||
|>||||Stuff at the end is a different comment
|
||||
|
@@ -76,7 +76,7 @@
|
||||
(function insertBlockBeforeComment [element]
|
||||
(case element
|
||||
((Comment (object start position))
|
||||
(vscode.postMessage (object type "insert" text "${KTxt2.emptyBlock}\n" position position)))
|
||||
(vscode.postMessage (object type "insert" text "\n${KTxt2.emptyBlock}" position position)))
|
||||
(otherwise (throw "element $element is not a comment"))))
|
||||
|
||||
(function insertBlockAfterComment [element]
|
||||
@@ -97,11 +97,18 @@
|
||||
(vscode.postMessage (object type "replace" text (toPlaintext newText) start start end end)))
|
||||
(otherwise (throw "element $element is not a block"))))
|
||||
|
||||
(function deleteEntireBlock [element]
|
||||
(case element
|
||||
((Block (object source text sourceStart start outputEnd end))
|
||||
(vscode.postMessage (object type "deleteBlock" start start end end)))
|
||||
(otherwise (throw "element $element is not a block"))))
|
||||
|
||||
(function blockElements [source output locked idx]
|
||||
(let [outerDiv (document.createElement "div")
|
||||
sourceDiv (document.createElement "div")
|
||||
outputDiv (document.createElement "div")
|
||||
lockDiv (document.createElement "div")]
|
||||
lockDiv (document.createElement "div")
|
||||
xLink (document.createElement "a")]
|
||||
(outerDiv.setAttribute "class" "container")
|
||||
(outerDiv.setAttribute "style" "display: flex;")
|
||||
(sourceDiv.setAttribute "style" "width: 50%; white-space: pre;")
|
||||
@@ -121,6 +128,13 @@
|
||||
(set lockDiv.innerHTML "!")
|
||||
// TODO add a "generate" button and "lock" button
|
||||
)
|
||||
// Link that will delete the whole block:
|
||||
(set xLink.innerHTML "x")
|
||||
(xLink.addEventListener "click"
|
||||
->(deleteEntireBlock (nth ktxt2Elements idx)))
|
||||
|
||||
(unless locked
|
||||
(outerDiv.appendChild xLink))
|
||||
(outerDiv.appendChild sourceDiv)
|
||||
(outerDiv.appendChild lockDiv)
|
||||
(outerDiv.appendChild outputDiv)
|
||||
|
@@ -16,6 +16,7 @@
|
||||
->e (when (= (e.document.uri.toString) (document.uri.toString))
|
||||
(updateWebview)))
|
||||
streamPosToDocumentPos ->pos (document.positionAt pos.absoluteChar)
|
||||
streamPosToOffsetDocumentPos ->[pos offset] (document.positionAt (+ offset pos.absoluteChar))
|
||||
rangeFromStartEnd ->[start end] (new Range (streamPosToDocumentPos start) (streamPosToDocumentPos end))
|
||||
makeEdit
|
||||
->[:WorkspaceEdit->Void builder]
|
||||
@@ -36,6 +37,9 @@
|
||||
((object type "insert" text text position position)
|
||||
(makeEdit
|
||||
->edit (edit.insert document.uri (streamPosToDocumentPos position) text)))
|
||||
((object type "deleteBlock" start start end end)
|
||||
(makeEdit
|
||||
->edit (edit.delete document.uri (new Range (streamPosToOffsetDocumentPos start -KTxt2.blockStartEnd.length) (streamPosToOffsetDocumentPos end KTxt2.blockStartEnd.length)))))
|
||||
(otherwise
|
||||
(Vscode.window.showErrorMessage "bad message $e from KTxt2Editor"))))
|
||||
|
||||
|
Reference in New Issue
Block a user