diff options
author | Sebastian Geerken <devnull@localhost> | 2013-01-29 18:28:36 +0100 |
---|---|---|
committer | Sebastian Geerken <devnull@localhost> | 2013-01-29 18:28:36 +0100 |
commit | ff62d018ba1434f9e9d5beb3a2c82fb1c4ed0f85 (patch) | |
tree | fa3e74abe72781b63468677ed024f68cf62aff06 | |
parent | b8270ee350357ef491fa9ba92cf6250258d3099c (diff) | |
parent | d8f1e1bcfa59947b0dabc7a1ec61232d2eb5535e (diff) |
Merge with main repo.
-rw-r--r-- | ChangeLog | 1 | ||||
-rw-r--r-- | dillorc | 36 | ||||
-rw-r--r-- | doc/dw-images-and-backgrounds.doc | 26 | ||||
-rw-r--r-- | doc/dw-overview.doc | 23 | ||||
-rw-r--r-- | doc/uml-legend.doc | 15 | ||||
-rw-r--r-- | dpi/https.c | 9 | ||||
-rw-r--r-- | dpid/dpid_common.c | 20 | ||||
-rw-r--r-- | dpid/dpid_common.h | 2 | ||||
-rw-r--r-- | dw/fltkui.cc | 24 | ||||
-rw-r--r-- | dw/fltkui.hh | 26 | ||||
-rw-r--r-- | dw/textblock.cc | 14 | ||||
-rw-r--r-- | dw/textblock.hh | 13 | ||||
-rw-r--r-- | dw/ui.hh | 5 | ||||
-rw-r--r-- | dw/widget.cc | 21 | ||||
-rwxr-xr-x | install-hyphenation | 116 | ||||
-rw-r--r-- | lout/container.cc | 230 | ||||
-rw-r--r-- | lout/container.hh | 105 | ||||
-rw-r--r-- | lout/object.cc | 3 | ||||
-rw-r--r-- | src/dialog.cc | 6 | ||||
-rw-r--r-- | src/dillo.cc | 66 | ||||
-rw-r--r-- | src/domain.c | 12 | ||||
-rw-r--r-- | src/form.cc | 27 | ||||
-rw-r--r-- | src/prefs.h | 7 | ||||
-rw-r--r-- | src/tipwin.cc | 2 | ||||
-rw-r--r-- | src/uicmd.cc | 16 | ||||
-rw-r--r-- | test/Makefile.am | 4 | ||||
-rw-r--r-- | test/containers.cc | 53 |
27 files changed, 601 insertions, 281 deletions
@@ -13,6 +13,7 @@ dillo-3.0.3 [not released yet] - Replace polling in DNS with a pipe. - Packed trie to optimize hyphenator memory consumption. - Fix crash in datauri dpi. + - Speed up DNS requests when ipv6 isn't enabled. Patches: Johannes Hofmann +- Fix image input coordinates (BUG#1070) - When location bar is given focus, temporarily show panels if hidden @@ -198,7 +198,7 @@ search_url="Google http://www.google.com/search?ie=UTF-8&oe=UTF-8&q=%s" # # See http://zytrax.com/tech/web/browser_ids.htm for a compilation of strings. # -# http_user_agent="Mozilla/5.0 (Windows NT 5.1; rv:7.0.1) Gecko/20100101 Firefox/7.0.1" +# http_user_agent="Mozilla/5.0 (Windows NT 5.1; rv:18.0) Gecko/20100101 Firefox/18.0" # http_user_agent="Wget/1.12 (linux-gnu)" #The default is "Dillo/"+current_version_number @@ -206,19 +206,6 @@ search_url="Google http://www.google.com/search?ie=UTF-8&oe=UTF-8&q=%s" # COLORS SECTION #------------------------------------------------------------------------- -# Override the user interface colors. -# -# ui_fg_color=black -# ui_main_bg_color=silver -# ui_text_bg_color=white -# ui_selection_color -# ui_button_highlight_color -# ui_tab_active_bg_color -# ui_tab_bg_color -# ui_tab_active_fg_color -# ui_tab_fg_color - - # Set the page background color # bg_color=gray # bg_color=0xd6d6c0 @@ -245,6 +232,27 @@ search_url="Google http://www.google.com/search?ie=UTF-8&oe=UTF-8&q=%s" # theme=gtk+ # theme=plastic +# UI colors +# The first four colors map to concepts in the underlying FLTK toolkit. Note +# that FLTK may sometimes override colors, generally for contrast and +# readability. +# +#ui_fg_color=black +#ui_main_bg_color=silver +#ui_text_bg_color=white +#ui_selection_color=navy +# +# Background used when the mouse cursor is over a button. +#ui_button_highlight_color=(by default, the main background color, lightened) +# +# Colors for the current tab. +#ui_tab_active_bg_color=(by default, the text background color) +#ui_tab_active_fg_color=(by default, the main foreground color) +# +# Colors for the other tabs. +#ui_tab_bg_color=(by default, the main background color) +#ui_tab_fg_color=(by default, the main foreground color) + # Size of dillo panel # tiny : buttons, location, and progress boxes in one row # small : location in one row, buttons + progress boxes in another diff --git a/doc/dw-images-and-backgrounds.doc b/doc/dw-images-and-backgrounds.doc index bb55aca5..356652a6 100644 --- a/doc/dw-images-and-backgrounds.doc +++ b/doc/dw-images-and-backgrounds.doc @@ -50,8 +50,9 @@ dw::core::Widget: \dot digraph G { node [shape=record, fontname=Helvetica, fontsize=10]; - edge [arrowhead="open", arrowtail="none", labelfontname=Helvetica, - labelfontsize=10, color="#404040", labelfontcolor="#000080"]; + edge [arrowhead="open", dir="both", arrowtail="none", + labelfontname=Helvetica, labelfontsize=10, color="#404040", + labelfontcolor="#000080"]; fontname=Helvetica; fontsize=10; "background renderer (as a part of style)" -> "image buffer" [headlabel="*", @@ -73,8 +74,9 @@ The following diagram gives a total overview: \dot digraph G { node [shape=record, fontname=Helvetica, fontsize=10]; - edge [arrowhead="open", arrowtail="none", labelfontname=Helvetica, - labelfontsize=10, color="#404040", labelfontcolor="#000080"]; + edge [arrowhead="open", dir="both", arrowtail="none", + labelfontname=Helvetica, labelfontsize=10, color="#404040", + labelfontcolor="#000080"]; fontname=Helvetica; fontsize=10; "DICache Entry"; @@ -113,25 +115,25 @@ digraph G { BgRenderer -> Imgbuf [headlabel="1", taillabel="*"]; BgRenderer -> BgAllocation [headlabel="*", taillabel="1"]; - ImageRenderer -> BgRenderer [arrowhead="none", arrowtail="empty", + ImageRenderer -> BgRenderer [arrowhead="none", arrowtail="empty", dir="both", style="dashed"]; - ImageRenderer -> Image [arrowhead="none", arrowtail="empty", + ImageRenderer -> Image [arrowhead="none", arrowtail="empty", dir="both", style="dashed"]; Style -> BgRenderer [headlabel="0..1", taillabel="1"]; - Widget -> Textblock [arrowhead="none", arrowtail="empty"]; + Widget -> Textblock [arrowhead="none", arrowtail="empty", dir="both"]; Textblock -> "Textblock::Word" [headlabel="*", taillabel="1"]; - Widget -> Table [arrowhead="none", arrowtail="empty"]; + Widget -> Table [arrowhead="none", arrowtail="empty", dir="both"]; Table -> "Table::Row" [headlabel="*", taillabel="1"]; - Widget -> Image [arrowhead="none", arrowtail="empty"]; + Widget -> Image [arrowhead="none", arrowtail="empty", dir="both"]; - BgAllocation -> Widget [arrowhead="none", arrowtail="empty", + BgAllocation -> Widget [arrowhead="none", arrowtail="empty", dir="both", style="dashed"]; BgAllocation -> "Textblock::Word" [arrowhead="none", arrowtail="empty", - style="dashed"]; + dir="both", style="dashed"]; BgAllocation -> "Table::Row" [arrowhead="none", arrowtail="empty", - style="dashed"]; + dir="both", style="dashed"]; } \enddot diff --git a/doc/dw-overview.doc b/doc/dw-overview.doc index 8c740635..0c4ffb53 100644 --- a/doc/dw-overview.doc +++ b/doc/dw-overview.doc @@ -79,21 +79,22 @@ implementations)"; Layout -> Widget [headlabel="1", taillabel="1", label="topLevel"]; Widget -> Widget [headlabel="*", taillabel="1", label="children"]; - Widget -> Textblock [arrowhead="none", arrowtail="empty"]; - Widget -> Table [arrowhead="none", arrowtail="empty"]; - Widget -> Image [arrowhead="none", arrowtail="empty"]; - Widget -> etc1 [arrowhead="none", arrowtail="empty"]; - Textblock -> AlignedTextblock [arrowhead="none", arrowtail="empty"]; - AlignedTextblock -> etc2 [arrowhead="none", arrowtail="empty"]; - - Platform -> FltkPlatform [arrowhead="none", arrowtail="empty", + Widget -> Textblock [arrowhead="none", arrowtail="empty", dir="both"]; + Widget -> Table [arrowhead="none", arrowtail="empty", dir="both"]; + Widget -> Image [arrowhead="none", arrowtail="empty", dir="both"]; + Widget -> etc1 [arrowhead="none", arrowtail="empty", dir="both"]; + Textblock -> AlignedTextblock [arrowhead="none", arrowtail="empty", + dir="both"]; + AlignedTextblock -> etc2 [arrowhead="none", arrowtail="empty", dir="both"]; + + Platform -> FltkPlatform [arrowhead="none", arrowtail="empty", dir="both", style="dashed"]; FltkPlatform -> FltkView [headlabel="*", taillabel="1"]; - View -> FltkView [arrowhead="none", arrowtail="empty"]; - FltkView -> FltkViewport [arrowhead="none", arrowtail="empty", + View -> FltkView [arrowhead="none", arrowtail="empty", dir="both"]; + FltkView -> FltkViewport [arrowhead="none", arrowtail="empty", dir="both", style="dashed"]; - FltkView -> FltkPreview [arrowhead="none", arrowtail="empty", + FltkView -> FltkPreview [arrowhead="none", arrowtail="empty", dir="both", style="dashed"]; } \enddot diff --git a/doc/uml-legend.doc b/doc/uml-legend.doc index 90294ef6..54004ccd 100644 --- a/doc/uml-legend.doc +++ b/doc/uml-legend.doc @@ -97,8 +97,9 @@ Possible other values for the \em multiplicity: \dot digraph G { node [shape=record, fontname=Helvetica, fontsize=10]; - edge [arrowhead="none", arrowtail="empty", labelfontname=Helvetica, - labelfontsize=10, color="#404040", labelfontcolor="#000080"]; + edge [arrowhead="none", dir="both", arrowtail="empty", + labelfontname=Helvetica, labelfontsize=10, color="#404040", + labelfontcolor="#000080"]; fontname=Helvetica; fontsize=10; A[color="#ff8080"]; B[color="#ff8080"]; @@ -127,8 +128,9 @@ instantiation by the template is shown by a yellow dashed arrow: \dot digraph G { node [shape=record, fontname=Helvetica, fontsize=10]; - edge [arrowhead="none", arrowtail="empty", labelfontname=Helvetica, - labelfontsize=10, color="#404040", labelfontcolor="#000080"]; + edge [arrowhead="none", arrowtail="empty", dir="both", + labelfontname=Helvetica, labelfontsize=10, color="#404040", + labelfontcolor="#000080"]; fontname=Helvetica; fontsize=10; A[color="#ff8080"]; @@ -159,8 +161,9 @@ Packages are presented by dashed rectangles: \dot digraph G { node [shape=record, fontname=Helvetica, fontsize=10]; - edge [arrowhead="none", arrowtail="empty", labelfontname=Helvetica, - labelfontsize=10, color="#404040", labelfontcolor="#000080"]; + edge [arrowhead="none", arrowtail="empty", dir="both", + labelfontname=Helvetica, labelfontsize=10, color="#404040", + labelfontcolor="#000080"]; fontname=Helvetica; fontsize=10; subgraph cluster_1 { diff --git a/dpi/https.c b/dpi/https.c index 9aea31e5..e6d2b0e9 100644 --- a/dpi/https.c +++ b/dpi/https.c @@ -75,8 +75,9 @@ #ifdef ENABLE_SSL -#include <openssl/ssl.h> +#include <openssl/err.h> #include <openssl/rand.h> +#include <openssl/ssl.h> static int get_network_connection(char * url); static int handle_certificate_problem(SSL * ssl_connection); @@ -155,6 +156,11 @@ static void yes_ssl_support(void) } } + /* Do not use the SSLv2 protocol. */ + if (exit_error == 0){ + SSL_CTX_set_options(ssl_context, SSL_OP_NO_SSLv2); + } + /*Set directory to load certificates from*/ /*FIXME - provide for sysconfdir variables and such*/ if (exit_error == 0){ @@ -286,6 +292,7 @@ static void yes_ssl_support(void) /*Actually do SSL connection handshake*/ if (SSL_connect(ssl_connection) != 1){ MSG("SSL_connect failed\n"); + ERR_print_errors_fp(stderr); exit_error = 1; } } diff --git a/dpid/dpid_common.c b/dpid/dpid_common.c index a903db95..23b49397 100644 --- a/dpid/dpid_common.c +++ b/dpid/dpid_common.c @@ -24,17 +24,6 @@ void errmsg(char *caller, char *called, int errornum, char *file, int line) MSG_ERR("%s\n", dStrerror(errornum)); } -/*! Selector function for scandir - * Do not scan files starting with '.' - */ -int no_dotfiles(const struct dirent *filedat) -{ - if (filedat->d_name[0] == '.') - return 0; - else - return 1; -} - /*! * Provides an error checked write command. * Call this via the CKD_WRITE macro @@ -62,12 +51,9 @@ ssize_t ckd_close(int fd, char *file, int line) { ssize_t ret; - do { - ret = close(fd); - } while (ret == -1 && errno == EINTR); - if (ret == -1) { + ret = dClose(fd); + if (ret == -1) MSG_ERR("%s:%d: close: %s\n", file, line, dStrerror(errno)); - } - return (ret); + return ret; } diff --git a/dpid/dpid_common.h b/dpid/dpid_common.h index ed886e19..cc7505a9 100644 --- a/dpid/dpid_common.h +++ b/dpid/dpid_common.h @@ -54,8 +54,6 @@ enum file_type { void errmsg(char *caller, char *called, int errornum, char *file, int line); -int no_dotfiles(const struct dirent *filedat); - ssize_t ckd_write(int fd, char *msg, char *file, int line); ssize_t ckd_close(int fd, char *file, int line); diff --git a/dw/fltkui.cc b/dw/fltkui.cc index 69473cb9..f5a2339b 100644 --- a/dw/fltkui.cc +++ b/dw/fltkui.cc @@ -107,8 +107,11 @@ int CustChoice::handle(int e) this, e, active(), (Fl::focus() == this)); if (Fl::focus() != this) { ; // Not Focused, let FLTK handle it - } else if (e == FL_KEYDOWN) { - if (modifier == 0 && isalnum(k)) { + } else if (e == FL_KEYDOWN && modifier == 0) { + if (k == FL_Enter || k == FL_Down) { + return Fl_Choice::handle(FL_PUSH); // activate menu + + } else if (isalnum(k)) { // try key as shortcut to menuitem int t = value()+1 >= size() ? 0 : value()+1; while (t != value()) { const Fl_Menu_Item *mi = &(menu()[t]); @@ -700,6 +703,20 @@ void FltkEntryResource::setMaxLength (int maxlen) // ---------------------------------------------------------------------- +static int kf_backspace_word (int c, Fl_Text_Editor *e) +{ + int p1, p2 = e->insert_position(); + + e->previous_word(); + p1 = e->insert_position(); + e->buffer()->remove(p1, p2); + e->show_insert_position(); + e->set_changed(); + if (e->when() & FL_WHEN_CHANGED) + e->do_callback(); + return 0; +} + FltkMultiLineTextResource::FltkMultiLineTextResource (FltkPlatform *platform, int cols, int rows): FltkSpecificResource <dw::core::ui::MultiLineTextResource> (platform) @@ -741,6 +758,9 @@ Fl_Widget *FltkMultiLineTextResource::createNewWidget (core::Allocation allocation->ascent + allocation->descent); text->wrap_mode(Fl_Text_Display::WRAP_AT_BOUNDS, 0); text->buffer (buffer); + text->remove_key_binding(FL_BackSpace, FL_TEXT_EDITOR_ANY_STATE); + text->add_key_binding(FL_BackSpace, 0, Fl_Text_Editor::kf_backspace); + text->add_key_binding(FL_BackSpace, FL_CTRL, kf_backspace_word); return text; } diff --git a/dw/fltkui.hh b/dw/fltkui.hh index e1845abd..46bb5c39 100644 --- a/dw/fltkui.hh +++ b/dw/fltkui.hh @@ -15,13 +15,23 @@ namespace fltk { /** * \brief FLTK implementation of dw::core::ui. * + * <div style="border: 2px solid #ff0000; margin-top: 0.5em; + * margin-bottom: 0.5em; padding: 0.5em 1em; + * background-color: #ffefe0"><b>Update:</b> The complicated design + * results from my insufficient knowledge of C++ some years ago; since + * then, I've learned how to deal with "diamond inheritance", as the + * (ideal, not actually implemented) design in the first diagram + * shows. It should be possible to implement this ideal design in a + * straightforward way, and so get rid of templates. --SG</div> + * * The design should be like this: * * \dot * digraph G { * node [shape=record, fontname=Helvetica, fontsize=10]; - * edge [arrowhead="none", arrowtail="empty", labelfontname=Helvetica, - * labelfontsize=10, color="#404040", labelfontcolor="#000080"]; + * edge [arrowhead="none", arrowtail="empty", dir="both", + * labelfontname=Helvetica, labelfontsize=10, color="#404040", + * labelfontcolor="#000080"]; * fontname=Helvetica; fontsize=10; * * subgraph cluster_core { @@ -72,8 +82,9 @@ namespace fltk { * \dot * digraph G { * node [shape=record, fontname=Helvetica, fontsize=10]; - * edge [arrowhead="none", arrowtail="empty", labelfontname=Helvetica, - * labelfontsize=10, color="#404040", labelfontcolor="#000080"]; + * edge [arrowhead="none", arrowtail="empty", dir="both", + * labelfontname=Helvetica, labelfontsize=10, color="#404040", + * labelfontcolor="#000080"]; * fontname=Helvetica; fontsize=10; * * subgraph cluster_core { @@ -113,8 +124,9 @@ namespace fltk { * \dot * digraph G { * node [shape=record, fontname=Helvetica, fontsize=10]; - * edge [arrowhead="none", arrowtail="empty", labelfontname=Helvetica, - * labelfontsize=10, color="#404040", labelfontcolor="#000080"]; + * edge [arrowhead="none", arrowtail="empty", dir="both", + * labelfontname=Helvetica, labelfontsize=10, color="#404040", + * labelfontcolor="#000080"]; * fontname=Helvetica; fontsize=10; * * subgraph cluster_core { @@ -150,10 +162,12 @@ namespace fltk { * FltkResource -> FltkSpecificResource; * FltkSpecificResource -> FltkSpecificResource_button [arrowhead="open", * arrowtail="none", + * dir="both", * style="dashed", * color="#808000"]; * FltkSpecificResource -> FltkSpecificResource_entry [arrowhead="open", * arrowtail="none", + * dir="both", * style="dashed", * color="#808000"]; * LabelButtonResource -> FltkSpecificResource_button; diff --git a/dw/textblock.cc b/dw/textblock.cc index d01e4320..68a6b9b3 100644 --- a/dw/textblock.cc +++ b/dw/textblock.cc @@ -1928,6 +1928,20 @@ void Textblock::addSpace (core::style::Style *style) } } +/** + * Add a break option (see setBreakOption() for details). Used instead + * of addStyle for ideographic characters. + */ +void Textblock::addBreakOption (core::style::Style *style) +{ + int wordIndex = words->size () - 1; + if (wordIndex >= 0) { + setBreakOption (words->getRef(wordIndex), style); + // Call of accumulateWordData() is not needed here. + correctLastWordExtremes (); + } +} + void Textblock::fillSpace (Word *word, core::style::Style *style) { // Old comment: diff --git a/dw/textblock.hh b/dw/textblock.hh index 21ec6263..61cf6a56 100644 --- a/dw/textblock.hh +++ b/dw/textblock.hh @@ -640,18 +640,7 @@ public: void addWidget (core::Widget *widget, core::style::Style *style); bool addAnchor (const char *name, core::style::Style *style); void addSpace (core::style::Style *style); - - /** - * Add a break option (see setBreakOption() for details). Used - * instead of addStyle for ideographic characters. - */ - inline void addBreakOption (core::style::Style *style) - { - int wordIndex = words->size () - 1; - if (wordIndex >= 0) - setBreakOption (words->getRef(wordIndex), style); - } - + void addBreakOption (core::style::Style *style); void addParbreak (int space, core::style::Style *style); void addLinebreak (core::style::Style *style); @@ -20,8 +20,9 @@ namespace core { * \dot * digraph G { * node [shape=record, fontname=Helvetica, fontsize=10]; - * edge [arrowhead="none", arrowtail="empty", labelfontname=Helvetica, - * labelfontsize=10, color="#404040", labelfontcolor="#000080"]; + * edge [arrowhead="none", arrowtail="empty", dir="both", + * labelfontname=Helvetica, labelfontsize=10, color="#404040", + * labelfontcolor="#000080"]; * fontname=Helvetica; fontsize=10; * * subgraph cluster_core { diff --git a/dw/widget.cc b/dw/widget.cc index 8f5bc5d5..5f6bb2c0 100644 --- a/dw/widget.cc +++ b/dw/widget.cc @@ -130,9 +130,6 @@ void Widget::queueResize (int ref, bool extremesChanged) { Widget *widget2, *child; - //printf("The %stop-level %s %p with parentRef = %d has changed its size.\n", - // parent ? "non-" : "", getClassName(), this, parentRef); - setFlags (NEEDS_RESIZE); setFlags (NEEDS_ALLOCATE); markSizeChange (ref); @@ -149,11 +146,6 @@ void Widget::queueResize (int ref, bool extremesChanged) widget2->markSizeChange (child->parentRef); widget2->setFlags (NEEDS_ALLOCATE); - //printf (" Setting DW_NEEDS_RESIZE and NEEDS_ALLOCATE for the " - // "%stop-level %s %p with parentRef = %d\n", - // widget2->parent ? "non-" : "", widget2->getClassName(), widget2, - // widget2->parentRef); - if (extremesChanged) { widget2->setFlags (EXTREMES_CHANGED); widget2->markExtremesChange (child->parentRef); @@ -220,15 +212,6 @@ void Widget::sizeAllocate (Allocation *allocation) allocation->ascent != this->allocation.ascent || allocation->descent != this->allocation.descent) { - //DEBUG_MSG (DEBUG_ALLOC, - // "a %stop-level %s with parent_ref = %d is newly allocated " - // "from %d, %d, %d x %d x %d ...\n", - // widget->parent ? "non-" : "", - // (GTK_OBJECT_TYPE_NAME (widget), widget->parent_ref, - // widget->allocation.x, widget->allocation.y, - // widget->allocation.width, widget->allocation.ascent, - // widget->allocation.descent); - if (wasAllocated ()) { layout->queueDrawExcept ( this->allocation.x, @@ -513,10 +496,6 @@ Widget *Widget::getWidgetAtPoint (int x, int y, int level) Iterator *it; Widget *childAtPoint; - //printf ("%*s-> examining the %s %p (%d, %d, %d x (%d + %d))\n", - // 3 * level, "", getClassName (), this, allocation.x, allocation.y, - // allocation.width, allocation.ascent, allocation.descent); - if (x >= allocation.x && y >= allocation.y && x <= allocation.x + allocation.width && diff --git a/install-hyphenation b/install-hyphenation new file mode 100755 index 00000000..7ee90602 --- /dev/null +++ b/install-hyphenation @@ -0,0 +1,116 @@ +#!/usr/bin/env perl + +use POSIX; +use File::Basename; + +sub getpattendir () { + # Extract pattern directory from Makefile, in the same directory as + # this script. A complete interpretation of the Makefiles would be + # too complicated, so only ${prefix} is read, which is (hopefully) + # defined as constant. + + my $mf = (dirname $0) . "/Makefile", $prefix = ""; + open MF, $mf or die "Cannot open $mf for reading: $!"; + while (<MF>) { + if (/^\s*prefix\s*=\s*(.*)\s*$/) { + $prefix = $1; + } + } + + close MF; + + if ($prefix eq "") { + die "prefix not defined in $mf"; + } + + return "$prefix/lib/dillo/hyphenation"; +} + + +sub printhelp { + print " Syntax: install-hyphenation <lang1> [<lang2> ...]\n"; + print "\n"; + print " If there are multiple pattern files for a language, and so the file name\n"; + print " is not \"hyph-<lang>.tex\", you can specify the origin by using a colon:\n"; + print " \"<src-lang>:<dest-lang>\", eg. \"de-1996:de\". If both are identical, the\n"; + print " colon can be committed; \"ru\" is equivalent to \"ru:ru\".\n"; + +} + +sub trpatfile { + # Extract the data needed by dillo from the TeX file, based on two + # rules: + # + # 1. Extract the argument of the "\pattern" sequence, i. e. + # anything between "\pattern{" and the next "}". + # 2. As an exception, comments are always preserved. + + my $url = $_[0], $in = $_[1], $out = $_[2]; + + open IN, $in or die die "Cannot open $in for reading: $!"; + open OUT, "> $out" or die "Cannot open $out for writing: $!"; + + printf OUT "%% The original file was downloaded from\n"; + printf OUT "%%\n"; + printf OUT "%% $url\n"; + printf OUT "%%\n"; + printf OUT "%% and automatically translated into this format. The original comments,\n"; + printf OUT "%% including the original copyright notice, are preserved.\n"; + printf OUT "%%\n"; + printf OUT "%% -----------------------------------------------------------------------------\n"; + printf OUT "%%\n"; + + $inpatterns = 0; + while (<IN>) { + if (/^%/) { + # Adopt all comments + print OUT; + } elsif (!$inpatterns) { + if (/\\patterns\s*{/) { + $inpatterns = 1; + } + } else { + if (/}/) { + $inpatterns = 0; + } else { + print OUT; + } + } + } + + close IN; + close OUT; + + printf "Wrote pattern file: $out\n"; +} + +sub dlpatfile { + my $lang = $_[0], $destdir = $_[1], $lang1, $lang2; + if ($lang =~ /(.*):(.*)/) { + $lang1 = $1; + $lang2 = $2; + } else { + $lang1 = $lang2 = $lang; + } + + my $url = "ftp://ftp.mpi-sb.mpg.de/pub/tex/mirror/ftp.dante.de/pub/tex/language/hyph-utf8/tex/generic/hyph-utf8/patterns/tex/hyph-$lang1.tex"; + my $tmp = tmpnam(); + if (system("wget -O $tmp $url") == 0) { + my $out = "$destdir/$lang2.pat"; + trpatfile $url, $tmp, $out; + unlink $tmp; + } else { + print "Error downloading patterns for language $lang1. See messages above for details.\n" + } +} + +$destdir = getpattendir; + +foreach $lang (@ARGV) { + if ($lang eq '-?' || $lang eq '--?' || $lang eq '-h' || + $lang eq '--h' || $lang eq '-help' || $lang eq '--help') { + printhelp; + } else { + dlpatfile $lang, $destdir; + } +} diff --git a/lout/container.cc b/lout/container.cc index 0a3d6acd..deeede57 100644 --- a/lout/container.cc +++ b/lout/container.cc @@ -17,7 +17,8 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ - +#define PRINTF(fmt, ...) +//#define PRINTF printf #include "container.hh" #include "misc.hh" @@ -302,13 +303,12 @@ Collection0::AbstractIterator* List::createIterator() // --------------- -// HashTable +// HashSet // --------------- -HashTable::HashTable(bool ownerOfKeys, bool ownerOfValues, int tableSize) +HashSet::HashSet(bool ownerOfObjects, int tableSize) { - this->ownerOfKeys = ownerOfKeys; - this->ownerOfValues = ownerOfValues; + this->ownerOfObjects = ownerOfObjects; this->tableSize = tableSize; table = new Node*[tableSize]; @@ -316,19 +316,24 @@ HashTable::HashTable(bool ownerOfKeys, bool ownerOfValues, int tableSize) table[i] = NULL; } -HashTable::~HashTable() +HashSet::~HashSet() { for (int i = 0; i < tableSize; i++) { Node *n1 = table[i]; while (n1) { Node *n2 = n1->next; - if (ownerOfValues && n1->value) - delete n1->value; - if (ownerOfKeys) - delete n1->key; - delete n1; + // It seems appropriate to call "clearNode(n1)" here instead + // of "delete n1->object", but since this is the destructor, + // the implementation of a sub class would not be called + // anymore. This is the reason why HashTable has an + // destructor. + if (ownerOfObjects) { + PRINTF ("- deleting object: %s\n", n1->object->toString()); + delete n1->object; + } + delete n1; n1 = n2; } } @@ -336,73 +341,77 @@ HashTable::~HashTable() delete[] table; } -void HashTable::intoStringBuffer(misc::StringBuffer *sb) +HashSet::Node *HashSet::createNode() { - sb->append("{ "); + return new Node; +} - bool first = true; - for (int i = 0; i < tableSize; i++) { - for (Node *node = table[i]; node; node = node->next) { - if (!first) - sb->append(", "); - node->key->intoStringBuffer(sb); - sb->append(" => "); - node->value->intoStringBuffer(sb); - first = false; - } +void HashSet::clearNode(HashSet::Node *node) +{ + if (ownerOfObjects) { + PRINTF ("- deleting object: %s\n", node->object->toString()); + delete node->object; } - - sb->append(" }"); } -void HashTable::put(Object *key, Object *value) +HashSet::Node *HashSet::findNode(Object *object) { - int h = calcHashValue(key); - Node *n = new Node; - n->key = key; - n->value = value; - n->next = table[h]; - table[h] = n; + int h = calcHashValue(object); + for (Node *node = table[h]; node; node = node->next) { + if (object->equals(node->object)) + return node; + } + + return NULL; } -bool HashTable::contains(Object *key) +HashSet::Node *HashSet::insertNode(Object *object) { - int h = calcHashValue(key); - for (Node *n = table[h]; n; n = n->next) { - if (key->equals(n->key)) - return true; + // Look whether object is already contained. + Node *node = findNode(object); + if (node) + clearNode(node); + else { + int h = calcHashValue(object); + node = createNode (); + node->next = table[h]; + table[h] = node; } - return false; + node->object = object; + return node; } -Object *HashTable::get(Object *key) + +void HashSet::put(Object *object) +{ + insertNode (object); +} + +bool HashSet::contains(Object *object) { - int h = calcHashValue(key); + int h = calcHashValue(object); for (Node *n = table[h]; n; n = n->next) { - if (key->equals(n->key)) - return n->value; + if (object->equals(n->object)) + return true; } - return NULL; + return false; } -bool HashTable::remove(Object *key) +bool HashSet::remove(Object *object) { - int h = calcHashValue(key); + int h = calcHashValue(object); Node *last, *cur; for (last = NULL, cur = table[h]; cur; last = cur, cur = cur->next) { - if (key->equals(cur->key)) { + if (object->equals(cur->object)) { if (last) last->next = cur->next; else table[h] = cur->next; - if (ownerOfValues && cur->value) - delete cur->value; - if (ownerOfKeys) - delete cur->key; + clearNode (cur); delete cur; return true; @@ -410,46 +419,53 @@ bool HashTable::remove(Object *key) } return false; + + // TODO for HashTable: also remove value. } -Object *HashTable::getKey (Object *key) +// For historical reasons: this method once existed under the name +// "getKey" in HashTable. It could be used to get the real object from +// the table, but it was dangerous, because a change of this object +// would also change the hash value, and so confuse the table. + +/*Object *HashSet::getReference (Object *object) { - int h = calcHashValue(key); + int h = calcHashValue(object); for (Node *n = table[h]; n; n = n->next) { - if (key->equals(n->key)) - return n->key; + if (object->equals(n->object)) + return n->object; } return NULL; -} +}*/ -HashTable::HashTableIterator::HashTableIterator(HashTable *table) +HashSet::HashSetIterator::HashSetIterator(HashSet *set) { - this->table = table; + this->set = set; node = NULL; pos = -1; gotoNext(); } -void HashTable::HashTableIterator::gotoNext() +void HashSet::HashSetIterator::gotoNext() { if (node) node = node->next; while (node == NULL) { - if (pos >= table->tableSize - 1) + if (pos >= set->tableSize - 1) return; pos++; - node = table->table[pos]; + node = set->table[pos]; } } -Object *HashTable::HashTableIterator::getNext() +Object *HashSet::HashSetIterator::getNext() { Object *result; if (node) - result = node->key; + result = node->object; else result = NULL; @@ -457,14 +473,98 @@ Object *HashTable::HashTableIterator::getNext() return result; } -bool HashTable::HashTableIterator::hasNext() +bool HashSet::HashSetIterator::hasNext() { return node != NULL; } -Collection0::AbstractIterator* HashTable::createIterator() +Collection0::AbstractIterator* HashSet::createIterator() +{ + return new HashSetIterator(this); +} + +// --------------- +// HashTable +// --------------- + +HashTable::HashTable(bool ownerOfKeys, bool ownerOfValues, int tableSize) : + HashSet (ownerOfKeys, tableSize) +{ + this->ownerOfValues = ownerOfValues; +} + +HashTable::~HashTable() +{ + // See comment in the destructor of HashSet. + for (int i = 0; i < tableSize; i++) { + for (Node *n = table[i]; n; n = n->next) { + if (ownerOfValues) { + Object *value = ((KeyValuePair*)n)->value; + if (value) { + PRINTF ("- deleting value: %s\n", value->toString()); + delete value; + } + } + } + } +} + +HashSet::Node *HashTable::createNode() +{ + return new KeyValuePair; +} + +void HashTable::clearNode(HashSet::Node *node) +{ + HashSet::clearNode (node); + if (ownerOfValues) { + Object *value = ((KeyValuePair*)node)->value; + if (value) { + PRINTF ("- deleting value: %s\n", value->toString()); + delete value; + } + } +} + +void HashTable::intoStringBuffer(misc::StringBuffer *sb) +{ + sb->append("{ "); + + bool first = true; + for (int i = 0; i < tableSize; i++) { + for (Node *node = table[i]; node; node = node->next) { + if (!first) + sb->append(", "); + node->object->intoStringBuffer(sb); + + sb->append(" => "); + + Object *value = ((KeyValuePair*)node)->value; + if (value) + value->intoStringBuffer(sb); + else + sb->append ("null"); + + first = false; + } + } + + sb->append(" }"); +} + +void HashTable::put(Object *key, Object *value) +{ + KeyValuePair *node = (KeyValuePair*)insertNode(key); + node->value = value; +} + +Object *HashTable::get(Object *key) { - return new HashTableIterator(this); + Node *node = findNode(key); + if (node) + return ((KeyValuePair*)node)->value; + else + return NULL; } // ----------- diff --git a/lout/container.hh b/lout/container.hh index d2484b13..f1008e82 100644 --- a/lout/container.hh +++ b/lout/container.hh @@ -179,46 +179,78 @@ public: /** - * \brief A hash table. + * \brief A hash set. */ -class HashTable: public Collection +class HashSet: public Collection { - friend class HashTableIterator; + friend class HashSetIterator; -private: +protected: struct Node { - object::Object *key, *value; + object::Object *object; Node *next; }; - class HashTableIterator: public Collection0::AbstractIterator + Node **table; + int tableSize; + bool ownerOfObjects; + + inline int calcHashValue(object::Object *object) + { + return abs(object->hashValue()) % tableSize; + } + + virtual Node *createNode(); + virtual void clearNode(Node *node); + + Node *findNode(object::Object *object); + Node *insertNode(object::Object *object); + + AbstractIterator* createIterator(); + +private: + class HashSetIterator: public Collection0::AbstractIterator { private: - HashTable *table; - HashTable::Node *node; + HashSet *set; + HashSet::Node *node; int pos; void gotoNext(); public: - HashTableIterator(HashTable *table); + HashSetIterator(HashSet *set); bool hasNext(); Object *getNext(); }; - Node **table; - int tableSize; - bool ownerOfKeys, ownerOfValues; +public: + HashSet(bool ownerOfObjects, int tableSize = 251); + ~HashSet(); + void put (object::Object *object); + bool contains (object::Object *key); + bool remove (object::Object *key); + //Object *getReference (object::Object *object); +}; + +/** + * \brief A hash table. + */ +class HashTable: public HashSet +{ private: - inline int calcHashValue(object::Object *key) + bool ownerOfValues; + + struct KeyValuePair: public Node { - return abs(key->hashValue()) % tableSize; - } + object::Object *value; + }; protected: - AbstractIterator* createIterator(); + Node *createNode(); + void clearNode(Node *node); public: HashTable(bool ownerOfKeys, bool ownerOfValues, int tableSize = 251); @@ -227,10 +259,7 @@ public: void intoStringBuffer(misc::StringBuffer *sb); void put (object::Object *key, object::Object *value); - bool contains (object::Object *key); - Object *get (object::Object *key); - bool remove (object::Object *key); - Object *getKey (Object *key); + object::Object *get (object::Object *key); }; /** @@ -328,6 +357,9 @@ protected: untyped::Collection *base; public: + Collection () { this->base = NULL; } + ~Collection () { if (this->base) delete this->base; } + void intoStringBuffer(misc::StringBuffer *sb) { this->base->intoStringBuffer(sb); } @@ -344,7 +376,6 @@ template <class T> class Vector: public Collection <T> public: inline Vector(int initSize, bool ownerOfObjects) { this->base = new untyped::Vector(initSize, ownerOfObjects); } - ~Vector() { delete this->base; } inline void put(T *newElement, int newPos = -1) { ((untyped::Vector*)this->base)->put(newElement, newPos); } @@ -367,7 +398,6 @@ template <class T> class List: public Collection <T> public: inline List(bool ownerOfObjects) { this->base = new untyped::List(ownerOfObjects); } - ~List() { delete this->base; } inline void clear() { ((untyped::List*)this->base)->clear(); } inline void append(T *element) @@ -388,28 +418,42 @@ public: { return (T*)((untyped::List*)this->base)->getLast(); } }; +/** + * \brief Typed version of container::untyped::HashSet. + */ +template <class T> class HashSet: public Collection <T> +{ +protected: + inline HashSet() { } + +public: + inline HashSet(bool owner, int tableSize = 251) + { this->base = new untyped::HashSet(owner, tableSize); } + + inline void put(T *object) + { return ((untyped::HashSet*)this->base)->put(object); } + inline bool contains(T *object) + { return ((untyped::HashSet*)this->base)->contains(object); } + inline bool remove(T *object) + { return ((untyped::HashSet*)this->base)->remove(object); } + //inline T *getReference(T *object) + //{ return (T*)((untyped::HashSet*)this->base)->getReference(object); } +}; /** * \brief Typed version of container::untyped::HashTable. */ -template <class K, class V> class HashTable: public Collection <K> +template <class K, class V> class HashTable: public HashSet <K> { public: inline HashTable(bool ownerOfKeys, bool ownerOfValues, int tableSize = 251) { this->base = new untyped::HashTable(ownerOfKeys, ownerOfValues, tableSize); } - ~HashTable() { delete this->base; } inline void put(K *key, V *value) { return ((untyped::HashTable*)this->base)->put(key, value); } - inline bool contains(K *key) - { return ((untyped::HashTable*)this->base)->contains(key); } inline V *get(K *key) { return (V*)((untyped::HashTable*)this->base)->get(key); } - inline bool remove(K *key) - { return ((untyped::HashTable*)this->base)->remove(key); } - inline K *getKey(K *key) - { return (K*)((untyped::HashTable*)this->base)->getKey(key); } }; /** @@ -420,7 +464,6 @@ template <class T> class Stack: public Collection <T> public: inline Stack (bool ownerOfObjects) { this->base = new untyped::Stack (ownerOfObjects); } - ~Stack() { delete this->base; } inline void push (T *object) { ((untyped::Stack*)this->base)->push (object); } diff --git a/lout/object.cc b/lout/object.cc index 843c0ae4..85a908b9 100644 --- a/lout/object.cc +++ b/lout/object.cc @@ -21,6 +21,7 @@ #include "object.hh" #include <stdio.h> +#include <stdint.h> #include <config.h> namespace lout { @@ -132,7 +133,7 @@ int Pointer::hashValue() // Combine both parts of the pointer value *itself*, not what it // points to, by first referencing it (operator "&"), then // dereferencing it again (operator "[]"). - return ((int*)&value)[0] ^ ((int*)&value)[1]; + return ((intptr_t)value >> 32) ^ ((intptr_t)value); #endif } diff --git a/src/dialog.cc b/src/dialog.cc index 484eebc4..92b99041 100644 --- a/src/dialog.cc +++ b/src/dialog.cc @@ -82,9 +82,9 @@ int CustInput3::handle(int e) /* * Used to make the ENTER key activate the CustChoice */ -class CustChoice : public Fl_Choice { +class CustChoice2 : public Fl_Choice { public: - CustChoice (int x, int y, int w, int h, const char* l=0) : + CustChoice2 (int x, int y, int w, int h, const char* l=0) : Fl_Choice(x,y,w,h,l) {}; int handle(int e) { if (e == FL_KEYBOARD && @@ -178,7 +178,7 @@ const char *a_Dialog_input(const char *title, const char *msg) c_inp->labelsize(14); c_inp->textsize(14); - CustChoice *ch = new CustChoice(1*gap,ih+3*gap,180,24); + CustChoice2 *ch = new CustChoice2(1*gap,ih+3*gap,180,24); if (!pm) { int n_it = dList_length(prefs.search_urls); pm = new Fl_Menu_Item[n_it+1]; diff --git a/src/dillo.cc b/src/dillo.cc index 5ad34e78..cef3e451 100644 --- a/src/dillo.cc +++ b/src/dillo.cc @@ -237,43 +237,47 @@ static void checkPreferredFonts() checkFont(prefs.font_fantasy, "fantasy"); } -static void setColorFLTK(int32_t color, void (*fn) (uchar, uchar, uchar)) +/* + * Set UI color. 'color' is an 0xrrggbb value, whereas 'default_val' is a fltk + * color (index 0-0xFF, or 0xrrggbb00). + */ +static void setUIColorWdef(Fl_Color idx, int32_t color, Fl_Color default_val) { if (color != -1) - fn(color >> 16, (color >> 8) & 0xff, color & 0xff); -} - -static void setColorPrefWdef(int32_t &color, int32_t default_val) -{ - if (color == -1) - color = default_val; - else if (color == 0) - color = FL_BLACK; - else - color <<= 8; + Fl::set_color(idx, color << 8); + else if (default_val != 0xFFFFFFFF) + Fl::set_color(idx, default_val); } static void setColors() { - unsigned rgb; - - setColorFLTK(prefs.ui_main_bg_color, Fl::background); - setColorFLTK(prefs.ui_text_bg_color, Fl::background2); - setColorFLTK(prefs.ui_fg_color, Fl::foreground); - - if (prefs.ui_selection_color == -1) - rgb = Fl::get_color(fl_contrast(FL_SELECTION_COLOR, - FL_BACKGROUND2_COLOR)); - else - rgb = prefs.ui_selection_color << 8; - Fl::set_color(FL_SELECTION_COLOR, rgb); - - setColorPrefWdef(prefs.ui_button_highlight_color, - fl_lighter(FL_BACKGROUND_COLOR)); - setColorPrefWdef(prefs.ui_tab_active_bg_color, FL_BACKGROUND2_COLOR); - setColorPrefWdef(prefs.ui_tab_bg_color, FL_BACKGROUND_COLOR); - setColorPrefWdef(prefs.ui_tab_active_fg_color, FL_FOREGROUND_COLOR); - setColorPrefWdef(prefs.ui_tab_fg_color, FL_FOREGROUND_COLOR); + /* The main background is a special case because Fl::background() will + * set the "gray ramp", which is a set of lighter and darker colors based + * on the main background and used for box edges and such. + */ + if (prefs.ui_main_bg_color != -1) { + uchar r = prefs.ui_main_bg_color >> 16, + g = prefs.ui_main_bg_color >> 8 & 0xff, + b = prefs.ui_main_bg_color & 0xff; + + Fl::background(r, g, b); + } + + setUIColorWdef(FL_BACKGROUND2_COLOR, prefs.ui_text_bg_color, 0xFFFFFFFF); + setUIColorWdef(FL_FOREGROUND_COLOR, prefs.ui_fg_color, 0xFFFFFFFF); + setUIColorWdef(FL_SELECTION_COLOR, prefs.ui_selection_color, + fl_contrast(FL_SELECTION_COLOR, FL_BACKGROUND2_COLOR)); + setUIColorWdef(PREFS_UI_BUTTON_HIGHLIGHT_COLOR, + prefs.ui_button_highlight_color, + fl_lighter(FL_BACKGROUND_COLOR)); + setUIColorWdef(PREFS_UI_TAB_ACTIVE_BG_COLOR, prefs.ui_tab_active_bg_color, + Fl::get_color(FL_BACKGROUND2_COLOR)); + setUIColorWdef(PREFS_UI_TAB_BG_COLOR, prefs.ui_tab_bg_color, + Fl::get_color(FL_BACKGROUND_COLOR)); + setUIColorWdef(PREFS_UI_TAB_ACTIVE_FG_COLOR, prefs.ui_tab_active_fg_color, + Fl::get_color(FL_FOREGROUND_COLOR)); + setUIColorWdef(PREFS_UI_TAB_FG_COLOR, prefs.ui_tab_fg_color, + Fl::get_color(FL_FOREGROUND_COLOR)); } /* diff --git a/src/domain.c b/src/domain.c index be5d2221..70cdaaa3 100644 --- a/src/domain.c +++ b/src/domain.c @@ -33,7 +33,7 @@ void a_Domain_parse(FILE *fp) char *line; uint_t lineno = 0; - MSG("Reading domainrc...\n"); + _MSG("Reading domainrc...\n"); while ((line = dGetline(fp)) != NULL) { ++lineno; @@ -68,7 +68,7 @@ void a_Domain_parse(FILE *fp) exceptions[num_exceptions].origin = dStrdup(tok1); exceptions[num_exceptions].destination = dStrdup(tok2); num_exceptions++; - MSG("Domain: Exception from %s to %s.\n", tok1, tok2); + _MSG("Domain: Exception from %s to %s.\n", tok1, tok2); } } } @@ -138,14 +138,14 @@ bool_t a_Domain_permit(const DilloUrl *source, const DilloUrl *dest) if (Domain_match(source_host, exceptions[i].origin) && Domain_match(dest_host, exceptions[i].destination)) { ret = default_deny; - MSG("Domain: Matched rule from %s to %s.\n", exceptions[i].origin, - exceptions[i].destination); + _MSG("Domain: Matched rule from %s to %s.\n", exceptions[i].origin, + exceptions[i].destination); break; } } - MSG("Domain: %s from %s to %s.\n", - (ret == TRUE ? "permitted" : "DENIED"), source_host, dest_host); + if (ret == FALSE) + MSG("Domain: DENIED from %s to %s.\n", source_host, dest_host); return ret; } diff --git a/src/form.cc b/src/form.cc index 8ec340bb..d9537036 100644 --- a/src/form.cc +++ b/src/form.cc @@ -363,29 +363,6 @@ void Html_tag_open_form(DilloHtml *html, const char *tag, int tagsize) void Html_tag_close_form(DilloHtml *html) { -// DilloHtmlForm *form; -// int i; -// -// if (html->InFlags & IN_FORM) { -// form = html->getCurrentForm (); -// -// /* Make buttons sensitive again */ -// for (i = 0; i < form->inputs->size(); i++) { -// input_i = form->inputs->get(i); -// /* Check for tricky HTML (e.g. <input type=image>) */ -// if (!input_i->widget) -// continue; -// if (input_i->type == DILLO_HTML_INPUT_SUBMIT || -// input_i->type == DILLO_HTML_INPUT_RESET) { -// gtk_widget_set_sensitive(input_i->widget, TRUE); -// } else if (input_i->type == DILLO_HTML_INPUT_IMAGE || -// input_i->type == DILLO_HTML_INPUT_BUTTON_SUBMIT || -// input_i->type == DILLO_HTML_INPUT_BUTTON_RESET) { -// a_Dw_button_set_sensitive(DW_BUTTON(input_i->widget), TRUE); -// } -// } -// } - html->InFlags &= ~IN_FORM; html->InFlags &= ~IN_SELECT; html->InFlags &= ~IN_OPTION; @@ -471,12 +448,10 @@ void Html_tag_open_input(DilloHtml *html, const char *tag, int tagsize) inp_type = DILLO_HTML_INPUT_SUBMIT; init_str = (value) ? value : dStrdup("submit"); resource = factory->createLabelButtonResource(init_str); -// gtk_widget_set_sensitive(widget, FALSE); /* Until end of FORM! */ } else if (!dStrAsciiCasecmp(type, "reset")) { inp_type = DILLO_HTML_INPUT_RESET; init_str = (value) ? value : dStrdup("Reset"); resource = factory->createLabelButtonResource(init_str); -// gtk_widget_set_sensitive(widget, FALSE); /* Until end of FORM! */ } else if (!dStrAsciiCasecmp(type, "image")) { if (URL_FLAGS(html->base_url) & URL_SpamSafe) { /* Don't request the image; make a text submit button instead */ @@ -485,7 +460,6 @@ void Html_tag_open_input(DilloHtml *html, const char *tag, int tagsize) label = attrbuf ? attrbuf : value ? value : name ? name : "Submit"; init_str = dStrdup(label); resource = factory->createLabelButtonResource(init_str); -// gtk_widget_set_sensitive(widget, FALSE); /* Until end of FORM! */ } else { inp_type = DILLO_HTML_INPUT_IMAGE; /* use a dw_image widget */ @@ -1942,7 +1916,6 @@ static Embed *Html_input_image(DilloHtml *html, const char *tag, int tagsize) factory->createComplexButtonResource(IM2DW(Image), false); button = new Embed(complex_b_r); HT2TB(html)->addWidget (button, html->styleEngine->style ()); -// gtk_widget_set_sensitive(widget, FALSE); /* Until end of FORM! */ } if (!button) MSG("Html_input_image: unable to create image submit.\n"); diff --git a/src/prefs.h b/src/prefs.h index 2b0f15e4..c7a04a9a 100644 --- a/src/prefs.h +++ b/src/prefs.h @@ -23,6 +23,13 @@ extern "C" { #define PREFS_GEOMETRY_DEFAULT_XPOS -9999 #define PREFS_GEOMETRY_DEFAULT_YPOS -9999 +/* FLTK has free color indices from 16 to 31 */ +#define PREFS_UI_BUTTON_HIGHLIGHT_COLOR 16 +#define PREFS_UI_TAB_ACTIVE_BG_COLOR 17 +#define PREFS_UI_TAB_ACTIVE_FG_COLOR 18 +#define PREFS_UI_TAB_BG_COLOR 19 +#define PREFS_UI_TAB_FG_COLOR 20 + /* Panel sizes */ enum { P_tiny = 0, P_small, P_medium }; diff --git a/src/tipwin.cc b/src/tipwin.cc index b3d18f27..100eb1c0 100644 --- a/src/tipwin.cc +++ b/src/tipwin.cc @@ -174,7 +174,7 @@ CustButton::CustButton(int x, int y, int w, int h, const char *l) : TipWinButton(x,y,w,h,l) { norm_color = color(); - light_color = prefs.ui_button_highlight_color; + light_color = PREFS_UI_BUTTON_HIGHLIGHT_COLOR; } int CustButton::handle(int e) diff --git a/src/uicmd.cc b/src/uicmd.cc index be2359da..153d5fb4 100644 --- a/src/uicmd.cc +++ b/src/uicmd.cc @@ -110,7 +110,6 @@ class CustTabs : public Fl_Group { Fl_Pack *Pack; Fl_Group *Control; CustButton *CloseBtn; - int tabcolor_inactive, tabcolor_active; void update_pack_offset(void); void resize(int x, int y, int w, int h) @@ -138,8 +137,6 @@ public: Pack = NULL; focus_counter = 0; tab_w = 50, tab_h = th, ctab_h = 1, btn_w = 20, ctl_w = 1*btn_w+2; - tabcolor_active = prefs.ui_tab_active_bg_color; - tabcolor_inactive = prefs.ui_tab_bg_color; resize(0,0,ww,ctab_h); /* tab buttons go inside a pack within a scroll */ Scroll = new Fl_Scroll(0,0,ww-ctl_w,ctab_h); @@ -283,9 +280,8 @@ UI *CustTabs::add_new_tab(UI *old_ui, int focus) btn->copy_label(DEFAULT_TAB_LABEL); btn->clear_visible_focus(); btn->box(FL_GTK_THIN_UP_BOX); - btn->color(focus ? tabcolor_active : tabcolor_inactive); - btn->labelcolor(focus ? prefs.ui_tab_active_fg_color : - prefs.ui_tab_fg_color); + btn->color(focus ? PREFS_UI_TAB_ACTIVE_BG_COLOR : PREFS_UI_TAB_BG_COLOR); + btn->labelcolor(focus ? PREFS_UI_TAB_ACTIVE_FG_COLOR:PREFS_UI_TAB_FG_COLOR); btn->ui(new_ui); btn->callback(tab_btn_cb, this); Pack->add(btn); // append @@ -413,8 +409,8 @@ void CustTabs::switch_tab(CustTabButton *cbtn) // Set old tab label to normal color if ((idx = get_btn_idx(old_ui)) != -1) { btn = (CustTabButton*)Pack->child(idx); - btn->color(tabcolor_inactive); - btn->labelcolor(prefs.ui_tab_fg_color); + btn->color(PREFS_UI_TAB_BG_COLOR); + btn->labelcolor(PREFS_UI_TAB_FG_COLOR); btn->redraw(); } /* We make a point of calling show() before value() is changed because @@ -428,8 +424,8 @@ void CustTabs::switch_tab(CustTabButton *cbtn) */ cbtn->ui()->show(); Wizard->value(cbtn->ui()); - cbtn->color(tabcolor_active); - cbtn->labelcolor(prefs.ui_tab_active_fg_color); + cbtn->color(PREFS_UI_TAB_ACTIVE_BG_COLOR); + cbtn->labelcolor(PREFS_UI_TAB_ACTIVE_FG_COLOR); cbtn->redraw(); update_pack_offset(); diff --git a/test/Makefile.am b/test/Makefile.am index 53e3d4ed..db7b65b9 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -20,6 +20,7 @@ noinst_PROGRAMS = \ dw-imgbuf-mem-test \ dw-resource-test \ dw-ui-test \ + containers \ shapes \ cookies \ liang \ @@ -164,6 +165,9 @@ shapes_LDADD = \ $(top_builddir)/dw/libDw-core.a \ $(top_builddir)/lout/liblout.a +containers_SOURCES = containers.cc +containers_LDADD = $(top_builddir)/lout/liblout.a + cookies_SOURCES = cookies.c cookies_LDADD = \ $(top_builddir)/dpip/libDpip.a \ diff --git a/test/containers.cc b/test/containers.cc new file mode 100644 index 00000000..646624aa --- /dev/null +++ b/test/containers.cc @@ -0,0 +1,53 @@ +#include "../lout/object.hh" +#include "../lout/container.hh" + +using namespace lout::object; +using namespace lout::container::typed; + +void testHashSet () +{ + HashSet<String> h(true); + + h.put (new String ("one")); + h.put (new String ("two")); + h.put (new String ("three")); + + Iterator<String> it = h.iterator (); + while (it.hasNext ()) { + String *o = it.getNext (); + printf ("%s\n", o->chars()); + } +} + +void testHashTable () +{ + HashTable<String, Integer> h(true, true); + + h.put (new String ("one"), new Integer (1)); + h.put (new String ("two"), new Integer (2)); + h.put (new String ("three"), new Integer (3)); + + for (Iterator<String> it = h.iterator (); it.hasNext (); ) { + String *k = it.getNext (); + Integer *v = h.get (k); + printf ("%s -> %d\n", k->chars(), v->getValue()); + } + + h.put (new String ("one"), new Integer (4)); + h.put (new String ("two"), new Integer (5)); + h.put (new String ("three"), new Integer (6)); + + for (Iterator<String> it = h.iterator (); it.hasNext (); ) { + String *k = it.getNext (); + Integer *v = h.get (k); + printf ("%s -> %d\n", k->chars(), v->getValue()); + } +} + +int main (int argc, char *argv[]) +{ + testHashSet (); + testHashTable (); + + return 0; +} |