Merge branch 'upstream'
Axel Beckert
12 years ago
108 | 108 | # home="file:/home/jcid/HomePage/Home.html" |
109 | 109 | #home="http://www.dillo.org/" |
110 | 110 | |
111 | # Set the URL used by the web search dialog. | |
111 | # Set the URLs used by the web search dialog. | |
112 | 112 | # "%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" | |
116 | 119 | #search_url="http://www.google.com/search?ie=UTF-8&oe=UTF-8&q=%s" |
117 | 120 | |
118 | 121 | # If set, dillo will ask web servers to send pages in this language. |
122 | 122 | font = family->get (fa); |
123 | 123 | |
124 | 124 | 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); | |
126 | 128 | int xx, xy, xw, xh; |
127 | 129 | fl_text_extents("x", xx, xy, xw, xh); |
128 | 130 | xHeight = xh; |
158 | 160 | if (t & FL_BOLD) |
159 | 161 | strstrip(name, " bold"); |
160 | 162 | |
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" : "", | |
162 | 164 | t & FL_ITALIC ? " italic" : ""); |
163 | 165 | |
164 | 166 | object::String *familyName = new object::String(name); |
538 | 538 | if (displayed() && style) { |
539 | 539 | FltkFont *font = (FltkFont*)style->font; |
540 | 540 | 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 */ | |
541 | 543 | requisition->width = |
542 | (int)fl_width ('n') | |
544 | (int)fl_width ("n") | |
543 | 545 | * (maxLength == UNLIMITED_MAX_LENGTH ? 10 : maxLength) |
544 | 546 | + label_w + (2 * RELIEF_X_THICKNESS); |
545 | 547 | requisition->ascent = font->ascent + RELIEF_Y_THICKNESS; |
656 | 658 | if (style) { |
657 | 659 | FltkFont *font = (FltkFont*)style->font; |
658 | 660 | 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 */ | |
659 | 663 | requisition->width = |
660 | (int)fl_width ('n') * numCols + 2 * RELIEF_X_THICKNESS; | |
664 | (int)fl_width ("n") * numCols + 2 * RELIEF_X_THICKNESS; | |
661 | 665 | requisition->ascent = |
662 | 666 | RELIEF_Y_THICKNESS + font->ascent + |
663 | 667 | (font->ascent + font->descent) * (numRows - 1); |
21 | 21 | #include <FL/Fl_Output.H> |
22 | 22 | #include <FL/Fl_Input.H> |
23 | 23 | #include <FL/Fl_Secret_Input.H> |
24 | #include <FL/Fl_Choice.H> | |
25 | #include <FL/Fl_Menu_Item.H> | |
24 | 26 | |
25 | 27 | #include "msg.h" |
26 | 28 | #include "dialog.hh" |
74 | 76 | } |
75 | 77 | return Fl_Input::handle(e); |
76 | 78 | } |
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 | ||
77 | 98 | //---------------------------------------------------------------------------- |
78 | 99 | |
79 | 100 | |
103 | 124 | */ |
104 | 125 | const char *a_Dialog_input(const char *msg) |
105 | 126 | { |
127 | static Fl_Menu_Item *pm = 0; | |
106 | 128 | int ww = 450, wh = 130, gap = 10, ih = 60, bw = 80, bh = 30; |
107 | 129 | |
108 | 130 | input_answer = 0; |
133 | 155 | c_inp->labelsize(14); |
134 | 156 | c_inp->textsize(14); |
135 | 157 | |
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 | ||
136 | 176 | int xpos = ww-2*(gap+bw), ypos = ih+3*gap; |
137 | 177 | Fl_Return_Button *rb = new Fl_Return_Button(xpos, ypos, bw, bh, "OK"); |
138 | 178 | rb->align(FL_ALIGN_INSIDE|FL_ALIGN_CLIP); |
155 | 195 | /* we have a string, save it */ |
156 | 196 | dFree(input_str); |
157 | 197 | input_str = dStrdup(c_inp->value()); |
198 | MSG("a_Dialog_input value() = %d\n", ch->value()); | |
199 | prefs.search_url_idx = ch->value(); | |
158 | 200 | } |
159 | 201 | delete window; |
160 | 202 |
610 | 610 | |
611 | 611 | /* |
612 | 612 | * The textarea tag |
613 | * (TODO: It doesn't support wrapping). | |
614 | 613 | */ |
615 | 614 | void Html_tag_open_textarea(DilloHtml *html, const char *tag, int tagsize) |
616 | 615 | { |
382 | 382 | } |
383 | 383 | |
384 | 384 | /* |
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 | /* | |
385 | 417 | * Encodes string using base64 encoding. |
386 | 418 | * Return value: new string or NULL if input string is empty. |
387 | 419 | */ |
16 | 16 | char **charset); |
17 | 17 | int a_Misc_content_type_cmp(const char* ct1, const char *ct2); |
18 | 18 | 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); | |
19 | 20 | char *a_Misc_encode_base64(const char *in); |
20 | 21 | Dstr *a_Misc_file2dstr(const char *filename); |
21 | 22 |
74 | 74 | prefs.panel_size = P_medium; |
75 | 75 | prefs.parse_embedded_css=TRUE; |
76 | 76 | 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; | |
78 | 81 | prefs.show_back = TRUE; |
79 | 82 | prefs.show_bookmarks = TRUE; |
80 | 83 | prefs.show_clear_url = TRUE; |
103 | 106 | */ |
104 | 107 | void a_Prefs_freeall(void) |
105 | 108 | { |
109 | int i; | |
110 | ||
106 | 111 | dFree(prefs.font_cursive); |
107 | 112 | dFree(prefs.font_fantasy); |
108 | 113 | dFree(prefs.font_monospace); |
116 | 121 | dFree(prefs.http_user_agent); |
117 | 122 | dFree(prefs.no_proxy); |
118 | 123 | 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); | |
120 | 127 | a_Url_free(prefs.start_page); |
121 | 128 | } |
84 | 84 | bool_t enterpress_forces_submit; |
85 | 85 | bool_t middle_click_opens_new_tab; |
86 | 86 | bool_t right_click_closes_tab; |
87 | char *search_url; | |
87 | bool_t search_url_idx; | |
88 | Dlist *search_urls; | |
88 | 89 | char *save_dir; |
89 | 90 | bool_t show_msg; |
90 | 91 | bool_t show_extra_warnings; |
23 | 23 | PREFS_BOOL, |
24 | 24 | PREFS_COLOR, |
25 | 25 | PREFS_STRING, |
26 | PREFS_STRINGS, | |
26 | 27 | PREFS_URL, |
27 | 28 | PREFS_INT32, |
28 | 29 | PREFS_DOUBLE, |
85 | 86 | { "panel_size", &prefs.panel_size, PREFS_PANEL_SIZE }, |
86 | 87 | { "parse_embedded_css", &prefs.parse_embedded_css, PREFS_BOOL }, |
87 | 88 | { "save_dir", &prefs.save_dir, PREFS_STRING }, |
88 | { "search_url", &prefs.search_url, PREFS_STRING }, | |
89 | { "search_url", &prefs.search_urls, PREFS_STRINGS }, | |
89 | 90 | { "show_back", &prefs.show_back, PREFS_BOOL }, |
90 | 91 | { "show_bookmarks", &prefs.show_bookmarks, PREFS_BOOL }, |
91 | 92 | { "show_clear_url", &prefs.show_clear_url, PREFS_BOOL }, |
133 | 134 | dFree(*(char **)node->pref); |
134 | 135 | *(char **)node->pref = dStrdup(value); |
135 | 136 | 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 | } | |
136 | 150 | case PREFS_URL: |
137 | 151 | a_Url_free(*(DilloUrl **)node->pref); |
138 | 152 | *(DilloUrl **)node->pref = a_Url_new(value, NULL); |
35 | 35 | #include "history.h" |
36 | 36 | #include "msg.h" |
37 | 37 | #include "prefs.h" |
38 | #include "misc.h" | |
38 | 39 | |
39 | 40 | #include "dw/fltkviewport.hh" |
40 | 41 | |
773 | 774 | |
774 | 775 | /* |
775 | 776 | * 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. | |
777 | 778 | * The search string is urlencoded. |
778 | 779 | */ |
779 | 780 | static char *UIcmd_make_search_str(const char *str) |
780 | 781 | { |
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); | |
782 | 785 | 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++) { | |
786 | 791 | if (*c == '%') |
787 | 792 | switch(*++c) { |
788 | 793 | case 's': |