mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-12-25 05:27:00 +03:00
fix framebuffer command line/default option usage
svn path=/trunk/netsurf/; revision=9849
This commit is contained in:
parent
185465df3d
commit
192d05c20c
@ -341,26 +341,10 @@ struct plotter_table plot = {
|
||||
|
||||
|
||||
nsfb_t *
|
||||
framebuffer_initialise(int argc, char** argv)
|
||||
framebuffer_initialise(const char *fename, int width, int height, int bpp)
|
||||
{
|
||||
const char *fename;
|
||||
enum nsfb_frontend_e fetype;
|
||||
|
||||
/* select frontend from commandline */
|
||||
if ((argc > 2) && (argv[1][0] == '-') &&
|
||||
(argv[1][1] == 'f') &&
|
||||
(argv[1][2] == 'e') &&
|
||||
(argv[1][3] == 0)) {
|
||||
int argcmv;
|
||||
fename = (const char *)argv[2];
|
||||
for (argcmv = 3; argcmv < argc; argcmv++) {
|
||||
argv[argcmv - 2] = argv[argcmv];
|
||||
}
|
||||
argc-=2;
|
||||
} else {
|
||||
fename="sdl";
|
||||
}
|
||||
|
||||
fetype = nsfb_frontend_from_name(fename);
|
||||
if (fetype == NSFB_FRONTEND_NONE) {
|
||||
LOG(("The %s frontend is not available from libnsfb\n", fename));
|
||||
@ -373,7 +357,7 @@ framebuffer_initialise(int argc, char** argv)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (nsfb_set_geometry(nsfb, 0, 0, 32) == -1) {
|
||||
if (nsfb_set_geometry(nsfb, width, height, bpp) == -1) {
|
||||
LOG(("Unable to set geometry\n"));
|
||||
nsfb_finalise(nsfb);
|
||||
return NULL;
|
||||
|
@ -1,4 +1,4 @@
|
||||
nsfb_t *framebuffer_initialise(int argc, char** argv);
|
||||
nsfb_t *framebuffer_initialise(const char *fename, int width, int height, int bpp);
|
||||
void framebuffer_finalise(void);
|
||||
bool framebuffer_set_cursor(struct bitmap *bm);
|
||||
|
||||
|
@ -346,12 +346,77 @@ static void *myrealloc(void *ptr, size_t len, void *pw)
|
||||
return realloc(ptr, len);
|
||||
}
|
||||
|
||||
|
||||
static const char *fename;
|
||||
static int febpp;
|
||||
static int fewidth;
|
||||
static int feheight;
|
||||
static const char *feurl;
|
||||
|
||||
static bool process_cmdline(int argc, char** argv)
|
||||
{
|
||||
int opt;
|
||||
|
||||
LOG(("argc %d, argv %p", argc, argv));
|
||||
|
||||
fename = "sdl";
|
||||
febpp = 32;
|
||||
|
||||
if ((option_window_width != 0) && (option_window_height != 0)) {
|
||||
fewidth = option_window_width;
|
||||
feheight = option_window_height;
|
||||
} else {
|
||||
fewidth = 800;
|
||||
feheight = 600;
|
||||
}
|
||||
|
||||
if (option_homepage_url != NULL && option_homepage_url[0] != '\0')
|
||||
feurl = option_homepage_url;
|
||||
else
|
||||
feurl = NETSURF_HOMEPAGE;
|
||||
|
||||
|
||||
while((opt = getopt(argc, argv, "f:b:w:h:")) != -1) {
|
||||
switch (opt) {
|
||||
case 'f':
|
||||
fename = optarg;
|
||||
break;
|
||||
|
||||
case 'b':
|
||||
febpp = atoi(optarg);
|
||||
break;
|
||||
|
||||
case 'w':
|
||||
fewidth = atoi(optarg);
|
||||
break;
|
||||
|
||||
case 'h':
|
||||
feheight = atoi(optarg);
|
||||
break;
|
||||
|
||||
default:
|
||||
fprintf(stderr,
|
||||
"Usage: %s [-f frontend] [-b bpp] url\n",
|
||||
argv[0]);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (optind < argc) {
|
||||
feurl = argv[optind];
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void gui_init(int argc, char** argv)
|
||||
{
|
||||
char buf[PATH_MAX];
|
||||
nsfb_t *nsfb;
|
||||
|
||||
LOG(("argc %d, argv %p", argc, argv));
|
||||
if (process_cmdline(argc,argv) != true)
|
||||
die("unable to process command line.\n");
|
||||
|
||||
|
||||
fb_find_resource(buf, "Aliases", "./framebuffer/res/Aliases");
|
||||
LOG(("Using '%s' as Aliases file", buf));
|
||||
@ -379,7 +444,7 @@ void gui_init(int argc, char** argv)
|
||||
fb_find_resource(buf, "quirks.css", "./framebuffer/res/quirks.css");
|
||||
quirks_stylesheet_url = path_to_url(buf);
|
||||
|
||||
nsfb = framebuffer_initialise(argc, argv);
|
||||
nsfb = framebuffer_initialise(fename, fewidth, feheight, febpp);
|
||||
if (nsfb == NULL)
|
||||
die("Unable to initialise framebuffer");
|
||||
|
||||
@ -395,17 +460,9 @@ void gui_init(int argc, char** argv)
|
||||
void gui_init2(int argc, char** argv)
|
||||
{
|
||||
struct browser_window *bw;
|
||||
const char *addr = NETSURF_HOMEPAGE;
|
||||
|
||||
LOG(("argc %d, argv %p", argc, argv));
|
||||
|
||||
if (option_homepage_url != NULL && option_homepage_url[0] != '\0')
|
||||
addr = option_homepage_url;
|
||||
|
||||
if (argc > 1) addr = argv[1];
|
||||
|
||||
LOG(("calling browser_window_create"));
|
||||
bw = browser_window_create(addr, 0, 0, true, false);
|
||||
bw = browser_window_create(feurl, 0, 0, true, false);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user