1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75local props = props or { }
76
77local byte, char = string.byte, string.char
78local lower, upper, format = string.lower, string.upper, string.format
79local gsub, sub, find, rep, match, gmatch = string.gsub, string.sub, string.find, string.rep, string.match, string.gmatch
80local sort, concat = table.sort, table.concat
81local loadstring = loadstring or load
82
83local function check_output_pane()
84 editor.StyleClearAll(output)
85end
86
87
88
89local magicstring = rep("<ctx-crlf/>", 2)
90
91local l2 = char(0xC0)
92local l3 = char(0xE0)
93local l4 = char(0xF0)
94
95local function utflen(str)
96 local n = 0
97 local l = 0
98 for s in gmatch(str,".") do
99 if l > 0 then
100 l = l - 1
101 else
102 n = n + 1
103 if s >= l4 then
104 l = 3
105 elseif s >= l3 then
106 l = 2
107 elseif s >= l2 then
108 l = 1
109 end
110 end
111 end
112 return n
113end
114
115local function utfchar(u)
116 if u <= 0x7F then
117 return char(
118 u
119 )
120 elseif u <= 0x7FF then
121 return char (
122 0xC0 | (u >> 6),
123 0x80 | (u & 0x3F)
124 )
125 elseif u <= 0xFFFF then
126 return char (
127 0xE0 | (u >> 12),
128 0x80 | ((u >> 6) & 0x3F),
129 0x80 | (u & 0x3F)
130 )
131 elseif n < 0x110000 then
132 local n = u - 0x10000
133 local r = ((n & 0xF0000) >> 16) + 1
134 return char (
135 0xF0 | (r >> 2),
136 0x80 | ((r & 3) << 4) | ((n & 0x0F000) >> 12),
137 0x80 | ((n & 0x00FC0) >> 6),
138 0x80 | (n & 0x0003F)
139 )
140 else
141 return utfchar(0xFFFD)
142 end
143end
144
145
146
147function io.exists(filename)
148 local ok, result, message = pcall(io.open,filename)
149 if result then
150 io.close(result)
151 return true
152 else
153 return false
154 end
155end
156
157local function resultof(command)
158 local handle = io.popen(command,"r")
159 if handle then
160 local result = handle:read("*all") or ""
161 handle:close()
162 return result
163 else
164 return ""
165 end
166end
167
168function os.envvar(str)
169 local s = os.getenv(str)
170 if s ~= '' then
171 return s
172 end
173 s = os.getenv(upper(str))
174 if s ~= '' then
175 return s
176 end
177 s = os.getenv(lower(str))
178 if s ~= '' then
179 return s
180 end
181end
182
183local function loadtable(name)
184 local f = io.open(name,"rb")
185 if f then
186 f:close()
187 return dofile(name)
188 end
189end
190
191
192
193local crlf = "\n"
194local report = nil
195local trace = trace
196
197if trace then
198 report = function(fmt,...)
199 if fmt then
200 trace(format(fmt,...))
201 end
202 trace(crlf)
203 io.flush()
204 end
205else
206 trace = print
207 report = function(fmt,...)
208 if fmt then
209 trace(format(fmt,...))
210 else
211 trace("")
212 end
213 io.flush()
214 end
215end
216
217
218
219local function grab(str,delimiter)
220 local list = { }
221 for snippet in gmatch(str,delimiter) do
222 list[#list+1] = snippet
223 end
224 return list
225end
226
227local function expand(str)
228 return (gsub(str,"ENV%((%w+)%)", os.envvar))
229end
230
231local function strip(str)
232 return (gsub(str,"^%s*(.-)%s*$", "%1"))
233end
234
235local function alphasort(list,i)
236 if i and i > 0 then
237 local function alphacmp(a,b)
238 return lower(gsub(sub(a,i),'0',' ')) < lower(gsub(sub(b,i),'0',' '))
239 end
240 sort(list,alphacmp)
241 else
242 local function alphacmp(a,b)
243 return lower(a) < lower(b)
244 end
245 sort(list,alphacmp)
246 end
247end
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272local function extend_to_start()
273 local selectionstart = editor.SelectionStart
274 local selectionend = editor.SelectionEnd
275 local line = editor:LineFromPosition(selectionstart)
276 if line > 0 then
277 while line == editor:LineFromPosition(selectionstart-1) do
278 selectionstart = selectionstart - 1
279 editor:SetSel(selectionstart,selectionend)
280 end
281 else
282 selectionstart = 0
283 end
284 editor:SetSel(selectionstart,selectionend)
285 return selectionstart
286end
287
288local function extend_to_end()
289 local selectionstart = editor.SelectionStart
290 local selectionend = editor.SelectionEnd
291 local line = editor:LineFromPosition(selectionend)
292 while line == editor:LineFromPosition(selectionend+1) do
293 selectionend = selectionend + 1
294 editor:SetSel(selectionstart,selectionend)
295 if selectionend ~= editor.SelectionEnd then
296 break
297 end
298 end
299 editor:SetSel(selectionstart,selectionend)
300 return selectionend
301end
302
303local function getfiletype()
304 local language = gsub(props.Language or "","script_","")
305 if language ~= "" then
306 return language
307 else
308 local firstline = editor:GetLine(0) or ""
309 if find(firstline,"^%%") then
310 return 'tex'
311 elseif find(firstline,"^<%?xml") then
312 return 'xml'
313 else
314 return 'unknown'
315 end
316 end
317end
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345local cat
346
347local function toutfcode(pos)
348 local c1 = cat[pos]
349 if c1 < 0 then
350 c1 = 256 + c1
351 end
352 if c1 < 128 then
353 return c1, 1
354 end
355 if c1 < 224 then
356 local c2 = cat[pos+1]
357 if c2 < 0 then
358 c2 = 256 + c2
359 end
360 return c1 * 64 + c2 - 12416, 2
361 end
362 if c1 < 240 then
363 local c2 = cat[pos+1]
364 local c3 = cat[pos+2]
365 if c2 < 0 then
366 c2 = 256 + c2
367 end
368 if c3 < 0 then
369 c3 = 256 + c3
370 end
371 return (c1 * 64 + c2) * 64 + c3 - 925824, 3
372 end
373 if c1 < 245 then
374 local c2 = cat[pos+1]
375 local c3 = cat[pos+2]
376 local c4 = cat[pos+3]
377 if c2 < 0 then
378 c2 = 256 + c2
379 end
380 if c3 < 0 then
381 c3 = 256 + c3
382 end
383 if c4 < 0 then
384 c4 = 256 + c4
385 end
386 return ((c1 * 64 + c2) * 64 + c3) * 64 + c4 - 63447168, 4
387 end
388end
389
390
391
392do
393
394 check_output_pane()
395
396 print("Some CTX extensions:")
397
398 local wraplength = props['ctx.wraptext.length']
399
400 if wraplength and wraplength ~= "" then
401 print("\n- ctx.wraptext.length is set to " .. wraplength)
402 else
403 print("\n- ctx.wraptext.length is not set")
404 end
405
406 local helpinfo = props['ctx.helpinfo']
407
408 if helpinfo and helpinfo ~= "" then
409 print("\n- key bindings:\n")
410 print((gsub(strip(helpinfo),"%s*|%s*","\n")))
411 else
412 print("\n- no extra key bindings")
413 end
414
415 print("\n- recognized first lines:\n")
416 print("xml <?xml version='1.0' language='..'")
417 print("tex % language=..")
418 print(" ")
419 print("(lexing is currently being upgraded / improved / made more native to scite)")
420 print(" ")
421
422end
423
424
425
426
427
428function wrap_text()
429
430
431
432
433 local length = props["ctx.wraptext.length"]
434
435 if length == '' then length = 80 else length = tonumber(length) end
436
437 local startposition = editor.SelectionStart
438 local endposition = editor.SelectionEnd
439
440 if startposition == endposition then return end
441
442 editor:LineEndExtend()
443
444 startposition = editor.SelectionStart
445 endposition = editor.SelectionEnd
446
447
448
449
450
451
452
453
454 local startline = props['SelectionStartLine']
455 local endline = props['SelectionEndLine']
456 local startcolumn = props['SelectionStartColumn'] - 1
457 local endcolumn = props['SelectionEndColumn'] - 1
458
459 local replacement = { }
460 local templine = ''
461 local tempsize = 0
462 local indentation = rep(' ',startcolumn)
463 local selection = editor:GetSelText()
464
465 selection = gsub(selection,"[\n\r][\n\r]","\n")
466 selection = gsub(selection,"\n\n+",' ' .. magicstring .. ' ')
467 selection = gsub(selection,"^%s",'')
468
469 for snippet in gmatch(selection,"%S+") do
470 if snippet == magicstring then
471 replacement[#replacement+1] = templine
472 replacement[#replacement+1] = ""
473 templine = ''
474 tempsize = 0
475 else
476 local snipsize = utflen(snippet)
477 if tempsize + snipsize > length then
478 replacement[#replacement+1] = templine
479 templine = indentation .. snippet
480 tempsize = startcolumn + snipsize
481 elseif tempsize == 0 then
482 templine = indentation .. snippet
483 tempsize = tempsize + startcolumn + snipsize
484 else
485 templine = templine .. ' ' .. snippet
486 tempsize = tempsize + 1 + snipsize
487 end
488 end
489 end
490
491 replacement[#replacement+1] = templine
492 replacement[1] = gsub(replacement[1],"^%s+",'')
493
494 if endcolumn == 0 then
495 replacement[#replacement+1] = ""
496 end
497
498 editor:ReplaceSel(concat(replacement,"\n"))
499
500end
501
502function unwrap_text()
503
504 local startposition = editor.SelectionStart
505 local endposition = editor.SelectionEnd
506
507 if startposition == endposition then return end
508
509 editor:HomeExtend()
510 editor:LineEndExtend()
511
512 startposition = editor.SelectionStart
513 endposition = editor.SelectionEnd
514
515 local magicstring = rep("<multiplelines/>", 2)
516 local selection = gsub(editor:GetSelText(),"[\n\r][\n\r]+", ' ' .. magicstring .. ' ')
517 local replacement = ''
518
519 for snippet in gmatch(selection,"%S+") do
520 if snippet == magicstring then
521 replacement = replacement .. "\n"
522 else
523 replacement = replacement .. snippet .. "\n"
524 end
525 end
526
527 if endcolumn == 0 then replacement = replacement .. "\n" end
528
529 editor:ReplaceSel(replacement)
530
531end
532
533function sort_text()
534
535 local startposition = editor.SelectionStart
536 local endposition = editor.SelectionEnd
537
538 if startposition == endposition then return end
539
540
541
542
543
544
545 local startline = props['SelectionStartLine']
546 local endline = props['SelectionEndLine']
547 local startcolumn = props['SelectionStartColumn'] - 1
548 local endcolumn = props['SelectionEndColumn'] - 1
549
550 startposition = extend_to_start()
551 endposition = extend_to_end()
552
553 local selection = gsub(editor:GetSelText(), "%s*$", '')
554 local list = grab(selection,"[^\n\r]+")
555 alphasort(list, startcolumn)
556 local replacement = concat(list, "\n")
557
558 editor:GotoPos(startposition)
559 editor:SetSel(startposition,endposition)
560
561 if endcolumn == 0 then replacement = replacement .. "\n" end
562
563 editor:ReplaceSel(replacement)
564
565end
566
567do
568
569 local data = {
570 xml = {
571 pattern = "%<%!%-%-.-%-%-%>"
572 },
573 tex = {
574 pattern = "%%.-[\r\n]"
575 },
576 }
577
578 function remove_comment()
579 local filetype = getfiletype()
580 local filedata = data[filetype]
581 local selection = editor:GetSelText()
582 if filedata and selection ~= "" then
583 local startposition = editor.SelectionStart
584 local endposition = editor.SelectionEnd
585 selection = gsub(selection,filedata.pattern,"")
586 selection = gsub(selection,"%s+","")
587 editor:ReplaceSel(selection)
588 end
589 end
590
591end
592
593do
594
595
596
597 local patterns = {
598 "(%d+)%s+(%d+)%s+obj",
599 "(%d+)%s+(%d+)%s+R",
600 }
601
602 local function show_pdf_object(n)
603 local name = props.FilePath
604 local data = resultof("mtxrun --script pdf --object=" .. n .. " " .. name)
605 print(format("file: %s, object number: %s, object data:\n",name,n))
606 print(data)
607 end
608
609 function filter_pdf_object()
610 local filetype = getfiletype()
611 local selection = editor:GetSelText()
612 if filetype == "pdf" and selection ~= 0 then
613 local n, m
614 for i=1,#patterns do
615 n, m = match(selection,patterns[i])
616 if n and m then
617 break
618 end
619 end
620 n = tonumber(n)
621 m = tonumber(m)
622 if n and m then
623 show_pdf_object(n)
624 end
625 end
626 end
627
628 function search_pdf_object()
629 local filetype = getfiletype()
630 local selection = editor:GetSelText()
631 if filetype == "pdf" and selection ~= 0 then
632 local onstrip = OnStrip
633 function OnStrip(control,change)
634 if control == 2 then
635 local n = tonumber(scite.StripValue(1))
636 if n then
637 show_pdf_object(n)
638 end
639 OnStrip = onstrip
640 scite.StripShow("")
641 end
642 end
643 scite.StripShow("!'Object Number:'{}(&Search)\n")
644 end
645 end
646
647end
648
649do
650
651 local valid = {
652 xml = true,
653 tex = true,
654 }
655
656 function document_text()
657 local filetype = getfiletype()
658 if valid[filetype or ""] then
659 local startposition = editor.SelectionStart
660 local endposition = editor.SelectionEnd
661 if startposition ~= endposition then
662 startposition = extend_to_start()
663 endposition = extend_to_end()
664 editor:SetSel(startposition,endposition)
665 local replacement = ''
666 for i = editor:LineFromPosition(startposition), editor:LineFromPosition(endposition) do
667 local str = editor:GetLine(i)
668 if filetype == 'xml' then
669 if find(str,"^<%!%-%- .* %-%->%s*$") then
670 replacement = replacement .. gsub(str,"^<%!%-%- (.*) %-%->(%s*)$","%1\n")
671 elseif find(str,"%S") then
672 replacement = replacement .. '<!-- ' .. gsub(str,"(%s*)$",'') .. " -->\n"
673 else
674 replacement = replacement .. str
675 end
676 else
677 if find(str,"^%%D%s+$") then
678 replacement = replacement .. "\n"
679 elseif find(str,"^%%D ") then
680 replacement = replacement .. gsub(str,"^%%D ",'')
681 else
682 replacement = replacement .. '%D ' .. str
683 end
684 end
685 end
686 replacement = gsub(replacement,"[\n\r]$",'')
687 editor:ReplaceSel(replacement)
688 end
689 end
690 end
691
692end
693
694do
695
696 local data = {
697 xml = {
698 quote = {
699 left = "<quote>",
700 right = "</quote>",
701 },
702 quotation = {
703 left = "<quotation>",
704 right = "</quotation>",
705 },
706 },
707 tex = {
708 quote = {
709 left = "\\quote {",
710 right = "}",
711 },
712 quotation = {
713 left = "\\quotation {",
714 right = "}",
715 },
716 },
717 }
718
719 function quote_text()
720 local filetype = getfiletype()
721 local filedata = data[filetype]
722 local selection = editor:GetSelText()
723 if filedata and selection ~= "" then
724 selection = gsub(selection,[["(.-)"]], filedata.quotation.left .. "%1" .. filedata.quotation.right)
725 selection = gsub(selection,[['(.-)']], filedata.quote .left .. "%1" .. filedata.quote .right)
726 editor:ReplaceSel(selection)
727 end
728 end
729
730 function quote_text_s()
731 local filetype = getfiletype()
732 local filedata = data[filetype]
733 local selection = editor:GetSelText()
734 if filedata and selection ~= "" then
735 selection = filedata.quote.left .. selection .. filedata.quote.right
736 editor:ReplaceSel(selection)
737 end
738 end
739
740 function quote_text_d()
741 local filetype = getfiletype()
742 local filedata = data[filetype]
743 local selection = editor:GetSelText()
744 if filedata and selection ~= "" then
745 selection = filedata.quotation.left .. selection .. filedata.quotation.right
746 editor:ReplaceSel(selection)
747 end
748 end
749
750end
751
752do
753
754 local data = {
755 xml = {
756 pattern = [[(>[^<%-][^<%-]+)([-/])(%w%w+)]],
757 replacement = [[%1<compound token="%2"/>%3]],
758 },
759 tex = {
760 pattern = [[([^|])([-/]+)([^|])]],
761 replacement = [[%1|%2|%3]],
762 },
763 }
764
765 function compound_text()
766
767 local filetype = getfiletype()
768 local filedata = data[filetype]
769 local selection = editor:GetSelText()
770 if filedata and selection ~= "" then
771 selection = gsub(selection,filedata.pattern,filedata.replacement)
772 editor:ReplaceSel(selection)
773 end
774
775 end
776
777end
778
779
780
781
782
783do
784
785 function add_text()
786
787 local startposition = editor.SelectionStart
788 local endposition = editor.SelectionEnd
789
790 if startposition == endposition then return end
791
792 local selection = gsub(editor:GetSelText(), "%s*$", '')
793
794 local n, sum = 0, 0
795 for s in gmatch(selection,"[%-%+]?[%d%.%,]+") do
796 s = gsub(s,",",".")
797 local m = tonumber(s)
798 if m then
799 n = n + 1
800 sum = sum + m
801 report("%4i : %s",n,m)
802 end
803 end
804 if n > 0 then
805 report()
806 report("sum : %s",sum)
807 else
808 report("no numbers selected")
809 end
810
811 end
812
813end
814
815local dirty = { } do
816
817 local bidi = nil
818
819 local mapping = {
820 l = 0,
821 lre = 7,
822 lro = 7,
823 r = 2,
824 al = 3,
825 rle = 7,
826 rlo = 7,
827 pdf = 7,
828 en = 4,
829 es = 4,
830 et = 4,
831 an = 5,
832 cs = 6,
833 nsm = 6,
834 bn = 7,
835 b = 0,
836 s = 7,
837 ws = 0,
838 on = 7,
839 }
840
841
842
843 local colors = {
844 [0] = 0x000000,
845 [1] = 0x00007F,
846 [2] = 0x007F00,
847 [3] = 0x7F0000,
848 [4] = 0x7F7F00,
849 [5] = 0x7F007F,
850 [6] = 0x007F7F,
851 [7] = 0x007FB0,
852 [8] = 0x4F4F4F,
853 }
854
855
856
857
858
859
860 function show_bidi()
861
862 cat = editor.CharAt
863
864 editor.CodePage = SC_CP_UTF8
865
866 for i=1,#colors do
867 editor.StyleFore[i] = colors[i]
868 end
869
870 if not bidi then
871 bidi = require("context.scite-ctx-bidi")
872 end
873
874 local len = editor.TextLength
875 local str = editor:textrange(0,len-1)
876
877 local t = { }
878 local a = { }
879 local n = 0
880 local i = 0
881
882 local v
883 while i < len do
884 n = n + 1
885 v, s = toutfcode(i)
886 t[n] = v
887 a[n] = s
888 i = i + s
889 end
890
891 local t = bidi.process(t)
892
893 editor:StartStyling(0,31)
894
895 local defaultcolor = mapping.l
896 local mirrorcolor = 1
897
898 if false then
899 for i=1,n do
900 local direction = t[i].direction
901 local color = direction and (mapping[direction] or 0) or defaultcolor
902 editor:SetStyling(a[i],color)
903 end
904 else
905 local lastcolor = -1
906 local runlength = 0
907 for i=1,n do
908 local ti = t[i]
909 local direction = ti.direction
910 local mirror = t[i].mirror
911 local color = (mirror and mirrorcolor) or (direction and mapping[direction]) or defaultcolor
912 if color == lastcolor then
913 runlength = runlength + a[i]
914 else
915 if runlength > 0 then
916 editor:SetStyling(runlength,lastcolor)
917 end
918 lastcolor = color
919 runlength = a[i]
920 end
921 end
922 if runlength > 0 then
923 editor:SetStyling(runlength,lastcolor)
924 end
925 end
926
927 editor:SetStyling(2,31)
928
929 dirty[props.FileNameExt] = true
930
931 end
932
933end
934
935
936
937local menuactions = { }
938local menufunctions = { }
939local menuentries = { }
940
941function UserListShow(menutrigger, menulist)
942 if type(menulist) == "string" then
943 menuentries = { }
944 menuactions = { }
945 for item in gmatch(menulist,"[^%|]+") do
946 if item ~= "" then
947
948 for key, value in gmatch(item,"%s*(.+)=(.+)%s*") do
949 menuentries[#menuentries+1] = key
950 menuactions[key] = value
951 end
952 end
953 end
954 else
955 menuentries = menulist
956 menuactions = false
957 end
958 local menustring = concat(menuentries,'|')
959 if menustring == "" then
960 report("there are no (further) options defined for this file type")
961 else
962 editor.AutoCSeparator = byte('|')
963 editor:UserListShow(menutrigger,menustring)
964 editor.AutoCSeparator = byte(' ')
965 end
966end
967
968function OnUserListSelection(trigger,choice)
969 if menufunctions[trigger] then
970 return menufunctions[trigger](menuactions and menuactions[choice] or choice)
971 else
972 return false
973 end
974end
975
976
977
978do
979
980 local menutrigger = 12
981
982 function show_menu(menulist)
983 UserListShow(menutrigger, menulist)
984 end
985
986 function process_menu(action)
987 if not find(action,"%(%)$") then
988 assert(load(action .. "()"))()
989 else
990 assert(load(action))()
991 end
992 end
993
994 menufunctions[12] = process_menu
995
996end
997
998
999
1000
1001do
1002
1003
1004
1005 local templatetrigger = 13
1006
1007 local ctx_template_file = "scite-ctx-templates.lua"
1008 local ctx_template_list = { }
1009 local ctx_template_menu = { }
1010
1011
1012
1013
1014
1015 local patterns = {
1016 xml = "<%?context%-directive job ctxtemplate (.-) %?>"
1017 }
1018
1019 local function loadtemplate(name)
1020 local temp = gsub(name,"\\","/")
1021 local okay = loadtable(temp)
1022 if okay then
1023 print("template loaded: " .. name)
1024 end
1025 return okay
1026 end
1027
1028 local function loadtemplatefrompaths(path,name)
1029 return loadtemplate(path .. "/" .. name) or
1030 loadtemplate(path .. "/../" .. name) or
1031 loadtemplate(path .. "/../../" .. name)
1032 end
1033
1034 function insert_template(templatelist)
1035 local path = props["FileDir"]
1036 local suffix = props["FileExt"]
1037 local list = ctx_template_list[path]
1038 if list == nil then
1039 local pattern = patterns[suffix]
1040 local okay = false
1041 if pattern then
1042 for i=0,9 do
1043 local line = editor:GetLine(i) or ""
1044 local name = match(line,pattern)
1045 if name then
1046 okay = loadtemplatefrompaths(path,name)
1047 if not okay then
1048 name = resultof("mtxrun --find-file " .. name)
1049 if name then
1050 name = gsub(name,"\n","")
1051 okay = loadtemplate(name)
1052 end
1053 end
1054 break
1055 end
1056 end
1057 end
1058 if not okay then
1059 okay = loadtemplatefrompaths(path,ctx_template_file)
1060 end
1061 if not okay then
1062 okay = loadtemplate(props["SciteDefaultHome"] .. "/context/" .. ctx_template_file)
1063 end
1064 if okay then
1065 list = okay
1066 else
1067 list = false
1068 print("no template file found")
1069 end
1070 ctx_template_list[path] = list
1071 end
1072 ctx_template_menu = { }
1073 if list then
1074 local okay = list[suffix]
1075 if okay then
1076 local menu = { }
1077 for i=1,#okay do
1078 local o = okay[i]
1079 local n = o.name
1080 menu[#menu+1] = n
1081 ctx_template_menu[n] = o
1082 end
1083 UserListShow(templatetrigger, menu, true)
1084 end
1085 end
1086 end
1087
1088 function inject_template(action)
1089 if ctx_template_menu then
1090 local a = ctx_template_menu[action]
1091 if a then
1092 local template = a.template
1093 local nature = a.nature
1094 if template then
1095 local margin = props['SelectionStartColumn'] - 1
1096
1097 template = gsub(template,"%?%?","_____")
1098 local pos = find(template,"%?")
1099 template = gsub(template,"%?","")
1100 template = gsub(template,"_____","?")
1101 if nature == "display" then
1102 local spaces = rep(" ",margin)
1103 if not find(template,"\n$") then
1104 template = template .. "\n"
1105 end
1106 template = gsub(template,"\n",function(s)
1107 return "\n" .. spaces
1108 end)
1109 pos = pos + margin
1110 end
1111 editor:insert(editor.CurrentPos,template)
1112 if pos then
1113 editor.CurrentPos = editor.CurrentPos + pos - 1
1114 editor.SelectionStart = editor.CurrentPos
1115 editor.SelectionEnd = editor.CurrentPos
1116 editor:GotoPos(editor.CurrentPos)
1117 end
1118 end
1119 end
1120 end
1121 end
1122
1123 menufunctions[13] = inject_template
1124
1125end
1126
1127do
1128
1129
1130
1131
1132 local textlists = {
1133 en = {
1134 "a", "b", "c", "d", "e", "f", "g", "h", "i", "j",
1135 "k", "l", "m", "n", "o", "p", "q", "r", "s", "t",
1136 "u", "v", "w", "x", "y", "z",
1137
1138 "A", "B", "C", "D", "E", "F", "G", "H", "I", "J",
1139 "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T",
1140 "U", "V", "W", "X", "Y", "Z",
1141 },
1142 nl = {
1143 "a", "b", "c", "d", "e", "f", "g", "h", "i", "j",
1144 "k", "l", "m", "n", "o", "p", "q", "r", "s", "t",
1145 "u", "v", "w", "x", "y", "z",
1146
1147 "A", "B", "C", "D", "E", "F", "G", "H", "I", "J",
1148 "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T",
1149 "U", "V", "W", "X", "Y", "Z",
1150 },
1151 fr = {
1152 "a", "รฆ", "b", "c", "รง", "d", "e", "รจ", "รฉ", "รช",
1153 "f", "g", "h", "i", "j", "k", "l", "m", "n", "o",
1154 "p", "q", "r", "s", "t", "u", "v", "w", "x", "y",
1155 "z",
1156
1157 "A", "ร", "B", "C", "ร", "D", "E", "ร", "ร", "ร",
1158 "F", "G", "H", "I", "J", "K", "L", "M", "N", "O",
1159 "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y",
1160 "Z",
1161
1162 },
1163 de = {
1164 "a", "รค", "b", "c", "d", "e", "f", "g", "h", "i",
1165 "j", "k", "l", "m", "n", "o", "รถ", "p", "q", "r",
1166 "s", "ร", "t", "u", "รผ", "v", "w", "x", "y", "z",
1167
1168 "A", "ร", "B", "C", "D", "E", "F", "G", "H", "I",
1169 "J", "K", "L", "M", "N", "O", "ร", "P", "Q", "R",
1170 "S", "SS", "T", "U", "ร", "V", "W", "X", "Y", "Z",
1171 },
1172 fi = {
1173 "a", "b", "c", "d", "e", "f", "g", "h", "i", "j",
1174 "k", "l", "m", "n", "o", "p", "q", "r", "s", "t",
1175 "u", "v", "w", "x", "y", "z", "รฅ", "รค", "รถ",
1176
1177 "A", "B", "C", "D", "E", "F", "G", "H", "I", "J",
1178 "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T",
1179 "U", "V", "W", "X", "Y", "Z", "ร
", "ร", "ร",
1180 },
1181 sl = {
1182 "a", "b", "c", "ฤ", "ฤ", "d", "ฤ", "e", "f", "g", "h", "i",
1183 "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "ลก", "t",
1184 "u", "v", "w", "x", "y", "z", "ลพ",
1185
1186 "A", "B", "C", "ฤ", "ฤ", "D", "ฤ", "E", "F", "G", "H", "I",
1187 "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "ล ", "T",
1188 "U", "V", "W", "X", "Y", "Z", "ลฝ",
1189 },
1190 ru = {
1191 "ะฐ", "ะฑ", "ะฒ", "ะณ", "ะด", "ะต", "ั", "ะถ", "ะท", "ะธ",
1192 "ั", "ะน", "ะบ", "ะป", "ะผ", "ะฝ", "ะพ", "ะฟ", "ั", "ั",
1193 "ั", "ั", "ั", "ั
", "ั", "ั", "ั", "ั", "ั", "ั",
1194 "ั", "ัฃ", "ั", "ั", "ั", "ัณ", "ัต",
1195
1196 "ะ", "ะ", "ะ", "ะ", "ะ", "ะ", "ะ", "ะ", "ะ", "ะ",
1197 "ะ", "ะ", "ะ", "ะ", "ะ", "ะ", "ะ", "ะ", "ะ ", "ะก",
1198 "ะข", "ะฃ", "ะค", "ะฅ", "ะฆ", "ะง", "ะจ", "ะฉ", "ะช", "ะซ",
1199 "ะฌ", "ัข", "ะญ", "ะฎ", "ะฏ", "ัฒ", "ัด",
1200 },
1201 uk = {
1202 "ะฐ", "ะฑ", "ะฒ", "ะณ", "า", "ะด", "ะต", "ั", "ะถ", "ะท", "ะธ", "ั",
1203 "ั", "ะน", "ะบ", "ะป", "ะผ", "ะฝ", "ะพ", "ะฟ", "ั", "ั", "ั", "ั",
1204 "ั", "ั
", "ั", "ั", "ั", "ั", "ั", "ั", "ั",
1205
1206 "ะ", "ะ", "ะ", "ะ", "า", "ะ", "ะ", "ะ", "ะ", "ะ", "ะ", "ะ",
1207 "ะ", "ะ", "ะ", "ะ", "ะ", "ะ", "ะ", "ะ", "ะ ", "ะก", "ะข", "ะฃ",
1208 "ะค", "ะฅ", "ะฆ", "ะง", "ะจ", "ะฉ", "ะฌ", "ะฎ", "ะฏ",
1209 },
1210 be = {
1211 "ะฐ", "ะฑ", "ะฒ", "ะณ", "ะด", "ะต", "ั", "ะถ", "ะท", "ั",
1212 "ะน", "ะบ", "ะป", "ะผ", "ะฝ", "ะพ", "ะฟ", "ั", "ั", "ั",
1213 "ั", "ั", "ั", "ั
", "ั", "ั", "ั", "ั", "ั", "ั",
1214 "ั", "ั",
1215
1216 "ะ", "ะ", "ะ", "ะ", "ะ", "ะ", "ะ", "ะ", "ะ", "ะ",
1217 "ะ", "ะ", "ะ", "ะ", "ะ", "ะ", "ะ", "ะ ", "ะก", "ะข",
1218 "ะฃ", "ะ", "ะค", "ะฅ", "ะฆ", "ะง", "ะจ", "ะซ", "ะฌ", "ะญ",
1219 "ะฎ", "ะฏ",
1220 },
1221 bg = {
1222 "ะฐ", "ะฑ", "ะฒ", "ะณ", "ะด", "ะต", "ะถ", "ะท","ะธ", "ะน",
1223 "ะบ", "a", "ะป", "a", "ะผ", "ะฝ", "ะพ", "ะฟ", "ั", "ั",
1224 "ั", "ั", "ั", "ั
", "ั", "ั", "ั", "ั", "ั", "ั",
1225 "ั", "ั",
1226
1227 "ะ", "ะ", "ะ", "ะ", "ะ", "ะ", "ะ", "ะ","ะ", "ะ",
1228 "ะ", "A", "ะ", "A", "ะ", "ะ", "ะ", "ะ", "ะ ", "ะก",
1229 "ะข", "ะฃ", "ะค", "ะฅ", "ะฆ", "ะง", "ะจ", "ะฉ", "ะช", "ะฌ",
1230 "ะฎ", "ะฏ",
1231 },
1232 pl = {
1233 "a", "ฤ
", "b", "c", "ฤ", "d", "e", "ฤ", "f", "g",
1234 "h", "i", "j", "k", "l", "ล", "m", "n", "ล", "o",
1235 "รณ", "p", "q", "r", "s", "ล", "t", "u", "v", "w",
1236 "x", "y", "z", "ลบ", "ลผ",
1237
1238 "A", "ฤ", "B", "C", "ฤ", "D", "E", "ฤ", "F", "G",
1239 "H", "I", "J", "K", "L", "ล", "M", "N", "ล", "O",
1240 "ร", "P", "Q", "R", "S", "ล", "T", "U", "V", "W",
1241 "X", "Y", "Z", "ลน", "ลป",
1242 },
1243 cz = {
1244 "a", "รก", "b", "c", "ฤ", "d", "ฤ", "e", "รฉ", "ฤ",
1245 "f", "g", "h", "i", "รญ", "j", "k", "l", "m",
1246 "n", "ล", "o", "รณ", "p", "q", "r", "ล", "s", "ลก",
1247 "t", "ลฅ", "u", "รบ", "ลฏ", "v", "w", "x", "y", "รฝ",
1248 "z", "ลพ",
1249
1250 "A", "ร", "B", "C", "ฤ", "D", "ฤ", "E", "ร", "ฤ",
1251 "F", "G", "H", "I", "ร", "J", "K", "L", "M",
1252 "N", "ล", "O", "ร", "P", "Q", "R", "ล", "S", "ล ",
1253 "T", "ลค", "U", "ร", "ลฎ", "V", "W", "X", "Y", "ร",
1254 "Z", "ลฝ",
1255 },
1256 sk = {
1257 "a", "รก", "รค", "b", "c", "ฤ", "d", "ฤ",
1258 "e", "รฉ", "f", "g", "h", ch, "i", "รญ", "j", "k",
1259 "l", "ฤบ", "ฤพ", "m", "n", "ล", "o", "รณ", "รด", "p",
1260 "q", "r", "ล", "s", "ลก", "t", "ลฅ", "u", "รบ", "v",
1261 "w", "x", "y", "รฝ", "z", "ลพ",
1262
1263 "A", "ร", "ร", "B", "C", "ฤ", "D", "ฤ",
1264 "E", "ร", "F", "G", "H", "I", "ร", "J", "K",
1265 "L", "ฤน", "ฤฝ", "M", "N", "ล", "O", "ร", "ร", "P",
1266 "Q", "R", "ล", "S", "ล ", "T", "ลค", "U", "ร", "V",
1267 "W", "X", "Y", "ร", "Z", "ลฝ",
1268 },
1269 hr = {
1270 "a", "b", "c", "ฤ", "ฤ", "d", "ฤ", "e", "f",
1271 "g", "h", "i", "j", "k", "l", "m", "n",
1272 "o", "p", "r", "s", "ลก", "t", "u", "v", "z", "ลพ",
1273
1274 "A", "B", "C", "ฤ", "ฤ", "D", "ฤ", "E", "F",
1275 "G", "H", "I", "J", "K", "L", "M", "N",
1276 "O", "P", "R", "S", "ล ", "T", "U", "V", "Z", "ลฝ",
1277 },
1278 sr = {
1279 "ะฐ", "ะฑ", "ะฒ", "ะณ", "ะด", "ั", "ะต", "ะถ", "ะท", "ะธ",
1280 "ั", "ะบ", "ะป", "ั", "ะผ", "ะฝ", "ั", "ะพ", "ะฟ", "ั",
1281 "ั", "ั", "ั", "ั", "ั", "ั
", "ั", "ั", "ั", "ั",
1282
1283 "ะ", "ะ", "ะ", "ะ", "ะ", "ะ", "ะ", "ะ", "ะ", "ะ",
1284 "ะ", "ะ", "ะ", "ะ", "ะ", "ะ", "ะ", "ะ", "ะ", "ะ ",
1285 "ะก", "ะข", "ะ", "ะฃ", "ะค", "ะฅ", "ะฆ", "ะง", "ะ", "ะจ",
1286 },
1287 no = {
1288 "a", "b", "c", "d", "e", "f", "g", "h", "i", "j",
1289 "k", "l", "m", "n", "o", "p", "q", "r", "s", "t",
1290 "u", "v", "w", "x", "y", "z", "รฆ", "รธ", "รฅ",
1291
1292 "A", "B", "C", "D", "E", "F", "G", "H", "I", "J",
1293 "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T",
1294 "U", "V", "W", "X", "Y", "Z", "ร", "ร", "ร
",
1295 },
1296 da = {
1297 "a", "b", "c", "d", "e", "f", "g", "h", "i", "j",
1298 "k", "l", "m", "n", "o", "p", "q", "r", "s", "t",
1299 "u", "v", "w", "x", "y", "z", "รฆ", "รธ", "รฅ",
1300
1301 "A", "B", "C", "D", "E", "F", "G", "H", "I", "J",
1302 "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T",
1303 "U", "V", "W", "X", "Y", "Z", "ร", "ร", "ร
",
1304 },
1305 sv = {
1306 "a", "b", "c", "d", "e", "f", "g", "h", "i", "j",
1307 "k", "l", "m", "n", "o", "p", "q", "r", "s", "t",
1308 "u", "v", "w", "x", "y", "z", "รฅ", "รค", "รถ",
1309
1310 "A", "B", "C", "D", "E", "F", "G", "H", "I", "J",
1311 "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T",
1312 "U", "V", "W", "X", "Y", "Z", "ร
", "ร", "ร",
1313 },
1314 is = {
1315 "a", "รก", "b", "d", "รฐ", "e", "รฉ", "f", "g", "h",
1316 "i", "รญ", "j", "k", "l", "m", "n", "o", "รณ", "p",
1317 "r", "s", "t", "u", "รบ", "v", "x", "y", "รฝ", "รพ",
1318 "รฆ", "รถ",
1319
1320 "A", "ร", "B", "D", "ร", "E", "ร", "F", "G", "H",
1321 "I", "ร", "J", "K", "L", "M", "N", "O", "ร", "P",
1322 "R", "S", "T", "U", "ร", "V", "X", "Y", "ร", "ร",
1323 "ร", "ร",
1324 },
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357 gr = {
1358 "ฮฑ", "ฮฒ", "ฮณ", "ฮด", "ฮต", "ฮถ", "ฮท", "ฮธ", "ฮน", "ฮบ",
1359 "ฮป", "ฮผ", "ฮฝ", "ฮพ", "ฮฟ", "ฯ", "ฯ", "ฯ", "ฯ", "ฯ
",
1360 "ฯ", "ฯ", "ฯ", "ฯ",
1361
1362 "ฮ", "ฮ", "ฮ", "ฮ", "ฮ", "ฮ", "ฮ", "ฮ", "ฮ", "ฮ",
1363 "ฮ", "ฮ", "ฮ", "ฮ", "ฮ", "ฮ ", "ฮก", "ฮฃ", "ฮค", "ฮฅ",
1364 "ฮง", "ฮจ", "ฮฉ",
1365 },
1366 la = {
1367 "a", "ฤ", "ฤ", "b", "c", "d", "e", "ฤ", "ฤ", "f",
1368 "g", "h", "i", "ฤซ", "ฤญ", "j", "k", "l", "m", "n",
1369 "o", "ล", "ล", "p", "q", "r", "s", "t", "u", "ลซ",
1370 "ลญ", "v", "w", "x", "y", "ศณ", "yฬ", "z", "รฆ",
1371
1372 "A", "ฤ", "ฤ", "B", "C", "D", "E", "ฤ", "ฤ", "F",
1373 "G", "H", "I", "ฤช", "ฤฌ", "J", "K", "L", "M", "N",
1374 "O", "ล", "ล", "P", "Q", "R", "S", "T", "U", "ลช",
1375 "ลฌ", "V", "W", "X", "Y", "ศฒ", "Yฬ", "Z", "ร",
1376 },
1377 it = {
1378 "a", "รก", "b", "c", "d", "e", "รฉ", "รจ", "f", "g",
1379 "h", "i", "รญ", "รฌ", "j", "k", "l", "m", "n", "o",
1380 "รณ", "รฒ", "p", "q", "r", "s", "t", "u", "รบ", "รน",
1381 "v", "w", "x", "y", "z",
1382
1383 "A", "ร", "B", "C", "D", "E", "ร", "ร", "F", "G",
1384 "H", "I", "ร", "ร", "J", "K", "L", "M", "N", "O",
1385 "ร", "ร", "P", "Q", "R", "S", "T", "U", "ร", "ร",
1386 "V", "W", "X", "Y", "Z",
1387 },
1388 ro = {
1389 "a", "ฤ", "รข", "b", "c", "d", "e", "f", "g", "h",
1390 "i", "รฎ", "j", "k", "l", "m", "n", "o", "p", "q",
1391 "r", "s", "ศ", "t", "ศ", "u", "v", "w", "x", "y",
1392 "z",
1393
1394 "A", "ฤ", "ร", "B", "C", "D", "E", "F", "G", "H",
1395 "I", "ร", "J", "K", "L", "M", "N", "O", "P", "Q",
1396 "R", "S", "ศ", "T", "ศ", "U", "V", "W", "X", "Y",
1397 "Z",
1398 },
1399 es = {
1400 "a", "รก", "b", "c", "d", "e", "รฉ", "f", "g", "h",
1401 "i", "รญ", "j", "k", "l", "m", "n", "รฑ", "o", "รณ",
1402 "p", "q", "r", "s", "t", "u", "รบ", "รผ", "v", "w",
1403 "x", "y", "z",
1404
1405 "A", "ร", "B", "C", "D", "E", "ร", "F", "G", "H",
1406 "I", "ร", "J", "K", "L", "M", "N", "ร", "O", "ร",
1407 "P", "Q", "R", "S", "T", "U", "ร", "ร", "V", "W",
1408 "X", "Y", "Z",
1409 },
1410 pt = {
1411 "a", "รก", "รข", "รฃ", "ร ", "b", "c", "รง", "d", "e",
1412 "รฉ", "รช", "f", "g", "h", "i", "รญ", "j", "k", "l",
1413 "m", "n", "o", "รณ", "รด", "รต", "p", "q", "r", "s",
1414 "t", "u", "รบ", "รผ", "v", "w", "x", "y", "z",
1415
1416 "A", "ร", "ร", "ร", "ร", "B", "C", "ร", "D", "E",
1417 "ร", "ร", "F", "G", "H", "I", "ร", "J", "K", "L",
1418 "M", "N", "O", "ร", "ร", "ร", "P", "Q", "R", "S",
1419 "T", "U", "ร", "ร", "V", "W", "X", "Y", "Z",
1420 },
1421 lt = {
1422 "a", "ฤ
", "b", "c", "ch", "ฤ", "d", "e", "ฤ", "ฤ",
1423 "f", "g", "h", "i", "ฤฏ", "y", "j", "k", "l", "m",
1424 "n", "o", "p", "r", "s", "ลก", "t", "u", "ลณ", "ลซ",
1425 "v", "z", "ลพ",
1426
1427 "A", "ฤ", "B", "C", "CH", "ฤ", "D", "E", "ฤ", "ฤ",
1428 "F", "G", "H", "I", "ฤฎ", "Y", "J", "K", "L", "M",
1429 "N", "O", "P", "R", "S", "ล ", "T", "U", "ลฒ", "ลช",
1430 "V", "Z", "ลฝ",
1431 },
1432 lv = {
1433 "a", "ฤ", "b", "c", "ฤ", "d", "e", "ฤ", "f", "g",
1434 "ฤฃ", "h", "i", "ฤซ", "j", "k", "ฤท", "l", "ฤผ", "m",
1435 "n", "ล", "o", "ล", "p", "r", "ล", "s", "ลก", "t",
1436 "u", "ลซ", "v", "z", "ลพ",
1437
1438 "A", "ฤ", "B", "C", "ฤ", "D", "E", "ฤ", "F", "G",
1439 "ฤข", "H", "I", "ฤช", "J", "K", "ฤถ", "L", "ฤป", "M",
1440 "N", "ล
", "O", "ล", "P", "R", "ล", "S", "ล ", "T",
1441 "U", "ลช", "V", "Z", "ลฝ",
1442 },
1443 hu = {
1444 "a", "รก", "b", "c", "d", "e", "รฉ",
1445 "f", "g", "h", "i", "รญ", "j", "k", "l",
1446 "m", "n", "o", "รณ", "รถ", "ล", "p", "q", "r",
1447 "s", "t", "u", "รบ", "รผ", "ลฑ", "v", "w",
1448 "x", "y", "z",
1449
1450 "A", "ร", "B", "C", "D", "E", "ร",
1451 "F", "G", "H", "I", "ร", "J", "K", "L",
1452 "M", "N", "O", "ร", "ร", "ล", "P", "Q", "R",
1453 "S", "T", "U", "ร", "ร", "ลฐ", "V", "W",
1454 "X", "Y", "Z",
1455 },
1456 et = {
1457 "a", "b", "d", "e", "f", "g", "h", "i", "j", "k",
1458 "l", "m", "n", "o", "p", "r", "s", "ลก", "z", "ลพ",
1459 "t", "u", "v", "w", "รต", "รค", "รถ", "รผ", "x", "y",
1460
1461 "A", "B", "D", "E", "F", "G", "H", "I", "J", "K",
1462 "L", "M", "N", "O", "P", "R", "S", "ล ", "Z", "ลฝ",
1463 "T", "U", "V", "W", "ร", "ร", "ร", "ร", "X", "Y",
1464 },
1465
1466
1467
1468
1469
1470
1471
1472 }
1473
1474 local textselector = { }
1475 for k, v in next, textlists do
1476 textselector[#textselector+1] = k
1477 end
1478 table.sort(textselector)
1479
1480
1481
1482
1483
1484 local mathsets = {
1485 { "tf", {
1486 "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z",
1487 "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z",
1488 "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"
1489 }, },
1490 { "bf", {
1491 "๐", "๐", "๐", "๐", "๐", "๐ ", "๐ก", "๐ข", "๐ฃ", "๐ค", "๐ฅ", "๐ฆ", "๐ง", "๐จ", "๐ฉ", "๐ช", "๐ซ", "๐ฌ", "๐ญ", "๐ฎ", "๐ฏ", "๐ฐ", "๐ฑ", "๐ฒ", "๐ณ",
1492 "๐", "๐", "๐", "๐", "๐", "๐
", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐",
1493 "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐"
1494 }, },
1495 { "it", {
1496 "๐", "๐", "๐", "๐", "๐", "๐", "๐", "โ", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐ ", "๐ก", "๐ข", "๐ฃ", "๐ค", "๐ฅ", "๐ฆ", "๐ง",
1497 "๐ด", "๐ต", "๐ถ", "๐ท", "๐ธ", "๐น", "๐บ", "๐ป", "๐ผ", "๐ฝ", "๐พ", "๐ฟ", "๐", "๐", "๐", "๐", "๐", "๐
", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐",
1498 }, },
1499 { "bi", {
1500 "๐", "๐", "๐", "๐
", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐",
1501 "๐จ", "๐ฉ", "๐ช", "๐ซ", "๐ฌ", "๐ญ", "๐ฎ", "๐ฏ", "๐ฐ", "๐ฑ", "๐ฒ", "๐ณ", "๐ด", "๐ต", "๐ถ", "๐ท", "๐ธ", "๐น", "๐บ", "๐ป", "๐ผ", "๐ฝ", "๐พ", "๐ฟ", "๐", "๐",
1502 }, },
1503 { "sc", {
1504 "๐ต", "๐ถ", "๐ท", "๐ธ", "๐น", "โฏ", "๐ป", "โ", "๐ฝ", "๐พ", "๐ฟ", "๐", "๐", "๐", "๐", "โด", "๐
", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐",
1505 "๐", "โฌ", "๐", "๐", "โฐ", "โฑ", "๐ข", "โ", "โ", "๐ฅ", "๐ฆ", "โ", "โณ", "๐ฉ", "๐ช", "๐ซ", "๐ฌ", "โ", "๐ฎ", "๐ฏ", "๐ฐ", "๐ฑ", "๐ฒ", "๐ณ", "๐ด",
1506 }, },
1507 { "sc bf", {
1508 "๐ช", "๐ซ", "๐ฌ", "๐ญ", "๐ฎ", "๐ฏ", "๐ฐ", "๐ฑ", "๐ฒ", "๐ณ", "๐ด", "๐ต", "๐ถ", "๐ท", "๐ธ", "๐น", "๐บ", "๐ป", "๐ผ", "๐ฝ", "๐พ", "๐ฟ", "๐", "๐", "๐", "๐",
1509 "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐ ", "๐ก", "๐ข", "๐ฃ", "๐ค", "๐ฅ", "๐ฆ", "๐ง", "๐จ", "๐ฉ",
1510 }, },
1511 { "fr", {
1512 "๐", "๐", "๐ ", "๐ก", "๐ข", "๐ฃ", "๐ค", "๐ฅ", "๐ฆ", "๐ง", "๐จ", "๐ฉ", "๐ช", "๐ซ", "๐ฌ", "๐ญ", "๐ฎ", "๐ฏ", "๐ฐ", "๐ฑ", "๐ฒ", "๐ณ", "๐ด", "๐ต", "๐ถ", "๐ท",
1513 "๐", "๐
", "โญ", "๐", "๐", "๐", "๐", "โ", "โ", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "โ", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "โจ",
1514 }, },
1515 { "ds", {
1516 "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐ ", "๐ก", "๐ข", "๐ฃ", "๐ค", "๐ฅ", "๐ฆ", "๐ง", "๐จ", "๐ฉ", "๐ช", "๐ซ",
1517 "๐ธ", "๐น", "โ", "๐ป", "๐ผ", "๐ฝ", "๐พ", "โ", "๐", "๐", "๐", "๐", "๐", "โ", "๐", "โ", "โ", "โ", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "โค", "๐",
1518 "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐ ", "๐ก"
1519 }, },
1520 { "fr bf", {
1521 "๐ฌ", "๐ญ", "๐ฎ", "๐ฏ", "๐ฐ", "๐ฑ", "๐ฒ", "๐ณ", "๐ด", "๐ต", "๐ถ", "๐ท", "๐ธ", "๐น", "๐บ", "๐ป", "๐ผ", "๐ฝ", "๐พ", "๐ฟ", "๐", "๐", "๐", "๐",
1522 "๐", "๐
", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐"
1523 }, },
1524 { "ss tf", {
1525 "๐บ", "๐ป", "๐ผ", "๐ฝ", "๐พ", "๐ฟ", "๐", "๐", "๐", "๐", "๐", "๐
", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐",
1526 "๐ ", "๐ก", "๐ข", "๐ฃ", "๐ค", "๐ฅ", "๐ฆ", "๐ง", "๐จ", "๐ฉ", "๐ช", "๐ซ", "๐ฌ", "๐ญ", "๐ฎ", "๐ฏ", "๐ฐ", "๐ฑ", "๐ฒ", "๐ณ", "๐ด", "๐ต", "๐ถ", "๐ท", "๐ธ", "๐น",
1527 "๐ข", "๐ฃ", "๐ค", "๐ฅ", "๐ฆ", "๐ง", "๐จ", "๐ฉ", "๐ช", "๐ซ"
1528 }, },
1529 { "ss bf", {
1530 "๐ฎ", "๐ฏ", "๐ฐ", "๐ฑ", "๐ฒ", "๐ณ", "๐ด", "๐ต", "๐ถ", "๐ท", "๐ธ", "๐น", "๐บ", "๐ป", "๐ผ", "๐ฝ", "๐พ", "๐ฟ", "๐", "๐", "๐", "๐", "๐", "๐
", "๐", "๐",
1531 "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐ ", "๐ก", "๐ข", "๐ฃ", "๐ค", "๐ฅ", "๐ฆ", "๐ง", "๐จ", "๐ฉ", "๐ช", "๐ซ", "๐ฌ", "๐ญ",
1532 "๐ฌ", "๐ญ", "๐ฎ", "๐ฏ", "๐ฐ", "๐ฑ", "๐ฒ", "๐ณ", "๐ด", "๐ต",
1533 }, },
1534 { "ss it", {
1535 "๐ข", "๐ฃ", "๐ค", "๐ฅ", "๐ฆ", "๐ง", "๐จ", "๐ฉ", "๐ช", "๐ซ", "๐ฌ", "๐ญ", "๐ฎ", "๐ฏ", "๐ฐ", "๐ฑ", "๐ฒ", "๐ณ", "๐ด", "๐ต", "๐ถ", "๐ท", "๐ธ", "๐น", "๐บ", "๐ป",
1536 "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐ ", "๐ก",
1537 }, },
1538 { "ss bi", {
1539 "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐ ", "๐ก", "๐ข", "๐ฃ", "๐ค", "๐ฅ", "๐ฆ", "๐ง", "๐จ", "๐ฉ", "๐ช", "๐ซ", "๐ฌ", "๐ญ", "๐ฎ", "๐ฏ",
1540 "๐ผ", "๐ฝ", "๐พ", "๐ฟ", "๐", "๐", "๐", "๐", "๐", "๐
", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐",
1541 }, },
1542 { "tt", {
1543 "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐ ", "๐ก", "๐ข", "๐ฃ",
1544 "๐ฐ", "๐ฑ", "๐ฒ", "๐ณ", "๐ด", "๐ต", "๐ถ", "๐ท", "๐ธ", "๐น", "๐บ", "๐ป", "๐ผ", "๐ฝ", "๐พ", "๐ฟ", "๐", "๐", "๐", "๐", "๐", "๐
", "๐", "๐", "๐", "๐",
1545 "๐ถ", "๐ท", "๐ธ", "๐น", "๐บ", "๐ป", "๐ผ", "๐ฝ", "๐พ", "๐ฟ"
1546 }, },
1547 { "gr tf", {
1548 "ฮฑ", "ฮฒ", "ฮณ", "ฮด", "ฮต", "ฮถ", "ฮท", "ฮธ", "ฮน", "ฮบ", "ฮป", "ฮผ", "ฮฝ", "ฮพ", "ฮฟ", "ฯ", "ฯ", "ฯ", "ฯ", "ฯ", "ฯ
", "ฯ", "ฯ", "ฯ", "ฯ",
1549 "ฮ", "ฮ", "ฮ", "ฮ", "ฮ", "ฮ", "ฮ", "ฮ", "ฮ", "ฮ", "ฮ", "ฮ", "ฮ", "ฮ", "ฮ", "ฮ ", "ฮก", "ฮข", "ฮฃ", "ฮค", "ฮฅ", "ฮฆ", "ฮง", "ฮจ", "ฮฉ",
1550 }, },
1551 { "gr bf", {
1552 "๐", "๐", "๐", "๐
", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐",
1553 "๐จ", "๐ฉ", "๐ช", "๐ซ", "๐ฌ", "๐ญ", "๐ฎ", "๐ฏ", "๐ฐ", "๐ฑ", "๐ฒ", "๐ณ", "๐ด", "๐ต", "๐ถ", "๐ท", "๐ธ", "๐น", "๐บ", "๐ป", "๐ผ", "๐ฝ", "๐พ", "๐ฟ", "๐",
1554 }, },
1555 { "gr it", {
1556 "๐ผ", "๐ฝ", "๐พ", "๐ฟ", "๐", "๐", "๐", "๐", "๐", "๐
", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐",
1557 "๐ข", "๐ฃ", "๐ค", "๐ฅ", "๐ฆ", "๐ง", "๐จ", "๐ฉ", "๐ช", "๐ซ", "๐ฌ", "๐ญ", "๐ฎ", "๐ฏ", "๐ฐ", "๐ฑ", "๐ฒ", "๐ณ", "๐ด", "๐ต", "๐ถ", "๐ท", "๐ธ", "๐น", "๐บ",
1558 }, },
1559 { "gr bi", {
1560 "๐ถ", "๐ท", "๐ธ", "๐น", "๐บ", "๐ป", "๐ผ", "๐ฝ", "๐พ", "๐ฟ", "๐", "๐", "๐", "๐", "๐", "๐
", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐",
1561 "๐", "๐", "๐", "๐", "๐ ", "๐ก", "๐ข", "๐ฃ", "๐ค", "๐ฅ", "๐ฆ", "๐ง", "๐จ", "๐ฉ", "๐ช", "๐ซ", "๐ฌ", "๐ญ", "๐ฎ", "๐ฏ", "๐ฐ", "๐ฑ", "๐ฒ", "๐ณ", "๐ด",
1562 }, },
1563 { "gr ss bf", {
1564 "๐ฐ", "๐ฑ", "๐ฒ", "๐ณ", "๐ด", "๐ต", "๐ถ", "๐ท", "๐ธ", "๐น", "๐บ", "๐ป", "๐ผ", "๐ฝ", "๐พ", "๐ฟ", "๐", "๐", "๐", "๐", "๐", "๐
", "๐", "๐", "๐",
1565 "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐ ", "๐ก", "๐ข", "๐ฃ", "๐ค", "๐ฅ", "๐ฆ", "๐ง", "๐จ", "๐ฉ", "๐ช", "๐ซ", "๐ฌ", "๐ญ", "๐ฎ",
1566 }, },
1567 { "gr ss bi", {
1568 "๐ช", "๐ซ", "๐ฌ", "๐ญ", "๐ฎ", "๐ฏ", "๐ฐ", "๐ฑ", "๐ฒ", "๐ณ", "๐ด", "๐ต", "๐ถ", "๐ท", "๐ธ", "๐น", "๐บ", "๐ป", "๐ผ", "๐ฝ", "๐พ", "๐ฟ", "๐", "๐", "๐",
1569 "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐ ", "๐ก", "๐ข", "๐ฃ", "๐ค", "๐ฅ", "๐ฆ", "๐ง", "๐จ",
1570 }, },
1571 { "op", {
1572 }, },
1573 { "sy a", {
1574 }, },
1575 { "sy b", {
1576 }, },
1577 { "sy c", {
1578 }, },
1579 }
1580
1581 local mathlists = { }
1582 local mathselector = { }
1583
1584 for i=1,#mathsets do
1585 local mathset = mathsets[i]
1586 mathselector[#mathselector+1] = mathset[1]
1587 mathlists[mathset[1]] = mathset[2]
1588 end
1589
1590 local enabled = 0
1591 local usedlists = {
1592 { name = "text", current = "en", lists = textlists, selector = textselector },
1593 { name = "math", current = "tf", lists = mathlists, selector = mathselector },
1594 }
1595
1596 local function make_strip()
1597 local used = usedlists[enabled]
1598 local lists = used.lists
1599 local alphabet = lists[used.current]
1600 local selector = "(hide)(" .. concat(used.selector,")(") .. ")"
1601 local alphabet = "(" .. used.current .. ":)(" .. concat(alphabet,")(") .. ")"
1602 scite.StripShow(selector .. "\n" .. alphabet)
1603 end
1604
1605 local function hide_strip()
1606 scite.StripShow("")
1607 end
1608
1609 local function process_strip(control)
1610 local value = scite.StripValue(control)
1611 if value == "hide" then
1612 hide_strip()
1613 return
1614 elseif find(value,".+:") then
1615 return
1616 end
1617 local used = usedlists[enabled]
1618 if used.lists[value] then
1619 used.current = value
1620 make_strip()
1621 else
1622 editor:insert(editor.CurrentPos,value)
1623 end
1624 end
1625
1626 local function ignore_strip()
1627 end
1628
1629 function toggle_strip(name)
1630 enabled = enabled + 1
1631 if usedlists[enabled] then
1632 make_strip()
1633 OnStrip = process_strip
1634 else
1635 enabled = 0
1636 hide_strip()
1637 OnStrip = ignore_strip
1638 end
1639 end
1640
1641end
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653do
1654
1655 package.path = props.SciteDefaultHome .. "/context/lexers/?.lua;" .. package.path
1656 package.path = props.SciteDefaultHome .. "/context/lexers/themes/?.lua;" .. package.path
1657 package.path = props.SciteDefaultHome .. "/context/lexers/data/?.lua;" .. package.path
1658
1659 local required = require
1660 local loaded = { }
1661
1662 require = function(name)
1663 local data = loaded[name]
1664 if not data then
1665 data = required(name)
1666 loaded[name] = data
1667 end
1668 return data
1669 end
1670
1671end
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738do
1739
1740 local lexers = nil
1741 local properties = props
1742 local partial = false
1743 local partial = true
1744 local trace = false
1745
1746
1747 local loadedlexers = setmetatable ( { }, {
1748 __index = function(t,k)
1749 local language = match(k,"^script_(.*)$") or k
1750 if not lexers then
1751 lexers = require("scite-context-lexer")
1752 lexers.loadtheme(require("scite-context-theme"))
1753 end
1754 local name = "scite-context-lexer-" .. language
1755 local v = lexers.load(name)
1756 if v then
1757 lexers.registertheme(properties,language)
1758 else
1759 v = false
1760 end
1761 t[name] = v
1762 t[k] = v
1763 t[language] = v
1764 return v
1765 end
1766 } )
1767
1768 local function update(language,size,start,stop)
1769 if language then
1770 local syntax = loadedlexers[language]
1771 if syntax then
1772 lexers.scite_onstyle(syntax,editor,partial,language,props.FileNameExt,size,start,stop,trace)
1773 end
1774 end
1775 end
1776
1777 function Initialise()
1778 check_output_pane()
1779 end
1780
1781 function OnStyle(styler)
1782
1783 update(styler.language,editor.TextLength,styler.startPos,styler.lengthDoc)
1784 end
1785
1786 function OnOpen(filename)
1787 if trace then
1788 report("opening '%s' of %i bytes, language '%s'",filename,editor.TextLength,props.Language)
1789 end
1790 update(props.Language,editor.TextLength,0,editor.TextLength)
1791 check_output_pane()
1792 end
1793
1794 function OnSwitchFile(filename)
1795 if dirty[props.FileNameExt] then
1796 if trace then
1797 report("switching '%s' of %i bytes, language '%s'",filename,editor.TextLength,props.Language)
1798 end
1799 update(props.Language,editor.TextLength,0,editor.TextLength)
1800 dirty[props.FileNameExt] = false
1801 end
1802 check_output_pane()
1803 end
1804
1805 function OnChar()
1806 if not editor:AutoCActive() then
1807 local syntax = loadedlexers[props.Language]
1808 if syntax and syntax.completion then
1809 local stop = editor.CurrentPos
1810 local start = editor:WordStartPosition(stop,true)
1811 local length = stop - start
1812 if length >= 2 then
1813 local snippet = editor:textrange(start,stop)
1814 local list = syntax.completion(snippet)
1815 if list then
1816 editor.AutoCMaxHeight = 30
1817 editor.AutoCSeparator = 32
1818 editor:AutoCShow(length,list)
1819 end
1820 end
1821 end
1822 end
1823 end
1824
1825end
1826
1827
1828
1829
1830
1831 |