#include "undo.h"
#include "vspace.h"
+#include "insets/insetbibtex.h"
#include "insets/insetref.h"
#include "insets/insettext.h"
boost::signals::connection lostcon;
-/// Get next inset of this class from current cursor position
+/// Return an inset of this class if it exists at the current cursor position
template <class T>
T * getInsetByCode(LCursor & cur, InsetBase::Code code)
{
cur.clearSelection();
break;
case bv_funcs::CUR_INSIDE:
- int const y = bv_funcs::getPos(cur).y_;
+ int const y = bv_funcs::getPos(cur, cur.boundary()).y_;
int const newy = min(last, max(y, first));
if (y != newy) {
cur.reset(buffer_->inset());
* of the cursor. Note we cannot do this inside
* dispatch() itself, because that's called recursively.
*/
- if (available()) {
- screen().prepareCursor();
- cursor_timeout.setTimeout(100);
- cursor_timeout.restart();
- cursor_timeout.setTimeout(400);
- }
+ if (available())
+ screen().showCursor(*bv_);
}
LyXFont const font = cursor_.getFont();
int const asc = font_metrics::maxAscent(font);
int const des = font_metrics::maxDescent(font);
- Point p = bv_funcs::getPos(cursor_);
+ Point const p = bv_funcs::getPos(cursor_, cursor_.boundary());
if (p.y_ - asc >= 0 && p.y_ + des < workarea().workHeight())
return false;
}
void BufferView::Pimpl::update(Update::flags flags)
{
- lyxerr << BOOST_CURRENT_FUNCTION
- << "[fitcursor = " << (flags & Update::FitCursor)
- << ", forceupdate = " << (flags & Update::Force)
- << ", singlepar = " << (flags & Update::SinglePar)
- << "] buffer: " << buffer_ << endl;
+ lyxerr[Debug::DEBUG]
+ << BOOST_CURRENT_FUNCTION
+ << "[fitcursor = " << (flags & Update::FitCursor)
+ << ", forceupdate = " << (flags & Update::Force)
+ << ", singlepar = " << (flags & Update::SinglePar)
+ << "] buffer: " << buffer_ << endl;
// Check needed to survive LyX startup
if (buffer_) {
CoordCache backup;
std::swap(theCoords, backup);
-
+
// This, together with doneUpdating(), verifies (using
- // asserts) that screen redraw is not called from
+ // asserts) that screen redraw is not called from
// within itself.
theCoords.startUpdating();
bot.text()->redoParagraph(pit);
Paragraph const & par = bot.text()->paragraphs()[pit];
anchor_ref_ = pit;
- offset_ref_ = bv_funcs::coordOffset(cursor_).y_ + par.ascent()
- - workarea().workHeight() / 2;
+ offset_ref_ = bv_funcs::coordOffset(cursor_, cursor_.boundary()).y_
+ + par.ascent() - workarea().workHeight() / 2;
}
bool BufferView::Pimpl::workAreaDispatch(FuncRequest const & cmd0)
{
- lyxerr << BOOST_CURRENT_FUNCTION
- << "[ cmd0 " << cmd0 << "]" << endl;
+ //lyxerr << BOOST_CURRENT_FUNCTION << "[ cmd0 " << cmd0 << "]" << endl;
// This is only called for mouse related events including
// LFUN_FILE_OPEN generated by drag-and-drop.
// Build temporary cursor.
cmd.y = min(max(cmd.y,-1), workarea().workHeight());
InsetBase * inset = bv_->text()->editXY(cur, cmd.x, cmd.y);
- lyxerr << BOOST_CURRENT_FUNCTION
- << " * hit inset at tip: " << inset << endl;
- lyxerr << BOOST_CURRENT_FUNCTION
- << " * created temp cursor:" << cur << endl;
+ //lyxerr << BOOST_CURRENT_FUNCTION
+ // << " * hit inset at tip: " << inset << endl;
+ //lyxerr << BOOST_CURRENT_FUNCTION
+ // << " * created temp cursor:" << cur << endl;
// Put anchor at the same position.
cur.resetAnchor();
case LFUN_FONT_STATE:
case LFUN_INSERT_LABEL:
case LFUN_BOOKMARK_SAVE:
- case LFUN_LABEL_GOTO:
case LFUN_GOTO_PARAGRAPH:
case LFUN_GOTOERROR:
case LFUN_GOTONOTE:
case LFUN_MARK_ON:
case LFUN_SETMARK:
case LFUN_CENTER:
+ case LFUN_BIBDB_ADD:
+ case LFUN_BIBDB_DEL:
case LFUN_WORDS_COUNT:
flag.enabled(true);
break;
+ case LFUN_LABEL_GOTO: {
+ flag.enabled(!cmd.argument.empty()
+ || getInsetByCode<InsetRef>(cursor_, InsetBase::REF_CODE));
+ break;
+ }
+
case LFUN_BOOKMARK_GOTO:
flag.enabled(isSavedPosition(convert<unsigned int>(cmd.argument)));
break;
center();
break;
+ case LFUN_BIBDB_ADD: {
+ LCursor tmpcur = cursor_;
+ bv_funcs::findInset(tmpcur, InsetBase::BIBTEX_CODE, false);
+ InsetBibtex * inset = getInsetByCode<InsetBibtex>(tmpcur,
+ InsetBase::BIBTEX_CODE);
+ if (inset)
+ inset->addDatabase(cmd.argument);
+ break;
+ }
+
+ case LFUN_BIBDB_DEL: {
+ LCursor tmpcur = cursor_;
+ bv_funcs::findInset(tmpcur, InsetBase::BIBTEX_CODE, false);
+ InsetBibtex * inset = getInsetByCode<InsetBibtex>(tmpcur,
+ InsetBase::BIBTEX_CODE);
+ if (inset)
+ inset->delDatabase(cmd.argument);
+ break;
+ }
+
case LFUN_WORDS_COUNT: {
DocIterator from, to;
if (cur.selection()) {
int pit2 = pit;
size_t const npit = text->paragraphs().size();
- lyxerr << BOOST_CURRENT_FUNCTION
- << " npit: " << npit
- << " pit1: " << pit1
- << " pit2: " << pit2
- << endl;
+ lyxerr[Debug::DEBUG]
+ << BOOST_CURRENT_FUNCTION
+ << " npit: " << npit
+ << " pit1: " << pit1
+ << " pit2: " << pit2
+ << endl;
// Rebreak anchor par
text->redoParagraph(pit);
y += text->getPar(pit).descent();
}
- lyxerr << BOOST_CURRENT_FUNCTION
- << " y1: " << y1
- << " y2: " << y2
- << endl;
+ lyxerr[Debug::DEBUG]
+ << BOOST_CURRENT_FUNCTION
+ << " y1: " << y1
+ << " y2: " << y2
+ << endl;
return ViewMetricsInfo(pit1, pit2, y1, y2, singlepar);
}