Re: introduction to programming LyX, anyone?

2011-11-03 Thread PhilipPirrip

On 11/01/2011 02:56 PM, Vincent van Ravesteijn wrote:


So, did you find something to implement ?


Nothing that would be simple enough for me. It will take a year, I 
guess, until I understand how to deal with a project of this size (given 
that I come to it only from time to time)


Yet, I'd really like to have a better solution for selecting languages, 
esp. in larger portions of text, that span over multiple paragraphs, 
sections, chapters, etc.

And I like the idea given here, of making Flex insets more... flexible?
Cheers!



Re: introduction to programming LyX, anyone?

2011-11-03 Thread PhilipPirrip

On 11/01/2011 02:56 PM, Vincent van Ravesteijn wrote:


So, did you find something to implement ?


Nothing that would be simple enough for me. It will take a year, I 
guess, until I understand how to deal with a project of this size (given 
that I come to it only from time to time)


Yet, I'd really like to have a better solution for selecting languages, 
esp. in larger portions of text, that span over multiple paragraphs, 
sections, chapters, etc.

And I like the idea given here, of making Flex insets more... flexible?
Cheers!



Re: introduction to programming LyX, anyone?

2011-11-01 Thread Vincent van Ravesteijn

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



So, did you find something to implement ?

Vincent


Re: introduction to programming LyX, anyone?

2011-11-01 Thread Vincent van Ravesteijn

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



So, did you find something to implement ?

Vincent


Re: introduction to programming LyX, anyone?

2011-10-30 Thread Abdelrazak Younes

On 30/10/2011 04:18, Xu Wang wrote:
I agree with you Philip! I have been wanting to write a similar email 
for a while. I would love to help develop LyX. In fact, I learned C++ 
with that being my primary purpose. But I am still lost when trying to 
navigate the code.


I would love for some of the experienced developers to maybe document 
all of the steps in particular bug fixes... For example,


1. I knew I had to look in xxx.cpp because... (e.g. I did a grep using 
the phrase yyy)

2. Then I went to the line containing the word xxx
3. Because xxx is of class yyy, I went to yyy.h
4. etc.

Even though every bug is so special, I think that we could learn a lot 
by following such documentation.


Hey, each bug is different :-)
But what you describe here is a typical workflow  for _any_ C++ source 
code, not LyX specific.


Anyway, whenever you understand a piece of code please propose 
documentation patches.


And you don't understand something, just ask questions on the list.

Cheers,
Abdel.



Re: introduction to programming LyX, anyone?

2011-10-30 Thread Abdelrazak Younes

On 30/10/2011 02:59, PhilipPirrip wrote:
Hi Vincent. Thanks for the reply. One day I hope there would emerge a 
sort of an overview of the whole code, to help the new beginners.
I'm sure that making inset by coping some other shouldn't be that 
hard. But then it comes to all sorts of things that are interconnected 
(translations, input encodings, spell-checking), and it gets harder to 
understand them all. For example, what would need to be changed if I 
just introduce \begin{otherlanguage}{xyz} \end{otherlanguage} as the 
environment of the inset?


Probably no source code change is required for that simple change. Have 
a look at InsetFlex.


This pair is not present now in LyX (but there's a similar polyglossia 
pair, yes). What if I want to disable foreign language underlining for 
that inset?


Two ways:

1) The quick and simple way, check for the containing inset type when 
the language underlining is done (in rowpainter.cpp IIRC).
2) Provide some kind of general Inset option for that (via a virtual 
method in Inset.h)


How to tell the spell checker that the inset is using some other 
language?


LyX is already checking the language before spell-checking.

Abdel.



Re: introduction to programming LyX, anyone?

2011-10-30 Thread PhilipPirrip

On 10/30/2011 07:39 AM, Abdelrazak Younes wrote:

For example, what would need to be changed if I
just introduce \begin{otherlanguage}{xyz} \end{otherlanguage} as the
environment of the inset?


Probably no source code change is required for that simple change. Have
a look at InsetFlex.


Think I don't need to reply to this as I see that you've just read my 
answer to Richard @ #7848 (InsetFlex would be a workaround, not the 
proper solution, IMO).





How to tell the spell checker that the inset is using some other
language?


LyX is already checking the language before spell-checking.


Yes, of course. I always mix what's shown in View Source with what's 
the inner doc format of LyX.






Re: introduction to programming LyX, anyone?

2011-10-30 Thread Vincent van Ravesteijn

Op 30-10-2011 2:59, PhilipPirrip schreef:
Hi Vincent. Thanks for the reply. One day I hope there would emerge a 
sort of an overview of the whole code, to help the new beginners.
I'm sure that making inset by coping some other shouldn't be that 
hard. But then it comes to all sorts of things that are interconnected 
(translations, input encodings, spell-checking), and it gets harder to 
understand them all. For example, what would need to be changed if I 
just introduce \begin{otherlanguage}{xyz} \end{otherlanguage} as the 
environment of the inset? This pair is not present now in LyX (but 
there's a similar polyglossia pair, yes). 
If you would create a new Inset class, then this environment will be 
outputed by


InsetForeignLanguage::latex(..) {
\\ begin environment
InsetText::latex(..)
\\ end environment
}

but if you look in InsetText::latex(..) you see that it uses InsetLayout 
to generalise things in the way you need:


InsetLayout il = geLayout();
if (il.latextype() == InsetLayout::ENVIRONMENT)  {
..
os  \\begin{  from_utf8(il.latexname())  }\n;
if (!il.latexparam().empty())
os  from_utf8(il.latexparam());

..
latexParagraphs(buffer(), text_, os, rp);
..
os  \\end{ ..
}

So if you define a layout il you have to specify:

il.latextype_ = ENVIRONMENT,
il.latexname_ = otherlanguage,
il.latexparam_ = {xyz}


What if I want to disable foreign language underlining for that inset? 


Grep for paintForeignMark:


void RowPainter::paintForeignMark(double orig_x, Language const * lang,
int desc)
{
if (!lyxrc.mark_foreign_language)
return;
if (lang == latex_language)
return;
if (lang == pi_.base.bv-buffer().params().language)
return;

int const y = yo_ + solid_line_offset_ + desc + 
int(solid_line_thickness_/2);

pi_.pain.line(int(orig_x), y, int(x_), y, Color_language,
Painter::line_solid, solid_line_thickness_);
}



First, you can see that we have a general preference to disable this 
underligning: lyxrc.mark_foreign_language. This is an option in 
Preferences-Language Settings-Language. So, if you switch this off, 
your initial problem that this underlining is annoying if you use 
foreign languages a lot is solved.


Second, you see the conditions that govern the underlining. Instead of 
comparing with the language of the Buffer, we might want to compare with 
the inset's default language. This will immediately generalise for the 
case of latex_language as this will be defined as the default language 
in InsetERT.


I think that introducing the Inset's default language is the way to go. 
This is also better than disabling the foreign language marks  in the 
Foreign language inset because this will allow you to use the original 
language again in the Foreign language inset and then it will be 
underlined to indicate this.


This would be a nice exercise anyway, because it's way less complex than 
introducing a new Inset.


How to tell the spell checker that the inset is using some other 
language?

...



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.


I've just tried to convince Richard on that, please take a look at 
http://www.lyx.org/trac/ticket/7848.


We are trying to generalise the Insets a bit, so that we don't need a 
special class of Insets for all latex commands there are out there. So, 
like Abdel said, if this can be done via an InsetFlex it would be 
preferable. But if you want a nice dialog to be able to select the 
language, or you want to customise a lot of other properties of the 
Inset, you will find that not all of that is supported yet.


Vincent


Re: introduction to programming LyX, anyone?

2011-10-30 Thread PhilipPirrip

On 10/30/2011 08:32 AM, Vincent van Ravesteijn wrote:

We are trying to generalise the Insets a bit, so that we don't need a
special class of Insets for all latex commands there are out there. So,
like Abdel said, if this can be done via an InsetFlex it would be
preferable. But if you want a nice dialog to be able to select the
language, or you want to customise a lot of other properties of the
Inset, you will find that not all of that is supported yet.



A way to go would be allowing Flex insets to call some of the dialogs, I 
can imagine a few examples:
- I made an autoref flex inset, say in a module, but I still need to 
manually add the reference label as its contents. If I were allowed to 
call the dialog for choosing cross-references from the inset properties 
I'd profit a lot.
- I want to change the language of a flex inset. If I were allowed to do 
that by calling a dialog (some advanced, that Abdel just proposed), I 
would not have to hard-code the new inset.

- similar flexibility with text styles, bibliographic references, etc.


How hard would it be for the .layout infrastructure to support this?



Re: introduction to programming LyX, anyone?

2011-10-30 Thread Vincent van Ravesteijn

Op 30-10-2011 8:53, PhilipPirrip schreef:

On 10/30/2011 08:32 AM, Vincent van Ravesteijn wrote:

We are trying to generalise the Insets a bit, so that we don't need a
special class of Insets for all latex commands there are out there. So,
like Abdel said, if this can be done via an InsetFlex it would be
preferable. But if you want a nice dialog to be able to select the
language, or you want to customise a lot of other properties of the
Inset, you will find that not all of that is supported yet.



A way to go would be allowing Flex insets to call some of the dialogs, 
I can imagine a few examples:
- I made an autoref flex inset, say in a module, but I still need to 
manually add the reference label as its contents. If I were allowed to 
call the dialog for choosing cross-references from the inset 
properties I'd profit a lot.
- I want to change the language of a flex inset. If I were allowed to 
do that by calling a dialog (some advanced, that Abdel just proposed), 
I would not have to hard-code the new inset.

- similar flexibility with text styles, bibliographic references, etc.



This makes me to think to introduce a property editor that a lot of 
applications have. If you put the cursor in your Foreign Language Inset 
in a Branch, the property editor will look like this:


[Branch]
Name: my-branch-name  [..]
[Foreign Language Inset]
Language: language[..]

- you have a clear overview of all settings influencing the cursor location
- you may have a drop-down list showing all languages, or when you press 
the 'Browse [..]' button this will take you to the Language selection 
dialog.

- pressing the branch browse button will take you to the branch dialog




How hard would it be for the .layout infrastructure to support this?



You will need to have InsetLayout process LFUN_INSET_SETTINGS and call 
the dialog. I'm not sure what problems you will encounter though.


Besides, I think this might be too limited. It might not be that often 
the case that you have a new Inset that calls an already existing dialog.


Vincent


Re: introduction to programming LyX, anyone?

2011-10-30 Thread PhilipPirrip

On 10/30/2011 09:16 AM, Vincent van Ravesteijn wrote:


This makes me to think to introduce a property editor that a lot of
applications have.


If I understood correctly, this would be great, and would also enhance 
many existing insets.
My idea about this is that you want the *.layout file* to contain which 
properties should an inset offer to the user, or provide some hidden to 
the user: from additional/optional parameters to its LaTeX command, 
commands executed at its beginning and end, insets within the inset 
(like in float/caption case), even buttons to fill in data with what LyX 
can provide: labels used, cross-references, bibliography references, etc.

There are tons of LaTeX packages that are just waiting for such a thing.





Besides, I think this might be too limited. It might not be that often
the case that you have a new Inset that calls an already existing dialog.


I was mostly thinking on those where LyX can provide its data: labels, 
cross-refs...







Re: introduction to programming LyX, anyone?

2011-10-30 Thread Richard Heck
On 10/30/2011 03:32 AM, Vincent van Ravesteijn wrote:
 Op 30-10-2011 2:59, PhilipPirrip schreef:

 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.

 I've just tried to convince Richard on that, please take a look at
 http://www.lyx.org/trac/ticket/7848.

 We are trying to generalise the Insets a bit, so that we don't need a
 special class of Insets for all latex commands there are out there.
 So, like Abdel said, if this can be done via an InsetFlex it would be
 preferable. But if you want a nice dialog to be able to select the
 language, or you want to customise a lot of other properties of the
 Inset, you will find that not all of that is supported yet.

Allowing this kind of dialog for custom insets is a long dream of mine.

Richard



Re: introduction to programming LyX, anyone?

2011-10-30 Thread Liviu Andronic
2011/10/30 Richard Heck rgh...@comcast.net:
 On 10/30/2011 03:32 AM, Vincent van Ravesteijn wrote:
 Op 30-10-2011 2:59, PhilipPirrip schreef:

 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.

 I've just tried to convince Richard on that, please take a look at
 http://www.lyx.org/trac/ticket/7848.

 We are trying to generalise the Insets a bit, so that we don't need a
 special class of Insets for all latex commands there are out there.
 So, like Abdel said, if this can be done via an InsetFlex it would be
 preferable. But if you want a nice dialog to be able to select the
 language, or you want to customise a lot of other properties of the
 Inset, you will find that not all of that is supported yet.

 Allowing this kind of dialog for custom insets is a long dream of mine.

I guess you're referring to #6753 [1]. This would improve the LyX
experience in many other areas (beamer, sweave, etc.), and I much hope
that 2.1 would boast this feature.

Regards
Liviu

[1] http://www.lyx.org/trac/ticket/6753


Re: introduction to programming LyX, anyone?

2011-10-30 Thread Richard Heck
On 10/30/2011 04:48 PM, Liviu Andronic wrote:
 2011/10/30 Richard Heck rgh...@comcast.net:
 On 10/30/2011 03:32 AM, Vincent van Ravesteijn wrote:
 Op 30-10-2011 2:59, PhilipPirrip schreef:
 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.
 I've just tried to convince Richard on that, please take a look at
 http://www.lyx.org/trac/ticket/7848.
 We are trying to generalise the Insets a bit, so that we don't need a
 special class of Insets for all latex commands there are out there.
 So, like Abdel said, if this can be done via an InsetFlex it would be
 preferable. But if you want a nice dialog to be able to select the
 language, or you want to customise a lot of other properties of the
 Inset, you will find that not all of that is supported yet.

 Allowing this kind of dialog for custom insets is a long dream of mine.

 I guess you're referring to #6753 [1]. This would improve the LyX
 experience in many other areas (beamer, sweave, etc.), and I much hope
 that 2.1 would boast this feature.

Partly. But #4066 points even more in that direction.

Richard



Re: introduction to programming LyX, anyone?

2011-10-30 Thread Abdelrazak Younes

On 30/10/2011 04:18, Xu Wang wrote:
I agree with you Philip! I have been wanting to write a similar email 
for a while. I would love to help develop LyX. In fact, I learned C++ 
with that being my primary purpose. But I am still lost when trying to 
navigate the code.


I would love for some of the experienced developers to maybe document 
all of the steps in particular bug fixes... For example,


1. I knew I had to look in xxx.cpp because... (e.g. I did a grep using 
the phrase "yyy")

2. Then I went to the line containing the word xxx
3. Because xxx is of class yyy, I went to yyy.h
4. etc.

Even though every bug is so special, I think that we could learn a lot 
by following such documentation.


Hey, each bug is different :-)
But what you describe here is a typical workflow  for _any_ C++ source 
code, not LyX specific.


Anyway, whenever you understand a piece of code please propose 
documentation patches.


And you don't understand something, just ask questions on the list.

Cheers,
Abdel.



Re: introduction to programming LyX, anyone?

2011-10-30 Thread Abdelrazak Younes

On 30/10/2011 02:59, PhilipPirrip wrote:
Hi Vincent. Thanks for the reply. One day I hope there would emerge a 
sort of an overview of the whole code, to help the new beginners.
I'm sure that making inset by coping some other shouldn't be that 
hard. But then it comes to all sorts of things that are interconnected 
(translations, input encodings, spell-checking), and it gets harder to 
understand them all. For example, what would need to be changed if I 
just introduce \begin{otherlanguage}{xyz} \end{otherlanguage} as the 
environment of the inset?


Probably no source code change is required for that simple change. Have 
a look at InsetFlex.


This pair is not present now in LyX (but there's a similar polyglossia 
pair, yes). What if I want to disable foreign language underlining for 
that inset?


Two ways:

1) The quick and simple way, check for the containing inset type when 
the language underlining is done (in rowpainter.cpp IIRC).
2) Provide some kind of general Inset option for that (via a virtual 
method in Inset.h)


How to tell the spell checker that the inset is using some other 
language?


LyX is already checking the language before spell-checking.

Abdel.



Re: introduction to programming LyX, anyone?

2011-10-30 Thread PhilipPirrip

On 10/30/2011 07:39 AM, Abdelrazak Younes wrote:

For example, what would need to be changed if I
just introduce \begin{otherlanguage}{xyz} \end{otherlanguage} as the
environment of the inset?


Probably no source code change is required for that simple change. Have
a look at InsetFlex.


Think I don't need to reply to this as I see that you've just read my 
answer to Richard @ #7848 (InsetFlex would be a workaround, not the 
proper solution, IMO).





How to tell the spell checker that the inset is using some other
language?


LyX is already checking the language before spell-checking.


Yes, of course. I always mix what's shown in "View Source" with what's 
the inner doc format of LyX.






Re: introduction to programming LyX, anyone?

2011-10-30 Thread Vincent van Ravesteijn

Op 30-10-2011 2:59, PhilipPirrip schreef:
Hi Vincent. Thanks for the reply. One day I hope there would emerge a 
sort of an overview of the whole code, to help the new beginners.
I'm sure that making inset by coping some other shouldn't be that 
hard. But then it comes to all sorts of things that are interconnected 
(translations, input encodings, spell-checking), and it gets harder to 
understand them all. For example, what would need to be changed if I 
just introduce \begin{otherlanguage}{xyz} \end{otherlanguage} as the 
environment of the inset? This pair is not present now in LyX (but 
there's a similar polyglossia pair, yes). 
If you would create a new Inset class, then this environment will be 
outputed by


InsetForeignLanguage::latex(..) {
\\ begin environment
InsetText::latex(..)
\\ end environment
}

but if you look in InsetText::latex(..) you see that it uses InsetLayout 
to generalise things in the way you need:


InsetLayout il = geLayout();
if (il.latextype() == InsetLayout::ENVIRONMENT)  {
..
os << "\\begin{" << from_utf8(il.latexname()) << "}\n";
if (!il.latexparam().empty())
os << from_utf8(il.latexparam());

..
latexParagraphs(buffer(), text_, os, rp);
..
os << "\\end{" ..
}

So if you define a layout il you have to specify:

il.latextype_ = ENVIRONMENT,
il.latexname_ = "otherlanguage",
il.latexparam_ = "{xyz}"


What if I want to disable foreign language underlining for that inset? 


Grep for "paintForeignMark":


void RowPainter::paintForeignMark(double orig_x, Language const * lang,
int desc)
{
if (!lyxrc.mark_foreign_language)
return;
if (lang == latex_language)
return;
if (lang == pi_.base.bv->buffer().params().language)
return;

int const y = yo_ + solid_line_offset_ + desc + 
int(solid_line_thickness_/2);

pi_.pain.line(int(orig_x), y, int(x_), y, Color_language,
Painter::line_solid, solid_line_thickness_);
}



First, you can see that we have a general preference to disable this 
underligning: lyxrc.mark_foreign_language. This is an option in 
Preferences->Language Settings->Language. So, if you switch this off, 
your initial problem that this underlining is annoying if you use 
foreign languages a lot is solved.


Second, you see the conditions that govern the underlining. Instead of 
comparing with the language of the Buffer, we might want to compare with 
the inset's default language. This will immediately generalise for the 
case of "latex_language" as this will be defined as the default language 
in InsetERT.


I think that introducing the Inset's default language is the way to go. 
This is also better than "disabling" the foreign language marks  in the 
"Foreign language inset" because this will allow you to use the original 
language again in the Foreign language inset and then it will be 
underlined to indicate this.


This would be a nice exercise anyway, because it's way less complex than 
introducing a new Inset.


How to tell the spell checker that the inset is using some other 
language?

...



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.


I've just tried to convince Richard on that, please take a look at 
http://www.lyx.org/trac/ticket/7848.


We are trying to generalise the Insets a bit, so that we don't need a 
special class of Insets for all latex commands there are out there. So, 
like Abdel said, if this can be done via an InsetFlex it would be 
preferable. But if you want a nice dialog to be able to select the 
language, or you want to customise a lot of other properties of the 
Inset, you will find that not all of that is supported yet.


Vincent


Re: introduction to programming LyX, anyone?

2011-10-30 Thread PhilipPirrip

On 10/30/2011 08:32 AM, Vincent van Ravesteijn wrote:

We are trying to generalise the Insets a bit, so that we don't need a
special class of Insets for all latex commands there are out there. So,
like Abdel said, if this can be done via an InsetFlex it would be
preferable. But if you want a nice dialog to be able to select the
language, or you want to customise a lot of other properties of the
Inset, you will find that not all of that is supported yet.



A way to go would be allowing Flex insets to call some of the dialogs, I 
can imagine a few examples:
- I made an autoref flex inset, say in a module, but I still need to 
manually add the reference label as its contents. If I were allowed to 
call the dialog for choosing cross-references from the inset properties 
I'd profit a lot.
- I want to change the language of a flex inset. If I were allowed to do 
that by calling a dialog (some advanced, that Abdel just proposed), I 
would not have to hard-code the new inset.

- similar flexibility with text styles, bibliographic references, etc.


How hard would it be for the .layout infrastructure to support this?



Re: introduction to programming LyX, anyone?

2011-10-30 Thread Vincent van Ravesteijn

Op 30-10-2011 8:53, PhilipPirrip schreef:

On 10/30/2011 08:32 AM, Vincent van Ravesteijn wrote:

We are trying to generalise the Insets a bit, so that we don't need a
special class of Insets for all latex commands there are out there. So,
like Abdel said, if this can be done via an InsetFlex it would be
preferable. But if you want a nice dialog to be able to select the
language, or you want to customise a lot of other properties of the
Inset, you will find that not all of that is supported yet.



A way to go would be allowing Flex insets to call some of the dialogs, 
I can imagine a few examples:
- I made an autoref flex inset, say in a module, but I still need to 
manually add the reference label as its contents. If I were allowed to 
call the dialog for choosing cross-references from the inset 
properties I'd profit a lot.
- I want to change the language of a flex inset. If I were allowed to 
do that by calling a dialog (some advanced, that Abdel just proposed), 
I would not have to hard-code the new inset.

- similar flexibility with text styles, bibliographic references, etc.



This makes me to think to introduce a "property editor" that a lot of 
applications have. If you put the cursor in your Foreign Language Inset 
in a Branch, the property editor will look like this:


[Branch]
Name:   [..]
[Foreign Language Inset]
Language: [..]

- you have a clear overview of all settings influencing the cursor location
- you may have a drop-down list showing all languages, or when you press 
the 'Browse [..]' button this will take you to the Language selection 
dialog.

- pressing the branch browse button will take you to the branch dialog




How hard would it be for the .layout infrastructure to support this?



You will need to have InsetLayout process LFUN_INSET_SETTINGS and call 
the dialog. I'm not sure what problems you will encounter though.


Besides, I think this might be too limited. It might not be that often 
the case that you have a new Inset that calls an already existing dialog.


Vincent


Re: introduction to programming LyX, anyone?

2011-10-30 Thread PhilipPirrip

On 10/30/2011 09:16 AM, Vincent van Ravesteijn wrote:


This makes me to think to introduce a "property editor" that a lot of
applications have.


If I understood correctly, this would be great, and would also enhance 
many existing insets.
My idea about this is that you want the *.layout file* to contain which 
properties should an inset offer to the user, or provide some hidden to 
the user: from additional/optional parameters to its LaTeX command, 
commands executed at its beginning and end, insets within the inset 
(like in float/caption case), even buttons to fill in data with what LyX 
can provide: labels used, cross-references, bibliography references, etc.

There are tons of LaTeX packages that are just waiting for such a thing.





Besides, I think this might be too limited. It might not be that often
the case that you have a new Inset that calls an already existing dialog.


I was mostly thinking on those where LyX can provide its data: labels, 
cross-refs...







Re: introduction to programming LyX, anyone?

2011-10-30 Thread Richard Heck
On 10/30/2011 03:32 AM, Vincent van Ravesteijn wrote:
> Op 30-10-2011 2:59, PhilipPirrip schreef:
>>
>>> 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.
>>
>> I've just tried to convince Richard on that, please take a look at
>> http://www.lyx.org/trac/ticket/7848.
>
> We are trying to generalise the Insets a bit, so that we don't need a
> special class of Insets for all latex commands there are out there.
> So, like Abdel said, if this can be done via an InsetFlex it would be
> preferable. But if you want a nice dialog to be able to select the
> language, or you want to customise a lot of other properties of the
> Inset, you will find that not all of that is supported yet.
>
Allowing this kind of dialog for custom insets is a long dream of mine.

Richard



Re: introduction to programming LyX, anyone?

2011-10-30 Thread Liviu Andronic
2011/10/30 Richard Heck :
> On 10/30/2011 03:32 AM, Vincent van Ravesteijn wrote:
>> Op 30-10-2011 2:59, PhilipPirrip schreef:
>>>
 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.
>>>
>>> I've just tried to convince Richard on that, please take a look at
>>> http://www.lyx.org/trac/ticket/7848.
>>
>> We are trying to generalise the Insets a bit, so that we don't need a
>> special class of Insets for all latex commands there are out there.
>> So, like Abdel said, if this can be done via an InsetFlex it would be
>> preferable. But if you want a nice dialog to be able to select the
>> language, or you want to customise a lot of other properties of the
>> Inset, you will find that not all of that is supported yet.
>>
> Allowing this kind of dialog for custom insets is a long dream of mine.
>
I guess you're referring to #6753 [1]. This would improve the LyX
experience in many other areas (beamer, sweave, etc.), and I much hope
that 2.1 would boast this feature.

Regards
Liviu

[1] http://www.lyx.org/trac/ticket/6753


Re: introduction to programming LyX, anyone?

2011-10-30 Thread Richard Heck
On 10/30/2011 04:48 PM, Liviu Andronic wrote:
> 2011/10/30 Richard Heck :
>> On 10/30/2011 03:32 AM, Vincent van Ravesteijn wrote:
>>> Op 30-10-2011 2:59, PhilipPirrip schreef:
> 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.
 I've just tried to convince Richard on that, please take a look at
 http://www.lyx.org/trac/ticket/7848.
>>> We are trying to generalise the Insets a bit, so that we don't need a
>>> special class of Insets for all latex commands there are out there.
>>> So, like Abdel said, if this can be done via an InsetFlex it would be
>>> preferable. But if you want a nice dialog to be able to select the
>>> language, or you want to customise a lot of other properties of the
>>> Inset, you will find that not all of that is supported yet.
>>>
>> Allowing this kind of dialog for custom insets is a long dream of mine.
>>
> I guess you're referring to #6753 [1]. This would improve the LyX
> experience in many other areas (beamer, sweave, etc.), and I much hope
> that 2.1 would boast this feature.
>
Partly. But #4066 points even more in that direction.

Richard



introduction to programming LyX, anyone?

2011-10-29 Thread PhilipPirrip
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



Re: introduction to programming LyX, anyone?

2011-10-29 Thread Vincent van Ravesteijn

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





Re: introduction to programming LyX, anyone?

2011-10-29 Thread PhilipPirrip
Hi Vincent. Thanks for the reply. One day I hope there would emerge a 
sort of an overview of the whole code, to help the new beginners.
I'm sure that making inset by coping some other shouldn't be that hard. 
But then it comes to all sorts of things that are interconnected 
(translations, input encodings, spell-checking), and it gets harder to 
understand them all. For example, what would need to be changed if I 
just introduce \begin{otherlanguage}{xyz} \end{otherlanguage} as the 
environment of the inset? This pair is not present now in LyX (but 
there's a similar polyglossia pair, yes). What if I want to disable 
foreign language underlining for that inset? How to tell the spell 
checker that the inset is using some other language?

...



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.


I've just tried to convince Richard on that, please take a look at 
http://www.lyx.org/trac/ticket/7848.






Re: introduction to programming LyX, anyone?

2011-10-29 Thread Xu Wang
I agree with you Philip! I have been wanting to write a similar email for a
while. I would love to help develop LyX. In fact, I learned C++ with that
being my primary purpose. But I am still lost when trying to navigate the
code.

I would love for some of the experienced developers to maybe document all
of the steps in particular bug fixes... For example,

1. I knew I had to look in xxx.cpp because... (e.g. I did a grep using the
phrase yyy)
2. Then I went to the line containing the word xxx
3. Because xxx is of class yyy, I went to yyy.h
4. etc.

Even though every bug is so special, I think that we could learn a lot by
following such documentation.

Thank you!

Xu


2011/10/29 PhilipPirrip p...@net.hr

 Hi Vincent. Thanks for the reply. One day I hope there would emerge a sort
 of an overview of the whole code, to help the new beginners.
 I'm sure that making inset by coping some other shouldn't be that hard.
 But then it comes to all sorts of things that are interconnected
 (translations, input encodings, spell-checking), and it gets harder to
 understand them all. For example, what would need to be changed if I just
 introduce \begin{otherlanguage}{xyz} \end{otherlanguage} as the environment
 of the inset? This pair is not present now in LyX (but there's a similar
 polyglossia pair, yes). What if I want to disable foreign language
 underlining for that inset? How to tell the spell checker that the inset is
 using some other language?
 ...



  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.


 I've just tried to convince Richard on that, please take a look at
 http://www.lyx.org/trac/**ticket/7848http://www.lyx.org/trac/ticket/7848
 .






introduction to programming LyX, anyone?

2011-10-29 Thread PhilipPirrip
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



Re: introduction to programming LyX, anyone?

2011-10-29 Thread Vincent van Ravesteijn

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





Re: introduction to programming LyX, anyone?

2011-10-29 Thread PhilipPirrip
Hi Vincent. Thanks for the reply. One day I hope there would emerge a 
sort of an overview of the whole code, to help the new beginners.
I'm sure that making inset by coping some other shouldn't be that hard. 
But then it comes to all sorts of things that are interconnected 
(translations, input encodings, spell-checking), and it gets harder to 
understand them all. For example, what would need to be changed if I 
just introduce \begin{otherlanguage}{xyz} \end{otherlanguage} as the 
environment of the inset? This pair is not present now in LyX (but 
there's a similar polyglossia pair, yes). What if I want to disable 
foreign language underlining for that inset? How to tell the spell 
checker that the inset is using some other language?

...



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.


I've just tried to convince Richard on that, please take a look at 
http://www.lyx.org/trac/ticket/7848.






Re: introduction to programming LyX, anyone?

2011-10-29 Thread Xu Wang
I agree with you Philip! I have been wanting to write a similar email for a
while. I would love to help develop LyX. In fact, I learned C++ with that
being my primary purpose. But I am still lost when trying to navigate the
code.

I would love for some of the experienced developers to maybe document all
of the steps in particular bug fixes... For example,

1. I knew I had to look in xxx.cpp because... (e.g. I did a grep using the
phrase "yyy")
2. Then I went to the line containing the word xxx
3. Because xxx is of class yyy, I went to yyy.h
4. etc.

Even though every bug is so special, I think that we could learn a lot by
following such documentation.

Thank you!

Xu


2011/10/29 PhilipPirrip 

> Hi Vincent. Thanks for the reply. One day I hope there would emerge a sort
> of an overview of the whole code, to help the new beginners.
> I'm sure that making inset by coping some other shouldn't be that hard.
> But then it comes to all sorts of things that are interconnected
> (translations, input encodings, spell-checking), and it gets harder to
> understand them all. For example, what would need to be changed if I just
> introduce \begin{otherlanguage}{xyz} \end{otherlanguage} as the environment
> of the inset? This pair is not present now in LyX (but there's a similar
> polyglossia pair, yes). What if I want to disable foreign language
> underlining for that inset? How to tell the spell checker that the inset is
> using some other language?
> ...
>
>
>
>  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.
>>
>
> I've just tried to convince Richard on that, please take a look at
> http://www.lyx.org/trac/**ticket/7848
> .
>
>
>
>