Commit a63e0cc539aa2439bb6ee2bce0961aeba37c839e
1 parent
6a81f385
Exists in
master
and in
2 other branches
Adding method to get translated cursor position.
Showing
2 changed files
with
36 additions
and
0 deletions
Show diff stats
src/core/screen.c
| ... | ... | @@ -422,6 +422,27 @@ LIB3270_EXPORT int lib3270_get_cursor_address(const H3270 *hSession) |
| 422 | 422 | return state ? -state : hSession->cursor_addr; |
| 423 | 423 | } |
| 424 | 424 | |
| 425 | +LIB3270_EXPORT int lib3270_get_cursor_position(const H3270 *hSession, unsigned short *row, unsigned short *col) | |
| 426 | +{ | |
| 427 | + int state = check_online_session(hSession); | |
| 428 | + if(state) | |
| 429 | + { | |
| 430 | + *row = *col = 9; | |
| 431 | + return state; | |
| 432 | + } | |
| 433 | + | |
| 434 | + unsigned short addr = (unsigned short) hSession->cursor_addr; | |
| 435 | + | |
| 436 | + if(row) | |
| 437 | + *row = (addr / ((unsigned short) hSession->view.cols))+1; | |
| 438 | + | |
| 439 | + if(col) | |
| 440 | + *col = (addr % ((unsigned short) hSession->view.cols))+1; | |
| 441 | + | |
| 442 | + return 0; | |
| 443 | +} | |
| 444 | + | |
| 445 | + | |
| 425 | 446 | /** |
| 426 | 447 | * @brief Converts row/col in a buffer address. |
| 427 | 448 | * | ... | ... |
src/include/lib3270.h
| ... | ... | @@ -767,6 +767,21 @@ |
| 767 | 767 | LIB3270_EXPORT int lib3270_get_cursor_address(const H3270 *hSession); |
| 768 | 768 | |
| 769 | 769 | /** |
| 770 | + * @brief Get row/col of the current cursor position. | |
| 771 | + * | |
| 772 | + * @param hSession Session handler. | |
| 773 | + * @param row Pointer for current cursor row. | |
| 774 | + * @param col Pointer for current cursor column. | |
| 775 | + * | |
| 776 | + * @return 0 if ok, error code if not (sets errno). | |
| 777 | + * | |
| 778 | + * @retval EINVAL Invalid session. | |
| 779 | + * @retval ENOTCONN Not connected to host. | |
| 780 | + * | |
| 781 | + */ | |
| 782 | + LIB3270_EXPORT int lib3270_get_cursor_position(const H3270 *hSession, unsigned short *row, unsigned short *col); | |
| 783 | + | |
| 784 | + /** | |
| 770 | 785 | * @brief Move cursor |
| 771 | 786 | * |
| 772 | 787 | * @param h Session handle. | ... | ... |