diff --git a/pw3270.cbp b/pw3270.cbp
index b906cc3..03250a0 100644
--- a/pw3270.cbp
+++ b/pw3270.cbp
@@ -174,6 +174,9 @@
+
+
+
diff --git a/src/gtk/v3270/accessible.c b/src/gtk/v3270/accessible.c
index 1739ee1..0c3da8f 100644
--- a/src/gtk/v3270/accessible.c
+++ b/src/gtk/v3270/accessible.c
@@ -506,7 +506,34 @@ static gboolean v3270_accessible_set_selection(AtkText *text, gint selection_num
return FALSE;
}
-/*
+static AtkAttributeSet *add_attribute(AtkAttributeSet * attributes, AtkTextAttribute attr, const gchar *value)
+{
+ AtkAttribute *at = g_new(AtkAttribute, 1);
+
+ at->name = g_strdup (atk_text_attribute_get_name (attr));
+ at->value = g_strdup (value);
+
+ return g_slist_prepend (attributes, at);
+}
+
+static AtkAttributeSet * v3270_accessible_get_default_attributes (AtkText *text)
+{
+ GtkWidget * widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (text));
+ AtkAttributeSet * attributes = NULL;
+
+ if(!widget)
+ return NULL;
+
+ trace("%s is incomplete ***********************",__FUNCTION__);
+
+ // http://developer.gnome.org/atk/stable/AtkText.html#AtkTextAttribute
+
+ // The direction of the text, if set. Values are "none", "ltr" or "rtl"
+ attributes = add_attribute(attributes, ATK_TEXT_ATTR_DIRECTION,atk_text_attribute_get_value(ATK_TEXT_ATTR_DIRECTION,gtk_widget_get_direction(widget)));
+
+ return attributes;
+}
+
static AtkAttributeSet * v3270_accessible_get_run_attributes(AtkText *text, gint offset, gint * start_offset, gint * end_offset)
{
GtkWidget * widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (text));
@@ -519,14 +546,33 @@ static AtkAttributeSet * v3270_accessible_get_run_attributes(AtkText *text, gint
// http://developer.gnome.org/atk/stable/AtkText.html#AtkTextAttribute
- attributes = add_attribute (attributes, ATK_TEXT_ATTR_DIRECTION,
- atk_text_attribute_get_value (ATK_TEXT_ATTR_DIRECTION,
- gtk_widget_get_direction(widget)));
+ // The direction of the text, if set. Values are "none", "ltr" or "rtl"
+ attributes = add_attribute(attributes, ATK_TEXT_ATTR_DIRECTION,atk_text_attribute_get_value(ATK_TEXT_ATTR_DIRECTION,gtk_widget_get_direction(widget)));
+
+
+ // ATK_TEXT_ATTR_LEFT_MARGIN
+ // The pixel width of the left margin
+ // ATK_TEXT_ATTR_RIGHT_MARGIN
+ // The pixel width of the right margin
+
+ // ATK_TEXT_ATTR_INVISIBLE
+ // Either "true" or "false" indicating whether text is visible or not
+
+ // Either "true" or "false" indicating whether text is editable or not
+ // ATK_TEXT_ATTR_EDITABLE
+
+ // The background color. The value is an RGB value of the format "u,u,u"
+ // ATK_TEXT_ATTR_BG_COLOR
+
+ // The foreground color. The value is an RGB value of the format "u,u,u"
+ // ATK_TEXT_ATTR_FG_COLOR
+
+ // The font family name
+ // ATK_TEXT_ATTR_FAMILY_NAME
return attributes;
}
-*/
static void atk_text_interface_init(AtkTextIface *iface)
{
@@ -547,6 +593,9 @@ static void atk_text_interface_init(AtkTextIface *iface)
iface->remove_selection = v3270_accessible_remove_selection;
iface->set_selection = v3270_accessible_set_selection;
iface->get_selection = v3270_accessible_get_selection;
+ iface->get_run_attributes = v3270_accessible_get_run_attributes;
+ iface->get_default_attributes = v3270_accessible_get_default_attributes;
+
/*
http://git.gnome.org/browse/gtk+/tree/gtk/a11y/gtklabelaccessible.c
@@ -556,8 +605,6 @@ http://git.gnome.org/browse/gtk+/tree/gtk/a11y/gtklabelaccessible.c
iface->get_text_after_offset = gtk_label_accessible_get_text_after_offset;
- iface->get_run_attributes = gtk_label_accessible_get_run_attributes;
- iface->get_default_attributes = gtk_label_accessible_get_default_attributes;
*/
}
diff --git a/src/gtk/v3270/mouse.c b/src/gtk/v3270/mouse.c
index 918560a..460f80a 100644
--- a/src/gtk/v3270/mouse.c
+++ b/src/gtk/v3270/mouse.c
@@ -87,11 +87,13 @@ static void button_1_press(GtkWidget *widget, GdkEventType type, int baddr)
break;
case GDK_2BUTTON_PRESS: // Double click - Select word
- lib3270_select_word(GTK_V3270(widget)->host,baddr);
+ if(lib3270_select_word_at(GTK_V3270(widget)->host,baddr));
+ lib3270_ring_bell(GTK_V3270(widget)->host);
break;
case GDK_3BUTTON_PRESS: // Triple clock - Select field
- lib3270_select_field_at(GTK_V3270(widget)->host,baddr);
+ if(lib3270_select_field_at(GTK_V3270(widget)->host,baddr))
+ lib3270_ring_bell(GTK_V3270(widget)->host);
break;
#ifdef DEBUG
diff --git a/src/include/lib3270.h b/src/include/lib3270.h
index 8b7c532..4c5e0ca 100644
--- a/src/include/lib3270.h
+++ b/src/include/lib3270.h
@@ -695,6 +695,22 @@
*/
LIB3270_EXPORT int lib3270_get_element(H3270 *h, int baddr, unsigned char *c, unsigned short *attr);
+ /**
+ * Get field region
+ *
+ * @param h Session handle.
+ * @param baddr Reference position to get the field start/stop offsets.
+ * @param start return location for start of selection, as a character offset.
+ * @param end return location for end of selection, as a character offset.
+ *
+ * @return Non 0 if invalid
+ *
+ */
+ LIB3270_EXPORT int lib3270_get_field_bounds(H3270 *hSession, int baddr, int *start, int *end);
+
+ LIB3270_EXPORT int lib3270_get_word_bounds(H3270 *hSession, int baddr, int *start, int *end);
+
+
LIB3270_EXPORT int lib3270_set_model(H3270 *session, int model);
LIB3270_EXPORT int lib3270_get_model(H3270 *session);
diff --git a/src/include/lib3270/selection.h b/src/include/lib3270/selection.h
index a319f99..88acad2 100644
--- a/src/include/lib3270/selection.h
+++ b/src/include/lib3270/selection.h
@@ -35,7 +35,7 @@
LIB3270_EXPORT void lib3270_clear_selection(H3270 *session);
LIB3270_EXPORT void lib3270_select_to(H3270 *session, int baddr);
- LIB3270_EXPORT void lib3270_select_word(H3270 *session, int baddr);
+ LIB3270_EXPORT int lib3270_select_word_at(H3270 *session, int baddr);
LIB3270_EXPORT int lib3270_select_field_at(H3270 *session, int baddr);
/**
diff --git a/src/include/lib3270/session.h b/src/include/lib3270/session.h
index 27a3231..84ff6f1 100644
--- a/src/include/lib3270/session.h
+++ b/src/include/lib3270/session.h
@@ -76,7 +76,8 @@
#endif
// flags
- int selected : 1;
+ int selected : 1; /**< Has selected region? */
+ int rectsel : 1; /**< Selected region is a rectangle ? */
struct lib3270_toggle toggle[LIB3270_TOGGLE_COUNT];
diff --git a/src/lib3270/Makefile.in b/src/lib3270/Makefile.in
index 855e334..2b5a1fb 100644
--- a/src/lib3270/Makefile.in
+++ b/src/lib3270/Makefile.in
@@ -95,7 +95,7 @@ SOURCES = XtGlue.c init.c actions.c ansi.c charset.c ctlr.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 \
- selection.c
+ selection.c bounds.c
#---[ Misc targets ]-----------------------------------------------------------
diff --git a/src/lib3270/bounds.c b/src/lib3270/bounds.c
new file mode 100644
index 0000000..8bd9509
--- /dev/null
+++ b/src/lib3270/bounds.c
@@ -0,0 +1,94 @@
+/*
+ * "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. 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 bounds.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)
+ * licinio@bb.com.br (Licínio Luis Branco)
+ * kraucer@bb.com.br (Kraucer Fernandes Mazuco)
+ * macmiranda@bb.com.br (Marco Aurélio Caldas Miranda)
+ *
+ */
+
+#include "globals.h"
+
+/*--[ Implement ]------------------------------------------------------------------------------------*/
+
+LIB3270_EXPORT int lib3270_get_field_bounds(H3270 *session, int baddr, int *start, int *end)
+{
+ int first;
+
+ CHECK_SESSION_HANDLE(session);
+
+ if(!lib3270_connected(session))
+ return -1;
+
+ first = lib3270_field_addr(session,baddr);
+
+ if(first < 0)
+ return -1;
+
+ first++;
+
+ if(start)
+ *start = first;
+
+ if(end)
+ {
+ int maxlen = (session->rows * session->cols)-1;
+ *end = first + lib3270_field_length(session,first);
+ if(*end > maxlen)
+ *end = maxlen;
+ }
+
+ return 0;
+}
+
+LIB3270_EXPORT int lib3270_get_word_bounds(H3270 *session, int baddr, int *start, int *end)
+{
+ int pos;
+
+ CHECK_SESSION_HANDLE(session);
+
+ if(!lib3270_connected(session) || isspace(session->text[baddr].chr))
+ return -1;
+
+ if(start)
+ {
+ for(pos = baddr; pos > 0 && !isspace(session->text[pos].chr);pos--);
+
+ *start = pos > 0 ? pos+1 : 0;
+ }
+
+ if(end)
+ {
+ int maxlen = session->rows * session->cols;
+ for(pos = baddr; pos < maxlen && !isspace(session->text[pos].chr);pos++);
+
+ *end = pos < maxlen ? pos-1 : maxlen;
+ }
+
+ return 0;
+}
+
+
diff --git a/src/lib3270/selection.c b/src/lib3270/selection.c
index 3f915d1..3f50157 100644
--- a/src/lib3270/selection.c
+++ b/src/lib3270/selection.c
@@ -34,13 +34,16 @@
#include
#include
- #define SELECTION_LEFT 0x01
- #define SELECTION_TOP 0x02
- #define SELECTION_RIGHT 0x04
- #define SELECTION_BOTTOM 0x08
- #define SELECTION_ACTIVE 0x10
+ #define SELECTION_LEFT 0x01
+ #define SELECTION_TOP 0x02
+ #define SELECTION_RIGHT 0x04
+ #define SELECTION_BOTTOM 0x08
+ #define SELECTION_SINGLE_ROW 0x10
+ #define SELECTION_SINGLE_COL 0x20
- static void select_region(H3270 *h, int start, int end);
+ #define SELECTION_ACTIVE 0x80
+
+ static void do_select(H3270 *h, int start, int end, int rect);
/*--[ Implement ]------------------------------------------------------------------------------------*/
@@ -212,7 +215,7 @@ LIB3270_EXPORT void lib3270_select_to(H3270 *session, int baddr)
cursor_move(session,end = baddr);
- select_region(session,start,end);
+ do_select(session,start,end,lib3270_get_toggle(session,LIB3270_TOGGLE_RECTANGLE_SELECT));
}
@@ -231,12 +234,12 @@ LIB3270_EXPORT void lib3270_select_region(H3270 *h, int start, int end)
if(start < 0 || start > maxlen || end < 0 || end > maxlen || start > end)
return;
- select_region(h,start,end);
+ do_select(h,start,end,lib3270_get_toggle(h,LIB3270_TOGGLE_RECTANGLE_SELECT));
cursor_move(h,h->select.end);
}
-static void select_region(H3270 *h, int start, int end)
+static void do_select(H3270 *h, int start, int end, int rect)
{
// Do we really need to change selection?
@@ -246,10 +249,16 @@ static void select_region(H3270 *h, int start, int end)
h->select.start = start;
h->select.end = end;
- if(lib3270_get_toggle(h,LIB3270_TOGGLE_RECTANGLE_SELECT))
+ if(rect)
+ {
+ h->rectsel = 1;
update_selected_rectangle(h);
+ }
else
+ {
+ h->rectsel = 0;
update_selected_region(h);
+ }
if(!h->selected)
{
@@ -275,6 +284,12 @@ LIB3270_EXPORT unsigned char lib3270_get_selection_flags(H3270 *hSession, int ba
col = baddr % hSession->cols;
rc |= SELECTION_ACTIVE;
+ if( (hSession->select.start % hSession->cols) == (hSession->select.end % hSession->cols) )
+ rc |= SELECTION_SINGLE_COL;
+
+ if( (hSession->select.start / hSession->cols) == (hSession->select.end / hSession->cols) )
+ rc |= SELECTION_SINGLE_ROW;
+
if( (col == 0) || !(hSession->text[baddr-1].attr & LIB3270_ATTR_SELECTED) )
rc |= SELECTION_LEFT;
@@ -290,57 +305,28 @@ LIB3270_EXPORT unsigned char lib3270_get_selection_flags(H3270 *hSession, int ba
return rc;
}
-LIB3270_EXPORT void lib3270_select_word(H3270 *session, int baddr)
+LIB3270_EXPORT int lib3270_select_word_at(H3270 *session, int baddr)
{
- int pos, len, start, end;
-
- CHECK_SESSION_HANDLE(session);
+ int start, end;
- if(!lib3270_connected(session) || isspace(session->text[baddr].chr))
- {
- lib3270_ring_bell(session);
- return;
- }
+ if(lib3270_get_word_bounds(session,baddr,&start,&end))
+ return -1;
- start = session->select.start;
- for(pos = baddr; pos > 0 && !isspace(session->text[pos].chr);pos--);
- start = pos > 0 ? pos+1 : 0;
+ trace("%s: baddr=%d start=%d end=%d",__FUNCTION__,baddr,start,end);
- len = session->rows * session->cols;
- for(pos = baddr; pos < len && !isspace(session->text[pos].chr);pos++);
- end = pos < len ? pos-1 : len;
+ do_select(session,start,end,0);
- select_region(session,start,end);
+ return 0;
}
LIB3270_EXPORT int lib3270_select_field_at(H3270 *session, int baddr)
{
- int start, end,len;
-
- CHECK_SESSION_HANDLE(session);
-
- if(!lib3270_connected(session))
- {
- lib3270_ring_bell(session);
- return -1;
- }
-
- start = lib3270_field_addr(session,baddr);
+ int start, end;
- if(start < 0)
- {
- lib3270_ring_bell(session);
+ if(lib3270_get_field_bounds(session,baddr,&start,&end))
return -1;
- }
-
- start++;
- len = (session->rows * session->cols)-1;
- end = start + lib3270_field_length(session,start);
- if(end > len)
- end = len;
-
- select_region(session,start,end);
+ do_select(session,start,end,0);
return 0;
}
@@ -358,21 +344,8 @@ LIB3270_ACTION( selectall )
CHECK_SESSION_HANDLE(hSession);
- select_region(hSession,0,hSession->rows*hSession->cols);
-/*
- len = hSession->rows*hSession->cols;
-
- for(baddr = 0; baddr < len; baddr++)
- {
- if(!(hSession->text[baddr].attr & LIB3270_ATTR_SELECTED))
- {
- hSession->text[baddr].attr |= LIB3270_ATTR_SELECTED;
- hSession->update(hSession,baddr,hSession->text[baddr].chr,hSession->text[baddr].attr,baddr == hSession->cursor_addr);
- }
- }
+ do_select(hSession,0,hSession->rows*hSession->cols,0);
- set_selected(hSession);
-*/
return 0;
}
@@ -385,7 +358,7 @@ LIB3270_ACTION( reselect )
if(!lib3270_connected(hSession) || hSession->select.start == hSession->select.end || hSession->selected)
return 0;
- select_region(hSession, hSession->select.start,hSession->select.end);
+ do_select(hSession, hSession->select.start,hSession->select.end,lib3270_get_toggle(hSession,LIB3270_TOGGLE_RECTANGLE_SELECT));
return 0;
}
@@ -589,9 +562,9 @@ LIB3270_EXPORT int lib3270_move_selected_area(H3270 *hSession, int from, int to)
cols = hSession->cols - ((pos[f] % hSession->cols)+1);
}
- step = (rows * hSession->cols) + cols;
+ step = (rows * hSession->cols) + cols;
- select_region(hSession,hSession->select.start + step,hSession->select.end + step);
+ do_select(hSession,hSession->select.start + step,hSession->select.end + step,hSession->rectsel);
cursor_move(hSession,hSession->select.end);
return from+step;
@@ -604,8 +577,6 @@ LIB3270_EXPORT int lib3270_drag_selection(H3270 *h, unsigned char flag, int orig
if(!lib3270_get_selection_bounds(h,&first,&last))
return origin;
- flag &= 0x1f;
-
trace("%s: flag=%04x",__FUNCTION__,flag);
if(!flag)
@@ -629,9 +600,9 @@ LIB3270_EXPORT int lib3270_drag_selection(H3270 *h, unsigned char flag, int orig
origin = last = (row*h->cols) + (last%h->cols);
if(first < last)
- select_region(h,first,last);
+ do_select(h,first,last,h->rectsel);
else
- select_region(h,last,first);
+ do_select(h,last,first,h->rectsel);
cursor_move(h,h->select.end);
@@ -683,7 +654,7 @@ LIB3270_EXPORT int lib3270_move_selection(H3270 *hSession, LIB3270_DIRECTION dir
return -1;
}
- select_region(hSession,start,end);
+ do_select(hSession,start,end,hSession->rectsel);
cursor_move(hSession,hSession->select.end);
return 0;
--
libgit2 0.21.2