From c18fce40584332764b6edcb83091cb056dd3f9ad Mon Sep 17 00:00:00 2001 From: JensLincke Date: Tue, 19 Dec 2023 11:41:16 +0100 Subject: [PATCH 1/2] misc SQUASHED: AUTO-COMMIT-demos-tree-sitter-codemirror.md,AUTO-COMMIT-src-components-widgets-lively-code-mirror.js, --- demos/tree-sitter/codemirror.md | 2 +- src/components/widgets/lively-code-mirror.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/demos/tree-sitter/codemirror.md b/demos/tree-sitter/codemirror.md index ed533f1a5..0576a1d0c 100644 --- a/demos/tree-sitter/codemirror.md +++ b/demos/tree-sitter/codemirror.md @@ -7,7 +7,7 @@ - [X] hide line numbers - [X] hide scrollbars - [ ] update RegExp match while editing - +- [ ] Stefan's hide indentation/whitespace issue in shards ## Probe Example diff --git a/src/components/widgets/lively-code-mirror.js b/src/components/widgets/lively-code-mirror.js index b6e8f6529..468255a7d 100644 --- a/src/components/widgets/lively-code-mirror.js +++ b/src/components/widgets/lively-code-mirror.js @@ -291,7 +291,7 @@ export default class LivelyCodeMirror extends HTMLElement { // editor.setOption("showTrailingSpace", true) // editor.setOption("matchTags", true) - );editor.on("change", evt => this.dispatchEvent(new CustomEvent("change", { detail: evt }))); + );editor.on("change", (doc, evt) => this.dispatchEvent(new CustomEvent("change", { detail: evt }))); editor.on("change", (() => this.checkSyntax()).debounce(500)); editor.on("change", (() => this.astCapabilities.codeChanged()).debounce(200)); From cfa6f3b56c12a79428123da9c8af4dcc88c13857 Mon Sep 17 00:00:00 2001 From: JensLincke Date: Tue, 19 Dec 2023 16:07:27 +0100 Subject: [PATCH 2/2] drag windows with alt SQUASHED: AUTO-COMMIT-src-client-morphic-selecting.js,AUTO-COMMIT-src-client-preferences.js,AUTO-COMMIT-src-components-widgets-lively-window.js, --- src/client/morphic/selecting.js | 16 ++++++++++++---- src/client/preferences.js | 1 + src/components/widgets/lively-window.js | 15 +++++++++++++++ 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/src/client/morphic/selecting.js b/src/client/morphic/selecting.js index 21f9b32b5..e41af31b9 100644 --- a/src/client/morphic/selecting.js +++ b/src/client/morphic/selecting.js @@ -36,15 +36,16 @@ export default class Selecting { // return // } - // console.log("mouse down " + e.target.tagName) - e.stopPropagation(); - e.preventDefault(); + // console.log("[selecting.js] mouse down " + e.target.tagName) + // e.stopPropagation(); + // e.preventDefault(); } } static handleMouseUp(e) { + if (this.shouldHandle(e)) { - console.log("mouse up " + e.target.tagName) + // console.log("[selecting.js] mouse up " + e.target.tagName) e.stopPropagation(); e.preventDefault(); } else { @@ -102,6 +103,13 @@ export default class Selecting { static handleSelect(e) { // lively.notify("path " + e.composedPath().map(ea => ea.tagName)) + // we are custom dragging... and not selecting + if (lively.lastDragTime && ((Date.now() - lively.lastDragTime) < 1000)) { + // lively.showEvent(e).innerHTML = "custom drag" + return + } + + if (this.shouldHandle(e)) { // lively.showElement(e.composedPath()[0],1300).textContent = "path: " + e.composedPath().map(ea => ea.tagName).join(",") var path = this.slicePathIfContainerContent(e.composedPath()); diff --git a/src/client/preferences.js b/src/client/preferences.js index 00118910e..c75b6426c 100644 --- a/src/client/preferences.js +++ b/src/client/preferences.js @@ -44,6 +44,7 @@ export default class Preferences { BabylonianProgramming: {default: false, short: "use babylonian programming editor"}, SandblocksText: {default: false, short: "use sandblocks text editor"}, TabbedWindows: {default: false, short: "use experimental window tabs"}, + AltDragWindows: {default: false, short: "alt drag windows"}, SWEDebugging: {default: false, short: "bug showcase in swe lecture"}, AEXPGraphExperimental: {default: false, short: "AExpr graph experimental"}, GSFullLogInfo: {default: false, short: "full log info for GS"}, diff --git a/src/components/widgets/lively-window.js b/src/components/widgets/lively-window.js index fc406a80f..b3c869750 100644 --- a/src/components/widgets/lively-window.js +++ b/src/components/widgets/lively-window.js @@ -149,6 +149,8 @@ export default class Window extends Morph { this.get('.window-min').addEventListener('click', evt => { this.onMinButtonClicked(evt); }); this.get('.window-unmin').addEventListener('click', evt => { this.onMinButtonClicked(evt); }); + this.addEventListener('pointerdown', evt => { this.onPointerDown(evt) }, {capture: true}); + this.maxButton.addEventListener('click', evt => { this.onMaxButtonClicked(evt); }); this.addEventListener('dblclick', evt => { this.onDoubleClick(evt); }); this.get('.window-close').addEventListener('click', evt => { this.onCloseButtonClicked(evt); }); @@ -451,6 +453,7 @@ export default class Window extends Morph { } this.dragging = pt(evt.clientX, evt.clientY) } + lively.removeEventListener('lively-window-drag', this.windowTitle) lively.addEventListener('lively-window-drag', document.documentElement, 'pointermove', @@ -506,6 +509,8 @@ export default class Window extends Morph { .subPt(this.dragging).subPt(lively.getScroll()) lively.setPosition(this, Grid.optSnapPosition(pos, evt)) } + + lively.lastDragTime = Date.now() } } @@ -528,6 +533,16 @@ export default class Window extends Morph { } this.dropintoOtherWindow = null; } + + + onPointerDown(evt) { + if (lively.preferences.get("AltDragWindows") && evt.altKey) { // + + // lively.showEvent(evt).innerHTML = "alt: " + evt.altKey + this.onTitleMouseDown(evt) + } + + } onExtentChanged(evt) { // console.log(evt); // evt has no content? => current bounds must already have been refreshed