mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 10:00:33 +00:00
* implement "inset-edit" in InsetInclude.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@24528 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
4170290545
commit
1458cd52b7
@ -192,6 +192,8 @@ Menuset
|
||||
Item "Listing|L" "next-inset-modify changetype lstinputlisting"
|
||||
Separator
|
||||
Item "Settings...|S" "next-inset-toggle"
|
||||
Separator
|
||||
Item "Edit included file...|E" "inset-edit"
|
||||
End
|
||||
|
||||
#
|
||||
@ -271,7 +273,7 @@ Menuset
|
||||
Menu "context-graphics"
|
||||
Item "Settings...|S" "next-inset-toggle"
|
||||
Separator
|
||||
Item "Edit externally...|x" "graphics-edit"
|
||||
Item "Edit externally...|x" "inset-edit"
|
||||
End
|
||||
|
||||
#
|
||||
|
@ -15,7 +15,6 @@
|
||||
#include "GuiInclude.h"
|
||||
|
||||
#include "Buffer.h"
|
||||
#include "Format.h"
|
||||
#include "FuncRequest.h"
|
||||
#include "LyXRC.h"
|
||||
|
||||
@ -289,11 +288,12 @@ void GuiInclude::browse()
|
||||
|
||||
void GuiInclude::edit()
|
||||
{
|
||||
if (isValid()) {
|
||||
string const file = fromqstr(filenameED->text());
|
||||
slotOK();
|
||||
edit(file);
|
||||
}
|
||||
if (!isValid())
|
||||
return;
|
||||
string const file = fromqstr(filenameED->text());
|
||||
slotOK();
|
||||
applyView();
|
||||
dispatch(FuncRequest(LFUN_INSET_EDIT));
|
||||
}
|
||||
|
||||
|
||||
@ -326,19 +326,6 @@ QString GuiInclude::browse(QString const & in_name, Type in_type) const
|
||||
}
|
||||
|
||||
|
||||
void GuiInclude::edit(string const & file)
|
||||
{
|
||||
string const ext = support::getExtension(file);
|
||||
if (ext == "lyx")
|
||||
dispatch(FuncRequest(LFUN_BUFFER_CHILD_OPEN, file));
|
||||
else
|
||||
// tex file or other text file in verbatim mode
|
||||
formats.edit(buffer(),
|
||||
support::makeAbsPath(file, support::onlyPath(buffer().absFileName())),
|
||||
"text");
|
||||
}
|
||||
|
||||
|
||||
bool GuiInclude::initialiseParams(std::string const & data)
|
||||
{
|
||||
InsetCommand::string2params("include", data, params_);
|
||||
|
@ -71,8 +71,6 @@ private:
|
||||
/// validate listings parameters and return an error message, if any
|
||||
docstring validate_listings_params();
|
||||
///
|
||||
void edit(std::string const & file);
|
||||
///
|
||||
bool isValid();
|
||||
/// Apply changes
|
||||
void applyView();
|
||||
|
@ -66,6 +66,8 @@ protected:
|
||||
///
|
||||
void doDispatch(Cursor & cur, FuncRequest & cmd);
|
||||
///
|
||||
bool getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus &) const;
|
||||
///
|
||||
docstring const getCommand() const { return p_.getCommand(); }
|
||||
///
|
||||
std::string const & getCmdName() const { return p_.getCmdName(); }
|
||||
@ -105,8 +107,6 @@ private:
|
||||
static bool isCompatibleCommand(std::string const & cmd);
|
||||
///
|
||||
docstring contextMenu(BufferView const & bv, int x, int y) const;
|
||||
///
|
||||
bool getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus &) const;
|
||||
/// This should provide the text for the button
|
||||
virtual docstring screenLabel() const = 0;
|
||||
|
||||
|
@ -23,10 +23,12 @@
|
||||
#include "DispatchResult.h"
|
||||
#include "ErrorList.h"
|
||||
#include "Exporter.h"
|
||||
#include "Format.h"
|
||||
#include "FuncRequest.h"
|
||||
#include "FuncStatus.h"
|
||||
#include "LaTeXFeatures.h"
|
||||
#include "LyX.h"
|
||||
#include "LyXFunc.h"
|
||||
#include "LyXRC.h"
|
||||
#include "Lexer.h"
|
||||
#include "MetricsInfo.h"
|
||||
@ -241,6 +243,11 @@ void InsetInclude::doDispatch(Cursor & cur, FuncRequest & cmd)
|
||||
LASSERT(&cur.buffer() == &buffer(), /**/);
|
||||
switch (cmd.action) {
|
||||
|
||||
case LFUN_INSET_EDIT: {
|
||||
editIncluded(to_utf8(params()["filename"]));
|
||||
break;
|
||||
}
|
||||
|
||||
case LFUN_INSET_MODIFY: {
|
||||
InsetCommandParams p(INCLUDE_CODE);
|
||||
if (cmd.getArg(0) == "changetype") {
|
||||
@ -276,6 +283,35 @@ void InsetInclude::doDispatch(Cursor & cur, FuncRequest & cmd)
|
||||
}
|
||||
|
||||
|
||||
void InsetInclude::editIncluded(string const & file)
|
||||
{
|
||||
string const ext = support::getExtension(file);
|
||||
if (ext == "lyx") {
|
||||
FuncRequest fr(LFUN_BUFFER_CHILD_OPEN, file);
|
||||
lyx::dispatch(fr);
|
||||
} else
|
||||
// tex file or other text file in verbatim mode
|
||||
formats.edit(buffer(),
|
||||
support::makeAbsPath(file, support::onlyPath(buffer().absFileName())),
|
||||
"text");
|
||||
}
|
||||
|
||||
|
||||
bool InsetInclude::getStatus(Cursor & cur, FuncRequest const & cmd,
|
||||
FuncStatus & flag) const
|
||||
{
|
||||
switch (cmd.action) {
|
||||
|
||||
case LFUN_INSET_EDIT:
|
||||
flag.enabled(true);
|
||||
return true;
|
||||
|
||||
default:
|
||||
return InsetCommand::getStatus(cur, cmd, flag);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void InsetInclude::setParams(InsetCommandParams const & p)
|
||||
{
|
||||
InsetCommand::setParams(p);
|
||||
|
@ -99,6 +99,8 @@ protected:
|
||||
InsetInclude(InsetInclude const &);
|
||||
///
|
||||
void doDispatch(Cursor & cur, FuncRequest & cmd);
|
||||
///
|
||||
bool getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus &) const;
|
||||
private:
|
||||
Inset * clone() const { return new InsetInclude(*this); }
|
||||
|
||||
@ -107,6 +109,8 @@ private:
|
||||
*/
|
||||
void fileChanged() const;
|
||||
|
||||
/// launch external application
|
||||
void editIncluded(std::string const & file);
|
||||
/// set the parameters
|
||||
void setParams(InsetCommandParams const & params);
|
||||
/// get the text displayed on the button
|
||||
|
Loading…
Reference in New Issue
Block a user