diff --git a/Makefile.in b/Makefile.in index e56e2cd..941c606 100644 --- a/Makefile.in +++ b/Makefile.in @@ -74,7 +74,8 @@ SOURCES = XtGlue.c actions.c ansi.c charset.c ctlr.c \ ft.c ft_cut.c ft_dft.c glue.c host.c kybd.c \ print.c printer.c proxy.c resources.c rpq.c screen.c see.c \ sf.c tables.c telnet.c toggles.c trace_ds.c utf8.c util.c \ - xio.c resolver.c log.c paste.c macros.c fallbacks.c version.c + xio.c resolver.c log.c paste.c macros.c fallbacks.c version.c \ + selection.c #---[ Misc targets ]----------------------------------------------------------- diff --git a/glue.c b/glue.c index 2928946..73895f3 100644 --- a/glue.c +++ b/glue.c @@ -175,11 +175,12 @@ static void lib3270_session_init(H3270 *hSession, const char *model) hSession->sz = sizeof(H3270); hSession->sock = -1; hSession->model_num = -1; -// hSession->first_changed = -1; -// hSession->last_changed = -1; hSession->cstate = NOT_CONNECTED; hSession->oia_status = -1; + hSession->selected.begin = -1; + hSession->selected.end = -1; + strncpy(hSession->full_model_name,"IBM-",LIB3270_FULL_MODEL_NAME_LENGTH); hSession->model_name = &hSession->full_model_name[4]; diff --git a/kybd.c b/kybd.c index 2a69554..afc317d 100644 --- a/kybd.c +++ b/kybd.c @@ -2945,301 +2945,6 @@ LIB3270_ACTION( fieldend ) return 0; } -/* - * MoveCursor action. Depending on arguments, this is either a move to the - * mouse cursor position, or to an absolute location. - */ /* -void -MoveCursor_action(Widget w, XEvent *event, String *params, Cardinal *num_params) -{ - register int baddr; - int row, col; - -// reset_idle_timer(); - if (kybdlock) { - if (*num_params == 2) - enq_ta(MoveCursor_action, params[0], params[1]); - return; - } - - switch (*num_params) { -#if defined(X3270_DISPLAY - case 0: // mouse click, presumably - if (w != *screen) - return; - cursor_move(mouse_baddr(w, event)); - break; -#endif - case 2: // probably a macro call - row = atoi(params[0]); - col = atoi(params[1]); - if (!IN_3270) { - row--; - col--; - } - if (row < 0) - row = 0; - if (col < 0) - col = 0; - baddr = ((row * COLS) + col) % (ROWS * COLS); - cursor_move(baddr); - break; - default: // couln't say - popup_an_error("%s requires 0 or 2 arguments", - action_name(MoveCursor_action)); -// cancel_if_idle_command(); - break; - } -} - -*/ -#if defined(X3270_DBCS) && defined(X3270_DISPLAY) /*[*/ -/* - * Run a KeyPress through XIM. - * Returns True if there is further processing to do, False otherwise. - */ /* -static Boolean -xim_lookup(XKeyEvent *event) -{ - static char *buf = NULL; - static UChar *Ubuf = NULL; - static int buf_len = 0, rlen; - KeySym k; - Status status; - extern XIC ic; - int i; - Boolean rv = False; - int wlen; -#define BASE_BUFSIZE 50 - - if (ic == NULL) - return True; - - if (buf == NULL) { - buf_len = BASE_BUFSIZE; - buf = Malloc(buf_len); - Ubuf = (UChar *)Malloc(buf_len * sizeof(UChar)); - } - - for (;;) { - memset(buf, '\0', buf_len); - rlen = XmbLookupString(ic, event, buf, buf_len - 1, &k, - &status); - if (status != XBufferOverflow) - break; - buf_len += BASE_BUFSIZE; - buf = Realloc(buf, buf_len); - Ubuf = (UChar *)Realloc(Ubuf, buf_len * sizeof(UChar)); - } - - switch (status) { - case XLookupNone: - rv = False; - break; - case XLookupKeySym: - rv = True; - break; - case XLookupChars: - trace_event("%d XIM char%s:", rlen, (rlen != 1)? "s": ""); - for (i = 0; i < rlen; i++) { - trace_event(" %02x", buf[i] & 0xff); - } - trace_event("\n"); - wlen = mb_to_unicode(buf, rlen, Ubuf, buf_len, NULL); - if (wlen < 0) - trace_event(" conversion failed\n"); - for (i = 0; i < wlen; i++) { - unsigned char asc; - unsigned char ebc[2]; - - if (dbcs_map8(Ubuf[i], &asc)) { - trace_event(" U+%04x -> " - "EBCDIC SBCS X'%02x'\n", - Ubuf[i] & 0xffff, asc2ebc[asc]); - key_ACharacter(asc, KT_STD, ia_cause, NULL); - } else if (dbcs_map16(Ubuf[i], ebc)) { - trace_event(" U+%04x -> " - "EBCDIC DBCS X'%02x%02x'\n", - Ubuf[i] & 0xffff, ebc[0], ebc[1]); - (void) key_WCharacter(ebc, NULL); - } else - trace_event(" Cannot convert U+%04x to " - "EBCDIC\n", Ubuf[i] & 0xffff); - } - rv = False; - break; - case XLookupBoth: - rv = True; - break; - } - return rv; -} -*/ -#endif - -/* - * Key action by string - */ /* -void Input_String(const unsigned char *str) -{ -// reset_idle_timer(); - - // FIXME (perry#3#): It works but, is it right? - while(*str) - { - key_ACharacter((unsigned char)((*str) & 0xff), KT_STD, IA_KEY, NULL); - str++; - } - screen_disp(&h3270); -} */ - -/* - * Key action. - */ /* -void -Key_action(Widget w unused, XEvent *event, String *params, Cardinal *num_params) -{ - Cardinal i; - KeySym k; - enum keytype keytype; - -// reset_idle_timer(); - - for (i = 0; i < *num_params; i++) { - char *s = params[i]; - - k = MyStringToKeysym(s, &keytype); - if (k == NoSymbol) { - popup_an_error("%s: Nonexistent or invalid KeySym: %s", - action_name(Key_action), s); -// cancel_if_idle_command(); - continue; - } - if (k & ~0xff) { - popup_an_error("%s: Invalid KeySym: %s", - action_name(Key_action), s); -// cancel_if_idle_command(); - continue; - } - key_ACharacter((unsigned char)(k & 0xff), keytype, IA_KEY, - NULL); - } -} -*/ -/* - * String action. - */ /* -void -String_action(Widget w unused, XEvent *event, String *params, Cardinal *num_params) -{ - Cardinal i; - int len = 0; - char *s0, *s; - -// reset_idle_timer(); - - // Determine the total length of the strings. - for (i = 0; i < *num_params; i++) - len += strlen(params[i]); - if (!len) - return; - - // Allocate a block of memory and copy them in. - s0 = s = Malloc(len + 1); - *s = '\0'; - for (i = 0; i < *num_params; i++) { - char *t = params[i]; - unsigned char c; - - while ((c = (unsigned char)*t) != '\0') { - if (c & 0x80) { - unsigned char xc; - enum ulfail fail; - int consumed; - - xc = utf8_lookup(t, &fail, &consumed); - if (xc == 0) { - switch (fail) { - case ULFAIL_NOUTF8: - *s++ = (char)c; - break; - case ULFAIL_INCOMPLETE: - case ULFAIL_INVALID: - *s++ = ' '; - break; - } - } else { - *s++ = (char)xc; - t += (consumed - 1); - } - } else - *s++ = (char)c; - t++; - } - } - *s = '\0'; - - // Set a pending string. -// ps_set(s0, False); -} -*/ - -/* - * HexString action. - */ /* -void HexString_action(Widget w unused, XEvent *event, String *params, Cardinal *num_params) -{ - Cardinal i; - int len = 0; - char *s; - char *t; - -// reset_idle_timer(); - - // Determine the total length of the strings. - for (i = 0; i < *num_params; i++) { - t = params[i]; - if (!strncmp(t, "0x", 2) || !strncmp(t, "0X", 2)) - t += 2; - len += strlen(t); - } - if (!len) - return; - - // Allocate a block of memory and copy them in. - s = Malloc(len + 1); - *s = '\0'; - for (i = 0; i < *num_params; i++) { - t = params[i]; - if (!strncmp(t, "0x", 2) || !strncmp(t, "0X", 2)) - t += 2; - (void) strcat(s, t); - } - - // Set a pending string. -// ps_set(s, True); -} -*/ - -/* - * Dual-mode action for the "asciicircum" ("^") key: - * If in ANSI mode, pass through untranslated. - * If in 3270 mode, translate to "notsign". - * This action is obsoleted by the use of 3270-mode and NVT-mode keymaps, but - * is still defined here for backwards compatibility with old keymaps. - */ /* -void -CircumNot_action(Widget w unused, XEvent *event, String *params, Cardinal *num_params) -{ -// reset_idle_timer(); - - if (IN_3270 && composing == NONE) - key_ACharacter(0xac, KT_STD, IA_KEY, NULL); - else - key_ACharacter('^', KT_STD, IA_KEY, NULL); -} -*/ - /* PA key action for String actions */ static void do_pa(unsigned n) diff --git a/screen.c b/screen.c index 4c95544..e63281f 100644 --- a/screen.c +++ b/screen.c @@ -740,9 +740,9 @@ void popup_system_error(H3270 *session, const char *title, const char *message, va_end(args); } +/* LIB3270_EXPORT void update_toggle_actions(void) { -/* int f; if(callbacks && callbacks->toggle_changed) @@ -750,8 +750,8 @@ LIB3270_EXPORT void update_toggle_actions(void) for(f=0;f< N_TOGGLES;f++) callbacks->toggle_changed(&h3270,f,appres.toggle[f].value,TT_UPDATE,toggle_names[f]); } -*/ } +*/ void mcursor_set(H3270 *session,LIB3270_CURSOR m) { diff --git a/selection.c b/selection.c new file mode 100644 index 0000000..589966e --- /dev/null +++ b/selection.c @@ -0,0 +1,93 @@ +/* + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a + * aplicativos mainframe. Registro no INPI sob o nome G3270. + * + * Copyright (C) <2008> + * + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela + * Free Software Foundation. + * + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para + * obter mais detalhes. + * + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este + * programa; se não, escreva para a Free Software Foundation, Inc., 59 Temple + * Place, Suite 330, Boston, MA, 02111-1307, USA + * + * Este programa está nomeado como selection.c e possui - linhas de código. + * + * Contatos: + * + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) + * + */ + + #include "globals.h" + #include "ctlr.h" + #include + #include + #include + +/*--[ Implement ]------------------------------------------------------------------------------------*/ + +LIB3270_EXPORT void lib3270_clear_selection(H3270 *session) +{ + int a; + + session->selected.begin = -1; + session->selected.end = -1; + + for(a = 0; a < session->rows*session->cols; a++) + { + unsigned short attr = ea_buf[a].attr; + + if(ea_buf[a].attr & LIB3270_ATTR_SELECTED) + { + ea_buf[a].attr &= ~LIB3270_ATTR_SELECTED; + if(session->update) + session->update(session,a,ea_buf[a].chr,ea_buf[a].attr,a == session->cursor_addr); + } + } +} + +LIB3270_EXPORT void lib3270_select_to(H3270 *session, int baddr) +{ + CHECK_SESSION_HANDLE(session); + + if(session->selected.begin < 0) + session->selected.begin = session->selected.end = session->cursor_addr; + + if(baddr > session->cursor_addr) + { + session->selected.begin = session->cursor_addr; + session->selected.end = baddr; + } + else + { + session->selected.begin = baddr; + session->selected.end = session->cursor_addr; + } + + // Update screen contents + for(baddr = 0; baddr < session->rows*session->cols; baddr++) + { + unsigned short attr = ea_buf[baddr].attr; + + if(baddr >= session->selected.begin && baddr <= session->selected.end) + attr |= LIB3270_ATTR_SELECTED; + else + attr &= ~LIB3270_ATTR_SELECTED; + + if(attr != ea_buf[baddr].attr && session->update) + { + ea_buf[baddr].attr = attr; + session->update(session,baddr,ea_buf[baddr].chr,attr,baddr == session->cursor_addr); + } + } +} + -- libgit2 0.21.2