]> git.lyx.org Git - lyx.git/commitdiff
Lior's color patch; other small things
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Mon, 26 Jun 2000 15:33:13 +0000 (15:33 +0000)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Mon, 26 Jun 2000 15:33:13 +0000 (15:33 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@837 a592a061-630c-0410-9148-cb99ea01b6c8

15 files changed:
ANNOUNCE
ChangeLog
configure.in
images/redo_bw.xpm [new file with mode: 0644]
images/undo_bw.xpm [new file with mode: 0644]
lib/lyxrc.example
lib/reLyX/configure.in
src/ColorHandler.C
src/ColorHandler.h
src/LColor.C
src/LColor.h
src/LyXAction.C
src/commandtags.h
src/lyxfunc.C
src/lyxrc.C

index bcd4d48a8bfb8b71b8fb6912b26abecf581d4ebd..ba1153e4a5d0afaa85fd5fe6ed329e86a9d15780 100644 (file)
--- a/ANNOUNCE
+++ b/ANNOUNCE
@@ -60,6 +60,7 @@ with mirrors at
 
        ftp://alpha.tat.physik.uni-tuebingen.de/pub/lyx
         ftp://ftp.lip6.fr/pub/lyx/
+       ftp://ftp.chg.ru/packages/lyx/
         ftp://ftp.sdsc.edu/pub/other/lyx/
         ftp://ftp.fciencias.unam.mx/pub/Lyx/
        ftp://mirror.aarnet.edu.au/pub/LyX/
index 49ef11e540830d818402dd62d7ef647e6182fbfd..74e3a757a3495de9acfe617aa09822b43aa50971 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2000-06-26  Lior Silberman <slior@math.huji.ac.il>
+
+       * src/lyxrc.C: 
+       * lib/lyxrc.example: new lyxrc tag \set_color.
+
+       * src/lyxfunc.C (Dispatch): 
+       * src/commandtags.h: 
+       * src/LyXAction.C: new lyxfunc "set-color".
+
+       * src/LColor.[Ch] (setColor): new method to set colors from a lyxname
+       and an x11name given as strings.
+
+       * src/ColorHandler.[Ch] (updateColor): new method. Updates the GC
+       cache when a color is changed.
+
 2000-06-26  Juergen Vigna  <jug@sad.it>
 
        * src/lyxrow.C (width): added this functions and variable.
@@ -9,6 +24,13 @@
 
 2000-06-26  Jean-Marc Lasgouttes  <Jean-Marc.Lasgouttes@inria.fr>
 
+       * images/undo_bw.xpm: new icon.
+       * images/redo_bw.xpm: ditto.
+
+       * configure.in (INSTALL_SCRIPT): change value to
+       ${INSTALL} to avoid failures of install-script target.
+       * lib/reLyX/configure.in (INSTALL_SCRIPT): ditto
+
        * src/BufferView.h: add a magic "friend" declaration to please
        compaq cxx.
 
index 84029dc4bd0323fcd90b99e5078dcc892c9cadd2..4a0dfa76c0d90f2443b24452fc9421a11a226df7 100644 (file)
@@ -42,6 +42,12 @@ if test "x$KPSEWHICH" = xkpsewhich ; then
     [Define this if you have the kpsewhich program working on your system.])
 fi
 
+# Work around a problem in automake 1.4: when invoking install-strip,
+# INSTALL_PROGRAM is changed to 'install -s', and since
+# INSTALL_SCRIPT==INSTALL_PROGRAM, we get errors with fileutils-4.0
+# which returns an error condition when stripping fails.
+INSTALL_SCRIPT='${INSTALL}'
+
 ### we will also need a C compiler to compile GNU gettext
 AC_PROG_CC
 
diff --git a/images/redo_bw.xpm b/images/redo_bw.xpm
new file mode 100644 (file)
index 0000000..bebc8e7
--- /dev/null
@@ -0,0 +1,25 @@
+/* XPM */
+static char const * redo_bw_xpm[] = {
+"20 20 2 1",
+"      c #BFBFBFBFBFBF",
+".     c black",
+"                    ",
+"                    ",
+"                    ",
+"                    ",
+"                    ",
+"                    ",
+"      ......        ",
+"     ..    ..       ",
+"    ..      ..   .  ",
+"   ..        .. ..  ",
+"  ..          ....  ",
+"  .           ....  ",
+"             .....  ",
+"            ......  ",
+"                    ",
+"                    ",
+"                    ",
+"                    ",
+"                    ",
+"                    "};
diff --git a/images/undo_bw.xpm b/images/undo_bw.xpm
new file mode 100644 (file)
index 0000000..1d68d85
--- /dev/null
@@ -0,0 +1,25 @@
+/* XPM */
+static char const * undo_bw_xpm[] = {
+"20 20 2 1",
+"      c #BFBFBFBFBFBF",
+".     c black",
+"                    ",
+"                    ",
+"                    ",
+"                    ",
+"                    ",
+"                    ",
+"        ......      ",
+"       ..    ..     ",
+"  .   ..      ..    ",
+"  .. ..        ..   ",
+"  ....          ..  ",
+"  ....           .  ",
+"  .....             ",
+"  ......            ",
+"                    ",
+"                    ",
+"                    ",
+"                    ",
+"                    ",
+"                    "};
index e41ac1bd097eb421f302dff3b621bb680b55f287..60664175472a74f40c5e77e02337accb9f45eda5 100644 (file)
 # This is the default in LyX (exactly what LaTeX does):
 #\screen_font_sizes 5.0 7.0 8.0 9.0 10.0 12.0 14.4 17.28 20.74 24.88
 
+# To change the colors for footnotes:
+#\set_color footnote green
+# for mathed you may also want to change the coloring of lines and brackets:
+#\set_color math yellow
+#\set_color mathlines yellow
+
 #
 # TOOLBAR SECTION ########################################################
 #
index b1ffdf0d7d96ea152a5d1cdde52abd904efeecbf..f59fec50ad7406efa9f8442907628ccaae9791a5 100644 (file)
@@ -26,6 +26,12 @@ test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
 LYX_DIR=`eval "echo \`eval \"echo ${datadir}/${PACKAGE}\"\`"`
 AC_SUBST(LYX_DIR)
 
+# Work around a problem in automake 1.4: when invoking install-strip,
+# INSTALL_PROGRAM is changed to 'install -s', and since
+# INSTALL_SCRIPT==INSTALL_PROGRAM, we get errors with fileutils-4.0
+# which returns an error condition when stripping fails.
+INSTALL_SCRIPT='${INSTALL}'
+
 dnl Checks for programs.
 AC_PROG_INSTALL
 RELYX_CHECK_PERL
index 5b2571fbdd1b6f6ace0565a06c429dc5ba5c2c63..48aea3a9ca8aa1eedacd34128d2ef061adb3cf27 100644 (file)
@@ -195,5 +195,33 @@ GC LyXColorHandler::getGCLinepars(PainterBase::line_style ls,
                          GCCapStyle | GCJoinStyle | GCFunction, &val);
 }
 
+// update GC cache after color redefinition
+void LyXColorHandler::updateColor (LColor::color c)
+{
+       // color GC cache
+       GC gc = colorGCcache[c];
+       if (gc != NULL) {
+               XFreeGC(display, gc);
+               colorGCcache[c] = NULL;
+               getGCForeground(c);
+       }
+
+       // line GC cache
+
+       int index, ls, lw;
+       for (ls=0; ls<3; ++ls)
+               for (lw=0; lw<2; ++lw) {
+                       index = lw + (ls << 1) + (c << 3);
+                       if (lineGCcache.find(index) != lineGCcache.end()) {
+                               gc = lineGCcache[index];
+                               XFreeGC(display,gc);
+                               lineGCcache.erase(index);
+                               getGCLinepars(PainterBase::line_style(ls),
+                                               PainterBase::line_width(lw), c);
+                       }
+               }
+}
+
 //
 LyXColorHandler * lyxColorHandler;
index f868fbfb341c247d72a10e2a543d4a8c85ee7690..b9e2640839f014d17f9da62f1941d551f31011f6 100644 (file)
@@ -42,6 +42,9 @@ public:
        ///
        GC getGCLinepars(PainterBase::line_style,
                         PainterBase::line_width, LColor::color c);
+       /// update the cache after a color definition change
+       void updateColor(LColor::color c);
+
 private:
        ///
        Display * display;
index c4763d8f72fc69624171fc477a1e2974f01205ee..16777903939838bb5e09316d786a41ab17345c80 100644 (file)
@@ -22,6 +22,7 @@
 #include "gettext.h"
 #include "support/lstrings.h"
 
+using std::endl;
 
 void LColor::fill(LColor::color col, string const & gui,
                  string const & latex, string const & x11,
@@ -171,6 +172,22 @@ void LColor::setColor(LColor::color col, string const & x11name)
 }
 
 
+bool LColor::setColor(string const & lyxname, string const & x11name)
+{
+       color col = getFromLyXName (lyxname);
+
+       // "inherit" is returned for colors not in the database
+       // (and anyway should not be redefined)
+       if (col == inherit || col == ignore) {
+               lyxerr << "Color " << lyxname << " is undefined or may not be"
+                       " redefined" << endl;
+               return false;
+       }
+       setColor (col, x11name);
+       return true;
+}
+
+
 LColor::color LColor::getFromGUIName(string const & guiname) const
 {
        InfoTab::const_iterator ici = infotab.begin();
index 4fc25de94d6eb884ebfd41b74ecaaf8c351615e0..1875816b784bcc30c78ec7583ef447450f153066 100644 (file)
@@ -173,6 +173,8 @@ public:
        LColor();
        ///
        void setColor(LColor::color col, string const & x11name);
+       ///
+       bool setColor(string const & lyxname, string const & x11name);
        /// Get GUI name of color
        string getGUIName(LColor::color c) const;
 
index 701c520d96efdc6c1c5287d9b9222f1e22eda765..3cc0237afd95f145f5f970de680c579b1379053a 100644 (file)
@@ -393,6 +393,7 @@ void LyXAction::init()
                { LFUN_UPCASE_WORD, "word-upcase", "", Noop },
                { LFUN_DATE_INSERT, "date-insert", "", Noop },
                { LFUN_PARAGRAPH_SPACING, "paragraph-spacing", "", Noop },
+               { LFUN_SET_COLOR, "set-color", "", Noop },
                { LFUN_NOACTION, "", "", Noop }
        };
 
index 06c95a909b88e45c25b6033188d68f7ff12be73e..91fca71d90417494a516d222c983e78c423f3e2d 100644 (file)
@@ -253,6 +253,7 @@ enum kb_action {
        LFUN_LOFVIEW,                   // Dekel 20000519       
        LFUN_LOTVIEW,                   // Dekel 20000519
        LFUN_LOAVIEW,                   // Dekel 20000519
+       LFUN_SET_COLOR,                 // SLior 20000611
        LFUN_INSET_EXTERNAL,            // Alstrup 20000609
        LFUN_LASTACTION  /* this marks the end of the table */
 };
index f23bd3f3c8da34d35aab038bb04c40436b0a5c57..02c3c25452c374d707e9b2a6b9ae08e9e555273c 100644 (file)
@@ -32,6 +32,7 @@ using std::istringstream;
 #include "kbmap.h"
 #include "lyxfunc.h"
 #include "bufferlist.h"
+#include "ColorHandler.h"
 #include "lyxserver.h"
 #include "lyx.h"
 #include "intl.h"
@@ -2601,6 +2602,30 @@ string LyXFunc::Dispatch(int ac,
        }
        break;
 
+       case LFUN_SET_COLOR:
+       {
+               string lyx_name, x11_name;
+               x11_name = split(argument, lyx_name, ' ');
+               if (lyx_name.empty() || x11_name.empty()) {
+                       LyXBell();
+                       setErrorMessage(N_("Syntax: set-color <lyx_name>"
+                                               " <x11_name>"));
+                       break;
+                       }
+
+               if (!lcolor.setColor(lyx_name, x11_name)) {
+                       static string err1 (N_("Set-color \""));
+                       static string err2 (N_("\" failed - color is undefined "
+                                               "or may not be redefined"));
+                       LyXBell();
+                       setErrorMessage(err1 + lyx_name + err2);
+                       break;
+               }
+               lyxColorHandler->updateColor(lcolor.getFromLyXName(lyx_name));
+               owner->view()->redraw();
+               break;
+       }
+
        case LFUN_UNKNOWN_ACTION:
        {
                if(!owner->buffer()) {
index f7359f6e5acf58bae776f9c1f6303552637db5c3..4533ac0875f116500c79663c8c9327acb2ab96bf 100644 (file)
@@ -85,6 +85,7 @@ enum LyXRCTags {
        RC_SCREEN_FONT_POPUP,
        RC_SCREEN_FONT_ENCODING,
        RC_SCREEN_FONT_ENCODING_MENU,
+       RC_SET_COLOR,
        RC_AUTOSAVE,
        RC_DOCUMENTPATH,
        RC_TEMPLATEPATH,
@@ -250,6 +251,7 @@ keyword_item lyxrcTags[] = {
        { "\\screen_font_typewriter", RC_SCREEN_FONT_TYPEWRITER },
        { "\\screen_zoom", RC_SCREEN_ZOOM },
        { "\\serverpipe", RC_SERVERPIPE },
+       { "\\set_color", RC_SET_COLOR },
        { "\\show_banner", RC_SHOW_BANNER },
        { "\\spell_command", RC_SPELL_COMMAND },
        { "\\tempdir_path", RC_TEMPDIRPATH },
@@ -837,6 +839,30 @@ int LyXRC::read(string const & filename)
                                font_norm_menu = lexrc.GetString();
                        break;
 
+               case RC_SET_COLOR:
+               {
+                       string lyx_name, x11_name;
+
+                       if (lexrc.lex() == LyXLex::LEX_DATA)  {
+                               lyx_name = lexrc.GetString();
+                       } else {
+                               lexrc.printError("Bad color tag: `$$Token'");
+                               break;
+                       }
+                       
+                       if (lexrc.lex() == LyXLex::LEX_DATA) {
+                               x11_name = lexrc.GetString();
+                       } else {
+                               lexrc.printError("Bad color name: `$$Token'");
+                               break;
+                       }
+
+                       if (!lcolor.setColor(lyx_name, x11_name))
+                               lyxerr << "Bad lyxrc set_color for "
+                                       << lyx_name << endl;
+
+                       break;
+               }
                case RC_AUTOREGIONDELETE:
                        // Auto region delete defaults to true
                        if (lexrc.next())
@@ -1043,6 +1069,7 @@ int LyXRC::read(string const & filename)
                        if ( lexrc.next())
                                docbook_to_pdf_command = lexrc.GetString();
                        break;
+
                case RC_LAST: break; // this is just a dummy
                }
        }
@@ -1101,6 +1128,8 @@ void LyXRC::output(ostream & os) const
                // bind files are not done here.
        case RC_BEGINTOOLBAR:
                // Toolbar is not written here (yet).
+       case RC_SET_COLOR:
+               // color bindings not written to preference file.
        case RC_FONT_ENCODING:
                os << "\\font_encoding \"" << fontenc << "\"\n";
        case RC_PRINTER: