diff options
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | dpi/file.c | 92 | ||||
-rw-r--r-- | dw/style.cc | 8 | ||||
-rw-r--r-- | src/IO/about.c | 75 | ||||
-rw-r--r-- | src/IO/http.c | 3 | ||||
-rw-r--r-- | src/auth.c | 11 | ||||
-rw-r--r-- | src/auth.h | 2 | ||||
-rw-r--r-- | src/dicache.c | 18 | ||||
-rw-r--r-- | src/dicache.h | 3 | ||||
-rw-r--r-- | src/dillo.cc | 233 | ||||
-rw-r--r-- | src/form.cc | 19 | ||||
-rw-r--r-- | src/form.hh | 3 | ||||
-rw-r--r-- | src/html.cc | 39 | ||||
-rw-r--r-- | src/html.hh | 2 | ||||
-rw-r--r-- | src/image.cc | 3 | ||||
-rw-r--r-- | src/image.hh | 1 | ||||
-rw-r--r-- | src/menu.cc | 65 | ||||
-rw-r--r-- | src/menu.hh | 2 | ||||
-rw-r--r-- | src/nav.c | 7 | ||||
-rw-r--r-- | src/png.c | 138 | ||||
-rw-r--r-- | src/prefs.c | 4 | ||||
-rw-r--r-- | src/prefs.h | 5 | ||||
-rw-r--r-- | src/ui.cc | 3 | ||||
-rw-r--r-- | src/uicmd.cc | 8 | ||||
-rw-r--r-- | src/uicmd.hh | 1 |
25 files changed, 518 insertions, 231 deletions
@@ -20,6 +20,9 @@ dillo-2.1 - Set middle click to submit in a new TAB. (Helps to keep form data!) - Added support for the Q element. BUG#343 - Cleaned up Html_pop_tag(). + - Ported the command line interface from dillo1 (XID not working yet). + - Switched file dpi error messages to HTML. + - Added a popup menu to form's submit button. Patches: place (AKA corvid) +- Switched SSL-enabled to configure.in (./configure --enable-ssl). - Standardised the installation of dpid/dpidrc with auto* tools. @@ -43,6 +46,7 @@ dillo-2.1 ? Trying a new iconv() test in configure.in. - Allowed the rc parser to skip whitespace around the equal sign. - Fixed the parser not to call Html_tag_close_* functions twice. +!- Started code cleanup of the image code mainly in dicache.c. Patches: Jorge Arellano Cid dw @@ -47,12 +47,6 @@ #define MAXNAMESIZE 30 #define HIDE_DOTFILES TRUE -enum { - FILE_OK, - FILE_NOT_FOUND, - FILE_NO_ACCESS -}; - typedef struct { char *full_path; const char *filename; @@ -408,7 +402,9 @@ static void File_transfer_dir(ClientInfo *Client, Hdirname = Escape_html_str(Ddir->dirname); sock_handler_printf(Client->sh, 0, - "Content-Type: text/html\n\n" + "HTTP/1.1 200 OK\r\n" + "Content-Type: text/html\r\n" + "\r\n" "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'>\n" "<HTML>\n<HEAD>\n <BASE href='file:%s'>\n" " <TITLE>file:%s</TITLE>\n</HEAD>\n" @@ -522,6 +518,43 @@ static const char *File_content_type(const char *filename) } /* + * Send an error page + */ +static void File_send_error_page(ClientInfo *Client, int res, + const char *orig_url) +{ + const char *status; + const char *body; + char *d_cmd; + + switch (res) { + case EACCES: + status = "403 Forbidden"; + break; + case ENOENT: + status = "404 Not Found"; + break; + default: + /* good enough */ + status = "500 Internal Server Error"; + } + + body = status; /* it's simple */ + + /* Send DPI command */ + d_cmd = a_Dpip_build_cmd("cmd=%s url=%s", "start_send_page", orig_url); + sock_handler_write_str(Client->sh, 1, d_cmd); + dFree(d_cmd); + + sock_handler_printf(Client->sh, 0, "HTTP/1.1 %s\r\n" + "Content-Type: text/plain\r\n" + "Content-Length: %ld\r\n" + "\r\n" + "%s", + status, strlen(body), body); +} + +/* * Try to stat the file and determine if it's readable. */ static void File_get(ClientInfo *Client, const char *filename, @@ -529,12 +562,10 @@ static void File_get(ClientInfo *Client, const char *filename, { int res; struct stat sb; - char *d_cmd; - Dstr *ds = NULL; if (stat(filename, &sb) != 0) { /* stat failed, prepare a file-not-found error. */ - res = FILE_NOT_FOUND; + res = ENOENT; } else if (S_ISDIR(sb.st_mode)) { /* set up for reading directory */ res = File_get_dir(Client, filename, orig_url); @@ -542,21 +573,8 @@ static void File_get(ClientInfo *Client, const char *filename, /* set up for reading a file */ res = File_get_file(Client, filename, &sb, orig_url); } - - if (res == FILE_NOT_FOUND) { - ds = dStr_sized_new(128); - dStr_sprintf(ds, "%s Not Found: %s", - S_ISDIR(sb.st_mode) ? "Directory" : "File", filename); - } else if (res == FILE_NO_ACCESS) { - ds = dStr_sized_new(128); - dStr_sprintf(ds, "Access denied to %s: %s", - S_ISDIR(sb.st_mode) ? "Directory" : "File", filename); - } - if (ds) { - d_cmd = a_Dpip_build_cmd("cmd=%s msg=%s","send_status_message",ds->str); - sock_handler_write_str(Client->sh, 1, d_cmd); - dFree(d_cmd); - dStr_free(ds, 1); + if (res != 0) { + File_send_error_page(Client, res, orig_url); } } @@ -580,13 +598,13 @@ static int File_get_dir(ClientInfo *Client, if (Ddir) { File_transfer_dir(Client, Ddir, orig_url); File_dillodir_free(Ddir); - return FILE_OK; + return 0; } else - return FILE_NO_ACCESS; + return EACCES; } /* - * Send the MIME content/type and then send the file itself. + * Send HTTP headers and then send the file itself. */ static int File_get_file(ClientInfo *Client, const char *filename, @@ -602,7 +620,7 @@ static int File_get_file(ClientInfo *Client, bool_t gzipped = FALSE; if ((fd = open(filename, O_RDONLY | O_NONBLOCK)) < 0) - return FILE_NO_ACCESS; + return errno; /* Send DPI command */ d_cmd = a_Dpip_build_cmd("cmd=%s url=%s", "start_send_page", orig_url); @@ -626,15 +644,18 @@ static int File_get_file(ClientInfo *Client, dFree(name); /* Send HTTP headers */ + sock_handler_write_str(Client->sh, 0, "HTTP/1.1 200 OK\r\n"); if (gzipped) { - sock_handler_write_str(Client->sh, 0, "Content-Encoding: gzip\n"); + sock_handler_write_str(Client->sh, 0, "Content-Encoding: gzip\r\n"); } if (!gzipped || strcmp(ct, unknown_type)) { - sock_handler_printf(Client->sh, 0, "Content-Type: %s\n", ct); + sock_handler_printf(Client->sh, 0, "Content-Type: %s\r\n", ct); } else { /* If we don't know type for gzipped data, let dillo figure it out. */ } - sock_handler_printf(Client->sh, 0, "Content-Length: %ld\n\n", sb->st_size); + sock_handler_printf(Client->sh, 0, "Content-Length: %ld\r\n" + "\r\n", + sb->st_size); /* Send body -- raw file contents */ do { @@ -657,11 +678,12 @@ static int File_get_file(ClientInfo *Client, } File_close(fd); - return FILE_OK; + + return 0; } /* - * Given an hex octet (e3, 2F, 20), return the corresponding + * Given a hex octet (e3, 2F, 20), return the corresponding * character if the octet is valid, and -1 otherwise */ static int File_parse_hex_octet(const char *s) @@ -729,7 +751,7 @@ static char *File_normalize_path(const char *orig) } /* - * Set the style flag and ask for a reload, so it shows inmediatly. + * Set the style flag and ask for a reload, so it shows immediately. */ static void File_toggle_html_style(ClientInfo *Client) { diff --git a/dw/style.cc b/dw/style.cc index 3faf1399..106f2592 100644 --- a/dw/style.cc +++ b/dw/style.cc @@ -560,10 +560,10 @@ void drawBackground (View *view, Rectangle *area, // ---------------------------------------------------------------------- static const char - *roman_I0[] = { "","I","II","III","IV","V","VI","VII","VIII","IX" }, - *roman_I1[] = { "","X","XX","XXX","XL","L","LX","LXX","LXXX","XC" }, - *roman_I2[] = { "","C","CC","CCC","CD","D","DC","DCC","DCCC","CM" }, - *roman_I3[] = { "","M","MM","MMM","MMMM" }; + *const roman_I0[] = { "","I","II","III","IV","V","VI","VII","VIII","IX" }, + *const roman_I1[] = { "","X","XX","XXX","XL","L","LX","LXX","LXXX","XC" }, + *const roman_I2[] = { "","C","CC","CCC","CD","D","DC","DCC","DCCC","CM" }, + *const roman_I3[] = { "","M","MM","MMM","MMMM" }; void strtolower (char *s) { diff --git a/src/IO/about.c b/src/IO/about.c index 4cd5e2c1..03d5057c 100644 --- a/src/IO/about.c +++ b/src/IO/about.c @@ -14,7 +14,7 @@ /* * HTML text for startup screen */ -const char *AboutSplash= +const char *const AboutSplash= "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'>\n" "<html>\n" "<head>\n" @@ -75,7 +75,7 @@ const char *AboutSplash= " <tr>\n" " <td> \n" " <td>\n" -" <a href='http://cvs.auriga.wearlab.de/cgi-bin/cvsweb.cgi/dillo2/ChangeLog?rev=HEAD;cvsroot=dillo'>\n" +" <a href='http://freehg.org/u/dillo/main/file/tip/ChangeLog'>\n" " ChangeLog</a>\n" " <tr>\n" " <td> \n" @@ -240,22 +240,14 @@ const char *AboutSplash= "<tr>\n" " <td bgcolor='#CCCCCC'>\n" " <h4>Release overview</h4>\n" -" October 14, 2008\n" +" ??, 2009\n" "<tr>\n" " <td bgcolor='#FFFFFF'>\n" " <table border='0' cellspacing='0' cellpadding='5'>\n" " <tr>\n" " <td>\n" "<p>\n" -"This is a rewrite of dillo, using FLTK2, that comes\n" -"with lots of improvements and fixes.\n" -"<p>\n" -"Our users will surely enjoy this new release as it will give them\n" -"the same things they're accustomed plus tabbed browsing,\n" -"antialiasing, different\n" -"character sets, accepting compressed pages, control over image\n" -"loading, smaller footprint, fewer dependencies, better table\n" -"rendering, bugfixes, improved GUI, ... In brief, a better dillo.\n" +"[...]\n" "<p>\n" "Remember that dillo project uses a release model where every new\n" "browser shall be better than the former.\n" @@ -272,69 +264,20 @@ const char *AboutSplash= " <td bgcolor='#CCCCCC'>\n" " <h4>ChangeLog highlights</h4>\n" " (Extracted from the\n" -" <a href='http://cvs.auriga.wearlab.de/cgi-bin/cvsweb.cgi/dillo2/ChangeLog?rev=HEAD;cvsroot=dillo'>full\n" +" <a href='http://freehg.org/u/dillo/main/file/tip/ChangeLog'>full\n" " ChangeLog</a>)\n" "<tr>\n" " <td bgcolor='#FFFFFF'>\n" " <table border='0' cellspacing='0' cellpadding='5'>\n" " <tr>\n" " <td>\n" +"Dillo:<br>\n" "<ul>\n" -"<li>Ported Dillo from GTK1 to FLTK2." -"<li>Ported a susbstantial part of the code from C to C++ (FLTK2 is in C++)." -"<li>Wrote a new library: Dlib. With 'Dlib' Dillo doesn't need glib anymore." -"<li>Ported all the code to Dlib." -"<li>Made Dillo's UI Control Panel resizable on-the-fly." -"<li>Implemented a new, simpler, dillorc parser." -"<li>Reimplemented the Concomitant Callback chains into a uniform scheme!" -"<li>Removed threads from IO. Now it only uses select-based watches." -"<li>Simplified http.c by reusing the new non-blocking writes in IO." -"<li>Implemented Stop button to not only stop rendering but also networking." -"<li>Bound Ctrl+Space to toggle fullscreen mode." -"<li>Added a http_referer preference. See details in dillorc." -"<li>CCC: added reentrancy control to the OpEnd and OpAbort operations." -"<li>CCC: enhanced the debug function and implemented OpAbort for dpi." -"<li>Hooked a decoder for text/plain with charset." -"<li>Forbid dpi GET and POST from non dpi-generated urls." -"<li>Implemented tabbed browsing." -"<li>Added a image-loading toggle button to the UI." -"<li>Added line numbers and enabled wrapping in the 'View Source' window." -"<li>Added HTTP-1.1's chunked transfer support!" -"<li>Made the stop button sensitive when loading an image." -"<li>Added support for 'charset' in the HTTP header field for Content-Type." -"<li>Added support for 'charset' in the META element." -"<li>Added the multipart/form-data encoding method to form submission." -"<li>Made zlib a configure requirement, and cleaned up configure.in." -"<li>Enabled the file dpi to look inside gzipped files." -"<li>Added code for optional image loading (nice interface)!" -"<li>Fixed data guesser to detect ASCII, LATIN1, UTF8, KOI8-R, CP-1251 as" -" text." -"<li>Fixed void to int conversions for 64bit-arch." -"<li>Set the url resolver to escape illegal chars instead of stripping." -"<li>Big html.cc cleanup. New classes, form API, source split." -"<li>Added int32_t, EAI_NODATA and iconv tests for FreeBSD." -"<li>Replaced the findtext dialog with an in-window widget!" +"<li>[...]" "</ul>\n" -"Dw2:<br>\n" +"Dw:<br>\n" "<ul>\n" -"<li>Enabled clipped redraws (avoids some flickering)." -"<li>Added combination of drawing rectangles into a larger one." -"<li>Made getWidgetAtPoint() a virtual method of widget and implemented a" -" custom one for TextBlock, reducing CPU usage on pages full of links." -"<li>Set FltkViewBase::draw to intersect with view area for expose." -"<li>Added double buffering for partial redraws!" -"<li>Reduced memory usage in 30% by reusing styles, reducing the size" -" of struct Content, and not preallocating in SimpleVector. !" -"<li>Moved highlighting information from struct Word into Textblock" -" to save memory." -"<li>Reduced memory usage 10% with a custom memory handler in Textblock." -"<li>Implemented selection of multibyte glyphs (UTF-8)." -"<li>Fixed a slithery BUG in lout::misc::Stringbuffer." -"<li>Added 'enter' and 'leave' signals into class Resource." -"<li>Enabled mouse wheel scrolling." -"<li>Added setDeleteCallback(DW_Callback_t func, void *data) to widget." -" This allows to hook a callback when the widget is destroyed." -"<li>Changed the table-apportion algorithms + bug fixes. Big work!" +"<li>[...]" "</ul>\n" " </table>\n" "</table>\n" diff --git a/src/IO/http.c b/src/IO/http.c index 9deb961a..328a8601 100644 --- a/src/IO/http.c +++ b/src/IO/http.c @@ -197,7 +197,8 @@ Dstr *Http_make_content_type(const DilloUrl *url) */ Dstr *a_Http_make_query_str(const DilloUrl *url, bool_t use_proxy) { - char *ptr, *cookies, *auth, *referer; + const char *auth; + char *ptr, *cookies, *referer; Dstr *query = dStr_new(""), *full_path = dStr_new(""), *proxy_auth = dStr_new(""); @@ -295,21 +295,20 @@ static AuthRealm_t *Auth_realm_by_path(const AuthHost_t *host, int i, j; int match_length; + match_length = 0; realm_best = NULL; for (i = 0; (realm = dList_nth_data(host->realms, i)); i++) { char *realm_path; for (j = 0; (realm_path = dList_nth_data(realm->paths, j)); j++) { - int realm_path_length; - - realm_path_length = strlen(realm_path); + int realm_path_length = strlen(realm_path); if (Auth_path_is_inside(path, realm_path, realm_path_length) && !(realm_best && match_length >= realm_path_length)) { realm_best = realm; match_length = realm_path_length; } - } /* for (j = 0; (path = ... */ - } /* for (i = 0; (realm = ... */ + } + } return realm_best; } @@ -353,7 +352,7 @@ static void Auth_realm_add_path(AuthRealm_t *realm, const char *path) /* * Return the authorization header for an HTTP query. */ -char *a_Auth_get_auth_str(const DilloUrl *url) +const char *a_Auth_get_auth_str(const DilloUrl *url) { AuthHost_t *host; AuthRealm_t *realm; @@ -8,7 +8,7 @@ extern "C" { #include "url.h" -char *a_Auth_get_auth_str(const DilloUrl *request_url); +const char *a_Auth_get_auth_str(const DilloUrl *request_url); int a_Auth_do_auth(Dlist *auth_string, const DilloUrl *url); void a_Auth_init(void); diff --git a/src/dicache.c b/src/dicache.c index 97ed1915..fb1a0c8c 100644 --- a/src/dicache.c +++ b/src/dicache.c @@ -33,9 +33,9 @@ struct _DICacheNode { */ static Dlist *CachedIMGs = NULL; -static int dicache_size_total; /* invariant: dicache_size_total is - * the sum of the image sizes (3*w*h) - * of all the images in the dicache. */ +static uint_t dicache_size_total; /* invariant: dicache_size_total is + * the sum of the image sizes (3*w*h) + * of all the images in the dicache. */ /* * Compare two dicache nodes @@ -87,6 +87,7 @@ static DICacheEntry *Dicache_entry_new(void) entry->BitVec = NULL; entry->State = DIC_Empty; entry->version = 0; + entry->next = NULL; return entry; @@ -223,7 +224,6 @@ void a_Dicache_unref(const DilloUrl *Url, int version) /* * Refs the counter of a dicache entry. */ - DICacheEntry* a_Dicache_ref(const DilloUrl *Url, int version) { DICacheEntry *entry; @@ -255,7 +255,6 @@ void a_Dicache_invalidate_entry(const DilloUrl *Url) */ void a_Dicache_callback(int Op, CacheClient_t *Client) { - /* TODO: Handle Op = CA_Abort (to show what was got) --Jcid */ uint_t i; DilloWeb *Web = Client->Web; DilloImage *Image = Web->Image; @@ -294,7 +293,7 @@ void a_Dicache_callback(int Op, CacheClient_t *Client) } } } else if (Op == CA_Close || Op == CA_Abort) { - a_Image_close(Web->Image); + a_Image_close(Image); a_Bw_close_client(Web->bw, Client->Key); } } @@ -309,12 +308,13 @@ void a_Dicache_set_parms(DilloUrl *url, int version, DilloImage *Image, uint_t width, uint_t height, DilloImgType type) { DICacheEntry *DicEntry; - size_t Size = width * height * 3; dReturn_if_fail ( Image != NULL && width && height ); /* Find the DicEntry for this Image */ DicEntry = Dicache_get_entry_version(url, version); dReturn_if_fail ( DicEntry != NULL ); + /* Parameters already set? */ + dReturn_if_fail ( DicEntry->State < DIC_SetParms ); /* Initialize the DicEntry */ DicEntry->linebuf = dNew(uchar_t, width * 3); @@ -328,14 +328,14 @@ void a_Dicache_set_parms(DilloUrl *url, int version, DilloImage *Image, * Extra code is necessary in Imgbuf to be able to free it */ //a_Image_imgbuf_ref(DicEntry->v_imgbuf); - DicEntry->TotalSize = Size; + DicEntry->TotalSize = width * height * 3; DicEntry->width = width; DicEntry->height = height; DicEntry->type = type; DicEntry->BitVec = a_Bitvec_new((int)height); DicEntry->State = DIC_SetParms; - dicache_size_total += Size; + dicache_size_total += DicEntry->TotalSize; /* Allocate and initialize this image */ a_Image_set_parms(Image, DicEntry->v_imgbuf, url, version, diff --git a/src/dicache.h b/src/dicache.h index 6cbcf3a5..c78d0953 100644 --- a/src/dicache.h +++ b/src/dicache.h @@ -29,7 +29,7 @@ struct _DICacheEntry { uchar_t *cmap; /* Color map */ uchar_t *linebuf; /* Decompressed RGB buffer for one line */ void *v_imgbuf; /* Void pointer to an Imgbuf object */ - size_t TotalSize; /* Amount of memory the image takes up */ + uint_t TotalSize; /* Amount of memory the image takes up */ int Y; /* Current decoding row */ uint_t ScanNumber; /* Current decoding scan */ bitvec_t *BitVec; /* Bit vector for decoded rows */ @@ -37,7 +37,6 @@ struct _DICacheEntry { int RefCount; /* Reference Counter */ int version; /* Version number, used for different versions of the same URL image */ - DICacheEntry *next; /* Link to the next "newer" version */ }; diff --git a/src/dillo.cc b/src/dillo.cc index 10430f29..86b1ffa1 100644 --- a/src/dillo.cc +++ b/src/dillo.cc @@ -47,15 +47,135 @@ #include "cookies.h" #include "auth.h" +/* + * Command line options structure + */ +typedef enum { + DILLO_CLI_NONE = 0, + DILLO_CLI_XID = 1 << 0, + DILLO_CLI_FULLWINDOW = 1 << 1, + DILLO_CLI_HELP = 1 << 2, + DILLO_CLI_VERSION = 1 << 3, + DILLO_CLI_LOCAL = 1 << 4, + DILLO_CLI_GEOMETRY = 1 << 5, + DILLO_CLI_ERROR = 1 << 15, +} OptID; + +typedef struct { + const char *shortopt; + const char *longopt; + int opt_argc; /* positive: mandatory, negative: optional */ + OptID id; + const char *help; +} CLI_options; + +static const CLI_options Options[] = { + {"-f", "--fullwindow", 0, DILLO_CLI_FULLWINDOW, + " -f, --fullwindow Start in full window mode: hide address bar,\n" + " navigation buttons, menu, and status bar."}, + {"-g", "-geometry", 1, DILLO_CLI_GEOMETRY, + " -g, -geometry GEO Set initial window position where GEO is\n" + " WxH[{+-}X{+-}Y]"}, + {"-h", "--help", 0, DILLO_CLI_HELP, + " -h, --help Display this help text and exit."}, + {"-l", "--local", 0, DILLO_CLI_LOCAL, + " -l, --local Don't load images for these URL(s)."}, + {"-v", "--version", 0, DILLO_CLI_VERSION, + " -v, --version Display version info and exit."}, + {"-x", "--xid", 1, DILLO_CLI_XID, + " -x, --xid XID (DOES NOT WORK YET)\n" + " Open first Dillo window in an existing\n" + " GtkSocket which window ID is XID (decimal)."}, + {NULL, NULL, 0, DILLO_CLI_NONE, NULL} +}; + +/* + * Print help text generated from the options structure + */ +static void Dillo_print_help(const char *cmdname, const CLI_options *options) +{ + printf("Usage: %s [OPTION]... [--] [URL|FILE]...\n" + "Options:\n", cmdname); + while(options && options->help) { + printf("%s\n", options->help); + options++; + } + printf(" URL URL to browse.\n" + " FILE Local FILE to view.\n" + "\n"); +} + +/* + * Return the maximum number of option arguments + */ +static int Dillo_get_max_opt(const CLI_options *options) +{ + int i, max; + + for (i = 0, max = 0; options[i].shortopt; i++) + if (abs(options[i].opt_argc) > max) + max = abs(options[i].opt_argc); + return max; +} + +/* + * Get next command line option. + */ +static OptID Dillo_get_opt(const CLI_options *options, int argc, char **argv, + char **opt_argv, int *idx) +{ + typedef enum { O_SEARCH, O_FOUND, O_NOTFOUND, O_DONE } State; + OptID opt_id = DILLO_CLI_NONE; + int i = 0; + State state = O_SEARCH; + + if (*idx >= argc) { + state = O_DONE; + } else { + state = O_NOTFOUND; + for (i = 0; options[i].shortopt; i++) { + if (strcmp(options[i].shortopt, argv[*idx]) == 0 || + strcmp(options[i].longopt, argv[*idx]) == 0) { + state = O_FOUND; + ++*idx; + break; + } + } + } + if (state == O_FOUND) { + int n_arg = options[i].opt_argc; + opt_id = options[i].id; + /* Find the required/optional arguments of the option */ + for (i = 0; *idx < argc && i < abs(n_arg) && argv[*idx][0] != '-'; i++) + opt_argv[i] = argv[(*idx)++]; + opt_argv[i] = NULL; + + /* Optional arguments have opt_argc < 0 */ + if (i < n_arg) { + fprintf(stderr, "Option %s requires %d argument%s\n", + argv[*idx-i-1], n_arg, (n_arg == 1) ? "" : "s"); + opt_id = DILLO_CLI_ERROR; + } + } + if (state == O_NOTFOUND) { + if (strcmp(argv[*idx], "--") == 0) + (*idx)++; + else if (argv[*idx][0] == '-') { + fprintf(stderr, "Command line option \"%s\" not recognized.\n", + argv[*idx]); + opt_id = DILLO_CLI_ERROR; + } + } + return opt_id; +} /* * Given a command line argument, build a DilloUrl for it. */ -static DilloUrl *Dillo_make_start_url(char *str) +static DilloUrl *Dillo_make_start_url(char *str, bool local) { char *url_str, *p; DilloUrl *start_url; - int is_file = FALSE; /* Relative path to a local file? */ p = (*str == '/') ? dStrdup(str) : dStrconcat(a_Dir_get_owd(),"/",str,NULL); @@ -63,20 +183,18 @@ static DilloUrl *Dillo_make_start_url(char *str) if (access(p, F_OK) == 0) { /* absolute path may have non-URL characters */ url_str = a_Misc_escape_chars(p, "% "); - is_file = TRUE; + start_url = a_Url_new(url_str + 1, "file:/"); } else { /* Not a file, filter URL string */ url_str = a_Url_string_strip_delimiters(str); - } - dFree(p); - - if (is_file) { - start_url = a_Url_new(url_str + 1, "file:/"); - } else { start_url = a_Url_new(url_str, NULL); } + dFree(p); dFree(url_str); + if (local) + a_Url_set_flags(start_url, URL_FLAGS(start_url) | URL_SpamSafe); + return start_url; } @@ -85,11 +203,58 @@ static DilloUrl *Dillo_make_start_url(char *str) */ int main(int argc, char **argv) { + uint opt_id; + uint options_got = 0; + uint32_t xid = 0; + int idx = 1; + int xpos = D_GEOMETRY_DEFAULT_XPOS, ypos = D_GEOMETRY_DEFAULT_YPOS; + int width = D_GEOMETRY_DEFAULT_WIDTH, height = D_GEOMETRY_DEFAULT_HEIGHT; + char **opt_argv; + srand((uint_t)(time(0) ^ getpid())); // Some OSes exit dillo without this (not GNU/Linux). signal(SIGPIPE, SIG_IGN); + /* Handle command line options */ + opt_argv = dNew0(char*, Dillo_get_max_opt(Options) + 1); + while ((opt_id = Dillo_get_opt(Options, argc, argv, opt_argv, &idx))) { + options_got |= opt_id; + switch (opt_id) { + case DILLO_CLI_FULLWINDOW: + case DILLO_CLI_LOCAL: + break; + case DILLO_CLI_XID: + { + char *end; + xid = strtol(opt_argv[0], &end, 10); + if (*end) { + fprintf(stderr, "XID argument \"%s\" not valid. Must be an " + "unsigned decimal number.\n",opt_argv[0]); + return -1; + } + break; + } + case DILLO_CLI_GEOMETRY: + if (!a_Misc_parse_geometry(opt_argv[0], &xpos, &ypos,&width,&height)){ + fprintf(stderr, "geometry argument \"%s\" not valid. Must be of " + "the form WxH[{+-}X{+-}Y].\n", opt_argv[0]); + return -1; + } + break; + case DILLO_CLI_VERSION: + puts("Dillo version " VERSION); + return 0; + case DILLO_CLI_HELP: + Dillo_print_help(argv[0], Options); + return 0; + default: + Dillo_print_help(argv[0], Options); + return -1; + } + } + dFree(opt_argv); + // Initialize internal modules a_Dir_init(); a_Prefs_init(); @@ -105,12 +270,23 @@ int main(int argc, char **argv) a_Cookies_init(); a_Auth_init(); + /* command line options override preferences */ + if (options_got & DILLO_CLI_FULLWINDOW) + prefs.fullwindow_start = TRUE; + if (options_got & DILLO_CLI_GEOMETRY) { + prefs.width = width; + prefs.height = height; + prefs.xpos = xpos; + prefs.ypos = ypos; + } + // Sets WM_CLASS hint on X11 fltk::Window::xclass("dillo"); // WORKAROUND: sometimes the default pager triggers redraw storms fltk::TabGroup::default_pager(fltk::PAGER_SHRINK); + /* use preferred font for UI */ fltk::Font *dfont = fltk::font(prefs.vw_fontname, 0); if (dfont) { fltk::Widget::default_style->textfont(dfont); @@ -120,6 +296,7 @@ int main(int argc, char **argv) // Create a new UI/bw pair BrowserWindow *bw = a_UIcmd_browser_window_new(0, 0, NULL); + /* Proxy authentication */ if (prefs.http_proxyuser && !a_Http_proxy_auth()) { const char *passwd = a_UIcmd_get_passwd(prefs.http_proxyuser); if (passwd) { @@ -129,23 +306,29 @@ int main(int argc, char **argv) } } - if (argc == 2) { - DilloUrl *url = Dillo_make_start_url(argv[1]); - a_UIcmd_open_urlstr(bw, URL_STR(url)); - a_Url_free(url); - } else if (argc == 6) { - // WORKAROUND: sylpheed execs "dillo -l -f -x XID URL" - if (strcmp(argv[1], "-l") == 0 && strcmp(argv[2], "-f") == 0 && - strcmp(argv[3], "-x") == 0) { - a_UIcmd_set_images_enabled(bw, FALSE); - DilloUrl *url = Dillo_make_start_url(argv[5]); - a_Url_set_flags(url, URL_FLAGS(url) & URL_SpamSafe); - a_UIcmd_open_urlstr(bw, URL_STR(url)); - a_Url_free(url); - } - } else { - /* Send startup screen */ + /* Open URLs/files */ + const bool local = options_got & DILLO_CLI_LOCAL; + + if (idx == argc) { + /* No URLs/files on cmdline. Send startup screen */ a_Nav_push(bw, prefs.start_page); + } else { + for (int i = idx; i < argc; i++) { + DilloUrl *start_url = Dillo_make_start_url(argv[i], local); + + if (i > idx) { + if (prefs.middle_click_opens_new_tab) { + /* user must prefer tabs */ + const int focus = 0; + a_UIcmd_open_url_nt(bw, start_url, focus); + } else { + a_UIcmd_open_url_nw(bw, start_url); + } + } else { + a_Nav_push(bw, start_url); + } + a_Url_free(start_url); + } } return fltk::run(); diff --git a/src/form.cc b/src/form.cc index 339150bb..c442c017 100644 --- a/src/form.cc +++ b/src/form.cc @@ -76,7 +76,6 @@ class DilloHtmlForm { DilloHtml *html; void eventHandler(Resource *resource, EventButton *event); - void submit(DilloHtmlInput *active_input, EventButton *event); DilloUrl *buildQueryUrl(DilloHtmlInput *active_input); Dstr *buildQueryData(DilloHtmlInput *active_submit); char *makeMultipartBoundary(iconv_t char_encoder, @@ -113,6 +112,7 @@ public: ~DilloHtmlForm (); DilloHtmlInput *getInput (Resource *resource); DilloHtmlInput *getRadioInput (const char *name); + void submit(DilloHtmlInput *active_input, EventButton *event); void reset (); void addInput(DilloHtmlInput *input, DilloHtmlInputType type); }; @@ -206,6 +206,16 @@ void a_Html_input_delete (DilloHtmlInput *input) delete input; } +void a_Html_form_submit2(void *vform) +{ + ((DilloHtmlForm *)vform)->submit(NULL, NULL); +} + +void a_Html_form_reset2(void *vform) +{ + ((DilloHtmlForm *)vform)->reset(); +} + /* * Form parsing functions */ @@ -332,7 +342,7 @@ void Html_tag_open_form(DilloHtml *html, const char *tag, int tagsize) void Html_tag_close_form(DilloHtml *html, int TagIdx) { - static const char *SubmitTag = + static const char *const SubmitTag = "<input type='submit' value='?Submit?' alt='dillo-generated-button'>"; DilloHtmlForm *form; // int i; @@ -945,7 +955,7 @@ void DilloHtmlForm::eventHandler(Resource *resource, EventButton *event) { MSG("DilloHtmlForm::eventHandler\n"); if (event && (event->button == 3)) { - MSG("Form menu\n"); + a_UIcmd_form_popup(html->bw, html->page_url, this); } else { DilloHtmlInput *input = getInput(resource); if (input) { @@ -996,7 +1006,7 @@ DilloUrl *DilloHtmlForm::buildQueryUrl(DilloHtmlInput *active_input) _MSG("DilloHtmlForm::buildQueryUrl: action=%s\n",URL_STR_(action)); - if (num_submit_buttons > 0) { + if (active_input && num_submit_buttons > 0) { if ((active_input->type == DILLO_HTML_INPUT_SUBMIT) || (active_input->type == DILLO_HTML_INPUT_IMAGE) || (active_input->type == DILLO_HTML_INPUT_BUTTON_SUBMIT)) { @@ -1727,6 +1737,7 @@ void DilloHtmlInput::reset () switch (type) { case DILLO_HTML_INPUT_TEXT: case DILLO_HTML_INPUT_PASSWORD: + case DILLO_HTML_INPUT_INDEX: { EntryResource *entryres = (EntryResource*)embed->getResource(); entryres->setText(init_str ? init_str : ""); diff --git a/src/form.hh b/src/form.hh index 36616466..910efe20 100644 --- a/src/form.hh +++ b/src/form.hh @@ -38,6 +38,9 @@ DilloHtmlForm *a_Html_form_new(DilloHtml *html, void a_Html_form_delete(DilloHtmlForm* form); void a_Html_input_delete(DilloHtmlInput* input); +void a_Html_form_submit2(void *v_form); +void a_Html_form_reset2(void *v_form); + /* * Form parsing functions diff --git a/src/html.cc b/src/html.cc index 772c0bb1..a03cc38d 100644 --- a/src/html.cc +++ b/src/html.cc @@ -215,6 +215,45 @@ void a_Html_load_images(void *v_html, DilloUrl *pattern) } /* + * Search for form + */ +static bool Html_contains_form(DilloHtml *html, void *v_form) +{ + for (int i = 0; i < html->forms->size(); i++) { + if (html->forms->get(i) == v_form) { + return true; + } + } + return false; +} + +/* + * Used by the "Submit form" form menuitem. + */ +void a_Html_form_submit(void *v_html, void *v_form) +{ + DilloHtml *html = (DilloHtml*)v_html; + + if (Html_contains_form(html, v_form)) { + /* it's still valid */ + a_Html_form_submit2(v_form); + } +} + +/* + * Used by the "Reset form" form menuitem. + */ +void a_Html_form_reset(void *v_html, void *v_form) +{ + DilloHtml *html = (DilloHtml*)v_html; + + if (Html_contains_form(html, v_form)) { + /* it's still valid */ + a_Html_form_reset2(v_form); + } +} + +/* * Set the URL data for image maps. */ static void Html_set_link_coordinates(DilloHtml *html, int link, int x, int y) diff --git a/src/html.hh b/src/html.hh index 3e08f37a..b742261c 100644 --- a/src/html.hh +++ b/src/html.hh @@ -11,6 +11,8 @@ extern "C" { * Exported functions */ void a_Html_load_images(void *v_html, DilloUrl *pattern); +void a_Html_form_submit(void *v_html, void *v_form); +void a_Html_form_reset(void *v_html, void *v_form); #ifdef __cplusplus } diff --git a/src/image.cc b/src/image.cc index 54eb4710..462ec90c 100644 --- a/src/image.cc +++ b/src/image.cc @@ -54,7 +54,6 @@ DilloImage *a_Image_new(int width, Image->cmap = NULL; Image->in_type = DILLO_IMG_TYPE_NOTSET; Image->bg_color = bg_color; - Image->ProcessedBytes = 0; Image->ScanNumber = 0; Image->BitVec = NULL; Image->State = IMG_Empty; @@ -172,7 +171,7 @@ void a_Image_new_scan(DilloImage *Image, void *v_imgbuf) void a_Image_write(DilloImage *Image, void *v_imgbuf, const uchar_t *buf, uint_t y, int decode) { - uchar_t *newbuf; + const uchar_t *newbuf; dReturn_if_fail ( y < Image->height ); diff --git a/src/image.hh b/src/image.hh index 73b0e5e7..ce906c74 100644 --- a/src/image.hh +++ b/src/image.hh @@ -42,7 +42,6 @@ struct _DilloImage { DilloImgType in_type; /* Image Type */ int32_t bg_color; /* Background color */ - int ProcessedBytes; /* Amount of bytes already decoded */ bitvec_t *BitVec; /* Bit vector for decoded rows */ uint_t ScanNumber; /* Current decoding scan */ ImageState State; /* Processing status */ diff --git a/src/menu.cc b/src/menu.cc index ac23117d..54babc0b 100644 --- a/src/menu.cc +++ b/src/menu.cc @@ -38,7 +38,7 @@ static DilloUrl *popup_url = NULL; // Weak reference to the popup's bw static BrowserWindow *popup_bw = NULL; // Where to place the filemenu popup -int popup_x, popup_y; +static int popup_x, popup_y; // History popup direction (-1 = back, 1 = forward). static int history_direction = -1; // History popup, list of URL-indexes. @@ -212,6 +212,44 @@ static void Menu_load_images_cb(Widget*, void *user_data) } } +/* + * Submit form + */ +static void Menu_form_submit_cb(Widget*, void *v_form) +{ + if (popup_bw && popup_bw->Docs) { + if (dList_find_custom(popup_bw->PageUrls, popup_url, + (dCompareFunc)a_Url_cmp)){ + /* HTML page is still there */ + int n = dList_length(popup_bw->Docs); + if (n == 1) { + a_Html_form_submit(dList_nth_data(popup_bw->Docs, 0), v_form); + } else if (n > 1) { + MSG ("Menu_form_submit_cb multiple Docs not implemented\n"); + } + } + } +} + +/* + * Reset form + */ +static void Menu_form_reset_cb(Widget*, void *v_form) +{ + if (popup_bw && popup_bw->Docs) { + if (dList_find_custom(popup_bw->PageUrls, popup_url, + (dCompareFunc)a_Url_cmp)){ + /* HTML page is still there */ + int n = dList_length(popup_bw->Docs); + if (n == 1) { + a_Html_form_reset(dList_nth_data(popup_bw->Docs, 0), v_form); + } else if (n > 1) { + MSG ("Menu_form_reset_cb multiple Docs not implemented\n"); + } + } + } +} + /* * Validate URL with the W3C */ @@ -452,6 +490,31 @@ void a_Menu_image_popup(BrowserWindow *bw, const DilloUrl *url, } /* + * Form popup menu (construction & popup) + */ +void a_Menu_form_popup(BrowserWindow *bw, const DilloUrl *page_url, + void *formptr) +{ + static PopupMenu *pm = 0; + + popup_bw = bw; + a_Url_free(popup_url); + popup_url = a_Url_dup(page_url); + if (!pm) { + Item *i; + pm = new PopupMenu(0,0,0,0,"FORM OPTIONS"); + pm->add(i = new Item("Submit form")); + i->callback(Menu_form_submit_cb); + pm->add(i = new Item("Reset form")); + i->callback(Menu_form_reset_cb); + pm->type(PopupMenu::POPUP123); + } + pm->user_data(formptr); + + a_Timeout_add(0.0, Menu_popup_cb, (void *)pm); +} + +/* * File popup menu (construction & popup) */ void a_Menu_file_popup(BrowserWindow *bw, void *v_wid) diff --git a/src/menu.hh b/src/menu.hh index 9e8a73c6..2b30e47d 100644 --- a/src/menu.hh +++ b/src/menu.hh @@ -12,6 +12,8 @@ void a_Menu_page_popup(BrowserWindow *bw, const DilloUrl *url, void a_Menu_link_popup(BrowserWindow *bw, const DilloUrl *url); void a_Menu_image_popup(BrowserWindow *bw, const DilloUrl *url, bool_t loaded_img, DilloUrl *link_url); +void a_Menu_form_popup(BrowserWindow *bw, const DilloUrl *page_url, + void *vform); void a_Menu_file_popup(BrowserWindow *bw, void *v_wid); void a_Menu_bugmeter_popup(BrowserWindow *bw, const DilloUrl *url); void a_Menu_history_popup(BrowserWindow *bw, int direction); @@ -194,12 +194,13 @@ static void Nav_stack_clean(BrowserWindow *bw) static void Nav_open_url(BrowserWindow *bw, const DilloUrl *url, int offset) { DilloUrl *old_url; - bool_t MustLoad, ForceReload; + bool_t MustLoad, ForceReload, Repush; int x, y, idx, ClientKey; DilloWeb *Web; MSG("Nav_open_url: new url='%s'\n", URL_STR_(url)); + Repush = (URL_FLAGS(url) & URL_ReloadFromCache) != 0; ForceReload = (URL_FLAGS(url) & (URL_E2EQuery + URL_ReloadFromCache)) != 0; /* Get the url of the current page */ @@ -207,8 +208,8 @@ static void Nav_open_url(BrowserWindow *bw, const DilloUrl *url, int offset) old_url = a_History_get_url(NAV_UIDX(bw, idx)); _MSG("Nav_open_url: old_url='%s' idx=%d\n", URL_STR(old_url), idx); /* Record current scrolling position */ - if (URL_FLAGS(url) & URL_ReloadFromCache) { - /* Repush operation, don't change scroll position */ + if (Repush) { + /* Don't change scroll position */ } else if (old_url) { a_UIcmd_get_scroll_xy(bw, &x, &y); Nav_save_scroll_pos(bw, idx, x, y); @@ -4,6 +4,7 @@ * * Geoff Lane nov 1999 zzassgl@twirl.mcc.ac.uk * Luca Rota, Jorge Arellano Cid, Eric Gaudet 2000 + * Jorge Arellano Cid 2009 * * "PNG: The Definitive Guide" by Greg Roelofs, O'Reilly * ISBN 1-56592-542-4 @@ -67,19 +68,19 @@ typedef struct _DilloPng { DilloImage *Image; /* Image meta data */ DilloUrl *url; /* Primary Key for the dicache */ - int version; /* Secondary Key for the dicache */ + int version; /* Secondary Key for the dicache */ double display_exponent; /* gamma correction */ - ulong_t width; /* png image width */ - ulong_t height; /* png image height */ + ulong_t width; /* png image width */ + ulong_t height; /* png image height */ png_structp png_ptr; /* libpng private data */ png_infop info_ptr; /* libpng private info */ - uchar_t *image_data; /* decoded image data */ - uchar_t **row_pointers; /* pntr to row starts */ + uchar_t *image_data; /* decoded image data */ + uchar_t **row_pointers; /* pntr to row starts */ jmp_buf jmpbuf; /* png error processing */ - int error; /* error flag */ + int error; /* error flag */ png_uint_32 previous_row; - int rowbytes; /* No. bytes in image row */ + int rowbytes; /* No. bytes in image row */ short passes; short channels; /* No. image channels */ @@ -92,13 +93,13 @@ struct _DilloPng { * ipbuf ipbufstart ipbufsize */ - uchar_t *ipbuf; /* image data in buffer */ - int ipbufstart; /* first valid image byte */ - int ipbufsize; /* size of valid data in */ + uchar_t *ipbuf; /* image data in buffer */ + int ipbufstart; /* first valid image byte */ + int ipbufsize; /* size of valid data in */ enum prog_state state; /* FSM current state */ - uchar_t *linebuf; /* o/p raster data */ + uchar_t *linebuf; /* o/p raster data */ } DilloPng; @@ -297,57 +298,37 @@ static void png->state = IS_finished; } - /* - * Op: Operation to perform. - * If (Op == 0) - * start or continue processing an image if image data exists. - * else - * terminate processing, cleanup any allocated memory, - * close down the decoding process. - * - * Client->CbData : pointer to previously allocated DilloPng work area. - * This holds the current state of the image processing and is saved - * across calls to this routine. - * Client->Buf : Pointer to data start. - * Client->BufSize : the size of the data buffer. - * - * You have to keep track of where you are in the image data and - * how much has been processed. - * - * It's entirely possible that you will not see the end of the data. The - * user may terminate transfer via a Stop button or there may be a network - * failure. This means that you can't just wait for all the data to be - * presented before starting conversion and display. + * Finish the decoding process (and free the memory) */ -static void Png_callback(int Op, CacheClient_t *Client) +static void Png_close(DilloPng *png, CacheClient_t *Client) { - DilloPng *png = Client->CbData; - - if (Op) { - /* finished - free up the resources for this image */ - a_Dicache_close(png->url, png->version, Client); - dFree(png->image_data); - dFree(png->row_pointers); - dFree(png->linebuf); - - if (setjmp(png->jmpbuf)) - MSG_WARN("PNG: can't destroy read structure\n"); - else if (png->png_ptr) - png_destroy_read_struct(&png->png_ptr, &png->info_ptr, NULL); - dFree(png); - return; - } + /* Free up the resources for this image */ + a_Dicache_close(png->url, png->version, Client); + dFree(png->image_data); + dFree(png->row_pointers); + dFree(png->linebuf); + + if (setjmp(png->jmpbuf)) + MSG_WARN("PNG: can't destroy read structure\n"); + else if (png->png_ptr) + png_destroy_read_struct(&png->png_ptr, &png->info_ptr, NULL); + dFree(png); +} - /* Let's make some sound if we have been called with no data */ - dReturn_if_fail ( Client->Buf != NULL && Client->BufSize > 0 ); +/* + * Receive and process new chunks of PNG image data + */ +static void Png_write(DilloPng *png, void *Buf, uint_t BufSize) +{ + dReturn_if_fail ( Buf != NULL && BufSize > 0 ); - _MSG("Png_callback BufSize = %d\n", Client->BufSize); + _MSG("Png_callback BufSize = %d\n", BufSize); /* Keep local copies so we don't have to pass multiple args to * a number of functions. */ - png->ipbuf = Client->Buf; - png->ipbufsize = Client->BufSize; + png->ipbuf = Buf; + png->ipbufsize = BufSize; /* start/resume the FSM here */ while (png->state != IS_finished && DATASIZE) { @@ -408,6 +389,37 @@ static void Png_callback(int Op, CacheClient_t *Client) } /* + * Op: Operation to perform. + * If (Op == 0) + * start or continue processing an image if image data exists. + * else + * terminate processing, cleanup any allocated memory, + * close down the decoding process. + * + * Client->CbData : pointer to previously allocated DilloPng work area. + * This holds the current state of the image processing and is kept + * across calls to this routine. + * Client->Buf : Pointer to data start. + * Client->BufSize : the size of the data buffer. + * + * You have to keep track of where you are in the image data and + * how much has been processed. + * + * It's entirely possible that you will not see the end of the data. The + * user may terminate transfer via a Stop button or there may be a network + * failure. This means that you can't just wait for all the data to be + * presented before starting conversion and display. + */ +static void Png_callback(int Op, CacheClient_t *Client) +{ + if (Op) { /* EOF */ + Png_close(Client->CbData, Client); + } else { + Png_write(Client->CbData, Client->Buf, Client->BufSize); + } +} + +/* * Create the image state data that must be kept between calls */ static DilloPng *Png_new(DilloImage *Image, DilloUrl *url, int version) @@ -433,25 +445,19 @@ static DilloPng *Png_new(DilloImage *Image, DilloUrl *url, int version) /* * MIME handler for "image/png" type * (Sets Png_callback or a_Dicache_callback as the cache-client) + * + * Parameters: + * Type: MIME type + * Ptr: points to a Web structure + * Call: Dillo calls this with more data/eod + * Data: Decoding data structure */ void *a_Png_image(const char *Type, void *Ptr, CA_Callback_t *Call, void **Data) { -/* - * Type: MIME type - * Ptr: points to a Web structure - * Call: Dillo calls this with more data/eod - * Data: raw image data - */ - DilloWeb *web = Ptr; DICacheEntry *DicEntry; - _MSG("a_Png_image: Type = %s\n" - "a_Png_image: libpng - Compiled %s; using %s.\n" - "a_Png_image: zlib - Compiled %s; using %s.\n", - Type, PNG_LIBPNG_VER_STRING, png_libpng_ver,ZLIB_VERSION,zlib_version); - if (!web->Image) web->Image = a_Image_new(0, 0, NULL, prefs.bg_color); diff --git a/src/prefs.c b/src/prefs.c index f04cb672..d7042924 100644 --- a/src/prefs.c +++ b/src/prefs.c @@ -35,10 +35,6 @@ #define DILLO_START_PAGE "about:splash" #define DILLO_HOME "http://www.dillo.org/" -#define D_GEOMETRY_DEFAULT_WIDTH 780 -#define D_GEOMETRY_DEFAULT_HEIGHT 580 -#define D_GEOMETRY_DEFAULT_XPOS -9999 -#define D_GEOMETRY_DEFAULT_YPOS -9999 #define D_VW_FONTNAME "DejaVu Sans" #define D_FW_FONTNAME "DejaVu Sans Mono" diff --git a/src/prefs.h b/src/prefs.h index ec807f46..a12e5a37 100644 --- a/src/prefs.h +++ b/src/prefs.h @@ -7,6 +7,11 @@ extern "C" { #endif /* __cplusplus */ +#define D_GEOMETRY_DEFAULT_WIDTH 780 +#define D_GEOMETRY_DEFAULT_HEIGHT 580 +#define D_GEOMETRY_DEFAULT_XPOS -9999 +#define D_GEOMETRY_DEFAULT_YPOS -9999 + /* Panel sizes */ enum { P_tiny = 0, P_small, P_medium, P_large }; @@ -993,7 +993,8 @@ void UI::panel_cb_i() */ void UI::color_change_cb_i() { - static int ncolor = 0, cols[] = {7,17,26,51,140,156,205,206,215,-1}; + const int cols[] = {7,17,26,51,140,156,205,206,215,-1}; + static int ncolor = 0; ncolor = (cols[ncolor+1] < 0) ? 0 : ncolor + 1; CuteColor = cols[ncolor]; diff --git a/src/uicmd.cc b/src/uicmd.cc index 4484f059..f8869129 100644 --- a/src/uicmd.cc +++ b/src/uicmd.cc @@ -666,6 +666,14 @@ void a_UIcmd_image_popup(void *vbw, const DilloUrl *url, bool_t loaded_img, } /* + * Pop up the form menu + */ +void a_UIcmd_form_popup(void *vbw, const DilloUrl *url, void *vform) +{ + a_Menu_form_popup((BrowserWindow*)vbw, url, vform); +} + +/* * Pop up the file menu */ void a_UIcmd_file_popup(void *vbw, void *v_wid) diff --git a/src/uicmd.hh b/src/uicmd.hh index c4e34736..3b5dc27e 100644 --- a/src/uicmd.hh +++ b/src/uicmd.hh @@ -41,6 +41,7 @@ void a_UIcmd_page_popup(void *vbw, const DilloUrl *url, void a_UIcmd_link_popup(void *vbw, const DilloUrl *url); void a_UIcmd_image_popup(void *vbw, const DilloUrl *url, bool_t loaded_img, DilloUrl *link_url); +void a_UIcmd_form_popup(void *vbw, const DilloUrl *url, void *vform); void a_UIcmd_file_popup(void *vbw, void *v_wid); void a_UIcmd_copy_urlstr(BrowserWindow *bw, const char *urlstr); void a_UIcmd_view_page_source(const DilloUrl *url); |