Commit 0294b1d2a51b6c2f933e37757c83e5ee679d4f44
1 parent
b5480b5c
Exists in
master
and in
3 other branches
Implementando funções rexx
Showing
2 changed files
with
83 additions
and
22 deletions
Show diff stats
paste.c
| @@ -161,34 +161,18 @@ | @@ -161,34 +161,18 @@ | ||
| 161 | } | 161 | } |
| 162 | 162 | ||
| 163 | return c; | 163 | return c; |
| 164 | - } | 164 | +} |
| 165 | 165 | ||
| 166 | -/** | ||
| 167 | - * Set string at cursor position. | ||
| 168 | - * | ||
| 169 | - * @param hSession Session handle. | ||
| 170 | - * @param str String to set | ||
| 171 | - * | ||
| 172 | - * @return Number of characters inserted; <0 in case of error. | ||
| 173 | - * | ||
| 174 | - */ | ||
| 175 | -LIB3270_EXPORT int lib3270_set_string(H3270 *hSession, const unsigned char *str) | 166 | +static int set_string(H3270 *hSession, const unsigned char *str) |
| 176 | { | 167 | { |
| 177 | PASTE_DATA data; | 168 | PASTE_DATA data; |
| 178 | unsigned char last = 1; | 169 | unsigned char last = 1; |
| 179 | 170 | ||
| 180 | - CHECK_SESSION_HANDLE(hSession); | ||
| 181 | - | ||
| 182 | memset(&data,0,sizeof(data)); | 171 | memset(&data,0,sizeof(data)); |
| 183 | data.row = BA_TO_ROW(hSession->cursor_addr); | 172 | data.row = BA_TO_ROW(hSession->cursor_addr); |
| 184 | data.orig_addr = hSession->cursor_addr; | 173 | data.orig_addr = hSession->cursor_addr; |
| 185 | data.orig_col = BA_TO_COL(hSession->cursor_addr); | 174 | data.orig_col = BA_TO_COL(hSession->cursor_addr); |
| 186 | 175 | ||
| 187 | - if(hSession->kybdlock) | ||
| 188 | - return -EINVAL; | ||
| 189 | - | ||
| 190 | - hSession->suspend(hSession); | ||
| 191 | - | ||
| 192 | while(*str && last && !hSession->kybdlock && hSession->cursor_addr >= data.orig_addr) | 176 | while(*str && last && !hSession->kybdlock && hSession->cursor_addr >= data.orig_addr) |
| 193 | { | 177 | { |
| 194 | switch(*str) | 178 | switch(*str) |
| @@ -234,9 +218,61 @@ LIB3270_EXPORT int lib3270_set_string(H3270 *hSession, const unsigned char *str) | @@ -234,9 +218,61 @@ LIB3270_EXPORT int lib3270_set_string(H3270 *hSession, const unsigned char *str) | ||
| 234 | break; | 218 | break; |
| 235 | } | 219 | } |
| 236 | 220 | ||
| 221 | + return data.qtd; | ||
| 222 | +} | ||
| 223 | + | ||
| 224 | +LIB3270_EXPORT int lib3270_set_string_at(H3270 *hSession, int row, int col, const unsigned char *str) | ||
| 225 | +{ | ||
| 226 | + int rc = -1; | ||
| 227 | + | ||
| 228 | + CHECK_SESSION_HANDLE(hSession); | ||
| 229 | + | ||
| 230 | + if(hSession->kybdlock) | ||
| 231 | + return -EINVAL; | ||
| 232 | + | ||
| 233 | + if(hSession->selected && !lib3270_get_toggle(hSession,LIB3270_TOGGLE_KEEP_SELECTED)) | ||
| 234 | + lib3270_unselect(hSession); | ||
| 235 | + | ||
| 236 | + row--; | ||
| 237 | + col--; | ||
| 238 | + | ||
| 239 | + if(row >= 0 && col >= 0 && row <= hSession->rows && col <= hSession->cols) | ||
| 240 | + { | ||
| 241 | + hSession->suspend(hSession); | ||
| 242 | + | ||
| 243 | + hSession->cursor_addr = (row * hSession->cols) + col; | ||
| 244 | + rc = set_string(hSession, str); | ||
| 245 | + | ||
| 246 | + hSession->resume(hSession); | ||
| 247 | + } | ||
| 248 | + | ||
| 249 | + return rc; | ||
| 250 | +} | ||
| 251 | + | ||
| 252 | + | ||
| 253 | +/** | ||
| 254 | + * Set string at cursor position. | ||
| 255 | + * | ||
| 256 | + * @param hSession Session handle. | ||
| 257 | + * @param str String to set | ||
| 258 | + * | ||
| 259 | + * @return Number of characters inserted; <0 in case of error. | ||
| 260 | + * | ||
| 261 | + */ | ||
| 262 | +LIB3270_EXPORT int lib3270_set_string(H3270 *hSession, const unsigned char *str) | ||
| 263 | +{ | ||
| 264 | + int rc; | ||
| 265 | + | ||
| 266 | + CHECK_SESSION_HANDLE(hSession); | ||
| 267 | + | ||
| 268 | + if(hSession->kybdlock) | ||
| 269 | + return -EINVAL; | ||
| 270 | + | ||
| 271 | + hSession->suspend(hSession); | ||
| 272 | + rc = set_string(hSession, str); | ||
| 237 | hSession->resume(hSession); | 273 | hSession->resume(hSession); |
| 238 | 274 | ||
| 239 | - return data.qtd; | 275 | + return rc; |
| 240 | } | 276 | } |
| 241 | 277 | ||
| 242 | LIB3270_EXPORT int lib3270_paste(H3270 *h, const unsigned char *str) | 278 | LIB3270_EXPORT int lib3270_paste(H3270 *h, const unsigned char *str) |
screen.c
| @@ -398,11 +398,36 @@ LIB3270_EXPORT int lib3270_set_cursor_address(H3270 *h, int baddr) | @@ -398,11 +398,36 @@ LIB3270_EXPORT int lib3270_set_cursor_address(H3270 *h, int baddr) | ||
| 398 | return cursor_move(h,baddr); | 398 | return cursor_move(h,baddr); |
| 399 | } | 399 | } |
| 400 | 400 | ||
| 401 | -int cursor_move(H3270 *h, int baddr) | 401 | +LIB3270_EXPORT int lib3270_set_cursor_position(H3270 *h, int row, int col) |
| 402 | { | 402 | { |
| 403 | - int ret; | 403 | + int baddr = -1; |
| 404 | + | ||
| 405 | + CHECK_SESSION_HANDLE(h); | ||
| 406 | + | ||
| 407 | + if(h->selected && !lib3270_get_toggle(h,LIB3270_TOGGLE_KEEP_SELECTED)) | ||
| 408 | + lib3270_unselect(h); | ||
| 409 | + | ||
| 410 | + row--; | ||
| 411 | + col--; | ||
| 412 | + | ||
| 413 | + if(row >= 0 && col >= 0 && row <= h->rows && col <= h->cols) | ||
| 414 | + { | ||
| 415 | + baddr = (row * h->cols) + col; | ||
| 404 | 416 | ||
| 405 | - ret = h->cursor_addr; | 417 | + if(baddr != h->cursor_addr) |
| 418 | + { | ||
| 419 | + h->cursor_addr = baddr; | ||
| 420 | + h->update_cursor(h,(unsigned short) row,(unsigned short) col,h->text[baddr].chr,h->text[baddr].attr); | ||
| 421 | + } | ||
| 422 | + } | ||
| 423 | + | ||
| 424 | + return baddr; | ||
| 425 | +} | ||
| 426 | + | ||
| 427 | + | ||
| 428 | +int cursor_move(H3270 *h, int baddr) | ||
| 429 | +{ | ||
| 430 | + int ret = h->cursor_addr; | ||
| 406 | 431 | ||
| 407 | if(ret == baddr) | 432 | if(ret == baddr) |
| 408 | return ret; | 433 | return ret; |