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
This commit is contained in:
Jean-Marc Lasgouttes 2000-03-20 14:49:54 +00:00
parent 4ca043181f
commit db0716f666
25 changed files with 237 additions and 96 deletions

View File

@ -1,3 +1,37 @@
2000-03-20 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
* src/LColor.C: made the command inset background a bit lighter.
2000-03-20 Hartmut Goebel <goebel@noris.net>
* 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 <dekel@math.tau.ac.il>
* 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 <Jean-Marc.Lasgouttes@inria.fr>
* src/lyx_cb.C: add a couple using directives.
2000-03-17 José Abílio Matos <jamatos@lyx.org>
* src/lyx_cb.C (RunLinuxDoc) Removed the flag==-1 option for linuxdoc
import based on the filename.

View File

@ -351,6 +351,7 @@ End
##
## stdstruct
##
Input stdtitle.inc
Input stdstruct.inc
Style Abstract

View File

@ -82,6 +82,7 @@ Style Bibliography
Input stdlists.inc
Input stdlayouts.inc
Input stdsections.inc
Input stdtitle.inc
Input stdstruct.inc
# Remove unwanted Styles

View File

@ -121,6 +121,7 @@ Style NoteToEditor
# First, the standard includes
Input stdsections.inc
Input stdtitle.inc
Input stdstruct.inc
Input stdlists.inc

View File

@ -233,6 +233,7 @@ Style Right_Address
AlignPossible Left, Right
End
Input stdtitle.inc
Input stdstruct.inc
# Input lyxmacros.inc
NoStyle Abstract

View File

@ -131,6 +131,7 @@ Style CrossList
End
# Then the Titles stuff.
Input stdtitle.inc
Input stdstruct.inc
# Title style definition.

View File

@ -257,6 +257,7 @@ Style Title
End
Input stdtitle.inc
Input stdstruct.inc
# Input lyxmacros.inc
NoStyle Abstract

View File

@ -90,6 +90,7 @@ NoStyle Chapter
NoStyle Chapter*
# Some standard layouts
Input stdtitle.inc
Input stdstruct.inc
Input lyxmacros.inc
Input stdlayouts.inc

View File

@ -97,6 +97,7 @@ Input stdlayouts.inc
Input stdlists.inc
################ STRUCTURE OF THE DOCUMENT
Input stdtitle.inc
Input stdstruct.inc
# Title style definition

View File

@ -106,6 +106,7 @@ Input stdlayouts.inc
Input stdlists.inc
################ STRUCTURE OF THE DOCUMENT
Input stdtitle.inc
Input stdstruct.inc
# Preprint style

View File

@ -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

View File

@ -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

View File

@ -2,76 +2,11 @@
# Author : Matthias Ettrich <ettrich@informatik.uni-tuebingen.de>
# Transposed by Pascal André <andre@via.ecp.fr>
# Heavily modifed and enhanced by several developers.
# Title definitions moved to stdtitle.inc by HArtmut Goebel <harmut@noris.net>
# 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

75
lib/layouts/stdtitle.inc Normal file
View File

@ -0,0 +1,75 @@
# Standard textclass definition file. Taken from initial LyX source code
# Author : Matthias Ettrich <ettrich@informatik.uni-tuebingen.de>
# Transposed by Pascal André <andre@via.ecp.fr>
# Heavily modifed and enhanced by several developers.
# Split from stdstruct.inc by Hartmut Goebel <hartmut@noris.net>
# 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

View File

@ -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 ####################################################
#

View File

@ -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

View File

@ -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");

View File

@ -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;

View File

@ -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;

View File

@ -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();

View File

@ -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());

View File

@ -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

View File

@ -13,6 +13,8 @@
#include <fstream>
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?"),

View File

@ -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";

View File

@ -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