about syntax hightlight

i wanna show code on screen or in a text box with syntax hightlight js or css?its better to give an example?thx

it’s not clear to me what you are asking

You want to draw text with different colors for specific words? You would have to draw each word individually, and figure out the spacing yourself if you want to do that.

i mean syntax hightlight like this post
http://codea.io/talk/discussion/1896/forum-syntax-for-text-decoration-cheatsheet/p1
i wanna make it while running?maybe it needs syntax hightlight js or css

You’d have to have to do what @SkyTheCoder said,

What you want to do includes coding your own text editor, which is pretty advanced stuff (regarding string modifications). Also difficult to do efficiently…

You could however try. But since you ask for examples instead for specific problem solutions, I would say, you better put this idea on hold, until you learned Lua a little better.

@firewolf Here’s something I was playing with long ago. It probably isn’t exactly what you’re after, but it might give you an idea.


displayMode(FULLSCREEN)

function setup()
    textMode(CORNER)
    str="¥aThis ¥cis ¥ddiff¥aerent ¥ccolored ¥dtext. You ¥bcan setup ¥aas many different ¥dcolors as you want. You can pick ¥athe screen ¥dx,y position and ¥ethe width to print. The colors are ¥ajust a matter ¥dof creating ¥ba ¥dlarger table of ¥ediff¥berent colors ¥dand adding ¥fthe control ¥bcharacters."
    col={a=color(255,0,0),
         b=color(0,255,0),
         c=color(0,0,255),
         d=color(255,255,0),
         e=color(0, 238, 255, 255),
         f=color(255, 0, 223, 255),
        }
end

function draw()
    background(40, 40, 50)
    showText(100,200,400)
    showText(200,600,150)
    showText(650,650,60)
end

function showText(x,y,size)
    local count, xoffset, yoffset=0,0,0
    for z=1,str:len() do
        local b1,b2=str:byte(z,z+1)
        if count==0 then
            local ch=str:sub(z,z)
            if b1==194 and b2==165 then
                fill(col[str:sub(z+2,z+2)])
                count=2
            else
                text(ch,x+xoffset,y-yoffset)
                local w,h=textSize(ch)
                xoffset = xoffset + w
                if xoffset>size then
                    xoffset=0
                    yoffset = yoffset + h
                end
                count=0
            end
        else
            count=count-1
        end
    end
end

i dont want a text editor, i juat think maybe theres a simple way to show code on screen or in a text box with syntax hightlight js or css

@dave1707 thanks

No

how to directly get the code’s webaddress “http…Comment”, chrome?

@firewolf, i’m not sure what ur asking, u mean the URL?

yes, like above code’s URL “http…Comment56272”

Codea code doesn’t have a URL, but you can read it, look up Storage in the reference link at top of this page

like above code’s URL “http…Comment56272” on forum, NOT Codea code

@firewolf I haven’t use Chrome for iOS, but have you tried tapping the URL? It should bring up a text box that lets you select the URL. Most browsers have that feature.