From ebeaeac97c0dc3eb303e38346a69e1dc61fe3646 Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Mon, 30 Nov 2020 13:20:51 -0500 Subject: Show character count of highlighted text in the REPL --- docs/repl.js | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'docs/repl.js') diff --git a/docs/repl.js b/docs/repl.js index 3c744d23..976882b8 100644 --- a/docs/repl.js +++ b/docs/repl.js @@ -1,10 +1,23 @@ let body = document.body; let doc={}; // html elements with a class body.querySelectorAll('[class]').forEach(e=>doc[e.classList[0]]=e); -let setcount = !doc.count ? (s=>s) : (s=>{ - let l = Array.from(s).length; - doc.count.textContent = l+" char"+(l!=1?"s":""); -}); + +let setcount = s=>s; +if (doc.count) { + let count_activeMin; + setcount = (s,m) => { + let l = Array.from(s).length; + if (l { + let s=c.selectionStart, e=c.selectionEnd; + setcount(c.value.slice(s,e), 2); + } +} + let setExplain = e=>e; let showErr = (s,e)=>{ let r=e.src, w=e.message, loc=[]; -- cgit v1.2.3