1999-09-27 18:44:28 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/* This file is part of
|
1999-11-04 01:40:20 +00:00
|
|
|
* ======================================================
|
|
|
|
*
|
|
|
|
* LyX, The Document Processor
|
|
|
|
*
|
|
|
|
* Copyright 1995 Matthias Ettrich
|
|
|
|
* Copyright 1995-1999 The LyX Team.
|
|
|
|
*
|
|
|
|
* ====================================================== */
|
1999-09-27 18:44:28 +00:00
|
|
|
|
1999-11-04 01:40:20 +00:00
|
|
|
#ifndef LASTFILES_H
|
|
|
|
#define LASTFILES_H
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma interface
|
|
|
|
#endif
|
|
|
|
|
1999-11-04 01:40:20 +00:00
|
|
|
#include <deque>
|
1999-09-27 18:44:28 +00:00
|
|
|
#include "LString.h"
|
|
|
|
|
|
|
|
|
|
|
|
/** The latest documents loaded
|
1999-11-04 01:40:20 +00:00
|
|
|
This class takes care of the last .lyx files used by the LyX user. It
|
|
|
|
both reads and writes this information to a file. The number of files
|
|
|
|
kept are user defined, but defaults to four.
|
1999-09-27 18:44:28 +00:00
|
|
|
*/
|
|
|
|
class LastFiles
|
|
|
|
{
|
|
|
|
public:
|
1999-11-04 01:40:20 +00:00
|
|
|
///
|
|
|
|
typedef deque<string> Files;
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
/**@name Constructors and Deconstructors */
|
|
|
|
//@{
|
|
|
|
/**
|
1999-11-04 01:40:20 +00:00
|
|
|
Parameters are: name of file to read. Whether LastFiles should
|
|
|
|
check for file existance, and the number of files to remember.
|
|
|
|
*/
|
|
|
|
LastFiles(string const &, bool dostat = true, unsigned int num = 4);
|
1999-09-27 18:44:28 +00:00
|
|
|
//@}
|
1999-11-04 01:40:20 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
/**@name Methods */
|
|
|
|
//@{
|
|
|
|
/**
|
1999-11-04 01:40:20 +00:00
|
|
|
This funtion inserts #file# into the last files list. If the file
|
|
|
|
already exist it is moved to the top of the list, else exist it
|
|
|
|
is placed on the top of the list. If the list is full the last
|
|
|
|
file in the list is popped from the end.
|
|
|
|
*/
|
1999-10-02 16:21:10 +00:00
|
|
|
void newFile(string const &);
|
1999-11-04 01:40:20 +00:00
|
|
|
/** Writes the lastfiles table to disk. One file on each line, this
|
|
|
|
way we can at least have some special chars (e.g. space), but
|
|
|
|
newline in filenames are thus not allowed.
|
|
|
|
*/
|
1999-10-02 16:21:10 +00:00
|
|
|
void writeFile(string const &) const;
|
1999-11-04 01:40:20 +00:00
|
|
|
///
|
|
|
|
string operator[](unsigned int) const;
|
|
|
|
///
|
|
|
|
Files::const_iterator begin() const { return files.begin(); }
|
|
|
|
///
|
|
|
|
Files::const_iterator end() const { return files.end(); }
|
1999-09-27 18:44:28 +00:00
|
|
|
//@}
|
|
|
|
private:
|
|
|
|
/**@name const variables */
|
|
|
|
//@{
|
|
|
|
enum {
|
|
|
|
///
|
1999-11-04 01:40:20 +00:00
|
|
|
DEFAULTFILES = 4,
|
|
|
|
/** There is no point in keeping more than this number
|
|
|
|
of files at the same time. However perhaps someday
|
|
|
|
someone finds use for more files and wants to
|
|
|
|
change it. Please do. But don't show the files in
|
|
|
|
a menu...
|
|
|
|
*/
|
1999-09-27 18:44:28 +00:00
|
|
|
ABSOLUTEMAXLASTFILES = 20
|
|
|
|
};
|
|
|
|
//@}
|
1999-11-04 01:40:20 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
/**@name Variables */
|
|
|
|
//@{
|
1999-11-04 01:40:20 +00:00
|
|
|
/// a list of lastfiles
|
|
|
|
Files files;
|
1999-09-27 18:44:28 +00:00
|
|
|
/// number of files in the lastfiles list.
|
1999-11-04 01:40:20 +00:00
|
|
|
unsigned int num_files;
|
1999-09-27 18:44:28 +00:00
|
|
|
/// check for file existance or not.
|
|
|
|
bool dostat;
|
|
|
|
//@}
|
|
|
|
|
|
|
|
/**@name Methods */
|
|
|
|
//@{
|
|
|
|
/** reads the .lyx_lastfiles at the beginning of the LyX session.
|
1999-11-04 01:40:20 +00:00
|
|
|
This will read the lastfiles file (usually .lyx_lastfiles). It
|
|
|
|
will normally discard files that don't exist anymore, unless
|
|
|
|
LastFiles has been initialized with dostat = false.
|
|
|
|
*/
|
1999-10-02 16:21:10 +00:00
|
|
|
void readFile(string const &);
|
1999-09-27 18:44:28 +00:00
|
|
|
/// used by the constructor to set the number of stored last files.
|
1999-11-04 01:40:20 +00:00
|
|
|
void setNumberOfFiles(unsigned int num);
|
1999-09-27 18:44:28 +00:00
|
|
|
//@}
|
|
|
|
};
|
|
|
|
#endif
|