Commit 279ad7c7b7969135e02ecd1577528b6e581c6436
1 parent
2bfb60d4
Exists in
master
and in
3 other branches
Fixing bug on cursor movement reported by user
Showing
4 changed files
with
98 additions
and
81 deletions
Show diff stats
lib3270.cbp
@@ -161,9 +161,6 @@ | @@ -161,9 +161,6 @@ | ||
161 | <Unit filename="src/lib3270/log.c"> | 161 | <Unit filename="src/lib3270/log.c"> |
162 | <Option compilerVar="CC" /> | 162 | <Option compilerVar="CC" /> |
163 | </Unit> | 163 | </Unit> |
164 | - <Unit filename="src/lib3270/macros.c"> | ||
165 | - <Option compilerVar="CC" /> | ||
166 | - </Unit> | ||
167 | <Unit filename="src/lib3270/mkactions/mkactions.c"> | 164 | <Unit filename="src/lib3270/mkactions/mkactions.c"> |
168 | <Option compilerVar="CC" /> | 165 | <Option compilerVar="CC" /> |
169 | </Unit> | 166 | </Unit> |
src/lib3270/kybd.c
@@ -42,6 +42,7 @@ struct ta; | @@ -42,6 +42,7 @@ struct ta; | ||
42 | 42 | ||
43 | #include "private.h" | 43 | #include "private.h" |
44 | #include <lib3270/trace.h> | 44 | #include <lib3270/trace.h> |
45 | +#include <lib3270/selection.h> | ||
45 | 46 | ||
46 | #ifndef ANDROID | 47 | #ifndef ANDROID |
47 | #include <stdlib.h> | 48 | #include <stdlib.h> |
@@ -1758,6 +1759,97 @@ LIB3270_EXPORT int lib3270_nextword(H3270 *hSession) | @@ -1758,6 +1759,97 @@ LIB3270_EXPORT int lib3270_nextword(H3270 *hSession) | ||
1758 | } | 1759 | } |
1759 | 1760 | ||
1760 | /** | 1761 | /** |
1762 | + * @brief Move cursor. | ||
1763 | + * | ||
1764 | + * @param hSession Session handle. | ||
1765 | + * @param dir Where to move. | ||
1766 | + * @param sel Non zero if it's selecting. | ||
1767 | + * | ||
1768 | + */ | ||
1769 | +LIB3270_EXPORT int lib3270_move_cursor(H3270 *hSession, LIB3270_DIRECTION dir, unsigned char sel) | ||
1770 | +{ | ||
1771 | + FAIL_IF_NOT_ONLINE(hSession); | ||
1772 | + | ||
1773 | + int cursor_addr = hSession->cursor_addr; | ||
1774 | + int maxlen = hSession->cols * hSession->rows; | ||
1775 | + | ||
1776 | + switch(dir) | ||
1777 | + { | ||
1778 | + case LIB3270_DIR_UP: | ||
1779 | + | ||
1780 | + if(sel && cursor_addr <= hSession->cols) | ||
1781 | + return errno = EINVAL; | ||
1782 | + | ||
1783 | + cursor_addr -= hSession->cols; | ||
1784 | + break; | ||
1785 | + | ||
1786 | + case LIB3270_DIR_DOWN: | ||
1787 | + | ||
1788 | + if(sel && cursor_addr >= (hSession->cols * (hSession->rows-1))) | ||
1789 | + return errno = EINVAL; | ||
1790 | + | ||
1791 | + cursor_addr += hSession->cols; | ||
1792 | + break; | ||
1793 | + | ||
1794 | + case LIB3270_DIR_LEFT: | ||
1795 | + | ||
1796 | + if(sel && (cursor_addr % hSession->cols) < 1) | ||
1797 | + return errno = EINVAL; | ||
1798 | + | ||
1799 | + cursor_addr--; | ||
1800 | + break; | ||
1801 | + | ||
1802 | + case LIB3270_DIR_RIGHT: | ||
1803 | + | ||
1804 | + if(sel && (cursor_addr % hSession->cols) >= (hSession->cols-1)) | ||
1805 | + return errno = EINVAL; | ||
1806 | + | ||
1807 | + cursor_addr++; | ||
1808 | + break; | ||
1809 | + | ||
1810 | + case LIB3270_DIR_END: | ||
1811 | + | ||
1812 | + cursor_addr = lib3270_get_field_end(hSession,cursor_addr); | ||
1813 | + if(cursor_addr == -1) | ||
1814 | + return errno = EINVAL; | ||
1815 | + break; | ||
1816 | + | ||
1817 | + default: | ||
1818 | + errno = EINVAL; | ||
1819 | + return -1; | ||
1820 | + } | ||
1821 | + | ||
1822 | + if(sel) | ||
1823 | + { | ||
1824 | + lib3270_select_to(hSession,cursor_addr); | ||
1825 | + } | ||
1826 | + else | ||
1827 | + { | ||
1828 | + | ||
1829 | + if(cursor_addr >= maxlen) | ||
1830 | + { | ||
1831 | + cursor_move(hSession,cursor_addr % maxlen); | ||
1832 | + } | ||
1833 | + else if(cursor_addr < 0) | ||
1834 | + { | ||
1835 | + cursor_move(hSession,cursor_addr + maxlen); | ||
1836 | + } | ||
1837 | + else | ||
1838 | + { | ||
1839 | + cursor_move(hSession,cursor_addr); | ||
1840 | + } | ||
1841 | + | ||
1842 | + if(hSession->kybdlock && (KYBDLOCK_IS_OERR(hSession))) | ||
1843 | + { | ||
1844 | + status_reset(hSession); | ||
1845 | + } | ||
1846 | + | ||
1847 | + } | ||
1848 | + | ||
1849 | + return 0; | ||
1850 | +} | ||
1851 | + | ||
1852 | +/** | ||
1761 | * @brief Cursor up 1 position. | 1853 | * @brief Cursor up 1 position. |
1762 | */ | 1854 | */ |
1763 | LIB3270_EXPORT int lib3270_cursor_up(H3270 *hSession) | 1855 | LIB3270_EXPORT int lib3270_cursor_up(H3270 *hSession) |
@@ -1766,6 +1858,7 @@ LIB3270_EXPORT int lib3270_cursor_up(H3270 *hSession) | @@ -1766,6 +1858,7 @@ LIB3270_EXPORT int lib3270_cursor_up(H3270 *hSession) | ||
1766 | 1858 | ||
1767 | FAIL_IF_NOT_ONLINE(hSession); | 1859 | FAIL_IF_NOT_ONLINE(hSession); |
1768 | 1860 | ||
1861 | + trace("kybdlock=%d OERR=%s",(int) hSession->kybdlock, (KYBDLOCK_IS_OERR(hSession) ? "yes" : "no")); | ||
1769 | if (hSession->kybdlock) | 1862 | if (hSession->kybdlock) |
1770 | { | 1863 | { |
1771 | if (KYBDLOCK_IS_OERR(hSession)) | 1864 | if (KYBDLOCK_IS_OERR(hSession)) |
@@ -1776,16 +1869,17 @@ LIB3270_EXPORT int lib3270_cursor_up(H3270 *hSession) | @@ -1776,16 +1869,17 @@ LIB3270_EXPORT int lib3270_cursor_up(H3270 *hSession) | ||
1776 | else | 1869 | else |
1777 | { | 1870 | { |
1778 | ENQUEUE_ACTION(lib3270_cursor_up); | 1871 | ENQUEUE_ACTION(lib3270_cursor_up); |
1779 | -// enq_ta(Up_action, CN, CN); | ||
1780 | return 0; | 1872 | return 0; |
1781 | } | 1873 | } |
1782 | } | 1874 | } |
1875 | + | ||
1783 | #if defined(X3270_ANSI) /*[*/ | 1876 | #if defined(X3270_ANSI) /*[*/ |
1784 | if (IN_ANSI) { | 1877 | if (IN_ANSI) { |
1785 | ansi_send_up(hSession); | 1878 | ansi_send_up(hSession); |
1786 | return 0; | 1879 | return 0; |
1787 | } | 1880 | } |
1788 | #endif /*]*/ | 1881 | #endif /*]*/ |
1882 | + | ||
1789 | baddr = hSession->cursor_addr - hSession->cols; | 1883 | baddr = hSession->cursor_addr - hSession->cols; |
1790 | if (baddr < 0) | 1884 | if (baddr < 0) |
1791 | baddr = (hSession->cursor_addr + (hSession->rows * hSession->cols)) - hSession->cols; | 1885 | baddr = (hSession->cursor_addr + (hSession->rows * hSession->cols)) - hSession->cols; |
src/lib3270/screen.c
@@ -568,14 +568,17 @@ void status_reset(H3270 *session) | @@ -568,14 +568,17 @@ void status_reset(H3270 *session) | ||
568 | 568 | ||
569 | if (session->kybdlock & KL_ENTER_INHIBIT) | 569 | if (session->kybdlock & KL_ENTER_INHIBIT) |
570 | { | 570 | { |
571 | + trace("%s",__FUNCTION__); | ||
571 | status_changed(session,LIB3270_MESSAGE_INHIBIT); | 572 | status_changed(session,LIB3270_MESSAGE_INHIBIT); |
572 | } | 573 | } |
573 | else if (session->kybdlock & KL_DEFERRED_UNLOCK) | 574 | else if (session->kybdlock & KL_DEFERRED_UNLOCK) |
574 | { | 575 | { |
576 | + trace("%s",__FUNCTION__); | ||
575 | status_changed(session,LIB3270_MESSAGE_X); | 577 | status_changed(session,LIB3270_MESSAGE_X); |
576 | } | 578 | } |
577 | else | 579 | else |
578 | { | 580 | { |
581 | + trace("%s",__FUNCTION__); | ||
579 | mcursor_set(session,LIB3270_POINTER_UNLOCKED); | 582 | mcursor_set(session,LIB3270_POINTER_UNLOCKED); |
580 | status_changed(session,LIB3270_MESSAGE_NONE); | 583 | status_changed(session,LIB3270_MESSAGE_NONE); |
581 | } | 584 | } |
src/lib3270/selection.c
@@ -908,80 +908,3 @@ LIB3270_EXPORT int lib3270_move_selection(H3270 *hSession, LIB3270_DIRECTION dir | @@ -908,80 +908,3 @@ LIB3270_EXPORT int lib3270_move_selection(H3270 *hSession, LIB3270_DIRECTION dir | ||
908 | return 0; | 908 | return 0; |
909 | } | 909 | } |
910 | 910 | ||
911 | -LIB3270_EXPORT int lib3270_move_cursor(H3270 *hSession, LIB3270_DIRECTION dir, unsigned char sel) | ||
912 | -{ | ||
913 | - int cursor_addr = hSession->cursor_addr; | ||
914 | - int maxlen = hSession->cols * hSession->rows; | ||
915 | - | ||
916 | - if(!lib3270_connected(hSession)) | ||
917 | - { | ||
918 | - errno = ENOTCONN; | ||
919 | - return -1; | ||
920 | - } | ||
921 | - | ||
922 | - switch(dir) | ||
923 | - { | ||
924 | - case LIB3270_DIR_UP: | ||
925 | - | ||
926 | - if(sel && cursor_addr <= hSession->cols) | ||
927 | - return errno = EINVAL; | ||
928 | - | ||
929 | - cursor_addr -= hSession->cols; | ||
930 | - break; | ||
931 | - | ||
932 | - case LIB3270_DIR_DOWN: | ||
933 | - | ||
934 | - if(sel && cursor_addr >= (hSession->cols * (hSession->rows-1))) | ||
935 | - return errno = EINVAL; | ||
936 | - | ||
937 | - cursor_addr += hSession->cols; | ||
938 | - break; | ||
939 | - | ||
940 | - case LIB3270_DIR_LEFT: | ||
941 | - | ||
942 | - if(sel && (cursor_addr % hSession->cols) < 1) | ||
943 | - return errno = EINVAL; | ||
944 | - | ||
945 | - cursor_addr--; | ||
946 | - break; | ||
947 | - | ||
948 | - case LIB3270_DIR_RIGHT: | ||
949 | - | ||
950 | - if(sel && (cursor_addr % hSession->cols) >= (hSession->cols-1)) | ||
951 | - return errno = EINVAL; | ||
952 | - | ||
953 | - cursor_addr++; | ||
954 | - break; | ||
955 | - | ||
956 | - case LIB3270_DIR_END: | ||
957 | - | ||
958 | - cursor_addr = lib3270_get_field_end(hSession,cursor_addr); | ||
959 | - if(cursor_addr == -1) | ||
960 | - return errno = EINVAL; | ||
961 | - break; | ||
962 | - | ||
963 | - default: | ||
964 | - errno = EINVAL; | ||
965 | - return -1; | ||
966 | - } | ||
967 | - | ||
968 | - if(sel) | ||
969 | - { | ||
970 | - lib3270_select_to(hSession,cursor_addr); | ||
971 | - } | ||
972 | - else if(cursor_addr >= maxlen) | ||
973 | - { | ||
974 | - cursor_move(hSession,cursor_addr % maxlen); | ||
975 | - } | ||
976 | - else if(cursor_addr < 0) | ||
977 | - { | ||
978 | - cursor_move(hSession,cursor_addr + maxlen); | ||
979 | - } | ||
980 | - else | ||
981 | - { | ||
982 | - cursor_move(hSession,cursor_addr); | ||
983 | - } | ||
984 | - | ||
985 | - return 0; | ||
986 | -} | ||
987 | - |