Saturday, December 29, 2007

Adding a menu to KMainWindow programmatically

First of all, let me stress that I'm not an experienced KDE programmer: my only KDE application, for now, is SourceHighlightIDE, a sort of IDE for developing GNU Source-highlight language definition files. While I was adding new features to this program, for the next release, I wanted to add the typical "Window" menu that permits tile all the windows in the workspace or cascade them, or selecting a specific window (SourceHighlightIDE is a MDI application). I then simply added this code to the KMainWindow subclass:


windowsMenu = new KPopupMenu( this );
connect( windowsMenu, SIGNAL( aboutToShow() ),
this, SLOT( windowsMenuAboutToShow() ) );
menuBar()->activateItemAt(-1); //needed as insertItem might crash if a menu is activated

// position: 2, means the third menu (the fourth one is Help)
menuBar()->insertItem( "&Window", windowsMenu, -1, 2);

However, the "Window" menu was never added to the application.

Actually, I know that one should add additional menus to the .rc file, e.g.,
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
<kpartgui name="sourcehighlightide" version="1">
<MenuBar>
<Menu name="custom"><text>C&amp;ustom</text>
<Action name="custom_action" />
</Menu>
</MenuBar>
</kpartgui>

but I wanted a way to add the menu programmaticaly, so that I would not depend on the .rc file that must be installed.

Actually, the code added by me above works, but you must make sure to execute it after the call to setupGUI().

Hope this saves some headache to others wanting the same thing :-)

Saturday, December 15, 2007

doublecpp (dynamic overloading in C++)

Doublecpp is a preprocessor for C++ that handles a new linguistic construct for defining branches of a multi-method. The "right'' branch of such a method will be selected dynamically at run-time according to the actual type of the object on which the method is invoked and to the actual type of the first argument: double dispatch.

This way, you will have dynamic overloading (but only on the first argument, for the other arguments standard static overloading will be adopted).

The home page of the project is http://doublecpp.sourceforge.net. And the documentation can be found on-line at this link.

Doublecpp is based on our research on formalization and implementation of dynamic overloading in languages providing only static overloading. In particular, doublecpp will take as input a program written in C++ extended with the linguistic construct for dynamic overloading and will produce in output a standard C++ program with the same semantics.

The idea of the translation is based on the Visitor pattern, but it does not require the programmer to manually implement such pattern; furthermore, it performs all the type checks to assure type safety; thus, it is not merely an automatic implementation of this pattern.

Such implementation avoids down-casts and it is efficient since it uses dynamic binding twice, i.e., dynamic overloading takes place in constant time (other implementations rely on RTTI checks and require to inspect the class hierarchy, thus their complexity depends on the depth and width of the class hierarchy).

More importantly, our implementation of dynamic overloading is type safe: once the program is successfully compiled, no run-time errors (exceptions) will be raised during the execution of the program. Thus, all possible (static and dynamic) ambiguities are ruled out during the type checking.

The papers concerning this research are the following:

Translating Double-Dispatch into Single-Dispatch
Lorenzo Bettini, Sara Capecchi, Betti Venneri.
Proceedings of the Second Workshop on Object Oriented Developments (WOOD 2004). pp. 59-78. ENTCS vol. 138 no. 2. Elsevier. 2005. abstract doubledisp.pdf bibtex
Double Dispatch in C++
Lorenzo Bettini, Sara Capecchi, Betti Venneri.
Software - Practice and Experience. pp. 581 - 613. vol. 36 no. 6. 2006. abstract spelxb.ps.gz bibtex

Tuesday, November 20, 2007

Problems in restoring Palm

It's not the first time I forgot to recharge my Palm Tungsten E for a long time; usually I manage to recharge it before it's too late, but this time I actually left my palm on (with the gps application running) so it definitely exhausted all its charge and so it went dead.

So I had to restore it, and, in order to avoid reinstalling all the applications, before performing the first synchronization, I had set the synchronization program to overwrite everything on the palm using the backup on my PC, in particular, the application database.

It went fine, but when I restarted the palm (it was required by the synchronization process) I got the scary error message:

DataMgr.c, Line:xxxx, Index out of range

I don't remember the actual line, but this is quite a typical error message, that requires a reset (the palm does not even switch off).

Fortunately, as I said, this error is quite typical, and you find on google with many results. I was lucky enough to find this post on a forum, and the situation looked quite similar to mine.

The problem seems to be caused by the Saved_Preferences.prc file; so, I removed it from the backup folder on my PC, and tried to perform synchronization again (with the above settings, saying to replace all the applications from the backup of my PC into the palm).

It worked! :-)

Of course, my preferences were lost, but at least my palm was up and running again.

Hope I won't have to reinstall the applications again (at least not until the next time I'll forget to recharge the palm ;-)

Monday, October 29, 2007

Thunderbird won't open http links

Sometimes, in Linux, after an update or a brand new install, Thunderbird won't open http links (e.g., with Firefox). This might depend on some default configuration value of your distribution.

However, the quickest, and, as far as I know, distribution independent solution, is to manually set these preferences in the prefs.js file:

user_pref("network.protocol-handler.app.ftp", "firefox");
user_pref("network.protocol-handler.app.http", "firefox");
user_pref("network.protocol-handler.app.https", "firefox");
where "firefox" can be replaced with your preferred browser.

Alternatively, you might set these settings with the config editor available from the "advanced" tab. You'll probably need to create new entries for these preferences (of type string).

Hope this helps, at least until the problem is fixed in your distribution :-)

Wednesday, October 17, 2007

Wifi-radar and WPA

Under my Debian installation I'm using Wifi-radar, a nice utility for managing wireless networks (although it is a GNOME application, I'm using it under KDE without problems). I've always used for WEP networks, but now I needed to start using also for WPA networks, and in order to deal with such networks, wifi-radar relies on wpa-supplicant, which is also available for Debian.

Thus, you need to setup the configuration file of wpa-supplicant so that wifi-radar can use it (thus, you cannot set WPA parameters from within wifi-radar), but this is not hard to do; for instance, in wpa_supplicant.conf you can put such a stanza:

network={
ssid="network ssid"
key_mgmt=WPA-PSK
proto=WPA
psk="network password"
}
and then you can specify the driver for your card in the "WPA" section of the wifi-radar's configuration dialog (for instance, for my ipw2200 wireless card, I chose wext).

Unfortunately, if you try this way, you'll get an error from wifi-radar due to an undefined variable:

NameError: global name 'WPA_SUPPLICANT_ARGS' is not defined

to solve this problem, I actually modified the wifi-radar script (it's a python script) by changing the line:

wpa_args = WPA_SUPPLICANT_ARGS % ( INTERFACE, profile['wpa_driver'] )

with

wpa_args = "-B -i " + INTERFACE + " -c " + WPA_SUPPLICANT_CONF + " -D " + profile['wpa_driver'] + " -P " + WPA_SUPPLICANT_PIDFILE

and now it seems to work correctly.

Saturday, October 06, 2007

Firmware upgrade for router D-Link DSL-G604T

I've been using this ADSL wireless router, D-LINK DSL-G604T, for almost one year now and I was quite happy with it, unless I discovered that the wireless connection provided by this router was not very good: my ADSL is 4Mb (and indeed with the wired connection I was reaching the full speed, ~500K) but with the wireless connection I was hardly reaching 100K speed, so the wireless connection was pretty slow.

I also tried with some wireless settings of the router (also using WEP and WPA) but nothing was changing (and the wireless embedded card in my laptop is actually OK since I was reaching very high speed with other wireless networks).

I checked the D-Link home site only to discover that this router is not maintained any more (discontinued product) and indeed I couldn't find any updates for it. However, by googling I found this site that was referring to a D-Link site which still provides some information and software about this router: http://www.dlink.com.au/tech. In particular, here I found a quite new firmware version for my router revision (A): V2.00B12.AU 20070509.


I was quite skeptical in trying to update the firmware (the last I had tried this procedure I ruined my previous Atlantic router), furthermore, the firmware in this site is Australian and in the readme file you read that this was tested only for Australian router... However, since the router was not working perfectly for me I decided to have a try: if the router was ruined I was willing to buy a new one :-)

Since my firmware version was 1.x and I was updating to version 2.x, as reported in the documentation in that site, I could not use the web update procedure, but I should use the EXE version, so I downloaded this zip file, which contains the .exe program to update the firmware.

Then I followed this procedure (using instructions found on that site and some instructions found on some other forums):

  1. Factory reset of the router (using the button on the back, pressed for at least 10 seconds)
  2. Connect my computer directly to the router and remove all the other computers from the router
  3. Disable antivirus and firewall on my computer
  4. Give a static IP address to my computer in the range 192.168.1.x (the IP and subnet mask depends on the current firmware in your router; for instance, the site states that the router address is 10.1.1.1, subnet mask 255.0.0.0, but my router has the default IP address 192.168.1.1, subnet 255.255.255.0)
  5. Run the exe program and specify the IP address of the router, 192.168.1.1, and the admin password (which is admin, since it was reset to the default settings)
  6. I did not choose the "corrupted image" checkbox (although it was suggested on some forums)
The upgrade of the firmware started and correctly concluded.

At this point the new firmware is on and the router is still working! :-)

Now the router has to be configured from the start. Since the new firmware is Australian, the default IP of the router is 10.1.1.1 (subnet 255.0.0.0), so I had to configure my computer accordingly in order to access the web interface of the router and perform the configuration (first of all I switched back to the local network 192.168.1.x).

Guess what: the wireless network now works perfectly and at full speed! :-)

With this firmware the router should also support ADSL 2, but I can't confirm this since I still have ADSL 1.

There are some new menus which I still have to go through. However, one thing that changed is that you cannot save the new configuration without rebooting, which was a nice previous feature (at least, I wasn't able to find a way to).

Monday, October 01, 2007

Researcher in Turin

It's with great pleasure that I can announce that today I started to work as a Researcher (in Computer Science) at Dipartimento di Informatica, University of Turin! On 20th September 2007 I won the permanent position, and I'm very happy and proud to work in this department :-)

Tuesday, September 18, 2007

GNU Source-highlight 2.8

Apart from the usual bug fixes, the main novelties of this release are:

  • Language definition for S-Lang (thanks to John E. Davis)
  • Perl and Javascript highlighting was improved
  • C-style comments are not defined as nested (I swear I never knew this, though I've been programming in C++ and Java for years... shame on me :-)
  • The padding character of line numbers can be specified (it does not have to be 0, e.g., it could be a blank space), thanks to Roger Nilsson.
Furthermore, I extended the language definition syntax a little bit, in order to handle, what I called, dynamic backreferences (to distinguish them from the backreferences of standard regular expressions).

With dynamic backreferences you can refer to a string matched by the regular expression of the first element of a delim specification. This is crucial in cases when the rigth delimiter depends on a subexpression matched by the left delimiter; for instance, Lua comments can be of the shape --[[ comment ]] or --[=[ comment ]=], but not --[=[ comment ]] neither --[[ comment ]=] (furthermore, they can be nested). Thus, the regular expression of the right element depends on the one of the left element.

A dynamic backreference is similar to a variable, but there's no declaration, and have the shape of

     @{number}

where number is the number of the marked subexpression in the left delimiter (source-highlight will actually check that such a marked subexpression exists in the left delimiter).

For instance, this is the definition of Lua comments (see also lua.lang):

     environment comment delim `--\[(=*)\[` "]" + @{1} + "]"
multiline nested begin
include "url.lang"
...
end

Notice how the left delimiter can match an optional =, as a marked subexpression, and the right delimiter refers to that with @{1}.

Source-highlight will take care of escaping possible special characters during dynamic backreference substitutions. For instance, suppose that you must substitute | for @{1}, because we matched | with the subexpression [^[:alnum:]] in a delim element like the following one:

     comment delim `([^[:alnum:]])` @{1}

Since | is a special character in regular expression syntax source-highlight will actually replace @{1} with \|.

Finally, although this is not related to this new release of source-highlight, Roger Nilsson wrote a frontend for source-highlight that is used in a popular webdesign app for OSX called RapidWeaver. The frontend is called High-Light and allows users to easily add syntax-colored code inside RapidWeaver.

http://nilrogsplace.se/webdesign/rapidweaver/plugins/high-light/index_en.html

Monday, September 17, 2007

Italian Hyphenation in OpenOffice (Debian)

I'm using LaTeX for most of the time for my writings, but for simple and small documents (e.g., letters) I prefer to rely on OpenOffice. I'm actually Italian, but I write most of my documents in English... sometimes, though, I have to go back to my mother tongue ;-) Thus, I wanted to use hyphenation in OpenOffice, under Debian, and so I installed the related packages, in particular, openoffice.org-hyphenation-it.

Unfortunately, hyphenation still did not work... Then, Kent West, in the debian-user mailing list, told me to install hyphenation packages directly from OpenOffice, and it worked! (Thank you Kent!)

I had never used such functionalities in OpenOffice, and they work great! I used the menu File->Wizards->Install Dictionaries and it does most of the work automatically, you just need to retrieve the list of available dictionaries and choose the one you want. Then, you'll find the corresponding dictionary in Options->Language Settings->Writing Aids.

Monday, August 27, 2007

Amarok can't play mp3 files

My favorite linux player, Amarok, stopped working (playing mp3 files) after an upgrade! It kept on complaining that the xine engine was not able to play mp3 files. I had checked and all the right packages seemed to have been installed.

However, I found the solution here, you need to install libxine1-plugins package (together with its dependences) and everything comes back to life :-)

Eclipse Fonts in Linux (part 2)

In this previous post, I said I had found a way to adjust the eclipse fonts (that are gtk fonts) in KDE. That was a right solution, but unfortunately, it does no survive logouts from KDE. Each time you should re-run the gnome configuration program.

However, that's an even nicer solution: install the package gtk-qt-engine:


The GTK-Qt Theme Engine is a plugin for GTK that allows GTK applications to use Qt widget styles. Aimed primarily at KDE users, this plugin provides a way to unify the look and feel of the Linux desktop.

this will add the additional menu in the KDE Control Center - Appearance and Themes that will do the trick! Now Eclipse, Firefox and Thunderbird look very nice with the same KDE style.

Saturday, August 25, 2007

Eclipse Fonts in Linux

As you might have guessed I'm using Linux most of the times (Windows only seldom), but I noticed that the Eclipse font layout looked better in Windows: actually, the Eclipse font size in Windows permits fitting much more information in a view. This is even more crucial when I'm using my laptop with a resolution of 1280x800.

Of course, I had tried to adjust the font size using the Eclipse Preferences, and actually managed to reduce the size of the editors and view titles (also for dialogs), but not other fonts, such as menu fonts, and, more importantly, the size of tables and trees (e.g., the Java Package Explorer). That's actually due to the fact that under Linux Eclipse relies on Gtk, and thus inherits the preferences of the Gnome Desktop but I'm using KDE :-)

Fortunately, it's quite easy to adjust Gnome font settings even from KDE, by running gnome-control-center from the command line and then set the font size from there. Now, my eclipse shows much more information due to the reduced font size.

And by the way, this reduced the fonts also for other Gtk based applications I'm using, e.g., Thunderbird and Firefox!

Saturday, August 04, 2007

GNU Gengetopt 2.21

It wasn't long ago since I released version 2.20 of GNU Gengetopt, and here's a new version.

First of all, I switched to version 3 of GPL.

Another novelty is that gengetopt generates doxygen comments in the generated header files. This way, if you use doxygen on your sources, you'll find also the documentation of the code generated by gengetopt.

Some build issues were fixed: parallel makes work again, and the make files do not depend on GNU make specific features (such as %. rules which are not standard - I must admit I didn't know this, but the new version of automake I started to use, i.e., version 1.10, reports a warning when you use such rules in your Makefile.am files, so I got to know about the problem).

Furthermore, the signatures of generated parser functions changed in a crucial way (of course, the previous signatures are still available, but they are deprecated and possibly removed in the future). In particular, besides the default parser functions (i.e., with default options), other versions are generated that accept further options, such as, e.g., initialize the argument structure, perform required options checks, etc. In the previous versions, this additional signature, whose name was the same as the main parser function with a 2 in the end, used to accept these options as single boolean (actually, integers) parameters. There's nothing wrong with this approach but it does not scale to future enhancements of the signature. In fact, a user requested another option (see the list of changes below) and adding that parameter to the signature would break existing code when regenerating the parser functions, since the code using those functions must be manually modified in order to use the new signature (in C++ this might be a small problem thanks to default values for parameters, but in C...). For this reason, the options are passed to the parser function in the shape of a structure: adding a field in the structure will not break existing code since the signature of the parser functions does not change. Notice that the structure object for these options should not be manually created and initialized (again, if a new field is added in future versions, that field might stay uninitialized), but it should be created and initialized by calling the dedicated generated init function. Here's a snippet of the generated header file (notice the new structure, the new signature with the _ext at the end, the deprecated old signature, and the init function for options):

/** @brief The additional parameters to pass to parser functions */
struct cmdline_parser_params
{
int override; /**< @brief whether to override possibly already present options (default 0) */
int initialize; /**< @brief whether to initialize the option structure gengetopt_args_info (default 0) */
int check_required; /**< @brief whether to check that all required options were provided (default 0) */
int check_ambiguity; /**< @brief whether to check for options already specified in the option structure gengetopt_args_info (default 0) */
} ;

/**
* The command line parser
* @param argc the number of command line options
* @param argv the command line options
* @param args_info the structure where option information will be stored
* @return 0 if everything went fine, NON 0 if an error took place
*/
int cmdline_parser (int argc, char * const *argv,
struct gengetopt_args_info *args_info);

/**
* The command line parser (version with additional parameters - deprecated)
* @param argc the number of command line options
* @param argv the command line options
* @param args_info the structure where option information will be stored
* @param override whether to override possibly already present options
* @param initialize whether to initialize the option structure my_args_info
* @param check_required whether to check that all required options were provided
* @return 0 if everything went fine, NON 0 if an error took place
* @deprecated use cmdline_parser_ext() instead
*/
int cmdline_parser2 (int argc, char * const *argv,
struct gengetopt_args_info *args_info,
int override, int initialize, int check_required);

/**
* The command line parser (version with additional parameters)
* @param argc the number of command line options
* @param argv the command line options
* @param args_info the structure where option information will be stored
* @param params additional parameters for the parser
* @return 0 if everything went fine, NON 0 if an error took place
*/
int cmdline_parser_ext (int argc, char * const *argv,
struct gengetopt_args_info *args_info,
struct cmdline_parser_params *params);

/**
* Allocates dynamically a cmdline_parser_params structure and initializes
* all its fields to 0
* @return the initialized cmdline_parser_params structure
*/
struct cmdline_parser_params *cmdline_parser_params_init();

Finally, here's the complete list of the new features:

* a structure for parser function parameters (that might be extended
in future versions)
* a parser parameter to check whether an option that is parsed is
already present in the args_info struct (suggested by
Yegor Yefremov)
* the generated files contain doxygen documentation (suggested by
Yegor Yefremov)
* parallel make works
* generated make files should not depend on GNU make
* fixed a bug with multiple options with back slashes (thanks to
Peter Kovacs)
* updated to version 3 of GPL

Friday, August 03, 2007

"Last Modified" in PHP

This is nothing exciting, but I just wanted to share :-)

If you want to put in your php web page the well known "Last Modified: " you can simply put this code:

<?php
echo "<b>Last modified:</b> " .
date( "F d, Y. H:i:s a", filemtime("YOUR FILENAME") );
?>

where, of course, you must substitute YOUR FILENAME with the filename of your web page.

That's it!

Tuesday, July 31, 2007

Sony Vaio VGN/S5VP/B and a low cost battery

I have a Sony Vaio VGN-S5VP/B and I hadn't experienced big problems (not even with Linux), so I was pretty happy with it... the only thing that I don't like is that the battery has an autonomy of only 2 hours (trying to save energy with several means, e.g., in Linux with laptop mode did not help). So I wanted to buy an extended battery (4 hours)... 400 euros!!! That's a little bit too much isn't it? So I tried to look for a cheaper one ebay, and found it! With less than 100 euros I bought a VGP-BPL2 battery! I was pretty happy you might guess.

As soon as I received it I put it into charging and noticed that the battery led on the front was flashing continuously (with the original battery it only flashes once a second); well, I thought, it must be because it's an extended one...

Then, after a few hours I tried to turn on the laptop... first bad surprise: the laptop does not turn on: the power led lights but nothing happens. I tried and tried again, but even with the AC connected, the laptop does not power up if the new battery is present.

I then decided to turn on the laptop without the battery (but with the AC) and then I tried to insert the battery: after a few seconds, under Windows XP, a popup shows up saying that my computer was going to sleep because the battery may be incompatible. Second bad surprise. Notice that at that point I could also remove the AC cable and the laptop stayed on with the battery, so the laptop could use the battery after all.

I then found a post on a blog on the net, http://sarabannerman.blogspot.com/2007/04/sony-laptop-battery-mal-ware.html, reporting a similar problem (with a different Sony laptop model). This post says that "Sony laptops are running a little software program called ISBMgr.exe that generates this error when you insert a generic battery. It appears to be the only purpose of the software, and if you disable the software the generic battery works fine." I then disabled that service from MSConfig, and rebooted and found out that the popup message did not come up again!

At this point, I realized that I could actually use the battery, provided I started the computer without the battery on, insert the battery when the computer had started and then remove the AC power (not very comfortable, isn't it? But at lease, I could use the battery). The taskbar battery indicator (both on Linux and Windows) did not show a correct value, but I could stand that, even though that means that I had remember the amount of time I was using the laptop on battery since the system did not sense the correct charge value.

Then, after approximately one hour and half the computer turns off... well, I said, of course, the battery had finished its power, but the system did not realize that... so I put the battery on charge; in the meantime I was checking another post on the net, http://forum.notebookreview.com/showthread.php?t=20440, reporting similar problems and even worse that their battery was not being charged at all... Third bad surprise: I had the problem too... the continuous flashing was actually an error situation, since the battery was not being charged (the hour I was using the computer on battery I was actually using the charge the battery came with).

I then contacted the ebay seller about the problem and he said he would have asked for information about this issue; he then told me that they actually found out that my laptop model was probably having some hardware locks (the software lock consisting of ISBMgr.exe can be disabled as above) and that there was no way the battery could have been used with my laptop. Fourth bad surprise :-(

Fortunately, the seller offered me to take the battery back and to refund me completely.

So with this laptop I can only buy original (very expensive) battery... SHAME ON SONY! That's the last Sony laptop I'll have!

Tuesday, July 24, 2007

Thunderbird 2 Summary Popup

I really like the new version 2 of Thunderbird. It has some nice new features; the ones I like most are those related to copy/move message features, i.e., the "Recent" submenu and in particular the "copy again to" that allows you to copy/move a message to the same folder you copied/moved the last time.

Another nice looking feature is the popup that appears on the right corner on the bottom of your desktop with a summary of the last received messages.

However, I experienced some problems lately that are due to this very popup.

In fact, when I'm using the low 56k modem connection I noticed that the first time in the morning I was reading my email (using my IMAP account, with lots of folders, many filters, and approx 200 messages on the first email check due to all the mailing lists I'm subscribed to) it took up to 10 minutes to be able to open a message in my Inbox, since thunderbird was using a lot of network bandwidth.

When at last I was able to open the message in the Inbox was when the bandwidth usage ceased and at that time also the popup message showed up! So I realized it was all due to that summary since it was inspecting all the folders to build the summary. Notice that this happened even if mail.check_all_imap_folders_for_new was set to false (the default).

Actually, I didn't know how to disable that summary since I could see no such option in the preference dialogs. Then, after asking on the nice MozillaZine forum I tried to disable the mail.biff alert properties (by using Preferences -> Advanced -> Config Editor) and it worked!


The nice popup does not show anymore, but at least I can read my email faster even on a slow modem connection :-)

Then, on the same forum, I was told that there's actually an option in the preference dialog, it's just that I probably haven't noticed... it is in Preferences -> General in the section "When new messages arrive"!

Thursday, July 05, 2007

Gengetopt 2.20

I released version 2.20 of GNU Gengetopt.

As usual, this new release fixes some bugs:

If --include-getopt is specified then the generated parser is actually independent of getopt.h; this way, the included getopt functions code, which will actually be used, will not conflict with possible signatures found in getopt.h; moreover, if getopt.h is not present in the system at all, you won't get an error (bug fixed thanks to Tiago Menezes).

In the --help output a section name and description will not be generated if all its options are hidden (thanks to Edsko de Vries).

I've added the command line option --default-optional that permits specifying that all options are by default optional (unless explicitely specified). In fact, up to now, all options were considered mandatory if not specified otherwise; this might not be a comfortable behavior, but I couldn't change it without breaking existing code... but if you use this command line option for gengetopt, you'll avoid this possible unwanted behavior.

A bug was fixed in the included getopt functions code when --include-getopt is specified.

Finally, I fixed a bug when using args entry in the .ggo file (thanks to Christian Gagneraud). In fact, if in the args entry you specify options such as --file-name the memory was corrupted with possible unexpected behavior. Moreover, now all the options specified in the args entry are taken into consideration.

Monday, July 02, 2007

Problems after upgrade xserver-xorg in Debian

Today I've upgrade my Debian installation (a mix of testing and unstable) and after a reboot the X server did not start complaining about the missing nvidia module (I'm using the drivers from NVidia site). I've also reinstalled the nvidia drivers but the problem still persisted...

I then tried to install the new version of the nvidia drivers (mine was version 1.0-9755 but now there's the new version 100.14.11). After having installed these new drivers, the X server did not complain about the missing nvidia driver, but it was complaining about the missing keyboard driver.

Actually, it looks like the name of the driver for the keyboard has changed from keyboard to kbd, so all I had to do is to change this string in the xorg.conf file... now I'm on X again :-)

Friday, June 08, 2007

GNU Source-highlight 2.7

I've just released the new version of GNU Source-highlight 2.7.

Apart from some bug fixes (and the addition to reference generation for docbook output format) the main novelties concern language definition file syntax which has been improved in order to handle regular expression back references and conditionals. This permits writing regular expressions for language definition files more comfortably.

Previously, regular expressions in a language definition file containing parenthesis were automatically transformed so that the marking parenthesis of the regular expressions became non-marking parenthesis (i.e., no subexpressions were created). This, however, did not permit specifying a back reference or conditionals in a regular expression. While this was not a big lack for standard uses, there might be cases these regular expression mechanisms helped in writing small and compact regular expressions.

For this reason, a new additional syntax for specifying a regular expression was introduced using backticks ` ` to overcome the limitations of the other two syntaxes (i.e., ' ' and " "). With this syntax, the marked subexpressions are not transformed, and so you can use regular expressions mechanisms that rely on marked subexpressions, such as back references and conditionals.

This syntax is also crucial for highlighting specific program parts of some programming languages, such as, e.g., Perl regular expressions (e.g., in substitution expressions) that can be expressed in many forms, in particular, separators for the part to be replaced and the part to replace with can be any non alphanumerical characters21, for instance,


s/foo/bar/g
s|foo|bar|g
s#foo#bar#g
s@foo@bar@g

Using this syntax, and backreferences, we can easily define a single language element to deal with these expressions (without specify all the cases for each possible non alphanumerical character):

regexp = `s([^[:alnum:][:blank:]]).*\1.*\1[ixsmogce]*`

Another new feature in language definition file syntax concerns the possibility of assign a different language element to each subexpressions: Often, you need to specify two program elements in the same regular expressions, because they are tightly related, but you also need to highlight them differently.

For instance, you might want to highlight the name of a class (or interface) in a class (or interface) definition (e.g., in Java). Thus, you can rely on the preceding class keyword which will then be followed by an identifier.

A definition such as

keyword = '(\<(?:class|interface))([[:blank:]]+)([$[:alnum:]]+)'

will not produce a good final result, since the name of the class will be highlighted as a keyword, which is not what you might have wanted: for instance, the class name should be highlighted as a type. Up to version 2.6, the only way to do this was to use state or environments (State/Environment Definitions) but this tended to be quite difficult to write. Since version 2.7, you can specify a regular expression with marked subexpressions and bind each of them to a specific language element (the regular expression must be enclosed in `, see Ways of specifying regular expressions):

(elem1,...,elemn) = `(subexp1)(...)(subexpn)`

Now, with this syntax, we can accomplish our previous goal:

(keyword,normal,type) =
`(\<(?:class|interface))([[:blank:]]+)([$[:alnum:]]+)`

This way, the class (or interface) will be highlighted as a keyword, the separating blank characters are formatted as normal, and the name of the class as a type. This mechanism permits expressing regular expressions for some situation in a much more compact and probably more readable way. For instance, for highlighting ChangeLog parts (the optional * as a symbol, the optional file name and the element specified in parenthesis as a file element, and the rest as normal) such as

* src/Makefile.am (source_highlight_SOURCES): correctly include
changelog_scanner.ll

* this is a comment without a file name

before version 2.6, we used to use these two language definitions:

state symbol start '^(?:[[:blank:]]+)\*[[:blank:]]+' begin
state file start '[^:]+\:' begin
normal start '.'
end
end

state normal start '^(?:[[:blank:]]+)' begin
state file start '[^:]+\:' begin
normal start '.'
end
end

which can be hard to read after having written them. Now, we can write them more easily (see changelog.lang):

(normal,symbol,normal,file)=
`(^[[:blank:]]+)(\*)([[:blank:]]+)((?:[^:]+\:)?)`
(normal,file)= `(^[[:blank:]]+)((?:[^:]+\:)?)`

A big thank goes to Elias Pipping for reporting problems in highlighting some perl parts (concerning regular expressions). This pushed me to extend the language definition file syntax in order to handle these cases more easily. :-)

Wednesday, June 06, 2007

Pdflatex and graphicx

I've always loved LaTeX as a typesetting environment and I'm still sure it's better than any WYSIWYG editor out there.

However, sometimes, you get stuck with some errors... well that's life ;-)

In particular I was struggling with a problem when including a diagram generated with MetaUML into a pdf file. Its documentation suggests this way of including the graphicx package, which is quite recurrent:

% The following is needed in order to make the code compatible
% with both latex/dvips and pdflatex.
\ifx\pdftexversion\undefined
\usepackage[dvips]{graphicx}
\else
\usepackage[pdftex]{graphicx}
\DeclareGraphicsRule{*}{mps}{*}{}
\fi

I was getting this error:
*hyperref using default driver hpdftex*
(/usr/share/texmf-texlive/tex/latex/hyperref/hpdftex.def))

! LaTeX Error: Option clash for package graphicx.
Actually, this time it wasn't hard to figure out where the problem was: the package hpdftex already uses graphicx with its options, so the easy way out is simply to correct the above inclusion of the package by removing the option in case of pdf compilation:

% The following is needed in order to make the code compatible
% with both latex/dvips and pdflatex.
\ifx\pdftexversion\undefined
\usepackage[dvips]{graphicx}
\else
\usepackage{graphicx}
\DeclareGraphicsRule{*}{mps}{*}{}
\fi

Wednesday, May 30, 2007

From Linux 2.6.18 to 2.6.20

I finally took the time to switch from linux kernel 2.6.18 to 2.6.20 on all my computers (two desktops and a laptop).

Unfortunately, on the laptop I experienced some problems, quite grave ones actually, since the kernel stopped on booting since it was unable to mount the main partition. Thus the problem was with the hard disk driver.

The laptop I'm talking about is a Sony Vaio, http://www.lorenzobettini.it/linux/LinuxSonyVaioVGN-S5VP_B, and the problem seemed to be with the SATA hard disk controller.

Actually, when I recompile a new kernel, I usually copy the .config file from the previous version of the kernel, and run a make oldconfig, which lets you specify only the new options w.r.t. the previous kernel (and which, by the way, I find the most useful feature added with version 2.6 series). When running this command with a .config taken from version 2.6.18 I got these warnings:

.config:759:warning: trying to assign nonexistent symbol SCSI_SATA
.config:760:warning: trying to assign nonexistent symbol SCSI_SATA_AHCI
.config:761:warning: trying to assign nonexistent symbol SCSI_SATA_SVW
.config:762:warning: trying to assign nonexistent symbol SCSI_ATA_PIIX
.config:763:warning: trying to assign nonexistent symbol SCSI_SATA_MV
.config:764:warning: trying to assign nonexistent symbol SCSI_SATA_NV
.config:765:warning: trying to assign nonexistent symbol SCSI_PDC_ADMA
.config:767:warning: trying to assign nonexistent symbol SCSI_SATA_QSTOR
.config:768:warning: trying to assign nonexistent symbol SCSI_SATA_PROMISE
.config:769:warning: trying to assign nonexistent symbol SCSI_SATA_SX4
.config:770:warning: trying to assign nonexistent symbol SCSI_SATA_SIL
.config:771:warning: trying to assign nonexistent symbol SCSI_SATA_SIL24
.config:772:warning: trying to assign nonexistent symbol SCSI_SATA_SIS
.config:773:warning: trying to assign nonexistent symbol SCSI_SATA_ULI
.config:774:warning: trying to assign nonexistent symbol SCSI_SATA_VIA
.config:775:warning: trying to assign nonexistent symbol SCSI_SATA_VITESSE
.config:776:warning: trying to assign nonexistent symbol SCSI_SATA_INTEL_COMBINED
then on some mailing lists I read that the SCSI related modules had changed names... In particular, the crucial option for my laptop is the last one SCSI_SATA_INTEL_COMBINED, which now has changed into CONFIG_SATA_INTEL_COMBINED.

Thus, I had to choose this driver under the new menu choice, Serial ATA (prod) and Parallel ATA (experimental) drivers.

Now everything seems to work out fine again :-)

Monday, May 14, 2007

My experience with Kubuntu

I've been experienced for some weeks a crash problems with Eclipse on my Debian installation on my Desktop... I use Debian (and Gentoo) on all my computers (3 desktops and 1 laptop), and this was the only computer showing this problem... unfortunately I haven't been able to solve the problem and so I resorted to reinstall the distribution.

I had tried kubuntu a year ago, and I didn't like it... but I thought I could give it another try, and so, instead of re-installing Debian (I'm using Debian on the other computers after all so I won't miss it), and installed a kubuntu edgy 6.10. Since I definitely don't like Gnome (I never did, and probably never will ;-) while I've always loved the pleasant environment provided by KDE, kubuntu was the only choice, instead of ubuntu.

My first impressions were definitely good: the installation consists of only few steps (although grub by default wants to install itself on the mbr, while I didn't want to touch the mbr, since I'm using Gentoo's installation grub, and it wasn't clear in the beginning how to avoid this) and it's quite smooth.

After the installation I was surprised by the desktop and menus that are quite clean, with only the essential programs; actually I was a little bit disappointed by the lacking of programs I'm used to, such as, e.g., the program for resizing the screen (although there's a similar program in System Settings). Concerning the System Settings program, this seems to replace the standard KDE Control Center, but it lacks some voices such as "themes". You can still call the good ol' KDE Control Center by the terminal, though.

I soon installed the good ol' Synaptic package manager, since I wasn't comfortable with Adept package manager, since it provides too few functionalities and packages (but probably it's more usable for the first time users, so praise for it!). Adept is however very good for update checking and installation. It checks for updates in background and then notifies you if some updates are ready. Installing the updates is also very easy.



What I never liked about (k)ubuntu, and I don't think I ever will, is the fact that you're forced to use sudo, since root shell is disabled... I don't think this enhances security and it's less error prone, but that's just my opinion... In fact, I always use sudo -s that opens a root shell ;-)

Another really great surprise is that, few weeks ago, the adept manager not only notified me about available updates, but also about the update of the whole kubuntu distribution itself!


It offered me to install the update (the new Kubuntu 7.04, codenamed Feisty Fawn), and I didn't refuse :-)


This update takes some time but goes on smoothly


and after the downloading, the installation of the update starts and when it's finished you can simply reboot into your new system!


I then enjoyed my new kubuntu system! I think I'll keep on using kubuntu (of course, together with debian and gentoo :-) since it really looks like a very good distribution (standing on the shoulders of the giants... but it stands very well!)

Friday, May 11, 2007

Clone a partition with cp

Today I had to move a linux root partition to another disk (in the same computer) because I needed more space. Instead of relying on programs such as partimage, I simply tried to use the command cp with option -a:

cp -a /mnt/source/* /mnt/dest/

where of course, /mnt/source is the mount point of the source partition and /mnt/dest/ is the (possibly empty) target partition.

Of course, I'm copying the root partition (/mnt/source) of another linux distribution, not the one where I'm executing this command. For instance, you can execute this command using a live distribution.

I then updated my /etc/fstabs (especially the version in the target partition) to use the new /dev device, and rebooted.

Everything worked fine :-)

Friday, May 04, 2007

Thunderbird 2 (crash problem)

Thunderbird 2 made it into Gentoo!


I was really excited to try it! Unfortunately, at the beginning, I got a very bad surprise: thunderbird crashes as soon as a message gets into the Inbox :-(

And it looked like I was not the only one: http://forums.gentoo.org/viewtopic-t-554755-highlight-.html.

Fortunately, the problem was only due to the theme I was using (Azerty), which seems to be responsible for the crash problem! Switching to the default theme solved all the crash problems.

So now I'm enjoying the new thunderbird with some new nice features :-)

Monday, April 23, 2007

Dealing with Flex generated scanner memory (part 2)

In a previous post, I discussed about my problems with flex scanner's memory. The procedure I was using for manually releasing memory did not seem to be enough since there were still 4 bytes leaking.

Basically, the solution was simpler than I thought: you just need to call

yylex_destroy()
after the lexer finished (for instance, after the call to yyparse()). You can also remove the <> rule (unless you need it to do specific tasks, but not for destroying the scanner!).

This solved all my problems :-)

Saturday, April 07, 2007

SourceHighlightIDE: an IDE for Source-Highlight

I've just released a new software: SourceHighlightIDE, an IDE for GNU Source-highlight (given a source file, produces a document with syntax highlighting).

Sourcehighlightide home page is http://srchighliteide.sourceforge.net.

You can download sourcehighlightide from http://sourceforge.net/projects/srchighliteide.

You can find installation and usage instructions in the on-line manual.

Source-highlight reads source language specifications dynamically, thus it can be easily extended (without recompiling the sources) for handling new languages. It also reads output format specifications dynamically, and thus it can be easily extended (without recompiling the sources) for handling new output formats. The syntax for these specifications is quite easy (take a look at the manual).

Sourcehighlightide is useful when you have to develop a new language definition file for source-highlight. A language definition file makes use of regular expressions, and if they become complex it might be hard to understand how they are matched. Source-highlight already provides some mechanisms for debugging a language definition file; Sourcehighlightide provides a graphical interface to debug a language definition file: it will show which regular expression is matched during the formatting of the input file, and you can process the input file step by step (i.e., an expression at time), and you can also see the output while it is produced.

As you can see from the following screenshot, Sourcehighlightide is a MDI (Multi Document Interface) application, so you can have many files open at one time. Moreover, it provides the basic commands that are common to every GUI application, so we will assume their knowledge throughout this manual.
In the screenshow we see two opened editor windows.


The files that you open with the standard Open commands (or that you create with the New command) are intended to be language definition files for Source-highlight (we refer to Source-highlight manual for further details about such files). This file is shown in the left text area of the editor window.


You start debugging by using the button "Debug" (instead of "Update"), and then press "Step" for formatting element by element the parts of the input file that is to be formatted. You can interrupt the debugging by toggling the button "Debug" again. The debugging steps at each matched regular expression and the one that was matched is shown highlighted in the text area of the language definition file. The "Formatted" tab shows the parts of the input file that are already formatted. In the screenshot above we have just matched a quoted string inside an #include environment.


Notice that if the language definition file includes another one, the editor window will open the included file containing the current matched regular expression.

I developed SourceHighlightIDE for developing new language definition files for Source-highlight, and in particular to debug these language definitions. Some users of Source-highlight often send me new (or modified) language definitions, and I hope SourceHighlightIDE is useful for them too.

Wednesday, March 28, 2007

Restoring GRUB

Today I had to reinstall windows on a computer (sigh). On the same hard disk there were a Debian and a Gentoo installation too. Of course, reinstalling windows wiped away the grub boot loader (the root of grub is in the Debian installation).

So, in order to restore grub, I started with a Netinst Debian disk and typed rescue at the boot prompt.

This led me to a shell in the root directory of my Debian installation. I then cd to the directory /boot/grub, and entered grub with the command

grub --batch

without the --batch option I got an error complaining about a non supported terminal (bterm).

at the grub prompt I checked that the root directory was actually in /dev/hdb8:

find /boot/grub/stage1

and got the expected answer (hd0,7) (remember that disks and partitions in grub start from 0 and not from 1).

So I set the root for grub

root (hd0,7)

and installed grub on hd0

setup (hd0)

quit grub and reboot... argh... bad surprise: after the message saying that grub was loading, the screen went blank and couldn't load any operating system :-(

I then booted again with the Debian netinst floppy disk. This time I tried to create a grub disk: I cd into /boot/grub and:

dd if=stage1 of=/dev/fd0 bs=512 count=1
dd if=stage2 of=/dev/fd0 bs=512 seek=1

then booted with this disk. I then got a grub prompt, and tried to reinstall grub from there (using the same steps above).

It worked!!! :-)

This time my grub menu was back and can boot all the operating systems I have.

Tuesday, March 27, 2007

Dealing with Flex generated scanner memory

I've been using Flex, a tool for generating scanners (tokenizers), for a while now, and I never worried about memory management of the C scanners it generates: I thought memory would be handled automatically, i.e., freed when the scanner finished its execution.

Actually, this is not the case: you have to deal with it yourself! If you don't you will end up with a memory leak of about 16k (see also the manual); you can use valgrind to check this.

Basically, all you have to do is to call yy_delete_buffer when the scanning is over. For instance, when you reach the end of file. Here's what I do in my flex scanners:

<<EOF>> {
/* For non-reentrant C scanner only. */
yy_delete_buffer(YY_CURRENT_BUFFER);

yyterminate();
}

Unfortunately, you'll still experience a memory leak of about 4 bytes, and this looks like a bug. Hope it will be fixed soon...

Friday, March 23, 2007

GNU Source-highlight 2.6

I've recently released the new version of GNU Source-highlight, http://www.gnu.org/software/src-highlite, which, given a source file, produces a document with syntax highlighting.

The main novelties are:

  • I've added language definitions for Makefiles, m4 and CSS.
  • In style files you can specify a color in double quotes meaning that that colro will be inserted in the output without any translation
  • In style files you can specify the formatting options for more than one element on the same line, by separating the elements with commas, e.g.,
    time, file darkblue b ;
  • In the style file you can also specify the background color for each element (not all the output formats support background colors; e.g., XHTML and LaTeX with colors support it, but plain HTML does not).
    todo black bg:cyan b;
    This formats todo elements in black with a cyan background
  • The background color for the entire output document can be specified in the style file
    bgcolor "white";
  • Furthermore, the main novelty, is that you can use a CSS file as a style file so that source-highlight will use its formatting specification to produce the output (independently from HTML); thus, instead of using
    --style-file=mystyle.style
    you can use
    --style-css-file=mystyle.css
    So that the same CSS file can be used either as a standard CSS file in a (X)HTML document, or as the style file for formatting in any format with source-highlight.
In order to show this last new feature, I inserted many CSS files (adapted from the SHJS project). Moreover, I've used all these CSS file to generate some examples; these examples are formatted in XHTML (the output does not use the CSS: the XHTML output contains direct formatting for all elements, and these elements are formatted by using the color and other style specifications taken from the CSS file).

This is the entire file (~400k) with all these examples.

../src/default.css


/*
This is a classical Hello program
to test source-highlight with Java programs.

to have an html translation type

source-highlight -s java -f html --input Hello.java --output Hello.html
source-highlight -s java -f html < Hello.java > Hello.html

or type source-highlight --help for the list of options

written by
Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite
*/

package hello;

import java.io.* ;

/**
* <p>
* A simple Hello World class, used to demonstrate some
* features of Java source highlighting.
* </p>
* TODO: nothing, just to show an highlighted TODO or FIXME
*
* @author Lorenzo Bettini
* @version 2.0
*/
public class Hello {
int foo = 1998 ;
int hex_foo = 0xCAFEBABE;
boolean b = false;
Integer i = null ;
char c = '\'', d = 'n', e = '\\' ;
String xml = "<tag attr=\"value\">&auml;</tag>", foo2 = "\\" ;

public static void main( String args[] ) {
// just some greetings ;-) /*
System.out.println( "Hello from java2html :-)" ) ;
System.out.println( "\tby Lorenzo Bettini" ) ;
System.out.println( "\thttp://www.lorenzobettini.it" ) ;
if (argc > 0)
String param = argc[0];
//System.out.println( "bye bye... :-D" ) ; // see you soon
}
}

mono.css


/*
This is a classical Hello program
to test source-highlight with Java programs.

to have an html translation type

source-highlight -s java -f html --input Hello.java --output Hello.html
source-highlight -s java -f html < Hello.java > Hello.html

or type source-highlight --help for the list of options

written by
Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite
*/

package hello;

import java.io.* ;

/**
* <p>
* A simple Hello World class, used to demonstrate some
* features of Java source highlighting.
* </p>
* TODO: nothing, just to show an highlighted TODO or FIXME
*
* @author Lorenzo Bettini
* @version 2.0
*/
public class Hello {
int foo = 1998 ;
int hex_foo = 0xCAFEBABE;
boolean b = false;
Integer i = null ;
char c = '\'', d = 'n', e = '\\' ;
String xml = "<tag attr=\"value\">&auml;</tag>", foo2 = "\\" ;

public static void main( String args[] ) {
// just some greetings ;-) /*
System.out.println( "Hello from java2html :-)" ) ;
System.out.println( "\tby Lorenzo Bettini" ) ;
System.out.println( "\thttp://www.lorenzobettini.it" ) ;
if (argc > 0)
String param = argc[0];
//System.out.println( "bye bye... :-D" ) ; // see you soon
}
}

mono-alt.css


/*
This is a classical Hello program
to test source-highlight with Java programs.

to have an html translation type

source-highlight -s java -f html --input Hello.java --output Hello.html
source-highlight -s java -f html < Hello.java > Hello.html

or type source-highlight --help for the list of options

written by
Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite
*/

package hello;

import java.io.* ;

/**
* <p>
* A simple Hello World class, used to demonstrate some
* features of Java source highlighting.
* </p>
* TODO: nothing, just to show an highlighted TODO or FIXME
*
* @author Lorenzo Bettini
* @version 2.0
*/
public class Hello {
int foo = 1998 ;
int hex_foo = 0xCAFEBABE;
boolean b = false;
Integer i = null ;
char c = '\'', d = 'n', e = '\\' ;
String xml = "<tag attr=\"value\">&auml;</tag>", foo2 = "\\" ;

public static void main( String args[] ) {
// just some greetings ;-) /*
System.out.println( "Hello from java2html :-)" ) ;
System.out.println( "\tby Lorenzo Bettini" ) ;
System.out.println( "\thttp://www.lorenzobettini.it" ) ;
if (argc > 0)
String param = argc[0];
//System.out.println( "bye bye... :-D" ) ; // see you soon
}
}

sh_golden.css


/*
This is a classical Hello program
to test source-highlight with Java programs.

to have an html translation type

source-highlight -s java -f html --input Hello.java --output Hello.html
source-highlight -s java -f html < Hello.java > Hello.html

or type source-highlight --help for the list of options

written by
Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite
*/

package hello;

import java.io.* ;

/**
* <p>
* A simple Hello World class, used to demonstrate some
* features of Java source highlighting.
* </p>
* TODO: nothing, just to show an highlighted TODO or FIXME
*
* @author Lorenzo Bettini
* @version 2.0
*/
public class Hello {
int foo = 1998 ;
int hex_foo = 0xCAFEBABE;
boolean b = false;
Integer i = null ;
char c = '\'', d = 'n', e = '\\' ;
String xml = "<tag attr=\"value\">&auml;</tag>", foo2 = "\\" ;

public static void main( String args[] ) {
// just some greetings ;-) /*
System.out.println( "Hello from java2html :-)" ) ;
System.out.println( "\tby Lorenzo Bettini" ) ;
System.out.println( "\thttp://www.lorenzobettini.it" ) ;
if (argc > 0)
String param = argc[0];
//System.out.println( "bye bye... :-D" ) ; // see you soon
}
}

sh_night.css


/*
This is a classical Hello program
to test source-highlight with Java programs.

to have an html translation type

source-highlight -s java -f html --input Hello.java --output Hello.html
source-highlight -s java -f html < Hello.java > Hello.html

or type source-highlight --help for the list of options

written by
Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite
*/

package hello;

import java.io.* ;

/**
* <p>
* A simple Hello World class, used to demonstrate some
* features of Java source highlighting.
* </p>
* TODO: nothing, just to show an highlighted TODO or FIXME
*
* @author Lorenzo Bettini
* @version 2.0
*/
public class Hello {
int foo = 1998 ;
int hex_foo = 0xCAFEBABE;
boolean b = false;
Integer i = null ;
char c = '\'', d = 'n', e = '\\' ;
String xml = "<tag attr=\"value\">&auml;</tag>", foo2 = "\\" ;

public static void main( String args[] ) {
// just some greetings ;-) /*
System.out.println( "Hello from java2html :-)" ) ;
System.out.println( "\tby Lorenzo Bettini" ) ;
System.out.println( "\thttp://www.lorenzobettini.it" ) ;
if (argc > 0)
String param = argc[0];
//System.out.println( "bye bye... :-D" ) ; // see you soon
}
}

sh_greenlcd.css


/*
This is a classical Hello program
to test source-highlight with Java programs.

to have an html translation type

source-highlight -s java -f html --input Hello.java --output Hello.html
source-highlight -s java -f html < Hello.java > Hello.html

or type source-highlight --help for the list of options

written by
Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite
*/

package hello;

import java.io.* ;

/**
* <p>
* A simple Hello World class, used to demonstrate some
* features of Java source highlighting.
* </p>
* TODO: nothing, just to show an highlighted TODO or FIXME
*
* @author Lorenzo Bettini
* @version 2.0
*/
public class Hello {
int foo = 1998 ;
int hex_foo = 0xCAFEBABE;
boolean b = false;
Integer i = null ;
char c = '\'', d = 'n', e = '\\' ;
String xml = "<tag attr=\"value\">&auml;</tag>", foo2 = "\\" ;

public static void main( String args[] ) {
// just some greetings ;-) /*
System.out.println( "Hello from java2html :-)" ) ;
System.out.println( "\tby Lorenzo Bettini" ) ;
System.out.println( "\thttp://www.lorenzobettini.it" ) ;
if (argc > 0)
String param = argc[0];
//System.out.println( "bye bye... :-D" ) ; // see you soon
}
}

sh_ide-eclipse.css


/*
This is a classical Hello program
to test source-highlight with Java programs.

to have an html translation type

source-highlight -s java -f html --input Hello.java --output Hello.html
source-highlight -s java -f html < Hello.java > Hello.html

or type source-highlight --help for the list of options

written by
Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite
*/

package hello;

import java.io.* ;

/**
* <p>
* A simple Hello World class, used to demonstrate some
* features of Java source highlighting.
* </p>
* TODO: nothing, just to show an highlighted TODO or FIXME
*
* @author Lorenzo Bettini
* @version 2.0
*/
public class Hello {
int foo = 1998 ;
int hex_foo = 0xCAFEBABE;
boolean b = false;
Integer i = null ;
char c = '\'', d = 'n', e = '\\' ;
String xml = "<tag attr=\"value\">&auml;</tag>", foo2 = "\\" ;

public static void main( String args[] ) {
// just some greetings ;-) /*
System.out.println( "Hello from java2html :-)" ) ;
System.out.println( "\tby Lorenzo Bettini" ) ;
System.out.println( "\thttp://www.lorenzobettini.it" ) ;
if (argc > 0)
String param = argc[0];
//System.out.println( "bye bye... :-D" ) ; // see you soon
}
}

sh_kwrite.css


/*
This is a classical Hello program
to test source-highlight with Java programs.

to have an html translation type

source-highlight -s java -f html --input Hello.java --output Hello.html
source-highlight -s java -f html < Hello.java > Hello.html

or type source-highlight --help for the list of options

written by
Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite
*/

package hello;

import java.io.* ;

/**
* <p>
* A simple Hello World class, used to demonstrate some
* features of Java source highlighting.
* </p>
* TODO: nothing, just to show an highlighted TODO or FIXME
*
* @author Lorenzo Bettini
* @version 2.0
*/
public class Hello {
int foo = 1998 ;
int hex_foo = 0xCAFEBABE;
boolean b = false;
Integer i = null ;
char c = '\'', d = 'n', e = '\\' ;
String xml = "<tag attr=\"value\">&auml;</tag>", foo2 = "\\" ;

public static void main( String args[] ) {
// just some greetings ;-) /*
System.out.println( "Hello from java2html :-)" ) ;
System.out.println( "\tby Lorenzo Bettini" ) ;
System.out.println( "\thttp://www.lorenzobettini.it" ) ;
if (argc > 0)
String param = argc[0];
//System.out.println( "bye bye... :-D" ) ; // see you soon
}
}

sh_easter.css


/*
This is a classical Hello program
to test source-highlight with Java programs.

to have an html translation type

source-highlight -s java -f html --input Hello.java --output Hello.html
source-highlight -s java -f html < Hello.java > Hello.html

or type source-highlight --help for the list of options

written by
Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite
*/

package hello;

import java.io.* ;

/**
* <p>
* A simple Hello World class, used to demonstrate some
* features of Java source highlighting.
* </p>
* TODO: nothing, just to show an highlighted TODO or FIXME
*
* @author Lorenzo Bettini
* @version 2.0
*/
public class Hello {
int foo = 1998 ;
int hex_foo = 0xCAFEBABE;
boolean b = false;
Integer i = null ;
char c = '\'', d = 'n', e = '\\' ;
String xml = "<tag attr=\"value\">&auml;</tag>", foo2 = "\\" ;

public static void main( String args[] ) {
// just some greetings ;-) /*
System.out.println( "Hello from java2html :-)" ) ;
System.out.println( "\tby Lorenzo Bettini" ) ;
System.out.println( "\thttp://www.lorenzobettini.it" ) ;
if (argc > 0)
String param = argc[0];
//System.out.println( "bye bye... :-D" ) ; // see you soon
}
}

sh_emacs.css


/*
This is a classical Hello program
to test source-highlight with Java programs.

to have an html translation type

source-highlight -s java -f html --input Hello.java --output Hello.html
source-highlight -s java -f html < Hello.java > Hello.html

or type source-highlight --help for the list of options

written by
Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite
*/

package hello;

import java.io.* ;

/**
* <p>
* A simple Hello World class, used to demonstrate some
* features of Java source highlighting.
* </p>
* TODO: nothing, just to show an highlighted TODO or FIXME
*
* @author Lorenzo Bettini
* @version 2.0
*/
public class Hello {
int foo = 1998 ;
int hex_foo = 0xCAFEBABE;
boolean b = false;
Integer i = null ;
char c = '\'', d = 'n', e = '\\' ;
String xml = "<tag attr=\"value\">&auml;</tag>", foo2 = "\\" ;

public static void main( String args[] ) {
// just some greetings ;-) /*
System.out.println( "Hello from java2html :-)" ) ;
System.out.println( "\tby Lorenzo Bettini" ) ;
System.out.println( "\thttp://www.lorenzobettini.it" ) ;
if (argc > 0)
String param = argc[0];
//System.out.println( "bye bye... :-D" ) ; // see you soon
}
}

sh_neon.css


/*
This is a classical Hello program
to test source-highlight with Java programs.

to have an html translation type

source-highlight -s java -f html --input Hello.java --output Hello.html
source-highlight -s java -f html < Hello.java > Hello.html

or type source-highlight --help for the list of options

written by
Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite
*/

package hello;

import java.io.* ;

/**
* <p>
* A simple Hello World class, used to demonstrate some
* features of Java source highlighting.
* </p>
* TODO: nothing, just to show an highlighted TODO or FIXME
*
* @author Lorenzo Bettini
* @version 2.0
*/
public class Hello {
int foo = 1998 ;
int hex_foo = 0xCAFEBABE;
boolean b = false;
Integer i = null ;
char c = '\'', d = 'n', e = '\\' ;
String xml = "<tag attr=\"value\">&auml;</tag>", foo2 = "\\" ;

public static void main( String args[] ) {
// just some greetings ;-) /*
System.out.println( "Hello from java2html :-)" ) ;
System.out.println( "\tby Lorenzo Bettini" ) ;
System.out.println( "\thttp://www.lorenzobettini.it" ) ;
if (argc > 0)
String param = argc[0];
//System.out.println( "bye bye... :-D" ) ; // see you soon
}
}

sh_desert.css


/*
This is a classical Hello program
to test source-highlight with Java programs.

to have an html translation type

source-highlight -s java -f html --input Hello.java --output Hello.html
source-highlight -s java -f html < Hello.java > Hello.html

or type source-highlight --help for the list of options

written by
Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite
*/

package hello;

import java.io.* ;

/**
* <p>
* A simple Hello World class, used to demonstrate some
* features of Java source highlighting.
* </p>
* TODO: nothing, just to show an highlighted TODO or FIXME
*
* @author Lorenzo Bettini
* @version 2.0
*/
public class Hello {
int foo = 1998 ;
int hex_foo = 0xCAFEBABE;
boolean b = false;
Integer i = null ;
char c = '\'', d = 'n', e = '\\' ;
String xml = "<tag attr=\"value\">&auml;</tag>", foo2 = "\\" ;

public static void main( String args[] ) {
// just some greetings ;-) /*
System.out.println( "Hello from java2html :-)" ) ;
System.out.println( "\tby Lorenzo Bettini" ) ;
System.out.println( "\thttp://www.lorenzobettini.it" ) ;
if (argc > 0)
String param = argc[0];
//System.out.println( "bye bye... :-D" ) ; // see you soon
}
}


Lots and lots of colors! :-)