Creating a bash-like Terminal GUI - unityscript

I asked this before and didn't get an answer. I would like to create a linux-like scene for my game. This means that it should look like this: https://upload.wikimedia.org/wikipedia/commons/2/29/Linux_command-line._Bash._GNOME_Terminal._screenshot.png . Right now I have the two window approach(like common text based games) but i cant mimic the behavior in linux.

Related

Lightweight event wrapper for the terminal

I believe this is the realm of the ncurses library. I'm trying to avoid having to get down and dirty with it though.
I'm looking for a program that I can configure to run a command while performing terminal mouse reporting translation to keypresses.
This is for use with pagers like less.
For example the MouseTerm SIMBL plugin for Terminal.app does exactly this.
But iTerm2 does not. And I want it.
I think the answer may be as simple as directly remapping the codes.
It looks like there are escape codes to switch the terminal into and out of mouse-listening mode, and mouse click escape codes actually seem to include the character coordinates. I can look at them with Ctrl+V inside of Vim because I have told vim to turn on the mouse.
It looks like this:
Note ^[ denotes escape (you can type escape by typing ctrl+[)
left click: ^[[M !!
right click: ^[[M"!!
middle click: ^[[M!!!
scroll up: ^[[M`!!
scroll down: ^[[Ma!!
So that does match up with the mouse wheel button codes being 64 more than the mouse button ones according to documentation (I like this page).
Now that I'm armed with the knowledge of what codes I need to map to what I just need to find out how to get a layer that lets me filter the input.
This has apparently led me to an epiphany. I simply need a simple non-line-buffering program that listens for mouse escape codes and replaces them with key codes. Surely Perl Term::ReadKey will let me set raw mode and do this nearly trivial task.
This stuff is difficult. I've been making do by configuring Tmux to handle things.

ctrl-r history search equivalent for R64/R GUI OS X Application [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Retrieving Variable Declaration
I would like some way to search through the history of commands sent to R for a running session. This can be done in Bash using ctrl-r history search, and I find it extremely useful.
Is there a shortcut key in the R GUI IDE that does this? I've looked through changelogs and done some google searching, and I can't find it.
If not, is there a way outside of the R GUI IDE to extract this information? Possibly by searching through some sort of .Rhistory file maybe?
How are other R users accessing command history?
In the R GUI there is is a discoverable side panel that appears to whichever side of the screen has the most space and it has the history entries displayed in a clickable manner. That panel is kbd-toggled with shift-cmd-H, and if opened that way will place the active cursor in an entry line. That line at the top of that panel accepts regex expressions that will limit the displayed lines to those that match. It's a bit confusing (to me anyway) that there are separate history files. The side panel like the R.app or R64.app uses a file named ".Rapp.history", while the regular history file that a Terminal R session would access has its expected name.
The icon that does the show/hide toggling is exposed to the toolbar item selection panel of the console, so I suspect it is exposed to AppleScript commands. I'm not a big user of AppleScript and that last part is a hunch more than a promise.
The MacOSX FAQ says R will accept Applescript delivered R commands.
What is available as a shortcut depends on what interface you are using. If you use the r terminal on windows (but not the GUI) then ctrl-r works like you describe.
One tool (though not as easy) that should work for all interfaces is to use the 'history' command. Y can type something like history(pat='plot') and the recent commands that included "plot" in them will be displayed and you can cut and paste to rerun the command of interest.

Bash script with graphical menus

I have been writing simple bash scripts for a while now, and I was wondering how I could implement simple menus and, if possible, use menus with color.
In the past, I have written simple C applications that use ncurses and would like to (if possible) have menus in my bash script where the user can use the up/down arrows to select items in a list, and go back/forth through a series of yes/no/cancel prompts.
I am familiar with setting up colored text in bash, so there's a start (eg: bash using colors), so the only requirement left at this point is to see if bash has these capabilities. I would prefer to avoid having to code an application in C/C++ for this, as I would like to be able to edit it on the fly.
there is a package called dialog, is this relevant to your requirement?
I haven't used this myself, but have you checked out bashsimplecurses? From the documentation, it looks like a possible solution.

Cocoa: simple tabs

Does any one know how to create a tab bar like this:
I mean that simple tab, without rounded corners or texture, with "Untitled" string
Is this a standard control? Or is there an open source library for such tabs? I think I saw it in a open source editor or something but totally forgot which one.
There are no doubt other ways to do this, but one I've used often in the past is PSMTabBarControl. It's been around for a while, and forked a few times. The version at https://github.com/dorianj/PSMTabBarControl can be used with Xcode 4.
Documentation can be found http://www.positivespinmedia.com/dev/PSMTabBarControl.html.

Reuse Edit Control as Command Window

This is a GUI application (actually MFC). I need a command window with the ability to display a prompt like such:
Name of favorite porn star:
The user should be able to enter text after the prompt like such:
Name of favorite porn star: Raven Riley
But I need to prevent the user from moving the cursor into the prompt area. Users should also be prevented from backspacing into the prompt in order to prevent the following:
Rrraven Rrrileeey Ruuuulez!!! Name of favorite porn star:
Also need to control text selection and so on. And finally, I should have no problem retrieving only the text the user entered (minus prompt text).
Will it be better to create my own window class from scratch (i.e inherit from CWnd) or should I reuse the Windows EDIT control (i.e. inherit from CEdit)?
A similar command window can be seen in AutoCAD and Visual Studio (in debug mode).
I think you'd be better off creating a subclass of CEdit and limiting filtering key-presses. I suppose the hard part is not letting the user move the caret to the prompt area, but you can probably write some code to make sure the caret always get sent back to where it belongs (the input part).
Anyway, if you really, really want to implement your own control (it's not that difficult after all) I recommend you read Jacob Navia's "technical documentation" on how he built the LCC compiler and environment. Actually, it seems the docs are not online anymore, but I'm sure you can get them through his e-mail (jacob#jacob.remcomp.fr).
Edit: I liked your previous example better. Keep it classy, LOL :)
I had a very similar requirement and did exactly what davidg suggested; subclassed a edit control and filtered key presses. This was actually using Qt not MFC but the principle will be exactly the same.
You need to remember to filter keys such as home as well as left and backspace. I just checked to see if the move would move the caret into the prompt and if it did ignored the keypress.
Another thing to watch for is pasting multiline text, you will have to choose whether to just paste the first line or all lines, adding the prompt on all lines after the first. When subclassing the control you get lots of behaviour which won't work exactly as you want it.

Resources