| 1793 | } |
| 1794 | |
| 1795 | void MsgListConsole::DoInput() { |
| 1796 | if (m_opened) { |
| 1797 | int i, offset_count = 0; // = ddio_KeyDownCount(KEY_DOWN) - ddio_KeyDownCount(KEY_UP); |
| 1798 | float key_time = ddio_KeyDownTime(KEY_DOWN) - ddio_KeyDownTime(KEY_UP); |
| 1799 | char *lineptr; |
| 1800 | |
| 1801 | if (m_numlines <= n_conlines) { |
| 1802 | offset_count = 0; // no need to offset if no need to scroll |
| 1803 | } |
| 1804 | |
| 1805 | if (key_time == 0.0f) { |
| 1806 | m_keydowntime = 0.0f; |
| 1807 | } else { |
| 1808 | m_keydowntime += key_time; |
| 1809 | } |
| 1810 | if (m_keydowntime < -0.1f) { |
| 1811 | offset_count = -1; |
| 1812 | m_keydowntime = 0.0f; |
| 1813 | } else if (m_keydowntime > 0.1f) { |
| 1814 | offset_count = 1; |
| 1815 | m_keydowntime = 0.0f; |
| 1816 | } |
| 1817 | |
| 1818 | // scroll offset_count amount. |
| 1819 | if (offset_count < 0) { |
| 1820 | // look back from m_conlines[0] |
| 1821 | if ((m_bufline + offset_count - n_conlines) < 0) |
| 1822 | offset_count = -(m_bufline - n_conlines); |
| 1823 | |
| 1824 | m_bufline = m_bufline + offset_count; |
| 1825 | |
| 1826 | if (offset_count < 0) { |
| 1827 | mprintf(0, "bufline=%d\n", m_bufline); |
| 1828 | } |
| 1829 | |
| 1830 | while (offset_count < 0) { |
| 1831 | offset_count++; |
| 1832 | for (i = n_conlines - 1; i > 0; i--) |
| 1833 | m_conlines[i] = m_conlines[i - 1]; |
| 1834 | |
| 1835 | // go back until hit previous newline of beginning of buffer. |
| 1836 | for (lineptr = m_conlines[0] - 1; lineptr != m_buffer && lineptr[-1] != '\n'; lineptr--) |
| 1837 | ; |
| 1838 | m_conlines[0] = lineptr; |
| 1839 | } |
| 1840 | } else if (offset_count > 0) { |
| 1841 | // look forward from m_conlines[n_conlines-1] |
| 1842 | if ((m_bufline + offset_count) > m_numlines) |
| 1843 | offset_count = m_numlines - m_bufline; |
| 1844 | |
| 1845 | m_bufline = m_bufline + offset_count; |
| 1846 | |
| 1847 | if (offset_count > 0) { |
| 1848 | mprintf(0, "bufline=%d\n", m_bufline); |
| 1849 | } |
| 1850 | |
| 1851 | while (offset_count > 0) { |
| 1852 | offset_count--; |
no test coverage detected