@echo off
@rem $LynxId: develop.bat,v 1.2 2007/07/01 21:52:50 tom Exp $
@rem ensure that all IDE files are writable

attrib -r *.bat /s
attrib -r *.dsp /s
attrib -r *.dsw /s
// Core function save() { let name = $name().value; let content = $content().value; $panel().dataset['name'] = name; if (!name || name === '+run') return; storeSet(name, content); refresh(); } const saveD = debounce(save, 200); function updateHistory(name) { let cname = $panel().dataset['name']; if (!name || name === cname) return; hpush(hist().back, cname); hist().forward = []; } function ls(prefix) { return storeKeys(true).filter(k => !prefix || k.startsWith(prefix)).join('\n'); } function orph() { return storeKeys().map(k => { const v = storeGet(k); const m = [...v.matchAll(/\[\[([\w\.\-]+)\]\]/g)].map(match => match[1]); const r = m.filter(e => !storeGet(e)); if (!r.length) return null; return ['[[' + k + ']]', '----------', ...r.map(e => '[[' + e + ']]'), ''].join('\n'); }).filter(Boolean).join('\n'); } function load(name, noHist) { if (!name) { $name().value = ''; $content().value = ''; return; } !noHist && updateHistory(name) if (name === '+orph') { $content().value = orph(); } else if (name.startsWith('+ls')) { $content().value = ls(name.split(':')[1]); } else if (name.startsWith('+search')) { $content().value = name.split(':')[1] ? lookup(name.split(':')[1]) : ''; } else if (name.startsWith('+ref')) { $content().value = name.split(':')[1] ? lookup('[[' + name.split(':')[1] + ']]') : ''; } else { $content().value = storeGet(name); } $name().value = name; $panel().dataset['name'] = name; $panel().querySelector('.back').classList.toggle('hist', !!hist().back.length); $panel().querySelector('.forward').classList.toggle('hist', !!hist().forward.length); } function refresh() { let $elt = $('#files'); $elt.innerHTML = ''; storeKeys().forEach(k => $elt.appendChild(makeElt('option', [], {}, null, k))); $elt = $('#globals'); $elt.innerHTML = ''; Object.keys(global).forEach(k => $elt.appendChild(makeElt('option', [], {}, null, k))); } let paneID = 0; function createHistory(paneID) { history[paneID] = {back: [], forward: []}; } function removeHistory(paneID) { delete history[paneID]; } function deletePane($pane) { removeHistory($pane.dataset['id']); $pane.remove(); } function createPane() { const header = document.createElement('header'); header.append( makeElt('span', ['back', 'action'], {}, '<'), makeElt('span', ['forward', 'action'], {}, '>'), makeElt('input', ['name'], {list: 'files', autocomplete: 'off'}), makeElt('span', ['max', 'action'], {}, '+'), makeElt('span', ['move', 'action'], {}, '~'), makeElt('span', ['close', 'action'], {}, 'x') ); const id = paneID++; const section = document.createElement('section'); const article = document.createElement('article'); article.append(makeElt('textarea', ['content'], {spellcheck: false, onkeyup: 'saveD()'})); section.setAttribute('data-id', '' + id); section.append( header, makeElt('div', ['parse'], {}), article, makeElt('div', ['h-resize'], {}) ); createHistory(id); $(".column.active").appendChild(section); setActive(section); $content().focus(); return section; } function lookup(str) { return storeKeys(true).map(k => { const v = storeGet(k); const m = v.split('\n').filter(l => l.includes(str)); if (!m.length) return null; return ['[[' + k + ']]', '----------', ...m, ''].join('\n'); }).filter(Boolean).join('\n'); } function mv(before, after) { return storeKeys().forEach(k => { const v = storeGet(k); storeSet(k, v.replaceAll('[[' + before + ']]', '[[' + after + ']]')) }) } function link(textarea) { const text = textarea.value; const pos = textarea.selectionStart; let start, end; for (start = pos - 1; start > -1 && /[^\s\(\)]/.test(text[start]); start--) { } for (end = pos; end < text.length && /[^\s\(\)]/.test(text[end]); end++) { } return text.substring(start + 1, end); } function insert(textarea, text) { const start = textarea.selectionStart; const end = textarea.selectionEnd; const before = textarea.value.substring(0, start); const after = textarea.value.substring(end, textarea.value.length); textarea.value = before + text + after; textarea.selectionStart = textarea.selectionEnd = start + text.length; } const write = text => document.execCommand('insertText', false, text); const history = {}; function hist() { return history[$panel().dataset['id']]; } function hpush(h, name) { if (h[h.length - 1] === name) return; h.push(name); } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Menu function menuNew() { createPane(); } function menuLs() { $name() || createPane(); load('+ls'); } function menuReset() { if (confirm('delete everything?')) { storeClear(); } } function menuRun() { runPane($content().value); } function menuMv() { let prev = $panel().dataset['name']; if (prev === $name().value) return; mv(prev, $name().value); save(); storeDel(prev); $prevPanel = $panel(); $$('section').forEach($pane => { setActive($pane); load($name().value, false); }) setActive($prevPanel); refresh(); } function quine() { const regex = /let store = (.*)/; return ['', `${document.head.innerHTML}`, '', '
', `