Log In  


Hello, the release thread is a bit busy and I'd like to make it a bit more visible as it's both about a possible bug and a feature the community could use for editor or more, it's a bit more interesting than just a crash, I'd say. I think I found a possible issue with wrangle and filenav.

Basically, wrangle that works with the current opened file pwf() and by when creating the wrangle object you have to pass getter/setter to store/load data from the file. Right?

Inspired by the GUI code here and there, I found out that the argument intention was mostly the thing that makes filenav acts as an open/close dialog, or supposedly. Thus, I ended up with code looking like that

    sidebar:attach_button{
        x=0, y=0,
        label="Open",
        tap = function()
            local segs = split(pwf(),"/",false)
            local path = string.sub(pwf(), 1, -#segs[#segs] - 2) -- same folder as current file
            create_process("/system/apps/filenav.p64", {path=path, intention="open_file", window_attribs={workspace = "current", autoclose=true}})        
        end
    }
    sidebar:attach_button{
        x=32, y=0,
        label="Save as",
        tap = function()
            local segs = split(pwf(),"/",false)
            local path = string.sub(pwf(), 1, -#segs[#segs] - 2) -- same folder as current file
            create_process("/system/apps/filenav.p64", {path=path, intention="save_file_as", window_attribs={workspace = "current", autoclose=true}})
        end
    }

And somehow, it works! Or almost.

I believe there's a slight issue with the open_file intention: it doesn't properly override the doubleclick event, as seen in 1/apps/filenav.p64/open.lua, @zep wrote that he didn't any find another intention that didn't needed the same exception thansave_file_as`; the default operation did the same expected result anyway by leaving the default editor to open the file thanks to that hardcoded* extension/editor association mapping.

Thus we end up with the situation where we can't just open a file from a non-system editor by doubleclicking with a custom file or file format. I found a workaround: if you type the file to open in the filename toolbar, it'll properly handle the event, pass the open_file event back to wrangle and your file will properly load!

So, here's my questions:

  • Picotron's boundaries about what's user-accesible code or not is a bit blurry, should we allowed to use wrangle?
  • Should filenav's open_file intention get the same exception than save_file_as if it was called from an external program?
  • Was the end result intented or is it a bug? Having two contradictory results from the dialog seems like a bit unexpected.

Anyway, have a nice day!

Addendum : I also noticed another potential issue: the opening workflow works only when one types the filename in the text entry. Selecting an icon and then pressing Open won't work and won't change the current file, failing the opening process.

2


I used filenav like this in my p8 sprite importer; I tried using intention="open_file" but it didn't work (it would try to actually open the files, when all I wanted was a file picker that let me process the chosen file)

It might be nice if there was a new intention added for use in tools, maybe file_pick or custom_file with customizable labels for the window title + rightside button.

function onclick()
    create_process("/system/apps/filenav.p64", {path=path, intention="file_pick", title_label="Import a file", button_label="Import", window_attribs={workspace = "current", autoclose=true}})
end

on_event("file_picker",function(msg)
    local file = fetch(msg.filename)
    -- custom import logic
end)

This can be done currently with intention="save_file_as" but the labels ("Save as") are probably confusing for users, when what they're doing in my tool is importing a file


oh, and my 2 cents on wrangle.lua: the wrangler looks to me like it's intended for us to use as tool-makers, it looks like it tries to handle common headaches (setting up common shortcuts, noticing external edits, autosaving when you leave the workstation, etc). looks helpful!



[Please log in to post a comment]