mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-13 17:20:55 +00:00
Backport jump-back button
http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg147979.html git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_6_X@28819 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
d735335c88
commit
f6ad811535
@ -1341,6 +1341,7 @@ lib_images_files = Split('''
|
|||||||
amssymb.png
|
amssymb.png
|
||||||
banner.png
|
banner.png
|
||||||
bookmark-goto.png
|
bookmark-goto.png
|
||||||
|
bookmark-goto_0.png
|
||||||
bookmark-save.png
|
bookmark-save.png
|
||||||
box-insert.png
|
box-insert.png
|
||||||
break-line.png
|
break-line.png
|
||||||
|
@ -270,6 +270,7 @@ dist_images_DATA = \
|
|||||||
images/amssymb.png \
|
images/amssymb.png \
|
||||||
images/banner.png \
|
images/banner.png \
|
||||||
images/bookmark-goto.png \
|
images/bookmark-goto.png \
|
||||||
|
images/bookmark-goto_0.png \
|
||||||
images/bookmark-save.png \
|
images/bookmark-save.png \
|
||||||
images/box-insert.png \
|
images/box-insert.png \
|
||||||
images/break-line.png \
|
images/break-line.png \
|
||||||
|
BIN
lib/images/bookmark-goto_0.png
Normal file
BIN
lib/images/bookmark-goto_0.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 937 B |
@ -88,7 +88,7 @@ Menuset
|
|||||||
#
|
#
|
||||||
Menu "context-label"
|
Menu "context-label"
|
||||||
Item "Next Cross-Reference|N" "reference-next"
|
Item "Next Cross-Reference|N" "reference-next"
|
||||||
Item "Go back to Reference|G" "bookmark-goto 0"
|
Item "Go back|G" "bookmark-goto 0"
|
||||||
Separator
|
Separator
|
||||||
Item "Copy as Reference|C" "copy-label-as-reference"
|
Item "Copy as Reference|C" "copy-label-as-reference"
|
||||||
Separator
|
Separator
|
||||||
@ -264,7 +264,7 @@ Menuset
|
|||||||
Item "Paste" "paste"
|
Item "Paste" "paste"
|
||||||
Submenu "Paste Recent|e" "edit_pasterecent"
|
Submenu "Paste Recent|e" "edit_pasterecent"
|
||||||
Separator
|
Separator
|
||||||
Item "Jump to Saved Bookmark|B" "bookmark-goto 0"
|
Item "Jump Back to Saved Bookmark|B" "bookmark-goto 0"
|
||||||
Separator
|
Separator
|
||||||
Item "Move Paragraph Up|o" "paragraph-move-up"
|
Item "Move Paragraph Up|o" "paragraph-move-up"
|
||||||
Item "Move Paragraph Down|v" "paragraph-move-down"
|
Item "Move Paragraph Down|v" "paragraph-move-down"
|
||||||
|
@ -67,6 +67,7 @@ ToolbarSet
|
|||||||
Item "Copy" "copy"
|
Item "Copy" "copy"
|
||||||
Item "Paste" "paste"
|
Item "Paste" "paste"
|
||||||
Item "Find and replace" "dialog-show findreplace"
|
Item "Find and replace" "dialog-show findreplace"
|
||||||
|
Item "Navigate back" "bookmark-goto 0"
|
||||||
Separator
|
Separator
|
||||||
Item "Toggle emphasis" "font-emph"
|
Item "Toggle emphasis" "font-emph"
|
||||||
Item "Toggle noun" "font-noun"
|
Item "Toggle noun" "font-noun"
|
||||||
|
@ -216,7 +216,7 @@ struct BufferView::Private
|
|||||||
Private(BufferView & bv): wh_(0), cursor_(bv),
|
Private(BufferView & bv): wh_(0), cursor_(bv),
|
||||||
anchor_pit_(0), anchor_ypos_(0),
|
anchor_pit_(0), anchor_ypos_(0),
|
||||||
inlineCompletionUniqueChars_(0),
|
inlineCompletionUniqueChars_(0),
|
||||||
last_inset_(0), gui_(0)
|
last_inset_(0), bookmark_edit_position_(0), gui_(0)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
///
|
///
|
||||||
@ -259,6 +259,9 @@ struct BufferView::Private
|
|||||||
*/
|
*/
|
||||||
Inset * last_inset_;
|
Inset * last_inset_;
|
||||||
|
|
||||||
|
// cache for id of the paragraph which was edited the last time
|
||||||
|
int bookmark_edit_position_;
|
||||||
|
|
||||||
mutable TextMetricsCache text_metrics_;
|
mutable TextMetricsCache text_metrics_;
|
||||||
|
|
||||||
/// Whom to notify.
|
/// Whom to notify.
|
||||||
@ -659,6 +662,16 @@ CursorStatus BufferView::cursorStatus(DocIterator const & dit) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void BufferView::bookmarkEditPosition()
|
||||||
|
{
|
||||||
|
// Don't eat cpu time for each keystroke
|
||||||
|
if (d->cursor_.paragraph().id() == d->bookmark_edit_position_)
|
||||||
|
return;
|
||||||
|
saveBookmark(0);
|
||||||
|
d->bookmark_edit_position_ = d->cursor_.paragraph().id();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void BufferView::saveBookmark(unsigned int idx)
|
void BufferView::saveBookmark(unsigned int idx)
|
||||||
{
|
{
|
||||||
// tenatively save bookmark, id and pos will be used to
|
// tenatively save bookmark, id and pos will be used to
|
||||||
|
@ -289,6 +289,8 @@ public:
|
|||||||
void insertPlaintextFile(support::FileName const & f, bool asParagraph);
|
void insertPlaintextFile(support::FileName const & f, bool asParagraph);
|
||||||
///
|
///
|
||||||
void insertLyXFile(support::FileName const & f);
|
void insertLyXFile(support::FileName const & f);
|
||||||
|
/// save temporary bookmark for jump back navigation
|
||||||
|
void bookmarkEditPosition();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// noncopyable
|
/// noncopyable
|
||||||
|
@ -2237,7 +2237,7 @@ void LyXAction::init()
|
|||||||
* \var lyx::FuncCode lyx::LFUN_LABEL_GOTO
|
* \var lyx::FuncCode lyx::LFUN_LABEL_GOTO
|
||||||
* \li Action: Goto a label.
|
* \li Action: Goto a label.
|
||||||
* \li Syntax: label-goto [<LABEL>]
|
* \li Syntax: label-goto [<LABEL>]
|
||||||
* \li Params: <LABEL>: Requested label. If no label is given and refernce
|
* \li Params: <LABEL>: Requested label. If no label is given and reference
|
||||||
is on cursor position, Bookmark 0 is saved and
|
is on cursor position, Bookmark 0 is saved and
|
||||||
cursor moves to the position of referenced label.
|
cursor moves to the position of referenced label.
|
||||||
* \li Origin: Ale, 6 Aug 1997
|
* \li Origin: Ale, 6 Aug 1997
|
||||||
@ -2264,10 +2264,15 @@ void LyXAction::init()
|
|||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \var lyx::FuncCode lyx::LFUN_BOOKMARK_GOTO
|
* \var lyx::FuncCode lyx::LFUN_BOOKMARK_GOTO
|
||||||
* \li Action: Goto a bookmark.
|
* \li Action: Moves the cursor to the numbered bookmark, opening the file
|
||||||
* \li Notion: Moves the cursor to the numbered bookmark, opening the file
|
|
||||||
if necessary. Note that bookmarsk are saved per-session, not
|
if necessary. Note that bookmarsk are saved per-session, not
|
||||||
per file.
|
per file.
|
||||||
|
* \li Notion: Bookmark 0 has a special purpose. It is automatically set \n
|
||||||
|
1. to the paragraph you are currently editing \n
|
||||||
|
2. to the paragraph from where you are jumping to the last-edited
|
||||||
|
position (jump-back feature) \n
|
||||||
|
3. when jumping from crossreference to the requested label by
|
||||||
|
#LFUN_LABEL_GOTO.
|
||||||
* \li Syntax: bookmark-goto <NUMBER>
|
* \li Syntax: bookmark-goto <NUMBER>
|
||||||
* \li Params: <NUMBER>: the number of the bookmark to restore.
|
* \li Params: <NUMBER>: the number of the bookmark to restore.
|
||||||
* \li Origin: Dekel, 27 January 2001
|
* \li Origin: Dekel, 27 January 2001
|
||||||
|
@ -256,15 +256,27 @@ void LyXFunc::gotoBookmark(unsigned int idx, bool openFile, bool switchToBuffer)
|
|||||||
if (!theBufferList().exists(bm.filename))
|
if (!theBufferList().exists(bm.filename))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// bm can be changed when saving
|
||||||
|
BookmarksSection::Bookmark tmp = bm;
|
||||||
|
|
||||||
|
// Special case idx == 0 used for back-from-back jump navigation
|
||||||
|
if (idx == 0)
|
||||||
|
dispatch(FuncRequest(LFUN_BOOKMARK_SAVE, "0"));
|
||||||
|
|
||||||
// if the current buffer is not that one, switch to it.
|
// if the current buffer is not that one, switch to it.
|
||||||
if (lyx_view_->buffer()->fileName() != bm.filename) {
|
if (lyx_view_->buffer()->fileName() != tmp.filename) {
|
||||||
if (!switchToBuffer)
|
if (!switchToBuffer)
|
||||||
return;
|
return;
|
||||||
dispatch(FuncRequest(LFUN_BUFFER_SWITCH, file));
|
dispatch(FuncRequest(LFUN_BUFFER_SWITCH, file));
|
||||||
}
|
}
|
||||||
|
|
||||||
// moveToPosition try paragraph id first and then paragraph (pit, pos).
|
// moveToPosition try paragraph id first and then paragraph (pit, pos).
|
||||||
if (!view()->moveToPosition(bm.bottom_pit, bm.bottom_pos,
|
if (!view()->moveToPosition(tmp.bottom_pit, tmp.bottom_pos,
|
||||||
bm.top_id, bm.top_pos))
|
tmp.top_id, tmp.top_pos))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// bm changed
|
||||||
|
if (idx == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Cursor jump succeeded!
|
// Cursor jump succeeded!
|
||||||
|
@ -1362,6 +1362,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
|
|||||||
|
|
||||||
cur.resetAnchor();
|
cur.resetAnchor();
|
||||||
moveCursor(cur, false);
|
moveCursor(cur, false);
|
||||||
|
bv->bookmarkEditPosition();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user