#include FORMS_H_LOCATION
#include "lyxvc.h"
-#include "error.h"
+#include "debug.h"
#include "lyx_gui_misc.h"
#include "bufferlist.h"
-#include "syscall.h"
-#include "pathstack.h"
-#include "filetools.h"
-#include "FileInfo.h"
+#include "support/syscall.h"
+#include "support/path.h"
+#include "support/filetools.h"
+#include "support/FileInfo.h"
#include "gettext.h"
#include "LyXView.h"
#include "lyxfunc.h"
}
-bool LyXVC::file_found_hook(LString const & fn)
+bool LyXVC::file_found_hook(string const & fn)
{
- LString tmp(fn);
+ string tmp(fn);
FileInfo f;
// Check if *,v exists.
tmp += ",v";
- lyxerr.debug(LString("Checking if file is under vc: ") + tmp, Error::LYXVC);
+ lyxerr[Debug::LYXVC] << "Checking if file is under vc: "
+ << tmp << endl;
if (f.newFile(tmp).readable()) {
- lyxerr.debug("Yes it is under vc.", Error::LYXVC);
+ lyxerr[Debug::LYXVC] << "Yes it is under vc." << endl;
master = tmp;
backend = RCS_VCS;
scanMaster();
// Check if RCS/*,v exists.
tmp = AddName(AddPath(OnlyPath(fn), "RCS"), fn);
tmp += ",v";
- lyxerr.debug("Checking if file is under vc: " + tmp, Error::LYXVC);
+ lyxerr[Debug::LYXVC] << "Checking if file is under vc: "
+ << tmp << endl;
if (f.newFile(tmp).readable()) {
- lyxerr.debug("Yes it is under vc.", Error::LYXVC);
+ lyxerr[Debug::LYXVC] << "Yes it is under vc."<< endl;
master = tmp;
backend = RCS_VCS;
scanMaster();
}
-bool LyXVC::file_not_found_hook(LString const &)
+bool LyXVC::file_not_found_hook(string const &)
{
// file is not under any VCS.
return false;
void LyXVC::scanMaster()
{
- lyxerr.debug("LyXVC: This file is a VC file.", Error::LYXVC);
+ lyxerr[Debug::LYXVC] << "LyXVC: This file is a VC file." << endl;
- LyXLex lex(NULL, 0);
+ LyXLex lex(0, 0);
lex.setFile(master);
- LString token;
+ string token;
bool read_enough = false;
while (lex.IsOK() && !read_enough) {
lex.next();
token = lex.GetString();
- lyxerr.debug("LyXVC::scanMaster: current lex text: `"
- +token+"'", Error::LYXVC);
+ lyxerr[Debug::LYXVC] <<"LyXVC::scanMaster: current lex text: `"
+ << token << "'" << endl;
if (token.empty())
continue;
else if (token == "head") {
// get version here
lex.next();
- LString tmv = lex.GetString();
- tmv.strip(';');
+ string tmv = strip(lex.GetString(), ';');
version = tmv;
- } else if (token.contains("access")
- || token.contains("symbols")
- || token.contains("strict")) {
+ } else if (contains(token, "access")
+ || contains(token, "symbols")
+ || contains(token, "strict")) {
// nothing
- } else if (token.contains("locks")) {
+ } else if (contains(token, "locks")) {
// get locker here
- if (token.contains(";")) {
+ if (contains(token, ";")) {
locker = "Unlocked";
vcstat = UNLOCKED;
continue;
}
- LString tmpt, s1, s2;
+ string tmpt, s1, s2;
do {
lex.next();
- tmpt = lex.GetString();
- s1 = tmpt;
- s1.strip(';');
+ s1 = strip(tmpt = lex.GetString(), ';');
// tmp is now in the format <user>:<version>
- s1.split(s2, ':');
+ s1 = split(s1, s2, ':');
// s2 is user, and s1 is version
if (s1 == version) {
locker = s2;
vcstat = LOCKED;
break;
}
- } while (!tmpt.contains(";"));
+ } while (!contains(tmpt, ";"));
} else if (token == "comment") {
// we don't need to read any further than this.
read_enough = true;
} else {
// unexpected
- lyxerr.debug("LyXVC::scanMaster(): unexpected token", Error::LYXVC);
+ lyxerr[Debug::LYXVC]
+ << "LyXVC::scanMaster(): unexpected token"
+ << endl;
}
}
}
return;
}
- lyxerr.debug("LyXVC: registrer", Error::LYXVC);
- LString tmp = askForText(_("LyX VC: Initial description"),
+ lyxerr[Debug::LYXVC] << "LyXVC: registrer" << endl;
+ string tmp = askForText(_("LyX VC: Initial description"),
_("(no initial description)"));
if (tmp.empty()) {
- lyxerr.debug("LyXVC: user cancelled", Error::LYXVC);
+ lyxerr[Debug::LYXVC] << "LyXVC: user cancelled" << endl;
WriteAlert(_("Info"), _("This document has NOT been registered."));
return;
}
- LString cmd = "ci -q -u -i -t-\"";
+ string cmd = "ci -q -u -i -t-\"";
cmd += tmp;
cmd += "\" \"";
cmd += OnlyFilename(_owner->getFileName());
return;
}
- lyxerr.debug("LyXVC: checkIn", Error::LYXVC);
+ lyxerr[Debug::LYXVC] << "LyXVC: checkIn" << endl;
_owner->getUser()->getOwner()->getLyXFunc()->Dispatch(LFUN_MENUWRITE);
- LString tmp = askForText(_("LyX VC: Log Message"));
+ string tmp = askForText(_("LyX VC: Log Message"));
if (tmp.empty()) tmp = "(no log msg)";
doVCCommand("ci -q -u -m\"" + tmp + "\" \""
+ OnlyFilename(_owner->getFileName()) + "\"");
void LyXVC::checkOut()
{
- lyxerr.debug("LyXVC: checkOut", Error::LYXVC);
+ lyxerr[Debug::LYXVC] << "LyXVC: checkOut" << endl;
if (!_owner->isLyxClean()
&& !AskQuestion(_("Changes in document:"),
MakeDisplayPath(_owner->getFileName(),50),
void LyXVC::revert()
{
- lyxerr.debug("LyXVC: revert", Error::LYXVC);
+ lyxerr[Debug::LYXVC] << "LyXVC: revert" << endl;
// Here we should check if the buffer is dirty. And if it is
// we should warn the user that reverting will discard all
// changes made since the last check in.
void LyXVC::undoLast()
{
- lyxerr.debug("LyXVC: undoLast", Error::LYXVC);
+ lyxerr[Debug::LYXVC] << "LyXVC: undoLast" << endl;
doVCCommand("rcs -o" + getVersion() + " \""
+ OnlyFilename(_owner->getFileName()) + "\"");
}
}
-LString const LyXVC::getVersion() const
+string const LyXVC::getVersion() const
{
return version;
}
-LString const LyXVC::getLocker() const
+string const LyXVC::getLocker() const
{
return locker;
}
fl_hide_form(This->browser->LaTeXLog);
}
+// and, hack over hack, here is a C wrapper :)
+extern "C" void C_LyXVC_logClose(FL_OBJECT *ob, long data)
+{
+ LyXVC::logClose(ob, data);
+}
+
void LyXVC::logUpdate(FL_OBJECT *obj, long)
{
This->showLog();
}
+extern "C" void C_LyXVC_logUpdate(FL_OBJECT *ob, long data)
+{
+ LyXVC::logUpdate(ob, data);
+}
+
-void LyXVC::viewLog(LString const & fil)
+void LyXVC::viewLog(string const & fil)
{
+ static int ow = -1, oh;
+
if (!browser) {
FL_OBJECT *obj;
browser = (FD_LaTeXLog *) fl_calloc(1, sizeof(*browser));
browser->browser_latexlog = fl_add_browser(FL_NORMAL_BROWSER, 10, 10, 450, 320, "");
obj = fl_add_button(FL_RETURN_BUTTON, 270, 340, 90, 30, _("Close"));
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
- fl_set_object_callback(obj, logClose, 0);
+ fl_set_object_callback(obj, C_LyXVC_logClose, 0);
obj = fl_add_button(FL_NORMAL_BUTTON,370,340,90,30,
idex(_("Update|#Uu")));
fl_set_button_shortcut(obj,scex(_("Update|#Uu")),1);
fl_set_object_lsize(obj,FL_NORMAL_SIZE);
- fl_set_object_callback(obj,logUpdate,0);
+ fl_set_object_callback(obj, C_LyXVC_logUpdate,0);
fl_end_form();
- fl_set_form_atclose(browser->LaTeXLog, CancelCloseBoxCB, NULL);
+ fl_set_form_atclose(browser->LaTeXLog, CancelCloseBoxCB, 0);
}
if (!fl_load_browser(browser->browser_latexlog, fil.c_str()))
fl_show_form(browser->LaTeXLog,
FL_PLACE_MOUSE | FL_FREE_SIZE, FL_FULLBORDER,
_("RCS History"));
+ if (ow < 0) {
+ ow = browser->LaTeXLog->w;
+ oh = browser->LaTeXLog->h;
+ }
+ fl_set_form_minsize(browser->LaTeXLog, ow, oh);
}
}
return;
}
#endif
- LString tmpf = tmpnam(NULL);
+ string tmpf = tmpnam(0);
doVCCommand("rlog \""
+ OnlyFilename(_owner->getFileName()) + "\" > " + tmpf);
viewLog(tmpf);
}
-int LyXVC::doVCCommand(LString const & cmd)
+int LyXVC::doVCCommand(string const & cmd)
{
- lyxerr.debug("doVCCommand: " + cmd, Error::LYXVC);
+ lyxerr[Debug::LYXVC] << "doVCCommand: " << cmd << endl;
Systemcalls one;
- PathPush(_owner->filepath);
- int ret = one.Startscript(Systemcalls::System, cmd);
- PathPop();
+ Path p(_owner->filepath);
+ int ret = one.startscript(Systemcalls::System, cmd);
return ret;
}