diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-08-31 23:33:22 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-08-31 23:33:22 -0400 |
| commit | 5fc7577b5a3bc2c445522dfd5b287e1c6eddc3e9 (patch) | |
| tree | 34d44c9330dc3ec71fc850b95b3412a1ce292cb8 /examples/colorful | |
| parent | a571ccffd795a595e990a3405dcf977aafc33c6c (diff) | |
Switch to using optional return values for list indexing.
Diffstat (limited to 'examples/colorful')
| -rw-r--r-- | examples/colorful/CHANGES.md | 4 | ||||
| -rw-r--r-- | examples/colorful/colorful.tm | 6 |
2 files changed, 7 insertions, 3 deletions
diff --git a/examples/colorful/CHANGES.md b/examples/colorful/CHANGES.md index 093cc077..985e98a7 100644 --- a/examples/colorful/CHANGES.md +++ b/examples/colorful/CHANGES.md @@ -1,5 +1,9 @@ # Version History +## v1.3 + +- Version bump for Tomo syntax changes. + ## v1.2 - Version bump for patterns. diff --git a/examples/colorful/colorful.tm b/examples/colorful/colorful.tm index 5b01cfd5..fed873fd 100644 --- a/examples/colorful/colorful.tm +++ b/examples/colorful/colorful.tm @@ -45,7 +45,7 @@ func main(texts:[Text], files:[Path]=[], by_line=no) func _for_terminal(c:Colorful, state:_TermState -> Text) - return c.text.map_pattern(recursive=no, $Pat/@(?)/, func(m:PatternMatch) _add_ansi_sequences(m.captures[1], state)) + return c.text.map_pattern(recursive=no, $Pat/@(?)/, func(m:PatternMatch) _add_ansi_sequences(m.captures[1]!, state)) enum _Color(Default, Bright(color:Int16), Color8Bit(color:Int16), Color24Bit(color:Int32)) func from_text(text:Text -> _Color?) @@ -174,7 +174,7 @@ func _add_ansi_sequences(text:Text, prev_state:_TermState -> Text) text.pattern_captures($Pat/{0+..}:{0+..}/) or return "@("++_for_terminal(Colorful.from_text(text), prev_state)++")" ) - attributes := parts[1].split_pattern($Pat/{0+space},{0+space}/) + attributes := parts[1]!.split_pattern($Pat/{0+space},{0+space}/) new_state := prev_state for attr in attributes if attr.starts_with("fg=") @@ -215,6 +215,6 @@ func _add_ansi_sequences(text:Text, prev_state:_TermState -> Text) fail("Invalid attribute: '$attr'") result := prev_state.apply(new_state) - result ++= parts[2].map_pattern(recursive=no, $Pat/@(?)/, func(m:PatternMatch) _add_ansi_sequences(m.captures[1], new_state)) + result ++= parts[2]!.map_pattern(recursive=no, $Pat/@(?)/, func(m:PatternMatch) _add_ansi_sequences(m.captures[1]!, new_state)) result ++= new_state.apply(prev_state) return result |
