mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-27 14:29:21 +00:00
Add LFUN_VC_COMMAND.
http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg147331.html git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@28138 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
da24e05566
commit
21470a6219
@ -413,6 +413,8 @@ enum FuncCode
|
||||
LFUN_WORD_FINDADV, // Tommaso, 20081003
|
||||
LFUN_REGEXP_MODE, // Tommaso, 20081003
|
||||
LFUN_COPY_LABEL_AS_REF, // sts, 20081116
|
||||
// 320
|
||||
LFUN_VC_COMMAND,
|
||||
|
||||
LFUN_LASTACTION // end of the table
|
||||
};
|
||||
|
@ -1984,6 +1984,24 @@ void LyXAction::init()
|
||||
* \endvar
|
||||
*/
|
||||
{ LFUN_VC_UNDO_LAST, "vc-undo-last", ReadOnly, System },
|
||||
/*!
|
||||
* \var lyx::FuncCode lyx::LFUN_VC_COMMAND
|
||||
* \li Action: Executes external command. This command is intended to support
|
||||
additonal VCS commands.
|
||||
* \li Syntax: vc-command <FLAG> <PATH> <COMMAND>
|
||||
* \li Params: <FLAG>: Flags for the command can be combined together.\n
|
||||
U - dUmmy - no flags \n
|
||||
D - Doc - need document loaded to proceed \n
|
||||
I - dIrty - mark document dirty \n
|
||||
R - Reload - reload the document after command execution \n
|
||||
M - Message - ask for input string (commit message)\n
|
||||
<PATH>: path where to start. $$p will be replaced by the current document path.\n
|
||||
<COMMAND>: command to execute. $$i/$$p/$$m will be replaced by the current document/path/message.
|
||||
* \li Sample: vc-command DR $$p "svn up"
|
||||
* \li Origin: sanda, 13 Jan 2009
|
||||
* \endvar
|
||||
*/
|
||||
{ LFUN_VC_COMMAND, "vc-command", NoBuffer | ReadOnly, System },
|
||||
|
||||
/*!
|
||||
* \var lyx::FuncCode lyx::LFUN_CHANGES_TRACK
|
||||
|
@ -566,6 +566,15 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
|
||||
break;
|
||||
}
|
||||
|
||||
case LFUN_VC_COMMAND: {
|
||||
if (cmd.argument().empty())
|
||||
enable = false;
|
||||
|
||||
if (!buf && contains(cmd.getArg(0), 'D'))
|
||||
enable = false;
|
||||
break;
|
||||
}
|
||||
|
||||
case LFUN_WORD_FIND_FORWARD:
|
||||
case LFUN_WORD_FIND_BACKWARD:
|
||||
case LFUN_WORD_FINDADV:
|
||||
@ -1599,6 +1608,48 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
|
||||
theSession().bookmarks().clear();
|
||||
break;
|
||||
|
||||
case LFUN_VC_COMMAND: {
|
||||
string flag = cmd.getArg(0);
|
||||
if (buffer && contains(flag, 'R') && !ensureBufferClean(view()))
|
||||
break;
|
||||
docstring message;
|
||||
if (contains(flag, 'M'))
|
||||
if (!Alert::askForText(message, _("LyX VC: Log Message")))
|
||||
break;
|
||||
|
||||
string path = cmd.getArg(1);
|
||||
if (contains(path, "$$p") && buffer)
|
||||
path = subst(path, "$$p", buffer->filePath());
|
||||
LYXERR(Debug::LYXVC, "Directory: " << path);
|
||||
FileName pp(path);
|
||||
if (!pp.isReadableDirectory()) {
|
||||
lyxerr<< _("Directory is not readable.\n");
|
||||
break;
|
||||
}
|
||||
support::PathChanger p(pp);
|
||||
|
||||
string command = cmd.getArg(2);
|
||||
if (command.empty())
|
||||
break;
|
||||
if (buffer) {
|
||||
command = subst(command, "$$i", buffer->absFileName());
|
||||
command = subst(command, "$$p", buffer->filePath());
|
||||
}
|
||||
command = subst(command, "$$m", to_utf8(message));
|
||||
LYXERR(Debug::LYXVC, "Command: " << command);
|
||||
Systemcall one;
|
||||
one.startscript(Systemcall::Wait, command);
|
||||
|
||||
if (!buffer)
|
||||
break;
|
||||
if (contains(flag, 'I'))
|
||||
buffer->markDirty();
|
||||
if (contains(flag, 'R'))
|
||||
reloadBuffer();
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
LASSERT(theApp(), /**/);
|
||||
// Let the frontend dispatch its own actions.
|
||||
|
Loading…
Reference in New Issue
Block a user