Tuesday, September 14, 2010

Ready for VoraX 2.3?

Hey, VoraX 2.3 is available for download. It has some new goodies which I'm sure you gonna like. The first one is the ability to get the explain plan (detailed or trace only) for a sql statement. Ingo Olbrich came up with this idea and now, I guess VoraX is closer to what a modern IDE should be. Thanks Ingo!

The next feature which I think is quite handful is that you can now offline search through the html Oracle documentation directly from VoraX. With some GNU Screen trickery and a good text web browser you'll never have to leave your beloved console. :)

Another feature which some might find it useful is the possibility to define your custom key mappings without using ugly auto-command workarounds. There's a good example into the VoraX documentation.

Below is a very short demo with VoraX 2.3 main features:



Enjoy!

Monday, September 13, 2010

How to Install VoraX on Cygwin

I'm coming back with the promised post about how to install VoraX on Cygwin. So, let's begin!

First of all, you obviously need Cygwin. You may download it from here. From the looong list of available cygwin packages I recommend to install the following ones (there's a search text field on top):
  • gcc
  • make
  • bzip2
  • ncurses-devel
  • openssl-devel
  • ruby-1.8.7
  • wget
  • w3m
  • mintty
  • screen
Accept all dependencies cygwin installer suggests and start the installation process. If you'll need any additional packages you may opt to install them later.

Next, go ahead and launch cygwin from your desktop. If you don't like the command window terminal get rid of it and start using mintty. Change the C:\cygwin\cygwin.bat as shown below:

@echo off
C:
chdir C:\cygwin\bin
set CYGWIN=nodosfilewarning
start mintty -e /bin/bash --login -i

Start your new terminal and then customize it to suit to your preferences. You have an "Options" menu item available. I always find myself customizing:
  • foreground/background colors. I like black on white instead of the default opposite
  • block cursor
  • set Consolas 9 font. (if you don't have this font package you may download it from here).
  • right click action: Paste
  • TERM at startup: xterm
  • Scrollbar: none
  • uncheck "Ask for exit confirmation".
Now, it's time to compile vim with ruby support:

1. download vim 7.3 package:

cd /tmp
wget ftp://ftp.vim.org/pub/vim/unix/vim-7.3.tar.bz2

2. uncompress the downloaded archive:

tar -xjf vim-7.3.tar.bz2

3. compile vim with ruby support:

cd vim73/
./configure --enable-rubyinterp --with-features=huge
make
make install

4. install rubygems utility:

cd /tmp
wget http://rubyforge.org/frs/download.php/70697/rubygems-1.3.7.zip
unzip rubygems-1.3.7.zip
cd rubygems-1.3.7
ruby setup.rb

5. install antlr3 gem:

gem install antlr3 -r

6. customize vim via .vimrc and install all your favorite vim plugins including of course VoraX. If you already have a _vimfiles directory in your $HOME then just copy it in your new cygwin home and change the name to .vim. Sqlplus should still be in your cygwin PATH.

Congrats! You have (at least I hope to) VoraX running on top of your Cygwin environment. So, you have the unix shell on your finger tips with all the useful tools you are so used to use: ssh, gnu screen, w3m etc.

However, I think is worth to mention some problems you may have migrating VoraX to Cygwin and some possible workarounds.

Problem 1: Where's my nice colorschema?
The first thing you'll notice is that your nice colorscheme on your gvim doesn't look the same on the console version of vim under Cygwin. There is a simple solution provided by CSApprox plugin. This plugin should seamlessly convert colors from the gui-version to the proper terminal colors. However, in order to have this conversion automatically done, our vim should have been compiled with "gui" support. But, we still have a fallback solution. CSApprox provides a way of creating a snapshot of your current colors into a new colorschema file. So, open your gvim windows version (which I suppose will open with your favorite colorschema) and use :CSApproxSnapshot [mycolors.vim]. This new colors file will be suitable for your terminal version of vim. If you like earendel colors I already have a converted schema. You may get it from here.

Problem 2: The title of mintty terminal doesn't change when a new VoraX connection is done.

This has nothing to do with mintty. You need to put this in your .vimrc:

set title

Problem 3: Under GNU Screen, colors are different and the title is not properly updated.

You may try the following .screenrc configuration:
# no annoying audible bell, please
vbell on

# detach on hangup
autodetach on

# don't display the copyright page
startup_message off

# generous scrollback
defscrollback 1000

# xterm for all new sessions
term xterm

# special xterm hardstatus: use the window title.
termcapinfo xterm 'hs:ts=\E]2;:fs=\007:ds=\E]2;screen\007'

# terminfo and termcap for nice 256 color terminal
# allow bold colors - necessary for some reason
attrcolor b ".I"
# tell screen how to set colors. AB=background, AF=foreground
termcapinfo xterm 'Co#256:AB=\E[48;5;%dm:AF=\E[38;5;%dm'
# erase background with current bg color
defbce "on"

That's it! Below is my VoraX into a GNU Screen session:


At the bottom of the VoraX window is a man page just to prove that we are under GNU Screen. And yes, it's on a Windows XP system. I think Oracle geeks may be happy on Windows too. :)

Wednesday, September 8, 2010

VoraX says Hello to Cygwin

In my previous post I was talking about GNU Screen and how nice this tool may be used in connection with VoraX and other terminal applications. The only problem was on Windows where there's no multiplexing tools available except for GNU Screen on Cygwin. Some Windows guys are happy with this Console but, in my opinion, this is far from what GNU Screen provides. And, if it happens to be on both, Unix and Windows, it's quite nice to have the same tool available, isn't it?

Well, starting from today, VoraX 2.2 is available for download and, as you maybe already guessed, it provides a Cygwin interface. If you don't like Cygwin then this new VoraX interface is not for you, but all of you who appreciate the UNIX style shell and tools on Windows I think will be glad to use VoraX on this platform. You'll also benefit from GNU Screen, ssh, bash scripting etc.

Installing vim with ruby support on cygwin is not quite a blink of an eye therefore I'm going to come back with a new post explaining in detail how to do it.

And because I use to let people know what every new VoraX version brings to light I will also briefly mention the refresh capability of the output buffer. If, for example, you monitor the progress of a rollbacking transaction, it is very likely to repeatedly execute the same query. It is a little bit awkward to go everytime into the sql buffer and to execute that query. Instead, in VoraX 2.2 you may simply press R while in the output buffer and the last executed query will be re-executed automatically.

VoraX 2.2 fixes also some bugs and, in addition, has some tweaks which improve the
fetching performance, especially on Unix.

Saturday, September 4, 2010

VoraX, GNU Screen and Nice Colors

Hi guys! All good there? :)

Today I want to share with you some tips. I discover them myself during my efforts to get the best out of VoraX.

I was asked once about the possibility to offer support for multiple connections within VoraX. Despite this would be quite nice, it is not easy to implement at all. I mean, think about it: you have to link every Vim buffer to a particular oracle connection and have to maintain this relation. When you open a new sql file you have to decide to which connection it belongs. Every connection must have its own output buffer, right? The DbExplorer has to be also aware of multiple connections.

At the beginning of VoraX I thought of this and one idea was to use Vim tabbing support to map one tab to an oracle connection. If you open a new sql file, you open it to the current tab which is supposed to have a connection attached. That sql buffer will inherit the connection from its parent tab. I switch the tab and I'm connected to another session. It sounds pretty good, doesn't it? Well, during my first attempts to implement this I encountered a lot of problems:
  1. vim support for tab events is quite poor. For example, it doesn't provide a tabClose event (aka autocommand). This event is critical in order to force a disconnect when the user simply closes a vim tab. However, I succeeded to manage this with a lot of CursorHold trickery but the final result was not very nice.
  2. the vim tabbing model is not the same as in the most known IDEs/editors. In vim, a tab acts more like a viewport or a layout. This means a particular buffer doesn't stick to its tab. It can be migrated to another tab if you want. This may lead to confusion, because a buffer which was belonging to a connection can suddenly become part of another tab and, as a consequence, mapped to a new unexpected connection.
  3. in addition there's no good support for vim unit testing. There are a few plugins (including this) but I didn't have a pleasant experience with them. So, I didn't want to implement a complex connection management feature without a strong testing/regression support.
But let's come back to the tips part. Okey, how can we have multiple connections in VoraX? Well, if you are on a UNIX based system you may happily use GNU Screen or tmux. They're a few more out there but basically all of them are terminal multiplexers. They allow to map many terminal sessions within the same console which is, of course, just lovely. So, we can use such a tool and have multiple VoraX running in different multiplexed sessions, connected to various oracle sessions. We may switch them as we want while still sharing the same single console.

But, how about VoraX on Windows? Well, here things are not very promising yet. The only multiplexer I know in Windows is GNU Screen on top of Cygwin. This means you'd also need a cygwin version of vim (console mode, not gvim) with ruby support. Most likely you'd have to compile it yourself. Maybe this is not a big deal but the major problem right now is that VoraX doesn't provide a cygwin interface yet. Nevertheless, I'm going to create one in the next future. Till then, all of you guys on Windows, sorry... you'll have to wait!

If you were to ask me, I use GNU Screen for years. I like it a lot and I think it is a great tool. It is a productivity booster and it's worthing to learn some of its key shortcuts. However, one problem I had was with my vim colors. I like the earendel colorscheme. It's light and friendly with my eyes. However, you may notice a big difference between the colors in the GUI version of vim and the colors displayed within the plain console vim. Of course, using gvim and GNU screen doesn't have much sense, so you have to focus on the console version of vim.

First of all, you must have a decent terminal with the ability to display 256 colors. I use gnome-terminal with a "Linux console" built-in schema palette and it's working pretty well. I expect XTerm to be also a good choice. Then, I recommend CSAprox plugin which tries to map vim colors to your terminal as close as possible. This plugin comes with good documentation therefore I'll just skip the details. So after installing this plugin, your vim colors should look fine in your terminal too.

There's one more catch. I noticed that the colors were not displayed correctly when vim is opened into a GNU screen session. They were okey in a plain terminal but not under GNU Screen. I google for this topic and I found a solution. Add this to your .screenrc file:
# terminfo and termcap for nice 256 color terminal
# allow bold colors - necessary for some reason
attrcolor b ".I"
# tell screen how to set colors. AB = background, AF=foreground
termcapinfo xterm 'Co#256:AB=\E[48;5;%dm:AF=\E[38;5;%dm'
# erase background with current bg color
defbce "on"
Restart your GNU Screen and Voila! You have beautiful colors in your screen console:

Above is a screenshot with two of my multiplexed VoraX sessions. Both of them are shown in a split which is not very common but is good for demonstration purposes. In practice is more likely to have one "full VoraX window" session at a time, with the possibility to switch to another one running in background. Isn't it great? In this light I must say: Who needs VoraX multi-connection support anyway?