#include "ParagraphParameters.h"
#include "undo_funcs.h"
#include "funcrequest.h"
-#include "language.h"
#include "insets/insetbib.h"
#include "insets/insettext.h"
#include "insets/insetref.h"
#include "insets/insetparent.h"
#include "insets/insetindex.h"
-#include "insets/insetnote.h"
#include "insets/insetinclude.h"
#include "insets/insetcite.h"
-#include "insets/insetert.h"
-#include "insets/insetexternal.h"
#include "insets/insetgraphics.h"
-#include "insets/insetfoot.h"
#include "insets/insetmarginal.h"
-#include "insets/insetminipage.h"
-#include "insets/insetfloat.h"
-#include "insets/insettabular.h"
-#include "insets/insetoptarg.h"
-#if 0
-#include "insets/insettheorem.h"
-#include "insets/insetlist.h"
-#endif
#include "insets/insetcaption.h"
#include "insets/insetfloatlist.h"
#include "support/LAssert.h"
#include "support/lstrings.h"
#include "support/filetools.h"
-#include "support/lyxfunctional.h"
#include <boost/bind.hpp>
#include <boost/signals/connection.hpp>
-#include <cstdio>
-#include <ctime>
#include <unistd.h>
#include <sys/wait.h>
-#include <clocale>
-#ifndef CXX_GLOBAL_CSTD
-using std::tm;
-using std::localtime;
-using std::time;
-using std::setlocale;
-using std::strftime;
-#endif
-
using std::vector;
using std::find_if;
using std::find;
using std::min;
using lyx::pos_type;
-using lyx::textclass_type;
/* the selection possible is needed, that only motion events are
* used, where the bottom press event was on the drawing area too */
bool selection_possible = false;
extern BufferList bufferlist;
-extern char ascii_type;
-
extern int bibitemMaxWidth(BufferView *, LyXFont const &);
LyXCursor cursor;
text->setCursorFromCoordinates(bv_, cursor, x, y_tmp);
- Inset * inset(checkInset(*text, cursor, x, y_tmp));
+ Inset * inset = checkInset(*text, cursor, x, y_tmp);
if (inset) {
y = y_tmp;
}
// look at previous position
-
if (cursor.pos() == 0) {
return 0;
}
if (lyxerr.debugging())
textcache.show(lyxerr, "Expose delete all");
textcache.clear();
- // FIXME: this is aalready done in resizeCurrentBuffer() ??
+ // FIXME: this is already done in resizeCurrentBuffer() ??
buffer_->resizeInsets(bv_);
} else if (heightChange) {
// fitCursor() ensures we don't jump back
}
-void BufferView::Pimpl::finishChange(bool fitcur)
-{
- finishUndo();
- moveCursorUpdate(fitcur);
- bv_->owner()->view_state_changed();
-}
-
-
void BufferView::Pimpl::savePosition(unsigned int i)
{
if (i >= saved_positions_num)
*/
-void BufferView::Pimpl::moveCursorUpdate(bool selecting, bool fitcur)
-{
- LyXText * lt = bv_->getLyXText();
-
- if (selecting || lt->selection.mark()) {
- lt->setSelection(bv_);
- if (lt->bv_owner)
- toggleToggle();
- else
- updateInset(lt->inset_owner, false);
- }
- if (lt->bv_owner) {
- if (fitcur)
- update(lt, BufferView::SELECT|BufferView::FITCUR);
- else
- update(lt, BufferView::SELECT);
- showCursor();
- } else if (bv_->text->status() != LyXText::UNCHANGED) {
- bv_->theLockingInset()->hideInsetCursor(bv_);
- update(bv_->text, BufferView::SELECT|BufferView::FITCUR);
- showCursor();
- }
-
- if (!lt->selection.set())
- workarea().haveSelection(false);
-
- switchKeyMap();
-}
-
-
Inset * BufferView::Pimpl::getInsetByCode(Inset::Code code)
{
#if 0
break;
}
- case LFUN_PASTE:
- bv_->paste();
- switchKeyMap();
- break;
-
- case LFUN_CUT:
- bv_->cut();
- break;
-
- case LFUN_COPY:
- bv_->copy();
- break;
-
case LFUN_LAYOUT_COPY:
bv_->copyEnvironment();
break;
switchKeyMap();
break;
- case LFUN_GOTOERROR:
- gotoInset(Inset::ERROR_CODE, false);
- break;
-
- case LFUN_GOTONOTE:
- gotoInset(Inset::NOTE_CODE, false);
- break;
-
- case LFUN_REFERENCE_GOTO:
- {
- vector<Inset::Code> tmp;
- tmp.push_back(Inset::LABEL_CODE);
- tmp.push_back(Inset::REF_CODE);
- gotoInset(tmp, true);
- break;
- }
-
case LFUN_DEPTH_MIN:
changeDepth(bv_, bv_->getLyXText(), -1);
break;
}
break;
- case LFUN_QUOTE:
- smartQuote();
- break;
-
case LFUN_HTMLURL:
case LFUN_URL:
{
}
break;
- case LFUN_INSET_ERT:
- insertAndEditInset(new InsetERT(buffer_->params));
- break;
-
- case LFUN_INSET_EXTERNAL:
- insertAndEditInset(new InsetExternal);
- break;
-
- case LFUN_INSET_FOOTNOTE:
- insertAndEditInset(new InsetFoot(buffer_->params));
- break;
-
- case LFUN_INSET_MARGINAL:
- insertAndEditInset(new InsetMarginal(buffer_->params));
- break;
-
- case LFUN_INSET_MINIPAGE:
- insertAndEditInset(new InsetMinipage(buffer_->params));
- break;
-
- case LFUN_INSERT_NOTE:
- insertAndEditInset(new InsetNote(buffer_->params));
- break;
-
- case LFUN_INSET_OPTARG:
- insertAndEditInset(new InsetOptArg(buffer_->params));
- break;
-
- case LFUN_INSET_FLOAT:
- // check if the float type exist
- if (floatList.typeExist(ev.argument)) {
- insertAndEditInset(new InsetFloat(buffer_->params,
- ev.argument));
- } else {
- lyxerr << "Non-existent float type: "
- << ev.argument << endl;
- }
- break;
-
- case LFUN_INSET_WIDE_FLOAT:
- // check if the float type exist
- if (floatList.typeExist(ev.argument)) {
- InsetFloat * new_inset =
- new InsetFloat(buffer_->params, ev.argument);
- new_inset->wide(true);
- insertAndEditInset(new_inset);
- } else {
- lyxerr << "Non-existent float type: "
- << ev.argument << endl;
- }
- break;
-
-#if 0
- case LFUN_INSET_LIST:
- insertAndEditInset(new InsetList);
- break;
-
- case LFUN_INSET_THEOREM:
- insertAndEditInset(new InsetTheorem);
- break;
-#endif
-
case LFUN_INSET_CAPTION:
{
// Do we have a locking inset...
}
break;
- case LFUN_TABULAR_INSERT:
- {
- if (ev.argument.empty()) {
- owner_->getDialogs().showTabularCreate();
- break;
- }
-
- int r = 2;
- int c = 2;
- ::sscanf(ev.argument.c_str(),"%d%d", &r, &c);
- InsetTabular * new_inset =
- new InsetTabular(*buffer_, r, c);
- bool const rtl =
- bv_->getLyXText()->real_current_font.isRightToLeft();
- if (!open_new_inset(new_inset, rtl))
- delete new_inset;
- }
- break;
-
// --- accented characters ---------------------------
break;
case LFUN_FLOAT_LIST:
- if (floatList.typeExist(ev.argument)) {
+ if (tclass.floats().typeExist(ev.argument)) {
Inset * inset = new InsetFloatList(ev.argument);
if (!insertInset(inset, tclass.defaultLayoutName()))
delete inset;
}
break;
- case LFUN_DATE_INSERT: // jdblair: date-insert cmd
- {
- time_t now_time_t = time(NULL);
- struct tm * now_tm = localtime(&now_time_t);
- setlocale(LC_TIME, "");
- string arg;
- if (!ev.argument.empty())
- arg = ev.argument;
- else
- arg = lyxrc.date_insert_format;
- char datetmp[32];
- int const datetmp_len =
- ::strftime(datetmp, 32, arg.c_str(), now_tm);
-
- LyXText * lt = bv_->getLyXText();
-
- for (int i = 0; i < datetmp_len; i++) {
- lt->insertChar(bv_, datetmp[i]);
- update(lt,
- BufferView::SELECT
- | BufferView::FITCUR
- | BufferView::CHANGE);
- }
-
- lt->selection.cursor = lt->cursor;
- moveCursorUpdate(false);
- }
- break;
-
case LFUN_UNKNOWN_ACTION:
ev.errorMessage(N_("Unknown function!"));
break;
}
-void BufferView::Pimpl::smartQuote()
-{
- LyXText const * lt = bv_->getLyXText();
- Paragraph const * par = lt->cursor.par();
- pos_type pos = lt->cursor.pos();
- char c;
-
- if (!pos
- || (par->isInset(pos - 1)
- && par->getInset(pos - 1)->isSpace()))
- c = ' ';
- else
- c = par->getChar(pos - 1);
-
- hideCursor();
-
- LyXLayout_ptr const & style = par->layout();
-
- if (style->pass_thru ||
- par->getFontSettings(buffer_->params,
- pos).language()->lang() == "hebrew" ||
- (!insertInset(new InsetQuotes(c, buffer_->params))))
- bv_->owner()->dispatch(FuncRequest(LFUN_SELFINSERT, "\""));
-}
-
-
-void BufferView::Pimpl::insertAndEditInset(Inset * inset)
-{
-#if 0
- if (insertInset(inset))
- inset->edit(bv_);
- else
- delete inset;
-#else
- bool gotsel = false;
-
- if (bv_->getLyXText()->selection.set()) {
- bv_->getLyXText()->cutSelection(bv_, true, false);
- gotsel = true;
- }
-
- if (insertInset(inset)) {
- inset->edit(bv_);
- if (gotsel)
- owner_->dispatch(FuncRequest(LFUN_PASTESELECTION));
- }
- else
- delete inset;
-#endif
-}
-
-
-// Open and lock an updatable inset
-bool BufferView::Pimpl::open_new_inset(UpdatableInset * new_inset, bool behind)
-{
- LyXText * lt = bv_->getLyXText();
-
- beforeChange(lt);
- finishUndo();
- if (!insertInset(new_inset)) {
- delete new_inset;
- return false;
- }
- new_inset->edit(bv_, !behind);
- return true;
-}
-
-
bool BufferView::Pimpl::insertInset(Inset * inset, string const & lout)
{
// if we are in a locking inset we should try to insert the
}
}
}
-
-
-void BufferView::Pimpl::gotoInset(vector<Inset::Code> const & codes,
- bool same_content)
-{
- if (!available()) return;
-
- hideCursor();
- beforeChange(bv_->text);
- update(bv_->text, BufferView::SELECT|BufferView::FITCUR);
-
- LyXCursor const & cursor = bv_->text->cursor;
-
- string contents;
- if (same_content &&
- cursor.par()->isInset(cursor.pos())) {
- Inset const * inset = cursor.par()->getInset(cursor.pos());
- if (find(codes.begin(), codes.end(), inset->lyxCode())
- != codes.end())
- contents =
- static_cast<InsetCommand const *>(inset)->getContents();
- }
-
-
- if (!bv_->text->gotoNextInset(bv_, codes, contents)) {
- if (bv_->text->cursor.pos()
- || bv_->text->cursor.par() != bv_->text->ownerParagraph()) {
- LyXCursor tmp = bv_->text->cursor;
- bv_->text->cursor.par(bv_->text->ownerParagraph());
- bv_->text->cursor.pos(0);
- if (!bv_->text->gotoNextInset(bv_, codes, contents)) {
- bv_->text->cursor = tmp;
- bv_->owner()->message(_("No more insets"));
- }
- } else {
- bv_->owner()->message(_("No more insets"));
- }
- }
- update(bv_->text, BufferView::SELECT|BufferView::FITCUR);
- bv_->text->selection.cursor = bv_->text->cursor;
-}
-
-
-void BufferView::Pimpl::gotoInset(Inset::Code code, bool same_content)
-{
- gotoInset(vector<Inset::Code>(1, code), same_content);
-}