#include "CutAndPaste.h"
#include "debug.h"
#include "DispatchResult.h"
+#include "EmbeddedFiles.h"
#include "ErrorList.h"
#include "factory.h"
#include "FloatList.h"
using support::FileFilterList;
using support::FileName;
using support::fileSearch;
-using support::isDirWriteable;
-using support::isFileReadable;
using support::makeDisplayPath;
using support::makeAbsPath;
using support::package;
bool same_content);
bool findNextInset(DocIterator & dit, vector<InsetCode> const & codes,
- string const & contents)
+ docstring const & contents)
{
DocIterator tmpdit = dit;
if (inset
&& find(codes.begin(), codes.end(), inset->lyxCode()) != codes.end()
&& (contents.empty() ||
- static_cast<InsetCommand const *>(inset)->getContents() == contents)) {
+ static_cast<InsetCommand const *>(inset)->getFirstNonOptParam() == contents)) {
dit = tmpdit;
return true;
}
}
-/// Looks for next inset with one of the the given code
+/// Looks for next inset with one of the given codes.
bool findInset(DocIterator & dit, vector<InsetCode> const & codes,
bool same_content)
{
- string contents;
+ docstring contents;
DocIterator tmpdit = dit;
tmpdit.forwardInset();
if (!tmpdit)
Inset const * inset = tmpdit.nextInset();
if (inset
&& find(codes.begin(), codes.end(), inset->lyxCode()) != codes.end()) {
- contents = static_cast<InsetCommand const *>(inset)->getContents();
+ contents = static_cast<InsetCommand const *>(inset)->getFirstNonOptParam();
}
}
// That is to say, if a cursor is in a nested inset, it will be
// restore to the left of the top level inset.
LyX::ref().session().lastFilePos().save(
- support::FileName(buffer_.fileName()),
+ support::FileName(buffer_.absFileName()),
boost::tie(d->cursor_.bottom().pit(), d->cursor_.bottom().pos()) );
delete d;
{
if (cursorStatus(d->cursor_) == CUR_INSIDE) {
frontend::FontMetrics const & fm =
- theFontMetrics(d->cursor_.getFont());
+ theFontMetrics(d->cursor_.getFont().fontInfo());
int const asc = fm.maxAscent();
int const des = fm.maxDescent();
Point const p = getPos(d->cursor_, d->cursor_.boundary());
// pit and pos will be updated with bottom level pit/pos
// when lyx exits.
LyX::ref().session().bookmarks().save(
- FileName(buffer_.fileName()),
+ FileName(buffer_.absFileName()),
d->cursor_.bottom().pit(),
d->cursor_.bottom().pos(),
d->cursor_.paragraph().id(),
switch (cmd.action) {
case LFUN_UNDO:
- flag.enabled(!buffer_.undo().hasUndoStack());
+ flag.enabled(buffer_.undo().hasUndoStack());
break;
case LFUN_REDO:
- flag.enabled(!buffer_.undo().hasRedoStack());
+ flag.enabled(buffer_.undo().hasRedoStack());
break;
case LFUN_FILE_INSERT:
case LFUN_FILE_INSERT_PLAINTEXT_PARA:
flag.setOnOff(buffer_.params().compressed);
break;
}
+
+ case LFUN_BUFFER_TOGGLE_EMBEDDING: {
+ flag.setOnOff(buffer_.params().embedded);
+ break;
+ }
case LFUN_SCREEN_UP:
case LFUN_SCREEN_DOWN:
LYXERR(Debug::INFO)
<< "Paragraph " << par->id()
<< " found in buffer `"
- << b->fileName() << "'." << endl;
+ << b->absFileName() << "'." << endl;
if (b == &buffer_) {
// Set the cursor
} else {
// Switch to other buffer view and resend cmd
theLyXFunc().dispatch(FuncRequest(
- LFUN_BUFFER_SWITCH, b->fileName()));
+ LFUN_BUFFER_SWITCH, b->absFileName()));
theLyXFunc().dispatch(cmd);
updateFlags = Update::None;
}
// turn compression on/off
buffer_.params().compressed = !buffer_.params().compressed;
break;
+
+ case LFUN_BUFFER_TOGGLE_EMBEDDING:
+ // turn embedding on/off
+ buffer_.embeddedFiles().enable(!buffer_.params().embedded);
+ break;
case LFUN_NEXT_INSET_TOGGLE: {
// this is the real function we want to invoke
d->cursor_.clearSelection();
d->cursor_.finishUndo();
+ d->cursor_.setCurrentFont();
return update;
}
string initpath = lyxrc.document_path;
string const trypath = buffer_.filePath();
// If directory is writeable, use this as default.
- if (isDirWriteable(FileName(trypath)))
+ if (FileName(trypath).isDirWritable())
initpath = trypath;
// FIXME UNICODE
- FileDialog fileDlg(_("Select LyX document to insert"),
- LFUN_FILE_INSERT,
- make_pair(_("Documents|#o#O"), from_utf8(lyxrc.document_path)),
- make_pair(_("Examples|#E#e"),
- from_utf8(addPath(package().system_support().absFilename(),
- "examples"))));
+ FileDialog dlg(_("Select LyX document to insert"), LFUN_FILE_INSERT);
+ dlg.setButton1(_("Documents|#o#O"), from_utf8(lyxrc.document_path));
+ dlg.setButton2(_("Examples|#E#e"),
+ from_utf8(addPath(package().system_support().absFilename(),
+ "examples")));
FileDialog::Result result =
- fileDlg.open(from_utf8(initpath),
+ dlg.open(from_utf8(initpath),
FileFilterList(_("LyX Documents (*.lyx)")),
docstring());
docstring res;
Buffer buf("", false);
- if (lyx::loadLyXFile(&buf, FileName(filename))) {
+ if (buf.loadLyXFile(FileName(filename))) {
ErrorList & el = buffer_.errorList("Parse");
// Copy the inserted document error list into the current buffer one.
el = buf.errorList("Parse");
cap::pasteParagraphList(d->cursor_, buf.paragraphs(),
buf.params().getTextClassPtr(), el);
res = _("Document %1$s inserted.");
- } else
+ } else {
res = _("Could not insert document %1$s");
+ }
// emit message signal.
message(bformat(res, disp_fn));
// lyxerr << "par ascent: " << text.getPar(d->metrics_info_.p1).ascent() << endl;
if (d->metrics_info_.y1 > 0
&& d->metrics_info_.update_strategy == FullScreenUpdate)
- pain.fillRectangle(0, 0, width_, d->metrics_info_.y1, Color::bottomarea);
+ pain.fillRectangle(0, 0, width_, d->metrics_info_.y1, Color_bottomarea);
// and possibly grey out below
// lyxerr << "par descent: " << text.getPar(d->metrics_info_.p1).ascent() << endl;
if (d->metrics_info_.y2 < height_
&& d->metrics_info_.update_strategy == FullScreenUpdate)
pain.fillRectangle(0, d->metrics_info_.y2, width_,
- height_ - d->metrics_info_.y2, Color::bottomarea);
+ height_ - d->metrics_info_.y2, Color_bottomarea);
}
FileName fname(f);
if (fname.empty()) {
- FileDialog fileDlg(_("Select file to insert"),
+ FileDialog dlg(_("Select file to insert"),
( asParagraph
? LFUN_FILE_INSERT_PLAINTEXT_PARA
: LFUN_FILE_INSERT_PLAINTEXT) );
FileDialog::Result result =
- fileDlg.open(from_utf8(buffer().filePath()),
+ dlg.open(from_utf8(buffer().filePath()),
FileFilterList(), docstring());
if (result.first == FileDialog::Later)