mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-26 14:15:32 +00:00
Bookmarks.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1410 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
dd19aa6e63
commit
1ecfd5f425
@ -217,21 +217,21 @@ void BufferView::beforeChange()
|
||||
}
|
||||
|
||||
|
||||
void BufferView::savePosition()
|
||||
void BufferView::savePosition(unsigned int i)
|
||||
{
|
||||
pimpl_->savePosition();
|
||||
pimpl_->savePosition(i);
|
||||
}
|
||||
|
||||
|
||||
void BufferView::restorePosition()
|
||||
void BufferView::restorePosition(unsigned int i)
|
||||
{
|
||||
pimpl_->restorePosition();
|
||||
pimpl_->restorePosition(i);
|
||||
}
|
||||
|
||||
|
||||
bool BufferView::NoSavedPositions()
|
||||
bool BufferView::isSavedPosition(unsigned int i)
|
||||
{
|
||||
return pimpl_->NoSavedPositions();
|
||||
return pimpl_->isSavedPosition(i);
|
||||
}
|
||||
|
||||
|
||||
|
@ -94,11 +94,11 @@ public:
|
||||
///
|
||||
void beforeChange();
|
||||
///
|
||||
void savePosition();
|
||||
void savePosition(unsigned int i);
|
||||
///
|
||||
void restorePosition();
|
||||
void restorePosition(unsigned int i);
|
||||
///
|
||||
bool NoSavedPositions();
|
||||
bool isSavedPosition(unsigned int i);
|
||||
/** This holds the mapping between buffer paragraphs and screen rows.
|
||||
This should be private...but not yet. (Lgb)
|
||||
*/
|
||||
|
@ -35,6 +35,7 @@ using std::pair;
|
||||
using std::endl;
|
||||
using std::vector;
|
||||
using std::make_pair;
|
||||
using std::min;
|
||||
|
||||
/* the selection possible is needed, that only motion events are
|
||||
* used, where the bottom press event was on the drawing area too */
|
||||
@ -47,6 +48,7 @@ extern "C" void TimerCB(FL_OBJECT *, long);
|
||||
extern void sigchldhandler(pid_t pid, int * status);
|
||||
extern int bibitemMaxWidth(BufferView *, LyXFont const &);
|
||||
|
||||
const unsigned int saved_positions_num = 20;
|
||||
|
||||
static inline
|
||||
void waitForX()
|
||||
@ -110,6 +112,7 @@ BufferView::Pimpl::Pimpl(BufferView * b, LyXView * o,
|
||||
cursor_timeout.start();
|
||||
workarea_->setFocus();
|
||||
using_xterm_cursor = false;
|
||||
saved_positions.resize(saved_positions_num);
|
||||
}
|
||||
|
||||
|
||||
@ -1171,20 +1174,23 @@ void BufferView::Pimpl::beforeChange()
|
||||
}
|
||||
|
||||
|
||||
void BufferView::Pimpl::savePosition()
|
||||
void BufferView::Pimpl::savePosition(unsigned int i)
|
||||
{
|
||||
backstack.push(buffer_->fileName(),
|
||||
bv_->text->cursor.x(),
|
||||
bv_->text->cursor.y());
|
||||
if (i >= saved_positions_num)
|
||||
return;
|
||||
saved_positions[i] = Position(buffer_->fileName(),
|
||||
bv_->text->cursor.par()->id(),
|
||||
bv_->text->cursor.pos());
|
||||
}
|
||||
|
||||
|
||||
void BufferView::Pimpl::restorePosition()
|
||||
void BufferView::Pimpl::restorePosition(unsigned int i)
|
||||
{
|
||||
if (backstack.empty()) return;
|
||||
|
||||
int x, y;
|
||||
string fname = backstack.pop(&x, &y);
|
||||
if (i >= saved_positions_num)
|
||||
return;
|
||||
|
||||
|
||||
string fname = saved_positions[i].filename;
|
||||
|
||||
beforeChange();
|
||||
|
||||
@ -1195,14 +1201,22 @@ void BufferView::Pimpl::restorePosition()
|
||||
if (b != 0 ) buffer(b);
|
||||
}
|
||||
|
||||
bv_->text->SetCursorFromCoordinates(bv_, x, y);
|
||||
LyXParagraph * par = bv_->text->GetParFromID(saved_positions[i].par_id);
|
||||
if (!par)
|
||||
return;
|
||||
|
||||
bv_->text->SetCursor(bv_, par,
|
||||
min(par->Last(), saved_positions[i].par_pos));
|
||||
update(BufferView::SELECT|BufferView::FITCUR);
|
||||
}
|
||||
|
||||
|
||||
bool BufferView::Pimpl::NoSavedPositions()
|
||||
bool BufferView::Pimpl::isSavedPosition(unsigned int i)
|
||||
{
|
||||
return backstack.empty();
|
||||
if (i >= saved_positions_num)
|
||||
return false;
|
||||
|
||||
return !saved_positions[i].filename.empty();
|
||||
}
|
||||
|
||||
|
||||
|
@ -5,7 +5,6 @@
|
||||
|
||||
#include "BufferView.h"
|
||||
#include "UpdateInset.h"
|
||||
#include "BackStack.h"
|
||||
#include "Timeout.h"
|
||||
|
||||
#ifdef __GNUG__
|
||||
@ -87,11 +86,11 @@ struct BufferView::Pimpl : public Object {
|
||||
///
|
||||
void beforeChange();
|
||||
///
|
||||
void savePosition();
|
||||
void savePosition(unsigned int i);
|
||||
///
|
||||
void restorePosition();
|
||||
void restorePosition(unsigned int i);
|
||||
///
|
||||
bool NoSavedPositions();
|
||||
bool isSavedPosition(unsigned int i);
|
||||
///
|
||||
void setState();
|
||||
///
|
||||
@ -133,8 +132,6 @@ struct BufferView::Pimpl : public Object {
|
||||
///
|
||||
Timeout cursor_timeout;
|
||||
///
|
||||
BackStack backstack;
|
||||
///
|
||||
int last_click_x;
|
||||
///
|
||||
int last_click_y;
|
||||
@ -149,5 +146,20 @@ struct BufferView::Pimpl : public Object {
|
||||
private:
|
||||
///
|
||||
bool using_xterm_cursor;
|
||||
|
||||
struct Position {
|
||||
/// Filename
|
||||
string filename;
|
||||
/// Cursor paragraph Id
|
||||
int par_id;
|
||||
/// Cursor position
|
||||
int par_pos;
|
||||
///
|
||||
Position() : par_id(0), par_pos(0) {}
|
||||
///
|
||||
Position(string const & f, int id, int pos)
|
||||
: filename(f), par_id(id), par_pos(pos) {}
|
||||
};
|
||||
vector<Position> saved_positions;
|
||||
};
|
||||
#endif
|
||||
|
@ -1,3 +1,12 @@
|
||||
2001-01-27 Dekel Tsur <dekelts@tau.ac.il>
|
||||
|
||||
* BufferView_pimpl.C (savePosition, restorePosition): Use a vector of
|
||||
saved positions instrad of a stack. Furthermore, a position is
|
||||
stored using paragraph id/paragraph position.
|
||||
|
||||
* commandtags.h: Add LFUN_BOOKMARK_SAVE and LFUN_BOOKMARK_GOTO.
|
||||
Remove LFUN_REF_BACK.
|
||||
|
||||
2001-01-27 Dekel Tsur <dekelts@tau.ac.il>
|
||||
|
||||
* converter.C (dvipdfm_options): New method.
|
||||
|
@ -105,6 +105,8 @@ void LyXAction::init()
|
||||
{ LFUN_INSERT_BIBTEX, "bibtex-insert", N_("Insert bibtex"),
|
||||
Noop },
|
||||
{ LFUN_BIBTEX_STYLE, "bibtex-style", "", Noop },
|
||||
{ LFUN_BOOKMARK_GOTO, "bookmark-goto", "", ReadOnly },
|
||||
{ LFUN_BOOKMARK_SAVE, "bookmark-save", "", ReadOnly },
|
||||
{ LFUN_BREAKLINE, "break-line", "", Noop },
|
||||
{ LFUN_BREAKPARAGRAPH, "break-paragraph", "", Noop },
|
||||
{ LFUN_BREAKPARAGRAPHKEEPLAYOUT, "break-paragraph-keep-layout",
|
||||
@ -355,7 +357,6 @@ void LyXAction::init()
|
||||
{ LFUN_RECONFIGURE, "reconfigure",
|
||||
N_("Reconfigure"), NoBuffer },
|
||||
{ LFUN_REDO, "redo", N_("Redo"), Noop },
|
||||
{ LFUN_REF_BACK, "reference-back", "", ReadOnly },
|
||||
{ LFUN_REF_GOTO, "reference-goto", "", ReadOnly },
|
||||
{ LFUN_REF_INSERT, "reference-insert",
|
||||
N_("Insert cross reference"), ReadOnly },
|
||||
|
@ -222,7 +222,7 @@ enum kb_action {
|
||||
LFUN_EXPORT, // Lgb 97-07-29
|
||||
LFUN_INSERTFOOTNOTE, // Bernhard 97-08-07
|
||||
LFUN_REF_GOTO, // 200 // Ale 970806
|
||||
LFUN_REF_BACK, // Ale 970806
|
||||
//LFUN_REF_BACK, // Ale 970806
|
||||
LFUN_PARENTINSERT, // Ale 970813
|
||||
LFUN_REMOVEERRORS, // Asger 970906
|
||||
LFUN_LDOTS, // Asger 970929
|
||||
@ -274,6 +274,8 @@ enum kb_action {
|
||||
LFUN_DIALOG_TABULAR_INSERT, // 250 // Jug 20000825 (old table-insert)
|
||||
LFUN_GOTO_PARAGRAPH, // Dekel 20000826
|
||||
LFUN_REFERENCE_GOTO, // Dekel 20010114
|
||||
LFUN_BOOKMARK_SAVE, // Dekel 20010127
|
||||
LFUN_BOOKMARK_GOTO, // Dekel 20010127
|
||||
LFUN_LASTACTION /* this marks the end of the table */
|
||||
};
|
||||
|
||||
|
@ -364,7 +364,7 @@ void FormRef::gotoRef()
|
||||
}
|
||||
case GOBACK:
|
||||
{
|
||||
lv_->getLyXFunc()->Dispatch(LFUN_REF_BACK);
|
||||
lv_->getLyXFunc()->Dispatch(LFUN_BOOKMARK_GOTO, "0");
|
||||
|
||||
gototype_ = GOREF;
|
||||
b_goto->set_text(GOTO_REF_LABEL);
|
||||
|
@ -108,7 +108,7 @@ void FormRef::goto_ref()
|
||||
QToolTip::add(dialog_->buttonGoto,_("Jump back to original position"));
|
||||
break;
|
||||
case GOTOBACK:
|
||||
lv_->getLyXFunc()->Dispatch(LFUN_REF_BACK);
|
||||
lv_->getLyXFunc()->Dispatch(LFUN_BOOKMARK_GOTO, "0");
|
||||
gotowhere=GOTOREF;
|
||||
dialog_->buttonGoto->setText(_("&Goto reference"));
|
||||
QToolTip::remove(dialog_->buttonGoto);
|
||||
@ -121,7 +121,7 @@ void FormRef::updateRefs()
|
||||
{
|
||||
// list will be re-done, should go back if necessary
|
||||
if (gotowhere==GOTOBACK) {
|
||||
lv_->getLyXFunc()->Dispatch(LFUN_REF_BACK);
|
||||
lv_->getLyXFunc()->Dispatch(LFUN_BOOKMARK_GOTO, "0");
|
||||
gotowhere = GOTOREF;
|
||||
dialog_->buttonGoto->setText(_("&Goto reference"));
|
||||
QToolTip::remove(dialog_->buttonGoto);
|
||||
@ -176,6 +176,7 @@ void FormRef::update(bool switched)
|
||||
if (inset_)
|
||||
dialog_->type->setCurrentItem(InsetRef::getType(params.getCmdName()));
|
||||
|
||||
lv_->getLyXFunc()->Dispatch(LFUN_BOOKMARK_SAVE, "0");
|
||||
dialog_->buttonGoto->setText(_("&Goto reference"));
|
||||
QToolTip::remove(dialog_->buttonGoto);
|
||||
QToolTip::add(dialog_->buttonGoto,_("Jump to selected reference"));
|
||||
|
@ -102,6 +102,8 @@ void FormRef::update()
|
||||
InsetRef::getType(params.getCmdName()) + 1);
|
||||
}
|
||||
|
||||
lv_->getLyXFunc()->Dispatch(LFUN_BOOKMARK_SAVE, "0");
|
||||
|
||||
toggle = GOBACK;
|
||||
fl_set_object_label(dialog_->button_go, _("Goto reference"));
|
||||
|
||||
@ -157,9 +159,10 @@ void FormRef::updateBrowser(vector<string> const & akeys) const
|
||||
string ref = fl_get_input(dialog_->ref);
|
||||
vector<string>::const_iterator cit =
|
||||
find(keys.begin(), keys.end(), ref);
|
||||
if (cit == keys.end())
|
||||
if (cit == keys.end()) {
|
||||
cit = keys.begin();
|
||||
if (ref.empty())
|
||||
fl_set_input(dialog_->ref, (*cit).c_str());
|
||||
} else if (ref.empty())
|
||||
fl_set_input(dialog_->ref, (*cit).c_str());
|
||||
|
||||
int const i = static_cast<int>(cit - keys.begin());
|
||||
@ -218,7 +221,7 @@ bool FormRef::input(FL_OBJECT *, long data)
|
||||
|
||||
case GOBACK:
|
||||
{
|
||||
lv_->getLyXFunc()->Dispatch(LFUN_REF_BACK);
|
||||
lv_->getLyXFunc()->Dispatch(LFUN_BOOKMARK_GOTO, "0");
|
||||
fl_set_object_label(dialog_->button_go,
|
||||
_("Goto reference"));
|
||||
}
|
||||
@ -242,7 +245,7 @@ bool FormRef::input(FL_OBJECT *, long data)
|
||||
}
|
||||
|
||||
toggle = GOBACK;
|
||||
lv_->getLyXFunc()->Dispatch(LFUN_REF_BACK);
|
||||
lv_->getLyXFunc()->Dispatch(LFUN_BOOKMARK_GOTO, "0");
|
||||
fl_set_object_label(dialog_->button_go, _("Goto reference"));
|
||||
|
||||
fl_activate_object(dialog_->type);
|
||||
|
@ -446,9 +446,9 @@ LyXFunc::func_status LyXFunc::getStatus(int ac) const
|
||||
case LFUN_VC_HISTORY:
|
||||
disable = !buf->lyxvc.inUse();
|
||||
break;
|
||||
case LFUN_REF_BACK:
|
||||
disable = owner->view()->NoSavedPositions();
|
||||
break;
|
||||
case LFUN_BOOKMARK_GOTO:
|
||||
disable = !owner->view()->
|
||||
isSavedPosition(strToUnsignedInt(argument));
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -1423,11 +1423,13 @@ string const LyXFunc::Dispatch(int ac,
|
||||
}
|
||||
break;
|
||||
|
||||
case LFUN_REF_BACK:
|
||||
{
|
||||
owner->view()->restorePosition();
|
||||
}
|
||||
break;
|
||||
case LFUN_BOOKMARK_SAVE:
|
||||
owner->view()->savePosition(strToUnsignedInt(argument));
|
||||
break;
|
||||
|
||||
case LFUN_BOOKMARK_GOTO:
|
||||
owner->view()->restorePosition(strToUnsignedInt(argument));
|
||||
break;
|
||||
|
||||
case LFUN_REF_GOTO:
|
||||
{
|
||||
@ -1435,12 +1437,14 @@ string const LyXFunc::Dispatch(int ac,
|
||||
if (label.empty()) {
|
||||
InsetRef * inset =
|
||||
static_cast<InsetRef*>(getInsetByCode(Inset::REF_CODE));
|
||||
if (inset)
|
||||
if (inset) {
|
||||
label = inset->getContents();
|
||||
owner->view()->savePosition(0);
|
||||
}
|
||||
}
|
||||
|
||||
if (!label.empty()) {
|
||||
owner->view()->savePosition();
|
||||
//owner->view()->savePosition(0);
|
||||
if (!owner->view()->gotoLabel(label))
|
||||
WriteAlert(_("Error"),
|
||||
_("Couldn't find this label"),
|
||||
@ -2765,7 +2769,7 @@ string const LyXFunc::Dispatch(int ac,
|
||||
OnlyPath(owner->buffer()->fileName()));
|
||||
setMessage(N_("Opening child document ") +
|
||||
MakeDisplayPath(filename) + "...");
|
||||
owner->view()->savePosition();
|
||||
owner->view()->savePosition(0);
|
||||
if (bufferlist.exists(filename))
|
||||
owner->view()->buffer(bufferlist.getBuffer(filename));
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user