#include "buffer.h"
#include "bufferlist.h"
#include "BufferView.h"
+#include "cursor.h"
#include "debug.h"
#include "gettext.h"
#include "lastfiles.h"
#include "support/FileInfo.h"
#include "support/filetools.h"
#include "support/forkedcall.h"
+#include "support/globbing.h"
#include "support/lyxlib.h"
#include "support/os.h"
#include "support/path.h"
using lyx::support::AddName;
using lyx::support::bformat;
using lyx::support::destroyDir;
+using lyx::support::FileFilterList;
using lyx::support::FileInfo;
using lyx::support::ForkedProcess;
using lyx::support::IsLyXFilename;
namespace os = lyx::support::os;
+using std::auto_ptr;
using std::back_inserter;
using std::copy;
using std::endl;
bool MenuWrite(Buffer * buffer)
{
if (buffer->save()) {
- lastfiles->newFile(buffer->fileName());
+ LyX::ref().lastfiles().newFile(buffer->fileName());
return true;
}
if (!IsLyXFilename(fname))
fname += ".lyx";
+ FileFilterList const filter (_("LyX Documents (*.lyx)"));
+
FileDialog::Result result =
fileDlg.save(OnlyPath(fname),
- _("*.lyx| LyX Documents (*.lyx)"),
- OnlyFilename(fname));
+ filter,
+ OnlyFilename(fname));
if (result.first == FileDialog::Later)
return false;
if (!bufferlist.quitWriteAll())
return;
- lastfiles->writeFile(lyxrc.lastfiles);
+ LyX::cref().lastfiles().writeFile(lyxrc.lastfiles);
}
// Set a flag that we do quitting from the program,
AutoSaveBuffer(BufferView & bv, string const & fname)
: bv_(bv), fname_(fname) {}
///
- virtual ForkedProcess * clone() const {
- return new AutoSaveBuffer(*this);
+ virtual auto_ptr<ForkedProcess> clone() const {
+ return auto_ptr<ForkedProcess>(new AutoSaveBuffer(*this));
}
///
int start();
return;
// clear the selection
- bool flag = (bv->text == bv->getLyXText());
- if (flag)
- bv->beforeChange(bv->text);
- if (!asParagraph)
- bv->getLyXText()->insertStringAsLines(tmpstr);
- else
+ if (bv->text() == bv->getLyXText())
+ bv->cursor().clearSelection();
+ if (asParagraph)
bv->getLyXText()->insertStringAsParagraphs(tmpstr);
+ else
+ bv->getLyXText()->insertStringAsLines(tmpstr);
bv->update();
}
FileDialog fileDlg(_("Select file to insert"),
(asParagraph) ? LFUN_FILE_INSERT_ASCII_PARA : LFUN_FILE_INSERT_ASCII);
- FileDialog::Result result = fileDlg.open(bv->owner()->buffer()->filePath());
+ FileDialog::Result result =
+ fileDlg.open(bv->owner()->buffer()->filePath(),
+ FileFilterList(), string());
if (result.first == FileDialog::Later)
return string();
string const getPossibleLabel(BufferView const & bv)
{
ParagraphList::iterator pit = bv.getLyXText()->cursorPar();
- ParagraphList & plist = bv.getLyXText()->ownerParagraphs();
+ ParagraphList & plist = bv.getLyXText()->paragraphs();
LyXLayout_ptr layout = pit->layout();
break;
string head;
par_text = split(par_text, head, ' ');
+ // Is it legal to use spaces in labels ?
if (i > 0)
- text += '-'; // Is it legal to use spaces in
- // labels ?
+ text += '-';
text += head;
}