CC: Tweaked

CC: Tweaked

57M Downloads

Better saving UX with `edit`

SquidDev opened this issue ยท 9 comments

commented

While the built-in edit program is useful for quick editing of files, it's quite easy to accidentally lose one's changes:

  • If there is insufficient disk space, saving a file will truncate it (#1218). I've lost a lot of code in test worlds this way, where I've copied large files onto computers out-of-game, and so the computer's drive has no free space at all.

    When saving, we should check if there is any free space on the drive (and sufficient space to save the changes). If not, we should display an error.

    The main problem with this is that it doesn't provide a way to actually save your changes (just a way to ensure you don't lose your original file). I'm not sure how best to handle this, but some ideas:

    • Show a "Warning, disk space low" message when starting edit.
    • If saving fails, provide an option to start a shell prompt and allow people to delete files. This feels a little clunky, especially on non-advanced computers.
    • If saving fails, display a "Save As" prompt, encouraging people to save to an external disk.
  • Exiting edit with unsaved changes should show a [Exit] [Save and exit] prompt. Not sure how this will fit on the single-line status bar, especially on pocket computers.

commented

If there is insufficient disk space, saving a file will truncate it

Just to clarify, is it just a computer that has an upper limit of disk space? Or individual files also? What specifically are these limits?

I'm also curious what impact a program's code has on this disk space. (It certainly was surprising that a program I was working on got truncated as a result of some edits and/or logging. (As described in #1218.)

Exiting edit with unsaved changes should show a [Exit] [Save and exit]

OMG, yes, please!

commented

Just to clarify, is it just a computer that has an upper limit of disk space?

Computers and floppy disks. It's 1MB by default (and 128KB for floppies), though can be adjusted in the config. fs.getCapacity returns the current limit.

commented

Some very good ideas here! But another idea (related to edit, but not saving. Sorry if offtopic):
Add a [GoTo] option on the status bar when pressing CTRL. Pressing this will then prompt for a line number, and go to the line number entered.


Exiting edit with unsaved changes should show a [Exit] [Save and exit] prompt. Not sure how this will fit on the single-line status bar, especially on pocket computers.

I absolutly would love this feature!

commented

Exiting edit with unsaved changes should show a [Exit] [Save and exit] prompt. Not sure how this will fit on the single-line status bar, especially on pocket computers.

Two-step exit process perhaps? You hit 'e' and it shows [Exit] [Save and exit]? That should fit on a pocket computer I believe, unless I am misremembering pocket computer width.

commented

If saving fails, provide an option to start a shell prompt and allow people to delete files. This feels a little clunky, especially on non-advanced computers.

Adding to this, it does feel a bit clunky, but the exit command provided by the shell doesn't have a whole lot of uses currently. Making the MOTD display "type 'exit' to return to the editor" may work.

commented

Two-step exit process perhaps? You hit 'e' and it shows [Exit] [Save and exit]?

Oh, that was the plan. I think I just also want to provide some context for that option. So you'd actually have something like:

Unsaved changes: [Exit] Save and Exit

However, this is 37 characters: fits on a turtle, but not on a pocket computer!

commented

37 characters: fits on a turtle, but not on a pocket computer!

What is the max width of a pocket computer? Would the following fit?

type Ctrl/Cmd --> Exit? (y/n)

If there were changes:
'n' --> do nothing (likewise if Ctrl/Cmd is typed again)
'y' --> Save changes? (y/n)
'y' --> Changes saved
'n' --> Changes not saved

commented

I forgot to mention this at the time, but I think this has some tie-in with #1226 too. Currently when you try to edit a read-only file, you cannot save (which is correct), but nothing tells the user why they cannot save. Similar to the idea of a disk space warning, I believe it would also be appropriate to add a read-only warning when the file is opened, much like vim.

image

#1226 is intended for a fairly niche use case but I think a read-only message in edit would be useful for beginners to explain why they cannot edit the programs in /rom.

commented

Someone hit the confusing UX for read-only files today. One never really realises how bad something is until you see it in action.