everything wrong with free software

 "obedience breeds foolishness"

### figured03 other pages: => the-wonders-of-modularity.html the-wonders-of-modularity *originally posted:* jul 2021 this is the version to try out. (save as figured03.fig and compile) ``` #### license: creative commons cc0 1.0 (public domain) #### http://creativecommons.org/publicdomain/zero/1.0/ proginf = "fig user-reprogrammable editor 0.3, jul 2021 mn" buf "" arr mid 1 0 cmds "" arr mid 1 0 osg "" cksv 0 insp 1 params arr mid 1 0 function vset params k v python params[k] = v return params fig fig function vget params k python return params[k] fig fig function getglcmd gl now gl ltrim split now " " mid 1 1 return now fig function gtoken g glcmd getglcmd g glen g len cmdlen glcmd len tlen instr g glcmd times -1 minus cmdlen plus glen token g right tlen return token fig function rsave p g python save(p, g) fig fig function textinsert buf p insp blen buf len bef buf left insp brc blen minus insp aft arr mid 1 0 ifless insp blen aft buf right brc next buf bef plus p plus aft now return buf fig python params = {} pst = [] if not os.isatty(stdin.fileno()): for each in stdin: pst += [str(each)[:-1]] sys.stdin.close() sys.stdin = os.fdopen(1) params["pstdin"] = pst try: osg = (os.getenv("HOME") + "/figured/").replace("//", "/") os.chdir(osg) from glob import glob plugins = glob("*.py") except: plugins = [] import readline for each in plugins: try: sig = each.split(".")[0] if "." + sig not in cmds and sig != "figured": exec("from " + sig + " import " + sig) cmds += ["." + sig] except: pass fig ck instr cmds ".hello" iftrue ck python hello(buf, params) fig next while g lineinput ck instr cmds ".gpreproc" iftrue ck python params["g"] = g g = gpreproc(buf, params) fig next gl g lcase ltrim rtrim glen gl len glcmd getglcmd gl gld glcmd mid 1 1 instr gld "." not gt gtoken g pb vset params "g" g vset params "text" buf vset params "token" gt params pb pad arr mid 1 0 pb vset params "pad" pad params pb ifequal glcmd ".q" glcmd ".quit" next ifequal glcmd ".quit" ck instr cmds ".save" times cksv iftrue ck now rsave buf params next now end next ifequal glcmd ".g" glcmd ".goto" next ifequal glcmd ".goto" blen buf len token gtoken g val try insp token minus 1 ifless insp 0 insp 0 next ifmore insp blen insp blen next except insp blen next next pb vset params "insp" insp params pb ifequal glcmd ".list" ck instr cmds ".llist" iftrue ck python llist(buf, params) fig next next ifequal glcmd ".save" cksv 0 next forin e cmds el e lcase ifequal glcmd el python try: exec("text = " + e[1:] + "(buf, params)") if type(text) == dict: params = text cksv = 1 pad = params["pad"] if pad: buf = textinsert(buf, pad, insp) ; insp += len(pad) else: buf = params["text"] ; insp = params["insp"] except: pass fig next next iftrue gld blen buf len bef buf left insp brc blen minus insp aft "" arr mid 1 0 ifless insp blen aft buf right brc next buf bef plus g plus aft now insp plus 1 swap now insp cksv 1 next ck instr cmds ".update" iftrue ck python update(buf, params) fig next wend ``` a plugin to display text: (save as update.fig, compile and copy to update.py) ``` #### license: creative commons cc0 1.0 (public domain) #### http://creativecommons.org/publicdomain/zero/1.0/ function update p g c 0 now cls python g["text"] = p fig plen p len str len plus 1 forin each p now c plus 1 swap now c cs c str now " " times plen plus cs plus " " right plen prints now each print next now return g fig ``` another to count lines: (save as wcl.fig, compile and copy to wcl.py) ``` #### license: creative commons cc0 1.0 (public domain) #### http://creativecommons.org/publicdomain/zero/1.0/ function wcl buf params now buf len prints " lines" print lineinput fig ``` shell: (save as sh.fig, compile and copy to sh.py) ``` #### license: creative commons cc0 1.0 (public domain) #### http://creativecommons.org/publicdomain/zero/1.0/ function vget g k python return g[k] fig fig function vset g k v python g[k] = v return g fig fig function sh buf params insp vget params "insp" glen vget params "g" len tlen ".sh" len times -1 plus glen cmdline vget params "g" ltrim rtrim right tlen ltrim python cmdline = cmdline.encode('utf-8') fig pad arr mid 1 0 pad vget params "g" arr bg vget params "g" rtrim right 1 instr bg "&" ifequal bg 0 padcmd cmdline arrshell pad plus padcmd next iftrue bg now cmdline shell next iftrue pad now vset params "text" buf vset params "pad" pad params now return params next fig ``` => https://wrongwithfreesw.neocities.org