password entry
I know that this is challenging (because I spent a bunch of time trying to get it working) but any chance of adding password here? The best options seem to be stty related trickery on platforms that support it and using tcltk otherwise (generating an ugly window but at least no output). Possibly your keypress package would do a better job too. And possibly you've already thought about this...
I have indeed thought about it, and then postponed it for the reasons you mention. tcltk is a good idea. I think there could be a tcltk backend, and then that and the 'fancy' backend would support it.
keypress could deal with this, too, possibly, that has the same challenges: in r-gui, r-app and rstudio you have no terminal.
But tcltk might be a good way to go, I guess it is installed in almost all implementations. Thanks!
I have tcltk and unix terminal versions that you'd be welcome to use here.
The tcltk version failed on a fairly up-to-date mac that I've not had the chance to test but otherwise seems to work well on other macs, windows machines and Linux machines I've used. Downside on a mac is the lag in opening X11. There are pretty annoying focus issues on everything other than osx.
The terminal version, via stty, works pretty well though keypress would probably be neater in that context.
Cool! I was wondering if we could implement this separately for win, osx and linux. With or without tcltk. E.g. we create another window (tcltk or something else) and switch the focus to it, type in the pw and then switch back.
We could have some small C programs, specific to each os. Then there are no focus issues and no lag for the tcltk start.
I have to say that I have no idea if this is feasible, though.
I think that separate programs for different OS's might be simplest given that the target is so small (it's not like it's a big complicated UI thing).
Another, possibly insane option, is a small shiny app :)
Re shiny app, well, I guess there must be better options. E.g. to switch windows on OSX: http://stackoverflow.com/a/2401792/604364
Linux: http://stackoverflow.com/a/2009514/604364
Windows might be tricky, considering that we need to use mingw.
So how about putting this in the keypress package?
Windows will probably work, too, but I don't know much about the win32 api: http://stackoverflow.com/questions/786368/how-to-bring-a-cmd-exe-window-to-top
Actually, apple script, as linked in that answer there will be fairly easy. Aside from the issues of dealing with applescript it will give a native looking application that's fast and the focus issues aren't a problem. To run it we'd just shell out to osascript. https://en.wikibooks.org/wiki/AppleScript_Programming/Advanced_Code_List/Display_Dialog
And yes, keypress seems like a good place (ask is probably a bit high level).
OSX looks easy, indeed.
I guess the question is whether we want a "real" window for the keyboard reader app. It might not be possible without a window, unfortunately, at least on Linux and OSX.
Still, an extra window for keypress looks awkward... so maybe first I would try doing it with an "invisible" window that just reads a key from the keyboard.
And/or for ask we could just have a new backend that uses an extra window. Easy on OSX, but I am not too keen to write it on Windows, and especially not for Linux. I am not even sure what portable toolkit you could use for Linux. Maybe only tcltk, which is not too bad, actually.
Oh, sorry I see - you're seeing a much more general problem here.
For linux this is only an issue in Rstudio right? Probably safe to assume/assert everyone else is using a terminal? For Rstudio it might be possible to talk nicely to one of the rstudio folk and see if they can add an API that would fit within whatever pluggable infrastructure keypress decides on.
Well, I just want to be able to read keys from the keyboards. :)
Yes, if Rstudio had some feature to read from the keyboard, that would be enough for all OSes I think. (And maybe Rgui, emacs and R.app users would get the tcltk workaround.)
Btw. a shiny app is not such a crazy idea after all, for Rstudio at least. :)