-- Test script for syntax highlighting API print("Testing syntax highlighting API...") -- Simple function to highlight keywords in a line function highlight_keywords(buf, line_num, keywords) local line_text = buf:line(line_num) for _, keyword in ipairs(keywords) do -- Find all occurrences of this keyword local start_pos = 1 while true do local pos = string.find(line_text, keyword, start_pos, true) if not pos then break end -- Create a range for this keyword local range = lumacs.Range( lumacs.Position(line_num, pos - 1), lumacs.Position(line_num, pos + #keyword - 1) ) -- Create text attribute for keywords (blue, bold) local attr = lumacs.TextAttribute( lumacs.ColorType.Keyword, lumacs.Style.Bold ) -- Set the style buf:set_style(range, attr) message(string.format("Highlighted '%s' at line %d, col %d-%d", keyword, line_num, pos-1, pos+#keyword-1)) start_pos = pos + #keyword end end end -- Test it on the buffer local buf = editor.buffer local keywords = {"function", "local", "end", "if", "then", "for", "while"} -- Highlight keywords in all lines for line = 0, buf:line_count() - 1 do highlight_keywords(buf, line, keywords) end -- Check what styles we have on line 0 local styles = buf:get_line_styles(0) message(string.format("Line 0 has %d styled ranges", #styles)) message("Syntax highlighting test complete!")