grosser / ruco

Desktop-style, Intuitive, Commandline Editor in Ruby. "Better than nano, simpler than vim."
MIT License
130 stars 10 forks source link

Ability to do in-memory editing #16

Open cmouse opened 10 years ago

cmouse commented 10 years ago

I would love to integrate ruco into an app I am making, but my major challenge is that ruco has been structured to require an actual file at all times. I could not find simple way to modify code via inheritance to provide the data directly. Is there a way you could consider extending your code to allow in-memory data instead of file?

cmouse commented 10 years ago

Actually, found a way. But it's not so pretty as I'd like, so if you can come up with something, it would be appreciated.

grosser commented 10 years ago

how about:

result = Tempfile.open('foo') do |f|
  ... open file in ruco ...
  File.read(f.path)
end
cmouse commented 10 years ago

@grosser yes, except that this is information that I would rather not write into disk at all. Using tempfiles is not a solution :(

cmouse commented 10 years ago

@grosser it did not seem very hard to modify the code by rewriting Ruco::Application and Ruco::Editor with minute changes. perhaps this could be done in the application api? The project is https://github.com/cmouse/pwkeep if you are interested.

grosser commented 10 years ago

The whole curses bootstrap thingy is in bin/ruco, so this would have to be moved over so it's accessible via a ruby interface. Then the editor has to know it's a string and not a file, so it has to read and write it differently etc.

Sounds like a lot of work to me, using files and doing being ... ensure ... delete file end sounds like the simpler solution to me, and you can use whatever ENV["EDITOR"] the user has chosen too

On Tue, Jan 7, 2014 at 12:26 PM, Aki Tuomi notifications@github.com wrote:

@grosser https://github.com/grosser it did not seem very hard to modify the code by rewriting Ruco::Application and Ruco::Editor with minute changes. perhaps this could be done in the application api? The project is https://github.com/cmouse/pwkeep if you are interested.

— Reply to this email directly or view it on GitHubhttps://github.com/grosser/ruco/issues/16#issuecomment-31775823 .