Re: Contribution to systematically advance through environments

2012-04-02 Thread Pavel Sanda
John Carbone wrote:
> I wished for a way to just have "Requirement" in the Environment choice
> box and be able to cycle through the levels much like one can do with
> the sections, with the tab key. Since this feature didn't exist, I
> decided to implement it in a manner generic that I hope will be useful
> to the project as a whole. 
 
Except for technical issues (I guess NextStyle needs increment of layout
format, conversion routines, documentation) I'm afraid there are more
problems WRT genericity of this solution.

First, "to cycle through the levels much like one can do with the sections"
-- we do more complex things (eg. sections->subsections involves subsections->
subsubsections transformation). The generic solution would perhaps 
use outline-in/out lfuns instead of creating new nextstyle lfun.

Second, the generic solution seems also involve the same handling for different
environments - at the end all our (sub(sub))sections should be implemented by
NextStyle. Now, shall we hide (sub)subsection in the default state, or do we
need yet anothe RC variable, etc...

This doesn't mean stop for your patch if othersl find it useful, just to give
you some feedback...
Pavel


Re: Contribution to systematically advance through environments

2012-03-31 Thread Tommaso Cucinotta

Hi John,

great to see a contribution to the project! The list is the right place 
where to discuss about features and their implementations (i.e., get 
feedback on a patch line by line). In the mean time, I'd suggest you to 
also copy'n'paste this message to a new enhancement request on the LyX 
trac, and attach the patch to the ticket. This way you get sure that, 
during the next release cycle, it will receive the needed attention, and 
it doesn't get forgotten.


My only comment to the code is this: does your patch keep the cycling 
through the "NextStyle" attribute separated (at the code level) from the 
cycling of section headings ? If yes, would there be a way to put the 2 
things together ? i.e., the default nextStyle() for a Section is a 
SubSection.
Second, the comment/documentation preceeding the new LFUN_LAYOUT_NEXT 
seems a rough copy of the LFUN_LAYOUT one in LyXAction.cpp. Probably you 
want to fix it.


Bye,

T.

Il 31/03/2012 22:12, John Carbone ha scritto:

Dear all,

I would like to thank all of the developers and contributors to the LyX
project that have made such a great piece of software. Also, I would
like to compliment the developers on the fine source code which made a
feature that I so desperately needed easy to implement. Which brings me
to my main point.

My Environment choice box started to grow to an unwieldy size as my
custom ".layouts" grew. Many of the styles were sub-levels. For example:
Requirement, Subrequirement, Subsubrequirement, and
Subsubsubrequirement. The same was true for other styles that I had made
like feature, supplement, and use case. As you can see, the environment
choice box was quickly growing.

I wished for a way to just have "Requirement" in the Environment choice
box and be able to cycle through the levels much like one can do with
the sections, with the tab key. Since this feature didn't exist, I
decided to implement it in a manner generic that I hope will be useful
to the project as a whole.

I have added a keyword within the "Style" section of a ".layout" file
called "NextStyle" that is implemented with an LyX function called
"layout-next" (action LFUN_LAYOUT_NEXT), and can be bound to a key of
your choosing. This enables the following in the .layout file:

  Style Requirement
...
NextStyle Subrequirement
...
End

Style Subrequirement
...
NextStyle Subsubrequirement
...
End

Style Subsubrequirement
...
NextStyle Subsubsubrequirement
...
End

Style Subsubsubrequirement
...
NextStyle Requirement
...
End

It is my sincere hope that the developers find this useful and decide to
implement it as part of the LyX project.

Kind regards,
John

I hereby grant permission to license my contributions to LyX under the
Gnu General Public Licence (version two or later):

diff -u -r lyx-2.0.3/src/frontends/qt4/GuiApplication.cpp
lyx-2.0.3-jwc/src/frontends/qt4/GuiApplication.cpp
--- lyx-2.0.3/src/frontends/qt4/GuiApplication.cpp  2011-12-04
11:16:32.0 -0500
+++ lyx-2.0.3-jwc/src/frontends/qt4/GuiApplication.cpp  2012-03-30
08:34:42.899226451 -0400
@@ -1031,6 +1031,7 @@
 case LFUN_RECONFIGURE:
 case LFUN_SERVER_GET_FILENAME:
 case LFUN_SERVER_NOTIFY:
+   case LFUN_LAYOUT_NEXT:
 enable = true;
 break;

diff -u -r lyx-2.0.3/src/FuncCode.h lyx-2.0.3-jwc/src/FuncCode.h
--- lyx-2.0.3/src/FuncCode.h2010-11-23 15:09:08.0 -0500
+++ lyx-2.0.3-jwc/src/FuncCode.h2012-03-29 16:31:21.577230704
-0400
@@ -173,6 +173,7 @@
 LFUN_MARK_OFF,
 LFUN_MARK_ON,
 LFUN_LAYOUT,
+   LFUN_LAYOUT_NEXT,
 // 120
 LFUN_LAYOUT_PARAGRAPH,
 LFUN_DROP_LAYOUTS_CHOICE,   // used in bindings as of
20071228
diff -u -r lyx-2.0.3/src/insets/InsetTabular.cpp
lyx-2.0.3-jwc/src/insets/InsetTabular.cpp
--- lyx-2.0.3/src/insets/InsetTabular.cpp   2012-01-27
16:44:30.0 -0500
+++ lyx-2.0.3-jwc/src/insets/InsetTabular.cpp   2012-03-29
19:50:13.123230530 -0400
@@ -3334,6 +3334,7 @@
 bool enabled = true;
 switch (cmd.action()) {
 case LFUN_LAYOUT:
+   case LFUN_LAYOUT_NEXT:
 enabled = !forcePlainLayout();
 break;
 case LFUN_LAYOUT_PARAGRAPH:
diff -u -r lyx-2.0.3/src/Layout.cpp lyx-2.0.3-jwc/src/Layout.cpp
--- lyx-2.0.3/src/Layout.cpp2012-01-14 10:06:40.0 -0500
+++ lyx-2.0.3-jwc/src/Layout.cpp2012-03-30 08:38:28.627232561
-0400
@@ -45,6 +45,7 @@
 LT_BOTTOMSEP,
 LT_CATEGORY,
 LT_COMMANDDEPTH,
+   LT_NEXTSTYLE,
 LT_COPYSTYLE,
 LT_DEPENDSON,
 LT_OBSOLETEDBY,
@@ -166,6 +167,7 @@
 { "category",   LT_CATEGORY },
 { "commanddepth",   LT_COMMANDDEPTH },
 { "copystyle",  LT_COPYSTYLE },
+   { "nextstyle",  LT_NEXTSTYLE },
 { "dependson",  LT_DEPEN

Contribution to systematically advance through environments

2012-03-31 Thread John Carbone
Dear all,

I would like to thank all of the developers and contributors to the LyX
project that have made such a great piece of software. Also, I would
like to compliment the developers on the fine source code which made a
feature that I so desperately needed easy to implement. Which brings me
to my main point.

My Environment choice box started to grow to an unwieldy size as my
custom ".layouts" grew. Many of the styles were sub-levels. For example:
Requirement, Subrequirement, Subsubrequirement, and
Subsubsubrequirement. The same was true for other styles that I had made
like feature, supplement, and use case. As you can see, the environment
choice box was quickly growing. 

I wished for a way to just have "Requirement" in the Environment choice
box and be able to cycle through the levels much like one can do with
the sections, with the tab key. Since this feature didn't exist, I
decided to implement it in a manner generic that I hope will be useful
to the project as a whole. 

I have added a keyword within the "Style" section of a ".layout" file
called "NextStyle" that is implemented with an LyX function called
"layout-next" (action LFUN_LAYOUT_NEXT), and can be bound to a key of
your choosing. This enables the following in the .layout file:

 Style Requirement
...
NextStyle Subrequirement 
...
End

Style Subrequirement
...
NextStyle Subsubrequirement 
...
End

Style Subsubrequirement
...
NextStyle Subsubsubrequirement 
...
End

Style Subsubsubrequirement
...
NextStyle Requirement 
...
End

It is my sincere hope that the developers find this useful and decide to
implement it as part of the LyX project. 

Kind regards,
John

I hereby grant permission to license my contributions to LyX under the
Gnu General Public Licence (version two or later):

diff -u -r lyx-2.0.3/src/frontends/qt4/GuiApplication.cpp
lyx-2.0.3-jwc/src/frontends/qt4/GuiApplication.cpp
--- lyx-2.0.3/src/frontends/qt4/GuiApplication.cpp  2011-12-04
11:16:32.0 -0500
+++ lyx-2.0.3-jwc/src/frontends/qt4/GuiApplication.cpp  2012-03-30
08:34:42.899226451 -0400
@@ -1031,6 +1031,7 @@
case LFUN_RECONFIGURE:
case LFUN_SERVER_GET_FILENAME:
case LFUN_SERVER_NOTIFY:
+   case LFUN_LAYOUT_NEXT:
enable = true;
break;

diff -u -r lyx-2.0.3/src/FuncCode.h lyx-2.0.3-jwc/src/FuncCode.h
--- lyx-2.0.3/src/FuncCode.h2010-11-23 15:09:08.0 -0500
+++ lyx-2.0.3-jwc/src/FuncCode.h2012-03-29 16:31:21.577230704
-0400
@@ -173,6 +173,7 @@
LFUN_MARK_OFF,
LFUN_MARK_ON,
LFUN_LAYOUT,
+   LFUN_LAYOUT_NEXT,
// 120
LFUN_LAYOUT_PARAGRAPH,
LFUN_DROP_LAYOUTS_CHOICE,   // used in bindings as of
20071228
diff -u -r lyx-2.0.3/src/insets/InsetTabular.cpp
lyx-2.0.3-jwc/src/insets/InsetTabular.cpp
--- lyx-2.0.3/src/insets/InsetTabular.cpp   2012-01-27
16:44:30.0 -0500
+++ lyx-2.0.3-jwc/src/insets/InsetTabular.cpp   2012-03-29
19:50:13.123230530 -0400
@@ -3334,6 +3334,7 @@
bool enabled = true;
switch (cmd.action()) {
case LFUN_LAYOUT:
+   case LFUN_LAYOUT_NEXT:
enabled = !forcePlainLayout();
break;
case LFUN_LAYOUT_PARAGRAPH:
diff -u -r lyx-2.0.3/src/Layout.cpp lyx-2.0.3-jwc/src/Layout.cpp
--- lyx-2.0.3/src/Layout.cpp2012-01-14 10:06:40.0 -0500
+++ lyx-2.0.3-jwc/src/Layout.cpp2012-03-30 08:38:28.627232561
-0400
@@ -45,6 +45,7 @@
LT_BOTTOMSEP,
LT_CATEGORY,
LT_COMMANDDEPTH,
+   LT_NEXTSTYLE,
LT_COPYSTYLE,
LT_DEPENDSON,
LT_OBSOLETEDBY,
@@ -166,6 +167,7 @@
{ "category",   LT_CATEGORY },
{ "commanddepth",   LT_COMMANDDEPTH },
{ "copystyle",  LT_COPYSTYLE },
+   { "nextstyle",  LT_NEXTSTYLE },
{ "dependson",  LT_DEPENDSON },
{ "end",LT_END },
{ "endlabelstring", LT_ENDLABELSTRING },
@@ -275,6 +277,16 @@
break;
}

+   case LT_NEXTSTYLE: { // initialize with a known
style
+   docstring style;
+   lex >> style;
+   style = subst(style, '_', ' ');
+
+   docstring const tmpname = style;
+   this->next_style_ = tmpname;
+   break;
+   }
+
case LT_OBSOLETEDBY: {   // replace with a known style
docstring style;
lex >> style;
diff -u -r lyx-2.0.3/src/Layout.h lyx-2.0.3-jwc/src/Layout.h
--- lyx-2.0.3/src/Layout.h  2011-10-30 18:40:03.0 -0400
+++ lyx-2.0.3-jwc/src/Layout.h  2012-03-29 11:28:37.392228561 -0400
@@ -80,6 +80,10 @@
///
docstring const & obsoleted_by() const { return obsoleted_b