I am a strange developer.
My preferred development environment is GCC running in a simulated BASH shell on Windows. This madness all started well over a decade ago when I first discovered DJGPP, a GCC for DOS. This means GCC was my first C and C++ compiler.
Now sure, like most kids (?!) I used Visual C++ in College. That was mainly for my school projects though. Whenever it was me time, I was rocking the DJGPP. To be honest, I can’t really remember when I switched away from DJGPP, but I’m fairly certain I was still using it in 1999.
End of 1999 I was hired by long forgotten game developer Sandbox Studios as a GameBoy programmer. I had been dabbling with the GameBoy homebrew during the summer of 1999, made some little games, and won some stuff in a contest (Flashcarts). This lead to me using a GameBoy assembler called RGBDS (Rednex GameBoy Development Suite), which was a great little macro assembler suite. All command line.
My point: I’ve been comfortably working in command lines and shells for a long time. And I do it on Windows, where everybody else uses Visual Studio. I treat my Windows as a Linux box.
For the past decade, Cygwin and MinGW/MSYS have been the go-to ways of working Linux’y on Windows. I used to use a lot of Cygwin, especially since all the major video game console toolchains of the time were GCC based, and Cygwin did a much better job at simulating/hosting/building a GCC cross compiler. GameBoy Advance, PlayStation, though there were some alternatives (SN, CodeWarrior), in my books GCC was the way to go.
Today I rarely use Cygwin, but I always keep it around. Instead I use MinGW, which is a GCC port with a mostly compatible set of Win32 libraries, and MSYS (a minimal Bash/Cygwin like environment). It’s had its rough moments over the years, but for my needs I find it to be the better of the two. Cygwin’s goals are to simulate Unix on Windows. MinGW/MSYS’s goals are to target Windows with GCC. Why half-ass it?
Installing MinGW has dramatically improved since the early days. You just have to go here:
And grab the installer. There’s a blatant link there you are supposed to click (beside the “Looking for the latest version?” text). Admittedly, it’s hard to notice, but that’s what you’re looking for.
With the installer, it’s just a few checkboxes to include MSYS and G++ with it, and you’re good to go.
Why I especially like MSYS over Cygwin is because MSYS features a package manager. From the shell you can use “mingw-get” to install things, just like on Linux with “apt-get” and “yum”. Any time you’re missing a typical Linux package, library, or tool, a quick invocation to “mingw-get install toolname” is sometimes all you need.
So lets grab something.
mingw-get install mintty
Something you may notice when working with the MSYS or Cygwin shell is that the Window it’s in really lacks nice resizing features. You can change the shape and size, but you have to do it inside the properties. You can’t just grab a corner and size it. The other thing is they don’t exactly support ANSI color sequences. You sometimes see colors, but the way colors work isn’t the same as shells on Linux.
The solution is to install MinTTY, a much nicer shell for working on Windows. Doing the above mingw-get installs it, but to use it you need to make 1 more change. I typically have a shortcut to msys.bat, so I modify my shortcut directly to have it start in MinTTY.
And now we’re in MinTTY town. If you’re on Windows 7 (Aero), you can even make your MinTTY Windows semi-transparent.
So that’s cool.
MinTTY does have some limitations though. Honestly, I hadn’t noticed them until I recently started using a library PDCurses. PDCurses is a cross platform implementation of the Curses library for controlling a terminal. If you’re familiar with Conio, Curses is the Unix version of that. On Linux you’d use NCurses, and on Windows you’d use PDCurses.
Same as before. The link you want is beside the “Looking for the latest version?” text.
MinTTY’s limitation is that it that despite everything it does support, it doesn’t support PDCurses.
The reason for this is long and complicated (which I admittedly don’t understand), but generally it’s some to do with MinTTY being implemented as pipes instead of something that directly encapsulates a Windows console.
Solution: Near the end of that discussion comes a tool called WinPTY. This is a tool that launches a program in a typical Windows console, captures the data, and forwards it to MinTTY seamlessly.
There were more tools suggested in the discussion, but WinPTY is the one that worked immediately for me. Like the instructions said, I needed the following to build it:
mingw-get install msys-dvlpr
After that I was able to “./configure”, “make”, an “make install”.
Then it’s simple. Prefix the program you’re calling with a call to a program “console”, and it’ll now work inside MinTTY.
console Netty.exe -server 1024
This can help with other programs like Python (with can alternatively be run in a -i mode), but things that use curses is the mean reason I use it.
WinPTY is new to me, and is actually the reason I wrote this post. This is me writing things down so *I* don’t forget.
* * *
And some curses usage notes. Color.
init_pair( 1, COLOR_RED, COLOR_BLACK );
attron( COLOR_PAIR(1) );
printw( "This is a curse\n" );