How do I create an interactive menu in a terminal? - ruby

I'm trying to build an terminal application that, when started, will take the user away from their prompt and present them with a screen with an interactive menu. I would like the user to be able to interact with it in the following way:
They will start the application by running my_app from the terminal. This will start the application and present them with the root menu.
They will use the cursor keys to navigate around the menu and use the [ENTER] key to make a selection.
When they make a selection, they will be presented with another screen/menu when they will do some work. When they are finished this work, they will press a key that will take them back to the root menu.
The key thing I'm after is for it to not be a scrolling view that just adds more information to the end. I'd like it to have distinct, encapsulated views with a navigation hierarchy. My problem is that I don't know how to produce such a view and present it to the user, and then dismiss it again once they're done. If someone could give me some kind of design pattern for this kind of application, I'll be able to take it from there.
FWIW, I'm using Ruby and would like the app to be cross-platform. If that's too much to ask, then Windows will suffice.

I'm a Linux guy and I want to suggest ncurses library for you. there's an ongoing effort to port this also to Windows.
AFAIK it's going pretty well, please check this question.

Related

Handle GUI window changes

I'm doing an automation script for installation wizards using AutoIt. I'm trying to handle window changes in some way.
Can some one explain how these GUI's work?
When I click on the Next button it looks just like the components in the GUI is beeing changed. Is this tha case? Or is a new window created and the old destroyed?
I've noticed that the process ID is the same for all windows.
I'm sure there is some way to know which "state" the GUI is in, or which step?
By the way. All the windows has the same title.
Thanks
/Anders
This will be dependant on the program you are automating.
The easiest approach would be to look at what changes in the GUI between stages, likely candidates are if there is a label that is giving instructions for that step, or a button that has text changing (e.g. if the button says "Finish" then you know your at the end).
Most installer programs have child windows for grouping the controls of each stage. These are typically implemented as dialog resources (as can be seen when using something like reshacker on them). So although the window remains the same, the panels are being created/destroyed as appropriate. This is a very neat method of doing it, for the obvious reason that you don't need to have to code to create/destroy a lot of controls. Resource created dialogs don't have nice class names like windows sometimes do though, so this may not be a reliable way to check the state.

How to connect multiple windows in gtk+?

I have created a window in gtk+ .in this window i am displaying some text and have button"next" through which i want to move to next window and my previous window should disappear.my new window should display something say,text.
Can someone tell me how to implement this?
I am new to gtk+.
It seems you want to use GtkAssistant, which is a widget precisely for the kind of interaction you are looking for. Run gtk-demo in your system to check the example with the code. It is likely you have it installed.
Also, you can check the code online in Gtk+ repository. (Check the version you want to view, either for GTK+2 or GTK+3).

Copy current selection on hotkey

I want to copy the current selection, even if it's in another application like Mail, when the user hits a specified hotkey like Cultured Code does it in Things when you create a new task. I got the hotkey working and I know how to place and get stuff on and from the pasteboard. But I have no idea how to get a current selection.
Anyone? Thanks!
You do this with a Service Provider. See the Service Implementation Guide. For what you're talking about, it should work very well. You don't need to do your own hotkey code; it'll do that for you. You don't even have to be running; it'll launch you.
To #Josh Caswell's point about OmniFocus, they're doing stuff fancier than just "the current selected text." They also copy the message itself into the inbox item as an attachment. That's what the plugin is assisting with.
This is a job for AppleScript, which is why applications that do clipping like this only support certain other applications to clip from -- those other applications have to support AS.
You'll have to take a look at the Mail AS dictionary and figure out how to get the selected text, and I believe that unfortunately you'll have to do the same with each application from which you want to clip.
Another possibility: it sounds like OmniFocus uses a Mail plugin for this functionality -- from http://forums.omnigroup.com/showthread.php?t=13906:
Starting in 10.6, Mail.app will refuse to use plugins... install the Clip-o-tron from that updated release... "OmniMailMessageEnabler...".

Creating quick GUI front ends

I wanted to have a GUI front-end for a script that accepts numerous command-line options, most of them are UNIX paths. So I thought rather than typing them in (even with auto-completion) every time, I'd create a GUI front end which contains text boxes with buttons beside them, which when clicked will invoke the file browser dialogue. Later, I thought I'd extend this to other scripts which would sure require a different set of GUI elements. This made me think if there's any existing app that would let me create a GUI dialog, after parsing some kind of description of the items that I want that window should contain.
I know of programs like Zenity, but I think it's doesn't give me what I want. For example, if I were to use it for the first script, it'll end up flashing sequence of windows in succession rather than getting everything done from a single window.
So, basically I'm looking at some corss-platform program that lets me create a window from a text description, probably XML or the like. Please suggest.
Thanks
Jeenu
Mozilla's XUL is a cross platform application framework - . You could write an app as a Firefox plugin or a standalone XUL application.
mono and monodevelop could work for this. Or even something super simple like shoes.

Replacing the Start Menu

I want to make my own Start Menu replacement and I am trying to figure out what approach to use. There are a number of ways the Start Menu is activated: click on it, hit windows key, hit Ctrl+Esc keys or tab until it gets focus and hit the space or enter key.
I know enough about win32 to do each one of these separately and I could figure it out with Spy++. I'd really like to know if there is an easier way through and I can't find any helpful articles.
I'd like to do this for XP and Vista/Windows 7.
I guess that you would have to inject yourself into the explorer.exe process (There can be more than one, but you want the one that has the "Shell_TrayWnd" window) and subclass the taskbar or one of its children to catch/eat the message that brings up the startmenu and instead, show your own window.
Take a look at http://bitbucket.org/wez/evildesk/src/755606d7935d/gdi.cpp , I think you could start your project by seing what they've done.
You can use WindowBlinds and design your own Start Menu as well.

Resources