Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

How to make different colored text?

edited January 2016 in Questions Posts: 809

I want to know how to make a screen with text in different colors that for example the text in the "brackets" Weill be red and the word function purple and words that will be after self (self.example), blue? Is there any way to do it?

Comments

  • Posts: 2,020

    What I think you're asking about is syntax highlighting for Lua. You'll need to read up on Lua pattern-matching for string.gsub, string.match etc. Start with the in-app reference for pattern matching, then google some examples.

    Here's an example, but for Markdown, not Lua:

    https://codea.io/talk/discussion/6710/markdown-codea-rich-text-formatting

    What you're asking for though is extremely complicated to get 100% right (occasionally even the Codea editor gets it wrong, in certain limit-cases). If I were you @TokOut I'd get comfortable with the basics of Lua before attempting something advanced like syntax-highlighting.

  • Posts: 809

    No I mean an editor with keyboard etc. an the text you will write will be highlighted

  • Posts: 2,020

    Ok, in that case you want an interpreter. It doesn't have the syntax highlighting, but it does suggest/autocomplete Lua/Codea commands by querying _G:

    Try the repo here. If you're using iOS 9, turn off the extra keyboard row, as it covers up the autocomplete suggestions bar:

    https://codea.io/talk/discussion/comment/61854/#Comment_61854

Sign In or Register to comment.