Changeset 27567

Show
Ignore:
Timestamp:
11/16/08 19:03:52 (2 months ago)
Author:
vfr
Message:

Make sure the selection painting is updated after LFUN_UP or LFUN_DOWN. See http://thread.gmane.org/gmane.editors.lyx.devel/113428

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • lyx-devel/trunk/src/Cursor.cpp

    r27465 r27567  
    17031703 
    17041704 
     1705bool Cursor::atFirstOrLastRow(bool up) 
     1706{ 
     1707        TextMetrics const & tm = bv_->textMetrics(text()); 
     1708        ParagraphMetrics const & pm = tm.parMetrics(pit()); 
     1709         
     1710        int row; 
     1711        if (pos() && boundary()) 
     1712                row = pm.pos2row(pos() - 1); 
     1713        else 
     1714                row = pm.pos2row(pos()); 
     1715         
     1716        if (up) { 
     1717                if (pit() == 0 && row == 0) 
     1718                        return true; 
     1719        } else { 
     1720                if (pit() + 1 >= int(text()->paragraphs().size()) && 
     1721                                row + 1 >= int(pm.rows().size())) 
     1722                        return true; 
     1723        } 
     1724        return false; 
     1725} 
     1726 
    17051727bool Cursor::upDownInText(bool up, bool & updateNeeded) 
    17061728{ 
     
    17561778                row = pm.pos2row(pos()); 
    17571779                 
    1758         // are we not at the start or end? 
    1759         if (up) { 
    1760                 if (pit() == 0 && row == 0) 
    1761                         return false; 
    1762         } else { 
    1763                 if (pit() + 1 >= int(text()->paragraphs().size()) && 
    1764                                 row + 1 >= int(pm.rows().size())) 
    1765                         return false; 
    1766         } 
     1780        if (atFirstOrLastRow(up)) 
     1781                return false; 
    17671782 
    17681783        // with and without selection are handled differently 
  • lyx-devel/trunk/src/Cursor.h

    r27465 r27567  
    360360        /// return true if fullscreen update is needed 
    361361        bool down(); 
     362        /// whether the cursor is either at the first or last row 
     363        bool atFirstOrLastRow(bool up); 
    362364        /// move up/down in a text inset, called for LFUN_UP/DOWN, 
    363365        /// return true if successful, updateNeeded set to true if fullscreen 
  • lyx-devel/trunk/src/Text3.cpp

    r27562 r27567  
    641641                bool select = cmd.action == LFUN_DOWN_SELECT || 
    642642                        cmd.action == LFUN_UP_SELECT; 
    643                 cur.selHandle(select); 
    644643 
    645644                // move cursor up/down 
    646645                bool up = cmd.action == LFUN_UP_SELECT || cmd.action == LFUN_UP; 
    647                 bool const successful = cur.upDownInText(up, needsUpdate); 
    648                 if (successful) { 
    649                         // redraw if you leave mathed (for the decorations) 
     646                bool const atFirstOrLastRow = cur.atFirstOrLastRow(up); 
     647 
     648                if (!atFirstOrLastRow) { 
     649                        needsUpdate |= cur.selHandle(select);    
     650                        cur.selHandle(select); 
     651                        cur.upDownInText(up, needsUpdate); 
    650652                        needsUpdate |= cur.beforeDispatchCursor().inMathed(); 
    651                 } else 
     653                } else { 
     654                        // if the cursor cannot be moved up or down do not remove 
     655                        // the selection right now, but wait for the next dispatch. 
     656                        if (select) 
     657                                needsUpdate |= cur.selHandle(select);    
     658                        cur.upDownInText(up, needsUpdate); 
    652659                        cur.undispatched(); 
     660                } 
    653661 
    654662                break;