Mike Lischke:
> There are also problems on macOS. Since a few Scintilla versions the width is no longer computed correctly. There are 2-3 pixels missing causing the longest entry to be shorted:
>
> <cc1.png> <cc2.png>
There is already an average character width (commonly around 7 pixels) worth of extra space added which is visible as unused space on the right. Whether the text is truncated depends on the text and font - zoom the view in or out and the problem may not appear. The measurement of the width of the strings appears reasonable but there may be additional details that should be taken into account - perhaps there is an API to ask for the text column’s preferred width for a string. I suppose an extra 3 pixels can be arbitrarily added but that may still break in untried cases.
> Regarding layout/colors/drawing: I'd like to see an API in Scintilla that allows the application to draw the auto completion entries.
On Cocoa, Scintilla doesn’t even draw the entries: Cocoa does the drawing with Scintilla telling it what the text or icon is for each cell.
The autocompletion list implementation differs greatly between platforms. Perhaps adding platform-specific APIs would be simpler than trying to abstract over all the platforms.
> (XCode uses a very similar layout, but without the context help). Such an API could be a notification carrying a pointer to a native drawing surface (HDC on Windows, CGContextRef on Cocoa, cairo_t on GTK) and a rectangle where to draw to.
This isn’t how list boxes work on Cocoa, GTK+, or Qt. On Cocoa, you implement a NSTableViewDataSource-compliant object that feeds data into an NSTableView and then the NSTableView (or its sub-objects) does the drawing. Custom drawing could be implemented by subclassing NSCell but that looks like much work. The coderunner example appears to be using 3 list columns with attributed text for the rightmost column as it displays both bold and plain.
GTK+ is similar and Qt uses a simplified API that handles the common icon+text case. Its only on Windows that Scintilla draws autocompletion entries.
Neil