Hints to implement Scintilla on a new Platform

68 views
Skip to first unread message

Aurelien R.

unread,
Oct 2, 2009, 8:58:48 AM10/2/09
to scintilla-interest
Hi everyone,

i'am looking for documentation on implementing scintilla on a new
platform but i found nothing else than the help given on Scintilla web
site. I also looked at the source code of many existing
implementations, Win, GTK, WX, QT, etc...

I am developing a robots game in which the player-programmer has to
program the Artificial Intelligence of itw own units. the AI scripting
is made in Squirrel Script. I want an ingame code editor with Syntax
highlithing, a little bit of code completion and i think Scintilla
will give me the best results. The game is developped in SDL, along
with a complete GUI system on top of SDL named Guichan, providing
quite everything needed to implement Scintilla on it, complete text
drawing, primitives drawings, window management, widgets like Listbox,
DropDown menus etc...

I have got some questions :
- why do all the implementations i saw use a proxy to provide a new
interface to the final widget user, is it to completely hide the
scintilla headers and classes?

i you want to look at the possiblitites og GuiChan, the new platform i
am a bout to implement, look here :
http://guichan.sourceforge.net

If some of you has hints, advices or links to guide me in this
process, it would be great. ;-)

Thank you. (sorry for my english)

Aurelien R.

Philippe Lhoste

unread,
Oct 2, 2009, 12:21:23 PM10/2/09
to scintilla...@googlegroups.com
On 02/10/2009 14:58, Aurelien R. wrote:
> I have got some questions :
> - why do all the implementations i saw use a proxy to provide a new
> interface to the final widget user, is it to completely hide the
> scintilla headers and classes?

I don't see the other questions... :-)
It seems obvious, so perhaps I didn't understand the question.
Basically, Scintilla manipulates abstract things like Surface, Font, ListBox. It doesn't
really care how it is actually managed by the target system.
The PlatXxx.cxx is in charge of actually implementing these abstract concepts. That's not
really a proxy, more like a concrete implementation.
That's what will allow you to use Scintilla on your system: you have only to implement
PlatGuiChan.cxx, without changing (in theory) Scintilla code itself.

--
Philippe Lhoste
-- (near) Paris -- France
-- http://Phi.Lho.free.fr
-- -- -- -- -- -- -- -- -- -- -- -- -- --

Aurelien R.

unread,
Oct 2, 2009, 12:35:05 PM10/2/09
to scintilla-interest
> That's what will allow you to use Scintilla on your system: you have only to implement
> PlatGuiChan.cxx, without changing (in theory) Scintilla code itself.

I hope only implementing PlatGuichan.cxx will suffice... And in fact i
already did that, but i have problems to create the editor after that,
and to make it display anything. And the problem is i don't know if it
comes from errors in my platorm implementation or in my use of
Scintilla...
That's why i would like to hear from people who already went through
this process. But in fact it is maybe something too specific, to find
documentation on this. Perhaps the best way to learn this is to look
at source code.

Thank you anyway. Btw i stay open to advices.

Aurélien R.

Neil Hodgson

unread,
Oct 2, 2009, 7:10:15 PM10/2/09
to scintilla...@googlegroups.com
Aurelien R.:

> I have got some questions :
> - why do all the implementations i saw use a proxy to provide a new
> interface to the final widget user, is it to completely hide the
> scintilla headers and classes?

All of the internal headers should be hidden with possibly
Scintilla.h, SciLexer.h and maybe a platform specific header like
ScintillaWidget.h (GTK+ specific) visible. A platform may also decide
to create their own headers based on Scintilla.iface to meet their
internal rules.

The object used to interact with a Scintilla instance should be the
appropriate platform type to allow composition with other widgets and
manipulation with the platform API. On Windows, Scintilla is exposed
as a HWND which is the system type of all windows. On GTK+,
ScintillaObject is a subclass (using GTK+'s implementation of object
orientation in C) of GtkWidget.

Neil

Aurelien R.

unread,
Oct 2, 2009, 8:29:09 PM10/2/09
to scintilla-interest
Thank you for your answers.

As i don't need all of the features for my editor, and also to better
understand the scintilla API, i am trying to make work a very simple
editor, a sort of "Hello world" example, printed in my scintilla
editor implementation.
What are the minimum Scintilla API calls needed to do that?

Neil Hodgson

unread,
Oct 5, 2009, 8:03:06 AM10/5/09
to scintilla...@googlegroups.com
Aurelien R.:

The first thing to do is to type into your implementation. There
is a bunch of platform specific set up needed to create an instance
and show it on the screen before any Scintilla API should be called.
For an example on GTK+, have a look at Bait
http://www.scintilla.org/bait.zip

Neil

Aurelien R.

unread,
Oct 5, 2009, 5:39:27 PM10/5/09
to scintilla-interest
Ok, I see. But the main problem is sometimes to understand how to
implement some methods of the platform classes, as they are not
documented.
For example what am i supposed to do with the parameters of those
methods:

1: virtual void Surface::Init(WindowID wid)=0;
2: virtual void Surface::Init(SurfaceID sid, WindowID wid)=0;
3: virtual void Surface::InitPixMap(int width, int height, Surface
*surface_, WindowID wid)=0;

What i understand is :

1 : After calling Init(wid) from somewhere, the Surface must represent
the drawing surface of the given Window?
2 : ??? Even if from what i understood this will only beused when
printing, i don't understant what to fo what wid and sid.
3 : ???

Neil Hodgson

unread,
Oct 5, 2009, 8:03:00 PM10/5/09
to scintilla...@googlegroups.com
Aurelien:

> 1 : After calling Init(wid) from somewhere, the Surface must represent
> the drawing surface of the given Window?

The surface is compatible with the window rather than for drawing
directly on the window. This is required by some platforms as drawing
has to use resources connected to the window or the screen the window
is on. For GTK+, the important resource is font access with different
font backends chosen in different circumstances. On WIndows, the
window ID is ignored as it is for the other 2 initialisers.

> 2 : ??? Even if from what i understood this will only beused when
> printing, i don't understant what to fo what wid and sid.

The surface ID is copied and will be drawn into. Other graphics
resources such as pens and brushes are created and managed by this
Surface. The window ID is used as in 1.

> 3 : ???

InitPixMap creates a new image object to draw into. It is
compatible with the surface ID and window ID.

Neil

Aurelien R.

unread,
Oct 6, 2009, 10:32:12 AM10/6/09
to scintilla-interest
OK, thanks a lot!!

I managed to print the rectangle of my editor, and the chars i type
are also printed into the editor.

Now I have other problems that i think are not Scintilla related, like
the slowlyness of the painting and the fact that sending SCK_RETURN
doesn't jump a line.
But i am on the right way ;-) !!

Aurélien R.
Reply all
Reply to author
Forward
0 new messages