mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
Tommaso patch, part 5, lots of thing to cleanup still but I'll do that afterwards.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@27521 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
a287184d72
commit
4209cbc631
@ -375,6 +375,12 @@ string const Buffer::temppath() const
|
||||
}
|
||||
|
||||
|
||||
TexRow & Buffer::texrow()
|
||||
{
|
||||
return d->texrow;
|
||||
}
|
||||
|
||||
|
||||
TexRow const & Buffer::texrow() const
|
||||
{
|
||||
return d->texrow;
|
||||
|
@ -348,6 +348,7 @@ public:
|
||||
|
||||
/// Used when typesetting to place errorboxes.
|
||||
TexRow const & texrow() const;
|
||||
TexRow & texrow();
|
||||
|
||||
///
|
||||
ParIterator par_iterator_begin();
|
||||
|
@ -878,6 +878,7 @@ FuncStatus BufferView::getStatus(FuncRequest const & cmd)
|
||||
case LFUN_NOTE_NEXT:
|
||||
case LFUN_REFERENCE_NEXT:
|
||||
case LFUN_WORD_FIND:
|
||||
case LFUN_WORD_FINDADV:
|
||||
case LFUN_WORD_REPLACE:
|
||||
case LFUN_MARK_OFF:
|
||||
case LFUN_MARK_ON:
|
||||
@ -891,6 +892,11 @@ FuncStatus BufferView::getStatus(FuncRequest const & cmd)
|
||||
flag.setEnabled(true);
|
||||
break;
|
||||
|
||||
// @todo Test if current WorkArea is the search WorkArea
|
||||
case LFUN_REGEXP_MODE:
|
||||
flag.setEnabled(! this->cursor().inRegexped());
|
||||
break;
|
||||
|
||||
case LFUN_NEXT_INSET_TOGGLE:
|
||||
case LFUN_NEXT_INSET_MODIFY: {
|
||||
// this is the real function we want to invoke
|
||||
@ -1232,6 +1238,10 @@ bool BufferView::dispatch(FuncRequest const & cmd)
|
||||
break;
|
||||
}
|
||||
|
||||
case LFUN_WORD_FINDADV:
|
||||
findAdv(this, cmd);
|
||||
break;
|
||||
|
||||
case LFUN_MARK_OFF:
|
||||
cur.clearSelection();
|
||||
cur.resetAnchor();
|
||||
|
@ -20,6 +20,7 @@
|
||||
|
||||
#include "mathed/MathData.h"
|
||||
#include "mathed/InsetMath.h"
|
||||
#include "mathed/InsetMathHull.h"
|
||||
|
||||
#include "insets/InsetTabular.h"
|
||||
|
||||
@ -60,6 +61,13 @@ DocIterator doc_iterator_end(Inset & inset)
|
||||
}
|
||||
|
||||
|
||||
bool DocIterator::inRegexped() const
|
||||
{
|
||||
InsetMathHull * i = dynamic_cast<InsetMathHull *>(inset().asInsetMath());
|
||||
return i && i->getType() == hullRegexp;
|
||||
}
|
||||
|
||||
|
||||
LyXErr & operator<<(LyXErr & os, DocIterator const & it)
|
||||
{
|
||||
os.stream() << it;
|
||||
|
@ -124,6 +124,8 @@ public:
|
||||
/// are we in texted?.
|
||||
bool inTexted() const
|
||||
{ return !empty() && !inset().inMathed(); }
|
||||
/// are we in regexp-mode ?
|
||||
bool inRegexped() const;
|
||||
|
||||
//
|
||||
// math-specific part
|
||||
|
@ -568,6 +568,7 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
|
||||
|
||||
case LFUN_WORD_FIND_FORWARD:
|
||||
case LFUN_WORD_FIND_BACKWARD:
|
||||
case LFUN_WORD_FINDADV:
|
||||
case LFUN_COMMAND_PREFIX:
|
||||
case LFUN_COMMAND_EXECUTE:
|
||||
case LFUN_CANCEL:
|
||||
|
@ -1907,9 +1907,10 @@ int Paragraph::Private::endTeXParParams(BufferParams const & bparams,
|
||||
|
||||
// This one spits out the text of the paragraph
|
||||
bool Paragraph::latex(BufferParams const & bparams,
|
||||
Font const & outerfont,
|
||||
odocstream & os, TexRow & texrow,
|
||||
OutputParams const & runparams) const
|
||||
Font const & outerfont,
|
||||
odocstream & os, TexRow & texrow,
|
||||
OutputParams const & runparams,
|
||||
int start_pos, int end_pos) const
|
||||
{
|
||||
LYXERR(Debug::LATEX, "Paragraph::latex... " << this);
|
||||
|
||||
@ -2083,7 +2084,7 @@ bool Paragraph::latex(BufferParams const & bparams,
|
||||
os << fontchange;
|
||||
}
|
||||
|
||||
if (c == ' ') {
|
||||
if (c == ' ' && i >= start_pos && i < end_pos) {
|
||||
// FIXME: integrate this case in latexSpecialChar
|
||||
// Do not print the separation of the optional argument
|
||||
// if style.pass_thru is false. This works because
|
||||
@ -2111,12 +2112,14 @@ bool Paragraph::latex(BufferParams const & bparams,
|
||||
// Two major modes: LaTeX or plain
|
||||
// Handle here those cases common to both modes
|
||||
// and then split to handle the two modes separately.
|
||||
if (c == META_INSET)
|
||||
if (c == META_INSET) {
|
||||
if (i >= start_pos && i < end_pos)
|
||||
d->latexInset(bparams, os,
|
||||
texrow, rp, running_font,
|
||||
basefont, outerfont, open_font,
|
||||
runningChange, style, i, column);
|
||||
else {
|
||||
} else {
|
||||
if (i >= start_pos && i < end_pos) {
|
||||
try {
|
||||
d->latexSpecialChar(os, rp, running_font, runningChange,
|
||||
style, i, column);
|
||||
@ -2134,6 +2137,7 @@ bool Paragraph::latex(BufferParams const & bparams,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Set the encoding to that returned from latexSpecialChar (see
|
||||
// comment for encoding member in OutputParams.h)
|
||||
|
@ -132,7 +132,8 @@ public:
|
||||
|
||||
///
|
||||
bool latex(BufferParams const &, Font const & outerfont, odocstream &,
|
||||
TexRow & texrow, OutputParams const &) const;
|
||||
TexRow & texrow, OutputParams const &,
|
||||
int start_pos = -1, int end_pos = -1) const;
|
||||
|
||||
/// Can we drop the standard paragraph wrapper?
|
||||
bool emptyTag() const;
|
||||
|
@ -48,6 +48,9 @@
|
||||
|
||||
#include "frontends/Clipboard.h"
|
||||
#include "frontends/Selection.h"
|
||||
#include "frontends/Application.h"
|
||||
#include "frontends/LyXView.h"
|
||||
#include "frontends/WorkArea.h"
|
||||
|
||||
#include "insets/InsetCollapsable.h"
|
||||
#include "insets/InsetCommand.h"
|
||||
@ -84,6 +87,8 @@ using cap::pasteFromStack;
|
||||
using cap::pasteClipboardText;
|
||||
using cap::pasteClipboardGraphics;
|
||||
using cap::replaceSelection;
|
||||
using cap::grabAndEraseSelection;
|
||||
using cap::selClearOrDel;
|
||||
|
||||
// globals...
|
||||
static Font freefont(ignore_font, ignore_language);
|
||||
@ -187,6 +192,26 @@ static void mathDispatch(Cursor & cur, FuncRequest const & cmd, bool display)
|
||||
}
|
||||
|
||||
|
||||
void regexpDispatch(Cursor & cur, FuncRequest const & cmd)
|
||||
{
|
||||
BOOST_ASSERT(cmd.action == LFUN_REGEXP_MODE);
|
||||
if (cur.inRegexped()) {
|
||||
cur.message(_("Already in regexp mode"));
|
||||
return;
|
||||
}
|
||||
cur.recordUndo();
|
||||
docstring const save_selection = grabAndEraseSelection(cur);
|
||||
selClearOrDel(cur);
|
||||
// replaceSelection(cur);
|
||||
|
||||
cur.insert(new InsetMathHull(hullRegexp));
|
||||
cur.nextInset()->edit(cur, true);
|
||||
cur.niceInsert(save_selection);
|
||||
|
||||
cur.message(_("Regexp editor mode"));
|
||||
}
|
||||
|
||||
|
||||
static void specialChar(Cursor & cur, InsetSpecialChar::Kind kind)
|
||||
{
|
||||
cur.recordUndo();
|
||||
@ -1487,6 +1512,10 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
|
||||
mathDispatch(cur, cmd, true);
|
||||
break;
|
||||
|
||||
case LFUN_REGEXP_MODE:
|
||||
regexpDispatch(cur, cmd);
|
||||
break;
|
||||
|
||||
case LFUN_MATH_MODE:
|
||||
if (cmd.argument() == "on")
|
||||
// don't pass "on" as argument
|
||||
|
@ -735,8 +735,10 @@ docstring latexifyFromCursor(Buffer const & buf, DocIterator const & cur, int le
|
||||
// ParagraphList::const_iterator pit_end = pit;
|
||||
// ++pit_end;
|
||||
// lyx::latexParagraphs(buf, cur.innerText()->paragraphs(), ods, texrow, runparams, string(), pit, pit_end);
|
||||
pos_type const endpos = (len == -1 || cur.pos() + len > int(pit->size()))
|
||||
? pit->size() : cur.pos() + len;
|
||||
TeXOnePar(buf, *cur.innerText(), pit, ods, texrow, runparams, string(),
|
||||
cur.pos(), ( len == -1 || cur.pos() + len > int(pit->size()) ) ? -1 : cur.pos() + len);
|
||||
cur.pos(), endpos);
|
||||
LYXERR(Debug::DEBUG, "Latexified text: '" << lyx::to_utf8(ods.str()) << "'");
|
||||
} else if (cur.inMathed()) {
|
||||
// Retrieve the math environment type, and add '$' or '$[' or others (\begin{equation}) accordingly
|
||||
|
@ -61,14 +61,6 @@ TeXEnvironment(Buffer const & buf,
|
||||
odocstream & os, TexRow & texrow,
|
||||
OutputParams const & runparams);
|
||||
|
||||
ParagraphList::const_iterator
|
||||
TeXOnePar(Buffer const & buf,
|
||||
Text const & text,
|
||||
ParagraphList::const_iterator pit,
|
||||
odocstream & os, TexRow & texrow,
|
||||
OutputParams const & runparams,
|
||||
string const & everypar = string());
|
||||
|
||||
|
||||
ParagraphList::const_iterator
|
||||
TeXDeeper(Buffer const & buf,
|
||||
@ -277,16 +269,14 @@ int latexOptArgInsets(Paragraph const & par, odocstream & os,
|
||||
return lines;
|
||||
}
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
ParagraphList::const_iterator
|
||||
TeXOnePar(Buffer const & buf,
|
||||
// FIXME: this should be anonymous
|
||||
ParagraphList::const_iterator TeXOnePar(Buffer const & buf,
|
||||
Text const & text,
|
||||
ParagraphList::const_iterator const pit,
|
||||
odocstream & os, TexRow & texrow,
|
||||
OutputParams const & runparams_in,
|
||||
string const & everypar)
|
||||
string const & everypar,
|
||||
int start_pos, int end_pos)
|
||||
{
|
||||
LYXERR(Debug::LATEX, "TeXOnePar... " << &*pit << " '"
|
||||
<< everypar << "'");
|
||||
@ -312,7 +302,7 @@ TeXOnePar(Buffer const & buf,
|
||||
}
|
||||
|
||||
/*bool need_par = */ pit->latex(bparams, outerfont,
|
||||
os, texrow, runparams);
|
||||
os, texrow, runparams, start_pos, end_pos);
|
||||
return nextpit;
|
||||
}
|
||||
|
||||
@ -543,7 +533,7 @@ TeXOnePar(Buffer const & buf,
|
||||
// FIXME UNICODE
|
||||
os << from_utf8(everypar);
|
||||
bool need_par = pit->latex(bparams, outerfont,
|
||||
os, texrow, runparams);
|
||||
os, texrow, runparams, start_pos, end_pos);
|
||||
|
||||
// Make sure that \\par is done with the font of the last
|
||||
// character if this has another size as the default.
|
||||
@ -747,8 +737,6 @@ TeXOnePar(Buffer const & buf,
|
||||
return nextpit;
|
||||
}
|
||||
|
||||
} // anon namespace
|
||||
|
||||
|
||||
// LaTeX all paragraphs
|
||||
void latexParagraphs(Buffer const & buf,
|
||||
@ -943,7 +931,7 @@ pair<bool, int> switchEncoding(odocstream & os, BufferParams const & bparams,
|
||||
count += 7;
|
||||
}
|
||||
if (runparams.local_font != 0
|
||||
&& oldEnc.package() == Encoding::CJK) {
|
||||
&& oldEnc.package() == Encoding::CJK) {
|
||||
// within insets, \inputenc switches need
|
||||
// to be embraced within \bgroup...\egroup;
|
||||
// else CJK fails.
|
||||
|
@ -15,6 +15,9 @@
|
||||
#include <utility>
|
||||
|
||||
#include "support/docstream.h"
|
||||
#include "Paragraph.h"
|
||||
#include "ParIterator.h"
|
||||
#include "ParagraphList.h"
|
||||
|
||||
|
||||
namespace lyx {
|
||||
@ -53,6 +56,15 @@ std::pair<bool, int> switchEncoding(odocstream & os,
|
||||
OutputParams const &, Encoding const & newEnc,
|
||||
bool force = false);
|
||||
|
||||
/// FIXME: this should not be visible.
|
||||
ParagraphList::const_iterator TeXOnePar(Buffer const & buf,
|
||||
Text const & text,
|
||||
ParagraphList::const_iterator pit,
|
||||
odocstream & os, TexRow & texrow,
|
||||
OutputParams const & runparams,
|
||||
std::string const & everypar = std::string(),
|
||||
int start_pos = -1, int end_pos = -1);
|
||||
|
||||
} // namespace lyx
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user