]> git.lyx.org Git - lyx.git/blob - src/lyxvc.h
removed a warning from screen and added CFLAGS in lyx.spec.in.
[lyx.git] / src / lyxvc.h
1 // -*- C++ -*-
2
3 #ifndef _LYX_VC_H_
4 #define _LYX_VC_H_
5
6 #ifdef __GNUG__
7 #pragma interface
8 #endif
9
10 #include "LString.h"
11 #include "latexoptions.h"
12
13 class Buffer;
14
15 /** Version Control for LyX. This is the class giving the verison control
16 features to LyX. It is
17   intended to support different kinds of version control, but at this point
18   we will only support RCS. Later CVS is a likely candidate for support.
19   The support in LyX is based loosely upon the version control in GNU Emacs,
20   but is not as extensive as that one. See examples/VC.lyx for a simple
21   tutorial and manual for the use of the version control system in LyX.
22
23   LyXVC use this algorithm when it searches for VC files:
24   for RCS it searches for <filename>,v and RCS/<filename>,v similar
25   should be done for CVS. By doing this there doesn't need to be any
26   special support for VC in the lyx format, and this is especially good
27   when the lyx format will be a subset of LaTeX.
28   */
29 class LyXVC {
30 public:
31         ///
32         LyXVC();
33         ///
34         ~LyXVC();
35         /** Not a good name perhaps. This function should be called whenever
36           LyX loads a file. This function then checks for a master VC file
37           (for RCS this is *,v or RCS/ *,v) if this file is found, the loaded
38           file is assumed to be under controll by VC (only RCS so far), and
39           the appropiate actions is taken. Returns true if the file is under
40           control by a VCS.
41           */
42         bool file_found_hook(string const & fn);
43         
44         /** This function should be run when a file is requested for loading,
45           but it does not exist. This function will then check for a VC master
46           file with the same name (see above function). If this exists the
47           user should be asked if he/her wants to checkout a version for
48           viewing/editing. Returns true if the file is under control by a VCS
49           and the user wants to view/edit it.
50           */
51         static bool file_not_found_hook(string const & fn);
52
53         ///
54         void scanMaster();
55         ///
56         void setBuffer(Buffer*);
57
58         /// Register the document as an VC file.
59         void registrer();
60
61         /// Unlock and commit changes.
62         void checkIn();
63
64         /// Lock and prepare to edit document.
65         void checkOut();
66
67         /// Revert to last version
68         void revert();
69
70         /// Undo last check-in.
71         void undoLast();
72
73         ///
74         void viewLog(string const &);
75
76         ///
77         void showLog();
78
79         /// 
80         void toggleReadOnly();
81         
82         /// Is the document under administration by RCS?
83         bool inUse();
84
85         /// Returns the version number.
86         string const getVersion() const;
87
88         /// Returns the userid of the person who has locked the doc.
89         string const getLocker() const;
90
91         ///
92         static void logClose(FL_OBJECT*, long);
93         ///
94         static void logUpdate(FL_OBJECT*, long);
95 protected:
96 private:
97         ///
98         int doVCCommand(string const&);
99         
100         /** The master VC file. For RCS this is *,v or RCS/ *,v. master should
101           have full path.
102           */
103         string master;
104
105         /** The version of the VC file. I am not sure if this can be a
106         string of if it must be a
107           float/int. */
108         string version;
109
110         /// The user currently keeping the lock on the VC file.
111         string locker;
112
113         ///
114         enum VCStatus {
115                 ///
116                 UNLOCKED,
117                 ///
118                 LOCKED
119         };
120
121         /// The status of the VC controlled file.
122         VCStatus vcstat;
123
124         ///     
125         enum Backend {
126                 ///
127                 UNKNOWN_VCS,
128                 ///
129                 RCS_VCS
130         };
131
132         /// The VC backend used. (so far this can only be RCS)
133         Backend backend;
134
135         /// The buffer using this VC
136         Buffer *_owner;
137
138         ///
139         FD_LaTeXLog *browser; // FD_LaTeXLog is just a browser with a
140         // close button. Unfortunately we can not use the standard callbacks.
141 };
142
143 #endif