rhysd/vim.wasm

Saving should trigger a file download

Lonami opened this issue · 6 comments

This is not an issue, nor appropriated for the Vim mailing list. However, since this is basically a version of Vim for the web it would make sense to offer some of the features you would expect from a web editor, such as saving. The :w command could for example trigger a file download. Likewise, opening a file could ask the user to select a file to upload.

rhysd commented

I agree. But vim.wasm is not in the phase for now. I'm now trying to fix/improve base implementations to make vim.wasm run faster/more robustly. I want to extend fundamental features like :write you're pointing after current fixes are done.
Anyway, thank you for reporting this. To keep your idea in my mind, I'll label this issue as 'enhancement'.

i was going to ask something like this, so my question is how can i get what i write?, i mean if i want to use what i write for an API, for example

rhysd commented

Possible implementation would be:

  1. Implement a JavaScript function which is supposed to be called at writing a file. In the function, we can show dialog or do something.
  2. In C, :write is implemented in do_write() function of ex_cmds.c. Call above JavaScript function in do_write() with the file name and the buffer content
rhysd commented

After some thoughts, I implemented :export special command to download current buffer or specific file at 4c81d4c.

I did not hook :write because browser does not overwrite existing file (e.g. when downloading foo.txt twice, foo (1).txt is downloaded at second time). Each :write generates a new file and it would be annoying.

rhysd commented

Here is a screenshot.

tmp

Cool, good job!