Codebase list dillo / 4171ddb
Merge branch 'upstream' Axel Beckert 12 years ago
11 changed file(s) with 128 addition(s) and 18 deletion(s). Raw diff Collapse all Expand all
108108 # home="file:/home/jcid/HomePage/Home.html"
109109 #home="http://www.dillo.org/"
110110
111 # Set the URL used by the web search dialog.
111 # Set the URLs used by the web search dialog.
112112 # "%s" is replaced with the search keywords separated by '+'.
113 # search_url="http://www.wikipedia.org/wiki/Special:Search?search=%s"
114 # search_url="http://search.lycos.com/?query=%s"
115 # search_url="http://duckduckgo.com/html?q=%s"
113 # Format: search_url="[<label> ]<url>"
114 # You can have several search engines, with the first being the default.
115 # e.g.
116 # search_url="DuckDuckGo http://duckduckgo.com/html?q=%s"
117 # search_url="Wikipedia http://www.wikipedia.org/wiki/Special:Search?search=%s"
118 # search_url="Lycos http://search.lycos.com/?query=%s"
116119 #search_url="http://www.google.com/search?ie=UTF-8&oe=UTF-8&q=%s"
117120
118121 # If set, dillo will ask web servers to send pages in this language.
122122 font = family->get (fa);
123123
124124 fl_font(font, size);
125 spaceWidth = misc::max(0, (int)fl_width(' ') + letterSpacing);
125 /* WORKAROUND: fl_width(uint_t) is not working on non-xft X.
126 * Reported to FLTK as STR #2688 */
127 spaceWidth = misc::max(0, (int)fl_width(" ") + letterSpacing);
126128 int xx, xy, xw, xh;
127129 fl_text_extents("x", xx, xy, xw, xh);
128130 xHeight = xh;
158160 if (t & FL_BOLD)
159161 strstrip(name, " bold");
160162
161 MSG("Found font: %s%s%s\n", name, t & FL_BOLD ? " bold" : "",
163 _MSG("Found font: %s%s%s\n", name, t & FL_BOLD ? " bold" : "",
162164 t & FL_ITALIC ? " italic" : "");
163165
164166 object::String *familyName = new object::String(name);
538538 if (displayed() && style) {
539539 FltkFont *font = (FltkFont*)style->font;
540540 fl_font(font->font,font->size);
541 /* WORKAROUND: fl_width(uint_t) is not working on non-xft X.
542 * Reported to FLTK as STR #2688 */
541543 requisition->width =
542 (int)fl_width ('n')
544 (int)fl_width ("n")
543545 * (maxLength == UNLIMITED_MAX_LENGTH ? 10 : maxLength)
544546 + label_w + (2 * RELIEF_X_THICKNESS);
545547 requisition->ascent = font->ascent + RELIEF_Y_THICKNESS;
656658 if (style) {
657659 FltkFont *font = (FltkFont*)style->font;
658660 fl_font(font->font,font->size);
661 /* WORKAROUND: fl_width(uint_t) is not working on non-xft X.
662 * Reported to FLTK as STR #2688 */
659663 requisition->width =
660 (int)fl_width ('n') * numCols + 2 * RELIEF_X_THICKNESS;
664 (int)fl_width ("n") * numCols + 2 * RELIEF_X_THICKNESS;
661665 requisition->ascent =
662666 RELIEF_Y_THICKNESS + font->ascent +
663667 (font->ascent + font->descent) * (numRows - 1);
2121 #include <FL/Fl_Output.H>
2222 #include <FL/Fl_Input.H>
2323 #include <FL/Fl_Secret_Input.H>
24 #include <FL/Fl_Choice.H>
25 #include <FL/Fl_Menu_Item.H>
2426
2527 #include "msg.h"
2628 #include "dialog.hh"
7476 }
7577 return Fl_Input::handle(e);
7678 }
79
80 /*
81 * Used to make the ENTER key activate the CustChoice
82 */
83 class CustChoice : public Fl_Choice {
84 public:
85 CustChoice (int x, int y, int w, int h, const char* l=0) :
86 Fl_Choice(x,y,w,h,l) {};
87 int handle(int e) {
88 if (e == FL_KEYBOARD &&
89 (Fl::event_key() == FL_Enter || Fl::event_key() == FL_Down) &&
90 (Fl::event_state() & (FL_SHIFT|FL_CTRL|FL_ALT|FL_META)) == 0) {
91 MSG("CustChoice: ENTER\n");
92 return Fl_Choice::handle(FL_PUSH);
93 }
94 return Fl_Choice::handle(e);
95 };
96 };
97
7798 //----------------------------------------------------------------------------
7899
79100
103124 */
104125 const char *a_Dialog_input(const char *msg)
105126 {
127 static Fl_Menu_Item *pm = 0;
106128 int ww = 450, wh = 130, gap = 10, ih = 60, bw = 80, bh = 30;
107129
108130 input_answer = 0;
133155 c_inp->labelsize(14);
134156 c_inp->textsize(14);
135157
158 CustChoice *ch = new CustChoice(1*gap,ih+3*gap,180,24);
159 if (!pm) {
160 int n_it = dList_length(prefs.search_urls);
161 pm = new Fl_Menu_Item[n_it+1];
162 memset(pm, '\0', sizeof(Fl_Menu_Item[n_it+1]));
163 for (int i = 0, j = 0; i < n_it; i++) {
164 char *label, *url, *source;
165 source = (char *)dList_nth_data(prefs.search_urls, i);
166 if (a_Misc_parse_search_url(source, &label, &url) < 0)
167 continue;
168 pm[j++].label(FL_NORMAL_LABEL, strdup(label));
169 }
170 }
171 ch->tooltip("Select search engine");
172 ch->menu(pm);
173 ch->value(prefs.search_url_idx);
174 ch->textcolor(FL_DARK_BLUE);
175
136176 int xpos = ww-2*(gap+bw), ypos = ih+3*gap;
137177 Fl_Return_Button *rb = new Fl_Return_Button(xpos, ypos, bw, bh, "OK");
138178 rb->align(FL_ALIGN_INSIDE|FL_ALIGN_CLIP);
155195 /* we have a string, save it */
156196 dFree(input_str);
157197 input_str = dStrdup(c_inp->value());
198 MSG("a_Dialog_input value() = %d\n", ch->value());
199 prefs.search_url_idx = ch->value();
158200 }
159201 delete window;
160202
610610
611611 /*
612612 * The textarea tag
613 * (TODO: It doesn't support wrapping).
614613 */
615614 void Html_tag_open_textarea(DilloHtml *html, const char *tag, int tagsize)
616615 {
382382 }
383383
384384 /*
385 * Parse dillorc's search_url string ("[<label> ]<url>")
386 * Return value: -1 on error, 0 on success (and label and urlstr pointers)
387 */
388 int a_Misc_parse_search_url(char *source, char **label, char **urlstr)
389 {
390 static char buf[32];
391 char *p, *q;
392 int ret = -1;
393
394 if ((p = strrchr(source, ' '))) {
395 /* label and url pair */
396 strncpy(buf,source,MIN(p-source,31));
397 buf[MIN(p-source,31)] = 0;
398 source = p+1;
399 if ((p = strchr(source, '/')) && p[1] && (q = strchr(p+2,'/'))) {
400 *urlstr = source;
401 ret = 0;
402 }
403 } else {
404 /* url only, make a custom label */
405 if ((p = strchr(source, '/')) && p[1] && (q = strchr(p+2,'/'))) {
406 strncpy(buf,p+2,MIN(q-p-2,31));
407 buf[MIN(q-p-2,31)] = 0;
408 *urlstr = source;
409 ret = 0;
410 }
411 }
412 *label = buf;
413 return ret;
414 }
415
416 /*
385417 * Encodes string using base64 encoding.
386418 * Return value: new string or NULL if input string is empty.
387419 */
1616 char **charset);
1717 int a_Misc_content_type_cmp(const char* ct1, const char *ct2);
1818 int a_Misc_parse_geometry(char *geom, int *x, int *y, int *w, int *h);
19 int a_Misc_parse_search_url(char *source, char **label, char **urlstr);
1920 char *a_Misc_encode_base64(const char *in);
2021 Dstr *a_Misc_file2dstr(const char *filename);
2122
7474 prefs.panel_size = P_medium;
7575 prefs.parse_embedded_css=TRUE;
7676 prefs.save_dir = dStrdup(PREFS_SAVE_DIR);
77 prefs.search_url = dStrdup(PREFS_SEARCH_URL);
77 prefs.search_urls = dList_new(16);
78 dList_append(prefs.search_urls, dStrdup(PREFS_SEARCH_URL));
79 dList_append(prefs.search_urls, NULL); /* flags a default search URL */
80 prefs.search_url_idx = 0;
7881 prefs.show_back = TRUE;
7982 prefs.show_bookmarks = TRUE;
8083 prefs.show_clear_url = TRUE;
103106 */
104107 void a_Prefs_freeall(void)
105108 {
109 int i;
110
106111 dFree(prefs.font_cursive);
107112 dFree(prefs.font_fantasy);
108113 dFree(prefs.font_monospace);
116121 dFree(prefs.http_user_agent);
117122 dFree(prefs.no_proxy);
118123 dFree(prefs.save_dir);
119 dFree(prefs.search_url);
124 for (i = 0; i < dList_length(prefs.search_urls); ++i)
125 dFree(dList_nth_data(prefs.search_urls, i));
126 dList_free(prefs.search_urls);
120127 a_Url_free(prefs.start_page);
121128 }
8484 bool_t enterpress_forces_submit;
8585 bool_t middle_click_opens_new_tab;
8686 bool_t right_click_closes_tab;
87 char *search_url;
87 bool_t search_url_idx;
88 Dlist *search_urls;
8889 char *save_dir;
8990 bool_t show_msg;
9091 bool_t show_extra_warnings;
2323 PREFS_BOOL,
2424 PREFS_COLOR,
2525 PREFS_STRING,
26 PREFS_STRINGS,
2627 PREFS_URL,
2728 PREFS_INT32,
2829 PREFS_DOUBLE,
8586 { "panel_size", &prefs.panel_size, PREFS_PANEL_SIZE },
8687 { "parse_embedded_css", &prefs.parse_embedded_css, PREFS_BOOL },
8788 { "save_dir", &prefs.save_dir, PREFS_STRING },
88 { "search_url", &prefs.search_url, PREFS_STRING },
89 { "search_url", &prefs.search_urls, PREFS_STRINGS },
8990 { "show_back", &prefs.show_back, PREFS_BOOL },
9091 { "show_bookmarks", &prefs.show_bookmarks, PREFS_BOOL },
9192 { "show_clear_url", &prefs.show_clear_url, PREFS_BOOL },
133134 dFree(*(char **)node->pref);
134135 *(char **)node->pref = dStrdup(value);
135136 break;
137 case PREFS_STRINGS:
138 {
139 Dlist *lp = *(Dlist **)node->pref;
140 if (dList_length(lp) == 2 && !dList_nth_data(lp, 1)) {
141 /* override the default */
142 void *data = dList_nth_data(lp, 0);
143 dList_remove(lp, data);
144 dList_remove(lp, NULL);
145 dFree(data);
146 }
147 dList_append(lp, dStrdup(value));
148 break;
149 }
136150 case PREFS_URL:
137151 a_Url_free(*(DilloUrl **)node->pref);
138152 *(DilloUrl **)node->pref = a_Url_new(value, NULL);
3535 #include "history.h"
3636 #include "msg.h"
3737 #include "prefs.h"
38 #include "misc.h"
3839
3940 #include "dw/fltkviewport.hh"
4041
773774
774775 /*
775776 * Returns a newly allocated string holding a search url generated from
776 * a string of keywords (separarated by blanks) and prefs.search_url.
777 * a string of keywords (separated by blanks) and the current search_url.
777778 * The search string is urlencoded.
778779 */
779780 static char *UIcmd_make_search_str(const char *str)
780781 {
781 char *keys = a_Url_encode_hex_str(str), *c = prefs.search_url;
782 char *search_url, *l, *u, *c;
783 char *keys = a_Url_encode_hex_str(str),
784 *src = (char*)dList_nth_data(prefs.search_urls, prefs.search_url_idx);
782785 Dstr *ds = dStr_sized_new(128);
783 char *search_url;
784
785 for (; *c; c++) {
786
787 /* parse search_url into label and url */
788 a_Misc_parse_search_url(src, &l, &u);
789
790 for (c = u; *c; c++) {
786791 if (*c == '%')
787792 switch(*++c) {
788793 case 's':