-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'gh-pages' of https://github.com/LivelyKernel/lively4-core…
… into gh-pages
- Loading branch information
Showing
6 changed files
with
173 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# Code Mirror Shards Sandblocks Proof of Concept | ||
|
||
## Issues: | ||
|
||
- [ ] (cursor in/out) | ||
- [ ] keep focus while typing | ||
- [X] hide line numbers | ||
- [X] hide scrollbars | ||
- [ ] update RegExp match while editing | ||
|
||
|
||
## Probe Example | ||
|
||
<script> | ||
|
||
customElements.define( | ||
"probe-widget", | ||
class extends HTMLElement { | ||
constructor() { | ||
super(); | ||
this.attachShadow({ mode: "open" }); | ||
this.addEventListener("keyup", evt => { | ||
// evt.preventDefault() | ||
// evt.stopPropagation() | ||
}) | ||
|
||
this.addEventListener("keydown", evt => { | ||
// evt.preventDefault() | ||
// evt.stopPropagation() | ||
}) | ||
this.shadowRoot.innerHTML = ` | ||
<div style="border: 1px solid gray">PROBE | ||
<lively-code-mirror class="shard"></lively-code-mirror> | ||
<slot></slot></div> | ||
`; | ||
} | ||
}) | ||
|
||
|
||
var outerLivelyCodeMirror = await (<lively-code-mirror></lively-code-mirror>) | ||
outerLivelyCodeMirror.value = `var a = probe(3 + 4)` | ||
|
||
|
||
var debugLivelyCodeMirror = await (<lively-code-mirror></lively-code-mirror>) | ||
debugLivelyCodeMirror.editor.swapDoc(outerLivelyCodeMirror.editor.linkedDoc()) | ||
|
||
var regEx = new RegExp(/((probe\()(.*))\)/, "g"); | ||
do { | ||
var m = regEx.exec(outerLivelyCodeMirror.value); | ||
if (m) { | ||
var from = m.index | ||
var to = m.index + m[0].length | ||
|
||
|
||
var innerFrom = m.index + m[2].length | ||
var innerTo = m.index + m[1].length | ||
var editor = outerLivelyCodeMirror.editor | ||
|
||
var comp = await outerLivelyCodeMirror.wrapWidget("probe-widget", | ||
editor.posFromIndex(from), | ||
editor.posFromIndex(to)) | ||
|
||
var innerLivelyCodeMirror = comp.shadowRoot.querySelector("lively-code-mirror") | ||
innerLivelyCodeMirror.editor.swapDoc(editor.linkedDoc()) | ||
const opts = {collapsed: true, clearWhenEmpty: false, inclusiveLeft: false, inclusiveRight: true}; | ||
innerLivelyCodeMirror.editor.getDoc().markText(editor.posFromIndex(-1), editor.posFromIndex(innerFrom), opts); | ||
innerLivelyCodeMirror.editor.getDoc().markText(editor.posFromIndex(innerTo), editor.posFromIndex(innerLivelyCodeMirror.value.length), opts); | ||
|
||
|
||
debugger | ||
} | ||
} while (m); | ||
|
||
(<div>{outerLivelyCodeMirror}DEBUG:{debugLivelyCodeMirror}</div>) | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
## 2023-12-14 Tom's Window Wishlist for Christmas | ||
*Author: @JensLincke* | ||
|
||
|
||
- [ ] alt+drag on window moves it | ||
- [ ] open window attached to cursor (centered around cursor) | ||
- [ ] attached window can be resize via press down and drag | ||
- [ ] scale in directions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import {Logging} from "src/client/morphic/component-loader.js" | ||
|
||
var debugCounterByClass = new Map() | ||
var debugPrintMap = new WeakMap() // obj -> string | ||
var debugPrintReverseMap = new Map() // string -> obj | ||
|
||
// for debugging WeakRefs.... | ||
// var debugReg = new FinalizationRegistry(value => console.warn('COLLECTED: ' + value)) | ||
|
||
/*globals WeakRef */ | ||
|
||
export {Logging} | ||
|
||
function debugPrint(element) { | ||
var print = debugPrintMap.get(element) | ||
if (!print) { | ||
var className = element.constructor.name | ||
var counter = debugCounterByClass.get(className) || 0 | ||
counter++ | ||
debugCounterByClass.set(className, counter) | ||
print = className + counter | ||
debugPrintMap.set(element, print) | ||
debugSet(print, element) | ||
} | ||
return print | ||
} | ||
|
||
export function debugGet(name) { | ||
let ref = debugPrintReverseMap.get(name) | ||
return ref && ref.deref() | ||
} | ||
|
||
// debugGet("sb-block61") | ||
|
||
|
||
// let obj = document.body | ||
|
||
export function debugSet(name, obj) { | ||
let ref = new WeakRef(obj) | ||
// debugReg.register(obj, name) | ||
return debugPrintReverseMap.set(name, ref) | ||
} | ||
|
||
Logging.enable() | ||
|
||
Logging.setLog((element, ...args) => { | ||
|
||
if (element && element instanceof HTMLElement ) { | ||
console.log(debugPrint(element), ...args) | ||
} | ||
}) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters