mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-05 13:26:21 +00:00
preliminary 'global cursor' stuff
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7784 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
f6bc7cd3ec
commit
57536be00f
@ -492,7 +492,8 @@ int BufferView::unlockInset(UpdatableInset * inset)
|
||||
dispatch(FuncRequest(LFUN_PARAGRAPH_UPDATE));
|
||||
finishUndo();
|
||||
return 0;
|
||||
} else if (inset && theLockingInset() &&
|
||||
}
|
||||
if (inset && theLockingInset() &&
|
||||
theLockingInset()->unlockInsetInInset(this, inset)) {
|
||||
// Tell the paragraph dialog that we changed paragraph
|
||||
dispatch(FuncRequest(LFUN_PARAGRAPH_UPDATE));
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "buffer_funcs.h"
|
||||
#include "bufferlist.h"
|
||||
#include "bufferparams.h"
|
||||
#include "cursor.h"
|
||||
#include "debug.h"
|
||||
#include "factory.h"
|
||||
#include "FloatList.h"
|
||||
@ -456,8 +457,8 @@ void BufferView::Pimpl::resizeCurrentBuffer()
|
||||
}
|
||||
|
||||
#warning does not help much
|
||||
bv_->text->redoParagraphs(bv_->text->ownerParagraphs().begin(),
|
||||
bv_->text->ownerParagraphs().end());
|
||||
//bv_->text->redoParagraphs(bv_->text->ownerParagraphs().begin(),
|
||||
// bv_->text->ownerParagraphs().end());
|
||||
|
||||
if (par != bv_->text->ownerParagraphs().end()) {
|
||||
bv_->text->selection.set(true);
|
||||
@ -1323,7 +1324,7 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & ev_in)
|
||||
ev.errorMessage(N_("Unknown function!"));
|
||||
break;
|
||||
|
||||
default:
|
||||
default:
|
||||
return bv_->getLyXText()->dispatch(FuncRequest(ev, bv_));
|
||||
} // end of switch
|
||||
|
||||
|
@ -137,6 +137,8 @@ lyx_SOURCES = \
|
||||
converter.h \
|
||||
counters.C \
|
||||
counters.h \
|
||||
cursor.C \
|
||||
cursor.h \
|
||||
debug.C \
|
||||
debug.h \
|
||||
dimension.C \
|
||||
|
@ -368,8 +368,14 @@ string const currentState(BufferView * bv)
|
||||
state << _(", Position: ") << text->cursor.pos();
|
||||
RowList::iterator rit = text->cursorRow();
|
||||
state << bformat(_(", Row b:%1$d e:%2$d"), rit->pos(), rit->end());
|
||||
state << _(", Inset: ") <<
|
||||
(text->cursor.par()->inInset() ? text->cursor.par()->inInset()->id() : -1);
|
||||
state << _(", Inset: ");
|
||||
InsetOld * inset = text->cursor.par()->inInset();
|
||||
if (inset)
|
||||
state << inset << " id: " << inset->id()
|
||||
<< " text: " << inset->getLyXText(bv, true)
|
||||
<< " owner: " << inset->owner();
|
||||
else
|
||||
state << -1;
|
||||
#endif
|
||||
return state.str();
|
||||
}
|
||||
|
78
src/cursor.C
Normal file
78
src/cursor.C
Normal file
@ -0,0 +1,78 @@
|
||||
/**
|
||||
* \file cursor.C
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author Jürgen Vigna
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "buffer.h"
|
||||
#include "BufferView.h"
|
||||
#include "cursor.h"
|
||||
#include "debug.h"
|
||||
#include "iterators.h"
|
||||
#include "lyxtext.h"
|
||||
#include "paragraph.h"
|
||||
|
||||
#include "insets/updatableinset.h"
|
||||
|
||||
using std::vector;
|
||||
|
||||
|
||||
dispatch_result Cursor::dispatch(FuncRequest const &)
|
||||
{
|
||||
for (int i = data_.size() - 1; i >= 0; --i) {
|
||||
lyxerr << "trying to dispatch to " << data_[i].text_ << std::endl;
|
||||
}
|
||||
return UNDISPATCHED;
|
||||
}
|
||||
|
||||
|
||||
void buildCursor(Cursor & cursor, BufferView & bv)
|
||||
{
|
||||
UpdatableInset * inset = bv.theLockingInset();
|
||||
lyxerr << "\nbuildCursor: " << inset << std::endl;
|
||||
if (!inset)
|
||||
return;
|
||||
|
||||
inset = inset->getLockingInset();
|
||||
|
||||
bool ok = false;
|
||||
ParIterator pit = bv.buffer()->par_iterator_begin();
|
||||
ParIterator end = bv.buffer()->par_iterator_end();
|
||||
for ( ; pit != end && !ok; ++pit) {
|
||||
InsetList::iterator it = pit->insetlist.begin();
|
||||
InsetList::iterator iend = pit->insetlist.end();
|
||||
for ( ; it != iend && !ok; ++it)
|
||||
if (it->inset == inset || it->inset == inset->owner())
|
||||
ok = true;
|
||||
}
|
||||
|
||||
if (!ok) {
|
||||
lyxerr << " tli not found! inset: " << inset << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
vector<ParagraphList::iterator> pits;
|
||||
vector<ParagraphList const *> plists;
|
||||
vector<LyXText *> texts;
|
||||
/*
|
||||
pit.getPits(pits, plists, texts);
|
||||
|
||||
cursor.data_.resize(pits.size());
|
||||
for (size_t i = 0, n = pits.size(); i != n; ++i) {
|
||||
cursor.data_[i].text_ = texts[i];
|
||||
cursor.data_[i].pit_ = pits[i];
|
||||
//cursor.data_[i].pos_ = texts[i]->cursor.pos();
|
||||
cursor.data_[i].pos_ = 0;
|
||||
lyxerr << " text: " << cursor.data_[i].text_
|
||||
<< " pit: " << cursor.data_[i].pit_->id()
|
||||
<< " pos: " << cursor.data_[i].pos_
|
||||
<< std::endl;
|
||||
}
|
||||
*/
|
||||
}
|
62
src/cursor.h
Normal file
62
src/cursor.h
Normal file
@ -0,0 +1,62 @@
|
||||
// -*- C++ -*-
|
||||
/**
|
||||
* \file cursor.h
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author André Pönitz
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#ifndef CURSOR_H
|
||||
#define CURSOR_H
|
||||
|
||||
#include "ParagraphList_fwd.h"
|
||||
#include "textcursor.h"
|
||||
|
||||
#include "support/types.h"
|
||||
|
||||
#include "insets/insetbase.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
class LyXText;
|
||||
|
||||
|
||||
/**
|
||||
* The cursor class describes the position of a cursor within a document.
|
||||
*/
|
||||
|
||||
class CursorItem : public TextCursor {
|
||||
public:
|
||||
///
|
||||
CursorItem() : text_(0) {}
|
||||
public:
|
||||
///
|
||||
LyXText * text_;
|
||||
///
|
||||
ParagraphList::iterator pit_;
|
||||
///
|
||||
int pos_;
|
||||
};
|
||||
|
||||
|
||||
class Cursor {
|
||||
public:
|
||||
///
|
||||
Cursor() {}
|
||||
///
|
||||
dispatch_result dispatch(FuncRequest const & cmd);
|
||||
public:
|
||||
/// mainly used as stack, bnut wee need random access
|
||||
std::vector<CursorItem> data_;
|
||||
};
|
||||
|
||||
/// build cursor from current cursor in view
|
||||
void buildCursor(Cursor & cursor, BufferView & bv);
|
||||
|
||||
/// build cursor from (x,y) coordinates
|
||||
void buildCursor(Cursor & cursor, BufferView & bv, int x, int y);
|
||||
|
||||
#endif // LYXCURSOR_H
|
@ -27,6 +27,7 @@
|
||||
#include "bufferlist.h"
|
||||
#include "bufferparams.h"
|
||||
#include "BufferView.h"
|
||||
#include "cursor.h"
|
||||
#include "debug.h"
|
||||
#include "encoding.h"
|
||||
#include "exporter.h"
|
||||
@ -891,6 +892,18 @@ void LyXFunc::dispatch(FuncRequest const & ev, bool verbose)
|
||||
if (view()->available())
|
||||
view()->hideCursor();
|
||||
|
||||
#if 1
|
||||
{
|
||||
Cursor cursor;
|
||||
buildCursor(cursor, *view());
|
||||
if (cursor.dispatch(FuncRequest(ev, view())) == DISPATCHED) {
|
||||
lyxerr << "dispatched by Cursor::dispatch()\n";
|
||||
goto exit_with_message;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
if (view()->available() && view()->theLockingInset()) {
|
||||
InsetOld::RESULT result;
|
||||
if (action > 1 || (action == LFUN_UNKNOWN_ACTION &&
|
||||
|
Loading…
Reference in New Issue
Block a user