2021-10-11 18:41:26 +02:00
|
|
|
tool
|
2021-10-11 05:10:22 +02:00
|
|
|
extends TE_ExtensionHelper
|
|
|
|
|
|
|
|
func toggle_comment(t:TextEdit, head:String="<!-- ", tail:String=" -->"):
|
|
|
|
return .toggle_comment(t, head, tail)
|
|
|
|
|
|
|
|
func apply_colors(e:TextEditor, t:TextEdit):
|
|
|
|
.apply_colors(e, t)
|
2021-10-11 21:09:16 +02:00
|
|
|
|
2021-10-11 05:10:22 +02:00
|
|
|
t.add_keyword_color("true", e.color_var)
|
|
|
|
t.add_keyword_color("false", e.color_var)
|
|
|
|
|
|
|
|
# bold italic
|
2021-10-11 18:41:26 +02:00
|
|
|
t.add_color_region("***", "***", Color.tomato.darkened(.3), false)
|
2021-10-11 05:10:22 +02:00
|
|
|
# bold
|
|
|
|
t.add_color_region("**", "**", Color.tomato, false)
|
|
|
|
# italic
|
2021-10-11 18:41:26 +02:00
|
|
|
t.add_color_region("*", "*", Color.tomato.lightened(.3), false)
|
2021-10-11 05:10:22 +02:00
|
|
|
|
|
|
|
# quote
|
2021-10-14 12:45:59 +02:00
|
|
|
t.add_color_region("> ", "", e.color_text.darkened(.6), true)
|
2021-10-11 05:10:22 +02:00
|
|
|
|
|
|
|
# comment
|
|
|
|
t.add_color_region("<!--", "-->", e.color_comment, false)
|
|
|
|
|
|
|
|
# headings
|
|
|
|
var head = e.color_symbol
|
2021-10-14 12:45:59 +02:00
|
|
|
t.add_color_region("# *", "*", TE_Util.hue_shift(head, -.33), true)
|
|
|
|
t.add_color_region("# \"", "\"", TE_Util.hue_shift(head, .33), true)
|
2021-10-11 05:10:22 +02:00
|
|
|
t.add_color_region("# ", "", head, true)
|
|
|
|
t.add_color_region("## ", "", head, true)
|
|
|
|
t.add_color_region("### ", "", head, true)
|
|
|
|
t.add_color_region("#### ", "", head, true)
|
|
|
|
t.add_color_region("##### ", "", head, true)
|
|
|
|
t.add_color_region("###### ", "", head, true)
|
|
|
|
|
|
|
|
# url links
|
2021-10-14 12:45:59 +02:00
|
|
|
t.add_color_region("![", ")", e.color_var.lightened(.5))
|
2021-10-11 05:10:22 +02:00
|
|
|
|
|
|
|
# lists
|
|
|
|
t.add_color_region("- [x", "]", Color.yellowgreen, false)
|
2021-10-11 21:09:16 +02:00
|
|
|
t.add_color_region("- [", " ]", e.color_text.darkened(.6), false)
|
2021-10-11 05:10:22 +02:00
|
|
|
|
|
|
|
# code blocks
|
2021-10-14 12:45:59 +02:00
|
|
|
var code:Color = lerp(e.color_text.darkened(.5), Color.yellowgreen, .5)
|
2021-10-11 05:10:22 +02:00
|
|
|
t.add_color_region("```", "```", code, false)
|
|
|
|
t.add_color_region("~~~", "~~~", code, false)
|
2021-10-11 21:09:16 +02:00
|
|
|
|
2021-10-11 05:10:22 +02:00
|
|
|
# strikeout
|
|
|
|
t.add_color_region("~~", "~~", Color.tomato, false)
|
2021-10-11 21:09:16 +02:00
|
|
|
|
2021-10-11 05:10:22 +02:00
|
|
|
# code
|
|
|
|
t.add_color_region("`", "`", code, false)
|
2021-10-11 21:09:16 +02:00
|
|
|
|
2021-10-11 05:10:22 +02:00
|
|
|
# at/mention
|
|
|
|
t.add_color_region("@", " ", Color.yellowgreen, false)
|
|
|
|
|
|
|
|
# tables
|
|
|
|
t.add_color_region("|", "", Color.tan, true)
|
|
|
|
|
|
|
|
|
|
|
|
func get_symbols(t:String) -> Dictionary:
|
|
|
|
var out = .get_symbols(t)
|
|
|
|
var last = add_symbol()
|
|
|
|
var lines = t.split("\n")
|
|
|
|
var i = 0
|
|
|
|
|
|
|
|
while i < len(lines):
|
|
|
|
# symbols
|
|
|
|
if lines[i].begins_with("#"):
|
|
|
|
var p = lines[i].split(" ", true, 1)
|
|
|
|
var deep = len(p[0])-1
|
|
|
|
var name = p[1].strip_edges()
|
|
|
|
last = add_symbol(i, deep, name)
|
|
|
|
|
|
|
|
# tags
|
|
|
|
elif "<!-- #" in lines[i]:
|
|
|
|
for tag in lines[i].split("<!-- #", true, 1)[1].split("-->", true, 1)[0].split("#"):
|
|
|
|
tag = tag.strip_edges()
|
|
|
|
if tag:
|
|
|
|
last.tags.append(tag)
|
|
|
|
|
|
|
|
i += 1
|
|
|
|
|
|
|
|
return out
|