[prev in list] [next in list] [prev in thread] [next in thread] 

List:       elinks-dev
Subject:    [elinks-dev] [PATCH 08/10] Make select forms look more like other
From:       yozohida () gmail ! com
Date:       2009-05-13 4:01:55
Message-ID: 1242187317-19338-9-git-send-email-yozohida () gmail ! com
[Download RAW message or body]

Insert "[_" and "_]" as part of the form link, and
include it as part of the link.
---
 src/document/html/parser/forms.c |    4 +-
 src/viewer/text/form.c           |   42 ++++++++++++++++++++++++++++----------
 src/viewer/text/link.c           |    2 +-
 3 files changed, 34 insertions(+), 14 deletions(-)

diff --git a/src/document/html/parser/forms.c b/src/document/html/parser/forms.c
index 68ec8d7..95bdf61 100644
--- a/src/document/html/parser/forms.c
+++ b/src/document/html/parser/forms.c
@@ -501,12 +501,12 @@ end_parse:
 	fc->labels = labels;
 
 	menu_labels(fc->menu, "", labels);
-	put_chrs(html_context, "[", 1);
 	html_stack_dup(html_context, ELEMENT_KILLABLE);
 	format.form = fc;
 	format.style.attr |= AT_BOLD;
 	if (html_context->options->use_form_color)
 		format.style.color.foreground = format.color.form;
+	put_chrs(html_context, "[ ", 7);
 
 	max_width = 0;
 	for (i = 0; i < order; i++) {
@@ -523,8 +523,8 @@ end_parse:
 	for (i = 0; i < max_width; i++)
 		put_chrs(html_context, "_", 1);
 
+	put_chrs(html_context, "&nbsp;]", 7);
 	pop_html_element(html_context);
-	put_chrs(html_context, "]", 1);
 	html_context->special_f(html_context, SP_CONTROL, fc);
 }
 
diff --git a/src/viewer/text/form.c b/src/viewer/text/form.c
index 9a6384f..a7265d9 100644
--- a/src/viewer/text/form.c
+++ b/src/viewer/text/form.c
@@ -592,28 +592,38 @@ drew_char:
 			else
 				/* XXX: when can this happen? --pasky */
 				s = "";
-#ifdef CONFIG_UTF8
-			if (term->utf8_cp) goto utf8_select;
-#endif /* CONFIG_UTF8 */
+
+			/* insert preceding '[_' */
+			i = 0;
+			x = link->points[i].x + dx;
+			y = link->points[i].y + dy;
+			if (is_in_box(box, x, y))
+				draw_char_data(term, x, y, '[');
+			i++;
+			x = link->points[i].x + dx;
+			y = link->points[i].y + dy;
+			if (is_in_box(box, x, y))
+				draw_char_data(term, x, y, '_');
+			i++;
+
+#ifndef CONFIG_UTF8
 			len = s ? strlen(s) : 0;
-			for (i = 0; i < link->npoints; i++) {
+			for (; i < link->npoints-2; i++) {
 				x = link->points[i].x + dx;
 				y = link->points[i].y + dy;
 				if (is_in_box(box, x, y))
-					draw_char_data(term, x, y, i < len ? s[i] : '_');
+					draw_char_data(term, x, y, i-2 < len ? s[i] : '_');
 			}
-			break;
-#ifdef CONFIG_UTF8
-utf8_select:
+#else
 			text = s;
 			end = strchr(s, '\0');
 			len = utf8_ptr2cells(text, end);
-			for (i = 0; i < link->npoints; i++) {
+			for (; i < link->npoints-2; i++) {
 				x = link->points[i].x + dx;
 				y = link->points[i].y + dy;
 				if (is_in_box(box, x, y)) {
 					unicode_val_T data;
-					if (i < len) {
+					if (i-2 < len) {
 						int cell;
 
 						data = utf8_to_unicode(&s, end);
@@ -631,8 +641,18 @@ utf8_select:
 					draw_char_data(term, x, y, data);
 				}
 			}
-			break;
 #endif /* CONFIG_UTF8 */
+			/* insert trailing ' ]'. */
+			x = link->points[i].x + dx;
+			y = link->points[i].y + dy;
+			if (is_in_box(box, x, y))
+				draw_char_data(term, x, y, '_');
+			i++;
+			x = link->points[i].x + dx;
+			y = link->points[i].y + dy;
+			if (is_in_box(box, x, y))
+				draw_char_data(term, x, y, ']');
+			break;
 		case FC_SUBMIT:
 		case FC_IMAGE:
 		case FC_RESET:
diff --git a/src/viewer/text/link.c b/src/viewer/text/link.c
index 3b12c33..bdf6d4b 100644
--- a/src/viewer/text/link.c
+++ b/src/viewer/text/link.c
@@ -122,6 +122,7 @@ get_link_cursor_offset(struct document_view *doc_view, struct link *link)
 		case LINK_CHECKBOX:
 			return 1;
 
+		case LINK_SELECT:
 		case LINK_BUTTON:
 			return 2;
 
@@ -155,7 +156,6 @@ get_link_cursor_offset(struct document_view *doc_view, struct link *link)
 
 		case LINK_HYPERTEXT:
 		case LINK_MAP:
-		case LINK_SELECT:
 			return 0;
 	}
 
-- 
1.6.3

_______________________________________________
elinks-dev mailing list
elinks-dev@linuxfromscratch.org
http://linuxfromscratch.org/mailman/listinfo/elinks-dev
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic