Re: [elinks-dev] [PATCH 04/10] Added option to change colors of HTML forms.

2009-05-16 Thread yozohida
Ah, thanks.  Your suggestion works.  Never thought of doing it that way,
actually.  Please disregard patch #4 in that case.

Thanks,
-Yozo

___
elinks-dev mailing list
elinks-dev@linuxfromscratch.org
http://linuxfromscratch.org/mailman/listinfo/elinks-dev


[elinks-dev] [PATCH 08/10] Make select forms look more like other forms.

2009-05-13 Thread yozohida
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, [nbsp;, 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 @@ 

[elinks-dev] [PATCH 05/10] Provide different color for text areas in insert mode.

2009-05-13 Thread yozohida
The color is controlled by

  document.browse.links.active_link.insert_mode_colors.background
  document.browse.links.active_link.insert_mode_colors.text

Also avoid overloading local variable i in get_current_link().
---
 src/config/options.inc  |   12 
 src/document/document.c |2 ++
 src/document/options.c  |2 ++
 src/document/options.h  |1 +
 src/viewer/text/link.c  |   17 -
 5 files changed, 29 insertions(+), 5 deletions(-)

diff --git a/src/config/options.inc b/src/config/options.inc
index 340ab93..7098854 100644
--- a/src/config/options.inc
+++ b/src/config/options.inc
@@ -294,6 +294,18 @@ static struct option_info config_options_info[] = {
text, 0, black,
N_(Default text color.)),
 
+   INIT_OPT_TREE(document.browse.links.active_link, N_(Insert mode 
colors),
+   insert_mode_colors, 0,
+   N_(Insert mode colors.)),
+
+   INIT_OPT_COLOR(document.browse.links.active_link.insert_mode_colors, 
N_(Background color for text field in insert mode.),
+   background, 0, #ff,
+   N_(Background color for text field in insert mode.)),
+
+   INIT_OPT_COLOR(document.browse.links.active_link.insert_mode_colors, 
N_(Text color for text field in insert mode),
+   text, 0, black,
+   N_(Text color for text field in insert mode.)),
+
INIT_OPT_BOOL(document.browse.links.active_link, N_(Enable color),
enable_color, 0, 0,
N_(Enable use of the active link background and text color 
diff --git a/src/document/document.c b/src/document/document.c
index 5424f6f..19ee2d0 100644
--- a/src/document/document.c
+++ b/src/document/document.c
@@ -234,6 +234,8 @@ update_cached_document_options(struct session *ses)
memset(active_link, 0, sizeof(active_link));   /* Safer. */
active_link.color.foreground = 
get_opt_color(document.browse.links.active_link.colors.text, ses);
active_link.color.background = 
get_opt_color(document.browse.links.active_link.colors.background, ses);
+   active_link.insert_mode_color.foreground = 
get_opt_color(document.browse.links.active_link.insert_mode_colors.text, ses);
+   active_link.insert_mode_color.background = 
get_opt_color(document.browse.links.active_link.insert_mode_colors.background,
 ses);
active_link.enable_color = 
get_opt_bool(document.browse.links.active_link.enable_color, ses);
active_link.invert = 
get_opt_bool(document.browse.links.active_link.invert, ses);
active_link.underline = 
get_opt_bool(document.browse.links.active_link.underline, ses);
diff --git a/src/document/options.c b/src/document/options.c
index b681fda..9208d64 100644
--- a/src/document/options.c
+++ b/src/document/options.c
@@ -52,6 +52,8 @@ init_document_options(struct session *ses, struct 
document_options *doo)
 
doo-active_link.color.foreground = 
get_opt_color(document.browse.links.active_link.colors.text, ses);
doo-active_link.color.background = 
get_opt_color(document.browse.links.active_link.colors.background, ses);
+   doo-active_link.insert_mode_color.foreground = 
get_opt_color(document.browse.links.active_link.insert_mode_colors.text, ses);
+   doo-active_link.insert_mode_color.background = 
get_opt_color(document.browse.links.active_link.insert_mode_colors.background,
 ses);
 
if (get_opt_bool(document.colors.increase_contrast, ses))
doo-color_flags |= COLOR_INCREASE_CONTRAST;
diff --git a/src/document/options.h b/src/document/options.h
index d3bd29a..52c1956 100644
--- a/src/document/options.h
+++ b/src/document/options.h
@@ -20,6 +20,7 @@ struct active_link_options {
unsigned int bold:1;
unsigned int invert:1;
struct active_link_options_colors color;
+   struct active_link_options_colors insert_mode_color;
 };
 
 /** This mostly acts as a option cache so rendering will be faster. However it
diff --git a/src/viewer/text/link.c b/src/viewer/text/link.c
index a9021b0..eaa15f1 100644
--- a/src/viewer/text/link.c
+++ b/src/viewer/text/link.c
@@ -165,7 +165,7 @@ get_link_cursor_offset(struct document_view *doc_view, 
struct link *link)
 /** Initialise a static template character with the colour and attributes
  * appropriate for an active link and return that character. */
 static inline struct screen_char *
-init_link_drawing(struct document_view *doc_view, struct link *link, int 
invert)
+init_link_drawing(struct document_view *doc_view, struct link *link, int 
invert, int input)
 {
struct document_options *doc_opts;
static struct screen_char template;
@@ -187,8 +187,13 @@ init_link_drawing(struct document_view *doc_view, struct 
link *link, int invert)
template.attr |= SCREEN_ATTR_BOLD;
 
if (doc_opts-active_link.enable_color) {
-   colors.foreground = doc_opts-active_link.color.foreground;
-   colors.background = 

[elinks-dev] Series of patches to improve elinks

2009-05-12 Thread yozohida
Hi,

  I started using elinks recently (moving from firefox + vimperator), and
hacked together some patches to improve (?) elinks.  Following messages are
the patches.

Most of the features are independent, but the patches themselves may be
dependent on earlier patch.  Patches are against the current git master branch.

Comments are welcome.

-Yozo

___
elinks-dev mailing list
elinks-dev@linuxfromscratch.org
http://linuxfromscratch.org/mailman/listinfo/elinks-dev


[elinks-dev] [PATCH 01/10] Underline links even in numbered links mode.

2009-05-12 Thread yozohida
See bug #1076.
---
 src/document/html/renderer.c |9 -
 1 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/src/document/html/renderer.c b/src/document/html/renderer.c
index ec6c312..bfbd9c7 100644
--- a/src/document/html/renderer.c
+++ b/src/document/html/renderer.c
@@ -350,11 +350,6 @@ get_format_screen_char(struct html_context *html_context,
copy_struct(ta_cache, format.style);
struct text_style final_style = format.style;
 
-   if (link_state != LINK_STATE_NONE
-html_context-options-underline_links) {
-   final_style.attr |= AT_UNDERLINE;
-   }
-
get_screen_char_template(schar_cache, html_context-options, 
final_style);
}
 
@@ -362,6 +357,10 @@ get_format_screen_char(struct html_context *html_context,
^ !!renderer_context.nosearchable) {
schar_cache.attr ^= SCREEN_ATTR_UNSEARCHABLE;
}
+   if (link_state != LINK_STATE_NONE
+html_context-options-underline_links) {
+   schar_cache.attr |= SCREEN_ATTR_UNDERLINE;
+   }
 
return schar_cache;
 }
-- 
1.6.3

___
elinks-dev mailing list
elinks-dev@linuxfromscratch.org
http://linuxfromscratch.org/mailman/listinfo/elinks-dev


[elinks-dev] [PATCH 02/10] Allow larger document.browse.margin_width.

2009-05-12 Thread yozohida
---
 src/config/options.inc |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/config/options.inc b/src/config/options.inc
index 4e4b255..f957669 100644
--- a/src/config/options.inc
+++ b/src/config/options.inc
@@ -449,7 +449,7 @@ static struct option_info config_options_info[] = {
 
 
INIT_OPT_INT(document.browse, N_(Horizontal text margin),
-   margin_width, 0, 0, 9, 3,
+   margin_width, 0, 0, 100, 3,
N_(Horizontal text margin.)),
 
INIT_OPT_BOOL(document.browse, N_(Document meta refresh),
-- 
1.6.3

___
elinks-dev mailing list
elinks-dev@linuxfromscratch.org
http://linuxfromscratch.org/mailman/listinfo/elinks-dev


[elinks-dev] [PATCH 06/10] Keep forms in bold even when active.

2009-05-12 Thread yozohida
---
 src/viewer/text/link.c |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/src/viewer/text/link.c b/src/viewer/text/link.c
index eaa15f1..7cf3455 100644
--- a/src/viewer/text/link.c
+++ b/src/viewer/text/link.c
@@ -183,7 +183,8 @@ init_link_drawing(struct document_view *doc_view, struct 
link *link, int invert,
if (doc_opts-active_link.underline)
template.attr |= SCREEN_ATTR_UNDERLINE;
 
-   if (doc_opts-active_link.bold)
+   /* keep forms in bold */
+   if (doc_opts-active_link.bold || link-type != LINK_HYPERTEXT)
template.attr |= SCREEN_ATTR_BOLD;
 
if (doc_opts-active_link.enable_color) {
-- 
1.6.3

___
elinks-dev mailing list
elinks-dev@linuxfromscratch.org
http://linuxfromscratch.org/mailman/listinfo/elinks-dev


[elinks-dev] [PATCH 09/10] Add preferred_document_width option.

2009-05-12 Thread yozohida
Option document.browse.preferred_document_width controls the
width of the document, so that documents are rendered with narrower
width than screen width.  Makes it easier to read paragraphs.

Patch originally from Sharon Wood ds...@pele.cx, see bug #1063.

Instead of using max_document_width as the hard limit to the document
width, it uses a soft limit, where if the document does not fit (due to
tables, etc.), then larger width is used.  This reduces the need for
horizontal scrolling for wide documents.

Also added toggle-document-width action to toggle between preferred
width and full screen width.  Initial toggle status is determined by
document.browse.use_preferred_document_width option.
---
 src/config/actions-main.inc|1 +
 src/config/options.inc |   10 ++
 src/document/html/parser.c |2 +-
 src/document/html/parser/forms.c   |8 
 src/document/html/parser/general.c |2 +-
 src/document/html/renderer.c   |4 ++--
 src/document/options.c |7 +++
 src/document/options.h |1 +
 src/document/plain/renderer.c  |2 +-
 src/document/renderer.c|3 +--
 src/viewer/action.c|5 +
 11 files changed, 34 insertions(+), 11 deletions(-)

diff --git a/src/config/actions-main.inc b/src/config/actions-main.inc
index 21ff838..25543f1 100644
--- a/src/config/actions-main.inc
+++ b/src/config/actions-main.inc
@@ -117,6 +117,7 @@ ACTION_(MAIN, toggle-css, TOGGLE_CSS, N__(Toggle 
rendering of page using CSS
 ACTION_(MAIN, toggle-display-images, TOGGLE_DISPLAY_IMAGES, N__(Toggle 
displaying of links to images), 0),
 ACTION_(MAIN, toggle-display-tables, TOGGLE_DISPLAY_TABLES, N__(Toggle 
rendering of tables), 0),
 ACTION_(MAIN, toggle-document-colors, TOGGLE_DOCUMENT_COLORS, N__(Toggle 
usage of document specific colors), 0),
+ACTION_(MAIN, toggle-document-width, TOGGLE_DOCUMENT_WIDTH, N__(Toggle use 
of document width), 0),
 ACTION_(MAIN, toggle-html-plain, TOGGLE_HTML_PLAIN, N__(Toggle rendering 
page as HTML / plain text), 0),
 ACTION_(MAIN, toggle-mouse, TOGGLE_MOUSE, N__(Toggle mouse handling), 0),
 ACTION_(MAIN, toggle-numbered-links, TOGGLE_NUMBERED_LINKS, N__(Toggle 
displaying of links numbers), 0),
diff --git a/src/config/options.inc b/src/config/options.inc
index 7098854..468d0ca 100644
--- a/src/config/options.inc
+++ b/src/config/options.inc
@@ -464,6 +464,16 @@ static struct option_info config_options_info[] = {
margin_width, 0, 0, 100, 3,
N_(Horizontal text margin.)),
 
+   INIT_OPT_INT(document.browse, N_(Preferred document width),
+   preferred_document_width, 0, 0, , 80,
+   N_(Try to fit the document within this width.  If set to zero,
+   use screen width.)),
+
+   INIT_OPT_INT(document.browse, N_(Whether to use preferred document 
width.),
+   use_preferred_document_width, 0, 0, 1, 0,
+   N_(Whether to use preferred document width.  If set to zero,\n
+   use screen width.  If set to one, use 
preferred_document_width.)),
+
INIT_OPT_BOOL(document.browse, N_(Document meta refresh),
refresh, 0, 1,
N_(Automatically follow document-specified refresh 
diff --git a/src/document/html/parser.c b/src/document/html/parser.c
index f3305db..c3cd635 100644
--- a/src/document/html/parser.c
+++ b/src/document/html/parser.c
@@ -930,7 +930,7 @@ init_html_parser(struct uri *uri, struct document_options 
*options,
par_format.leftmargin = options-margin;
par_format.rightmargin = options-margin;
 
-   par_format.width = options-box.width;
+   par_format.width = options-document_width;
par_format.list_level = par_format.list_number = 0;
par_format.dd_margin = options-margin;
par_format.flags = P_NONE;
diff --git a/src/document/html/parser/forms.c b/src/document/html/parser/forms.c
index 95bdf61..9a642b8 100644
--- a/src/document/html/parser/forms.c
+++ b/src/document/html/parser/forms.c
@@ -323,8 +323,8 @@ html_input(struct html_context *html_context, unsigned char 
*a,
if (fc-size == -1)
fc-size = html_context-options-default_form_input_size;
fc-size++;
-   if (fc-size  html_context-options-box.width)
-   fc-size = html_context-options-box.width;
+   if (fc-size  html_context-options-document_width)
+   fc-size = html_context-options-document_width;
fc-maxlength = get_num(a, maxlength, cp);
if (fc-maxlength == -1) fc-maxlength = INT_MAX;
if (fc-type == FC_CHECKBOX || fc-type == FC_RADIO)
@@ -689,8 +689,8 @@ pp:
cols = html_context-options-default_form_input_size;
cols++; /* Add 1 column, other browsers may have different
   behavior here (mozilla adds 2) --Zas */
-   if (cols  html_context-options-box.width)
-   cols =