Changeset 27567
- Timestamp:
- 11/16/08 19:03:52 (2 months ago)
- Files:
-
- lyx-devel/trunk/src/Cursor.cpp (modified) (2 diffs)
- lyx-devel/trunk/src/Cursor.h (modified) (1 diff)
- lyx-devel/trunk/src/Text3.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
lyx-devel/trunk/src/Cursor.cpp
r27465 r27567 1703 1703 1704 1704 1705 bool 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 1705 1727 bool Cursor::upDownInText(bool up, bool & updateNeeded) 1706 1728 { … … 1756 1778 row = pm.pos2row(pos()); 1757 1779 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; 1767 1782 1768 1783 // with and without selection are handled differently lyx-devel/trunk/src/Cursor.h
r27465 r27567 360 360 /// return true if fullscreen update is needed 361 361 bool down(); 362 /// whether the cursor is either at the first or last row 363 bool atFirstOrLastRow(bool up); 362 364 /// move up/down in a text inset, called for LFUN_UP/DOWN, 363 365 /// return true if successful, updateNeeded set to true if fullscreen lyx-devel/trunk/src/Text3.cpp
r27562 r27567 641 641 bool select = cmd.action == LFUN_DOWN_SELECT || 642 642 cmd.action == LFUN_UP_SELECT; 643 cur.selHandle(select);644 643 645 644 // move cursor up/down 646 645 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); 650 652 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); 652 659 cur.undispatched(); 660 } 653 661 654 662 break;
