-/* This file is part of
- * ======================================================
+/**
+ * \file insettext.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
*
- * LyX, The Document Processor
+ * \author Jürgen Vigna
*
- * Copyright 1998-2001 The LyX Team.
- *
- * ======================================================
+ * Full author contact details are available in file CREDITS
*/
#include <config.h>
#include "trans_mgr.h"
#include "undo_funcs.h"
#include "WordLangTuple.h"
+#include "paragraph_funcs.h"
+#include "sgml.h"
#include "frontends/Alert.h"
#include "frontends/Dialogs.h"
void InsetText::writeParagraphData(Buffer const * buf, ostream & os) const
{
- paragraphs.begin()->writeFile(buf, os, buf->params, 0);
+ ParagraphList::iterator it = paragraphs.begin();
+ ParagraphList::iterator end = paragraphs.end();
+ Paragraph::depth_type dth = 0;
+ for (; it != end; ++it) {
+ it->write(buf, os, buf->params, dth);
+ }
}
if (token.empty())
continue;
if (token == "\\end_inset") {
-#ifndef NO_COMPABILITY
- const_cast<Buffer*>(buf)->insertErtContents(par, pos, false);
-#endif
break;
}
int tmp_x = cmd.x - drawTextXOffset;
int tmp_y = cmd.y + insetAscent - getLyXText(bv)->first_y;
- Inset * inset = bv->checkInsetHit(getLyXText(bv), tmp_x, tmp_y);
+ Inset * inset = getLyXText(bv)->checkInsetHit(bv, tmp_x, tmp_y);
hideInsetCursor(bv);
if (the_locking_inset) {
int tmp_x = cmd.x - drawTextXOffset;
int tmp_y = cmd.y + insetAscent - getLyXText(bv)->first_y;
- Inset * inset = bv->checkInsetHit(getLyXText(bv), tmp_x, tmp_y);
+ Inset * inset = getLyXText(bv)->checkInsetHit(bv, tmp_x, tmp_y);
bool ret = false;
if (inset) {
- if (isHighlyEditableInset(inset))
+ if (isHighlyEditableInset(inset))
ret = inset->localDispatch(cmd1);
else {
inset_x = cix(bv) - top_x + drawTextXOffset;
Inset::RESULT InsetText::localDispatch(FuncRequest const & ev)
{
BufferView * bv = ev.view();
+ switch (ev.action) {
+ case LFUN_MOUSE_PRESS:
+ lfunMousePress(ev);
+ return DISPATCHED;
+ case LFUN_MOUSE_MOTION:
+ lfunMouseMotion(ev);
+ return DISPATCHED;
+ case LFUN_MOUSE_RELEASE:
+ return lfunMouseRelease(ev) ? DISPATCHED : UNDISPATCHED;
+ default:
+ break;
+ }
+
bool was_empty = (paragraphs.begin()->empty() && !paragraphs.begin()->next());
no_selection = false;
RESULT result = UpdatableInset::localDispatch(ev);
int updwhat = 0;
int updflag = false;
switch (ev.action) {
+
// Normal chars
case LFUN_SELFINSERT:
if (bv->buffer()->isReadonly()) {
* typed in now. Depends on lyxrc settings
* "auto_region_delete", which defaults to
* true (on). */
-
+#if 0
+ // This should not be needed here and is also WRONG!
setUndo(bv, Undo::INSERT,
lt->cursor.par(), lt->cursor.par()->next());
+#endif
bv->switchKeyMap();
if (lyxrc.auto_region_delete) {
if (lt->selection.set()) {
lt->cursorEnd(bv);
updwhat = CURSOR;
break;
+ case LFUN_PRIOR:
+ if (!crow(bv)->previous())
+ result = FINISHED_UP;
+ else {
+ lt->cursorPrevious(bv);
+ result = DISPATCHED_NOUPDATE;
+ }
+ updwhat = CURSOR;
+ break;
+ case LFUN_NEXT:
+ if (!crow(bv)->next())
+ result = FINISHED_DOWN;
+ else {
+ lt->cursorNext(bv);
+ result = DISPATCHED_NOUPDATE;
+ }
+ updwhat = CURSOR;
+ break;
case LFUN_BACKSPACE: {
- setUndo(bv, Undo::DELETE,
- lt->cursor.par(), lt->cursor.par()->next());
if (lt->selection.set())
lt->cutSelection(bv, true, false);
else
break;
case LFUN_DELETE: {
- setUndo(bv, Undo::DELETE,
- lt->cursor.par(), lt->cursor.par()->next());
if (lt->selection.set()) {
lt->cutSelection(bv, true, false);
} else {
break;
case LFUN_CUT: {
- setUndo(bv, Undo::DELETE,
- lt->cursor.par(), lt->cursor.par()->next());
lt->cutSelection(bv);
updwhat = CURSOR_PAR;
updflag = true;
break;
}
}
+#if 0
+ // This should not be needed here and is also WRONG!
setUndo(bv, Undo::INSERT,
lt->cursor.par(), lt->cursor.par()->next());
+#endif
lt->pasteSelection(bv);
// bug 393
lt->clearSelection();
result = DISPATCHED;
break;
}
+#if 0
+ // This should not be needed here and is also WRONG!
setUndo(bv, Undo::INSERT,
lt->cursor.par(), lt->cursor.par()->next());
+#endif
lt->insertChar(bv, Paragraph::META_NEWLINE);
updwhat = CURSOR | CURSOR_PAR;
updflag = true;
for (; depth > p->params().depth(); --depth) {
if (environment_inner[depth] != "!-- --") {
item_name = "listitem";
- lines += buf->sgmlCloseTag(os, command_depth + depth, mixcont, item_name);
+ lines += sgml::closeTag(os, command_depth + depth, mixcont, item_name);
if (environment_inner[depth] == "varlistentry")
- lines += buf->sgmlCloseTag(os, depth+command_depth, mixcont, environment_inner[depth]);
+ lines += sgml::closeTag(os, depth+command_depth, mixcont, environment_inner[depth]);
}
- lines += buf->sgmlCloseTag(os, depth + command_depth, mixcont, environment_stack[depth]);
+ lines += sgml::closeTag(os, depth + command_depth, mixcont, environment_stack[depth]);
environment_stack[depth].erase();
environment_inner[depth].erase();
}
&& !environment_stack[depth].empty()) {
if (environment_inner[depth] != "!-- --") {
item_name= "listitem";
- lines += buf->sgmlCloseTag(os, command_depth+depth, mixcont, item_name);
+ lines += sgml::closeTag(os, command_depth+depth, mixcont, item_name);
if (environment_inner[depth] == "varlistentry")
- lines += buf->sgmlCloseTag(os, depth + command_depth, mixcont, environment_inner[depth]);
+ lines += sgml::closeTag(os, depth + command_depth, mixcont, environment_inner[depth]);
}
- lines += buf->sgmlCloseTag(os, depth + command_depth, mixcont, environment_stack[depth]);
+ lines += sgml::closeTag(os, depth + command_depth, mixcont, environment_stack[depth]);
environment_stack[depth].erase();
environment_inner[depth].erase();
// Write opening SGML tags.
switch (style->latextype) {
case LATEX_PARAGRAPH:
- lines += buf->sgmlOpenTag(os, depth + command_depth, mixcont, style->latexname());
+ lines += sgml::openTag(os, depth + command_depth, mixcont, style->latexname());
break;
case LATEX_COMMAND:
}
environment_stack[depth] = style->latexname();
environment_inner[depth] = "!-- --";
- lines += buf->sgmlOpenTag(os, depth + command_depth, mixcont, environment_stack[depth]);
+ lines += sgml::openTag(os, depth + command_depth, mixcont, environment_stack[depth]);
} else {
if (environment_inner[depth] != "!-- --") {
item_name= "listitem";
- lines += buf->sgmlCloseTag(os, command_depth + depth, mixcont, item_name);
+ lines += sgml::closeTag(os, command_depth + depth, mixcont, item_name);
if (environment_inner[depth] == "varlistentry")
- lines += buf->sgmlCloseTag(os, depth + command_depth, mixcont, environment_inner[depth]);
+ lines += sgml::closeTag(os, depth + command_depth, mixcont, environment_inner[depth]);
}
}
if (style->latexparam() == "CDATA")
os << "<![CDATA[";
else
- lines += buf->sgmlOpenTag(os, depth + command_depth, mixcont, style->latexparam());
+ lines += sgml::openTag(os, depth + command_depth, mixcont, style->latexparam());
}
break;
}
desc_on = (style->labeltype == LABEL_MANUAL);
environment_inner[depth] = desc_on?"varlistentry":"listitem";
- lines += buf->sgmlOpenTag(os, depth + 1 + command_depth, mixcont, environment_inner[depth]);
+ lines += sgml::openTag(os, depth + 1 + command_depth, mixcont, environment_inner[depth]);
item_name = desc_on?"term":"para";
- lines += buf->sgmlOpenTag(os, depth + 1 + command_depth, mixcont, item_name);
+ lines += sgml::openTag(os, depth + 1 + command_depth, mixcont, item_name);
break;
default:
- lines += buf->sgmlOpenTag(os, depth + command_depth, mixcont, style->latexname());
+ lines += sgml::openTag(os, depth + command_depth, mixcont, style->latexname());
break;
}
if (style->latexparam() == "CDATA")
os << "]]>";
else
- lines += buf->sgmlCloseTag(os, depth + command_depth, mixcont, style->latexparam());
+ lines += sgml::closeTag(os, depth + command_depth, mixcont, style->latexparam());
}
break;
case LATEX_ITEM_ENVIRONMENT:
if (desc_on == 1) break;
end_tag= "para";
- lines += buf->sgmlCloseTag(os, depth + 1 + command_depth, mixcont, end_tag);
+ lines += sgml::closeTag(os, depth + 1 + command_depth, mixcont, end_tag);
break;
case LATEX_PARAGRAPH:
- lines += buf->sgmlCloseTag(os, depth + command_depth, mixcont, style->latexname());
+ lines += sgml::closeTag(os, depth + command_depth, mixcont, style->latexname());
break;
default:
- lines += buf->sgmlCloseTag(os, depth + command_depth, mixcont, style->latexname());
+ lines += sgml::closeTag(os, depth + command_depth, mixcont, style->latexname());
break;
}
}
if (!environment_stack[depth].empty()) {
if (environment_inner[depth] != "!-- --") {
item_name = "listitem";
- lines += buf->sgmlCloseTag(os, command_depth + depth, mixcont, item_name);
+ lines += sgml::closeTag(os, command_depth + depth, mixcont, item_name);
if (environment_inner[depth] == "varlistentry")
- lines += buf->sgmlCloseTag(os, depth + command_depth, mixcont, environment_inner[depth]);
+ lines += sgml::closeTag(os, depth + command_depth, mixcont, environment_inner[depth]);
}
- lines += buf->sgmlCloseTag(os, depth + command_depth, mixcont, environment_stack[depth]);
+ lines += sgml::closeTag(os, depth + command_depth, mixcont, environment_stack[depth]);
}
}
}
-Inset::RESULT
-InsetText::moveUp(BufferView * bv)
+Inset::RESULT InsetText::moveUp(BufferView * bv)
{
if (!crow(bv)->previous())
return FINISHED_UP;
}
-Inset::RESULT
-InsetText::moveDown(BufferView * bv)
+Inset::RESULT InsetText::moveDown(BufferView * bv)
{
if (!crow(bv)->next())
return FINISHED_DOWN;
x -= drawTextXOffset;
int dummyx = x;
int dummyy = y + insetAscent;
- Inset * inset = bv->checkInsetHit(getLyXText(bv), dummyx, dummyy);
+ Inset * inset = getLyXText(bv)->checkInsetHit(bv, dummyx, dummyy);
// we only do the edit() call if the inset was hit by the mouse
// or if it is a highly editable inset. So we should call this
// function from our own edit with button < 0.
llt->selection.end.pos() + paragraphs.begin()->size());
}
}
- paragraphs.begin()->pasteParagraph(bparams);
+ mergeParagraph(bparams, &*paragraphs.begin());
}
reinitLyXText();
}
// paste it!
lastbuffer->next(buf);
buf->previous(lastbuffer);
- lastbuffer->pasteParagraph(bparams);
+ mergeParagraph(bparams, lastbuffer);
reinitLyXText();
}