]> git.lyx.org Git - features.git/commitdiff
Three patches from Dekel. Read ChangeLog
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Mon, 5 Jun 2000 15:12:09 +0000 (15:12 +0000)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Mon, 5 Jun 2000 15:12:09 +0000 (15:12 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@791 a592a061-630c-0410-9148-cb99ea01b6c8

14 files changed:
ChangeLog
forms/lyx.fd
src/BufferView.C
src/BufferView.h
src/BufferView2.C
src/BufferView_pimpl.C
src/BufferView_pimpl.h
src/insets/insetlabel.C
src/lyx.C
src/lyx.h
src/lyx_cb.C
src/lyx_gui_misc.C
src/menus.C
src/text2.C

index df28f3f1543f7ce244db6f2248e0bd8a879c8a65..982ad62f92777198a0034e3ce408eec1c40ea6a6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,32 @@
+2000-06-02  Dekel Tsur  <dekel@math.tau.ac.il>
+
+       * src/BufferView2.C (removeAutoInsets): Fix a bug: 
+       Do not call to SetCursor when the paragraph is a closed footnote!
+
+2000-06-01  Dekel Tsur  <dekel@math.tau.ac.il>
+
+       * 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  <dekel@math.tau.ac.il>
+
+       * 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  <larsbj@lyx.org>
 
        * src/lyx_cb.C (MakeLaTeXOutput): we run MakeLaTeXOutput regard
index 8547380f3f61dab7698a9aa1299e8bc7da52f535..c879241dc14c786c51fdac159d42700dee3c5a09 100644 (file)
@@ -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
index 8fe15ff5eecdbe2e452ae84a8abfbe3311c03298..b422edcd572e091cd135def40e57168b8c399b84 100644 (file)
@@ -237,6 +237,12 @@ void BufferView::restorePosition()
 }
 
 
+bool BufferView::NoSavedPositions()
+{
+       return pimpl_->NoSavedPositions();
+}
+
+
 void BufferView::update(signed char f)
 {
        pimpl_->update(f);
index 4d85b4008c3f3f431baa449838e483ccb1f734fb..b1e1e11b8b7a5043a90b829f6a358ec6b9f98477 100644 (file)
@@ -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)
        */
index 656b598f36d9100ccf6c637067956f994bbabe97..d3a61c3ac6f847c131bc5a7a7359b8935ebbfdc9 100644 (file)
@@ -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){
index 5b627e50e9262f0c30d4f33587c66492f54823a7..bcf925758574e22421f405ac19a8a43dad67d978 100644 (file)
@@ -1380,6 +1380,11 @@ void BufferView::Pimpl::restorePosition()
        update(0);
 } 
 
+bool BufferView::Pimpl::NoSavedPositions()
+{
+       return backstack.empty();
+}
+
 
 void BufferView::Pimpl::setState()
 {
index 68c6b8b89f4f01f6fa1c1c334186cc6c276188f8..9edfbb3743aade60b2cc3c3e58e0c640046b7f01 100644 (file)
@@ -89,6 +89,8 @@ struct BufferView::Pimpl {
        ///
        void restorePosition();
        ///
+       bool NoSavedPositions();
+       ///
        void setState();
        ///
        void insetSleep();
index 32e167cedad9c5cedbf824e56af4600db9180a59..ea7b8e6e1e99c2c2800ac52e2179d142e1d2f6c7 100644 (file)
@@ -48,7 +48,7 @@ vector<string> 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();
index 3747cc7da1c6ba190bd1a38329f1d369f842d0b5..6d00442aeb627a39054e4c9e1f31945592a58be4 100644 (file)
--- 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;
index 181b09a46de20fb778922499ef77b70dc177f3d2..5ba0cd9c0fc109f7dcc226ae32c9721a2889353d 100644 (file)
--- 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);
index 7749933ed7ce771765677c3c2e86f733f2ccefe2..f93db63ab5b4820201290c8b340f2205e44cfc99 100644 (file)
@@ -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 ***"));
index 1df880a7ae69a46e0a5c7518d9301559aecc06f7..88ded8a2e47f509a7c50170b086a620cf2a61a42 100644 (file)
@@ -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);
index 115a981bf93cd04cab570555dfab9c9dfc0f6031..34a192be72c64a5891ca1173aaebbb0212caea71 100644 (file)
@@ -1417,12 +1417,17 @@ void Add_to_refs_menu(vector<string> const & label_list, int offset,
        typedef vector<string>::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<string> 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());
index adc55916568f2f4a05fd5f034fcb145701a19fb3..c64e3803228ae8c3762939584ed9aa27e49401e8 100644 (file)
@@ -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;