Codea 3.3 (258)

This version updates the autocomplete bar and has a lot of underlying code editor changes

https://imgur.com/Cqs6Je0

https://imgur.com/6WWT52v

https://imgur.com/uZ5o1IN

https://imgur.com/rHkZMmO

What to test

  • Please test autocomplete for code and assets
  • Try long pressing various autocomplete suggestions
  • Try wrapping long lines in the code editor
    ?

New Autocomplete bar

  • New design. Autocomplete suggestions replace the top row of input buttons
  • Colour coded suggestions
  • Scrollable when there are lots of suggestions
  • See an autocomplete suggestion with an underline? Long press it for instant documentation
  • Try autocompleting your asset keys, you’ll get neat icons showing their file types
  • Long press on the autocomplete suggestions for assets for a visual preview

This update also includes a big code editor change:

  • Line wrapping is completely changed. Wrapped lines now indent at the same level as the initial line

Accessibility changes

  • Autocomplete suggestions follow editor font size
  • Gutter line numbers track editor font size

@Simeon Playing with autocomplete. I keyed an a then selected asset. I then keyed the . and long pressed documents. Codea hung for approx 10 seconds.

@Simeon I’m running into various delays with autocomplete. If I key a for asset then tap asset, key the . then tap documents then tap the . there is a delay before the . is accepted.

@Simeon I think I found out why there’s a delay when I do something with documents. The autocomplete bar lists every one of my projects. I have over 600 projects so the autocomplete bar is really long.

@Simeon Here’s something else I ran into. I just had a bunch of random letters to force line wrap. The function setup() was at the top of the screen and when I hit the run icon, it shifted down the screen. See image below.

PS.
The problem doesn’t have anything to do with long lines. If there’s a code error, that forces the problem. Key the below code and press run.

function setup()
    a=1a
end

@Simeon - Codea crashed when I was cutting from existing code, in the same tab, and pasting into a statement. Video recorded will try to attach. Video too big will reduce and post later.

Also can reiterate slow response on asset listing and when trying to delete asset components - which resulted in half line disappearing as I didn’t know if the touch had been accepted hence multiple touches.

Also some issue with selecting screen - selected all of screen. Plus screen scrolls awkwardly when trying to select - especially in landscape.

Also - with remarked long lines the remark wraps but also drops a line below the — REM characters.

Here is youtube link address: https://youtu.be/-m6N1GyGQeI

Sorry about the advertising - didn’t know that would be added.

How can I access the beta?

@skar You have to be given beta rights by @Simeon .

@Simeon Here’s another problem. The error message is skinny. See image.

@skar happy to include you if you’re willing to provide feedback. DM me your email address for an invite

@dave1707 thank you for those examples, I’ll profile the autocomplete bar with 600 file system items and try get performance better. The editor bugs look fixable too

@Bri_G that crash looks bad! Does it happen every time? Does copying and pasting in that exact text do the same crash? If so can you share the code here with instructions on how I can cause the crash on my iPad for debugging

@Simeon - happens every time, and tried pasting in different locations but still crashes. I was trying to tidy an initial project up and expand it to add further features so the code is a bit of a mess. Intended posting later in the forum so here is code:


viewer.mode = LANDSCAPE_LEFT
function setup()
    --
    xmax,ymax,xmin,ymin = 100,100,100,100
    planets = {}
    scene = asset.documents.Dropbox.TyroGalaxies.galaxy06
    readData(1)
end


function draw()
    --
    --  background(40, 40, 50)
    spriteMode(CENTER)
    sprite(scene,WIDTH/2,HEIGHT/2,WIDTH,HEIGHT)
    fill(241, 222, 47)
    font("Baskerville-SemiBold")
    fontSize(32)
    textMode(CENTER)
    text("BBC MICRO ELITE - Galaxy 1",WIDTH/2,HEIGHT-40)
    fill(154, 215, 218)
    ellipseMode(CENTER)
    starter = 1
    for gl = 1, 256 do
        pln,plX,plY,rad = planets[starter],planets[starter+3], planets[starter+4], planets[starter+11]
        prad = math.floor(tonumber(rad/1000))
        ellipse(tonumber(plX)*4,tonumber(plY)*3+1,prad,prad)
        starter = starter + 14
    end
    stroke(255)
    strokeWidth(3)
    ellipse(planetData[loc.x],planetData[loc.y],100,100)
end


function touched(touch)
    --
    
end

function parsePlanet(str)
    --
    for value,_ in string.gmatch(str,"(.-)(,)") do
        table.insert(planets,value)
    end
end

function printAll()
    --
    print(table.concat(planets,"\
"))
    print("ranges : ",xmin,xmax," : ",ymin,ymax)
end

function maxmin()
    --
    cplX,cplY = tonumber(plX),tonumber(plY)
    if xmin > cplX then xmin = cplX end
    if xmax < cplX then xmax = cplX end
    if ymin > cplY then ymin = cplY end
    if ymax < cplY then ymax = cplY end
end

function readData(pl)
    --
    -- galaxy_num,system_num,name,x,y,economy_id,economy,govtype_id,govtype,techlev,productivity,radius,population,description
    path = asset.documents[galaxy[1]]
    csv = readText(path)
    parsePlanet(csv)
    num = {}
    sys = {}
    name = {}
    pos = {}
    econ = {}
    gov = {}
    tech = {}
    prod = {}
    rad = {}
    pop = {}
    desc = {}
    starter = 1
    for gl = 1, 256 do
        pln,plX,plY,rad  = planets[starter],planets[starter+3], planets[starter+4], planets[starter+11]
        maxmin()
        print(starter.."- "..pln.." - "..plX..":"..plY.." rad "..rad.." = "..tonumber(plX)*tonumber(plY))
        if gl < 255 then
            starter = starter + 14
        end
        num[gl] =
    end
    planetData = {num = 8,loc = vec2(tonumber(planets[101]),tonumber(planets[102]))}
end

galaxy = {
            "Galaxy1"
            }

Will also include the relevant csv and image, if the image isn’t too big.

Note: whilst copying code scrolling down from top to bottom to select - as soon as you reach the bottom the copy menu appears then disappears. Difficult to get menu up by selecting the selection handle at the bottom - it tends to move up a couple of lines. So I copied what I could but had to add the end } bracket in this forum post. Tied up with editor problem with cursor at bottom - no free space/lines mentioned earlier.

@Simeon - resolved the problem - it was a clash between two arrays. Modified code added below. Note deleted touch as not used at moment and added small extra routine. Did this in previous version which did not crash. Believe this may be due to two errors incurred at once.


--
viewer.mode = LANDSCAPE_LEFT
function setup()
    --
    xmax,ymax,xmin,ymin = 100,100,100,100
    planets = {}
    scene = asset.documents.Dropbox.TyroGalaxies.galaxy06
    readData(1)
end

function draw()
    --
    --  background(40, 40, 50)
    spriteMode(CENTER)
    sprite(scene,WIDTH/2,HEIGHT/2,WIDTH,HEIGHT)
    fill(241, 222, 47)
    font("Baskerville-SemiBold")
    fontSize(32)
    textMode(CENTER)
    text("BBC MICRO ELITE - Galaxy 1",WIDTH/2,HEIGHT-40)
    fill(154, 215, 218)
    ellipseMode(CENTER)
    starter = 1
    for gl = 1, 256 do
        pln,plX,plY,rad = planets[starter],planets[starter+3], planets[starter+4], planets[starter+11]
        prad = math.floor(tonumber(rad/1000))
        ellipse(tonumber(plX)*4,tonumber(plY)*3+1,prad,prad)
        starter = starter + 14
    end
    stroke(255)
    strokeWidth(2)
    noFill()
    ellipse(tonumber(planets[102]),tonumber(planets[103]),80,80)
    fill(255)
    textMode(CORNER)
    fontSize(18)
    text(planets[101],tonumber(planets[102])+20,tonumber(planets[103]+20))
end

function parsePlanet(str)
    --
    for value,_ in string.gmatch(str,"(.-)(,)") do
        table.insert(planets,value)
    end
end

function printAll()
    --
    print(table.concat(planets,"\
"))
    print("ranges : ",xmin,xmax," : ",ymin,ymax)
end

function maxmin()
    --
    cplX,cplY = tonumber(plX),tonumber(plY)
    if xmin > cplX then xmin = cplX end
    if xmax < cplX then xmax = cplX end
    if ymin > cplY then ymin = cplY end
    if ymax < cplY then ymax = cplY end
end

function readData(pl)
    --
    -- galaxy_num,system_num,name,x,y,economy_id,economy,govtype_id,govtype,techlev,productivity,radius,population,description
    path = asset.documents[galaxy[1]]
    csv = readText(path)
    parsePlanet(csv)
    num = {}
    sys = {}
    name = {}
    pos = {}
    econ = {}
    gov = {}
    tech = {}
    prod = {}
    rad = {}
    pop = {}
    desc = {}
    starter = 1
    for gl = 1, 256 do
        pln,plX,plY,rad  = planets[starter],planets[starter+3], planets[starter+4], planets[starter+11]
        maxmin()
        print(starter.."- "..pln.." - "..plX..":"..plY.." rad "..rad.." = "..tonumber(plX)*tonumber(plY))
        if gl < 255 then
            starter = starter + 14
        end
        num[gl] = planets[starter]
        pos[gl] = vec2(tonumber(planets[101]),tonumber(planets[102]))
    end
  --  planetData = {num = 8,pos = vec2(tonumber(planets[101]),tonumber(planets[102]))}
    print(tonumber(planets[102]),tonumber(planets[103]))
end

galaxy = {
            "Galaxy1"
        }


If, ignoring my bad programming, hope you can see the changes and dig out the cause of the crash and, of course, resolve it.

@Simeon - in retrospect I had a line with nam[gl] =, where I was trying to paste copied array value. The nam array was not initialized. I had initialized arrays num and name. Could this have caused the error?

@Bri_G I tried pasting planets[starter] into num[gl] = <pasted here> but was not able to produce the crash. Did I do it wrong?

@Simeon Here’s what @Bri_G might be saying. Load the below code. Double tap on asdfghjkl to select it then select Copy. Move the cursor to the end of the line. Press return to create a new blank line. Tap on that new line and do a Paste. Crashes every time.

viewer.mode=STANDARD

function setup()  
    str="qwertyuiop asdfghjkl zxcvbnm"
end

@Simeon Here’s another problem. Double tap on asdfghjkl to select it then select Copy. Try to paste a copy after zxcvbnm.

viewer.mode=STANDARD

function setup()  
    str="qwertyuiop asdfghjkl zxcvbnm     "
end

@Simeon Under certain circumstances, I’m having a very difficult time trying to place the cursor where I want it. I’ll just give up and let the cursor go wherever it wants and then I’ll drag it to where I want it.

@Bri_G Now that I see what your CSV file looks like, here’s another way to read it and populate the fields in a table. The table planets is now a multiple array table with the different planet values per entry.

viewer.mode=STANDARD

function setup()  
    planets={}
    parsePlanet()
end

function parsePlanet(str)
    -- galaxy_num,system_num,name,x,y,economy_id,
    -- economy,govtype_id,govtype,techlev,productivity,
    -- radius,population,description
    
    str=readText(asset.documents.Dropbox.Csv)
    for a,_,b,_,c,_,d,_,e,_,f,_,g,_,h,_,i,_,j,_,k,_,l,_,m,_,n,_
        in string.gmatch(str,"(.-)(,)(.-)(,)(.-)(,)(.-)(,)(.-)(,)(.-)(,)(.-)(,)(.-)(,)(.-)(,)(.-)(,)(.-)(,)(.-)(,)(.-)(,)(.-)(,)") do
        table.insert(planets,
            {gal=a,sys=b,name=c,pos=vec2(d,e),
            econ_id=f,econ=g,gov_id=h,gov=i,
            tech=j,prod=k,rad=l,pop=m,desc=n})
    end
    print(planets[1].name,planets[1].pos)
    print(planets[100].name,planets[100].pos)
end

@Simeon - try pasting again with nam[gl] not num[gl]. Also I can confirm @dave1707 placement of cursor - very difficult to paste into bracketed code. Usually have to paste after last bracket and use cursor keys to move. This has always been an issue, I sometimes remove the last bracket to place the cursor edit then add the last bracket.

@dave1707 - spot on with you bug finding. Noted that dropping the bracket off of the end of a function call to paste a string into it crashed Codea, but getting the menu up with the cursor within the brackets is a nightmare. Frustrating. Cursor location does seem very difficult it tends to offset from the touch. It is also reluctant to go into a () bracket pair.