From 609a11852e193730db57ebbd2115c9ca8fb4549d Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Mon, 5 Jun 2000 15:12:09 +0000 Subject: [PATCH] Three patches from Dekel. Read ChangeLog git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@791 a592a061-630c-0410-9148-cb99ea01b6c8 --- ChangeLog | 29 ++++++++++++++++++++++++ forms/lyx.fd | 20 ++++++++++++++++- src/BufferView.C | 6 +++++ src/BufferView.h | 2 ++ src/BufferView2.C | 3 ++- src/BufferView_pimpl.C | 5 +++++ src/BufferView_pimpl.h | 2 ++ src/insets/insetlabel.C | 3 ++- src/lyx.C | 4 ++++ src/lyx.h | 1 + src/lyx_cb.C | 23 +++++++++++++++++-- src/lyx_gui_misc.C | 40 +++++++++++++++++++++++++++++++++ src/menus.C | 49 ++++++++++++++++++++++++++++++----------- src/text2.C | 4 +++- 14 files changed, 172 insertions(+), 19 deletions(-) diff --git a/ChangeLog b/ChangeLog index df28f3f154..982ad62f92 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,32 @@ +2000-06-02 Dekel Tsur + + * src/BufferView2.C (removeAutoInsets): Fix a bug: + Do not call to SetCursor when the paragraph is a closed footnote! + +2000-06-01 Dekel Tsur + + * src/insets/insetlabel.C (Edit): Mark buffer as dirty when a + label is changed. + + * src/text.C (SetCursor): Made the computation of cursor_vpos safer. + +2000-05-31 Dekel Tsur + + * forms/lyx.fd + * src/lyx_cb.C (RefSelectCB): Added "Go Back" button in the insert + reference popup, that activates the reference-back action + + * src/menus.C (ShowRefsMenu): Added "Go Back" menu item. + + * src/menus.C (Add_to_refs_menu): Limit the size of each item in + the menus. Also fixed a bug. + + * src/lyx_cb.C (updateAllVisibleBufferRelatedPopups): Do not close + the math panels when switching buffers (unless new buffer is readonly). + + * src/BufferView.C (NoSavedPositions) + * src/BufferView_pimpl.C (NoSavedPositions): New methods + 2000-06-01 Lars Gullik Bjønnes * src/lyx_cb.C (MakeLaTeXOutput): we run MakeLaTeXOutput regard diff --git a/forms/lyx.fd b/forms/lyx.fd index 8547380f3f..c879241dc1 100644 --- a/forms/lyx.fd +++ b/forms/lyx.fd @@ -502,7 +502,7 @@ argument: 0 Name: form_ref Width: 590 Height: 400 -Number of Objects: 12 +Number of Objects: 13 -------------------- class: FL_BOX @@ -721,5 +721,23 @@ name: prettyref callback: RefSelectCB argument: 4 +-------------------- +class: FL_BUTTON +type: NORMAL_BUTTON +box: 310 320 160 30 +boxtype: FL_UP_BOX +colors: FL_COL1 FL_COL1 +alignment: FL_ALIGN_CENTER +style: FL_NORMAL_STYLE +size: FL_NORMAL_SIZE +lcol: FL_BLACK +label: Go Back|#B +shortcut: +resize: FL_RESIZE_NONE +gravity: FL_SouthWest FL_SouthWest +name: back +callback: RefSelectCB +argument: 6 + ============================== create_the_forms diff --git a/src/BufferView.C b/src/BufferView.C index 8fe15ff5ee..b422edcd57 100644 --- a/src/BufferView.C +++ b/src/BufferView.C @@ -237,6 +237,12 @@ void BufferView::restorePosition() } +bool BufferView::NoSavedPositions() +{ + return pimpl_->NoSavedPositions(); +} + + void BufferView::update(signed char f) { pimpl_->update(f); diff --git a/src/BufferView.h b/src/BufferView.h index 4d85b4008c..b1e1e11b8b 100644 --- a/src/BufferView.h +++ b/src/BufferView.h @@ -73,6 +73,8 @@ public: void savePosition(); /// void restorePosition(); + /// + bool NoSavedPositions(); /** This holds the mapping between buffer paragraphs and screen rows. This should be private...but not yet. (Lgb) */ diff --git a/src/BufferView2.C b/src/BufferView2.C index 656b598f36..d3a61c3ac6 100644 --- a/src/BufferView2.C +++ b/src/BufferView2.C @@ -102,7 +102,8 @@ bool BufferView::removeAutoInsets() bool a = false; while (par) { // this has to be done before the delete - text->SetCursor(cursor, par, 0); + if (par->footnoteflag != LyXParagraph::CLOSED_FOOTNOTE) + text->SetCursor(cursor, par, 0); if (par->AutoDeleteInsets()){ a = true; if (par->footnoteflag != LyXParagraph::CLOSED_FOOTNOTE){ diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index 5b627e50e9..bcf9257585 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -1380,6 +1380,11 @@ void BufferView::Pimpl::restorePosition() update(0); } +bool BufferView::Pimpl::NoSavedPositions() +{ + return backstack.empty(); +} + void BufferView::Pimpl::setState() { diff --git a/src/BufferView_pimpl.h b/src/BufferView_pimpl.h index 68c6b8b89f..9edfbb3743 100644 --- a/src/BufferView_pimpl.h +++ b/src/BufferView_pimpl.h @@ -89,6 +89,8 @@ struct BufferView::Pimpl { /// void restorePosition(); /// + bool NoSavedPositions(); + /// void setState(); /// void insetSleep(); diff --git a/src/insets/insetlabel.C b/src/insets/insetlabel.C index 32e167ceda..ea7b8e6e1e 100644 --- a/src/insets/insetlabel.C +++ b/src/insets/insetlabel.C @@ -48,7 +48,7 @@ vector InsetLabel::getLabelList() const void InsetLabel::Edit(BufferView * bv, int, int, unsigned int) { - if(bv->buffer()->isReadonly()) { + if (bv->buffer()->isReadonly()) { WarnReadonly(bv->buffer()->fileName()); return; } @@ -59,6 +59,7 @@ void InsetLabel::Edit(BufferView * bv, int, int, unsigned int) string new_contents = frontStrip(strip(result.second)); if (!new_contents.empty() && contents != new_contents) { + bv->buffer()->markDirty(); bool flag = bv->ChangeRefs(contents,new_contents); contents = new_contents; bv->text->RedoParagraph(); diff --git a/src/lyx.C b/src/lyx.C index 3747cc7da1..6d00442aeb 100644 --- a/src/lyx.C +++ b/src/lyx.C @@ -190,6 +190,10 @@ FD_form_ref *create_form_form_ref(void) fl_set_object_lsize(obj, FL_NORMAL_SIZE); fl_set_object_gravity(obj, FL_SouthWest, FL_SouthWest); fl_set_object_callback(obj, RefSelectCB, 4); + fdui->back = obj = fl_add_button(FL_NORMAL_BUTTON, 310, 320, 160, 30, idex(_("Go Back|#B")));fl_set_button_shortcut(obj,scex(_("Go Back|#B")), 1); + fl_set_object_lsize(obj,FL_NORMAL_SIZE); + fl_set_object_gravity(obj, FL_SouthWest, FL_SouthWest); + fl_set_object_callback(obj,RefSelectCB, 6); fl_end_form(); //fdui->form_ref->fdui = fdui; diff --git a/src/lyx.h b/src/lyx.h index 181b09a46d..5ba0cd9c0f 100644 --- a/src/lyx.h +++ b/src/lyx.h @@ -81,6 +81,7 @@ typedef struct { FL_OBJECT *vref; FL_OBJECT *vpageref; FL_OBJECT *prettyref; + FL_OBJECT *back; } FD_form_ref; extern FD_form_ref * create_form_form_ref(void); diff --git a/src/lyx_cb.C b/src/lyx_cb.C index 7749933ed7..f93db63ab5 100644 --- a/src/lyx_cb.C +++ b/src/lyx_cb.C @@ -3203,10 +3203,21 @@ extern "C" void RefSelectCB(FL_OBJECT *, long data) if (s.empty()) return; - if (data >= 5) { + if (data == 5) { current_view->owner()->getLyXFunc()->Dispatch(LFUN_REFGOTO, s.c_str()); + if (!current_view->NoSavedPositions()) { + fl_activate_object(fd_form_ref->back); + fl_set_object_lcol(fd_form_ref->back, FL_BLACK); + } return; - } + } else if (data >= 6) { + current_view->owner()->getLyXFunc()->Dispatch(LFUN_REFBACK); + if (current_view->NoSavedPositions()) { + fl_deactivate_object(fd_form_ref->back); + fl_set_object_lcol(fd_form_ref->back, FL_INACTIVE); + } + return; + } static string const commands[5] = { "\\ref", "\\pageref", "\\vref", "\\vpageref", @@ -3262,6 +3273,14 @@ extern "C" void RefUpdateCB(FL_OBJECT *, long) bool sgml = current_view->buffer()->isSGML(); bool readonly = current_view->buffer()->isReadonly(); + if (current_view->NoSavedPositions()) { + fl_deactivate_object(fd_form_ref->back); + fl_set_object_lcol(fd_form_ref->back, FL_INACTIVE); + } else { + fl_activate_object(fd_form_ref->back); + fl_set_object_lcol(fd_form_ref->back, FL_BLACK); + } + if (empty) { fl_add_browser_line(brow, _("*** No labels found in document ***")); diff --git a/src/lyx_gui_misc.C b/src/lyx_gui_misc.C index 1df880a7ae..88ded8a2e4 100644 --- a/src/lyx_gui_misc.C +++ b/src/lyx_gui_misc.C @@ -251,12 +251,51 @@ void updateAllVisibleBufferRelatedPopups() if (fd_form_table->form_table->visible) { fl_hide_form(fd_form_table->form_table); } + +#ifndef ALWAYS_UPDATE_REF + // We must update the popup in order to make the + // insert ref buttons insactive + if (fd_form_ref->form_ref->visible) { + RefUpdateCB(0, 0); + } +#endif + +#ifndef ALWAYS_CLOSE_MATH_PANELS + // The math popups should be closed only if we switch + // to a readonly buffer + if (fd_panel) { + if (fd_panel->panel->visible) { + fl_hide_form(fd_panel->panel); + } + } + if (fd_delim) { + if (fd_delim->delim->visible) { + fl_hide_form(fd_delim->delim); + } + } + if (fd_deco) { + if (fd_deco->deco->visible) { + fl_hide_form(fd_deco->deco); + } + } + if (fd_space) { + if (fd_space->space->visible) { + fl_hide_form(fd_space->space); + } + } + if (fd_matrix) { + if (fd_matrix->matrix->visible) { + fl_hide_form(fd_matrix->matrix); + } + } +#endif } // We have either changed buffers or changed the readonly status // so the safest thing to do is hide all inset popups that // are editting insets from the previous buffer or aren't // allowed in readonly docs. +#ifdef ALWAYS_CLOSE_MATH_PANELS if (fd_panel) { if (fd_panel->panel->visible) { fl_hide_form(fd_panel->panel); @@ -282,6 +321,7 @@ void updateAllVisibleBufferRelatedPopups() fl_hide_form(fd_matrix->matrix); } } +#endif if (citation_form) { if (citation_form->citation_form->visible) { fl_hide_form(citation_form->citation_form); diff --git a/src/menus.C b/src/menus.C index 115a981bf9..34a192be72 100644 --- a/src/menus.C +++ b/src/menus.C @@ -1417,12 +1417,17 @@ void Add_to_refs_menu(vector const & label_list, int offset, typedef vector::size_type size_type; size_type const max_number_of_items = 25; size_type const max_number_of_items2 = 20; + string::size_type const max_item_length = 40; + string::size_type const max_item_length2 = 20; if (label_list.size() <= max_number_of_items) - for (size_type i = 0; i < label_list.size(); ++i) - fl_addtopup(menu, - (label_list[i] + "%x" - +tostr(i+offset)).c_str()); + for (size_type i = 0; i < label_list.size(); ++i) { + string entry = label_list[i]; + if (entry.size() > max_item_length) + entry = entry.substr(0, max_item_length-1) + "$"; + entry += "%x" + tostr(i+offset); + fl_addtopup(menu, entry.c_str()); + } else { size_type count = 0; for (size_type i = 0; i < label_list.size(); @@ -1434,15 +1439,28 @@ void Add_to_refs_menu(vector const & label_list, int offset, } size_type j = std::min(label_list.size(), i+max_number_of_items2); - string entry = label_list[i]+".."+label_list[j-1]; + + string entry; + if (label_list[i].size() > max_item_length2) + entry += label_list[i].substr(0, max_item_length2-1) + "$"; + else + entry += label_list[i]; + entry += ".."; + if (label_list[j-1].size() > max_item_length2) + entry += label_list[j-1].substr(0, max_item_length2-1) + "$"; + else + entry += label_list[j-1]; if (menus.size() < max_number_of_menus) { int menu2 = fl_newpup(FL_ObjWin(ob)); menus.push_back(menu2); - for (size_type k = i; k < j; ++k) - fl_addtopup(menu2, - (label_list[k] + "%x" - + tostr(k+offset)).c_str()); + for (size_type k = i; k < j; ++k) { + string entry2 = label_list[k]; + if (entry2.size() > max_item_length) + entry2 = entry2.substr(0, max_item_length-1) + "$"; + entry2 += "%x" + tostr(k+offset); + fl_addtopup(menu2, entry2.c_str()); + } entry += "%m"; fl_addtopup(menu, entry.c_str(), menu2); } else { @@ -1487,7 +1505,7 @@ void Menus::ShowRefsMenu(FL_OBJECT * ob, long) if (menus.size() < max_number_of_menus) { int menu2 = fl_newpup(FL_ObjWin(ob)); menus.push_back(menu2); - Add_to_refs_menu(label_list, 1+j*BIG_NUM, menu2, menus, ob); + Add_to_refs_menu(label_list, (j+1)*BIG_NUM, menu2, menus, ob); fl_addtopup(RefsMenu, _(MenuNames[j]), menu2); } else { string tmp = _(MenuNames[j]); @@ -1495,6 +1513,7 @@ void Menus::ShowRefsMenu(FL_OBJECT * ob, long) fl_addtopup(RefsMenu, tmp.c_str()); } } + fl_addtopup(RefsMenu, _("Go Back")); bool empty = label_list.empty(); bool sgml = buffer->isSGML(); @@ -1511,6 +1530,8 @@ void Menus::ShowRefsMenu(FL_OBJECT * ob, long) fl_setpup_mode(RefsMenu, 4, FL_PUP_GREY); fl_setpup_mode(RefsMenu, 5, FL_PUP_GREY); } + if (men->currentView()->NoSavedPositions()) + fl_setpup_mode(RefsMenu, 7, FL_PUP_GREY); fl_setpup_position( men->_view->getForm()->x + ob->x, @@ -1522,9 +1543,11 @@ void Menus::ShowRefsMenu(FL_OBJECT * ob, long) fl_set_object_boxtype(ob, FL_FLAT_BOX); fl_redraw_object(ob); - if (choice > 0) { - int type = choice / BIG_NUM; - int num = (choice % BIG_NUM) - 1; + if (choice == 7) + men->_view->getLyXFunc()->Dispatch(LFUN_REFBACK); + else if (choice >= BIG_NUM) { + int type = (choice / BIG_NUM) - 1; + int num = choice % BIG_NUM; if (type >= 5) men->_view->getLyXFunc()->Dispatch(LFUN_REFGOTO, label_list[num].c_str()); diff --git a/src/text2.C b/src/text2.C index adc5591656..c64e380322 100644 --- a/src/text2.C +++ b/src/text2.C @@ -3175,9 +3175,11 @@ void LyXText::SetCursor(LyXCursor & cur, LyXParagraph * par, if (pos > last + 1) // This shouldn't happen. pos = last+1; + else if (pos < row->pos) + pos = row->pos; if (last < row->pos) - cursor_vpos = 0; + cursor_vpos = row->pos; else if (pos > last && !boundary) cursor_vpos = (row->par->isRightToLeftPar()) ? row->pos : last+1; -- 2.39.5