Op 29-10-2011 10:31, PhilipPirrip schreef:
As an exercise in programming I'd like to implement "foreign language inset" I proposed at http://www.lyx.org/trac/ticket/7848. I suppose there are at least two of us at this mailing list that would like to contribute, but have difficulties in understanding all the layers of the code, actions taken between them, etc. The existing code not thoroughly commented, if at all, and it's sometimes hard to guess what some methods are for. Is there anyone here willing to write a short summary, or an introduction to programming LyX? Someone who has recently been a beginner himself? You may say that LyX is too complex for a novice like me, but LyX is on the other hand the piece of software I enjoy using, and the (only one) I'd like to contribute to.

For a start, how about choosing the inset that is closest to the one I need (note, comment, greyed-out?), and making comments to the code that is relevant for it? Please. I understand that "foreign language inset" will eventually be much more complex. I'd appreciate some idea of a programming workflow, as you see it, as well.

Regards,
PP


Hi Philip,

First of all, be sure that people think that a "foreign language inset" is useful. Otherwise, it might be a waste of your time implementing something that may not be used.

Second, there have been multiple attempts or ideas to write some documentation on programming for LyX, but it never got anywhere. There is at least the "CodingRulesAndAdvice.lyx" in "development/coding". I once tried to keep it up-to-date, but it still is a bit outdated, so don't take it too literally for the moment. Also, I wanted to collect some notes on the code structure there.

I think that especially the Inset classes are documented quite well (in comparison to other parts). If in a header a function is not documented, this is either because the name of the function is self-explanatory, or the function is inherited from another class and it is documented there. So, your main source of information for insets is the Inset.h file.

The Inset structure is roughly as follows:

- Inset
  * InsetCommand
  * InsetText
     # InsetCollapsable

Your inset needs to:
- extend from InsetText,
- have a settings dialog to specify the language,
so it might look like the InfoInset, or InsetNote.

I would just copy-paste one of these insets and get rid of the unwanted stuff and implement the output functions: latex, docbook, xhtml, plaintext.

Vincent



Reply via email to