mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-26 14:15:32 +00:00
Modify the forward-search lfun such that no argument is needed.
If a dvi file exists in the temp dir, the command specified by the \forward_search_dvi rc setting is used to initiate the search. Otherwise, if a pdf file exists, the forward search is performed by using the command specified by the \forward_search_pdf rc setting. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@34148 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
84689d1cda
commit
ba57ee8a24
@ -2829,13 +2829,14 @@ void LyXAction::init()
|
||||
* \li Action: Sets the cursor position in the previewed (e.g. dvi) file based on the row
|
||||
number in LyX window.
|
||||
* \li Notion: The external program used for forward search call can be specified in
|
||||
\\forward_search RC setting. By default its value is\n
|
||||
\\forward_search_dvi and \\forward_search_pdf RC settings.
|
||||
By default, the value for pdf is empty, while for dvi it is\n
|
||||
"xdvi -sourceposition $$n:$$t $$o"\n
|
||||
The values replaced in the call: $$n for row number, $$t for
|
||||
exported temporary .tex file, $$o exported output file, either
|
||||
dvi or pdf, depending on the argument of #LFUN_FORWARD_SEARCH.
|
||||
* \li Syntax: forward-search [dvi|pdf]
|
||||
* \li Params: By default dvi route is taken.
|
||||
dvi or pdf, depending on which one exists in the temp dir
|
||||
(preferred is dvi).
|
||||
* \li Syntax: forward-search
|
||||
* \li Origin: sanda, 14 Apr 2010
|
||||
* \endvar
|
||||
*/
|
||||
|
@ -94,7 +94,8 @@ LexerKeyword lyxrcTags[] = {
|
||||
{ "\\example_path", LyXRC::RC_EXAMPLEPATH },
|
||||
{ "\\font_encoding", LyXRC::RC_FONT_ENCODING },
|
||||
{ "\\format", LyXRC::RC_FORMAT },
|
||||
{ "\\forward_search", LyXRC::RC_FORWARD_SEARCH },
|
||||
{ "\\forward_search_dvi", LyXRC::RC_FORWARD_SEARCH_DVI },
|
||||
{ "\\forward_search_pdf", LyXRC::RC_FORWARD_SEARCH_PDF },
|
||||
{ "\\fullscreen_limit", LyXRC::RC_FULL_SCREEN_LIMIT },
|
||||
{ "\\fullscreen_menubar", LyXRC::RC_FULL_SCREEN_MENUBAR },
|
||||
{ "\\fullscreen_scrollbar", LyXRC::RC_FULL_SCREEN_SCROLLBAR },
|
||||
@ -327,7 +328,8 @@ void LyXRC::setDefaults()
|
||||
user_email = to_utf8(support::user_email());
|
||||
open_buffers_in_tabs = true;
|
||||
single_close_tab_button = false;
|
||||
forward_search = "xdvi -sourceposition $$n:$$t $$o";
|
||||
forward_search_dvi = "xdvi -sourceposition $$n:$$t $$o";
|
||||
forward_search_pdf = string();
|
||||
|
||||
// Fullscreen settings
|
||||
full_screen_limit = false;
|
||||
@ -1158,9 +1160,13 @@ int LyXRC::read(Lexer & lexrc)
|
||||
case RC_SINGLE_CLOSE_TAB_BUTTON:
|
||||
lexrc >> single_close_tab_button;
|
||||
break;
|
||||
case RC_FORWARD_SEARCH:
|
||||
case RC_FORWARD_SEARCH_DVI:
|
||||
if (lexrc.next(true))
|
||||
forward_search = lexrc.getString();
|
||||
forward_search_dvi = lexrc.getString();
|
||||
break;
|
||||
case RC_FORWARD_SEARCH_PDF:
|
||||
if (lexrc.next(true))
|
||||
forward_search_pdf = lexrc.getString();
|
||||
break;
|
||||
|
||||
// Obsoteted in 1.4.0
|
||||
@ -1857,10 +1863,17 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
|
||||
}
|
||||
if (tag != RC_LAST)
|
||||
break;
|
||||
case RC_FORWARD_SEARCH:
|
||||
case RC_FORWARD_SEARCH_DVI:
|
||||
if (ignore_system_lyxrc ||
|
||||
forward_search != system_lyxrc.forward_search) {
|
||||
os << "\\forward_search \"" << escapeCommand(forward_search) << "\"\n";
|
||||
forward_search_dvi != system_lyxrc.forward_search_dvi) {
|
||||
os << "\\forward_search_dvi \"" << escapeCommand(forward_search_dvi) << "\"\n";
|
||||
}
|
||||
if (tag != RC_LAST)
|
||||
break;
|
||||
case RC_FORWARD_SEARCH_PDF:
|
||||
if (ignore_system_lyxrc ||
|
||||
forward_search_pdf != system_lyxrc.forward_search_pdf) {
|
||||
os << "\\forward_search_pdf \"" << escapeCommand(forward_search_pdf) << "\"\n";
|
||||
}
|
||||
if (tag != RC_LAST)
|
||||
break;
|
||||
@ -2816,7 +2829,8 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new)
|
||||
case LyXRC::RC_VISUAL_CURSOR:
|
||||
case LyXRC::RC_VIEWER:
|
||||
case LyXRC::RC_VIEWER_ALTERNATIVES:
|
||||
case LyXRC::RC_FORWARD_SEARCH:
|
||||
case LyXRC::RC_FORWARD_SEARCH_DVI:
|
||||
case LyXRC::RC_FORWARD_SEARCH_PDF:
|
||||
case LyXRC::RC_LAST:
|
||||
break;
|
||||
}
|
||||
|
@ -78,7 +78,8 @@ public:
|
||||
RC_EXAMPLEPATH,
|
||||
RC_FONT_ENCODING,
|
||||
RC_FORMAT,
|
||||
RC_FORWARD_SEARCH,
|
||||
RC_FORWARD_SEARCH_DVI,
|
||||
RC_FORWARD_SEARCH_PDF,
|
||||
RC_FULL_SCREEN_LIMIT,
|
||||
RC_FULL_SCREEN_SCROLLBAR,
|
||||
RC_FULL_SCREEN_TABBAR,
|
||||
@ -492,7 +493,9 @@ public:
|
||||
///
|
||||
bool single_close_tab_button;
|
||||
///
|
||||
std::string forward_search;
|
||||
std::string forward_search_dvi;
|
||||
///
|
||||
std::string forward_search_pdf;
|
||||
};
|
||||
|
||||
|
||||
|
@ -3224,25 +3224,27 @@ void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
|
||||
break;
|
||||
|
||||
case LFUN_FORWARD_SEARCH: {
|
||||
string out_type="dvi";
|
||||
if (argument == "pdf")
|
||||
out_type = "pdf";
|
||||
|
||||
string command = lyxrc.forward_search_dvi;
|
||||
FileName const path(doc_buffer->temppath());
|
||||
support::PathChanger p(path);
|
||||
string const texname = doc_buffer->latexName();
|
||||
string const outname = support::changeExtension(doc_buffer->latexName(), out_type);
|
||||
string outname = support::changeExtension(texname, "dvi");
|
||||
if (!FileName(addName(path.absFilename(), outname)).exists()) {
|
||||
outname = support::changeExtension(texname, "pdf");
|
||||
command = lyxrc.forward_search_pdf;
|
||||
if (!FileName(addName(path.absFilename(), outname)).exists())
|
||||
break;
|
||||
}
|
||||
|
||||
int row = doc_buffer->texrow().getRowFromIdPos(bv->cursor().paragraph().id(), bv->cursor().pos());
|
||||
if (!row)
|
||||
if (!row || command.empty())
|
||||
break;
|
||||
string texrow = convert<string>(row);
|
||||
|
||||
string command = lyxrc.forward_search;
|
||||
command = subst(command, "$$n", texrow);
|
||||
command = subst(command, "$$t", texname);
|
||||
command = subst(command, "$$o", outname);
|
||||
|
||||
PathChanger p(path);
|
||||
Systemcall one;
|
||||
one.startscript(Systemcall::Wait, command);
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user