minimal_UTF8.leo 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <!-- Created by Leo: https://leo-editor.github.io/leo-editor/leo_toc.html -->
  3. <leo_file xmlns:leo="http://leo-editor.github.io/leo-editor/namespaces/leo-python-editor/1.1" >
  4. <leo_header file_format="2"/>
  5. <globals/>
  6. <preferences/>
  7. <find_panel_settings/>
  8. <vnodes>
  9. <v t="caminhante.20230226160006.1"><vh>@settings</vh>
  10. <v t="caminhante.20230226160006.2"><vh>@data abbreviations</vh></v>
  11. <v t="caminhante.20230226160006.3"><vh>@outline-data tree-abbreviations</vh></v>
  12. <v t="caminhante.20230226160006.4"><vh>nodeActions</vh>
  13. <v t="caminhante.20230421001433.1"><vh>@bin *</vh></v>
  14. <v t="caminhante.20200604232050.1"><vh>@cmd *</vh></v>
  15. <v t="caminhante.20211012181130.1"><vh>@cp *</vh></v>
  16. <v t="caminhante.20211113172701.1"><vh>@files Makefile</vh></v>
  17. <v t="caminhante.20210501142945.2"><vh>@mkdir *</vh></v>
  18. <v t="caminhante.20211012180812.1"><vh>@mv *</vh></v>
  19. <v t="caminhante.20210905232208.1"><vh>@rm *</vh></v>
  20. <v t="caminhante.20210501142945.4"><vh>@rmdir /*/</vh></v>
  21. <v t="caminhante.20200618203115.1"><vh>@run|@run .* [X]</vh></v>
  22. <v t="caminhante.20230410165201.1"><vh>\@edit * [X]</vh></v>
  23. <v t="caminhante.20230623143806.1"><vh>\@file * [X]</vh></v>
  24. <v t="caminhante.20230623181912.1"><vh>/*/</vh></v>
  25. <v t="caminhante.20231002175916.1"><vh>\@path * [X]</vh></v>
  26. <v t="caminhante.20230623144919.1"><vh>*</vh></v>
  27. </v>
  28. </v>
  29. <v t="caminhante.20200309141027.3"><vh>Minimal UTF-8 support</vh>
  30. <v t="caminhante.20200309141415.1"><vh>@auto README.md</vh></v>
  31. <v t="caminhante.20200309141148.1"><vh>@file ./utf8.c</vh></v>
  32. <v t="caminhante.20200309141158.1"><vh>@file ./utf8.h</vh></v>
  33. <v t="caminhante.20200309145700.1"><vh>@clean Makefile</vh></v>
  34. </v>
  35. </vnodes>
  36. <tnodes>
  37. <t tx="caminhante.20200309141027.3"></t>
  38. <t tx="caminhante.20200309145700.1">@tabwidth 4
  39. CFLAGS := -std=gnu2x -Wall -Wextra -Werror -Wfatal-errors -Wno-unused-function -Wno-ignored-qualifiers -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -O2
  40. all: build/libminiutf8.so build/libminiutf8.a
  41. build/utf8.o: utf8.c utf8.h Makefile
  42. @mkdir -p build
  43. gcc $(CFLAGS) $&lt; -c -o $@
  44. build/libminiutf8.a: build/utf8.o
  45. ar cr $@ $&lt;
  46. ranlib $@
  47. build/libminiutf8.so: build/utf8.o
  48. gcc -shared $&lt; -o $@
  49. clean:
  50. rm -rfv build</t>
  51. <t tx="caminhante.20200604232050.1">import subprocess
  52. def execute (cmd):
  53. return subprocess.run(cmd,shell=True,universal_newlines=True,stderr=subprocess.STDOUT,stdout=subprocess.PIPE).stdout
  54. if c.isChanged(): c.save()
  55. path = c.getNodePath(c.p)
  56. g.os.chdir(path)
  57. command = ''.join(c.p.h.split('@cmd ')[1:])
  58. command = "cat &lt;&lt;'EOFEOFEOFEOFEOFEOF' | bash\n"+command+'\nEOFEOFEOFEOFEOFEOF'
  59. g.es(c.p.h)
  60. c.p.b += execute(command)
  61. c.save()
  62. </t>
  63. <t tx="caminhante.20200618203115.1">@language python
  64. import subprocess
  65. # def getpath (p):
  66. # dict = c.scanAllDirectives(p)
  67. # d = dict.get("path")
  68. # if p.isAnyAtFileNode():
  69. # filename = p.anyAtFileNodeName()
  70. # filename = g.os_path_join(d,filename)
  71. # if filename:
  72. # d = g.os_path_dirname(filename)
  73. # if d is None:
  74. # return ""
  75. # else:
  76. # return g.os_path_normpath(d)
  77. def execute (cmd):
  78. return subprocess.run(cmd,shell=True,universal_newlines=True,stderr=subprocess.STDOUT,stdout=subprocess.PIPE).stdout
  79. path = c.getNodePath(c.p)
  80. # g.os.chdir(path)
  81. w = c.frame.body.wrapper
  82. s1,s2 = w.getSelectionRange()
  83. if s1 == s2:
  84. code = c.p.b
  85. else:
  86. linebr = c.p.b.find('\n',s2)
  87. if linebr == -1: linebr = len(c.p.b)
  88. code = c.p.b[s1:s2]
  89. g.es(c.p.h)
  90. command = "cat &lt;&lt;'EOFEOFEOFEOFEOFEOF' | bash\ncd '"+path+"';\n"+code+'\nEOFEOFEOFEOFEOFEOF'
  91. if c.isChanged(): c.save()
  92. cpc = c.p.copy()
  93. novoNo = cpc.insertAsLastChild()
  94. novoNo.h = c.p.h + ' ['+code+']'
  95. novoNo.b = execute(command)
  96. c.save()
  97. w.setSelectionRange(s1,s2)
  98. c.redraw(c.p)
  99. </t>
  100. <t tx="caminhante.20210501142945.2">import subprocess
  101. def execute (cmd):
  102. return subprocess.run(cmd,shell=True,universal_newlines=True,stderr=subprocess.STDOUT,stdout=subprocess.PIPE).stdout
  103. path = c.getNodePath(c.p)
  104. g.os.chdir(path)
  105. path = ''.join(c.p.h.split('@mkdir ')[1:])
  106. cmd = "mkdir -p -- '" + path + "'"
  107. g.es(c.p.h)
  108. execute(cmd)
  109. c.p.h = '/'+path+'/'
  110. c.p.b = '@path ' + path
  111. </t>
  112. <t tx="caminhante.20210501142945.4">import subprocess
  113. import shutil
  114. def execute (cmd):
  115. return subprocess.run(cmd,shell=True,universal_newlines=True,stderr=subprocess.STDOUT,stdout=subprocess.PIPE).stdout
  116. ps = c.p.parents()
  117. for par in ps:
  118. break
  119. path = c.getNodePath(par)
  120. g.os.chdir(path)
  121. path = ''.join(c.p.h.split('@rmdir /')[1:]).split('/')[0]
  122. shutil.rmtree(path)
  123. c.p.b = 'deleted'
  124. c.p.deleteAllChildren()
  125. c.redraw(c.p)
  126. </t>
  127. <t tx="caminhante.20210905232208.1">import subprocess
  128. def execute (cmd):
  129. return subprocess.run(cmd,shell=True,universal_newlines=True,stderr=subprocess.STDOUT,stdout=subprocess.PIPE).stdout
  130. path = c.getNodePath(c.p)
  131. g.os.chdir(path)
  132. filename = ''.join(c.p.h.split('@rm ')[1:])
  133. cmd = 'rm -vf -- "' + filename + '"'
  134. g.es(c.p.h)
  135. g.es(execute(cmd))
  136. c.p.deleteAllChildren()
  137. c.redraw(c.p)
  138. </t>
  139. <t tx="caminhante.20211012180812.1">import subprocess
  140. def execute (cmd):
  141. return subprocess.run(cmd,shell=True,universal_newlines=True,stderr=subprocess.STDOUT,stdout=subprocess.PIPE).stdout
  142. path = c.getNodePath(c.p)
  143. g.os.chdir(path)
  144. if 'file://' in c.p.h:
  145. path = ''.join(c.p.h.split('@mv file://')[1:])
  146. else:
  147. path = ''.join(c.p.h.split('@mv ')[1:])
  148. cmd = "mv -v -- '" + path + "' ./"
  149. g.es(c.p.h)
  150. g.es(execute(cmd))
  151. </t>
  152. <t tx="caminhante.20211012181130.1">import subprocess
  153. def execute (cmd):
  154. return subprocess.run(cmd,shell=True,universal_newlines=True,stderr=subprocess.STDOUT,stdout=subprocess.PIPE).stdout
  155. path = c.getNodePath(c.p)
  156. g.os.chdir(path)
  157. if 'file://' in c.p.h:
  158. path = ''.join(c.p.h.split('@cp file://')[1:])
  159. else:
  160. path = ''.join(c.p.h.split('@cp ')[1:])
  161. cmd = "cp -v -- '" + path + "' ./"
  162. g.es(c.p.h)
  163. g.es(execute(cmd))
  164. </t>
  165. <t tx="caminhante.20211113172701.1">@language python
  166. import subprocess
  167. import re
  168. def execute (cmd):
  169. return subprocess.run(cmd,shell=True,universal_newlines=True,stderr=subprocess.STDOUT,stdout=subprocess.PIPE).stdout
  170. if c.isChanged(): c.save()
  171. path = c.getNodePath(c.p)
  172. g.os.chdir(path)
  173. cpc = c.p.copy()
  174. novoNo = cpc.insertAfter()
  175. novoNo.h = 'make return'
  176. novoNo.b = execute('make')
  177. c.redraw(c.p)
  178. </t>
  179. <t tx="caminhante.20230226160006.1">@tabwidth -2
  180. </t>
  181. <t tx="caminhante.20230226160006.2"></t>
  182. <t tx="caminhante.20230226160006.3"></t>
  183. <t tx="caminhante.20230226160006.4">@language python
  184. </t>
  185. <t tx="caminhante.20230410165201.1">path = ''.join(c.p.h.split('@edit ')[1:])
  186. c.p.h = path
  187. c.p.b = ''
  188. </t>
  189. <t tx="caminhante.20230421001433.1">import subprocess
  190. def execute (cmd):
  191. return subprocess.run(
  192. cmd,shell=True,
  193. universal_newlines=True,
  194. stderr=subprocess.STDOUT,
  195. stdout=subprocess.PIPE).stdout
  196. path = c.getNodePath(c.p)
  197. g.os.chdir(path)
  198. command = ''.join(c.p.h.split('@bin ')[1:])
  199. command = "xxd -- '"+command+"'"
  200. g.es(c.p.h)
  201. c.p.b = execute(command)
  202. c.save()
  203. </t>
  204. <t tx="caminhante.20230623143806.1">path = ''.join(c.p.h.split('@file ')[1:])
  205. c.p.h = path
  206. c.p.b = ''
  207. c.p.deleteAllChildren()
  208. c.redraw(c.p)
  209. </t>
  210. <t tx="caminhante.20230623144919.1">path = c.getNodePath(c.p)
  211. g.os.chdir(path)
  212. filename = c.p.h
  213. at = c.atFileCommands
  214. c.p.deleteAllChildren()
  215. c.p.h = "@file " + filename
  216. c.recreateGnxDict()
  217. at.readFileAtPosition(c.p)
  218. c.p.setDirty()
  219. c.redraw(c.p)
  220. c.p.contract()
  221. </t>
  222. <t tx="caminhante.20230623181912.1">c.p.deleteAllChildren()
  223. c.p.setDirty()
  224. c.redraw(c.p)
  225. </t>
  226. <t tx="caminhante.20231002175916.1">c.p.deleteAllChildren()
  227. c.p.setDirty()
  228. c.redraw(c.p)
  229. </t>
  230. </tnodes>
  231. </leo_file>