Re: What's missing for char styles...

2007-10-01 Thread Richard Heck

John Levon wrote:

I'm a bit confused, I just compiled svn, and there's no style UI. So,
that would be what's missing.
  
You mean: No gui for constructing character styles? If so, that's right. 
We lack any sort of layout editor, which we very much need.


rh



Re: What's missing for char styles...

2007-10-01 Thread John Levon
On Mon, Oct 01, 2007 at 11:37:43AM -0400, Richard Heck wrote:

 You mean: No gui for constructing character styles? If so, that's right. 

Right. That's critical before char styles can be said to be done.

 We lack any sort of layout editor, which we very much need.

We also need this; however, it is significantly less important than a
char style editor.

regards
john


Re: What's missing for char styles...

2007-10-01 Thread Richard Heck

John Levon wrote:

On Mon, Oct 01, 2007 at 11:37:43AM -0400, Richard Heck wrote:
  
You mean: No gui for constructing character styles? If so, that's right. 


Right. That's critical before char styles can be said to be done

We lack any sort of layout editor, which we very much need.


We also need this; however, it is significantly less important than a
char style editor.
  
I'll guess that once you had the latter, you'd have 95% of the 
infrastructure for the former. But yes, we could start small.


Richard



Re: What's missing for char styles...

2007-10-01 Thread Martin Vermeer
On Mon, 01 Oct 2007 11:56:31 -0400
Richard Heck [EMAIL PROTECTED] wrote:

 John Levon wrote:
  On Mon, Oct 01, 2007 at 11:37:43AM -0400, Richard Heck wrote:

  You mean: No gui for constructing character styles? If so, that's right. 
  
  Right. That's critical before char styles can be said to be done
  We lack any sort of layout editor, which we very much need.
  
  We also need this; however, it is significantly less important than a
  char style editor.

 I'll guess that once you had the latter, you'd have 95% of the 
 infrastructure for the former. But yes, we could start small.
 
 Richard


I had once a working prototype for a charstyle editor based on picking a 
combination of font attributes on-screen -- i.e., the combination existing
at the cursor location -- and converting it to a charstyle. Which could be 
saved in the LyX document. It worked through the minibuffer 
(create-charstyle mystyle), but a GUI would not be hard to do after that.

- Martin


Re: What's missing for char styles...

2007-10-01 Thread Richard Heck

Martin Vermeer wrote:

On Mon, 01 Oct 2007 11:56:31 -0400
Richard Heck [EMAIL PROTECTED] wrote:
  

John Levon wrote:


On Mon, Oct 01, 2007 at 11:37:43AM -0400, Richard Heck wrote:
  
You mean: No gui for constructing character styles? If so, that's right. 


Right. That's critical before char styles can be said to be done
  

We lack any sort of layout editor, which we very much need.


We also need this; however, it is significantly less important than a
char style editor.
  
I'll guess that once you had the latter, you'd have 95% of the 
infrastructure for the former. But yes, we could start small.

I had once a working prototype for a charstyle editor based on picking a 
combination of font attributes on-screen -- i.e., the combination existing
at the cursor location -- and converting it to a charstyle. Which could be 
saved in the LyX document. It worked through the minibuffer 
(create-charstyle mystyle), but a GUI would not be hard to do after that.
  

What did you do with the charstyle once you had it? Write it to a file?

Richard



Re: What's missing for char styles...

2007-10-01 Thread John Levon
On Mon, Oct 01, 2007 at 12:29:14PM -0400, Richard Heck wrote:

 What did you do with the charstyle once you had it? Write it to a file?

This I think is the difficult bit. Where are they stored, and how are
they transmitted? It's a layout thing won't do...

regards
john


Re: What's missing for char styles...

2007-10-01 Thread Richard Heck

John Levon wrote:

On Mon, Oct 01, 2007 at 12:29:14PM -0400, Richard Heck wrote

What did you do with the charstyle once you had it? Write it to a file?


This I think is the difficult bit. Where are they stored, and how are
they transmitted? It's a layout thing won't do...
  
I'm not sure what you mean by `transmitted' here. But at present, 
charstyle definitions are stored in layout files or, at least in 
1.6.svn, in layout modules, which can be used with different 
document-class layouts. (This is at least some improvement.) But it does 
seem to me that there ought to be some sort of on-the-fly alternative. 
One possibility is to store them in the document itself. But if they are 
in the document, there ought to be the possibility of writing them to a 
module, so they could be used with other documents, too, and that seems 
messy. Another option would be to write them to a layout module that is 
associated with the document. E.g., if the document is file.lyx, then 
the charstyles get written to file_charstyles.module, which then gets 
written to the list of included modules, too---so we're not actually 
depending upon the fact that the names will continue to correspond, and 
the module will automatically get loaded. Note, by the way, that this 
same module could actually be used for other on-the-fly layout it might 
be possible to generate.


Richard



Re: What's missing for char styles...

2007-10-01 Thread Jürgen Spitzmüller
John Levon wrote:
 This I think is the difficult bit. Where are they stored, and how are
 they transmitted? It's a layout thing won't do...

I think we will have to store some of then in the document.

We already had this discussion. I think we ended with three kind of char 
styles:

a.) global char styles, stored in some prefs file
b.) char styles with document-class wide scope (probably related to Richards 
modules idea and basically what we have now)
c.) char styles with document-wide scope only. These should be stored in the 
document.

c.) should override b.) should override a.), probably. But all this needs to 
be discussed yet.

Jürgen


Re: What's missing for char styles...

2007-10-01 Thread John Levon
On Mon, Oct 01, 2007 at 12:44:35PM -0400, Richard Heck wrote:

 I'm not sure what you mean by `transmitted' here. But at present, 
 charstyle definitions are stored in layout files or, at least in 
 1.6.svn, in layout modules, which can be used with different 
 document-class layouts. (This is at least some improvement.) But it does 
 seem to me that there ought to be some sort of on-the-fly alternative. 
 One possibility is to store them in the document itself. But if they are 
 in the document, there ought to be the possibility of writing them to a 
 module, so they could be used with other documents, too, and that seems 
 messy. Another option would be to write them to a layout module that is 
 associated with the document. E.g., if the document is file.lyx, then 
 the charstyles get written to file_charstyles.module, which then gets 
 written to the list of included modules, too---so we're not actually 
 depending upon the fact that the names will continue to correspond, and 
 the module will automatically get loaded. Note, by the way, that this 
 same module could actually be used for other on-the-fly layout it might 
 be possible to generate.

Then I send file.lyx to a colleague and the doc is broken. This is the
sort of thing I mean by transmitted. It's not easy. We clearly need
both layout-based and ad-hoc char styles. The former needs to go in (or
associated with) the layout, the latter with the document, and even with
the user.

The old 2003 discussion I linked to has some discussion on this.

regards
john


Re: What's missing for char styles...

2007-10-01 Thread John Levon
On Mon, Oct 01, 2007 at 06:45:05PM +0200, Jürgen Spitzmüller wrote:

 I think we will have to store some of then in the document.
 
 We already had this discussion. I think we ended with three kind of char 

You remember that far back too :)

john


Re: What's missing for char styles...

2007-10-01 Thread Richard Heck

John Levon wrote:

On Mon, Oct 01, 2007 at 12:44:35PM -0400, Richard Heck wrote:

  
I'm not sure what you mean by `transmitted' here. But at present, 
charstyle definitions are stored in layout files or, at least in 
1.6.svn, in layout modules, which can be used with different 
document-class layouts. (This is at least some improvement.) But it does 
seem to me that there ought to be some sort of on-the-fly alternative. 
One possibility is to store them in the document itself. But if they are 
in the document, there ought to be the possibility of writing them to a 
module, so they could be used with other documents, too, and that seems 
messy. Another option would be to write them to a layout module that is 
associated with the document. E.g., if the document is file.lyx, then 
the charstyles get written to file_charstyles.module, which then gets 
written to the list of included modules, too---so we're not actually 
depending upon the fact that the names will continue to correspond, and 
the module will automatically get loaded. Note, by the way, that this 
same module could actually be used for other on-the-fly layout it might 
be possible to generate.


Then I send file.lyx to a colleague and the doc is broken. This is the
sort of thing I mean by transmitted. It's not easy. We clearly need
both layout-based and ad-hoc char styles. The former needs to go in (or
associated with) the layout, the latter with the document, and even with
the user.
  
Yes, I see. I can see the case for document-internal stuff, then. And 
I'm glad, actually. I had anticipated doing something like this when 
doing the modules work, namely, that there would be a document-specific 
layout section, not unlike the current LaTeX preamble section. But 
various people talked me out of it. I can't now remember why.


Richard



Re: What's missing for char styles...

2007-10-01 Thread Jürgen Spitzmüller
John Levon wrote:
 You remember that far back too :)

I do. And I'm pinning all my hope on Richard and Martin, so that this crucial 
feature will eventually become reality. I really hope this will make it into 
1.6.0.

Jürgen


Re: What's missing for char styles...

2007-10-01 Thread John Levon
On Mon, Oct 01, 2007 at 07:02:02PM +0200, Jürgen Spitzmüller wrote:

 I do. And I'm pinning all my hope on Richard and Martin, so that this crucial 
 feature will eventually become reality. I really hope this will make it into 
 1.6.0.

Me too. I'd be happy to help out with UI design or whatever wherever I
can... I doubt I'll ever find time to dig into the code again though

cheers
john


Re: What's missing for char styles...

2007-10-01 Thread Richard Heck

Jürgen Spitzmüller wrote:

John Levon wrote:
  

You remember that far back too :)

I do. And I'm pinning all my hope on Richard and Martin, so that this crucial 
feature will eventually become reality. I really hope this will make it into 
1.6.0.
  
Document-internal layout is fairly easy to do now. Here's the recipe: 
(i) Add the internal layout to BufferParams, mimicking what's there for 
preamble; it'll need to be read and written 
(\begin_layout...\end_layout?), for example, and don't forget the 
Format line at the beginning; (ii) borrow the preamble bit from the 
DocumentSettings UI to get a simple UI for document internal 
layout---you enter it as text; (iii) re-factor TextClass::read() so that 
its successors can read from a file or a stream---so in particular it 
can read the string from BufferParams; (iv) slightly modify 
BufferParams::makeTextClass() so that it adds the document-internal 
layout at the end (if such there is). There's a danger here, namely, 
that the user enters layout that throws errors, but I think we handle 
this properly. If not, that can be fixed.


Ultimately, we'd prefer to have a better UI for editing the 
document-internal layout. But that's a different issue, and having SOME 
way of making document-internal layout is a start.


Richard



Re: What's missing for char styles...

2007-10-01 Thread Martin Vermeer
On Mon, Oct 01, 2007 at 12:29:14PM -0400, Richard Heck wrote:
 Martin Vermeer wrote:
 On Mon, 01 Oct 2007 11:56:31 -0400
 Richard Heck [EMAIL PROTECTED] wrote:
   
 John Levon wrote:
 
 On Mon, Oct 01, 2007 at 11:37:43AM -0400, Richard Heck wrote:
   
 You mean: No gui for constructing character styles? If so, that's 
 right. 
 Right. That's critical before char styles can be said to be done
   
 We lack any sort of layout editor, which we very much need.
 
 We also need this; however, it is significantly less important than a
 char style editor.
   
 I'll guess that once you had the latter, you'd have 95% of the 
 infrastructure for the former. But yes, we could start small.
 
 I had once a working prototype for a charstyle editor based on picking a 
 combination of font attributes on-screen -- i.e., the combination existing
 at the cursor location -- and converting it to a charstyle. Which could be 
 saved in the LyX document. It worked through the minibuffer 
 (create-charstyle mystyle), but a GUI would not be hard to do after that.
   
 What did you do with the charstyle once you had it? Write it to a file?

Yes... the LyX document file. A list of internal charstyles travelling
in its bufferparams.

- Martin
 


Re: What's missing for char styles...

2007-10-01 Thread Martin Vermeer
On Mon, Oct 01, 2007 at 01:21:12PM -0400, Richard Heck wrote:
 Jürgen Spitzmüller wrote:
 John Levon wrote:
   
 You remember that far back too :)
 
 I do. And I'm pinning all my hope on Richard and Martin, so that this 
 crucial feature will eventually become reality. I really hope this will 
 make it into 1.6.0.
   
 Document-internal layout is fairly easy to do now. Here's the recipe: 
 (i) Add the internal layout to BufferParams, mimicking what's there for 
 preamble; it'll need to be read and written 
 (\begin_layout...\end_layout?), for example, and don't forget the 
 Format line at the beginning; (ii) borrow the preamble bit from the 
 DocumentSettings UI to get a simple UI for document internal 
 layout---you enter it as text; (iii) re-factor TextClass::read() so that 
 its successors can read from a file or a stream---so in particular it 
 can read the string from BufferParams; (iv) slightly modify 
 BufferParams::makeTextClass() so that it adds the document-internal 
 layout at the end (if such there is). There's a danger here, namely, 
 that the user enters layout that throws errors, but I think we handle 
 this properly. If not, that can be fixed.
 
 Ultimately, we'd prefer to have a better UI for editing the 
 document-internal layout. But that's a different issue, and having SOME 
 way of making document-internal layout is a start.
 
 Richard

Here's what I dragged up. Primitive, based on a charstyle implementation 
long gone. I now see that the buffer charstyles were entered in the
minibuffer starting with an underscore character, like

charstyle-insert _mystyle

Ah well. It's a start.

- Martin

Index: insets/insetcharstyle.C
===
--- insets/insetcharstyle.C	(revision 13327)
+++ insets/insetcharstyle.C	(working copy)
@@ -48,7 +48,7 @@
 	setInsetName(CharStyle);
 	setInlined();
 	setDrawFrame(false);
-	has_label_ = true;
+	has_label_ = params_.latextype != fontstyle;
 }
 
 
@@ -104,6 +104,7 @@
 void InsetCharStyle::setDefined(CharStyles::iterator cs)
 {
 	params_.latextype = cs-latextype;
+	has_label_ = params_.latextype != fontstyle;
 	params_.latexname = cs-latexname;
 	params_.latexparam = cs-latexparam;
 	params_.font = cs-font;
@@ -261,15 +262,26 @@
 int InsetCharStyle::latex(Buffer const  buf, ostream  os,
 		 OutputParams const  runparams) const
 {
-	if (!undefined()) {
-		os  \\  params_.latexname;
-		if (!params_.latexparam.empty())
-			os  params_.latexparam;
-		os  {;
+	int i = 0;
+	if (params_.latextype == fontstyle) {
+		params_.font.latexWriteStartChanges(os, 
+			LyXFont(LyXFont::ALL_SANE), 
+			LyXFont(LyXFont::ALL_SANE));
+		i = InsetText::latex(buf, os, runparams);
+		params_.font.latexWriteEndChanges(os, 
+			LyXFont(LyXFont::ALL_SANE),
+			LyXFont(LyXFont::ALL_SANE));
+	} else if (params_.latextype == command) {
+		if (!undefined()) {
+			os  \\  params_.latexname;
+			if (!params_.latexparam.empty())
+os  params_.latexparam;
+			os  {;
+		}
+		i = InsetText::latex(buf, os, runparams);
+		if (!undefined())
+			os  };
 	}
-	int i = InsetText::latex(buf, os, runparams);
-	if (!undefined())
-		os  };
 	return i;
 }
 
@@ -327,6 +339,8 @@
 {
 	// Force inclusion of preamble snippet in layout file
 	features.require(params_.type);
+	if (params_.font.color() !=  LColor::none)
+		features.require(color);
 	InsetText::validate(features);
 }
 
Index: factory.C
===
--- factory.C	(revision 13312)
+++ factory.C	(working copy)
@@ -90,8 +90,28 @@
 		CharStyles::iterator found_cs = tclass.charstyle(s);
 		if (found_cs != tclass.charstyles().end())
 			return new InsetCharStyle(params, found_cs);
-		else
-			return new InsetCharStyle(params, s);
+		else {
+			found_cs = params.charstyle(s);
+			if (found_cs != params.charstyles().end())
+return new InsetCharStyle(params, found_cs);
+			else if (s[0] == '_') {
+// Insert here new buffer style into list...
+InsetCharStyle * inset = 
+	new InsetCharStyle(params, s);
+CharStyle cs;
+cs.name = s;
+cs.latexname = s;
+cs.latextype = fontstyle;
+cs.font = bv-cursor().getFont();
+CharStyles  css = const_castCharStyles (params.charstyles());
+if (params.charstyle(cs.name) == css.end())
+	css.push_back(cs);
+//inset-setDefined(css.end() - 1);
+inset-setDefined(params.charstyle(cs.name));
+return inset;
+			} else
+return new InsetCharStyle(params, s);
+		}
 	}
 
 	case LFUN_INSERT_NOTE: {
@@ -410,8 +430,15 @@
 			if (found_cs != tclass.charstyles().end())
 inset.reset(new InsetCharStyle(buf.params(), found_cs));
 			else {
+CharStyles::iterator found_cs 
+	= buf.params().charstyle(s);
+if (found_cs != buf.params().charstyles().end())
+	inset.reset(new InsetCharStyle(buf.params(), found_cs));
+else {
+
 // Undefined inset
 inset.reset(new InsetCharStyle(buf.params(), s));
+}
 			}
 		} else if (tmptok == 

Re: What's missing for char styles...

2007-10-01 Thread Richard Heck

John Levon wrote:

I'm a bit confused, I just compiled svn, and there's no style UI. So,
that would be what's missing.
  
You mean: No gui for constructing character styles? If so, that's right. 
We lack any sort of layout editor, which we very much need.


rh



Re: What's missing for char styles...

2007-10-01 Thread John Levon
On Mon, Oct 01, 2007 at 11:37:43AM -0400, Richard Heck wrote:

> You mean: No gui for constructing character styles? If so, that's right. 

Right. That's critical before char styles can be said to be done.

> We lack any sort of layout editor, which we very much need.

We also need this; however, it is significantly less important than a
char style editor.

regards
john


Re: What's missing for char styles...

2007-10-01 Thread Richard Heck

John Levon wrote:

On Mon, Oct 01, 2007 at 11:37:43AM -0400, Richard Heck wrote:
  
You mean: No gui for constructing character styles? If so, that's right. 


Right. That's critical before char styles can be said to be done

We lack any sort of layout editor, which we very much need.


We also need this; however, it is significantly less important than a
char style editor.
  
I'll guess that once you had the latter, you'd have 95% of the 
infrastructure for the former. But yes, we could start small.


Richard



Re: What's missing for char styles...

2007-10-01 Thread Martin Vermeer
On Mon, 01 Oct 2007 11:56:31 -0400
Richard Heck <[EMAIL PROTECTED]> wrote:

> John Levon wrote:
> > On Mon, Oct 01, 2007 at 11:37:43AM -0400, Richard Heck wrote:
> >   
> >> You mean: No gui for constructing character styles? If so, that's right. 
> >> 
> > Right. That's critical before char styles can be said to be done
> >> We lack any sort of layout editor, which we very much need.
> >> 
> > We also need this; however, it is significantly less important than a
> > char style editor.
> >   
> I'll guess that once you had the latter, you'd have 95% of the 
> infrastructure for the former. But yes, we could start small.
> 
> Richard


I had once a working prototype for a charstyle editor based on "picking" a 
combination of font attributes on-screen -- i.e., the combination existing
at the cursor location -- and converting it to a charstyle. Which could be 
saved in the LyX document. It worked through the minibuffer 
("create-charstyle mystyle"), but a GUI would not be hard to do after that.

- Martin


Re: What's missing for char styles...

2007-10-01 Thread Richard Heck

Martin Vermeer wrote:

On Mon, 01 Oct 2007 11:56:31 -0400
Richard Heck <[EMAIL PROTECTED]> wrote:
  

John Levon wrote:


On Mon, Oct 01, 2007 at 11:37:43AM -0400, Richard Heck wrote:
  
You mean: No gui for constructing character styles? If so, that's right. 


Right. That's critical before char styles can be said to be done
  

We lack any sort of layout editor, which we very much need.


We also need this; however, it is significantly less important than a
char style editor.
  
I'll guess that once you had the latter, you'd have 95% of the 
infrastructure for the former. But yes, we could start small.

I had once a working prototype for a charstyle editor based on "picking" a 
combination of font attributes on-screen -- i.e., the combination existing
at the cursor location -- and converting it to a charstyle. Which could be 
saved in the LyX document. It worked through the minibuffer 
("create-charstyle mystyle"), but a GUI would not be hard to do after that.
  

What did you do with the charstyle once you had it? Write it to a file?

Richard



Re: What's missing for char styles...

2007-10-01 Thread John Levon
On Mon, Oct 01, 2007 at 12:29:14PM -0400, Richard Heck wrote:

> What did you do with the charstyle once you had it? Write it to a file?

This I think is the difficult bit. Where are they stored, and how are
they transmitted? "It's a layout thing" won't do...

regards
john


Re: What's missing for char styles...

2007-10-01 Thread Richard Heck

John Levon wrote:

On Mon, Oct 01, 2007 at 12:29:14PM -0400, Richard Heck wrote

What did you do with the charstyle once you had it? Write it to a file?


This I think is the difficult bit. Where are they stored, and how are
they transmitted? "It's a layout thing" won't do...
  
I'm not sure what you mean by `transmitted' here. But at present, 
charstyle definitions are stored in layout files or, at least in 
1.6.svn, in layout "modules", which can be used with different 
document-class layouts. (This is at least some improvement.) But it does 
seem to me that there ought to be some sort of on-the-fly alternative. 
One possibility is to store them in the document itself. But if they are 
in the document, there ought to be the possibility of writing them to a 
module, so they could be used with other documents, too, and that seems 
messy. Another option would be to write them to a layout module that is 
associated with the document. E.g., if the document is file.lyx, then 
the charstyles get written to file_charstyles.module, which then gets 
written to the list of included modules, too---so we're not actually 
depending upon the fact that the names will continue to correspond, and 
the module will automatically get loaded. Note, by the way, that this 
same module could actually be used for other on-the-fly layout it might 
be possible to generate.


Richard



Re: What's missing for char styles...

2007-10-01 Thread Jürgen Spitzmüller
John Levon wrote:
> This I think is the difficult bit. Where are they stored, and how are
> they transmitted? "It's a layout thing" won't do...

I think we will have to store some of then in the document.

We already had this discussion. I think we ended with three kind of char 
styles:

a.) global char styles, stored in some prefs file
b.) char styles with document-class wide scope (probably related to Richards 
modules idea and basically what we have now)
c.) char styles with document-wide scope only. These should be stored in the 
document.

c.) should override b.) should override a.), probably. But all this needs to 
be discussed yet.

Jürgen


Re: What's missing for char styles...

2007-10-01 Thread John Levon
On Mon, Oct 01, 2007 at 12:44:35PM -0400, Richard Heck wrote:

> I'm not sure what you mean by `transmitted' here. But at present, 
> charstyle definitions are stored in layout files or, at least in 
> 1.6.svn, in layout "modules", which can be used with different 
> document-class layouts. (This is at least some improvement.) But it does 
> seem to me that there ought to be some sort of on-the-fly alternative. 
> One possibility is to store them in the document itself. But if they are 
> in the document, there ought to be the possibility of writing them to a 
> module, so they could be used with other documents, too, and that seems 
> messy. Another option would be to write them to a layout module that is 
> associated with the document. E.g., if the document is file.lyx, then 
> the charstyles get written to file_charstyles.module, which then gets 
> written to the list of included modules, too---so we're not actually 
> depending upon the fact that the names will continue to correspond, and 
> the module will automatically get loaded. Note, by the way, that this 
> same module could actually be used for other on-the-fly layout it might 
> be possible to generate.

Then I send file.lyx to a colleague and the doc is broken. This is the
sort of thing I mean by "transmitted". It's not easy. We clearly need
both layout-based and ad-hoc char styles. The former needs to go in (or
associated with) the layout, the latter with the document, and even with
the user.

The old 2003 discussion I linked to has some discussion on this.

regards
john


Re: What's missing for char styles...

2007-10-01 Thread John Levon
On Mon, Oct 01, 2007 at 06:45:05PM +0200, Jürgen Spitzmüller wrote:

> I think we will have to store some of then in the document.
> 
> We already had this discussion. I think we ended with three kind of char 

You remember that far back too :)

john


Re: What's missing for char styles...

2007-10-01 Thread Richard Heck

John Levon wrote:

On Mon, Oct 01, 2007 at 12:44:35PM -0400, Richard Heck wrote:

  
I'm not sure what you mean by `transmitted' here. But at present, 
charstyle definitions are stored in layout files or, at least in 
1.6.svn, in layout "modules", which can be used with different 
document-class layouts. (This is at least some improvement.) But it does 
seem to me that there ought to be some sort of on-the-fly alternative. 
One possibility is to store them in the document itself. But if they are 
in the document, there ought to be the possibility of writing them to a 
module, so they could be used with other documents, too, and that seems 
messy. Another option would be to write them to a layout module that is 
associated with the document. E.g., if the document is file.lyx, then 
the charstyles get written to file_charstyles.module, which then gets 
written to the list of included modules, too---so we're not actually 
depending upon the fact that the names will continue to correspond, and 
the module will automatically get loaded. Note, by the way, that this 
same module could actually be used for other on-the-fly layout it might 
be possible to generate.


Then I send file.lyx to a colleague and the doc is broken. This is the
sort of thing I mean by "transmitted". It's not easy. We clearly need
both layout-based and ad-hoc char styles. The former needs to go in (or
associated with) the layout, the latter with the document, and even with
the user.
  
Yes, I see. I can see the case for document-internal stuff, then. And 
I'm glad, actually. I had anticipated doing something like this when 
doing the modules work, namely, that there would be a document-specific 
"layout" section, not unlike the current LaTeX preamble section. But 
various people talked me out of it. I can't now remember why.


Richard



Re: What's missing for char styles...

2007-10-01 Thread Jürgen Spitzmüller
John Levon wrote:
> You remember that far back too :)

I do. And I'm pinning all my hope on Richard and Martin, so that this crucial 
feature will eventually become reality. I really hope this will make it into 
1.6.0.

Jürgen


Re: What's missing for char styles...

2007-10-01 Thread John Levon
On Mon, Oct 01, 2007 at 07:02:02PM +0200, Jürgen Spitzmüller wrote:

> I do. And I'm pinning all my hope on Richard and Martin, so that this crucial 
> feature will eventually become reality. I really hope this will make it into 
> 1.6.0.

Me too. I'd be happy to help out with UI design or whatever wherever I
can... I doubt I'll ever find time to dig into the code again though

cheers
john


Re: What's missing for char styles...

2007-10-01 Thread Richard Heck

Jürgen Spitzmüller wrote:

John Levon wrote:
  

You remember that far back too :)

I do. And I'm pinning all my hope on Richard and Martin, so that this crucial 
feature will eventually become reality. I really hope this will make it into 
1.6.0.
  
Document-internal layout is fairly easy to do now. Here's the recipe: 
(i) Add the internal layout to BufferParams, mimicking what's there for 
preamble; it'll need to be read and written 
(\begin_layout...\end_layout?), for example, and don't forget the 
"Format" line at the beginning; (ii) borrow the preamble bit from the 
Document>Settings UI to get a simple UI for document internal 
layout---you enter it as text; (iii) re-factor TextClass::read() so that 
its successors can read from a file or a stream---so in particular it 
can read the string from BufferParams; (iv) slightly modify 
BufferParams::makeTextClass() so that it adds the document-internal 
layout at the end (if such there is). There's a danger here, namely, 
that the user enters layout that throws errors, but I think we handle 
this properly. If not, that can be fixed.


Ultimately, we'd prefer to have a better UI for editing the 
document-internal layout. But that's a different issue, and having SOME 
way of making document-internal layout is a start.


Richard



Re: What's missing for char styles...

2007-10-01 Thread Martin Vermeer
On Mon, Oct 01, 2007 at 12:29:14PM -0400, Richard Heck wrote:
> Martin Vermeer wrote:
> >On Mon, 01 Oct 2007 11:56:31 -0400
> >Richard Heck <[EMAIL PROTECTED]> wrote:
> >  
> >>John Levon wrote:
> >>
> >>>On Mon, Oct 01, 2007 at 11:37:43AM -0400, Richard Heck wrote:
> >>>  
> You mean: No gui for constructing character styles? If so, that's 
> right. 
> >>>Right. That's critical before char styles can be said to be done
> >>>  
> We lack any sort of layout editor, which we very much need.
> 
> >>>We also need this; however, it is significantly less important than a
> >>>char style editor.
> >>>  
> >>I'll guess that once you had the latter, you'd have 95% of the 
> >>infrastructure for the former. But yes, we could start small.
> >>
> >I had once a working prototype for a charstyle editor based on "picking" a 
> >combination of font attributes on-screen -- i.e., the combination existing
> >at the cursor location -- and converting it to a charstyle. Which could be 
> >saved in the LyX document. It worked through the minibuffer 
> >("create-charstyle mystyle"), but a GUI would not be hard to do after that.
> >  
> What did you do with the charstyle once you had it? Write it to a file?

Yes... the LyX document file. A list of internal charstyles travelling
in its bufferparams.

- Martin
 


Re: What's missing for char styles...

2007-10-01 Thread Martin Vermeer
On Mon, Oct 01, 2007 at 01:21:12PM -0400, Richard Heck wrote:
> Jürgen Spitzmüller wrote:
> >John Levon wrote:
> >  
> >>You remember that far back too :)
> >>
> >I do. And I'm pinning all my hope on Richard and Martin, so that this 
> >crucial feature will eventually become reality. I really hope this will 
> >make it into 1.6.0.
> >  
> Document-internal layout is fairly easy to do now. Here's the recipe: 
> (i) Add the internal layout to BufferParams, mimicking what's there for 
> preamble; it'll need to be read and written 
> (\begin_layout...\end_layout?), for example, and don't forget the 
> "Format" line at the beginning; (ii) borrow the preamble bit from the 
> Document>Settings UI to get a simple UI for document internal 
> layout---you enter it as text; (iii) re-factor TextClass::read() so that 
> its successors can read from a file or a stream---so in particular it 
> can read the string from BufferParams; (iv) slightly modify 
> BufferParams::makeTextClass() so that it adds the document-internal 
> layout at the end (if such there is). There's a danger here, namely, 
> that the user enters layout that throws errors, but I think we handle 
> this properly. If not, that can be fixed.
> 
> Ultimately, we'd prefer to have a better UI for editing the 
> document-internal layout. But that's a different issue, and having SOME 
> way of making document-internal layout is a start.
> 
> Richard

Here's what I dragged up. Primitive, based on a charstyle implementation 
long gone. I now see that the "buffer charstyles" were entered in the
minibuffer starting with an underscore character, like

charstyle-insert _mystyle

Ah well. It's a start.

- Martin

Index: insets/insetcharstyle.C
===
--- insets/insetcharstyle.C	(revision 13327)
+++ insets/insetcharstyle.C	(working copy)
@@ -48,7 +48,7 @@
 	setInsetName("CharStyle");
 	setInlined();
 	setDrawFrame(false);
-	has_label_ = true;
+	has_label_ = params_.latextype != "fontstyle";
 }
 
 
@@ -104,6 +104,7 @@
 void InsetCharStyle::setDefined(CharStyles::iterator cs)
 {
 	params_.latextype = cs->latextype;
+	has_label_ = params_.latextype != "fontstyle";
 	params_.latexname = cs->latexname;
 	params_.latexparam = cs->latexparam;
 	params_.font = cs->font;
@@ -261,15 +262,26 @@
 int InsetCharStyle::latex(Buffer const & buf, ostream & os,
 		 OutputParams const & runparams) const
 {
-	if (!undefined()) {
-		os << "\\" << params_.latexname;
-		if (!params_.latexparam.empty())
-			os << params_.latexparam;
-		os << "{";
+	int i = 0;
+	if (params_.latextype == "fontstyle") {
+		params_.font.latexWriteStartChanges(os, 
+			LyXFont(LyXFont::ALL_SANE), 
+			LyXFont(LyXFont::ALL_SANE));
+		i = InsetText::latex(buf, os, runparams);
+		params_.font.latexWriteEndChanges(os, 
+			LyXFont(LyXFont::ALL_SANE),
+			LyXFont(LyXFont::ALL_SANE));
+	} else if (params_.latextype == "command") {
+		if (!undefined()) {
+			os << "\\" << params_.latexname;
+			if (!params_.latexparam.empty())
+os << params_.latexparam;
+			os << "{";
+		}
+		i = InsetText::latex(buf, os, runparams);
+		if (!undefined())
+			os << "}";
 	}
-	int i = InsetText::latex(buf, os, runparams);
-	if (!undefined())
-		os << "}";
 	return i;
 }
 
@@ -327,6 +339,8 @@
 {
 	// Force inclusion of preamble snippet in layout file
 	features.require(params_.type);
+	if (params_.font.color() !=  LColor::none)
+		features.require("color");
 	InsetText::validate(features);
 }
 
Index: factory.C
===
--- factory.C	(revision 13312)
+++ factory.C	(working copy)
@@ -90,8 +90,28 @@
 		CharStyles::iterator found_cs = tclass.charstyle(s);
 		if (found_cs != tclass.charstyles().end())
 			return new InsetCharStyle(params, found_cs);
-		else
-			return new InsetCharStyle(params, s);
+		else {
+			found_cs = params.charstyle(s);
+			if (found_cs != params.charstyles().end())
+return new InsetCharStyle(params, found_cs);
+			else if (s[0] == '_') {
+// Insert here new buffer style into list...
+InsetCharStyle * inset = 
+	new InsetCharStyle(params, s);
+CharStyle cs;
+cs.name = s;
+cs.latexname = s;
+cs.latextype = "fontstyle";
+cs.font = bv->cursor().getFont();
+CharStyles & css = const_cast(params.charstyles());
+if (params.charstyle(cs.name) == css.end())
+	css.push_back(cs);
+//inset->setDefined(css.end() - 1);
+inset->setDefined(params.charstyle(cs.name));
+return inset;
+			} else
+return new InsetCharStyle(params, s);
+		}
 	}
 
 	case LFUN_INSERT_NOTE: {
@@ -410,8 +430,15 @@
 			if (found_cs != tclass.charstyles().end())
 inset.reset(new InsetCharStyle(buf.params(), found_cs));
 			else {
+CharStyles::iterator found_cs 
+	= buf.params().charstyle(s);
+if (found_cs != buf.params().charstyles().end())
+	inset.reset(new InsetCharStyle(buf.params(), found_cs));
+else {
+
 // "Undefined" inset