From db0716f6669599f9b6293f77223cd017810295ca Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Mon, 20 Mar 2000 14:49:54 +0000 Subject: [PATCH] Backup file patch from Dekel; Update to scr layout files from Hartmut Goebel git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@621 a592a061-630c-0410-9148-cb99ea01b6c8 --- ChangeLog | 34 ++++++++++++++++ lib/layouts/IEEEtran.layout | 1 + lib/layouts/aapaper.layout | 1 + lib/layouts/aastex.layout | 1 + lib/layouts/broadway.layout | 1 + lib/layouts/foils.layout | 1 + lib/layouts/hollywood.layout | 1 + lib/layouts/paper.layout | 1 + lib/layouts/revtex.layout | 1 + lib/layouts/revtex4.layout | 1 + lib/layouts/scrclass.inc | 32 +++++++-------- lib/layouts/stdclass.inc | 1 + lib/layouts/stdstruct.inc | 69 +-------------------------------- lib/layouts/stdtitle.inc | 75 ++++++++++++++++++++++++++++++++++++ lib/lyxrc.example | 45 ++++++++++++++++++++++ po/POTFILES.in | 1 - src/LColor.C | 2 +- src/buffer.C | 14 ++++--- src/buffer.h | 2 +- src/bufferlist.C | 2 +- src/insets/insetbib.C | 18 +++++++-- src/insets/insetbib.h | 14 ++++++- src/lyx_cb.C | 4 +- src/lyxrc.C | 9 +++++ src/lyxrc.h | 2 + 25 files changed, 237 insertions(+), 96 deletions(-) create mode 100644 lib/layouts/stdtitle.inc diff --git a/ChangeLog b/ChangeLog index e68528e095..cf1f3e0957 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,37 @@ +2000-03-20 Jean-Marc Lasgouttes + + * src/LColor.C: made the command inset background a bit lighter. + +2000-03-20 Hartmut Goebel + + * lib/layouts/stdstruct.inc: split into stdtitle.inc and + stdstruct.inc. Koma-Script added some title elements which + otherwise have been listed below "bibliography". This split allows + adding title elements to where they belong. + + * lib/layouts/scrclass.inc: changed to include stdtitle.inc, then + define the additional tilte elements and then include + stdstruct.inc. + + * many other layout files: changed to include stdtitle.inc just + before stdstruct.inc. + +2000-03-18 Dekel Tsur + + * src/buffer.C: (save) Added the option to store all backup files + in a single directory + + * src/lyxrc.[Ch]: Added variable \backupdir_path + + * lib/lyxrc.example: Added descriptions of recently added variables + + * src/insets/insetbib.[Ch]: Fixed few bugs (crash when editing a + bibtex inset, not closing the bibtex popup when deleting the inset) + +2000-03-17 Jean-Marc Lasgouttes + + * src/lyx_cb.C: add a couple using directives. + 2000-03-17 José Abílio Matos * src/lyx_cb.C (RunLinuxDoc) Removed the flag==-1 option for linuxdoc import based on the filename. diff --git a/lib/layouts/IEEEtran.layout b/lib/layouts/IEEEtran.layout index e1463a0974..73d9522a5b 100644 --- a/lib/layouts/IEEEtran.layout +++ b/lib/layouts/IEEEtran.layout @@ -351,6 +351,7 @@ End ## ## stdstruct ## +Input stdtitle.inc Input stdstruct.inc Style Abstract diff --git a/lib/layouts/aapaper.layout b/lib/layouts/aapaper.layout index 4336571f90..b350d0be2c 100644 --- a/lib/layouts/aapaper.layout +++ b/lib/layouts/aapaper.layout @@ -82,6 +82,7 @@ Style Bibliography Input stdlists.inc Input stdlayouts.inc Input stdsections.inc +Input stdtitle.inc Input stdstruct.inc # Remove unwanted Styles diff --git a/lib/layouts/aastex.layout b/lib/layouts/aastex.layout index 432cba4441..cdd776061c 100644 --- a/lib/layouts/aastex.layout +++ b/lib/layouts/aastex.layout @@ -121,6 +121,7 @@ Style NoteToEditor # First, the standard includes Input stdsections.inc +Input stdtitle.inc Input stdstruct.inc Input stdlists.inc diff --git a/lib/layouts/broadway.layout b/lib/layouts/broadway.layout index b69ccbdd29..787d9ec2bc 100644 --- a/lib/layouts/broadway.layout +++ b/lib/layouts/broadway.layout @@ -233,6 +233,7 @@ Style Right_Address AlignPossible Left, Right End +Input stdtitle.inc Input stdstruct.inc # Input lyxmacros.inc NoStyle Abstract diff --git a/lib/layouts/foils.layout b/lib/layouts/foils.layout index f2ac43fd98..ed01ff9c10 100644 --- a/lib/layouts/foils.layout +++ b/lib/layouts/foils.layout @@ -131,6 +131,7 @@ Style CrossList End # Then the Titles stuff. +Input stdtitle.inc Input stdstruct.inc # Title style definition. diff --git a/lib/layouts/hollywood.layout b/lib/layouts/hollywood.layout index 6dcd7b5974..800ac81bfa 100644 --- a/lib/layouts/hollywood.layout +++ b/lib/layouts/hollywood.layout @@ -257,6 +257,7 @@ Style Title End +Input stdtitle.inc Input stdstruct.inc # Input lyxmacros.inc NoStyle Abstract diff --git a/lib/layouts/paper.layout b/lib/layouts/paper.layout index 905014e1b2..0ae48b75ff 100644 --- a/lib/layouts/paper.layout +++ b/lib/layouts/paper.layout @@ -90,6 +90,7 @@ NoStyle Chapter NoStyle Chapter* # Some standard layouts +Input stdtitle.inc Input stdstruct.inc Input lyxmacros.inc Input stdlayouts.inc diff --git a/lib/layouts/revtex.layout b/lib/layouts/revtex.layout index 5041393b6f..f908e054ac 100644 --- a/lib/layouts/revtex.layout +++ b/lib/layouts/revtex.layout @@ -97,6 +97,7 @@ Input stdlayouts.inc Input stdlists.inc ################ STRUCTURE OF THE DOCUMENT +Input stdtitle.inc Input stdstruct.inc # Title style definition diff --git a/lib/layouts/revtex4.layout b/lib/layouts/revtex4.layout index 5e563dd4c1..e848a70b84 100644 --- a/lib/layouts/revtex4.layout +++ b/lib/layouts/revtex4.layout @@ -106,6 +106,7 @@ Input stdlayouts.inc Input stdlists.inc ################ STRUCTURE OF THE DOCUMENT +Input stdtitle.inc Input stdstruct.inc # Preprint style diff --git a/lib/layouts/scrclass.inc b/lib/layouts/scrclass.inc index de2b3766be..de195fd96c 100644 --- a/lib/layouts/scrclass.inc +++ b/lib/layouts/scrclass.inc @@ -141,7 +141,7 @@ Style Minisec EndFont End -Input stdstruct.inc +Input stdtitle.inc # Modify Title Style Title @@ -165,20 +165,6 @@ Style Date EndFont End -# Modify Abstract -Style Abstract - LabelFont - Family Sans - EndFont -End - -# Modify Bibliography -Style Bibliography - LabelFont - Family Sans - EndFont -End - # Subject style definition Style Subject CopyStyle Author @@ -227,6 +213,22 @@ Style Extratitle LatexName extratitle End +Input stdstruct.inc + +# Modify Abstract +Style Abstract + LabelFont + Family Sans + EndFont +End + +# Modify Bibliography +Style Bibliography + LabelFont + Family Sans + EndFont +End + Input stdlayouts.inc Input lyxmacros.inc Input scrmacros.inc diff --git a/lib/layouts/stdclass.inc b/lib/layouts/stdclass.inc index a5609ff8ec..06785745dc 100644 --- a/lib/layouts/stdclass.inc +++ b/lib/layouts/stdclass.inc @@ -37,6 +37,7 @@ End Input stdlists.inc Input stdsections.inc Input stdstarsections.inc +Input stdtitle.inc Input stdstruct.inc Input lyxmacros.inc Input stdlayouts.inc diff --git a/lib/layouts/stdstruct.inc b/lib/layouts/stdstruct.inc index cd97f7958b..864af1efa8 100644 --- a/lib/layouts/stdstruct.inc +++ b/lib/layouts/stdstruct.inc @@ -2,76 +2,11 @@ # Author : Matthias Ettrich # Transposed by Pascal André # Heavily modifed and enhanced by several developers. +# Title definitions moved to stdtitle.inc by HArtmut Goebel # This include files contains all layouts that handle the structure of -# a document, like titles and such. +# a document, like abstract, bibliography and such. -# Title style definition -Style Title - Margin Static - LatexType Command - InTitle 1 - LatexName title - ParSkip 0.4 - ItemSep 0 - TopSep 0 - BottomSep 1 - ParSep 1 - Align Center - AlignPossible Center - LabelType No_Label - - # standard font definition - Font - Size Largest - EndFont - -End - -# Author style definition -Style Author - Margin Static - LatexType Command - InTitle 1 - LatexName author - LabelSep xxx - ParSkip 0.4 - TopSep 1.3 - BottomSep 0.7 - ParSep 0.7 - Align Center - AlignPossible Center - LabelType No_Label - - # standard font definition - Font - Size Large - EndFont - -End - -# Date style definition -Style Date - Margin Dynamic - LatexType Command - InTitle 1 - LatexName date - LabelSep xxx - ParSkip 0.4 - TopSep 0.9 - BottomSep 0.5 - ParSep 1 - Align Center - AlignPossible Center - LabelType No_Label - - - # standard font definition - Font - Size Large - EndFont - -End # Abstract style definition Style Abstract diff --git a/lib/layouts/stdtitle.inc b/lib/layouts/stdtitle.inc new file mode 100644 index 0000000000..524c1c9d6d --- /dev/null +++ b/lib/layouts/stdtitle.inc @@ -0,0 +1,75 @@ +# Standard textclass definition file. Taken from initial LyX source code +# Author : Matthias Ettrich +# Transposed by Pascal André +# Heavily modifed and enhanced by several developers. +# Split from stdstruct.inc by Hartmut Goebel + +# This include files contains all layouts that handle the title area +# a document, like title, author and such. + +# Title style definition +Style Title + Margin Static + LatexType Command + InTitle 1 + LatexName title + ParSkip 0.4 + ItemSep 0 + TopSep 0 + BottomSep 1 + ParSep 1 + Align Center + AlignPossible Center + LabelType No_Label + + # standard font definition + Font + Size Largest + EndFont + +End + +# Author style definition +Style Author + Margin Static + LatexType Command + InTitle 1 + LatexName author + LabelSep xxx + ParSkip 0.4 + TopSep 1.3 + BottomSep 0.7 + ParSep 0.7 + Align Center + AlignPossible Center + LabelType No_Label + + # standard font definition + Font + Size Large + EndFont + +End + +# Date style definition +Style Date + Margin Dynamic + LatexType Command + InTitle 1 + LatexName date + LabelSep xxx + ParSkip 0.4 + TopSep 0.9 + BottomSep 0.5 + ParSep 1 + Align Center + AlignPossible Center + LabelType No_Label + + + # standard font definition + Font + Size Large + EndFont + +End diff --git a/lib/lyxrc.example b/lib/lyxrc.example index 5f7bfcb5c7..6bd1f5d265 100644 --- a/lib/lyxrc.example +++ b/lib/lyxrc.example @@ -511,6 +511,15 @@ # SGML or plain text). Default is 75. #\ascii_linelen 80 +# Set to false if you don't want LyX to create backup files. +# Default is true. +#\make_backup true + +# The path for storing backup files. If it is the empty string, LyX will +# store the backup file in the same directory of the original file. +# Default is "". +#\backupdir_path "~/Desktop/Trash/" + # # FAX SECTION ############################################################# @@ -589,6 +598,42 @@ # #\date_insert_format "%A, %e. %B %Y" +# +# LANGUAGE SUPPORT SECTION #################################################### +# + +# Set to true to enable support of right-to-left languages (e.g. Hebrew, +# Arabic). Default is false. +#\rtl true + +# If auto_mathmode is set to "true", each time a digit key is pressed, +# LyX will automatically enter into math-mode. +# If auto_mathmode is set to "rtl", the above behavior will take place +# only when editing right-to-left text. +# Default is false. +#\auto_mathmode true + +# The latex command for loading the language package. +# Default is \usepackage{babel}. +#\language_package "\usepackage{omega}" + +# The latex command for changing the from the language of the document +# to another language. $$lang is substituted by the name of the second +# language. Default is \selectlanguage{$$lang}. +#\language_command_begin "\begin{otherlanguage}{$$lang}" + +# The latex command for changing back the language to the language of +# the document. Default is \selectlanguage{$$lang}. +#\language_command_end "\end{otherlanguage}" + +# Set to false if a language switching command is needed at the beginning of +# the document. Default is true. +#\language_auto_begin false + +# Set to false if a language switching command is needed at the end of +# the document. Default is true. +#\language_auto_end false + # # HEBREW SUPPORT SECTION #################################################### # diff --git a/po/POTFILES.in b/po/POTFILES.in index 01a4988ba5..d33b423a19 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -28,7 +28,6 @@ src/insets/figinset.h src/insets/form_graphics.C src/insets/form_url.C src/insets/insetbib.C -src/insets/inseteditor.C src/insets/inseterror.C src/insets/inseterror.h src/insets/insetert.C diff --git a/src/LColor.C b/src/LColor.C index d047a1cdd9..9d64bf6122 100644 --- a/src/LColor.C +++ b/src/LColor.C @@ -57,7 +57,7 @@ LColor::LColor() fill(notebg, _("note background"), "notebg", "yellow", "notebg"); fill(noteframe, _("note frame"), "noteframe", "black", "noteframe"); fill(command, _("command-inset"), "command", "black", "command"); - fill(commandbg, _("command-inset background"), "commandbg", "grey50", "commandbg"); + fill(commandbg, _("command-inset background"), "commandbg", "grey80", "commandbg"); fill(commandframe, _("inset frame"), "commandframe", "black", "commandframe"); fill(accent, _("accent"), "accent", "black", "accent"); fill(accentbg, _("accent background"), "accentbg", "offwhite", "accentbg"); diff --git a/src/buffer.C b/src/buffer.C index 1826584815..fc739c412b 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -1093,14 +1093,19 @@ bool Buffer::readFile(LyXLex & lex, LyXParagraph * par) // Should probably be moved to somewhere else: BufferView? LyXView? -bool Buffer::save(bool makeBackup) const +bool Buffer::save() const { // We don't need autosaves in the immediate future. (Asger) resetAutosaveTimers(); // make a backup - if (makeBackup) { - string s = fileName() + '~'; + string s; + if (lyxrc.make_backup) { + s = fileName() + '~'; + if (!lyxrc.backupdir_path.empty()) + s = AddName(lyxrc.backupdir_path, + subst(CleanupPath(s),'/','!')); + // Rename is the wrong way of making a backup, // this is the correct way. /* truss cp fil fil2: @@ -1168,8 +1173,7 @@ bool Buffer::save(bool makeBackup) const } } else { // Saving failed, so backup is not backup - if (makeBackup) { - string s = fileName() + '~'; + if (lyxrc.make_backup) { ::rename(s.c_str(), fileName().c_str()); } return false; diff --git a/src/buffer.h b/src/buffer.h index 9a58df3282..0c0262beab 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -143,7 +143,7 @@ public: Takes care of auto-save files and backup file if requested. Returns true if the save is successful, false otherwise. */ - bool save(bool makeBackup) const; + bool save() const; /// Write file. Returns false if unsuccesful. bool writeFile(string const &, bool) const; diff --git a/src/bufferlist.C b/src/bufferlist.C index 47f2e9b258..e47f83ccad 100644 --- a/src/bufferlist.C +++ b/src/bufferlist.C @@ -156,7 +156,7 @@ bool BufferList::close(Buffer * buf) MakeDisplayPath(buf->fileName(), 50), _("Save document?"))){ case 1: // Yes - if (buf->save(lyxrc.make_backup)) { + if (buf->save()) { lastfiles->newFile(buf->fileName()); } else { AllowInput(); diff --git a/src/insets/insetbib.C b/src/insets/insetbib.C index b38c864729..7887b6f6ae 100644 --- a/src/insets/insetbib.C +++ b/src/insets/insetbib.C @@ -220,7 +220,8 @@ InsetBibKey::InsetBibKey(InsetBibKey const * b): InsetBibKey::~InsetBibKey() { if(bibitem_form && bibitem_form->bibitem_form - && bibitem_form->bibitem_form->visible) + && bibitem_form->bibitem_form->visible + && bibitem_form->bibitem_form->u_vdata == &holder) fl_hide_form(bibitem_form->bibitem_form); } @@ -303,6 +304,14 @@ InsetBibtex::InsetBibtex(string const & dbase, string const & style, { } +InsetBibtex::~InsetBibtex() +{ + if(bibitem_form && bibitem_form->bibitem_form + && bibitem_form->bibitem_form->visible + && bibitem_form->bibitem_form->u_vdata == &holder) + fl_hide_form(bibitem_form->bibitem_form); +} + string InsetBibtex::getScreenLabel() const { @@ -404,7 +413,7 @@ string InsetBibtex::getKeys(char delim) // BibTeX should have its own dialog. This is provisional. -void InsetBibtex::Edit(BufferView *, int, int, unsigned int) +void InsetBibtex::Edit(BufferView * bv, int, int, unsigned int) { if (!bibitem_form) { bibitem_form = create_form_bibitem_form(); @@ -412,7 +421,10 @@ void InsetBibtex::Edit(BufferView *, int, int, unsigned int) CancelCloseBoxCB, 0); } - bibitem_form->bibitem_form->u_vdata = this; + holder.inset = this; + holder.view = bv; + bibitem_form->bibitem_form->u_vdata = &holder; + fl_set_object_label(bibitem_form->key, _("Database:")); fl_set_object_label(bibitem_form->label, _("Style: ")); fl_set_input(bibitem_form->key, getContents().c_str()); diff --git a/src/insets/insetbib.h b/src/insets/insetbib.h index 5db3846998..90bd3dfbcd 100644 --- a/src/insets/insetbib.h +++ b/src/insets/insetbib.h @@ -113,6 +113,9 @@ public: /// InsetBibtex(string const & dbase, string const & style, Buffer *); + /// + ~InsetBibtex(); + /// Inset * Clone() const { return new InsetBibtex(contents, options, 0); @@ -139,10 +142,19 @@ public: /// bool delDatabase(string const &); /// - bool display() const { return true; } + bool display() const { return true; } + + struct Holder { + InsetBibtex * inset; + BufferView * view; + }; + private: /// mutable Buffer * owner; + + /// + Holder holder; }; #endif diff --git a/src/lyx_cb.C b/src/lyx_cb.C index c94abb3c4c..48ac8b47bb 100644 --- a/src/lyx_cb.C +++ b/src/lyx_cb.C @@ -13,6 +13,8 @@ #include using std::ifstream; +using std::copy; +using std::back_inserter; #include "LString.h" #include "support/lstrings.h" @@ -276,7 +278,7 @@ void SetUpdateTimer(float time) void MenuWrite(Buffer * buffer) { XFlush(fl_display); - if (!buffer->save(lyxrc.make_backup)) { + if (!buffer->save()) { string fname = buffer->fileName(); string s = MakeAbsPath(fname); if (AskQuestion(_("Save failed. Rename and try again?"), diff --git a/src/lyxrc.C b/src/lyxrc.C index 92090ce0ea..9b71b5f7f2 100644 --- a/src/lyxrc.C +++ b/src/lyxrc.C @@ -132,6 +132,7 @@ enum LyXRCTags { RC_RELYX_COMMAND, RC_HTML_COMMAND, RC_MAKE_BACKUP, + RC_BACKUPDIR_PATH, RC_RTL_SUPPORT, RC_AUTO_MATHMODE, RC_LANGUAGE_PACKAGE, @@ -160,6 +161,7 @@ keyword_item lyxrcTags[] = { { "\\auto_region_delete", RC_AUTOREGIONDELETE }, { "\\autosave", RC_AUTOSAVE }, { "\\background_color", RC_BACKGROUND_COLOR }, + { "\\backupdir_path", RC_BACKUPDIR_PATH }, { "\\begin_toolbar", RC_BEGINTOOLBAR }, { "\\bind", RC_BIND }, { "\\bind_file", RC_BINDFILE }, @@ -334,6 +336,7 @@ void LyXRC::setDefaults() { num_lastfiles = 4; check_lastfiles = true; make_backup = true; + backupdir_path = ""; exit_confirmation = true; display_shortcuts = true; // Spellchecker settings: @@ -947,6 +950,10 @@ int LyXRC::read(string const & filename) if (lexrc.next()) make_backup = lexrc.GetBool(); break; + case RC_BACKUPDIR_PATH: + if (lexrc.next()) + backupdir_path = ExpandPath(lexrc.GetString()); + break; case RC_DATE_INSERT_FORMAT: if (lexrc.next()) date_insert_format = lexrc.GetString(); @@ -1293,6 +1300,8 @@ void LyXRC::output(ostream & os) const << "\"\n"; case RC_MAKE_BACKUP: os << "\\make_backup " << tostr(make_backup) << "\n"; + case RC_BACKUPDIR_PATH: + os << "\\backupdir_path" << backupdir_path << "\n"; case RC_DATE_INSERT_FORMAT: os << "\\date_insert_format \"" << date_insert_format << "\"\n"; diff --git a/src/lyxrc.h b/src/lyxrc.h index 9cab1ff5e0..fffbdccf46 100644 --- a/src/lyxrc.h +++ b/src/lyxrc.h @@ -140,6 +140,8 @@ public: unsigned int num_lastfiles; /// shall a backup file be created bool make_backup; + /// A directory for storing backup files + string backupdir_path; /// Zoom factor for screen fonts unsigned int zoom; /// Screen font sizes in points for each font size -- 2.39.2