Ruby prompt when stdin isn't a terminal (for Notepad++ explicitely)?

两盒软妹~` 提交于 2019-12-12 09:27:32

问题


I'm a Notepad++ user. One of the features I like from that software is the fact that you can have a "console" in the UI (which is not an actual terminal), and that you can run some command line interpreters from there.

FYI, to get the console running in Notepad++, you need to have the NppExec plugin installed, and then go to Menu > Plugins > NppExec > Execute... and type in whatever executable file you want in there (exe, batch, etc) and press OK. The Console will be brought up, and you'll see the output of your program in there, and in the case of an interactive shell, you can also input commands.

For example

  • for an actual DOS prompt, you run cmd.exe
  • for a Python prompt, you run python.exe -i.
    • From the Python help: -i inspect interactively after running script; forces a prompt even if stdin does not appear to be a terminal; also PYTHONINSPECT=x

Now, I'm wondering if there's a way to get a similar prompt with irb. Anybody has an idea how to get that running in Notepad++?

Update

There's mention in the answer(s) I got that it already works in Notepad++ 5.4.5. In my view, it does not.

What I get from Notepad++:

alt text http://content.screencast.com/users/JocelynLegault/folders/Jing/media/7cec643e-0924-479d-b31a-a40c691ec25d/2009-11-18_1814.png

What I expect:

alt text http://content.screencast.com/users/JocelynLegault/folders/Jing/media/211d1b9f-6f66-458e-9a19-61b7e9b19b43/2009-11-18_1816.png


回答1:


use the following script in npp_exec:

cmd /c start what_you_want_to_execute

explanation: to get a new instance of cmd, you need to use the start command. But the start command only works in cmd. So you execute cmd first with option /c so it'll execute the stuff that follows and exit after that. Then you use the start command with what you need to execute.

To make it a little prettier you can use:

cmd /c start cmd /q /c "what_you_want_to_execute && pause"

same as before, only now you use the start command to start cmd with option /q, which stands for quiet and does the same as @echo off in a .bat file. Again the /c option. Then the thing you want to execute plus pausing afterwards. Those last two thing are between quotes so the first call to cmd doesn't execute it in the npp_exec console.

I use this script to execute java sometimes:

cmd /c start cmd /q /c "C:\Progra~1\Java\jdk1.6.0_17\bin\java.exe -classpath "$(CURRENT_DIRECTORY)" "$(NAME_PART)" && pause"



回答2:


For IRB, just run irb.bat.

This is what it looks like (Notepad++ 5.4.5 and NppExec 0.3 RC1):

alt text http://img198.imageshack.us/img198/8373/86448854.jpg



来源:https://stackoverflow.com/questions/1760115/ruby-prompt-when-stdin-isnt-a-terminal-for-notepad-explicitely

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!