Lars Gullik Bjønnes wrote:

> "Asger K. Alstrup Nielsen" <[EMAIL PROTECTED]> writes:
> 
> | Other than that, I think it's a killer feature.
> | If the implementation is nice, I think it should be committed.
> 
> It is pretty much ok, but there are some small nit-picks.
> 
> - comments after statement on same line etc.


ok, 2nd try ...

Herbert



-- 
http://www.lyx.org/help/
Index: lib/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/lib/ChangeLog,v
retrieving revision 1.213
diff -u -r1.213 ChangeLog
--- lib/ChangeLog       24 May 2002 08:29:14 -0000      1.213
+++ lib/ChangeLog       24 May 2002 15:05:49 -0000
@@ -1,3 +1,8 @@
+2002-05-23 Herbert Voss  <[EMAIL PROTECTED]>
+
+       * doc/LaTeXconfig.lyx.in: 
+       * doc/LyXconfig.lyx.in: package listings
+       * ui/default.ui: item for insert sourcecode
 
 2002-05-23  André Pönitz <[EMAIL PROTECTED]>
 
Index: lib/doc/LaTeXConfig.lyx.in
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/lib/doc/LaTeXConfig.lyx.in,v
retrieving revision 1.24
diff -u -r1.24 LaTeXConfig.lyx.in
--- lib/doc/LaTeXConfig.lyx.in  11 Apr 2002 13:18:18 -0000      1.24
+++ lib/doc/LaTeXConfig.lyx.in  24 May 2002 15:05:50 -0000
@@ -1765,4 +1765,25 @@
 url
 \family default 
  is needed by LyX to be able to output url's corrently.
+
+\layout Subsection
+
+listings
+\layout Description
+
+Found: @chk_listings@
+\layout Description
+
+CTAN: 
+\family typewriter 
+macros/latex/contrib/other/misc/listings.sty
+\layout Description
+
+Notes: The package 
+\family sans 
+listings
+\family default 
+ is needed by LyX to be able to output program listings
+
+
 \the_end
Index: lib/doc/LyXConfig.lyx.in
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/lib/doc/LyXConfig.lyx.in,v
retrieving revision 1.3
diff -u -r1.3 LyXConfig.lyx.in
--- lib/doc/LyXConfig.lyx.in    8 Mar 2002 13:53:30 -0000       1.3
+++ lib/doc/LyXConfig.lyx.in    24 May 2002 15:05:50 -0000
@@ -1376,6 +1376,26 @@
  is needed by LyX to be able to output url's corrently.
 \layout Subsection
 
+listings
+\layout Description
+
+Found: @chk_listings@
+\layout Description
+
+CTAN: 
+\family typewriter 
+macros/latex/contrib/other/misc/listings.sty
+\layout Description
+
+Notes: The package 
+\family sans 
+listings
+\family default 
+ is needed by LyX to be able to output program listings
+
+
+\layout Subsection
+
 prettyref
 \layout Description
 
Index: lib/ui/default.ui
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/lib/ui/default.ui,v
retrieving revision 1.85
diff -u -r1.85 default.ui
--- lib/ui/default.ui   20 Mar 2002 12:36:14 -0000      1.85
+++ lib/ui/default.ui   24 May 2002 15:05:51 -0000
@@ -242,6 +242,8 @@
        Item "LyX Document...|X" "file-insert"
        Item "Ascii as Lines...|L" "file-insert-ascii"
        Item "Ascii as Paragraphs...|P" "file-insert-ascii-para"
+       Separator
+       Item "Sourcecode formatted|S" "listing-insert"
     End
 
 #
Index: src/BufferView_pimpl.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView_pimpl.C,v
retrieving revision 1.242
diff -u -r1.242 BufferView_pimpl.C
--- src/BufferView_pimpl.C      24 May 2002 14:34:25 -0000      1.242
+++ src/BufferView_pimpl.C      24 May 2002 15:05:52 -0000
@@ -35,6 +35,7 @@
 #include "insets/insetbib.h"
 #include "insets/insettext.h"
 #include "insets/inseturl.h"
+#include "insets/insetlisting.h"
 #include "insets/insetlatexaccent.h"
 #include "insets/insettoc.h"
 #include "insets/insetref.h"
@@ -2909,6 +2910,28 @@
        }
        break;
 
+       case LFUN_INSERT_LISTING: 
+       {
+//         if (!packageAvailable("listings"))
+//             Alert::alert(_("Sorry, but package listings is not installed\n"),
+//                         _("try to get it from http://www.ctan.org";));
+//         else 
+               if (!argument.empty()) {
+                       InsetCommandParams p;
+                       p.setFromString(argument);
+ 
+                       InsetListing * inset = new InsetListing(p);
+                       if (!insertInset(inset))
+                               delete inset;
+                       else                    
+                               updateInset(inset, true);
+               } else {
+                       InsetCommandParams p("lstinputlisting");
+                       owner_->getDialogs()->createListing(p.getAsString());
+               }
+       }
+       break;
+ 
        case LFUN_INSET_ERT:
                insertAndEditInset(new InsetERT(buffer_->params));
                break;
Index: src/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/ChangeLog,v
retrieving revision 1.724
diff -u -r1.724 ChangeLog
--- src/ChangeLog       24 May 2002 14:34:25 -0000      1.724
+++ src/ChangeLog       24 May 2002 15:05:54 -0000
@@ -1,3 +1,12 @@
+2002-05-23 Herbert Voss  <[EMAIL PROTECTED]>
+
+       * BufferView_pimple.C: 
+       * LaTeXFeatures.C:
+       * LyXAction:
+       * buffer.C:
+       * commandtags.h: support for package listings to insert 
+       sourcecode
+
 2002-05-24  John Levon  <[EMAIL PROTECTED]>
 
        * LColor.C: remove spurious X include
Index: src/LaTeXFeatures.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/LaTeXFeatures.C,v
retrieving revision 1.63
diff -u -r1.63 LaTeXFeatures.C
--- src/LaTeXFeatures.C 10 May 2002 12:58:07 -0000      1.63
+++ src/LaTeXFeatures.C 24 May 2002 15:05:55 -0000
@@ -141,7 +141,8 @@
        "floatflt",
        "varioref",
        "prettyref",
-       "float"
+       "float",
+       "listings"
 };
 
 const int nb_simplefeatures = sizeof(simplefeatures) / sizeof(char const *);
Index: src/LyXAction.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/LyXAction.C,v
retrieving revision 1.115
diff -u -r1.115 LyXAction.C
--- src/LyXAction.C     21 Mar 2002 17:25:08 -0000      1.115
+++ src/LyXAction.C     24 May 2002 15:05:55 -0000
@@ -433,6 +433,8 @@
                { LFUN_FORKS_KILL, "kill-forks",
                  N_("Kill the forked process with this PID"), NoBuffer },
                { LFUN_TOOLTIPS_TOGGLE, "toggle-tooltips", "", NoBuffer },
+               { LFUN_INSERT_LISTING, "listing-insert",                // Herbert 
+2001-10-01
+                   N_("Inserts formatted sourcecode"), Noop },
                { LFUN_NOACTION, "", "", Noop }
        };
 
Index: src/buffer.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/buffer.C,v
retrieving revision 1.340
diff -u -r1.340 buffer.C
--- src/buffer.C        23 May 2002 12:08:33 -0000      1.340
+++ src/buffer.C        24 May 2002 15:05:57 -0000
@@ -52,6 +52,7 @@
 #include "insets/inset.h"
 #include "insets/inseterror.h"
 #include "insets/insetlabel.h"
+#include "insets/insetlisting.h"
 #include "insets/insetref.h"
 #include "insets/inseturl.h"
 #include "insets/insetnote.h"
@@ -1587,6 +1588,8 @@
                } else if (cmdName == "url"
                           || cmdName == "htmlurl") {
                        inset = new InsetUrl(inscmd);
+               } else if (cmdName == "lstinputlisting") {
+                       inset = new InsetListing(inscmd);
                } else if (cmdName == "ref"
                           || cmdName == "pageref"
                           || cmdName == "vref"
Index: src/commandtags.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/commandtags.h,v
retrieving revision 1.88
diff -u -r1.88 commandtags.h
--- src/commandtags.h   21 Mar 2002 17:25:09 -0000      1.88
+++ src/commandtags.h   24 May 2002 15:05:57 -0000
@@ -294,6 +294,7 @@
        LFUN_HELP_ABOUTLYX,             // Edwin 20010712
        LFUN_THESAURUS_ENTRY,           // Levon 20010720
        LFUN_HELP_TEXINFO,              // Herbert 20011001
+       LFUN_INSERT_LISTING,            // Herbert 20011110
        LFUN_FORKS_SHOW,                // Angus 16 Feb 2002
        LFUN_FORKS_KILL,                // Angus 16 Feb 2002
        LFUN_TOOLTIPS_TOGGLE,           // Angus 8 Mar 2002
Index: src/frontends/Dialogs.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/Dialogs.h,v
retrieving revision 1.53
diff -u -r1.53 Dialogs.h
--- src/frontends/Dialogs.h     22 May 2002 01:16:35 -0000      1.53
+++ src/frontends/Dialogs.h     24 May 2002 15:05:57 -0000
@@ -183,6 +183,10 @@
        SigC::Signal1<void, InsetCommand *> showUrl;
        ///
        SigC::Signal1<void, string const &> createUrl;
+       ///
+       SigC::Signal1<void, InsetCommand *> showListing;
+       ///
+       SigC::Signal1<void, string const &> createListing;
        /// show the version control log
        SigC::Signal0<void> showVCLogFile;
        //@}
Index: src/frontends/controllers/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/ChangeLog,v
retrieving revision 1.176
diff -u -r1.176 ChangeLog
--- src/frontends/controllers/ChangeLog 23 May 2002 12:08:40 -0000      1.176
+++ src/frontends/controllers/ChangeLog 24 May 2002 15:05:58 -0000
@@ -1,3 +1,10 @@
+2002-05-23 Herbert Voss  <[EMAIL PROTECTED]>
+
+       * ControlListing.[Ch]:
+       * GUI.h:
+       * makefile.am: support for package listings to insert 
+       sourcecode
+
 2002-05-23  John Levon  <[EMAIL PROTECTED]>
 
        * ControlAboutlyx.C:
Index: src/frontends/controllers/ControlListing.C
===================================================================
RCS file: src/frontends/controllers/ControlListing.C
diff -N src/frontends/controllers/ControlListing.C
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ src/frontends/controllers/ControlListing.C  24 May 2002 15:05:58 -0000
@@ -0,0 +1,86 @@
+/* This file is part of
+ * ====================================================== 
+ *
+ *           LyX, The Document Processor
+ *
+ *           Copyright 2001 The LyX Team.
+ *
+ * ======================================================
+ *
+ * \file ControlBibtex.C
+ * \author Herbert Voss <[EMAIL PROTECTED]> 2001-11-01
+ */
+
+#include <algorithm>
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include <config.h>
+#include "ViewBase.h"
+#include "ButtonControllerBase.h"
+#include "Dialogs.h"
+#include "ControlListing.h"
+#include "frontends/LyXView.h"
+#include "buffer.h"
+#include "BufferView.h"
+#include "helper_funcs.h"
+#include "support/filetools.h"
+#include "lyxfunc.h"
+#include "gettext.h"
+
+#include "lyxrc.h"
+
+using std::pair;
+using std::tolower;
+using std::make_pair;
+using SigC::slot;
+
+ControlListing::ControlListing(LyXView & lv, Dialogs & d)
+       : ControlCommand(lv, d, LFUN_INSERT_LISTING)
+{
+       d_.showListing.connect(slot(this, &ControlListing::showInset));
+       d_.createListing.connect(slot(this, &ControlListing::createInset));
+}
+
+
+string const ControlListing::Browse(string const & in_name, 
+                                   string const & title,
+                                  string const & pattern)
+{
+       pair<string, string> dir1(N_("Files"), string(lyxrc.document_path));
+       return browseFile(&lv_, in_name, title, pattern, 
+                         dir1,make_pair(string(), string()));
+}
+
+
+string const ControlListing::checkFrame(string const & in_frame)
+{
+       string out_frame;
+       string::const_iterator p = in_frame.begin();
+       while (p != in_frame.end()) {
+               // only LTRB/ltrb allowed
+               int const l = tolower(*p);
+               if ((l == 'l') || (l == 't') || (l == 'r') || (l == 'b')) 
+                       out_frame += (*p);    
+               ++p;
+       }
+       return out_frame;
+}
+
+
+string const ControlListing::checkRound(string const & in_round)
+{
+       string out_round;
+       string::const_iterator p = in_round.begin();
+       while (p != in_round.end()) {
+               // only t/f and lower letters allowed
+               int const l = tolower(*p);
+               if ((l == 't') || (l == 'f'))
+                       out_round += l; 
+               ++p;
+       }
+       return out_round;
+}
+
Index: src/frontends/controllers/ControlListing.h
===================================================================
RCS file: src/frontends/controllers/ControlListing.h
diff -N src/frontends/controllers/ControlListing.h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ src/frontends/controllers/ControlListing.h  24 May 2002 15:05:58 -0000
@@ -0,0 +1,42 @@
+// -*- C++ -*-
+/* This file is part of
+ * ====================================================== 
+ *
+ *           LyX, The Document Processor
+ *
+ *           Copyright 2001 The LyX Team.
+ *
+ * ======================================================
+ *
+ * \file ControlListing.h
+ * \author Herbert Voss <[EMAIL PROTECTED]> 2001-11-01
+ */
+
+#ifndef CONTROLLISTING_H
+#define CONTROLLISTING_H
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+#include "ControlCommand.h"
+
+/** A controller for Listing dialogs.
+ */
+class ControlListing : public ControlCommand
+{
+public:
+       ///
+       ControlListing(LyXView &, Dialogs &);
+       ///
+       string const checkFrame(string const & in_frame);
+       ///
+       string const checkRound(string const & in_frame);
+       /// Browse for a file
+       string const Browse(string const &, string const &, string const &);
+ 
+private:
+
+};
+
+#endif // CONTROLLISTING_H
Index: src/frontends/controllers/GUI.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/GUI.h,v
retrieving revision 1.28
diff -u -r1.28 GUI.h
--- src/frontends/controllers/GUI.h     21 Mar 2002 21:21:27 -0000      1.28
+++ src/frontends/controllers/GUI.h     24 May 2002 15:05:58 -0000
@@ -27,6 +27,7 @@
 #include "insets/insetgraphicsParams.h"
 #include "ControlInclude.h"
 #include "ControlIndex.h"
+#include "ControlListing.h"
 #include "ControlLog.h"
 #include "ControlMinipage.h"
 #include "ControlPreamble.h"
@@ -219,6 +220,18 @@
        ///
        GUILog(LyXView & lv, Dialogs & d)
                : GUI<ControlLog, GUIview, OkCancelPolicy, GUIbc>(lv, d) {}
+};
+
+
+ /** Specialization for Listing dialog
+ */
+template <class GUIview, class GUIbc>
+class GUIListing :
+       public GUI<ControlListing, GUIview, NoRepeatedApplyReadOnlyPolicy, GUIbc> {
+public:
+       ///
+       GUIListing(LyXView & lv, Dialogs & d)
+               : GUI<ControlListing, GUIview, NoRepeatedApplyReadOnlyPolicy, 
+GUIbc>(lv, d) {}
 };
 
 
Index: src/frontends/controllers/Makefile.am
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/Makefile.am,v
retrieving revision 1.36
diff -u -r1.36 Makefile.am
--- src/frontends/controllers/Makefile.am       29 Apr 2002 15:56:36 -0000      1.36
+++ src/frontends/controllers/Makefile.am       24 May 2002 15:05:58 -0000
@@ -56,6 +56,8 @@
        ControlIndex.C \
        ControlIndex.h \
        ControlInset.h \
+       ControlListing.C \
+       ControlListing.h \
        ControlLog.C \
        ControlLog.h \
        ControlMinipage.C \
Index: src/frontends/xforms/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/ChangeLog,v
retrieving revision 1.388
diff -u -r1.388 ChangeLog
--- src/frontends/xforms/ChangeLog      24 May 2002 14:34:32 -0000      1.388
+++ src/frontends/xforms/ChangeLog      24 May 2002 15:06:00 -0000
@@ -1,3 +1,12 @@
+2002-05-23 Herbert Voss  <[EMAIL PROTECTED]>
+
+       * Dialogs.C:
+       * FormListing.[Ch]:
+       * forms_listing.[Ch]:
+       * Makefile.am:
+       * forms/form_listing.fd: support for package listings to insert 
+       sourcecode
+
 2002-05-23  John Levon  <[EMAIL PROTECTED]>
 
        * Makefile.am:
Index: src/frontends/xforms/Dialogs.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/Dialogs.C,v
retrieving revision 1.70
diff -u -r1.70 Dialogs.C
--- src/frontends/xforms/Dialogs.C      21 Mar 2002 21:18:02 -0000      1.70
+++ src/frontends/xforms/Dialogs.C      24 May 2002 15:06:00 -0000
@@ -33,6 +33,7 @@
 #include "form_graphics.h"
 #include "form_include.h"
 #include "form_index.h"
+#include "form_listing.h"
 #include "form_minipage.h"
 #include "form_preamble.h"
 #include "form_print.h"
@@ -59,6 +60,7 @@
 #include "FormGraphics.h"
 #include "FormInclude.h"
 #include "FormIndex.h"
+#include "FormListing.h"
 #include "FormLog.h"
 #include "FormMinipage.h"
 #include "FormPreamble.h"
@@ -104,6 +106,7 @@
        add(new GUIGraphics<FormGraphics, xformsBC>(*lv, *this));
        add(new GUIInclude<FormInclude, xformsBC>(*lv, *this));
        add(new GUIIndex<FormIndex, xformsBC>(*lv, *this));
+       add(new GUIListing<FormListing, xformsBC>(*lv, *this));
        add(new GUILog<FormLog, xformsBC>(*lv, *this));
        add(new GUIMinipage<FormMinipage, xformsBC>(*lv, *this));
        add(new GUIFloat<FormFloat, xformsBC>(*lv, *this));
Index: src/frontends/xforms/FormListing.C
===================================================================
RCS file: src/frontends/xforms/FormListing.C
diff -N src/frontends/xforms/FormListing.C
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ src/frontends/xforms/FormListing.C  24 May 2002 15:06:00 -0000
@@ -0,0 +1,313 @@
+/* This file is part of
+ * ====================================================== 
+ *
+ *           LyX, The Document Processor
+ *
+ *           Copyright 2000-2001 The LyX Team.
+ *
+ * ======================================================
+ * 
+ * \file FormListing.C
+ * \author Herbert Voss <[EMAIL PROTECTED]> 2001-11-01
+ */
+
+#include <config.h>
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include "xformsBC.h"
+#include "ControlListing.h"
+#include "FormListing.h"
+#include "form_listing.h"
+#include "xforms_helpers.h" 
+#include "controllers/helper_funcs.h" 
+#include "support/lstrings.h"
+
+string const language = 
+       "no language\nBAP\nACSL\nAda\nALGOL\nC\nC++\nCaml\nClean\nCobol\n"
+       "Comal 80\ncsh\nDelphi\nEiffel\nElan\nEuphoria\nFortran\nHaskell\n"
+       "HTML\nIDL\nJava\nLisp\nLogo\nmake\nMathematica\nMatlab\nMercury\n"
+       "Miranda\nML\nModula-2\nOberon-2\nOCL\nPascal\nPerl\nPL/I\nPOV\n"
+       "Python\nProlog\nR\nS\nSAS\nSHELXL\nSimula\ntcl\nSQL\nTeX\nVBScript\n"
+       "VHDL\nXML";
+string const frames = "none|leftline|topline|lines|single|shadowbox";
+string const fontsize = "default|tiny|scriptsize|footnotesize|small|normalsize";
+string const fontstyle = "default|roman|typewriter";
+
+typedef FormCB<ControlListing, FormDB<FD_form_listing> > base_class;
+
+FormListing::FormListing(ControlListing & c)
+       : base_class(c, _("Input Sourcecode"))
+{}
+
+
+void FormListing::build()
+{
+       dialog_.reset(build_listing());
+
+       // Manage the ok, apply, restore and cancel/close buttons
+       bc().setOK(dialog_->button_ok);
+       bc().setCancel(dialog_->button_cancel);
+       bc().setRestore(dialog_->button_restore);
+       bc().addReadOnly(dialog_->button_browse);
+
+       fl_set_input_return(dialog_->input_filename, FL_RETURN_CHANGED);
+       fl_set_input_return(dialog_->input_frame, FL_RETURN_CHANGED);
+       fl_set_input_maxchars(dialog_->input_frame, 4);
+       fl_set_object_lstyle(dialog_->input_frame, FL_FIXED_STYLE);
+       fl_set_input_return(dialog_->input_round, FL_RETURN_CHANGED);
+       fl_set_input_maxchars(dialog_->input_round, 4);
+       fl_set_object_lstyle(dialog_->input_round, FL_FIXED_STYLE);
+       fl_set_input_return(dialog_->input_caption, FL_RETURN_CHANGED);
+       fl_set_input_return(dialog_->input_label, FL_RETURN_CHANGED);
+       fl_add_browser_line(dialog_->browser_language,language.c_str());
+       fl_addto_choice(dialog_->choice_frames,frames.c_str());
+       fl_addto_choice(dialog_->choice_fontsize,fontsize.c_str());
+       fl_addto_choice(dialog_->choice_fontstyle,fontstyle.c_str());
+       fl_addto_choice(dialog_->choice_numberfontsize,fontsize.c_str());
+       // the default from package
+       fl_set_button(dialog_->button_space, 1);
+}
+
+void FormListing::update()
+{
+       fl_set_input(dialog_->input_filename,
+           controller().params().getContents().c_str());
+       string options = controller().params().getOptions();
+       if (contains(options,"language=")) {
+               // lang is the 1. option
+               options = split(options,'=');
+               string lang = token(options,',',0);
+               if (lang == "{}")
+                       lang = "no language";
+               string tok = token(language,'\n',0);
+               int selection = 1;
+               while ((tok.compare(lang) != 0) && 
+                       (selection < fl_get_browser_maxline(
+                               dialog_->browser_language)))
+                       tok = token(language,'\n',selection++);
+               if (selection < fl_get_browser_maxline(dialog_->browser_language)) {
+                       fl_select_browser_line(dialog_->browser_language,selection);
+                       fl_set_browser_topline(dialog_->browser_language, selection);
+               }
+       }
+       if (contains(options,"basicstyle=")) {
+               // must be a latex command
+               options = split(options,'\\');
+               string basicstyle = token(options,',',0);
+               // there can be 1 or 2 commands, so we have to scan
+               int selection = 0;
+               string cmd = token(basicstyle,'\\',selection++);
+               while (!cmd.empty() && (selection < 3)) {
+                       if (cmd == "rm")
+                               fl_set_choice_text(dialog_->choice_fontstyle,"roman");
+                       else if ( cmd == "tt")
+                               
+fl_set_choice_text(dialog_->choice_fontstyle,"typewriter");
+                       else if (contains(fontsize,cmd))
+                               fl_set_choice_text(dialog_->choice_fontsize, 
+cmd.c_str());
+                       cmd = token(basicstyle,'\\',selection++);
+               }
+               options = split(options,',');
+       } else {
+               // no style, no size
+               fl_set_choice(dialog_->choice_fontstyle, 0);    
+               fl_set_choice(dialog_->choice_fontsize, 0);
+       }
+       if (contains(options,"caption=")) {
+               options = split(options,'{');
+               string const caption = token(options,'}',0);
+               fl_set_input(dialog_->input_caption, caption.c_str()); 
+               options = split(options,',');
+       } else
+               // no caption
+               fl_set_input(dialog_->input_caption, ""); 
+       if (contains(options,"label=")) {
+               options = split(options,'{');
+               string const label = token(options,'}',0);
+               fl_set_input(dialog_->input_label, label.c_str()); 
+               options = split(options,',');
+       } else
+               // no label
+               fl_set_input(dialog_->input_label, "");
+       fl_set_button(dialog_->button_space,
+               !contains(options,"showstringspaces=false"));
+       fl_set_button(dialog_->button_breaklines,
+               contains(options,"breaklines=true"));
+       fl_set_button(dialog_->button_extendedchars,
+               contains(options,"extendedchars=true"));
+       fl_set_button(dialog_->radio_leftnumbers,
+               contains(options,"numbers=left"));
+       fl_set_button(dialog_->radio_rightnumbers,
+               contains(options,"numbers=right"));
+       if (contains(options,"stepnumber=")) {
+               options = options.substr(options.find("stepnumber="));
+               options = split(options,'=');
+               fl_set_slider_value(dialog_->slider_stepnumber,
+               strToDbl(token(options,',',0)));
+       } else
+               fl_set_slider_value(dialog_->slider_stepnumber,1);
+       if (contains(options,"numberstyle=")) {
+               string const font = 
+               token(split(options,'\\'),',',0);
+               fl_set_choice_text(dialog_->choice_numberfontsize, font.c_str());
+       } else
+               fl_set_choice(dialog_->choice_numberfontsize, 1);
+       if (contains(options,"frame=")) {
+               options = options.substr(options.find("frame="));
+               options = split(options,'=');
+               string const frame = token(options,',',0);
+               if (contains(frames,frame)) {
+                       fl_set_choice_text(dialog_->choice_frames, frame.c_str());
+                       fl_set_object_color(dialog_->input_frame, 
+                               FL_INACTIVE_COL, FL_INPUT_COL2);
+                       fl_set_object_color(dialog_->input_round, 
+                               FL_INACTIVE_COL, FL_INPUT_COL2);
+                       setEnabled(dialog_->input_frame, false); 
+                       setEnabled(dialog_->input_round, false); 
+               } else {
+                       fl_set_input(dialog_->input_frame, frame.c_str()); 
+               }
+               if (contains(options,"frameround=")) {
+                       options = options.substr(options.find("frameround="));
+                       options = split(options,'=');
+                       string const round = token(options,',',0);
+                       fl_set_input(dialog_->input_round, round.c_str());
+               } else
+                       fl_set_input(dialog_->input_round, "");
+       } else {
+               fl_set_choice_text(dialog_->choice_frames, "");
+               fl_set_input(dialog_->input_round, "");
+       }
+}
+
+
+void FormListing::apply()
+{
+       const string file = fl_get_input(dialog_->input_filename);
+       if (!file.empty())      
+               controller().params().setContents(
+                       fl_get_input(dialog_->input_filename));
+       int selection = fl_get_browser(dialog_->browser_language);
+       string options;
+       if (selection > 1) {
+               options = "language=";
+               options += fl_get_browser_line(dialog_->browser_language,selection);
+               options += ",";
+       } else
+               options = "language={},";
+       string basicstyle = string();
+       selection = fl_get_choice(dialog_->choice_fontstyle);
+       switch (selection) {
+               case 2: 
+                       basicstyle += "\\rm";
+               break;
+               case 3:
+                       basicstyle += "\\tt";
+               break;
+               default: ;
+       }
+       if (fl_get_choice(dialog_->choice_fontsize) > 1) {
+               basicstyle += "\\";
+               basicstyle += fl_get_choice_text(dialog_->choice_fontsize);
+       }
+       if (!basicstyle.empty())
+               options += ("basicstyle="+basicstyle+",");
+       string const caption = fl_get_input(dialog_->input_caption); 
+       if (!caption.empty())
+               options += ("caption={"+caption+"},");
+       string const label = fl_get_input(dialog_->input_label); 
+       if (!label.empty())
+               options += ("label={"+label+"},");
+       // button_space has default true!!
+       if (!fl_get_button(dialog_->button_space))
+               options += "showstringspaces=false,";
+       if (fl_get_button(dialog_->button_breaklines))
+               options += "breaklines=true,";
+       if (fl_get_button(dialog_->button_extendedchars))
+               options += "extendedchars=true,";
+       if (fl_get_button(dialog_->radio_rightnumbers))
+               options += "numbers=right,";
+       else if (fl_get_button(dialog_->radio_leftnumbers))
+               options += "numbers=left,";
+       if (contains(options,"numbers=")) {
+               options += ("stepnumber="+
+                       tostr(fl_get_slider_value(dialog_->slider_stepnumber))+",");
+               string const font = fl_get_choice_text(dialog_->choice_numberfontsize);
+               if (font != "default")
+                       options += ("numberstyle=\\"+font+","); 
+       }
+       string border = string();
+       if (fl_get_choice(dialog_->choice_frames) > 1) {
+               border += fl_get_choice_text(dialog_->choice_frames);
+       } else {
+               string const f_ = fl_get_input(dialog_->input_frame);
+               if (!f_.empty()) 
+                       // only LTRB/ltrb ?
+                       border += controller().checkFrame(f_);
+       }
+       if (!border.empty()) {          
+               // frame exists
+               options += ("frame="+border);
+               string const r_ = fl_get_input(dialog_->input_round);
+               if (!r_.empty())
+                       options += ",frameround="+controller().checkRound(r_)+",";
+       }
+       // now strip last ','
+       options = strip(options,',');
+//    controller().params().setOptions(options.substr(0,options.size()-1));    
+       controller().params().setOptions(options);    
+}
+
+
+ButtonPolicy::SMInput FormListing::input(FL_OBJECT * ob, long)
+{
+       if (ob == dialog_->button_browse) {
+               string name = controller().Browse("", "Select Sourcefile", "*");
+               if (!name.empty()) {
+                       fl_freeze_form(form()); 
+                       fl_set_input(dialog_->input_filename, name.c_str());
+                       fl_unfreeze_form(form()); 
+               }
+       } else if (ob == dialog_->radio_leftnumbers) {
+               fl_set_button(dialog_->radio_rightnumbers,0);
+                       setEnabled(dialog_->choice_numberfontsize,
+                       fl_get_button(dialog_->radio_leftnumbers) || 
+                       fl_get_button(dialog_->radio_rightnumbers));
+               setEnabled(dialog_->slider_stepnumber,
+                       fl_get_button(dialog_->radio_leftnumbers) || 
+                       fl_get_button(dialog_->radio_rightnumbers));
+       } else if (ob == dialog_->radio_rightnumbers) {
+               fl_set_button(dialog_->radio_leftnumbers,0);
+               setEnabled(dialog_->choice_numberfontsize,
+                       fl_get_button(dialog_->radio_leftnumbers) || 
+                       fl_get_button(dialog_->radio_rightnumbers));
+               setEnabled(dialog_->slider_stepnumber,
+                       fl_get_button(dialog_->radio_leftnumbers) || 
+                       fl_get_button(dialog_->radio_rightnumbers));
+       } else if (ob == dialog_->input_frame) {
+               string const f_ = fl_get_input(dialog_->input_frame);
+               // only 4 characters possible
+               if (f_.size() > 4)
+                       fl_set_input(dialog_->input_frame,f_.substr(0,4).c_str());
+       } else if (ob == dialog_->input_round) {
+               string const r_ = fl_get_input(dialog_->input_round);
+               if (r_.size() > 4)
+                       fl_set_input(dialog_->input_round,r_.substr(0,4).c_str());
+       }
+       if (fl_get_choice(dialog_->choice_frames) < 2) {
+               setEnabled(dialog_->input_round, true); 
+               setEnabled(dialog_->input_frame, true); 
+               fl_set_object_color(dialog_->input_frame, FL_INPUT_COL1, 
+FL_INPUT_COL2);
+               fl_set_object_color(dialog_->input_round, FL_INPUT_COL1, 
+FL_INPUT_COL2);
+       } else {
+               setEnabled(dialog_->input_frame, false); 
+               setEnabled(dialog_->input_round, false); 
+               fl_set_object_color(dialog_->input_frame, 
+                       FL_INACTIVE_COL, FL_INPUT_COL2);
+               fl_set_object_color(dialog_->input_round, 
+                       FL_INACTIVE_COL, FL_INPUT_COL2);
+       }
+       return ButtonPolicy::SMI_VALID;
+}
Index: src/frontends/xforms/FormListing.h
===================================================================
RCS file: src/frontends/xforms/FormListing.h
diff -N src/frontends/xforms/FormListing.h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ src/frontends/xforms/FormListing.h  24 May 2002 15:06:00 -0000
@@ -0,0 +1,48 @@
+// -*- C++ -*-
+/* This file is part of
+ * ====================================================== 
+ *
+ *           LyX, The Document Processor
+ *
+ *           Copyright 2000-2001 The LyX Team.
+ *
+ * ======================================================
+ *
+ * \file FormListing.h
+ * \author herbert voss <[EMAIL PROTECTED]> 2001-10-01
+ */
+
+#ifndef FORMLISTING_H
+#define FORMLISTING_H
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+#include "FormBase.h"
+
+class ControlListing;
+struct FD_form_listing;
+
+/** This class provides an XForms implementation of the listing Dialog.
+ */
+class FormListing : public FormCB<ControlListing, FormDB<FD_form_listing> > {
+public:
+       ///
+       FormListing(ControlListing &);
+
+private:
+       /// Apply from dialog (modify or create inset)
+       virtual void apply();
+       /// Build the dialog
+       virtual void build();
+       /// Update dialog before showing it
+       virtual void update();
+       /// Check the buttons
+       virtual ButtonPolicy::SMInput input(FL_OBJECT *, long);
+       ///
+       FD_form_listing * build_listing();
+
+};
+
+#endif // FORMLISTING_H
Index: src/frontends/xforms/Makefile.am
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/Makefile.am,v
retrieving revision 1.68
diff -u -r1.68 Makefile.am
--- src/frontends/xforms/Makefile.am    24 May 2002 14:34:32 -0000      1.68
+++ src/frontends/xforms/Makefile.am    24 May 2002 15:06:00 -0000
@@ -101,6 +101,10 @@
        form_index.h \
        FormInset.C \
        FormInset.h \
+       FormListing.C \
+       FormListing.h \
+       form_listing.C \
+       form_listing.h \
        FormLog.C \
        FormLog.h \
        FormMathsBitmap.C \
Index: src/frontends/xforms/form_listing.C
===================================================================
RCS file: src/frontends/xforms/form_listing.C
diff -N src/frontends/xforms/form_listing.C
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ src/frontends/xforms/form_listing.C 24 May 2002 15:06:00 -0000
@@ -0,0 +1,207 @@
+// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext
+#include <config.h>
+#include "xforms_helpers.h"
+#include "gettext.h"
+
+/* Form definition file generated with fdesign. */
+
+#include FORMS_H_LOCATION
+#include <stdlib.h>
+#include "form_listing.h"
+#include "FormListing.h"
+
+FD_form_listing::~FD_form_listing()
+{
+  if ( form->visible ) fl_hide_form( form );
+  fl_free_form( form );
+}
+
+
+FD_form_listing * FormListing::build_listing()
+{
+  FL_OBJECT *obj;
+  FD_form_listing *fdui = new FD_form_listing;
+
+  fdui->form = fl_bgn_form(FL_NO_BOX, 360, 520);
+  fdui->form->u_vdata = this;
+  obj = fl_add_box(FL_UP_BOX, 0, 0, 360, 520, "");
+  {
+    char const * const dummy = N_("Browse ...|#B");
+    fdui->button_browse = obj = fl_add_button(FL_NORMAL_BUTTON, 270, 20, 70, 30, 
+idex(_(dummy)));
+    fl_set_button_shortcut(obj, scex(_(dummy)), 1);
+  }
+    fl_set_object_lsize(obj, FL_NORMAL_SIZE);
+    fl_set_object_callback(obj, C_FormBaseInputCB, 0);
+  fdui->button_ok = obj = fl_add_button(FL_RETURN_BUTTON, 10, 480, 70, 30, _("OK"));
+    fl_set_object_lsize(obj, FL_NORMAL_SIZE);
+    fl_set_object_callback(obj, C_FormBaseOKCB, 0);
+  {
+    char const * const dummy = N_("Cancel|^[");
+    fdui->button_cancel = obj = fl_add_button(FL_NORMAL_BUTTON, 280, 480, 70, 30, 
+idex(_(dummy)));
+    fl_set_button_shortcut(obj, scex(_(dummy)), 1);
+  }
+    fl_set_object_lsize(obj, FL_NORMAL_SIZE);
+    fl_set_object_callback(obj, C_FormBaseCancelCB, 0);
+  fdui->input_filename = obj = fl_add_input(FL_NORMAL_INPUT, 20, 20, 240, 30, "");
+    fl_set_object_lsize(obj, FL_NORMAL_SIZE);
+    fl_set_object_lalign(obj, FL_ALIGN_TOP_LEFT);
+    fl_set_object_lstyle(obj, FL_BOLD_STYLE);
+    fl_set_object_callback(obj, C_FormBaseInputCB, 0);
+  {
+    char const * const dummy = N_("Fontsize|#z");
+    fdui->choice_numberfontsize = obj = fl_add_choice(FL_DROPLIST_CHOICE, 210, 310, 
+120, 20, idex(_(dummy)));
+    fl_set_button_shortcut(obj, scex(_(dummy)), 1);
+  }
+    fl_set_object_boxtype(obj, FL_FRAME_BOX);
+    fl_set_object_lsize(obj, FL_NORMAL_SIZE);
+    fl_set_object_lalign(obj, FL_ALIGN_TOP);
+    fl_set_object_callback(obj, C_FormBaseInputCB, 0);
+  obj = fl_add_labelframe(FL_ENGRAVED_FRAME, 10, 230, 170, 110, _("Frame"));
+    fl_set_object_lsize(obj, FL_NORMAL_SIZE);
+    fl_set_object_lstyle(obj, FL_BOLD_STYLE);
+  obj = fl_add_labelframe(FL_ENGRAVED_FRAME, 10, 350, 170, 120, _("Options"));
+    fl_set_object_lsize(obj, FL_NORMAL_SIZE);
+    fl_set_object_lstyle(obj, FL_BOLD_STYLE);
+  {
+    char const * const dummy = N_("Space as a symbol|#S");
+    fdui->button_space = obj = fl_add_checkbutton(FL_PUSH_BUTTON, 20, 420, 30, 30, 
+idex(_(dummy)));
+    fl_set_button_shortcut(obj, scex(_(dummy)), 1);
+  }
+    fl_set_object_lsize(obj, FL_NORMAL_SIZE);
+    fl_set_object_callback(obj, C_FormBaseInputCB, 0);
+  {
+    char const * const dummy = N_("Break lines|#B");
+    fdui->button_breaklines = obj = fl_add_checkbutton(FL_PUSH_BUTTON, 20, 390, 30, 
+30, idex(_(dummy)));
+    fl_set_button_shortcut(obj, scex(_(dummy)), 1);
+  }
+    fl_set_object_lsize(obj, FL_NORMAL_SIZE);
+    fl_set_object_callback(obj, C_FormBaseInputCB, 0);
+  {
+    char const * const dummy = N_("Left|#L");
+    fdui->radio_leftnumbers = obj = fl_add_checkbutton(FL_PUSH_BUTTON, 240, 210, 30, 
+30, idex(_(dummy)));
+    fl_set_button_shortcut(obj, scex(_(dummy)), 1);
+  }
+    fl_set_object_lsize(obj, FL_NORMAL_SIZE);
+    fl_set_object_lalign(obj, FL_ALIGN_LEFT);
+    fl_set_object_callback(obj, C_FormBaseInputCB, 0);
+  {
+    char const * const dummy = N_("Right|#R");
+    fdui->radio_rightnumbers = obj = fl_add_checkbutton(FL_PUSH_BUTTON, 270, 210, 30, 
+30, idex(_(dummy)));
+    fl_set_button_shortcut(obj, scex(_(dummy)), 1);
+  }
+    fl_set_object_lsize(obj, FL_NORMAL_SIZE);
+    fl_set_object_lalign(obj, FL_ALIGN_RIGHT);
+    fl_set_object_callback(obj, C_FormBaseInputCB, 0);
+  obj = fl_add_labelframe(FL_ENGRAVED_FRAME, 190, 190, 160, 150, _("Line numbers"));
+    fl_set_object_lsize(obj, FL_NORMAL_SIZE);
+    fl_set_object_lstyle(obj, FL_BOLD_STYLE);
+  obj = fl_add_labelframe(FL_ENGRAVED_FRAME, 10, 10, 340, 50, _("Source file"));
+    fl_set_object_lstyle(obj, FL_BOLD_STYLE);
+  {
+    char const * const dummy = N_("Extended Character|#E");
+    fdui->button_extendedchars = obj = fl_add_checkbutton(FL_PUSH_BUTTON, 20, 360, 
+30, 30, idex(_(dummy)));
+    fl_set_button_shortcut(obj, scex(_(dummy)), 1);
+  }
+    fl_set_object_lsize(obj, FL_NORMAL_SIZE);
+    fl_set_object_callback(obj, C_FormBaseInputCB, 0);
+  {
+    char const * const dummy = N_("Programming Language|#P");
+    fdui->browser_language = obj = fl_add_browser(FL_HOLD_BROWSER, 10, 80, 170, 140, 
+idex(_(dummy)));
+    fl_set_button_shortcut(obj, scex(_(dummy)), 1);
+  }
+    fl_set_object_lsize(obj, FL_NORMAL_SIZE);
+    fl_set_object_lalign(obj, FL_ALIGN_TOP_LEFT);
+    fl_set_object_lstyle(obj, FL_BOLD_STYLE);
+    fl_set_object_callback(obj, C_FormBaseInputCB, 0);
+  {
+    char const * const dummy = N_("Step|#p");
+    fdui->slider_stepnumber = obj = fl_add_valslider(FL_HOR_BROWSER_SLIDER, 200, 260, 
+140, 20, idex(_(dummy)));
+    fl_set_button_shortcut(obj, scex(_(dummy)), 1);
+  }
+    fl_set_object_lsize(obj, FL_NORMAL_SIZE);
+    fl_set_object_lalign(obj, FL_ALIGN_TOP);
+    fl_set_object_callback(obj, C_FormBaseInputCB, 0);
+    fl_set_slider_bounds(obj, 1, 100);
+    fl_set_slider_value(obj, 1);
+    fl_set_slider_size(obj, 0.00);
+    fl_set_slider_step(obj, 1);
+  obj = fl_add_labelframe(FL_ENGRAVED_FRAME, 190, 70, 160, 110, _("Basic style"));
+    fl_set_object_lsize(obj, FL_NORMAL_SIZE);
+    fl_set_object_lstyle(obj, FL_BOLD_STYLE);
+  {
+    char const * const dummy = N_("Font size|#F");
+    fdui->choice_fontsize = obj = fl_add_choice(FL_DROPLIST_CHOICE, 210, 100, 120, 
+20, idex(_(dummy)));
+    fl_set_button_shortcut(obj, scex(_(dummy)), 1);
+  }
+    fl_set_object_boxtype(obj, FL_FRAME_BOX);
+    fl_set_object_lsize(obj, FL_NORMAL_SIZE);
+    fl_set_object_lalign(obj, FL_ALIGN_TOP);
+    fl_set_object_callback(obj, C_FormBaseInputCB, 0);
+  {
+    char const * const dummy = N_("Font style|#y");
+    fdui->choice_fontstyle = obj = fl_add_choice(FL_DROPLIST_CHOICE, 210, 150, 120, 
+20, idex(_(dummy)));
+    fl_set_button_shortcut(obj, scex(_(dummy)), 1);
+  }
+    fl_set_object_boxtype(obj, FL_FRAME_BOX);
+    fl_set_object_lsize(obj, FL_NORMAL_SIZE);
+    fl_set_object_lalign(obj, FL_ALIGN_TOP);
+    fl_set_object_callback(obj, C_FormBaseInputCB, 0);
+  {
+    char const * const dummy = N_("Predefined|#d");
+    fdui->choice_frames = obj = fl_add_choice(FL_DROPLIST_CHOICE, 40, 260, 120, 20, 
+idex(_(dummy)));
+    fl_set_button_shortcut(obj, scex(_(dummy)), 1);
+  }
+    fl_set_object_boxtype(obj, FL_FRAME_BOX);
+    fl_set_object_lsize(obj, FL_NORMAL_SIZE);
+    fl_set_object_lalign(obj, FL_ALIGN_TOP);
+    fl_set_object_callback(obj, C_FormBaseInputCB, 0);
+  {
+    char const * const dummy = N_("Special|#i");
+    fdui->input_frame = obj = fl_add_input(FL_NORMAL_INPUT, 30, 300, 60, 30, 
+idex(_(dummy)));
+    fl_set_button_shortcut(obj, scex(_(dummy)), 1);
+  }
+    fl_set_object_lsize(obj, FL_NORMAL_SIZE);
+    fl_set_object_lalign(obj, FL_ALIGN_TOP_LEFT);
+    fl_set_object_callback(obj, C_FormBaseInputCB, 0);
+  {
+    char const * const dummy = N_("Rounded|#o");
+    fdui->input_round = obj = fl_add_input(FL_NORMAL_INPUT, 110, 300, 60, 30, 
+idex(_(dummy)));
+    fl_set_button_shortcut(obj, scex(_(dummy)), 1);
+  }
+    fl_set_object_lsize(obj, FL_NORMAL_SIZE);
+    fl_set_object_lalign(obj, FL_ALIGN_TOP_LEFT);
+    fl_set_object_callback(obj, C_FormBaseInputCB, 0);
+  {
+    char const * const dummy = N_("Restore|#t");
+    fdui->button_restore = obj = fl_add_button(FL_NORMAL_BUTTON, 140, 480, 70, 30, 
+idex(_(dummy)));
+    fl_set_button_shortcut(obj, scex(_(dummy)), 1);
+  }
+    fl_set_object_lsize(obj, FL_NORMAL_SIZE);
+    fl_set_object_callback(obj, C_FormBaseRestoreCB, 0);
+  obj = fl_add_labelframe(FL_ENGRAVED_FRAME, 190, 350, 160, 120, _("Miscellaneous"));
+    fl_set_object_lsize(obj, FL_NORMAL_SIZE);
+    fl_set_object_lstyle(obj, FL_BOLD_STYLE);
+  {
+    char const * const dummy = N_("Caption|#C");
+    fdui->input_caption = obj = fl_add_input(FL_NORMAL_INPUT, 200, 380, 140, 30, 
+idex(_(dummy)));
+    fl_set_button_shortcut(obj, scex(_(dummy)), 1);
+  }
+    fl_set_object_lsize(obj, FL_NORMAL_SIZE);
+    fl_set_object_lalign(obj, FL_ALIGN_TOP_LEFT);
+    fl_set_object_callback(obj, C_FormBaseInputCB, 0);
+  {
+    char const * const dummy = N_("Label|#a");
+    fdui->input_label = obj = fl_add_input(FL_NORMAL_INPUT, 200, 430, 140, 30, 
+idex(_(dummy)));
+    fl_set_button_shortcut(obj, scex(_(dummy)), 1);
+  }
+    fl_set_object_lsize(obj, FL_NORMAL_SIZE);
+    fl_set_object_lalign(obj, FL_ALIGN_TOP_LEFT);
+    fl_set_object_callback(obj, C_FormBaseInputCB, 0);
+  fl_end_form();
+
+  fdui->form->fdui = fdui;
+
+  return fdui;
+}
+/*---------------------------------------*/
+
Index: src/frontends/xforms/form_listing.h
===================================================================
RCS file: src/frontends/xforms/form_listing.h
diff -N src/frontends/xforms/form_listing.h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ src/frontends/xforms/form_listing.h 24 May 2002 15:06:00 -0000
@@ -0,0 +1,41 @@
+// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext
+/** Header file generated with fdesign **/
+
+#ifndef FD_form_listing_h_
+#define FD_form_listing_h_
+
+/** Callbacks, globals and object handlers **/
+extern  "C" void C_FormBaseInputCB(FL_OBJECT *, long);
+extern  "C" void C_FormBaseOKCB(FL_OBJECT *, long);
+extern  "C" void C_FormBaseCancelCB(FL_OBJECT *, long);
+extern  "C" void C_FormBaseRestoreCB(FL_OBJECT *, long);
+
+
+/**** Forms and Objects ****/
+struct FD_form_listing {
+       ~FD_form_listing();
+
+       FL_FORM *form;
+       FL_OBJECT *button_browse;
+       FL_OBJECT *button_ok;
+       FL_OBJECT *button_cancel;
+       FL_OBJECT *input_filename;
+       FL_OBJECT *choice_numberfontsize;
+       FL_OBJECT *button_space;
+       FL_OBJECT *button_breaklines;
+       FL_OBJECT *radio_leftnumbers;
+       FL_OBJECT *radio_rightnumbers;
+       FL_OBJECT *button_extendedchars;
+       FL_OBJECT *browser_language;
+       FL_OBJECT *slider_stepnumber;
+       FL_OBJECT *choice_fontsize;
+       FL_OBJECT *choice_fontstyle;
+       FL_OBJECT *choice_frames;
+       FL_OBJECT *input_frame;
+       FL_OBJECT *input_round;
+       FL_OBJECT *button_restore;
+       FL_OBJECT *input_caption;
+       FL_OBJECT *input_label;
+};
+
+#endif /* FD_form_listing_h_ */
Index: src/frontends/xforms/forms/form_listing.fd
===================================================================
RCS file: src/frontends/xforms/forms/form_listing.fd
diff -N src/frontends/xforms/forms/form_listing.fd
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ src/frontends/xforms/forms/form_listing.fd  24 May 2002 15:06:00 -0000
@@ -0,0 +1,506 @@
+Magic: 13000
+
+Internal Form Definition File
+    (do not change)
+
+Number of forms: 1
+Unit of measure: FL_COORD_PIXEL
+
+=============== FORM ===============
+Name: form_listing
+Width: 360
+Height: 520
+Number of Objects: 27
+
+--------------------
+class: FL_BOX
+type: UP_BOX
+box: 0 0 360 520
+boxtype: FL_UP_BOX
+colors: FL_COL1 FL_COL1
+alignment: FL_ALIGN_CENTER
+style: FL_NORMAL_STYLE
+size: FL_DEFAULT_SIZE
+lcol: FL_BLACK
+label: 
+shortcut: 
+resize: FL_RESIZE_ALL
+gravity: FL_NoGravity FL_NoGravity
+name: 
+callback: 
+argument: 
+
+--------------------
+class: FL_BUTTON
+type: NORMAL_BUTTON
+box: 270 20 70 30
+boxtype: FL_UP_BOX
+colors: FL_COL1 FL_COL1
+alignment: FL_ALIGN_CENTER
+style: FL_NORMAL_STYLE
+size: FL_NORMAL_SIZE
+lcol: FL_BLACK
+label: Browse ...|#B
+shortcut: 
+resize: FL_RESIZE_ALL
+gravity: FL_NoGravity FL_NoGravity
+name: button_browse
+callback: C_FormBaseInputCB
+argument: 0
+
+--------------------
+class: FL_BUTTON
+type: RETURN_BUTTON
+box: 10 480 70 30
+boxtype: FL_UP_BOX
+colors: FL_COL1 FL_COL1
+alignment: FL_ALIGN_CENTER
+style: FL_NORMAL_STYLE
+size: FL_NORMAL_SIZE
+lcol: FL_BLACK
+label: OK
+shortcut: ^M
+resize: FL_RESIZE_ALL
+gravity: FL_NoGravity FL_NoGravity
+name: button_ok
+callback: C_FormBaseOKCB
+argument: 0
+
+--------------------
+class: FL_BUTTON
+type: NORMAL_BUTTON
+box: 280 480 70 30
+boxtype: FL_UP_BOX
+colors: FL_COL1 FL_COL1
+alignment: FL_ALIGN_CENTER
+style: FL_NORMAL_STYLE
+size: FL_NORMAL_SIZE
+lcol: FL_BLACK
+label: Cancel|^[
+shortcut: 
+resize: FL_RESIZE_ALL
+gravity: FL_NoGravity FL_NoGravity
+name: button_cancel
+callback: C_FormBaseCancelCB
+argument: 0
+
+--------------------
+class: FL_INPUT
+type: NORMAL_INPUT
+box: 20 20 240 30
+boxtype: FL_DOWN_BOX
+colors: FL_COL1 FL_MCOL
+alignment: FL_ALIGN_TOP_LEFT
+style: FL_BOLD_STYLE
+size: FL_NORMAL_SIZE
+lcol: FL_BLACK
+label: 
+shortcut: 
+resize: FL_RESIZE_ALL
+gravity: FL_NoGravity FL_NoGravity
+name: input_filename
+callback: C_FormBaseInputCB
+argument: 0
+
+--------------------
+class: FL_CHOICE
+type: DROPLIST_CHOICE
+box: 210 310 120 20
+boxtype: FL_FRAME_BOX
+colors: FL_COL1 FL_BLACK
+alignment: FL_ALIGN_TOP
+style: FL_NORMAL_STYLE
+size: FL_NORMAL_SIZE
+lcol: FL_BLACK
+label: Fontsize|#z
+shortcut: 
+resize: FL_RESIZE_ALL
+gravity: FL_NoGravity FL_NoGravity
+name: choice_numberfontsize
+callback: C_FormBaseInputCB
+argument: 0
+
+--------------------
+class: FL_LABELFRAME
+type: ENGRAVED_FRAME
+box: 10 230 170 110
+boxtype: FL_NO_BOX
+colors: FL_BLACK FL_COL1
+alignment: FL_ALIGN_TOP_LEFT
+style: FL_BOLD_STYLE
+size: FL_NORMAL_SIZE
+lcol: FL_BLACK
+label: Frame
+shortcut: 
+resize: FL_RESIZE_ALL
+gravity: FL_NoGravity FL_NoGravity
+name: 
+callback: 
+argument: 
+
+--------------------
+class: FL_LABELFRAME
+type: ENGRAVED_FRAME
+box: 10 350 170 120
+boxtype: FL_NO_BOX
+colors: FL_BLACK FL_COL1
+alignment: FL_ALIGN_TOP_LEFT
+style: FL_BOLD_STYLE
+size: FL_NORMAL_SIZE
+lcol: FL_BLACK
+label: Options
+shortcut: 
+resize: FL_RESIZE_ALL
+gravity: FL_NoGravity FL_NoGravity
+name: 
+callback: 
+argument: 
+
+--------------------
+class: FL_CHECKBUTTON
+type: PUSH_BUTTON
+box: 20 420 30 30
+boxtype: FL_NO_BOX
+colors: FL_COL1 FL_YELLOW
+alignment: FL_ALIGN_CENTER
+style: FL_NORMAL_STYLE
+size: FL_NORMAL_SIZE
+lcol: FL_BLACK
+label: Space as a symbol|#S
+shortcut: 
+resize: FL_RESIZE_ALL
+gravity: FL_NoGravity FL_NoGravity
+name: button_space
+callback: C_FormBaseInputCB
+argument: 0
+
+--------------------
+class: FL_CHECKBUTTON
+type: PUSH_BUTTON
+box: 20 390 30 30
+boxtype: FL_NO_BOX
+colors: FL_COL1 FL_YELLOW
+alignment: FL_ALIGN_CENTER
+style: FL_NORMAL_STYLE
+size: FL_NORMAL_SIZE
+lcol: FL_BLACK
+label: Break lines|#B
+shortcut: 
+resize: FL_RESIZE_ALL
+gravity: FL_NoGravity FL_NoGravity
+name: button_breaklines
+callback: C_FormBaseInputCB
+argument: 0
+
+--------------------
+class: FL_CHECKBUTTON
+type: PUSH_BUTTON
+box: 240 210 30 30
+boxtype: FL_NO_BOX
+colors: FL_COL1 FL_YELLOW
+alignment: FL_ALIGN_LEFT
+style: FL_NORMAL_STYLE
+size: FL_NORMAL_SIZE
+lcol: FL_BLACK
+label: Left|#L
+shortcut: 
+resize: FL_RESIZE_ALL
+gravity: FL_NoGravity FL_NoGravity
+name: radio_leftnumbers
+callback: C_FormBaseInputCB
+argument: 0
+
+--------------------
+class: FL_CHECKBUTTON
+type: PUSH_BUTTON
+box: 270 210 30 30
+boxtype: FL_NO_BOX
+colors: FL_COL1 FL_YELLOW
+alignment: FL_ALIGN_RIGHT
+style: FL_NORMAL_STYLE
+size: FL_NORMAL_SIZE
+lcol: FL_BLACK
+label: Right|#R
+shortcut: 
+resize: FL_RESIZE_ALL
+gravity: FL_NoGravity FL_NoGravity
+name: radio_rightnumbers
+callback: C_FormBaseInputCB
+argument: 0
+
+--------------------
+class: FL_LABELFRAME
+type: ENGRAVED_FRAME
+box: 190 190 160 150
+boxtype: FL_NO_BOX
+colors: FL_BLACK FL_COL1
+alignment: FL_ALIGN_TOP_LEFT
+style: FL_BOLD_STYLE
+size: FL_NORMAL_SIZE
+lcol: FL_BLACK
+label: Line numbers
+shortcut: 
+resize: FL_RESIZE_ALL
+gravity: FL_NoGravity FL_NoGravity
+name: 
+callback: 
+argument: 0
+
+--------------------
+class: FL_LABELFRAME
+type: ENGRAVED_FRAME
+box: 10 10 340 50
+boxtype: FL_NO_BOX
+colors: FL_BLACK FL_COL1
+alignment: FL_ALIGN_TOP_LEFT
+style: FL_BOLD_STYLE
+size: FL_DEFAULT_SIZE
+lcol: FL_BLACK
+label: Source file
+shortcut: 
+resize: FL_RESIZE_ALL
+gravity: FL_NoGravity FL_NoGravity
+name: 
+callback: 
+argument: 
+
+--------------------
+class: FL_CHECKBUTTON
+type: PUSH_BUTTON
+box: 20 360 30 30
+boxtype: FL_NO_BOX
+colors: FL_COL1 FL_YELLOW
+alignment: FL_ALIGN_CENTER
+style: FL_NORMAL_STYLE
+size: FL_NORMAL_SIZE
+lcol: FL_BLACK
+label: Extended Character|#E
+shortcut: 
+resize: FL_RESIZE_ALL
+gravity: FL_NoGravity FL_NoGravity
+name: button_extendedchars
+callback: C_FormBaseInputCB
+argument: 0
+
+--------------------
+class: FL_BROWSER
+type: HOLD_BROWSER
+box: 10 80 170 140
+boxtype: FL_DOWN_BOX
+colors: FL_COL1 FL_YELLOW
+alignment: FL_ALIGN_TOP_LEFT
+style: FL_BOLD_STYLE
+size: FL_NORMAL_SIZE
+lcol: FL_BLACK
+label: Programming Language|#P
+shortcut: 
+resize: FL_RESIZE_ALL
+gravity: FL_NoGravity FL_NoGravity
+name: browser_language
+callback: C_FormBaseInputCB
+argument: 0
+
+--------------------
+class: FL_VALSLIDER
+type: HOR_BROWSER_SLIDER
+box: 200 260 140 20
+boxtype: FL_DOWN_BOX
+colors: FL_COL1 FL_COL1
+alignment: FL_ALIGN_TOP
+style: FL_NORMAL_STYLE
+size: FL_NORMAL_SIZE
+lcol: FL_BLACK
+label: Step|#p
+shortcut: 
+resize: FL_RESIZE_ALL
+gravity: FL_NoGravity FL_NoGravity
+name: slider_stepnumber
+callback: C_FormBaseInputCB
+argument: 0
+       bounds: 1 100
+       value: 1
+       slsize: 0.00
+       step: 1
+
+--------------------
+class: FL_LABELFRAME
+type: ENGRAVED_FRAME
+box: 190 70 160 110
+boxtype: FL_NO_BOX
+colors: FL_BLACK FL_COL1
+alignment: FL_ALIGN_TOP_LEFT
+style: FL_BOLD_STYLE
+size: FL_NORMAL_SIZE
+lcol: FL_BLACK
+label: Basic style
+shortcut: 
+resize: FL_RESIZE_ALL
+gravity: FL_NoGravity FL_NoGravity
+name: 
+callback: 
+argument: 
+
+--------------------
+class: FL_CHOICE
+type: DROPLIST_CHOICE
+box: 210 100 120 20
+boxtype: FL_FRAME_BOX
+colors: FL_COL1 FL_BLACK
+alignment: FL_ALIGN_TOP
+style: FL_NORMAL_STYLE
+size: FL_NORMAL_SIZE
+lcol: FL_BLACK
+label: Font size|#F
+shortcut: 
+resize: FL_RESIZE_ALL
+gravity: FL_NoGravity FL_NoGravity
+name: choice_fontsize
+callback: C_FormBaseInputCB
+argument: 0
+
+--------------------
+class: FL_CHOICE
+type: DROPLIST_CHOICE
+box: 210 150 120 20
+boxtype: FL_FRAME_BOX
+colors: FL_COL1 FL_BLACK
+alignment: FL_ALIGN_TOP
+style: FL_NORMAL_STYLE
+size: FL_NORMAL_SIZE
+lcol: FL_BLACK
+label: Font style|#y
+shortcut: 
+resize: FL_RESIZE_ALL
+gravity: FL_NoGravity FL_NoGravity
+name: choice_fontstyle
+callback: C_FormBaseInputCB
+argument: 0
+
+--------------------
+class: FL_CHOICE
+type: DROPLIST_CHOICE
+box: 40 260 120 20
+boxtype: FL_FRAME_BOX
+colors: FL_COL1 FL_BLACK
+alignment: FL_ALIGN_TOP
+style: FL_NORMAL_STYLE
+size: FL_NORMAL_SIZE
+lcol: FL_BLACK
+label: Predefined|#d
+shortcut: 
+resize: FL_RESIZE_ALL
+gravity: FL_NoGravity FL_NoGravity
+name: choice_frames
+callback: C_FormBaseInputCB
+argument: 0
+
+--------------------
+class: FL_INPUT
+type: NORMAL_INPUT
+box: 30 300 60 30
+boxtype: FL_DOWN_BOX
+colors: FL_COL1 FL_MCOL
+alignment: FL_ALIGN_TOP_LEFT
+style: FL_NORMAL_STYLE
+size: FL_NORMAL_SIZE
+lcol: FL_BLACK
+label: Special|#i
+shortcut: 
+resize: FL_RESIZE_ALL
+gravity: FL_NoGravity FL_NoGravity
+name: input_frame
+callback: C_FormBaseInputCB
+argument: 0
+
+--------------------
+class: FL_INPUT
+type: NORMAL_INPUT
+box: 110 300 60 30
+boxtype: FL_DOWN_BOX
+colors: FL_COL1 FL_MCOL
+alignment: FL_ALIGN_TOP_LEFT
+style: FL_NORMAL_STYLE
+size: FL_NORMAL_SIZE
+lcol: FL_BLACK
+label: Rounded|#o
+shortcut: 
+resize: FL_RESIZE_ALL
+gravity: FL_NoGravity FL_NoGravity
+name: input_round
+callback: C_FormBaseInputCB
+argument: 0
+
+--------------------
+class: FL_BUTTON
+type: NORMAL_BUTTON
+box: 140 480 70 30
+boxtype: FL_UP_BOX
+colors: FL_COL1 FL_COL1
+alignment: FL_ALIGN_CENTER
+style: FL_NORMAL_STYLE
+size: FL_NORMAL_SIZE
+lcol: FL_BLACK
+label: Restore|#t
+shortcut: 
+resize: FL_RESIZE_ALL
+gravity: FL_NoGravity FL_NoGravity
+name: button_restore
+callback: C_FormBaseRestoreCB
+argument: 0
+
+--------------------
+class: FL_LABELFRAME
+type: ENGRAVED_FRAME
+box: 190 350 160 120
+boxtype: FL_NO_BOX
+colors: FL_BLACK FL_COL1
+alignment: FL_ALIGN_TOP_LEFT
+style: FL_BOLD_STYLE
+size: FL_NORMAL_SIZE
+lcol: FL_BLACK
+label: Miscellaneous
+shortcut: 
+resize: FL_RESIZE_ALL
+gravity: FL_NoGravity FL_NoGravity
+name: 
+callback: 
+argument: 
+
+--------------------
+class: FL_INPUT
+type: NORMAL_INPUT
+box: 200 380 140 30
+boxtype: FL_DOWN_BOX
+colors: FL_COL1 FL_MCOL
+alignment: FL_ALIGN_TOP_LEFT
+style: FL_NORMAL_STYLE
+size: FL_NORMAL_SIZE
+lcol: FL_BLACK
+label: Caption|#C
+shortcut: 
+resize: FL_RESIZE_ALL
+gravity: FL_NoGravity FL_NoGravity
+name: input_caption
+callback: C_FormBaseInputCB
+argument: 0
+
+--------------------
+class: FL_INPUT
+type: NORMAL_INPUT
+box: 200 430 140 30
+boxtype: FL_DOWN_BOX
+colors: FL_COL1 FL_MCOL
+alignment: FL_ALIGN_TOP_LEFT
+style: FL_NORMAL_STYLE
+size: FL_NORMAL_SIZE
+lcol: FL_BLACK
+label: Label|#a
+shortcut: 
+resize: FL_RESIZE_ALL
+gravity: FL_NoGravity FL_NoGravity
+name: input_label
+callback: C_FormBaseInputCB
+argument: 0
+
+==============================
+create_the_forms
Index: src/insets/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/ChangeLog,v
retrieving revision 1.429
diff -u -r1.429 ChangeLog
--- src/insets/ChangeLog        24 May 2002 14:34:31 -0000      1.429
+++ src/insets/ChangeLog        24 May 2002 15:06:02 -0000
@@ -1,3 +1,10 @@
+2002-05-23 Herbert Voss  <[EMAIL PROTECTED]>
+
+       * Makefile.am:
+       * insetlisting.[Ch]: 
+       * inset.h: support for package listings to insert 
+       sourcecode
+
 2002-05-24  John Levon  <[EMAIL PROTECTED]>
 
        * insetbib.C:
Index: src/insets/Makefile.am
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/Makefile.am,v
retrieving revision 1.46
diff -u -r1.46 Makefile.am
--- src/insets/Makefile.am      25 Mar 2002 11:15:27 -0000      1.46
+++ src/insets/Makefile.am      24 May 2002 15:06:02 -0000
@@ -55,6 +55,8 @@
        insetlabel.h \
        insetlatexaccent.C \
        insetlatexaccent.h \
+       insetlisting.C \
+       insetlisting.h \
        insetmarginal.h \
        insetmarginal.C \
        insetminipage.C \
Index: src/insets/inset.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/inset.h,v
retrieving revision 1.44
diff -u -r1.44 inset.h
--- src/insets/inset.h  16 Apr 2002 14:10:38 -0000      1.44
+++ src/insets/inset.h  24 May 2002 15:06:02 -0000
@@ -111,7 +111,9 @@
                ///
                FLOAT_LIST_CODE,
                ///
-               INDEX_PRINT_CODE
+               INDEX_PRINT_CODE,
+               ///
+               LISTING_CODE    // 35
        };
 
        ///
Index: src/insets/insetlisting.C
===================================================================
RCS file: src/insets/insetlisting.C
diff -N src/insets/insetlisting.C
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ src/insets/insetlisting.C   24 May 2002 15:06:02 -0000
@@ -0,0 +1,88 @@
+/* This file is part of
+ * ======================================================
+ * 
+ *           LyX, The Document Processor
+ *      
+ *          Copyright 2000-2001 The LyX Team.
+ *
+ * ======================================================
+ 
+ \author Herbert Voss <[EMAIL PROTECTED]>  2001-11-01
+ */
+
+#include <config.h>
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include "insetlisting.h"
+#include "BufferView.h"
+#include "LaTeXFeatures.h"
+#include "frontends/LyXView.h"
+#include "frontends/Dialogs.h"
+#include "debug.h"
+#include "gettext.h"
+#include "support/lstrings.h"
+
+using std::ostream;
+
+InsetListing::InsetListing(InsetCommandParams const & p, bool)
+               : InsetCommand(p)
+{}
+
+
+void InsetListing::edit(BufferView * bv, int, int, unsigned int)
+{
+       bv->owner()->getDialogs()->showListing(this);
+}
+
+
+void InsetListing::edit(BufferView * bv, bool)
+{
+       edit(bv, 0, 0, 0);
+}
+
+
+string const InsetListing::getScreenLabel(Buffer const *) const
+{
+       return "SOURCE code";
+}
+
+
+int InsetListing::latex(Buffer const *, ostream & os, 
+                       bool /*fragile*/, bool /*free space*/) const
+{
+       if (getContents().empty())
+               return 0;
+       os << "\\" << getCmdName() << "[%\n";
+       string options = getOptions();
+       while (contains(options,',')) {
+               os << "\t" << token(options,',',0) << ",%\n";
+               options = split(options,',');
+       }
+       os << "\t" << options << "%\n]{" << getContents() << "}";
+       return 0;
+}
+
+
+int InsetListing::ascii(Buffer const *, ostream & os, int) const
+{
+       if (getContents().empty())
+               return 0;
+       // it's the same than the latex output
+       os << "\\" << getCmdName() << "[%\n";
+       string options = getOptions();
+       while (contains(options,',')) {
+               os << "\t" << token(options,',',0) << ",%\n";
+               options = split(options,',');
+       }
+       os << "\t" << options << "%\n]{" << getContents() << "}";
+       return 0;
+}
+
+
+void InsetListing::validate(LaTeXFeatures & features) const
+{
+       features.require("listings");
+}
\ No newline at end of file
Index: src/insets/insetlisting.h
===================================================================
RCS file: src/insets/insetlisting.h
diff -N src/insets/insetlisting.h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ src/insets/insetlisting.h   24 May 2002 15:06:02 -0000
@@ -0,0 +1,56 @@
+// -*- C++ -*-
+/* This file is part of*
+ * ====================================================== 
+ *
+ *           LyX, The Document Processor
+ *      
+ *         Copyright 1997-2001 The LyX Team.
+ * 
+ * ======================================================
+ *
+ *\author Herbert Voss <[EMAIL PROTECTED]> 2001-10-01
+ */
+
+#ifndef INSET_LISTING_H
+#define INSET_LISTING_H
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+#include "insetcommand.h"
+
+class LaTeXFeatures;
+
+/** The inset for highlited sourcecode
+*/
+class InsetListing : public InsetCommand {
+public:
+       ///
+       explicit
+       InsetListing(InsetCommandParams const &, bool same_id = false);
+       ///
+       virtual Inset * clone(Buffer const &, bool same_id = false) const {
+               return new InsetListing(params(), same_id);
+       }
+       ///
+       Inset::Code lyxCode() const { return Inset::LISTING_CODE; }
+       ///
+       string const getScreenLabel(Buffer const *) const;
+       ///
+       EDITABLE editable() const { return IS_EDITABLE; }
+       ///
+       void edit(BufferView *, int, int, unsigned int);
+       ///
+       void edit(BufferView * bv, bool front = true);
+       ///
+       bool display() const { return false; }
+       ///
+       void validate(LaTeXFeatures &) const;
+       ///
+       int latex(Buffer const *, std::ostream &, bool, bool ) const;
+       ///
+       int ascii(Buffer const *, std::ostream &, int linelen) const;
+};
+
+#endif

Reply via email to