2003-08-23 00:17:00 +00:00
|
|
|
|
/**
|
2007-04-28 20:44:46 +00:00
|
|
|
|
* \file callback.cpp
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
2002-03-21 17:27:08 +00:00
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* \author Lars Gullik Bj<EFBFBD>nnes
|
|
|
|
|
* \author Angus Leeming
|
|
|
|
|
* \author John Levon
|
|
|
|
|
* \author Andr<EFBFBD> P<EFBFBD>nitz
|
|
|
|
|
* \author J<EFBFBD>rgen Vigna
|
2002-03-21 17:27:08 +00:00
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
|
*/
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
2007-04-28 20:44:46 +00:00
|
|
|
|
#include "callback.h"
|
2003-09-06 18:38:02 +00:00
|
|
|
|
|
2007-04-26 04:41:58 +00:00
|
|
|
|
#include "Buffer.h"
|
|
|
|
|
#include "BufferList.h"
|
2003-09-06 18:38:02 +00:00
|
|
|
|
#include "BufferView.h"
|
2006-07-13 16:37:55 +00:00
|
|
|
|
#include "buffer_funcs.h"
|
2007-04-26 14:56:30 +00:00
|
|
|
|
#include "Cursor.h"
|
2007-02-25 20:16:45 +00:00
|
|
|
|
#include "CutAndPaste.h"
|
2001-07-29 15:34:18 +00:00
|
|
|
|
#include "debug.h"
|
2003-09-06 18:38:02 +00:00
|
|
|
|
#include "gettext.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
|
#include "Session.h"
|
2005-01-28 14:50:23 +00:00
|
|
|
|
#include "LaTeXFeatures.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
|
#include "LyX.h"
|
2007-04-29 18:58:28 +00:00
|
|
|
|
#include "Layout.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
|
#include "LyXRC.h"
|
2007-04-29 23:33:02 +00:00
|
|
|
|
#include "Text.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
|
#include "Paragraph.h"
|
|
|
|
|
#include "Undo.h"
|
2001-12-28 13:26:54 +00:00
|
|
|
|
|
2007-04-28 20:44:46 +00:00
|
|
|
|
#include "frontends/alert.h"
|
2006-09-27 10:24:13 +00:00
|
|
|
|
#include "frontends/Application.h"
|
2001-03-28 14:51:25 +00:00
|
|
|
|
#include "frontends/FileDialog.h"
|
2006-11-01 13:14:21 +00:00
|
|
|
|
#include "frontends/LyXView.h"
|
2001-12-28 13:26:54 +00:00
|
|
|
|
|
Rename files in src/support, step one.
src/support/package.h src/support/Package.h Package
src/support/package.C.in src/support/Package.C.in Package
src/support/path.h src/support/Path.h Path
src/support/fs_extras.h src/support/fs_extras.h NOCLASSES
src/support/RandomAccessList.h src/support/RandomAccessList.h RandomAccessList
src/support/lyxmanip.h src/support/lyxmanip.h NOCLASSES
src/support/rename.C src/support/rename.cpp NOCLASSES
src/support/abort.C src/support/abort.cpp NOCLASSES
src/support/lyxlib.h src/support/lyxlib.h NOCLASSES
src/support/ExceptionMessage.h src/support/ExceptionMessage.h ExceptionMessage
src/support/copy.C src/support/copy.cpp NOCLASSES
src/support/limited_stack.h src/support/limited_stack.h limited_stack
src/support/filefilterlist.C src/support/FileFilterList.cpp ['FileFilterList', 'Filter']
src/support/cow_ptr.h src/support/cow_ptr.h cow_ptr
src/support/os_unix.C src/support/os_unix.cpp NOCLASSES
src/support/socktools.h src/support/socktools.h NOCLASSES
src/support/forkedcontr.h src/support/ForkedcallsController.h ForkedcallsController
src/support/os.h src/support/os.h NOCLASSES
src/support/FileMonitor.h src/support/FileMonitor.h FileMonitor
src/support/copied_ptr.h src/support/copied_ptr.h copied_ptr
src/support/translator.h src/support/Translator.h Translator
src/support/filetools.C src/support/filetools.cpp NOCLASSES
src/support/unlink.C src/support/unlink.cpp NOCLASSES
src/support/os_win32.C src/support/os_win32.cpp GetFolderPath
src/support/lstrings.C src/support/lstrings.cpp NOCLASSES
src/support/qstring_helpers.C src/support/qstring_helpers.cpp NOCLASSES
src/support/getcwd.C src/support/getcwd.cpp NOCLASSES
src/support/systemcall.C src/support/Systemcall.cpp Systemcall
src/support/lyxalgo.h src/support/lyxalgo.h NOCLASSES
src/support/filefilterlist.h src/support/FileFilterList.h ['FileFilterList', 'Filter']
src/support/unicode.C src/support/unicode.cpp IconvProcessor
src/support/userinfo.C src/support/userinfo.cpp NOCLASSES
src/support/lyxtime.C src/support/lyxtime.cpp NOCLASSES
src/support/kill.C src/support/kill.cpp NOCLASSES
src/support/docstring.C src/support/docstring.cpp to_local8bit_failure
src/support/os_cygwin.C src/support/os_cygwin.cpp NOCLASSES
src/support/lyxsum.C src/support/lyxsum.cpp NOCLASSES
src/support/environment.C src/support/environment.cpp NOCLASSES
src/support/filetools.h src/support/filetools.h NOCLASSES
src/support/textutils.C src/support/textutils.cpp NOCLASSES
src/support/mkdir.C src/support/mkdir.cpp NOCLASSES
src/support/forkedcall.C src/support/Forkedcall.cpp ['ForkedProcess', 'Forkedcall']
src/support/tempname.C src/support/tempname.cpp NOCLASSES
src/support/os_win32.h src/support/os_win32.h GetFolderPath
src/support/types.h src/support/types.h NOCLASSES
src/support/lstrings.h src/support/lstrings.h NOCLASSES
src/support/forkedcallqueue.C src/support/ForkedCallQueue.cpp ForkedCallQueue
src/support/qstring_helpers.h src/support/qstring_helpers.h NOCLASSES
src/support/convert.C src/support/convert.cpp NOCLASSES
src/support/filename.C src/support/FileName.cpp ['FileName', 'DocFileName']
src/support/tests/convert.C src/support/tests/convert.cpp NOCLASSES
src/support/tests/filetools.C src/support/tests/filetools.cpp NOCLASSES
src/support/tests/lstrings.C src/support/tests/lstrings.cpp NOCLASSES
src/support/tests/boost.C src/support/tests/boost.cpp NOCLASSES
src/support/docstream.C src/support/docstream.cpp ['iconv_codecvt_facet_exception', 'idocfstream', 'odocfstream']
src/support/std_istream.h src/support/std_istream.h NOCLASSES
src/support/systemcall.h src/support/Systemcall.h Systemcall
src/support/chdir.C src/support/chdir.cpp NOCLASSES
src/support/std_ostream.h src/support/std_ostream.h NOCLASSES
src/support/unicode.h src/support/unicode.h IconvProcessor
src/support/path.C src/support/Path.cpp Path
src/support/fs_extras.C src/support/fs_extras.cpp NOCLASSES
src/support/userinfo.h src/support/userinfo.h NOCLASSES
src/support/lyxtime.h src/support/lyxtime.h NOCLASSES
src/support/docstring.h src/support/docstring.h to_local8bit_failure
src/support/debugstream.h src/support/debugstream.h basic_debugstream
src/support/environment.h src/support/environment.h NOCLASSES
src/support/textutils.h src/support/textutils.h NOCLASSES
src/support/forkedcall.h src/support/Forkedcall.h ['ForkedProcess', 'Forkedcall']
src/support/socktools.C src/support/socktools.cpp NOCLASSES
src/support/forkedcallqueue.h src/support/ForkedCallQueue.h ForkedCallQueue
src/support/forkedcontr.C src/support/ForkedcallsController.cpp ForkedcallsController
src/support/os.C src/support/os.cpp NOCLASSES
src/support/convert.h src/support/convert.h NOCLASSES
src/support/filename.h src/support/FileName.h ['FileName', 'DocFileName']
src/support/docstream.h src/support/docstream.h ['iconv_codecvt_facet_exception', 'idocfstream', 'odocfstream']
src/support/FileMonitor.C src/support/FileMonitor.cpp FileMonitor
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@18024 a592a061-630c-0410-9148-cb99ea01b6c8
2007-04-26 05:12:52 +00:00
|
|
|
|
#include "support/FileFilterList.h"
|
2000-04-12 14:20:08 +00:00
|
|
|
|
#include "support/filetools.h"
|
Rename files in src/support, step one.
src/support/package.h src/support/Package.h Package
src/support/package.C.in src/support/Package.C.in Package
src/support/path.h src/support/Path.h Path
src/support/fs_extras.h src/support/fs_extras.h NOCLASSES
src/support/RandomAccessList.h src/support/RandomAccessList.h RandomAccessList
src/support/lyxmanip.h src/support/lyxmanip.h NOCLASSES
src/support/rename.C src/support/rename.cpp NOCLASSES
src/support/abort.C src/support/abort.cpp NOCLASSES
src/support/lyxlib.h src/support/lyxlib.h NOCLASSES
src/support/ExceptionMessage.h src/support/ExceptionMessage.h ExceptionMessage
src/support/copy.C src/support/copy.cpp NOCLASSES
src/support/limited_stack.h src/support/limited_stack.h limited_stack
src/support/filefilterlist.C src/support/FileFilterList.cpp ['FileFilterList', 'Filter']
src/support/cow_ptr.h src/support/cow_ptr.h cow_ptr
src/support/os_unix.C src/support/os_unix.cpp NOCLASSES
src/support/socktools.h src/support/socktools.h NOCLASSES
src/support/forkedcontr.h src/support/ForkedcallsController.h ForkedcallsController
src/support/os.h src/support/os.h NOCLASSES
src/support/FileMonitor.h src/support/FileMonitor.h FileMonitor
src/support/copied_ptr.h src/support/copied_ptr.h copied_ptr
src/support/translator.h src/support/Translator.h Translator
src/support/filetools.C src/support/filetools.cpp NOCLASSES
src/support/unlink.C src/support/unlink.cpp NOCLASSES
src/support/os_win32.C src/support/os_win32.cpp GetFolderPath
src/support/lstrings.C src/support/lstrings.cpp NOCLASSES
src/support/qstring_helpers.C src/support/qstring_helpers.cpp NOCLASSES
src/support/getcwd.C src/support/getcwd.cpp NOCLASSES
src/support/systemcall.C src/support/Systemcall.cpp Systemcall
src/support/lyxalgo.h src/support/lyxalgo.h NOCLASSES
src/support/filefilterlist.h src/support/FileFilterList.h ['FileFilterList', 'Filter']
src/support/unicode.C src/support/unicode.cpp IconvProcessor
src/support/userinfo.C src/support/userinfo.cpp NOCLASSES
src/support/lyxtime.C src/support/lyxtime.cpp NOCLASSES
src/support/kill.C src/support/kill.cpp NOCLASSES
src/support/docstring.C src/support/docstring.cpp to_local8bit_failure
src/support/os_cygwin.C src/support/os_cygwin.cpp NOCLASSES
src/support/lyxsum.C src/support/lyxsum.cpp NOCLASSES
src/support/environment.C src/support/environment.cpp NOCLASSES
src/support/filetools.h src/support/filetools.h NOCLASSES
src/support/textutils.C src/support/textutils.cpp NOCLASSES
src/support/mkdir.C src/support/mkdir.cpp NOCLASSES
src/support/forkedcall.C src/support/Forkedcall.cpp ['ForkedProcess', 'Forkedcall']
src/support/tempname.C src/support/tempname.cpp NOCLASSES
src/support/os_win32.h src/support/os_win32.h GetFolderPath
src/support/types.h src/support/types.h NOCLASSES
src/support/lstrings.h src/support/lstrings.h NOCLASSES
src/support/forkedcallqueue.C src/support/ForkedCallQueue.cpp ForkedCallQueue
src/support/qstring_helpers.h src/support/qstring_helpers.h NOCLASSES
src/support/convert.C src/support/convert.cpp NOCLASSES
src/support/filename.C src/support/FileName.cpp ['FileName', 'DocFileName']
src/support/tests/convert.C src/support/tests/convert.cpp NOCLASSES
src/support/tests/filetools.C src/support/tests/filetools.cpp NOCLASSES
src/support/tests/lstrings.C src/support/tests/lstrings.cpp NOCLASSES
src/support/tests/boost.C src/support/tests/boost.cpp NOCLASSES
src/support/docstream.C src/support/docstream.cpp ['iconv_codecvt_facet_exception', 'idocfstream', 'odocfstream']
src/support/std_istream.h src/support/std_istream.h NOCLASSES
src/support/systemcall.h src/support/Systemcall.h Systemcall
src/support/chdir.C src/support/chdir.cpp NOCLASSES
src/support/std_ostream.h src/support/std_ostream.h NOCLASSES
src/support/unicode.h src/support/unicode.h IconvProcessor
src/support/path.C src/support/Path.cpp Path
src/support/fs_extras.C src/support/fs_extras.cpp NOCLASSES
src/support/userinfo.h src/support/userinfo.h NOCLASSES
src/support/lyxtime.h src/support/lyxtime.h NOCLASSES
src/support/docstring.h src/support/docstring.h to_local8bit_failure
src/support/debugstream.h src/support/debugstream.h basic_debugstream
src/support/environment.h src/support/environment.h NOCLASSES
src/support/textutils.h src/support/textutils.h NOCLASSES
src/support/forkedcall.h src/support/Forkedcall.h ['ForkedProcess', 'Forkedcall']
src/support/socktools.C src/support/socktools.cpp NOCLASSES
src/support/forkedcallqueue.h src/support/ForkedCallQueue.h ForkedCallQueue
src/support/forkedcontr.C src/support/ForkedcallsController.cpp ForkedcallsController
src/support/os.C src/support/os.cpp NOCLASSES
src/support/convert.h src/support/convert.h NOCLASSES
src/support/filename.h src/support/FileName.h ['FileName', 'DocFileName']
src/support/docstream.h src/support/docstream.h ['iconv_codecvt_facet_exception', 'idocfstream', 'odocfstream']
src/support/FileMonitor.C src/support/FileMonitor.cpp FileMonitor
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@18024 a592a061-630c-0410-9148-cb99ea01b6c8
2007-04-26 05:12:52 +00:00
|
|
|
|
#include "support/Forkedcall.h"
|
2005-01-31 10:42:26 +00:00
|
|
|
|
#include "support/fs_extras.h"
|
2003-09-04 01:44:16 +00:00
|
|
|
|
#include "support/lyxlib.h"
|
Rename files in src/support, step one.
src/support/package.h src/support/Package.h Package
src/support/package.C.in src/support/Package.C.in Package
src/support/path.h src/support/Path.h Path
src/support/fs_extras.h src/support/fs_extras.h NOCLASSES
src/support/RandomAccessList.h src/support/RandomAccessList.h RandomAccessList
src/support/lyxmanip.h src/support/lyxmanip.h NOCLASSES
src/support/rename.C src/support/rename.cpp NOCLASSES
src/support/abort.C src/support/abort.cpp NOCLASSES
src/support/lyxlib.h src/support/lyxlib.h NOCLASSES
src/support/ExceptionMessage.h src/support/ExceptionMessage.h ExceptionMessage
src/support/copy.C src/support/copy.cpp NOCLASSES
src/support/limited_stack.h src/support/limited_stack.h limited_stack
src/support/filefilterlist.C src/support/FileFilterList.cpp ['FileFilterList', 'Filter']
src/support/cow_ptr.h src/support/cow_ptr.h cow_ptr
src/support/os_unix.C src/support/os_unix.cpp NOCLASSES
src/support/socktools.h src/support/socktools.h NOCLASSES
src/support/forkedcontr.h src/support/ForkedcallsController.h ForkedcallsController
src/support/os.h src/support/os.h NOCLASSES
src/support/FileMonitor.h src/support/FileMonitor.h FileMonitor
src/support/copied_ptr.h src/support/copied_ptr.h copied_ptr
src/support/translator.h src/support/Translator.h Translator
src/support/filetools.C src/support/filetools.cpp NOCLASSES
src/support/unlink.C src/support/unlink.cpp NOCLASSES
src/support/os_win32.C src/support/os_win32.cpp GetFolderPath
src/support/lstrings.C src/support/lstrings.cpp NOCLASSES
src/support/qstring_helpers.C src/support/qstring_helpers.cpp NOCLASSES
src/support/getcwd.C src/support/getcwd.cpp NOCLASSES
src/support/systemcall.C src/support/Systemcall.cpp Systemcall
src/support/lyxalgo.h src/support/lyxalgo.h NOCLASSES
src/support/filefilterlist.h src/support/FileFilterList.h ['FileFilterList', 'Filter']
src/support/unicode.C src/support/unicode.cpp IconvProcessor
src/support/userinfo.C src/support/userinfo.cpp NOCLASSES
src/support/lyxtime.C src/support/lyxtime.cpp NOCLASSES
src/support/kill.C src/support/kill.cpp NOCLASSES
src/support/docstring.C src/support/docstring.cpp to_local8bit_failure
src/support/os_cygwin.C src/support/os_cygwin.cpp NOCLASSES
src/support/lyxsum.C src/support/lyxsum.cpp NOCLASSES
src/support/environment.C src/support/environment.cpp NOCLASSES
src/support/filetools.h src/support/filetools.h NOCLASSES
src/support/textutils.C src/support/textutils.cpp NOCLASSES
src/support/mkdir.C src/support/mkdir.cpp NOCLASSES
src/support/forkedcall.C src/support/Forkedcall.cpp ['ForkedProcess', 'Forkedcall']
src/support/tempname.C src/support/tempname.cpp NOCLASSES
src/support/os_win32.h src/support/os_win32.h GetFolderPath
src/support/types.h src/support/types.h NOCLASSES
src/support/lstrings.h src/support/lstrings.h NOCLASSES
src/support/forkedcallqueue.C src/support/ForkedCallQueue.cpp ForkedCallQueue
src/support/qstring_helpers.h src/support/qstring_helpers.h NOCLASSES
src/support/convert.C src/support/convert.cpp NOCLASSES
src/support/filename.C src/support/FileName.cpp ['FileName', 'DocFileName']
src/support/tests/convert.C src/support/tests/convert.cpp NOCLASSES
src/support/tests/filetools.C src/support/tests/filetools.cpp NOCLASSES
src/support/tests/lstrings.C src/support/tests/lstrings.cpp NOCLASSES
src/support/tests/boost.C src/support/tests/boost.cpp NOCLASSES
src/support/docstream.C src/support/docstream.cpp ['iconv_codecvt_facet_exception', 'idocfstream', 'odocfstream']
src/support/std_istream.h src/support/std_istream.h NOCLASSES
src/support/systemcall.h src/support/Systemcall.h Systemcall
src/support/chdir.C src/support/chdir.cpp NOCLASSES
src/support/std_ostream.h src/support/std_ostream.h NOCLASSES
src/support/unicode.h src/support/unicode.h IconvProcessor
src/support/path.C src/support/Path.cpp Path
src/support/fs_extras.C src/support/fs_extras.cpp NOCLASSES
src/support/userinfo.h src/support/userinfo.h NOCLASSES
src/support/lyxtime.h src/support/lyxtime.h NOCLASSES
src/support/docstring.h src/support/docstring.h to_local8bit_failure
src/support/debugstream.h src/support/debugstream.h basic_debugstream
src/support/environment.h src/support/environment.h NOCLASSES
src/support/textutils.h src/support/textutils.h NOCLASSES
src/support/forkedcall.h src/support/Forkedcall.h ['ForkedProcess', 'Forkedcall']
src/support/socktools.C src/support/socktools.cpp NOCLASSES
src/support/forkedcallqueue.h src/support/ForkedCallQueue.h ForkedCallQueue
src/support/forkedcontr.C src/support/ForkedcallsController.cpp ForkedcallsController
src/support/os.C src/support/os.cpp NOCLASSES
src/support/convert.h src/support/convert.h NOCLASSES
src/support/filename.h src/support/FileName.h ['FileName', 'DocFileName']
src/support/docstream.h src/support/docstream.h ['iconv_codecvt_facet_exception', 'idocfstream', 'odocfstream']
src/support/FileMonitor.C src/support/FileMonitor.cpp FileMonitor
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@18024 a592a061-630c-0410-9148-cb99ea01b6c8
2007-04-26 05:12:52 +00:00
|
|
|
|
#include "support/Package.h"
|
|
|
|
|
#include "support/Path.h"
|
|
|
|
|
#include "support/Systemcall.h"
|
2001-12-28 13:26:54 +00:00
|
|
|
|
|
2005-05-05 21:08:18 +00:00
|
|
|
|
#if !defined (HAVE_FORK)
|
2005-05-02 13:35:30 +00:00
|
|
|
|
# define fork() -1
|
|
|
|
|
#endif
|
|
|
|
|
|
2004-03-23 14:39:41 +00:00
|
|
|
|
#include <boost/shared_ptr.hpp>
|
2005-01-31 10:42:26 +00:00
|
|
|
|
#include <boost/filesystem/operations.hpp>
|
2004-03-23 14:39:41 +00:00
|
|
|
|
|
2003-09-05 22:17:02 +00:00
|
|
|
|
#include <cerrno>
|
2001-12-28 13:26:54 +00:00
|
|
|
|
#include <fstream>
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
|
|
|
|
|
|
using support::bformat;
|
|
|
|
|
using support::FileFilterList;
|
2006-11-26 21:30:39 +00:00
|
|
|
|
using support::FileName;
|
2006-10-21 00:16:43 +00:00
|
|
|
|
using support::ForkedProcess;
|
|
|
|
|
using support::isLyXFilename;
|
|
|
|
|
using support::libFileSearch;
|
|
|
|
|
using support::makeAbsPath;
|
|
|
|
|
using support::makeDisplayPath;
|
|
|
|
|
using support::onlyFilename;
|
|
|
|
|
using support::onlyPath;
|
|
|
|
|
using support::package;
|
|
|
|
|
using support::removeAutosaveFile;
|
|
|
|
|
using support::rename;
|
|
|
|
|
using support::split;
|
|
|
|
|
using support::Systemcall;
|
|
|
|
|
using support::tempName;
|
|
|
|
|
using support::unlink;
|
2003-09-16 11:03:20 +00:00
|
|
|
|
|
2004-03-23 14:39:41 +00:00
|
|
|
|
using boost::shared_ptr;
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
namespace Alert = frontend::Alert;
|
2005-01-31 10:42:26 +00:00
|
|
|
|
namespace fs = boost::filesystem;
|
|
|
|
|
|
2003-09-08 00:33:41 +00:00
|
|
|
|
using std::back_inserter;
|
2000-03-28 02:18:55 +00:00
|
|
|
|
using std::copy;
|
|
|
|
|
using std::endl;
|
2003-09-08 00:33:41 +00:00
|
|
|
|
using std::make_pair;
|
2003-10-06 15:43:21 +00:00
|
|
|
|
using std::string;
|
2003-09-08 00:33:41 +00:00
|
|
|
|
using std::ifstream;
|
2001-03-12 08:52:37 +00:00
|
|
|
|
using std::ios;
|
2000-03-28 02:18:55 +00:00
|
|
|
|
using std::istream_iterator;
|
|
|
|
|
|
2003-09-09 22:13:45 +00:00
|
|
|
|
|
2007-04-26 04:41:58 +00:00
|
|
|
|
// this should be static, but I need it in Buffer.cpp
|
1999-09-27 18:44:28 +00:00
|
|
|
|
bool quitting; // flag, that we are quitting the program
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Menu callbacks
|
|
|
|
|
//
|
|
|
|
|
|
2006-04-09 00:26:19 +00:00
|
|
|
|
bool menuWrite(Buffer * buffer)
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2003-03-29 07:09:13 +00:00
|
|
|
|
if (buffer->save()) {
|
2006-12-02 16:07:15 +00:00
|
|
|
|
LyX::ref().session().lastFiles().add(FileName(buffer->fileName()));
|
2003-03-29 07:09:13 +00:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// FIXME: we don't tell the user *WHY* the save failed !!
|
|
|
|
|
|
2006-09-11 08:54:10 +00:00
|
|
|
|
docstring const file = makeDisplayPath(buffer->fileName(), 30);
|
2003-03-29 07:09:13 +00:00
|
|
|
|
|
2006-09-11 08:54:10 +00:00
|
|
|
|
docstring text = bformat(_("The document %1$s could not be saved.\n\n"
|
|
|
|
|
"Do you want to rename the document and try again?"), file);
|
|
|
|
|
int const ret = Alert::prompt(_("Rename and save?"),
|
|
|
|
|
text, 0, 1, _("&Rename"), _("&Cancel"));
|
2003-03-29 07:09:13 +00:00
|
|
|
|
|
|
|
|
|
if (ret == 0)
|
2006-04-09 00:26:19 +00:00
|
|
|
|
return writeAs(buffer);
|
2003-03-29 07:09:13 +00:00
|
|
|
|
return false;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-03-07 14:25:31 +00:00
|
|
|
|
|
2006-12-05 12:57:01 +00:00
|
|
|
|
bool writeAs(Buffer * buffer, string const & newname)
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
1999-12-10 00:07:59 +00:00
|
|
|
|
string fname = buffer->fileName();
|
2001-12-28 13:26:54 +00:00
|
|
|
|
string const oldname = fname;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2006-12-05 12:57:01 +00:00
|
|
|
|
if (newname.empty()) {
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2006-10-09 16:33:20 +00:00
|
|
|
|
// FIXME UNICODE
|
|
|
|
|
FileDialog fileDlg(_("Choose a filename to save document as"),
|
2006-05-05 20:23:12 +00:00
|
|
|
|
LFUN_BUFFER_WRITE_AS,
|
2006-10-21 00:16:43 +00:00
|
|
|
|
make_pair(_("Documents|#o#O"), from_utf8(lyxrc.document_path)),
|
|
|
|
|
make_pair(_("Templates|#T#t"), from_utf8(lyxrc.template_path)));
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2006-04-08 09:09:57 +00:00
|
|
|
|
if (!isLyXFilename(fname))
|
2001-03-07 14:25:31 +00:00
|
|
|
|
fname += ".lyx";
|
2000-11-10 17:29:47 +00:00
|
|
|
|
|
2006-10-09 16:33:20 +00:00
|
|
|
|
FileFilterList const filter (_("LyX Documents (*.lyx)"));
|
2004-01-08 10:59:51 +00:00
|
|
|
|
|
2001-03-12 01:43:12 +00:00
|
|
|
|
FileDialog::Result result =
|
2006-10-21 00:16:43 +00:00
|
|
|
|
fileDlg.save(from_utf8(onlyPath(fname)),
|
2004-01-08 10:59:51 +00:00
|
|
|
|
filter,
|
2006-10-21 00:16:43 +00:00
|
|
|
|
from_utf8(onlyFilename(fname)));
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2001-03-07 14:25:31 +00:00
|
|
|
|
if (result.first == FileDialog::Later)
|
|
|
|
|
return false;
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
fname = to_utf8(result.second);
|
2001-03-07 14:25:31 +00:00
|
|
|
|
|
|
|
|
|
if (fname.empty())
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
// Make sure the absolute filename ends with appropriate suffix
|
2006-12-27 10:56:11 +00:00
|
|
|
|
fname = makeAbsPath(fname).absFilename();
|
2006-04-08 09:09:57 +00:00
|
|
|
|
if (!isLyXFilename(fname))
|
2001-03-07 14:25:31 +00:00
|
|
|
|
fname += ".lyx";
|
|
|
|
|
} else
|
2006-12-05 12:57:01 +00:00
|
|
|
|
fname = newname;
|
2000-11-10 17:29:47 +00:00
|
|
|
|
|
2006-12-05 12:57:01 +00:00
|
|
|
|
FileName const filename(fname);
|
|
|
|
|
if (fs::exists(filename.toFilesystemEncoding())) {
|
2006-09-11 08:54:10 +00:00
|
|
|
|
docstring const file = makeDisplayPath(fname, 30);
|
|
|
|
|
docstring text = bformat(_("The document %1$s already exists.\n\n"
|
2007-06-07 07:50:27 +00:00
|
|
|
|
"Do you want to overwrite that document?"), file);
|
|
|
|
|
int const ret = Alert::prompt(_("Overwrite document?"),
|
|
|
|
|
text, 0, 1, _("&Overwrite"), _("&Cancel"));
|
2003-03-29 07:09:13 +00:00
|
|
|
|
|
|
|
|
|
if (ret == 1)
|
2000-07-26 13:43:16 +00:00
|
|
|
|
return false;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Ok, change the name of the buffer
|
2001-03-07 14:25:31 +00:00
|
|
|
|
buffer->setFileName(fname);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
buffer->markDirty();
|
2000-08-08 15:36:25 +00:00
|
|
|
|
bool unnamed = buffer->isUnnamed();
|
2000-07-26 13:43:16 +00:00
|
|
|
|
buffer->setUnnamed(false);
|
2001-03-07 14:25:31 +00:00
|
|
|
|
|
2006-04-09 00:26:19 +00:00
|
|
|
|
if (!menuWrite(buffer)) {
|
2003-03-29 07:09:13 +00:00
|
|
|
|
buffer->setFileName(oldname);
|
|
|
|
|
buffer->setUnnamed(unnamed);
|
|
|
|
|
return false;
|
2000-08-08 15:36:25 +00:00
|
|
|
|
}
|
2003-03-29 07:09:13 +00:00
|
|
|
|
|
2000-08-08 15:36:25 +00:00
|
|
|
|
removeAutosaveFile(oldname);
|
2000-07-26 13:43:16 +00:00
|
|
|
|
return true;
|
2000-08-08 15:36:25 +00:00
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
|
2002-10-31 12:42:26 +00:00
|
|
|
|
namespace {
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2002-10-31 12:42:26 +00:00
|
|
|
|
class AutoSaveBuffer : public ForkedProcess {
|
|
|
|
|
public:
|
|
|
|
|
///
|
2006-11-26 21:30:39 +00:00
|
|
|
|
AutoSaveBuffer(BufferView & bv, FileName const & fname)
|
2002-10-31 12:42:26 +00:00
|
|
|
|
: bv_(bv), fname_(fname) {}
|
|
|
|
|
///
|
2004-03-23 14:39:41 +00:00
|
|
|
|
virtual shared_ptr<ForkedProcess> clone() const
|
|
|
|
|
{
|
|
|
|
|
return shared_ptr<ForkedProcess>(new AutoSaveBuffer(*this));
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
2002-10-31 12:42:26 +00:00
|
|
|
|
///
|
|
|
|
|
int start();
|
|
|
|
|
private:
|
|
|
|
|
///
|
|
|
|
|
virtual int generateChild();
|
|
|
|
|
///
|
|
|
|
|
BufferView & bv_;
|
2006-11-26 21:30:39 +00:00
|
|
|
|
FileName fname_;
|
2002-10-31 12:42:26 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int AutoSaveBuffer::start()
|
|
|
|
|
{
|
2006-11-26 21:30:39 +00:00
|
|
|
|
command_ = to_utf8(bformat(_("Auto-saving %1$s"), from_utf8(fname_.absFilename())));
|
2004-03-26 23:55:33 +00:00
|
|
|
|
return run(DontWait);
|
2002-10-31 12:42:26 +00:00
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2002-10-31 12:42:26 +00:00
|
|
|
|
int AutoSaveBuffer::generateChild()
|
|
|
|
|
{
|
1999-09-27 18:44:28 +00:00
|
|
|
|
// tmp_ret will be located (usually) in /tmp
|
|
|
|
|
// will that be a problem?
|
2000-11-14 02:01:57 +00:00
|
|
|
|
pid_t const pid = fork(); // If you want to debug the autosave
|
1999-09-27 18:44:28 +00:00
|
|
|
|
// you should set pid to -1, and comment out the
|
|
|
|
|
// fork.
|
|
|
|
|
if (pid == 0 || pid == -1) {
|
|
|
|
|
// pid = -1 signifies that lyx was unable
|
|
|
|
|
// to fork. But we will do the save
|
|
|
|
|
// anyway.
|
|
|
|
|
bool failed = false;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2006-12-27 10:56:11 +00:00
|
|
|
|
FileName const tmp_ret(tempName(FileName(), "lyxauto"));
|
1999-09-27 18:44:28 +00:00
|
|
|
|
if (!tmp_ret.empty()) {
|
2006-11-30 16:59:50 +00:00
|
|
|
|
bv_.buffer()->writeFile(tmp_ret);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
// assume successful write of tmp_ret
|
2003-06-30 23:56:22 +00:00
|
|
|
|
if (!rename(tmp_ret, fname_)) {
|
1999-09-27 18:44:28 +00:00
|
|
|
|
failed = true;
|
|
|
|
|
// most likely couldn't move between filesystems
|
|
|
|
|
// unless write of tmp_ret failed
|
|
|
|
|
// so remove tmp file (if it exists)
|
2003-06-30 23:56:22 +00:00
|
|
|
|
unlink(tmp_ret);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
failed = true;
|
|
|
|
|
}
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
if (failed) {
|
|
|
|
|
// failed to write/rename tmp_ret so try writing direct
|
2006-11-30 16:59:50 +00:00
|
|
|
|
if (!bv_.buffer()->writeFile(fname_)) {
|
1999-09-27 18:44:28 +00:00
|
|
|
|
// It is dangerous to do this in the child,
|
|
|
|
|
// but safe in the parent, so...
|
|
|
|
|
if (pid == -1)
|
2006-08-23 21:14:43 +00:00
|
|
|
|
// emit message signal.
|
2006-09-11 08:54:10 +00:00
|
|
|
|
bv_.buffer()->message(_("Autosave failed!"));
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (pid == 0) { // we are the child so...
|
|
|
|
|
_exit(0);
|
|
|
|
|
}
|
|
|
|
|
}
|
2002-10-31 12:42:26 +00:00
|
|
|
|
return pid;
|
|
|
|
|
}
|
2002-11-25 01:15:10 +00:00
|
|
|
|
|
2002-10-31 12:42:26 +00:00
|
|
|
|
} // namespace anon
|
|
|
|
|
|
|
|
|
|
|
2006-04-09 00:26:19 +00:00
|
|
|
|
void autoSave(BufferView * bv)
|
2002-10-31 12:42:26 +00:00
|
|
|
|
// should probably be moved into BufferList (Lgb)
|
|
|
|
|
// Perfect target for a thread...
|
|
|
|
|
{
|
2006-09-16 14:00:13 +00:00
|
|
|
|
if (!bv->buffer())
|
2002-10-31 12:42:26 +00:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (bv->buffer()->isBakClean() || bv->buffer()->isReadonly()) {
|
|
|
|
|
// We don't save now, but we'll try again later
|
2006-09-26 09:59:03 +00:00
|
|
|
|
bv->buffer()->resetAutosaveTimers();
|
2002-10-31 12:42:26 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2006-08-23 21:14:43 +00:00
|
|
|
|
// emit message signal.
|
2006-09-11 08:54:10 +00:00
|
|
|
|
bv->buffer()->message(_("Autosaving current document..."));
|
2002-10-31 12:42:26 +00:00
|
|
|
|
|
|
|
|
|
// create autosave filename
|
|
|
|
|
string fname = bv->buffer()->filePath();
|
2002-11-27 10:30:28 +00:00
|
|
|
|
fname += '#';
|
2006-04-08 22:31:11 +00:00
|
|
|
|
fname += onlyFilename(bv->buffer()->fileName());
|
2002-11-27 10:30:28 +00:00
|
|
|
|
fname += '#';
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2006-11-26 21:30:39 +00:00
|
|
|
|
AutoSaveBuffer autosave(*bv, FileName(fname));
|
2002-10-31 12:42:26 +00:00
|
|
|
|
autosave.start();
|
2002-11-25 01:15:10 +00:00
|
|
|
|
|
2000-04-11 22:55:29 +00:00
|
|
|
|
bv->buffer()->markBakClean();
|
2006-09-26 09:59:03 +00:00
|
|
|
|
bv->buffer()->resetAutosaveTimers();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
2000-03-09 03:36:48 +00:00
|
|
|
|
// Copyright CHT Software Service GmbH
|
1999-09-27 18:44:28 +00:00
|
|
|
|
// Uwe C. Schroeder
|
|
|
|
|
//
|
|
|
|
|
// create new file with template
|
|
|
|
|
// SERVERCMD !
|
|
|
|
|
//
|
2006-04-09 00:26:19 +00:00
|
|
|
|
void newFile(BufferView * bv, string const & filename)
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
|
|
|
|
// Split argument by :
|
1999-10-02 16:21:10 +00:00
|
|
|
|
string name;
|
1999-11-01 04:22:28 +00:00
|
|
|
|
string tmpname = split(filename, name, ':');
|
2007-04-01 10:09:49 +00:00
|
|
|
|
LYXERR(Debug::INFO) << "Arg is " << filename
|
2001-06-27 14:10:35 +00:00
|
|
|
|
<< "\nName is " << name
|
|
|
|
|
<< "\nTemplate is " << tmpname << endl;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2006-07-17 15:13:49 +00:00
|
|
|
|
Buffer * const b = newFile(name, tmpname);
|
|
|
|
|
if (b)
|
|
|
|
|
bv->setBuffer(b);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-01-15 22:49:14 +00:00
|
|
|
|
// Insert plain text file (if filename is empty, prompt for one)
|
|
|
|
|
void insertPlaintextFile(BufferView * bv, string const & f, bool asParagraph)
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2006-09-16 14:00:13 +00:00
|
|
|
|
if (!bv->buffer())
|
2001-03-07 14:25:31 +00:00
|
|
|
|
return;
|
2002-03-04 15:42:54 +00:00
|
|
|
|
|
2007-04-03 08:15:39 +00:00
|
|
|
|
docstring const tmpstr = getContentsOfPlaintextFile(bv, f, asParagraph);
|
2002-03-04 15:42:54 +00:00
|
|
|
|
if (tmpstr.empty())
|
|
|
|
|
return;
|
|
|
|
|
|
2007-04-26 14:56:30 +00:00
|
|
|
|
Cursor & cur = bv->cursor();
|
2007-02-25 20:16:45 +00:00
|
|
|
|
cap::replaceSelection(cur);
|
|
|
|
|
recordUndo(cur);
|
2003-11-10 09:06:48 +00:00
|
|
|
|
if (asParagraph)
|
2007-02-25 20:16:45 +00:00
|
|
|
|
cur.innerText()->insertStringAsParagraphs(cur, tmpstr);
|
2003-11-10 09:06:48 +00:00
|
|
|
|
else
|
2007-02-25 20:16:45 +00:00
|
|
|
|
cur.innerText()->insertStringAsLines(cur, tmpstr);
|
2002-03-04 15:42:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-04-03 08:15:39 +00:00
|
|
|
|
docstring const getContentsOfPlaintextFile(BufferView * bv, string const & f,
|
|
|
|
|
bool asParagraph)
|
2002-03-04 15:42:54 +00:00
|
|
|
|
{
|
2006-12-04 14:45:17 +00:00
|
|
|
|
FileName fname(f);
|
2002-03-04 15:42:54 +00:00
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
if (fname.empty()) {
|
2006-10-09 16:33:20 +00:00
|
|
|
|
FileDialog fileDlg(_("Select file to insert"),
|
2007-01-15 22:49:14 +00:00
|
|
|
|
(asParagraph) ? LFUN_FILE_INSERT_PLAINTEXT_PARA : LFUN_FILE_INSERT_PLAINTEXT);
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2004-01-08 10:59:51 +00:00
|
|
|
|
FileDialog::Result result =
|
2006-10-21 00:16:43 +00:00
|
|
|
|
fileDlg.open(from_utf8(bv->buffer()->filePath()),
|
2006-10-09 16:33:20 +00:00
|
|
|
|
FileFilterList(), docstring());
|
2001-03-07 14:25:31 +00:00
|
|
|
|
|
|
|
|
|
if (result.first == FileDialog::Later)
|
2007-04-03 08:15:39 +00:00
|
|
|
|
return docstring();
|
2001-03-07 14:25:31 +00:00
|
|
|
|
|
2006-12-27 10:56:11 +00:00
|
|
|
|
fname = makeAbsPath(to_utf8(result.second));
|
2001-03-07 14:25:31 +00:00
|
|
|
|
|
2002-03-21 17:27:08 +00:00
|
|
|
|
if (fname.empty())
|
2007-04-03 08:15:39 +00:00
|
|
|
|
return docstring();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2006-12-04 14:45:17 +00:00
|
|
|
|
if (!fs::is_readable(fname.toFilesystemEncoding())) {
|
2006-10-21 00:16:43 +00:00
|
|
|
|
docstring const error = from_ascii(strerror(errno));
|
2006-12-04 14:45:17 +00:00
|
|
|
|
docstring const file = makeDisplayPath(fname.absFilename(), 50);
|
2006-09-11 08:54:10 +00:00
|
|
|
|
docstring const text = bformat(_("Could not read the specified document\n"
|
|
|
|
|
"%1$s\ndue to the error: %2$s"), file, error);
|
|
|
|
|
Alert::error(_("Could not read file"), text);
|
2007-04-03 08:15:39 +00:00
|
|
|
|
return docstring();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
1999-11-24 22:14:46 +00:00
|
|
|
|
|
2006-12-04 14:45:17 +00:00
|
|
|
|
ifstream ifs(fname.toFilesystemEncoding().c_str());
|
2000-01-06 02:44:26 +00:00
|
|
|
|
if (!ifs) {
|
2006-10-21 00:16:43 +00:00
|
|
|
|
docstring const error = from_ascii(strerror(errno));
|
2006-12-04 14:45:17 +00:00
|
|
|
|
docstring const file = makeDisplayPath(fname.absFilename(), 50);
|
2006-09-11 08:54:10 +00:00
|
|
|
|
docstring const text = bformat(_("Could not open the specified document\n"
|
|
|
|
|
"%1$s\ndue to the error: %2$s"), file, error);
|
|
|
|
|
Alert::error(_("Could not open file"), text);
|
2007-04-03 08:15:39 +00:00
|
|
|
|
return docstring();
|
1999-11-24 22:14:46 +00:00
|
|
|
|
}
|
1999-11-15 12:01:38 +00:00
|
|
|
|
|
2000-03-28 02:18:55 +00:00
|
|
|
|
ifs.unsetf(ios::skipws);
|
|
|
|
|
istream_iterator<char> ii(ifs);
|
|
|
|
|
istream_iterator<char> end;
|
2000-07-24 21:49:58 +00:00
|
|
|
|
#if !defined(USE_INCLUDED_STRING) && !defined(STD_STRING_IS_GOOD)
|
|
|
|
|
// We use this until the compilers get better...
|
2003-09-08 00:33:41 +00:00
|
|
|
|
std::vector<char> tmp;
|
2000-07-24 21:49:58 +00:00
|
|
|
|
copy(ii, end, back_inserter(tmp));
|
2000-12-06 22:24:17 +00:00
|
|
|
|
string const tmpstr(tmp.begin(), tmp.end());
|
2000-07-24 21:49:58 +00:00
|
|
|
|
#else
|
|
|
|
|
// This is what we want to use and what we will use once the
|
2002-03-21 17:27:08 +00:00
|
|
|
|
// compilers get good enough.
|
2000-03-17 10:14:46 +00:00
|
|
|
|
//string tmpstr(ii, end); // yet a reason for using std::string
|
2000-03-16 04:29:22 +00:00
|
|
|
|
// alternate approach to get the file into a string:
|
2000-03-17 10:14:46 +00:00
|
|
|
|
string tmpstr;
|
|
|
|
|
copy(ii, end, back_inserter(tmpstr));
|
2000-07-24 21:49:58 +00:00
|
|
|
|
#endif
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2007-04-03 08:15:39 +00:00
|
|
|
|
// FIXME UNICODE: We don't know the encoding of the file
|
2007-05-15 18:45:23 +00:00
|
|
|
|
docstring file_content = from_utf8(tmpstr);
|
|
|
|
|
if (file_content.empty()) {
|
2007-05-28 22:27:45 +00:00
|
|
|
|
Alert::error(_("Reading not UTF-8 encoded file"),
|
2007-05-15 18:45:23 +00:00
|
|
|
|
_("The file is not UTF-8 encoded.\n"
|
|
|
|
|
"It will be read as local 8Bit-encoded.\n"
|
|
|
|
|
"If this does not give the correct result\n"
|
|
|
|
|
"then please change the encoding of the file\n"
|
|
|
|
|
"to UTF-8 with a program other than LyX.\n"));
|
|
|
|
|
file_content = from_local8bit(tmpstr);
|
|
|
|
|
}
|
2007-05-28 22:27:45 +00:00
|
|
|
|
|
2007-05-15 18:45:23 +00:00
|
|
|
|
return normalize_kc(file_content);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// This function runs "configure" and then rereads lyx.defaults to
|
|
|
|
|
// reconfigure the automatic settings.
|
2006-11-01 13:14:21 +00:00
|
|
|
|
void reconfigure(LyXView & lv)
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2006-08-23 21:14:43 +00:00
|
|
|
|
// emit message signal.
|
2006-11-01 13:14:21 +00:00
|
|
|
|
lv.message(_("Running configure..."));
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
// Run configure in user lyx directory
|
2006-10-21 00:16:43 +00:00
|
|
|
|
support::Path p(package().user_support());
|
2006-04-22 11:58:02 +00:00
|
|
|
|
string const configure_command = package().configure_command();
|
2002-02-18 19:13:48 +00:00
|
|
|
|
Systemcall one;
|
2005-01-05 10:08:34 +00:00
|
|
|
|
one.startscript(Systemcall::Wait, configure_command);
|
1999-10-13 17:32:46 +00:00
|
|
|
|
p.pop();
|
2006-08-23 21:14:43 +00:00
|
|
|
|
// emit message signal.
|
2006-11-01 13:14:21 +00:00
|
|
|
|
lv.message(_("Reloading configuration..."));
|
2006-04-08 22:31:11 +00:00
|
|
|
|
lyxrc.read(libFileSearch(string(), "lyxrc.defaults"));
|
2005-01-28 14:50:23 +00:00
|
|
|
|
// Re-read packages.lst
|
|
|
|
|
LaTeXFeatures::getAvailable();
|
2003-03-29 09:02:08 +00:00
|
|
|
|
|
2006-09-11 08:54:10 +00:00
|
|
|
|
Alert::information(_("System reconfigured"),
|
|
|
|
|
_("The system has been reconfigured.\n"
|
2006-09-09 15:27:44 +00:00
|
|
|
|
"You need to restart LyX to make use of any\n"
|
2006-09-11 08:54:10 +00:00
|
|
|
|
"updated document class specifications."));
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace lyx
|