From 37e96dbda5ee7b599c3659008c94907fdc8425a2 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sat, 1 Mar 2025 16:53:58 -0500 Subject: [PATCH] Change `lang.text_content` to `lang.text` --- compile.c | 2 +- docs/langs.md | 2 +- examples/base64/base64.tm | 4 ++-- examples/ini/ini.tm | 2 +- examples/tomodeps/tomodeps.tm | 4 ++-- examples/wrap/wrap.tm | 2 +- test/lang.tm | 2 +- types.c | 2 +- 8 files changed, 10 insertions(+), 10 deletions(-) diff --git a/compile.c b/compile.c index 7331483..ddba677 100644 --- a/compile.c +++ b/compile.c @@ -3722,7 +3722,7 @@ CORD compile(env_t *env, ast_t *ast) } case TextType: { const char *lang = Match(value_t, TextType)->lang; - if (lang && streq(f->field, "text_content")) { + if (lang && streq(f->field, "text")) { CORD text = compile_to_pointer_depth(env, f->fielded, 0, false); return CORD_all("((Text_t)", text, ")"); } else if (streq(f->field, "length")) { diff --git a/docs/langs.md b/docs/langs.md index 96c026f..ed5e349 100644 --- a/docs/langs.md +++ b/docs/langs.md @@ -36,7 +36,7 @@ page := $HTML" Hello $username! How are you? " -say(page.text_content) +say(page.text) ``` What we _don't_ want to happen is to get a page that looks like: diff --git a/examples/base64/base64.tm b/examples/base64/base64.tm index 6979b15..4e4cc8b 100644 --- a/examples/base64/base64.tm +++ b/examples/base64/base64.tm @@ -65,7 +65,7 @@ lang Base64: return Text.from_bytes(b64:decode_bytes() or return none) func decode_bytes(b64:Base64 -> [Byte]?): - bytes := b64.text_content:bytes() + bytes := b64.text:bytes() output := &[Byte(0) for _ in bytes.length/4 * 3] src := Int64(1) dest := Int64(1) @@ -94,4 +94,4 @@ func main(input=(/dev/stdin), decode=no): say(b:decode_text()!) else: text := input:read()! - say(Base64.parse(text)!.text_content) + say(Base64.parse(text)!.text) diff --git a/examples/ini/ini.tm b/examples/ini/ini.tm index 46c2586..9b27e8c 100644 --- a/examples/ini/ini.tm +++ b/examples/ini/ini.tm @@ -7,7 +7,7 @@ _HELP := " " func parse_ini(path:Path -> {Text,{Text,Text}}): - text := path:read() or exit("Could not read INI file: $\[31;1]$(path.text_content)$\[]") + text := path:read() or exit("Could not read INI file: $\[31;1]$(path.text)$\[]") sections := @{:Text,@{Text,Text}} current_section := @{:Text,Text} diff --git a/examples/tomodeps/tomodeps.tm b/examples/tomodeps/tomodeps.tm index 3ff48f9..48c026e 100644 --- a/examples/tomodeps/tomodeps.tm +++ b/examples/tomodeps/tomodeps.tm @@ -66,9 +66,9 @@ func _printable_name(dep:Dependency -> Text): is File(f): f = f:relative() if f:exists(): - return "$(f.text_content)" + return "$(f.text)" else: - return "$(\x1b)[31;1m$(f.text_content) (not found)$(\x1b)[m" + return "$(\x1b)[31;1m$(f.text) (not found)$(\x1b)[m" func _draw_tree(dep:Dependency, dependencies:{Dependency,{Dependency}}, already_printed:@{Dependency}, prefix="", is_last=yes): if already_printed:has(dep): diff --git a/examples/wrap/wrap.tm b/examples/wrap/wrap.tm index b6cf140..94d752b 100644 --- a/examples/wrap/wrap.tm +++ b/examples/wrap/wrap.tm @@ -82,7 +82,7 @@ func main(files:[Path], width=80, inplace=no, min_split=3, rewrap=yes, hyphen=UN files = [(/dev/stdin)] for file in files: - text := file:read() or exit("Could not read file: $(file.text_content)") + text := file:read() or exit("Could not read file: $(file.text)") if rewrap: text = unwrap(text) diff --git a/test/lang.tm b/test/lang.tm index 5d8c619..777a05b 100644 --- a/test/lang.tm +++ b/test/lang.tm @@ -28,7 +28,7 @@ func main(): >> HTML.HEADER[1] = $HTML"<" - >> HTML.HEADER.text_content + >> HTML.HEADER.text = "" >> user := "I <3 hax" diff --git a/types.c b/types.c index cee1db9..3b0fd9b 100644 --- a/types.c +++ b/types.c @@ -639,7 +639,7 @@ type_t *get_field_type(type_t *t, const char *field_name) case PointerType: return get_field_type(Match(t, PointerType)->pointed, field_name); case TextType: { - if (Match(t, TextType)->lang && streq(field_name, "text_content")) + if (Match(t, TextType)->lang && streq(field_name, "text")) return Type(TextType); else if (streq(field_name, "length")) return INT_TYPE; return NULL;