diff options
Diffstat (limited to 'src/ui/documentwidget.c')
-rw-r--r-- | src/ui/documentwidget.c | 75 |
1 files changed, 35 insertions, 40 deletions
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c index 5c6780d1..a2bea17b 100644 --- a/src/ui/documentwidget.c +++ b/src/ui/documentwidget.c | |||
@@ -1536,7 +1536,7 @@ static iBool handleCommand_DocumentWidget_(iDocumentWidget *d, const char *cmd) | |||
1536 | updateVisible_DocumentWidget_(d); | 1536 | updateVisible_DocumentWidget_(d); |
1537 | return iTrue; | 1537 | return iTrue; |
1538 | } | 1538 | } |
1539 | else if (equalWidget_Command(cmd, w, "scroll.page")) { | 1539 | else if (equal_Command(cmd, "scroll.page") && document_App() == d) { |
1540 | if (argLabel_Command(cmd, "repeat")) { | 1540 | if (argLabel_Command(cmd, "repeat")) { |
1541 | /* TODO: Adjust scroll animation to be linear during repeated scroll? */ | 1541 | /* TODO: Adjust scroll animation to be linear during repeated scroll? */ |
1542 | } | 1542 | } |
@@ -1547,6 +1547,40 @@ static iBool handleCommand_DocumentWidget_(iDocumentWidget *d, const char *cmd) | |||
1547 | smoothDuration_DocumentWidget_); | 1547 | smoothDuration_DocumentWidget_); |
1548 | return iTrue; | 1548 | return iTrue; |
1549 | } | 1549 | } |
1550 | else if (equal_Command(cmd, "scroll.top") && document_App() == d) { | ||
1551 | init_Anim(&d->scrollY, 0); | ||
1552 | invalidate_VisBuf(d->visBuf); | ||
1553 | scroll_DocumentWidget_(d, 0); | ||
1554 | updateVisible_DocumentWidget_(d); | ||
1555 | refresh_Widget(w); | ||
1556 | return iTrue; | ||
1557 | } | ||
1558 | else if (equal_Command(cmd, "scroll.bottom") && document_App() == d) { | ||
1559 | init_Anim(&d->scrollY, scrollMax_DocumentWidget_(d)); | ||
1560 | invalidate_VisBuf(d->visBuf); | ||
1561 | scroll_DocumentWidget_(d, 0); | ||
1562 | updateVisible_DocumentWidget_(d); | ||
1563 | refresh_Widget(w); | ||
1564 | return iTrue; | ||
1565 | } | ||
1566 | else if (equal_Command(cmd, "scroll.step") && document_App() == d) { | ||
1567 | smoothScroll_DocumentWidget_(d, | ||
1568 | 3 * lineHeight_Text(paragraph_FontId) * arg_Command(cmd), | ||
1569 | smoothDuration_DocumentWidget_); | ||
1570 | return iTrue; | ||
1571 | } | ||
1572 | #if 0 | ||
1573 | case SDLK_PAGEUP: | ||
1574 | case SDLK_PAGEDOWN: | ||
1575 | case SDLK_SPACE: | ||
1576 | postCommand_Widget( | ||
1577 | w, | ||
1578 | "scroll.page arg:%d repeat:%d", | ||
1579 | (key == SDLK_SPACE && mods & KMOD_SHIFT) || key == SDLK_PAGEUP ? -1 : +1, | ||
1580 | ev->key.repeat != 0); | ||
1581 | return iTrue; | ||
1582 | } | ||
1583 | #endif | ||
1550 | else if (equal_Command(cmd, "document.goto") && document_App() == d) { | 1584 | else if (equal_Command(cmd, "document.goto") && document_App() == d) { |
1551 | const iRangecc heading = range_Command(cmd, "heading"); | 1585 | const iRangecc heading = range_Command(cmd, "heading"); |
1552 | if (heading.start) { | 1586 | if (heading.start) { |
@@ -1790,45 +1824,6 @@ static iBool processEvent_DocumentWidget_(iDocumentWidget *d, const SDL_Event *e | |||
1790 | refresh_Widget(w); | 1824 | refresh_Widget(w); |
1791 | } | 1825 | } |
1792 | break; | 1826 | break; |
1793 | case SDLK_HOME: | ||
1794 | init_Anim(&d->scrollY, 0); | ||
1795 | invalidate_VisBuf(d->visBuf); | ||
1796 | scroll_DocumentWidget_(d, 0); | ||
1797 | updateVisible_DocumentWidget_(d); | ||
1798 | refresh_Widget(w); | ||
1799 | return iTrue; | ||
1800 | case SDLK_END: | ||
1801 | init_Anim(&d->scrollY, scrollMax_DocumentWidget_(d)); | ||
1802 | invalidate_VisBuf(d->visBuf); | ||
1803 | scroll_DocumentWidget_(d, 0); | ||
1804 | updateVisible_DocumentWidget_(d); | ||
1805 | refresh_Widget(w); | ||
1806 | return iTrue; | ||
1807 | case SDLK_UP: | ||
1808 | case SDLK_DOWN: | ||
1809 | if (mods == 0) { | ||
1810 | if (ev->key.repeat) { | ||
1811 | // if (!d->smoothContinue) { | ||
1812 | // d->smoothContinue = iTrue; | ||
1813 | // } | ||
1814 | // else return iTrue; | ||
1815 | } | ||
1816 | smoothScroll_DocumentWidget_(d, | ||
1817 | 3 * lineHeight_Text(paragraph_FontId) * | ||
1818 | (key == SDLK_UP ? -1 : 1), | ||
1819 | /*gap_Text * */smoothDuration_DocumentWidget_); | ||
1820 | return iTrue; | ||
1821 | } | ||
1822 | break; | ||
1823 | case SDLK_PAGEUP: | ||
1824 | case SDLK_PAGEDOWN: | ||
1825 | case SDLK_SPACE: | ||
1826 | postCommand_Widget( | ||
1827 | w, | ||
1828 | "scroll.page arg:%d repeat:%d", | ||
1829 | (key == SDLK_SPACE && mods & KMOD_SHIFT) || key == SDLK_PAGEUP ? -1 : +1, | ||
1830 | ev->key.repeat != 0); | ||
1831 | return iTrue; | ||
1832 | #if 1 | 1827 | #if 1 |
1833 | case SDLK_KP_1: | 1828 | case SDLK_KP_1: |
1834 | case '`': { | 1829 | case '`': { |