everything wrong with free software

 "obedience breeds foolishness"

### figured02 other pages: => the-wonders-of-modularity.html the-wonders-of-modularity *originally posted:* jul 2021 there is a very weird bug running .q, but this version is something i was trying to avoid. functions now get insert point as a parameter. .q takes three tries before it relents. looking at the compiled output didnt solve the mystery. (save as figured02.fig and compile) ``` #### license: creative commons cc0 1.0 (public domain) #### http://creativecommons.org/publicdomain/zero/1.0/ proginf = "fig user-reprogrammable editor 0.2, jul 2021 mn" p "" arr mid 1 0 cmds "" arr mid 1 0 osg "" cksv 0 insp 1 dflags arr mid 1 0 function rsave p g insp python save(p, g, insp) fig fig python 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(p, g, insp) fig next next while g lineinput gl g lcase ltrim rtrim glen gl len glcmd split gl " " mid 1 1 gld gl mid 1 1 instr gld "." not ifequal glcmd ".q" glcmd ".quit" next ifequal glcmd ".quit" ck instr cmds ".save" times cksv iftrue ck now rsave p g insp next now end next ifequal glcmd ".g" glcmd ".goto" next ifequal glcmd ".goto" plen p len pm1 plen minus 1 tlen ".goto" len times -1 plus glen token g ltrim rtrim right tlen ltrim val try insp token minus 1 ifless insp 0 insp 0 next ifmore insp plen insp plen next except insp plen next next ifequal glcmd ".list" ck instr cmds ".llist" iftrue ck python llist(p, g) fig next next ifequal glcmd ".save" cksv 0 next forin e cmds el e lcase ifequal glcmd el python try: exec("text = " + e[1:] + "(p, g, insp)") except: pass if type(text) == list: p = text ; insp = len(p) ; cksv = 1 fig next next iftrue gld plen p len pbef p left insp prc plen minus insp paft "" arr mid 1 0 ifless insp plen paft p right prc next p pbef plus g plus paft now insp plus 1 swap now insp cksv 1 next ck instr cmds ".update" iftrue ck python update(p, g, insp) 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 insp plen p len str len plus 1 c 0 now cls 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 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 p g now p len prints " lines" print lineinput fig ``` this one uses the support 0.1 was meant to provide: (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 sh p g insp glen g len tlen ".sh" len times -1 plus glen cmdline g ltrim rtrim right tlen ltrim python cmdline = cmdline.encode('utf-8') fig pad arr mid 1 0 bg g rtrim right 1 instr bg "&" ifequal bg 0 pad cmdline arrshell next forin each pad plen p len pbef p left insp prc plen minus insp paft "" arr mid 1 0 ifless insp plen paft p right prc next p pbef plus each plus paft now insp plus 1 swap now insp next iftrue bg now cmdline shell next iftrue pad now return p next fig ``` save routine: (save as save.fig, compile and copy to save.py) ``` #### license: creative commons cc0 1.0 (public domain) #### http://creativecommons.org/publicdomain/zero/1.0/ function save p g i glen g len tlen ".save" len times -1 plus glen filename g ltrim rtrim right tlen ltrim ck 1 sv 1 python try: f = open(filename) ; f.close() except: ck = 0 fig iftrue ck sv 0 q "file exists, overwrite? (y/n) " prints lineinput ltrim rtrim lcase ifequal q "y" sv 1 fig fig iftrue sv python try: with open(filename, "w") as outfile: for each in p: outfile.write((each + chr(10)).encode('utf-8')) except: pass fig fig fig ``` => https://wrongwithfreesw.neocities.org