❌ About FreshRSS

Normal view

There are new articles available, click to refresh the page.
Before yesterdayNews from the Ada programming language world

LEA 0.85 - the Tabs are here!

20 November 2022 at 20:05
Note for subscribers: if you are interested in my Ada programming articles only, you can use this RSS feed link.

The 0.85 version of LEA (the Lightweight Editor for Ada) is available!

Web site: http://l-e-a.sf.net/
Source repository #1: https://sf.net/p/l-e-a/code/HEAD/tree/
Source repository #2: https://github.com/zertovitch/lea

The new version has two main new features:
Β  - Tabs (screenshot below)
Β  - LEA doesn't write scilexer.dll as a file; thus, it runs as a portable application (in the sense: you can run it from a read-only drive directly, without installation)

Click to enlarge


AZip, GWindows, the Windows API and another surprise!

13 November 2022 at 12:38


Note for subscribers: if you are interested in my Ada programming articles only, you can use this RSS feed link.

Last post was about an improvement of the GWindows.Common_Controls.Ex_List_View widget which is distributed with the GWindows framework. Without changing the specification, it was possible to avoid Windows API calls during the performance-sensitive comparison function, leading to impressive speedup factors: from 3.3x with 4096 items to 16.5x with 32768 items.

But actually, it was only the prelude!

If you can live with data duplication, which is not nice and not always practical, it is possible to do much better. Concretely, you store the same strings in the cells of the List_View widget and in the payload data associated with each row. Then, the sorting for all columns (text, dates, numbers, ...) is using the payload data. An addition to the Ex_List_View package later (this time, enriching a bit the specification), the comparison function may exclusively use the payload of both compared rows, directly, thus avoiding any API call during the lifespan of the comparison function.

Without going into too many details, here are the performance gains in charts:

This represents a factor of ~100x to ~300x on top of the previous improvement, depending on the test machine.

Here are links to the sources:


Project site & Subversion repository:
GitHub clone with Git repository:


Project site & Subversion repository:
GitHub clone with Git repository:

LEA 0.84 - the Build & Run button!

12 November 2022 at 11:43


Note for subscribers: if you are interested in my Ada programming articles only, you can use this RSS feed link.

The 0.84 version of LEA (the Lightweight Editor for Ada) is available!

Web site: http://l-e-a.sf.net/
Source repository #1: https://sf.net/p/l-e-a/code/HEAD/tree/
Source repository #2: https://github.com/zertovitch/lea

This version is essentialy a rework of LEA's ergonomy - we had recently the chance of having a group of young first-time programmers and first-time LEA users to test it!

The main addition is the green Build & Run button, which matches a (less intuitive) menu entry and the F9 key.

Click screenshot to enlarge

Another addition is a dedicated box for the "User_Abort" internal Virtual Machine exception, so that the LEA user doesn't take the exception message for an actual error (which would be the case for any other exception).




AZip, GWindows, the Windows API and a good surprise!

5 November 2022 at 21:23

Note for subscribers: if you are interested in my Ada programming articles only, you can use this RSS feed link.

Programming user interfaces is often a bizarre experience where you program only one side and the other side is done by other people (for instance the programmers of the Windows components) that you cannot contact for asking questions. Even if it was possible (like working at Microsoft in Redmond), those people are probably already retired for long. So the only possibility is to experiment with the black box and skim the Internet in the hope someone else has encountered the same issues and found a solution. Fortunately, as time goes by, there are more and more solutions appearing.

Here is a typical example.

The AZip Zip archive manager is designed to operate with different user interface systems, like native Windows (it is done through the GWindows framework), or the multi-platform Gtk system (there is a draft version of that).

AZip uses the Ex_List_View_Control_Type widget (package GWindows.Common_Controls.Ex_List_View) which is an extension of List_View_Control_Type (package GWindows.Common_Controls), developed by the company KonAd GmbH, with cool features like individually coloured cells, and sorting.

A hiccup was the performance of the sorting. On Zip archives with many entries (say, 10,000 or more), the sorting became frustratingly slow. On other software sorting is MUCH faster, so there was an issue to solve.

Sorting a column in AZip - click to enlarge screenshot

Fortunately GWindows and its extensions are completely open-source, so you can inspect everything. By the way, it is also the case for GNAT (the open-source Ada compiler): you can inspect the entire run-time library. All in all, AZip is a rare software whose entire source (the program itself, the user interface, the data compression library, and the run-time library) can be comfortably browsed per mouse clicks from GNAT Studio. This amounts to more than 112,000 and 572 units (mostly packages), completely in Ada. You see here a slide from a FOSDEM presentation about AZip.

Break-down of the Ada source code of AZip

Wait, the "entire source"? Not really, since Windows is neither open-source, nor in Ada. That's where the fun begins. Back to our sorting issue (sorting is too slow). GWindows (the nice object-oriented framework) provides a Sort method, which sends behind the scenes a Windows message, LVM_SORTITEMS, which calls back a comparison function provided by GWindows, Compare_Internal, which in turn will calls a On_Compare method - built-in, or derived by the programmer, for instance for sorting the columns of a Zip archive where some columns are numerical and other ones are texts. This mechnism is convoluted but it is how it works if you want to use the List_View widget provided by Windows. It is a case where you really have to dance with the Windows API (of course, you would have the same situation for other user interface systems: Mac, Gtk, ...). After a certain amount of Internet searches, through forums, blogs, etc., it appears that there is an alternative way with a Windows message called LVM_SORTITEMSEX. Note the "EX" at the end: it is for "extended". You have probably noticed rather the last three letters, but anyway... This alternative way provides directly to the comparison call-back the indices of the rows that Windows want to compare. With the initial approach (using LVM_SORTITEMS, without EX) two messages, LVM_FINDITEM, have to be sent in order to get those row indices. So you can save those two calls and hope for a small speedup.

Now comes the surprise. The gain in terms of time is astounding!

On a certain computer, with 4096 items to be sorted, both calls (that can be skipped with the new approach) consume 70% of the entire sorting time - including the comparison itself, the sorting effort on Windows' side, the object-oriented dispatching, etc. . With 8192 items, it is 81%. With 16'384 items, it is 88%. With 32'768 items, 94% of the time is consumed by the extra calls. Seen differently, the old approach takes 14 seconds for sorting, and the new approach takes 0.85 second for the same job!

Here are performance charts on two differents computers.


Interestingly, the performance stays linear with the new approach.

Here are links to the sources:


Project site & subversion repository:
GitHub clone with git repository:


Project site & subversion repository:
GitHub clone with git repository:

News about GWindows.Scintilla

21 November 2021 at 17:25


Some news about the GWindows Ada programming framework, more specifically, the GWindows.Scintilla package.

Scintilla is a powerful text editor widget that is behind, among others, LEA and Notepad++.

  • The Scintilla notifications work now on 64 bit platforms. Of course the compatibility is kept for 32 bit, so if you need to build your application for a 32 bit target, the Scintilla widgets will continue to work as before.
  • Method names are now "de-camel-cased". For instance you have now: "Move_Caret_Inside_View" instead of a cryptic "MoveCaretInsideView". The naming convention is now consistent with the rest of the GWindows framework, GNAT's run-time and most Ada libraries.

GWindows can be found on SourceForge here and on GitHub here.

Finally, here is a cute screenshot of the Scintilla sample (gwindows\samples\scintilla\sci_example.adb) running, with its source code shown by LEA - so again, GWindows.Scintilla in action!

Advent of Code 2020 with HAC and LEA

2 December 2020 at 20:27

First use of HAC, via the LEAΒ editor, for the famous Advent of Code contest.

LEA screenshot: a parser for Day 2 Advent of Code's puzzle

In my (of course biased) opinion, LEA is perfect (among other tasks...) forΒ developing quickly Ada solutions to the Advent of Code problems.

After the rush, I tidy up the source code with GNAT's style checks. Hence the presence of a GNAT project file, aoc_2020.gpr .

Then I post my solutions as HAC examples,Β hereΒ andΒ here.Β 

The HAC scripts invasion

27 October 2020 at 12:42

Perhaps you were already confronted to this problem:

  • You have "housekeeping" shell scripts for cleaning files, building tools, listing results, etc. .Β 
  • You would like to have the project, that these scripts are serving, running on multiple systems: Linux, MacOS, Windows, ... Especially for highly portable Ada projects, it is almost a must.
  • But in the end, you have lots of duplicate scripts: for each script one version for Linux, one version for Windows.
The solution: use HAC (the HAC Ada Compiler).

One practical example of script simplification can be found in the Zip-Ada project.
In the test directory, there were test_za.cmd and test_za.sh, meant to do the same thing: testing the compression side of the library. But the scripts were out of sync, and it was a pain to make them converge. So it was a perfect opportunity to switch to HAC, which has since its 0.076 version standard subprograms for file management. The unified script is test_za.adb, can be run with the hacΒ test_za.adb command.
NowΒ test_rz.cmdΒ andΒ test_rz.sh (for testing the Zip archive recompression tool, ReZip) are also unified, and so areΒ make_za.cmdΒ andΒ make_za.sh for building everything.

More generally HAC scripts have tremendous advantages:
  • They are plain Ada, so there is no need to learn a new language.
  • If you need it, they can be compiled with an Ada compiler. It can be for different reasons:
    • You need performance (nested loops, for instance). You'll get C-level performance, at least with the GNAT compiler.
    • You need more functionalities that are not present in HAC.
    • You are afraid HAC is not developed or supported further.
Here are a few screenshots:

The screenshots are taken from TeXCAD and LEA - other Ada projects 😏...

AZip 2.40 - Windows Explorer context menus

3 October 2020 at 18:00

New release (2.40) of AZip.

The long-awaited Windows Explorer integration is there:

Context menu for a file

Context menu for a folder

This integration is activated upon installation or on demand via the Manage button:



This new version is based on the Zip-Ada library v.57 and includes its recent developments.


GWindows: Desktop shortcuts and Explorer context menu

29 September 2020 at 10:13

Just in time to celebrate the 25th anniversary of Windows as we know it (ouch!), here is a gadget-ish contribution to the GWindows library, the open-source Ada library for MS Windows, availableΒ hereΒ andΒ here.

In there gwindows/contrib directory, there is gwin_util.ads (spec.) and gwin_util.adb (body), and in gwindows/contrib/test, there are demos. All that is available comfortably through the gwindows_contrib.gpr project file in the gwindows directory.

  1. test_shortcut.adb:

  2. test_explorer_context_menu.adb:

AZip in action for duplicating a Thunderbird profile

18 September 2020 at 07:16

You want to copy your Thunderbird profile from machine A to machine B (with all mail accounts, passwords, settings, feeds, newgroups, ...) ? Actually it is very easy. From the user storage (on Windows, %appdata% (you get there with Windows key+R and typing %appdata%)), you copy the entire Thunderbird folder of machine A to the equivalent location on machine B, and that's it. The new active profile will be automatically selected since the file profiles.ini will be overwritten on the way.

Now, if you want or need to use a cloud drive or a USB stick for the operation, it's better to wrap everything in a Zip file (a single file instead of hundreds) to save time. Plus, you can store the Zip file in case of an emergency (losing data on both A and B machines).

With AZip, it's pretty easy:Β 

  • Shut down Thunderbird on both machines.
  • On machine A: drag & drop the Thunderbird folder on an empty AZip window.
  • Copy or move the Zip file.
  • On machine B: extract everything with another drag & drop,Β from AZip to the Explorer window with the %appdata% path. When asked "Use archive's folder names for output", say "Yes". When asked "Do you want to replace this file ?", say "All".

That's it!

Here a few screenshots:

Folder tree view - click to enlarge

You can squeeze the data to a smaller size (the LZMA format will be most of the time chosen over Deflate) with the "Recompress" button (third from the right).

After recompression - click to enlarge