mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 18:08:10 +00:00
some std::string -> filename changes
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21404 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
2fbc75b552
commit
09b7e6e60a
@ -1700,6 +1700,12 @@ void Buffer::markDirty()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
FileName Buffer::fileName() const
|
||||||
|
{
|
||||||
|
return pimpl_->filename;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
string Buffer::absFileName() const
|
string Buffer::absFileName() const
|
||||||
{
|
{
|
||||||
return pimpl_->filename.absFilename();
|
return pimpl_->filename.absFilename();
|
||||||
|
@ -236,6 +236,9 @@ public:
|
|||||||
/// Mark this buffer as dirty.
|
/// Mark this buffer as dirty.
|
||||||
void markDirty();
|
void markDirty();
|
||||||
|
|
||||||
|
/// Returns the buffer's filename. It is always an absolute path.
|
||||||
|
support::FileName fileName() const;
|
||||||
|
|
||||||
/// Returns the buffer's filename. It is always an absolute path.
|
/// Returns the buffer's filename. It is always an absolute path.
|
||||||
std::string absFileName() const;
|
std::string absFileName() const;
|
||||||
|
|
||||||
|
@ -99,10 +99,12 @@ bool BufferList::quitWriteBuffer(Buffer * buf)
|
|||||||
BOOST_ASSERT(buf);
|
BOOST_ASSERT(buf);
|
||||||
|
|
||||||
docstring file;
|
docstring file;
|
||||||
|
|
||||||
|
// FIXME: Unicode?
|
||||||
if (buf->isUnnamed())
|
if (buf->isUnnamed())
|
||||||
file = from_utf8(onlyFilename(buf->absFileName()));
|
file = from_utf8(buf->fileName().onlyFileName());
|
||||||
else
|
else
|
||||||
file = makeDisplayPath(buf->absFileName(), 30);
|
file = buf->fileName().displayName(30);
|
||||||
|
|
||||||
docstring const text =
|
docstring const text =
|
||||||
bformat(_("The document %1$s has unsaved changes.\n\n"
|
bformat(_("The document %1$s has unsaved changes.\n\n"
|
||||||
|
@ -14,8 +14,6 @@
|
|||||||
|
|
||||||
#include "support/docstring.h"
|
#include "support/docstring.h"
|
||||||
|
|
||||||
#include <boost/noncopyable.hpp>
|
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
|
||||||
@ -28,7 +26,7 @@ class OutputParams;
|
|||||||
* The class holds all all open buffers, and handles construction
|
* The class holds all all open buffers, and handles construction
|
||||||
* and deletions of new ones.
|
* and deletions of new ones.
|
||||||
*/
|
*/
|
||||||
class BufferList : boost::noncopyable {
|
class BufferList {
|
||||||
public:
|
public:
|
||||||
typedef std::vector<Buffer *>::iterator iterator;
|
typedef std::vector<Buffer *>::iterator iterator;
|
||||||
typedef std::vector<Buffer *>::const_iterator const_iterator;
|
typedef std::vector<Buffer *>::const_iterator const_iterator;
|
||||||
@ -106,6 +104,10 @@ public:
|
|||||||
void setCurrentAuthor(docstring const & name, docstring const & email);
|
void setCurrentAuthor(docstring const & name, docstring const & email);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
/// noncopiable
|
||||||
|
BufferList(BufferList const &);
|
||||||
|
void operator=(BufferList const &);
|
||||||
|
|
||||||
/// ask to save a buffer on quit, returns false if should cancel
|
/// ask to save a buffer on quit, returns false if should cancel
|
||||||
bool quitWriteBuffer(Buffer * buf);
|
bool quitWriteBuffer(Buffer * buf);
|
||||||
|
|
||||||
|
@ -423,8 +423,7 @@ BufferView::~BufferView()
|
|||||||
LastFilePosSection::FilePos fp;
|
LastFilePosSection::FilePos fp;
|
||||||
fp.pit = d->cursor_.bottom().pit();
|
fp.pit = d->cursor_.bottom().pit();
|
||||||
fp.pos = d->cursor_.bottom().pos();
|
fp.pos = d->cursor_.bottom().pos();
|
||||||
LyX::ref().session().lastFilePos().save(
|
LyX::ref().session().lastFilePos().save(buffer_.fileName(), fp);
|
||||||
support::FileName(buffer_.absFileName()), fp);
|
|
||||||
|
|
||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
@ -724,7 +723,7 @@ void BufferView::saveBookmark(unsigned int idx)
|
|||||||
// pit and pos will be updated with bottom level pit/pos
|
// pit and pos will be updated with bottom level pit/pos
|
||||||
// when lyx exits.
|
// when lyx exits.
|
||||||
LyX::ref().session().bookmarks().save(
|
LyX::ref().session().bookmarks().save(
|
||||||
FileName(buffer_.absFileName()),
|
buffer_.fileName(),
|
||||||
d->cursor_.bottom().pit(),
|
d->cursor_.bottom().pit(),
|
||||||
d->cursor_.bottom().pos(),
|
d->cursor_.bottom().pos(),
|
||||||
d->cursor_.paragraph().id(),
|
d->cursor_.paragraph().id(),
|
||||||
|
@ -60,7 +60,6 @@ using support::FileName;
|
|||||||
using support::DocFileName;
|
using support::DocFileName;
|
||||||
using support::makeAbsPath;
|
using support::makeAbsPath;
|
||||||
using support::addName;
|
using support::addName;
|
||||||
using support::onlyPath;
|
|
||||||
using support::absolutePath;
|
using support::absolutePath;
|
||||||
using support::onlyFilename;
|
using support::onlyFilename;
|
||||||
using support::makeRelPath;
|
using support::makeRelPath;
|
||||||
@ -155,7 +154,7 @@ bool EmbeddedFile::extract(Buffer const * buf) const
|
|||||||
// copy file
|
// copy file
|
||||||
try {
|
try {
|
||||||
// need to make directory?
|
// need to make directory?
|
||||||
string path = onlyPath(ext_file);
|
string path = support::onlyPath(ext_file);
|
||||||
if (!fs::is_directory(path))
|
if (!fs::is_directory(path))
|
||||||
makedir(const_cast<char*>(path.c_str()), 0755);
|
makedir(const_cast<char*>(path.c_str()), 0755);
|
||||||
fs::copy_file(emb_file, ext_file, false);
|
fs::copy_file(emb_file, ext_file, false);
|
||||||
@ -197,7 +196,7 @@ bool EmbeddedFile::updateFromExternalFile(Buffer const * buf) const
|
|||||||
// copy file
|
// copy file
|
||||||
try {
|
try {
|
||||||
// need to make directory?
|
// need to make directory?
|
||||||
string path = onlyPath(emb_file);
|
string path = support::onlyPath(emb_file);
|
||||||
if (!fs::is_directory(path))
|
if (!fs::is_directory(path))
|
||||||
makedir(const_cast<char*>(path.c_str()), 0755);
|
makedir(const_cast<char*>(path.c_str()), 0755);
|
||||||
fs::copy_file(ext_file, emb_file, false);
|
fs::copy_file(ext_file, emb_file, false);
|
||||||
|
@ -16,10 +16,6 @@
|
|||||||
#include "support/FileName.h"
|
#include "support/FileName.h"
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <utility>
|
|
||||||
|
|
||||||
#include "ParIterator.h"
|
|
||||||
#include "Paragraph.h"
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
||||||
@ -91,6 +87,7 @@ is why external filename will exist even if a file is at "EMBEDDED" status.
|
|||||||
namespace lyx {
|
namespace lyx {
|
||||||
|
|
||||||
class Buffer;
|
class Buffer;
|
||||||
|
class Inset;
|
||||||
class Lexer;
|
class Lexer;
|
||||||
class ErrorList;
|
class ErrorList;
|
||||||
|
|
||||||
|
@ -97,7 +97,6 @@
|
|||||||
#include "support/os.h"
|
#include "support/os.h"
|
||||||
|
|
||||||
#include <boost/current_function.hpp>
|
#include <boost/current_function.hpp>
|
||||||
#include <boost/filesystem/operations.hpp>
|
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
@ -110,8 +109,6 @@ using std::ostringstream;
|
|||||||
using std::find;
|
using std::find;
|
||||||
using std::vector;
|
using std::vector;
|
||||||
|
|
||||||
namespace fs = boost::filesystem;
|
|
||||||
|
|
||||||
namespace lyx {
|
namespace lyx {
|
||||||
|
|
||||||
using frontend::LyXView;
|
using frontend::LyXView;
|
||||||
@ -604,7 +601,7 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
|
|||||||
enable = buf->lyxvc().inUse();
|
enable = buf->lyxvc().inUse();
|
||||||
break;
|
break;
|
||||||
case LFUN_BUFFER_RELOAD:
|
case LFUN_BUFFER_RELOAD:
|
||||||
enable = !buf->isUnnamed() && fs::exists(buf->absFileName())
|
enable = !buf->isUnnamed() && buf->fileName().exists()
|
||||||
&& (!buf->isClean() || buf->isExternallyModified(Buffer::timestamp_method));
|
&& (!buf->isClean() || buf->isExternallyModified(Buffer::timestamp_method));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -856,7 +853,7 @@ bool LyXFunc::ensureBufferClean(BufferView * bv)
|
|||||||
if (buf.isClean())
|
if (buf.isClean())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
docstring const file = makeDisplayPath(buf.absFileName(), 30);
|
docstring const file = buf.fileName().displayName(30);
|
||||||
docstring text = bformat(_("The document %1$s has unsaved "
|
docstring text = bformat(_("The document %1$s has unsaved "
|
||||||
"changes.\n\nDo you want to save "
|
"changes.\n\nDo you want to save "
|
||||||
"the document?"), file);
|
"the document?"), file);
|
||||||
|
@ -32,7 +32,6 @@ namespace lyx {
|
|||||||
using support::bformat;
|
using support::bformat;
|
||||||
using support::FileName;
|
using support::FileName;
|
||||||
using support::makeAbsPath;
|
using support::makeAbsPath;
|
||||||
using support::makeDisplayPath;
|
|
||||||
using support::tempName;
|
using support::tempName;
|
||||||
|
|
||||||
using std::endl;
|
using std::endl;
|
||||||
@ -92,7 +91,7 @@ void LyXVC::setBuffer(Buffer * buf)
|
|||||||
|
|
||||||
void LyXVC::registrer()
|
void LyXVC::registrer()
|
||||||
{
|
{
|
||||||
FileName const filename(owner_->absFileName());
|
FileName const filename = owner_->fileName();
|
||||||
|
|
||||||
// there must be a file to save
|
// there must be a file to save
|
||||||
if (!filename.isFileReadable()) {
|
if (!filename.isFileReadable()) {
|
||||||
@ -109,14 +108,14 @@ void LyXVC::registrer()
|
|||||||
if (cvs_entries.isFileReadable()) {
|
if (cvs_entries.isFileReadable()) {
|
||||||
LYXERR(Debug::LYXVC)
|
LYXERR(Debug::LYXVC)
|
||||||
<< "LyXVC: registering "
|
<< "LyXVC: registering "
|
||||||
<< to_utf8(makeDisplayPath(filename.absFilename()))
|
<< to_utf8(filename.displayName())
|
||||||
<< " with CVS" << endl;
|
<< " with CVS" << endl;
|
||||||
vcs.reset(new CVS(cvs_entries, filename));
|
vcs.reset(new CVS(cvs_entries, filename));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
LYXERR(Debug::LYXVC)
|
LYXERR(Debug::LYXVC)
|
||||||
<< "LyXVC: registering "
|
<< "LyXVC: registering "
|
||||||
<< to_utf8(makeDisplayPath(filename.absFilename()))
|
<< to_utf8(filename.displayName())
|
||||||
<< " with RCS" << endl;
|
<< " with RCS" << endl;
|
||||||
vcs.reset(new RCS(filename));
|
vcs.reset(new RCS(filename));
|
||||||
}
|
}
|
||||||
@ -166,7 +165,7 @@ void LyXVC::revert()
|
|||||||
{
|
{
|
||||||
LYXERR(Debug::LYXVC) << "LyXVC: revert" << endl;
|
LYXERR(Debug::LYXVC) << "LyXVC: revert" << endl;
|
||||||
|
|
||||||
docstring const file = makeDisplayPath(owner_->absFileName(), 20);
|
docstring const file = owner_->fileName().displayName(20);
|
||||||
docstring text = bformat(_("Reverting to the stored version of the "
|
docstring text = bformat(_("Reverting to the stored version of the "
|
||||||
"document %1$s will lose all current changes.\n\n"
|
"document %1$s will lose all current changes.\n\n"
|
||||||
"Do you want to revert to the saved version?"), file);
|
"Do you want to revert to the saved version?"), file);
|
||||||
|
@ -139,9 +139,9 @@ docstring const MenuItem::binding(bool forgui) const
|
|||||||
// first one later
|
// first one later
|
||||||
KeyMap::Bindings bindings = theTopLevelKeymap().findBindings(func_);
|
KeyMap::Bindings bindings = theTopLevelKeymap().findBindings(func_);
|
||||||
|
|
||||||
if (bindings.size()) {
|
if (bindings.size())
|
||||||
return bindings.begin()->print(KeySequence::ForGui);
|
return bindings.begin()->print(KeySequence::ForGui);
|
||||||
} else {
|
|
||||||
LYXERR(Debug::KBMAP)
|
LYXERR(Debug::KBMAP)
|
||||||
<< "No binding for "
|
<< "No binding for "
|
||||||
<< lyxaction.getActionName(func_.action)
|
<< lyxaction.getActionName(func_.action)
|
||||||
@ -149,8 +149,6 @@ docstring const MenuItem::binding(bool forgui) const
|
|||||||
return docstring();
|
return docstring();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Menu & Menu::add(MenuItem const & i)
|
Menu & Menu::add(MenuItem const & i)
|
||||||
{
|
{
|
||||||
@ -494,8 +492,9 @@ void expandDocuments(Menu & tomenu)
|
|||||||
|
|
||||||
// We cannot use a for loop as the buffer list cycles.
|
// We cannot use a for loop as the buffer list cycles.
|
||||||
do {
|
do {
|
||||||
docstring label = makeDisplayPath(b->absFileName(), 20);
|
docstring label = b->fileName().displayName(20);
|
||||||
if (!b->isClean()) label = label + "*";
|
if (!b->isClean())
|
||||||
|
label = label + "*";
|
||||||
if (ii < 10)
|
if (ii < 10)
|
||||||
label = convert<docstring>(ii) + ". " + label + '|' + convert<docstring>(ii);
|
label = convert<docstring>(ii) + ". " + label + '|' + convert<docstring>(ii);
|
||||||
tomenu.add(MenuItem(MenuItem::Command, label,
|
tomenu.add(MenuItem(MenuItem::Command, label,
|
||||||
@ -507,7 +506,6 @@ void expandDocuments(Menu & tomenu)
|
|||||||
} else {
|
} else {
|
||||||
tomenu.add(MenuItem(MenuItem::Command, _("No Documents Open!"),
|
tomenu.add(MenuItem(MenuItem::Command, _("No Documents Open!"),
|
||||||
FuncRequest(LFUN_NOACTION)));
|
FuncRequest(LFUN_NOACTION)));
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,7 +186,7 @@ static void specialChar(Cursor & cur, InsetSpecialChar::Kind kind)
|
|||||||
static bool doInsertInset(Cursor & cur, Text * text,
|
static bool doInsertInset(Cursor & cur, Text * text,
|
||||||
FuncRequest const & cmd, bool edit, bool pastesel)
|
FuncRequest const & cmd, bool edit, bool pastesel)
|
||||||
{
|
{
|
||||||
Inset * inset = createInset(&cur.bv(), cmd);
|
Inset * inset = createInset(cur.bv().buffer(), cmd);
|
||||||
if (!inset)
|
if (!inset)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -687,7 +687,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
|
|||||||
|
|
||||||
case LFUN_INSET_INSERT: {
|
case LFUN_INSET_INSERT: {
|
||||||
cur.recordUndo();
|
cur.recordUndo();
|
||||||
Inset * inset = createInset(bv, cmd);
|
Inset * inset = createInset(bv->buffer(), cmd);
|
||||||
if (inset) {
|
if (inset) {
|
||||||
// FIXME (Abdel 01/02/2006):
|
// FIXME (Abdel 01/02/2006):
|
||||||
// What follows would be a partial fix for bug 2154:
|
// What follows would be a partial fix for bug 2154:
|
||||||
@ -1144,7 +1144,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
case LFUN_INFO_INSERT: {
|
case LFUN_INFO_INSERT: {
|
||||||
Inset * inset = createInset(&cur.bv(), cmd);
|
Inset * inset = createInset(cur.bv().buffer(), cmd);
|
||||||
if (!inset)
|
if (!inset)
|
||||||
break;
|
break;
|
||||||
// if an empty inset is created (cmd.argument() is empty)
|
// if an empty inset is created (cmd.argument() is empty)
|
||||||
@ -1244,8 +1244,13 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
|
|||||||
doInsertInset(cur, this, cmd, true, true);
|
doInsertInset(cur, this, cmd, true, true);
|
||||||
cur.posRight();
|
cur.posRight();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LFUN_NOMENCL_INSERT: {
|
case LFUN_NOMENCL_INSERT: {
|
||||||
Inset * inset = createInset(&cur.bv(), cmd);
|
FuncRequest cmd1 = cmd;
|
||||||
|
if (cmd.argument().empty())
|
||||||
|
cmd1 = FuncRequest(cmd,
|
||||||
|
bv->cursor().innerText()->getStringToIndex(bv->cursor()));
|
||||||
|
Inset * inset = createInset(cur.bv().buffer(), cmd1);
|
||||||
if (!inset)
|
if (!inset)
|
||||||
break;
|
break;
|
||||||
cur.recordUndo();
|
cur.recordUndo();
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
#include "factory.h"
|
#include "factory.h"
|
||||||
|
|
||||||
#include "Buffer.h"
|
#include "Buffer.h"
|
||||||
#include "BufferView.h"
|
|
||||||
#include "BufferParams.h"
|
#include "BufferParams.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "FloatList.h"
|
#include "FloatList.h"
|
||||||
@ -80,9 +79,9 @@ namespace Alert = frontend::Alert;
|
|||||||
using support::compare_ascii_no_case;
|
using support::compare_ascii_no_case;
|
||||||
|
|
||||||
|
|
||||||
Inset * createInset(BufferView * bv, FuncRequest const & cmd)
|
Inset * createInset(Buffer & buf, FuncRequest const & cmd)
|
||||||
{
|
{
|
||||||
BufferParams const & params = bv->buffer().params();
|
BufferParams const & params = buf.params();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
@ -154,7 +153,6 @@ Inset * createInset(BufferView * bv, FuncRequest const & cmd)
|
|||||||
if (params.getTextClass().floats().typeExist(argument))
|
if (params.getTextClass().floats().typeExist(argument))
|
||||||
return new InsetFloat(params, argument);
|
return new InsetFloat(params, argument);
|
||||||
lyxerr << "Non-existent float type: " << argument << endl;
|
lyxerr << "Non-existent float type: " << argument << endl;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case LFUN_FLOAT_WIDE_INSERT: {
|
case LFUN_FLOAT_WIDE_INSERT: {
|
||||||
@ -182,9 +180,7 @@ Inset * createInset(BufferView * bv, FuncRequest const & cmd)
|
|||||||
|
|
||||||
case LFUN_NOMENCL_INSERT: {
|
case LFUN_NOMENCL_INSERT: {
|
||||||
InsetCommandParams icp(NOMENCL_CODE);
|
InsetCommandParams icp(NOMENCL_CODE);
|
||||||
icp["symbol"] = cmd.argument().empty() ?
|
icp["symbol"] = cmd.argument();
|
||||||
bv->cursor().innerText()->getStringToIndex(bv->cursor()) :
|
|
||||||
cmd.argument();
|
|
||||||
return new InsetNomencl(icp);
|
return new InsetNomencl(icp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -198,7 +194,7 @@ Inset * createInset(BufferView * bv, FuncRequest const & cmd)
|
|||||||
r = 2;
|
r = 2;
|
||||||
if (c <= 0)
|
if (c <= 0)
|
||||||
c = 2;
|
c = 2;
|
||||||
return new InsetTabular(bv->buffer(), r, c);
|
return new InsetTabular(buf, r, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
case LFUN_CAPTION_INSERT: {
|
case LFUN_CAPTION_INSERT: {
|
||||||
@ -267,18 +263,16 @@ Inset * createInset(BufferView * bv, FuncRequest const & cmd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
case EXTERNAL_CODE: {
|
case EXTERNAL_CODE: {
|
||||||
Buffer const & buffer = bv->buffer();
|
|
||||||
InsetExternalParams iep;
|
InsetExternalParams iep;
|
||||||
InsetExternalMailer::string2params(to_utf8(cmd.argument()), buffer, iep);
|
InsetExternalMailer::string2params(to_utf8(cmd.argument()), buf, iep);
|
||||||
auto_ptr<InsetExternal> inset(new InsetExternal);
|
auto_ptr<InsetExternal> inset(new InsetExternal);
|
||||||
inset->setParams(iep, buffer);
|
inset->setParams(iep, buf);
|
||||||
return inset.release();
|
return inset.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
case GRAPHICS_CODE: {
|
case GRAPHICS_CODE: {
|
||||||
Buffer const & buffer = bv->buffer();
|
|
||||||
InsetGraphicsParams igp;
|
InsetGraphicsParams igp;
|
||||||
InsetGraphicsMailer::string2params(to_utf8(cmd.argument()), buffer, igp);
|
InsetGraphicsMailer::string2params(to_utf8(cmd.argument()), buf, igp);
|
||||||
auto_ptr<InsetGraphics> inset(new InsetGraphics);
|
auto_ptr<InsetGraphics> inset(new InsetGraphics);
|
||||||
inset->setParams(igp);
|
inset->setParams(igp);
|
||||||
return inset.release();
|
return inset.release();
|
||||||
@ -314,7 +308,7 @@ Inset * createInset(BufferView * bv, FuncRequest const & cmd)
|
|||||||
case REF_CODE: {
|
case REF_CODE: {
|
||||||
InsetCommandParams icp(code);
|
InsetCommandParams icp(code);
|
||||||
InsetCommandMailer::string2params(name, to_utf8(cmd.argument()), icp);
|
InsetCommandMailer::string2params(name, to_utf8(cmd.argument()), icp);
|
||||||
return new InsetRef(icp, bv->buffer());
|
return new InsetRef(icp, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
case TOC_CODE: {
|
case TOC_CODE: {
|
||||||
@ -341,21 +335,21 @@ Inset * createInset(BufferView * bv, FuncRequest const & cmd)
|
|||||||
string const name = to_utf8(cmd.argument());
|
string const name = to_utf8(cmd.argument());
|
||||||
if (name == "normal")
|
if (name == "normal")
|
||||||
return new InsetSpace(InsetSpace::NORMAL);
|
return new InsetSpace(InsetSpace::NORMAL);
|
||||||
else if (name == "protected")
|
if (name == "protected")
|
||||||
return new InsetSpace(InsetSpace::PROTECTED);
|
return new InsetSpace(InsetSpace::PROTECTED);
|
||||||
else if (name == "thin")
|
if (name == "thin")
|
||||||
return new InsetSpace(InsetSpace::THIN);
|
return new InsetSpace(InsetSpace::THIN);
|
||||||
else if (name == "quad")
|
if (name == "quad")
|
||||||
return new InsetSpace(InsetSpace::QUAD);
|
return new InsetSpace(InsetSpace::QUAD);
|
||||||
else if (name == "qquad")
|
if (name == "qquad")
|
||||||
return new InsetSpace(InsetSpace::QQUAD);
|
return new InsetSpace(InsetSpace::QQUAD);
|
||||||
else if (name == "enspace")
|
if (name == "enspace")
|
||||||
return new InsetSpace(InsetSpace::ENSPACE);
|
return new InsetSpace(InsetSpace::ENSPACE);
|
||||||
else if (name == "enskip")
|
if (name == "enskip")
|
||||||
return new InsetSpace(InsetSpace::ENSKIP);
|
return new InsetSpace(InsetSpace::ENSKIP);
|
||||||
else if (name == "negthinspace")
|
if (name == "negthinspace")
|
||||||
return new InsetSpace(InsetSpace::NEGTHIN);
|
return new InsetSpace(InsetSpace::NEGTHIN);
|
||||||
else if (name.empty())
|
if (name.empty())
|
||||||
lyxerr << "LyX function 'space' needs an argument." << endl;
|
lyxerr << "LyX function 'space' needs an argument." << endl;
|
||||||
else
|
else
|
||||||
lyxerr << "Wrong argument for LyX function 'space'." << endl;
|
lyxerr << "Wrong argument for LyX function 'space'." << endl;
|
||||||
|
@ -15,14 +15,13 @@
|
|||||||
namespace lyx {
|
namespace lyx {
|
||||||
|
|
||||||
class Buffer;
|
class Buffer;
|
||||||
class BufferView;
|
|
||||||
class FuncRequest;
|
class FuncRequest;
|
||||||
class Inset;
|
class Inset;
|
||||||
class Lexer;
|
class Lexer;
|
||||||
|
|
||||||
|
|
||||||
/// creates inset according to 'cmd'
|
/// creates inset according to 'cmd'
|
||||||
Inset * createInset(BufferView * bv, FuncRequest const & cmd);
|
Inset * createInset(Buffer & buf, FuncRequest const & cmd);
|
||||||
|
|
||||||
/// read inset from a file
|
/// read inset from a file
|
||||||
Inset * readInset(Lexer & lex, Buffer const & buf);
|
Inset * readInset(Lexer & lex, Buffer const & buf);
|
||||||
|
@ -544,7 +544,7 @@ void GuiViewBase::setWindowTitle(docstring const & t, docstring const & it)
|
|||||||
}
|
}
|
||||||
if (Buffer const * buf = buffer())
|
if (Buffer const * buf = buffer())
|
||||||
d.tab_widget_->setTabText(d.tab_widget_->currentIndex(),
|
d.tab_widget_->setTabText(d.tab_widget_->currentIndex(),
|
||||||
toqstr(makeDisplayPath(buf->absFileName(), 30)));
|
toqstr(buf->fileName().displayName(30)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -809,7 +809,7 @@ WorkArea * GuiViewBase::addWorkArea(Buffer & buffer)
|
|||||||
{
|
{
|
||||||
GuiWorkArea * wa = new GuiWorkArea(buffer, *this);
|
GuiWorkArea * wa = new GuiWorkArea(buffer, *this);
|
||||||
wa->setUpdatesEnabled(false);
|
wa->setUpdatesEnabled(false);
|
||||||
d.tab_widget_->addTab(wa, toqstr(makeDisplayPath(buffer.absFileName(), 30)));
|
d.tab_widget_->addTab(wa, toqstr(buffer.fileName().displayName(30)));
|
||||||
wa->bufferView().updateMetrics(false);
|
wa->bufferView().updateMetrics(false);
|
||||||
if (d.stack_widget_)
|
if (d.stack_widget_)
|
||||||
d.stack_widget_->setCurrentWidget(d.tab_widget_);
|
d.stack_widget_->setCurrentWidget(d.tab_widget_);
|
||||||
|
@ -67,7 +67,6 @@ using support::isLyXFilename;
|
|||||||
using support::isValidLaTeXFilename;
|
using support::isValidLaTeXFilename;
|
||||||
using support::latex_path;
|
using support::latex_path;
|
||||||
using support::makeAbsPath;
|
using support::makeAbsPath;
|
||||||
using support::makeDisplayPath;
|
|
||||||
using support::makeRelPath;
|
using support::makeRelPath;
|
||||||
using support::onlyFilename;
|
using support::onlyFilename;
|
||||||
using support::onlyPath;
|
using support::onlyPath;
|
||||||
@ -101,7 +100,8 @@ enum Types {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
Types type(std::string const & s) {
|
Types type(std::string const & s)
|
||||||
|
{
|
||||||
if (s == "input")
|
if (s == "input")
|
||||||
return INPUT;
|
return INPUT;
|
||||||
if (s == "verbatiminput")
|
if (s == "verbatiminput")
|
||||||
@ -118,8 +118,7 @@ Types type(std::string const & s) {
|
|||||||
|
|
||||||
Types type(InsetCommandParams const & params)
|
Types type(InsetCommandParams const & params)
|
||||||
{
|
{
|
||||||
string const command_name = params.getCmdName();
|
return type(params.getCmdName());
|
||||||
return type(command_name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -172,7 +171,8 @@ CommandInfo const * InsetInclude::findInfo(std::string const & /* cmdName */)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool InsetInclude::isCompatibleCommand(std::string const & s) {
|
bool InsetInclude::isCompatibleCommand(std::string const & s)
|
||||||
|
{
|
||||||
return type(s) != NONE;
|
return type(s) != NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -213,9 +213,9 @@ void InsetInclude::doDispatch(Cursor & cur, FuncRequest & cmd)
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
string const masterFilename(Buffer const & buffer)
|
FileName const masterFileName(Buffer const & buffer)
|
||||||
{
|
{
|
||||||
return buffer.masterBuffer()->absFileName();
|
return buffer.masterBuffer()->fileName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -416,7 +416,7 @@ int InsetInclude::latex(Buffer const & buffer, odocstream & os,
|
|||||||
docstring text = bformat(_("Included file `%1$s'\n"
|
docstring text = bformat(_("Included file `%1$s'\n"
|
||||||
"has textclass `%2$s'\n"
|
"has textclass `%2$s'\n"
|
||||||
"while parent file has textclass `%3$s'."),
|
"while parent file has textclass `%3$s'."),
|
||||||
makeDisplayPath(included_file.absFilename()),
|
included_file.displayName(),
|
||||||
from_utf8(tmp->params().getTextClass().name()),
|
from_utf8(tmp->params().getTextClass().name()),
|
||||||
from_utf8(masterBuffer->params().getTextClass().name()));
|
from_utf8(masterBuffer->params().getTextClass().name()));
|
||||||
Alert::warning(_("Different textclasses"), text);
|
Alert::warning(_("Different textclasses"), text);
|
||||||
@ -438,7 +438,7 @@ int InsetInclude::latex(Buffer const & buffer, odocstream & os,
|
|||||||
docstring text = bformat(_("Included file `%1$s'\n"
|
docstring text = bformat(_("Included file `%1$s'\n"
|
||||||
"uses module `%2$s'\n"
|
"uses module `%2$s'\n"
|
||||||
"which is not used in parent file."),
|
"which is not used in parent file."),
|
||||||
makeDisplayPath(included_file.absFilename()), from_utf8(module));
|
included_file.displayName(), from_utf8(module));
|
||||||
Alert::warning(_("Module not found"), text);
|
Alert::warning(_("Module not found"), text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -454,7 +454,7 @@ int InsetInclude::latex(Buffer const & buffer, odocstream & os,
|
|||||||
Encoding const * const oldEnc = runparams.encoding;
|
Encoding const * const oldEnc = runparams.encoding;
|
||||||
runparams.encoding = &tmp->params().encoding();
|
runparams.encoding = &tmp->params().encoding();
|
||||||
tmp->makeLaTeXFile(writefile,
|
tmp->makeLaTeXFile(writefile,
|
||||||
onlyPath(masterFilename(buffer)),
|
masterFileName(buffer).onlyPath(),
|
||||||
runparams, false);
|
runparams, false);
|
||||||
runparams.encoding = oldEnc;
|
runparams.encoding = oldEnc;
|
||||||
} else {
|
} else {
|
||||||
|
@ -116,6 +116,18 @@ bool FileName::isReadable() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
std::string FileName::onlyFileName() const
|
||||||
|
{
|
||||||
|
return support::onlyFilename(absFilename());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
std::string FileName::onlyPath() const
|
||||||
|
{
|
||||||
|
return support::onlyPath(absFilename());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool FileName::isFileReadable() const
|
bool FileName::isFileReadable() const
|
||||||
{
|
{
|
||||||
QFileInfo const fi(toqstr(name_));
|
QFileInfo const fi(toqstr(name_));
|
||||||
@ -175,6 +187,12 @@ bool FileName::createDirectory(int permission) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
docstring FileName::displayName(int threshold) const
|
||||||
|
{
|
||||||
|
return makeDisplayPath(absFilename(), threshold);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
string FileName::fileContents() const
|
string FileName::fileContents() const
|
||||||
{
|
{
|
||||||
if (exists()) {
|
if (exists()) {
|
||||||
|
@ -12,6 +12,8 @@
|
|||||||
#ifndef FILENAME_H
|
#ifndef FILENAME_H
|
||||||
#define FILENAME_H
|
#define FILENAME_H
|
||||||
|
|
||||||
|
#include "strfwd.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
|
|
||||||
@ -98,6 +100,15 @@ public:
|
|||||||
/// \p mask must be in filesystem encoding
|
/// \p mask must be in filesystem encoding
|
||||||
static FileName tempName(FileName const & dir = FileName(),
|
static FileName tempName(FileName const & dir = FileName(),
|
||||||
std::string const & mask = std::string());
|
std::string const & mask = std::string());
|
||||||
|
|
||||||
|
/// filename without path
|
||||||
|
std::string onlyFileName() const;
|
||||||
|
/// path without file name
|
||||||
|
std::string onlyPath() const;
|
||||||
|
/// used for display in the Gui
|
||||||
|
docstring displayName(int threshold = 1000) const;
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/// The absolute file name.
|
/// The absolute file name.
|
||||||
/// The encoding is currently unspecified, anything else than ASCII
|
/// The encoding is currently unspecified, anything else than ASCII
|
||||||
|
Loading…
Reference in New Issue
Block a user