From 7eaa8c0ae7ff22f7c4f6ac86e864575dc7dd0e49 Mon Sep 17 00:00:00 2001 From: Raphael Forment Date: Fri, 22 Sep 2023 19:31:04 +0200 Subject: [PATCH] fix vim keybindings bug --- index.html | 4 ++-- src/examples/excerpts.ts | 21 +++++++++------------ src/main.ts | 20 ++++++++++++++++++-- 3 files changed, 29 insertions(+), 16 deletions(-) diff --git a/index.html b/index.html index 54167a1..0ba3c1e 100644 --- a/index.html +++ b/index.html @@ -213,11 +213,11 @@
- +
- +
diff --git a/src/examples/excerpts.ts b/src/examples/excerpts.ts index 62b332a..2ee9e61 100644 --- a/src/examples/excerpts.ts +++ b/src/examples/excerpts.ts @@ -75,23 +75,20 @@ beat([4, 2, 8].pick() / [2,1].bar()) :: sound('triangle') .delay(0.5).delaytime(.75).delayfb(0.25) .room(1.5).size(1.9).out() `, - `// Super gentle computing - Bubobubobubo + `// Super gentle computing aka Super-Zapping - Bubobubobubo let melody = [30,30,34,35,37].palindrome() .beat() + [0, -12].repeatAll(2).beat(2) if (flip(8, 75)) { - rhythm(.5, 4, 8) :: sound('ST12').n([0,1,2].beat(0.5)).speed(0.5).gain(0.4).out() - rhythm(.5, 6, 8) :: sound('ST20').n([0,1,2].beat(0.5) + 20).gain(0.4) - .speed(0.25).end(0.1).orbit(2).room(0.5).size(0.5).out() - beat(.5) :: sound('ST01').note(melody).gain(0.4) - .n($(1)).speed(0.5).room(0.5).size(0.5).out() + rhythm(.5, 4, 8) :: sound('ST71').n([5,6,8].beat(0.5)).gain(0.4).out() + beat(.5) :: sound('ST11').note(melody).gain(0.4) + .n($(1)).room(0.5).size(0.5).out() } else { rhythm(.5, 2, 8) :: sound('ST20') - .n([0,1,2].beat(0.5)).speed(0.5).gain(0.4) - .end(0.1).out() - beat(.5) :: sound('ST01').note(melody).n($(1)).speed(0.5).gain(0.4).end(0.1).out() - beat(1) :: sound('ST02').note(melody).n($(1)).speed(0.5).gain(0.4).end(0.1).out() -}`, - `// Race day - Bubobubobubo + .n([0,1,2].beat(0.5)).gain(0.4) + .end(1).out() + beat(.5) :: sound('ST01').note(melody).n($(1)).gain(0.4).end(1).out() + beat(1) :: sound('ST02').note(melody).n($(1)).gain(0.4).end(1).out() +}`, `// Race day - Bubobubobubo bpm(125); beat(.5) :: sound('STB6').n(irand(1,10)).gain(1).out() rhythm(flip(4) ? 1 : .5, 5, 8) :: sound('kick').out() diff --git a/src/main.ts b/src/main.ts index fc2e8e4..c938639 100644 --- a/src/main.ts +++ b/src/main.ts @@ -35,7 +35,7 @@ import { makeStringExtensions } from "./StringExtensions"; const classMap = { h1: "text-white lg:text-4xl text-xl lg:ml-4 lg:mx-4 mx-2 lg:my-4 my-2 lg:mb-4 mb-4 bg-neutral-900 rounded-lg py-2 px-2", h2: "text-white lg:text-3xl text-xl lg:ml-4 lg:mx-4 mx-2 lg:my-4 my-2 lg:mb-4 mb-4 bg-neutral-900 rounded-lg py-2 px-2", - h3: "text-white lg:text-2xl text-xl lg:ml-4 lg:mx-4 mx-2 lg:my-4 my-2 lg:mb-4 mb-4 bg-neutral-700 rounded-lg py-2 px-2 lg:mt-16", + h3: "text-white lg:text-2xl text-xl lg:ml-4 lg:mx-4 mx-2 lg:my-4 my-2 lg:mb-4 mb-4 bg-neutoral-700 rounded-lg py-2 px-2 lg:mt-16", ul: "text-underline pl-6", li: "list-disc lg:text-2xl text-base text-white lg:mx-4 mx-2 my-4 my-2 leading-normal", p: "lg:text-2xl text-base text-white lg:mx-6 mx-2 my-4 leading-normal", @@ -287,9 +287,9 @@ export class Editor { }); this.editorExtensions = [ + this.vimModeCompartment.of(vimPlugin), this.withLineNumbers.of(lines), this.fontSize.of(fontModif), - this.vimModeCompartment.of(vimPlugin), this.hoveringCompartment.of(this.settings.tips ? inlineHoveringTips : []), editorSetup, toposTheme, @@ -554,12 +554,28 @@ export class Editor { "style", `font-size: ${this.settings.font_size}px;` ); + + // Get the right value to update graphical widgets this.line_numbers_checkbox.checked = this.settings.line_numbers; this.time_position_checkbox.checked = this.settings.time_position; this.tips_checkbox.checked = this.settings.tips; + + if (this.settings.vimMode) { + let vim = document.getElementById("vim-mode-radio") as HTMLInputElement; + let normal = document.getElementById("normal-mode-radio") as HTMLInputElement; + vim.checked = true; + normal.checked = false; + } else { + let vim = document.getElementById("vim-mode-radio") as HTMLInputElement; + let normal = document.getElementById("normal-mode-radio") as HTMLInputElement; + normal.checked = true; + vim.checked = false; + } + let modal_settings = document.getElementById("modal-settings"); let editor = document.getElementById("editor"); modal_settings?.classList.remove("invisible"); + editor?.classList.add("invisible"); });