centralise monkey output generation

This commit is contained in:
Vincent Sanders 2018-11-03 15:12:27 +00:00
parent 4fcb6eb301
commit 6ff3238825
11 changed files with 221 additions and 126 deletions

View File

@ -258,12 +258,15 @@ create_login_window(nsurl *url,
/* exported function documented in gtk/login.h */
nserror gui_401login_open(nsurl *url, const char *realm,
const char *username, const char *password,
nserror (*cb)(const char *username,
nserror
gui_401login_open(nsurl *url,
const char *realm,
const char *username,
const char *password,
nserror (*cb)(const char *username,
const char *password,
void *pw),
void *cbpw)
void *cbpw)
{
lwc_string *host;
nserror res;

View File

@ -21,6 +21,7 @@
#include <stdlib.h>
#include <stdio.h>
#include "monkey/output.h"
#include "monkey/401login.h"
typedef struct monkey401 {
@ -34,12 +35,16 @@ typedef struct monkey401 {
static monkey401_t *m4_ring = NULL;
static uint32_t m4_ctr = 0;
nserror gui_401login_open(nsurl *url, const char *realm,
const char *username, const char *password,
nserror (*cb)(const char *username,
nserror
gui_401login_open(nsurl *url,
const char *realm,
const char *username,
const char *password,
nserror (*cb)(const char *username,
const char *password,
void *pw),
void *cbpw)
void *cbpw)
{
monkey401_t *m4t = calloc(sizeof(*m4t), 1);
if (m4t == NULL) {
@ -51,7 +56,7 @@ nserror gui_401login_open(nsurl *url, const char *realm,
RING_INSERT(m4_ring, m4t);
fprintf(stdout, "401LOGIN OPEN M4 %u URL %s REALM %s\n",
moutf(MOUT_LOGIN, "OPEN LWIN %u URL %s REALM %s",
m4t->num, nsurl_access(url), realm);
return NSERROR_OK;

View File

@ -39,7 +39,7 @@ endif
# ----------------------------------------------------------------------------
# S_MONKEY are sources purely for the MONKEY build
S_FRONTEND := main.c filetype.c schedule.c bitmap.c plot.c browser.c \
S_FRONTEND := main.c output.c filetype.c schedule.c bitmap.c plot.c browser.c \
download.c 401login.c cert.c layout.c dispatch.c fetch.c

View File

@ -23,6 +23,7 @@
#include "utils/errors.h"
#include "netsurf/bitmap.h"
#include "monkey/output.h"
#include "monkey/bitmap.h"
struct bitmap {
@ -127,7 +128,7 @@ static int bitmap_get_height(void *bitmap)
static nserror bitmap_render(struct bitmap *bitmap,
struct hlcache_handle *content)
{
fprintf(stdout, "GENERIC BITMAP RENDER\n");
moutf(MOUT_GENERIC, "BITMAP RENDER");
return NSERROR_OK;
}

View File

@ -32,6 +32,7 @@
#include "netsurf/browser_window.h"
#include "netsurf/plotters.h"
#include "monkey/output.h"
#include "monkey/browser.h"
#include "monkey/plot.h"
@ -42,7 +43,7 @@ static struct gui_window *gw_ring = NULL;
/* exported function documented in monkey/browser.h */
nserror monkey_warn_user(const char *warning, const char *detail)
{
fprintf(stderr, "WARN %s %s\n", warning, detail);
moutf(MOUT_WARNING, "%s %s", warning, detail);
return NSERROR_OK;
}
@ -50,14 +51,14 @@ struct gui_window *
monkey_find_window_by_num(uint32_t win_num)
{
struct gui_window *ret = NULL;
RING_ITERATE_START(struct gui_window, gw_ring, c_ring) {
if (c_ring->win_num == win_num) {
ret = c_ring;
RING_ITERATE_STOP(gw_ring, c_ring);
}
} RING_ITERATE_END(gw_ring, c_ring);
return ret;
}
@ -77,28 +78,31 @@ gui_window_create(struct browser_window *bw,
struct gui_window *ret = calloc(sizeof(*ret), 1);
if (ret == NULL)
return NULL;
ret->win_num = win_ctr++;
ret->bw = bw;
ret->width = 800;
ret->height = 600;
fprintf(stdout, "WINDOW NEW WIN %u FOR %p EXISTING %p NEWTAB %s CLONE %s\n",
ret->win_num, bw, existing, flags & GW_CREATE_TAB ? "TRUE" : "FALSE",
flags & GW_CREATE_CLONE ? "TRUE" : "FALSE");
fprintf(stdout, "WINDOW SIZE WIN %u WIDTH %d HEIGHT %d\n",
ret->win_num, ret->width, ret->height);
moutf(MOUT_WINDOW,
"NEW WIN %u FOR %p EXISTING %p NEWTAB %s CLONE %s",
ret->win_num, bw, existing,
flags & GW_CREATE_TAB ? "TRUE" : "FALSE",
flags & GW_CREATE_CLONE ? "TRUE" : "FALSE");
moutf(MOUT_WINDOW,
"SIZE WIN %u WIDTH %d HEIGHT %d",
ret->win_num, ret->width, ret->height);
RING_INSERT(gw_ring, ret);
return ret;
}
static void
gui_window_destroy(struct gui_window *g)
{
fprintf(stdout, "WINDOW DESTROY WIN %u\n", g->win_num);
moutf(MOUT_WINDOW, "DESTROY WIN %u", g->win_num);
RING_REMOVE(gw_ring, g);
free(g);
}
@ -106,7 +110,7 @@ gui_window_destroy(struct gui_window *g)
static void
gui_window_set_title(struct gui_window *g, const char *title)
{
fprintf(stdout, "WINDOW TITLE WIN %u STR %s\n", g->win_num, title);
moutf(MOUT_WINDOW, "TITLE WIN %u STR %s", g->win_num, title);
}
/**
@ -120,9 +124,9 @@ gui_window_set_title(struct gui_window *g, const char *title)
*/
static nserror
gui_window_get_dimensions(struct gui_window *g, int *width, int *height,
bool scaled)
bool scaled)
{
fprintf(stdout, "WINDOW GET_DIMENSIONS WIN %u WIDTH %d HEIGHT %d\n",
moutf(MOUT_WINDOW, "GET_DIMENSIONS WIN %u WIDTH %d HEIGHT %d",
g->win_num, g->width, g->height);
*width = g->width;
*height = g->height;
@ -133,25 +137,25 @@ gui_window_get_dimensions(struct gui_window *g, int *width, int *height,
static void
gui_window_new_content(struct gui_window *g)
{
fprintf(stdout, "WINDOW NEW_CONTENT WIN %u\n", g->win_num);
moutf(MOUT_WINDOW, "NEW_CONTENT WIN %u", g->win_num);
}
static void
gui_window_set_icon(struct gui_window *g, struct hlcache_handle *icon)
{
fprintf(stdout, "WINDOW NEW_ICON WIN %u\n", g->win_num);
moutf(MOUT_WINDOW, "NEW_ICON WIN %u", g->win_num);
}
static void
gui_window_start_throbber(struct gui_window *g)
{
fprintf(stdout, "WINDOW START_THROBBER WIN %u\n", g->win_num);
moutf(MOUT_WINDOW, "START_THROBBER WIN %u", g->win_num);
}
static void
gui_window_stop_throbber(struct gui_window *g)
{
fprintf(stdout, "WINDOW STOP_THROBBER WIN %u\n", g->win_num);
moutf(MOUT_WINDOW, "STOP_THROBBER WIN %u", g->win_num);
}
@ -171,7 +175,7 @@ gui_window_set_scroll(struct gui_window *gw, const struct rect *rect)
gw->scrollx = rect->x0;
gw->scrolly = rect->y0;
fprintf(stdout, "WINDOW SET_SCROLL WIN %u X %d Y %d\n",
moutf(MOUT_WINDOW, "SET_SCROLL WIN %u X %d Y %d",
gw->win_num, rect->x0, rect->y0);
return NSERROR_OK;
}
@ -187,15 +191,14 @@ gui_window_set_scroll(struct gui_window *gw, const struct rect *rect)
static nserror
monkey_window_invalidate_area(struct gui_window *gw, const struct rect *rect)
{
fprintf(stdout, "WINDOW INVALIDATE_AREA WIN %u", gw->win_num);
if (rect != NULL) {
fprintf(stdout,
" X %d Y %d WIDTH %d HEIGHT %d\n",
rect->x0, rect->y0,
(rect->x1 - rect->x0), (rect->y1 - rect->y0));
moutf(MOUT_WINDOW,
"INVALIDATE_AREA WIN %u X %d Y %d WIDTH %d HEIGHT %d",
gw->win_num,
rect->x0, rect->y0,
(rect->x1 - rect->x0), (rect->y1 - rect->y0));
} else {
fprintf(stdout," ALL\n");
moutf(MOUT_WINDOW, "INVALIDATE_AREA WIN %u ALL", gw->win_num);
}
return NSERROR_OK;
@ -209,21 +212,21 @@ gui_window_update_extent(struct gui_window *g)
if (browser_window_get_extents(g->bw, false, &width, &height) != NSERROR_OK)
return;
fprintf(stdout, "WINDOW UPDATE_EXTENT WIN %u WIDTH %d HEIGHT %d\n",
g->win_num, width, height);
moutf(MOUT_WINDOW, "UPDATE_EXTENT WIN %u WIDTH %d HEIGHT %d",
g->win_num, width, height);
}
static void
gui_window_set_status(struct gui_window *g, const char *text)
{
fprintf(stdout, "WINDOW SET_STATUS WIN %u STR %s\n", g->win_num, text);
moutf(MOUT_WINDOW, "SET_STATUS WIN %u STR %s", g->win_num, text);
}
static void
gui_window_set_pointer(struct gui_window *g, gui_pointer_shape shape)
{
const char *ptr_name = "UNKNOWN";
switch (shape) {
case GUI_POINTER_POINT:
ptr_name = "POINT";
@ -285,21 +288,24 @@ gui_window_set_pointer(struct gui_window *g, gui_pointer_shape shape)
default:
break;
}
fprintf(stdout, "WINDOW SET_POINTER WIN %u POINTER %s\n", g->win_num, ptr_name);
moutf(MOUT_WINDOW, "SET_POINTER WIN %u POINTER %s",
g->win_num, ptr_name);
}
static nserror
gui_window_set_url(struct gui_window *g, nsurl *url)
{
fprintf(stdout, "WINDOW SET_URL WIN %u URL %s\n", g->win_num, nsurl_access(url));
moutf(MOUT_WINDOW, "SET_URL WIN %u URL %s",
g->win_num, nsurl_access(url));
return NSERROR_OK;
}
static bool
gui_window_get_scroll(struct gui_window *g, int *sx, int *sy)
{
fprintf(stdout, "WINDOW GET_SCROLL WIN %u X %d Y %d\n",
g->win_num, g->scrollx, g->scrolly);
moutf(MOUT_WINDOW, "GET_SCROLL WIN %u X %d Y %d",
g->win_num, g->scrollx, g->scrolly);
*sx = g->scrollx;
*sy = g->scrolly;
return true;
@ -308,7 +314,7 @@ gui_window_get_scroll(struct gui_window *g, int *sx, int *sy)
static bool
gui_window_scroll_start(struct gui_window *g)
{
fprintf(stdout, "WINDOW SCROLL_START WIN %u\n", g->win_num);
moutf(MOUT_WINDOW, "SCROLL_START WIN %u", g->win_num);
g->scrollx = g->scrolly = 0;
return true;
}
@ -318,28 +324,28 @@ static void
gui_window_place_caret(struct gui_window *g, int x, int y, int height,
const struct rect *clip)
{
fprintf(stdout, "WINDOW PLACE_CARET WIN %u X %d Y %d HEIGHT %d\n",
g->win_num, x, y, height);
moutf(MOUT_WINDOW, "PLACE_CARET WIN %u X %d Y %d HEIGHT %d",
g->win_num, x, y, height);
}
static void
gui_window_remove_caret(struct gui_window *g)
{
fprintf(stdout, "WINDOW REMOVE_CARET WIN %u\n", g->win_num);
moutf(MOUT_WINDOW, "REMOVE_CARET WIN %u", g->win_num);
}
static bool
gui_window_drag_start(struct gui_window *g, gui_drag_type type,
const struct rect *rect)
const struct rect *rect)
{
fprintf(stdout, "WINDOW SCROLL_START WIN %u TYPE %i\n", g->win_num, type);
moutf(MOUT_WINDOW, "SCROLL_START WIN %u TYPE %i", g->win_num, type);
return false;
}
static nserror
gui_window_save_link(struct gui_window *g, nsurl *url, const char *title)
{
fprintf(stdout, "WINDOW SAVE_LINK WIN %u URL %s TITLE %s\n",
moutf(MOUT_WINDOW, "SAVE_LINK WIN %u URL %s TITLE %s",
g->win_num, nsurl_access(url), title);
return NSERROR_OK;
}
@ -380,11 +386,11 @@ monkey_window_handle_destroy(int argc, char **argv)
{
struct gui_window *gw;
uint32_t nr = atoi((argc > 2) ? argv[2] : "-1");
gw = monkey_find_window_by_num(nr);
if (gw == NULL) {
fprintf(stdout, "ERROR WINDOW NUM BAD\n");
moutf(MOUT_ERROR, "WINDOW NUM BAD");
} else {
browser_window_destroy(gw->bw);
}
@ -397,16 +403,16 @@ monkey_window_handle_go(int argc, char **argv)
nsurl *url;
nsurl *ref_url = NULL;
nserror error;
if (argc < 4 || argc > 5) {
fprintf(stdout, "ERROR WINDOW GO ARGS BAD\n");
moutf(MOUT_ERROR, "WINDOW GO ARGS BAD");
return;
}
gw = monkey_find_window_by_num(atoi(argv[2]));
if (gw == NULL) {
fprintf(stdout, "ERROR WINDOW NUM BAD\n");
moutf(MOUT_ERROR, "WINDOW NUM BAD");
return;
}
@ -446,35 +452,35 @@ monkey_window_handle_redraw(int argc, char **argv)
.background_images = true,
.plot = monkey_plotters
};
if (argc != 3 && argc != 7) {
fprintf(stdout, "ERROR WINDOW REDRAW ARGS BAD\n");
moutf(MOUT_ERROR, "WINDOW REDRAW ARGS BAD");
return;
}
gw = monkey_find_window_by_num(atoi(argv[2]));
if (gw == NULL) {
fprintf(stdout, "ERROR WINDOW NUM BAD\n");
moutf(MOUT_ERROR, "WINDOW NUM BAD");
return;
}
clip.x0 = 0;
clip.y0 = 0;
clip.x1 = gw->width;
clip.y1 = gw->height;
if (argc == 7) {
clip.x0 = atoi(argv[3]);
clip.y0 = atoi(argv[4]);
clip.x1 = atoi(argv[5]);
clip.y1 = atoi(argv[6]);
}
NSLOG(netsurf, INFO, "Issue redraw");
fprintf(stdout, "WINDOW REDRAW WIN %d START\n", atoi(argv[2]));
browser_window_redraw(gw->bw, gw->scrollx, gw->scrolly, &clip, &ctx);
fprintf(stdout, "WINDOW REDRAW WIN %d STOP\n", atoi(argv[2]));
moutf(MOUT_WINDOW, "REDRAW WIN %d START", atoi(argv[2]));
browser_window_redraw(gw->bw, gw->scrollx, gw->scrolly, &clip, &ctx);
moutf(MOUT_ERROR, "REDRAW WIN %d STOP", atoi(argv[2]));
}
static void
@ -482,13 +488,13 @@ monkey_window_handle_reload(int argc, char **argv)
{
struct gui_window *gw;
if (argc != 3 && argc != 4) {
fprintf(stdout, "ERROR WINDOW RELOAD ARGS BAD\n");
moutf(MOUT_ERROR, "WINDOW RELOAD ARGS BAD\n");
}
gw = monkey_find_window_by_num(atoi(argv[2]));
if (gw == NULL) {
fprintf(stdout, "ERROR WINDOW NUM BAD\n");
moutf(MOUT_ERROR, "WINDOW NUM BAD");
} else {
browser_window_reload(gw->bw, argc == 4);
}
@ -500,7 +506,7 @@ monkey_window_handle_command(int argc, char **argv)
{
if (argc == 1)
return;
if (strcmp(argv[1], "NEW") == 0) {
monkey_window_handle_new(argc, argv);
} else if (strcmp(argv[1], "DESTROY") == 0) {
@ -512,9 +518,9 @@ monkey_window_handle_command(int argc, char **argv)
} else if (strcmp(argv[1], "RELOAD") == 0) {
monkey_window_handle_reload(argc, argv);
} else {
fprintf(stdout, "ERROR WINDOW COMMAND UNKNOWN %s\n", argv[1]);
moutf(MOUT_ERROR, "WINDOW COMMAND UNKNOWN %s\n", argv[1]);
}
}
static struct gui_window_table window_table = {

View File

@ -22,6 +22,7 @@
#include "utils/ring.h"
#include "utils/nsurl.h"
#include "monkey/output.h"
#include "monkey/cert.h"
typedef struct monkey_cert {
@ -36,9 +37,10 @@ static monkey_cert_t *cert_ring = NULL;
static uint32_t cert_ctr = 0;
nserror
gui_cert_verify(nsurl *url, const struct ssl_cert_info *certs,
unsigned long num, nserror (*cb)(bool proceed, void *pw),
void *cbpw)
gui_cert_verify(nsurl *url,
const struct ssl_cert_info *certs,
unsigned long num, nserror (*cb)(bool proceed, void *pw),
void *cbpw)
{
monkey_cert_t *m4t = calloc(sizeof(*m4t), 1);
if (m4t == NULL) {
@ -47,13 +49,11 @@ gui_cert_verify(nsurl *url, const struct ssl_cert_info *certs,
m4t->cb = cb;
m4t->pw = cbpw;
m4t->num = cert_ctr++;
RING_INSERT(cert_ring, m4t);
fprintf(stdout, "SSLCERT VERIFY CERT %u URL %s\n",
m4t->num, nsurl_access(url));
moutf(MOUT_SSLCERT, "VERIFY CWIN %u URL %s",
m4t->num, nsurl_access(url));
return NSERROR_OK;
}

View File

@ -25,6 +25,7 @@
#include "netsurf/download.h"
#include "desktop/download.h"
#include "monkey/output.h"
#include "monkey/browser.h"
static uint32_t dwin_ctr = 0;
@ -51,8 +52,8 @@ gui_download_window_create(download_context *ctx,
RING_INSERT(dw_ring, ret);
fprintf(stdout, "DOWNLOAD_WINDOW CREATE DWIN %u WIN %u\n",
ret->dwin_num, parent->win_num);
moutf(MOUT_DOWNLOAD, "CREATE DWIN %u WIN %u",
ret->dwin_num, parent->win_num);
return ret;
}
@ -61,7 +62,7 @@ static nserror
gui_download_window_data(struct gui_download_window *dw,
const char *data, unsigned int size)
{
fprintf(stdout, "DOWNLOAD_WINDOW DATA DWIN %u SIZE %u DATA %s\n",
moutf(MOUT_DOWNLOAD, "DATA DWIN %u SIZE %u DATA %s",
dw->dwin_num, size, data);
return NSERROR_OK;
}
@ -70,15 +71,13 @@ static void
gui_download_window_error(struct gui_download_window *dw,
const char *error_msg)
{
fprintf(stdout, "DOWNLOAD_WINDOW ERROR DWIN %u ERROR %s\n",
dw->dwin_num, error_msg);
moutf(MOUT_DOWNLOAD, "ERROR DWIN %u ERROR %s", dw->dwin_num, error_msg);
}
static void
gui_download_window_done(struct gui_download_window *dw)
{
fprintf(stdout, "DOWNLOAD_WINDOW DONE DWIN %u\n",
dw->dwin_num);
moutf(MOUT_DOWNLOAD, "DONE DWIN %u", dw->dwin_num);
RING_REMOVE(dw_ring, dw);
free(dw);
}

View File

@ -37,6 +37,7 @@
#include "netsurf/cookie_db.h"
#include "content/fetch.h"
#include "monkey/output.h"
#include "monkey/dispatch.h"
#include "monkey/browser.h"
#include "monkey/cert.h"
@ -66,7 +67,7 @@ static bool monkey_done = false;
*/
static void die(const char * const error)
{
fprintf(stderr, "DIE %s\n", error);
moutf(MOUT_DIE, "%s", error);
exit(EXIT_FAILURE);
}
@ -199,7 +200,7 @@ static void monkey_quit(void)
static nserror gui_launch_url(struct nsurl *url)
{
fprintf(stdout, "GENERIC LAUNCH URL %s\n", nsurl_access(url));
moutf(MOUT_GENERIC, "LAUNCH URL %s", nsurl_access(url));
return NSERROR_OK;
}
@ -279,7 +280,7 @@ static void monkey_run(void)
switch (schedtm) {
case -1:
NSLOG(netsurf, INFO, "Iterate blocking");
fprintf(stdout, "GENERIC POLL BLOCKING\n");
moutf(MOUT_GENERIC, "POLL BLOCKING");
timeout = NULL;
break;
@ -292,7 +293,7 @@ static void monkey_run(void)
default:
NSLOG(netsurf, INFO, "Iterate non-blocking");
fprintf(stdout, "GENERIC POLL TIMED %d\n", schedtm);
moutf(MOUT_GENERIC, "POLL TIMED %d", schedtm);
tv.tv_sec = schedtm / 1000; /* miliseconds to seconds */
tv.tv_usec = (schedtm % 1000) * 1000; /* remainder to microseconds */
timeout = &tv;
@ -392,14 +393,14 @@ main(int argc, char **argv)
die("options handler failed to register");
}
fprintf(stdout, "GENERIC STARTED\n");
moutf(MOUT_GENERIC, "STARTED");
monkey_run();
fprintf(stdout, "GENERIC CLOSING_DOWN\n");
moutf(MOUT_GENERIC, "CLOSING_DOWN");
monkey_kill_browser_windows();
netsurf_exit();
fprintf(stdout, "GENERIC FINISHED\n");
moutf(MOUT_GENERIC, "FINISHED");
/* finalise options */
nsoption_finalise(nsoptions, nsoptions_default);

54
frontends/monkey/output.c Normal file
View File

@ -0,0 +1,54 @@
/*
* Copyright 2018 Vincent Sanders <vince@nexturf-browser.org>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
* NetSurf is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* NetSurf is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <stdarg.h>
#include "monkey/output.h"
/**
* output type prefixes
*/
static const char *type_text[]={
"DIE",
"ERROR",
"WARN",
"GENERIC",
"WINDOW",
"LOGIN",
"SSLCERT",
"DOWNLOAD",
"PLOT",
};
/* exported interface documented in monkey/output.h */
int moutf(enum monkey_output_type mout_type, const char *fmt, ...)
{
va_list ap;
int res;
res = fprintf(stdout, "%s ", type_text[mout_type]);
va_start(ap, fmt);
res += vfprintf(stdout, fmt, ap);
va_end(ap);
fputc('\n', stdout);
return res + 1;
}

36
frontends/monkey/output.h Normal file
View File

@ -0,0 +1,36 @@
/*
* Copyright 2018 Vincent Sanders <vince@netsurf-browser.org>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
* NetSurf is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* NetSurf is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef NS_MONKEY_OUTPUT_H
#define NS_MONKEY_OUTPUT_H
enum monkey_output_type {
MOUT_DIE,
MOUT_ERROR,
MOUT_WARNING,
MOUT_GENERIC,
MOUT_WINDOW,
MOUT_LOGIN,
MOUT_SSLCERT,
MOUT_DOWNLOAD,
MOUT_PLOT,
};
int moutf(enum monkey_output_type mout_type, const char *fmt, ...);
#endif

View File

@ -22,6 +22,8 @@
#include "utils/errors.h"
#include "netsurf/plotters.h"
#include "monkey/output.h"
/**
* \brief Sets a clip rectangle for subsequent plot operations.
*
@ -33,8 +35,7 @@
static nserror
monkey_plot_clip(const struct redraw_context *ctx, const struct rect *clip)
{
fprintf(stdout,
"PLOT CLIP X0 %d Y0 %d X1 %d Y1 %d\n",
moutf(MOUT_PLOT, "CLIP X0 %d Y0 %d X1 %d Y1 %d",
clip->x0, clip->y0, clip->x1, clip->y1);
return NSERROR_OK;
}
@ -61,9 +62,8 @@ monkey_plot_arc(const struct redraw_context *ctx,
const plot_style_t *style,
int x, int y, int radius, int angle1, int angle2)
{
fprintf(stdout,
"PLOT ARC X %d Y %d RADIUS %d ANGLE1 %d ANGLE2 %d\n",
x, y, radius, angle1, angle2);
moutf(MOUT_PLOT, "ARC X %d Y %d RADIUS %d ANGLE1 %d ANGLE2 %d",
x, y, radius, angle1, angle2);
return NSERROR_OK;
}
@ -85,9 +85,7 @@ monkey_plot_disc(const struct redraw_context *ctx,
const plot_style_t *style,
int x, int y, int radius)
{
fprintf(stdout,
"PLOT DISC X %d Y %d RADIUS %d\n",
x, y, radius);
moutf(MOUT_PLOT, "DISC X %d Y %d RADIUS %d", x, y, radius);
return NSERROR_OK;
}
@ -108,8 +106,7 @@ monkey_plot_line(const struct redraw_context *ctx,
const plot_style_t *style,
const struct rect *line)
{
fprintf(stdout,
"PLOT LINE X0 %d Y0 %d X1 %d Y1 %d\n",
moutf(MOUT_PLOT, "LINE X0 %d Y0 %d X1 %d Y1 %d",
line->x0, line->y0, line->x1, line->y1);
return NSERROR_OK;
}
@ -133,8 +130,7 @@ monkey_plot_rectangle(const struct redraw_context *ctx,
const plot_style_t *style,
const struct rect *rect)
{
fprintf(stdout,
"PLOT RECT X0 %d Y0 %d X1 %d Y1 %d\n",
moutf(MOUT_PLOT, "RECT X0 %d Y0 %d X1 %d Y1 %d",
rect->x0, rect->y0, rect->x1, rect->y1);
return NSERROR_OK;
}
@ -160,9 +156,7 @@ monkey_plot_polygon(const struct redraw_context *ctx,
const int *p,
unsigned int n)
{
fprintf(stdout,
"PLOT POLYGON VERTICIES %d\n",
n);
moutf(MOUT_PLOT, "POLYGON VERTICIES %d", n);
return NSERROR_OK;
}
@ -187,8 +181,7 @@ monkey_plot_path(const struct redraw_context *ctx,
unsigned int n,
const float transform[6])
{
fprintf(stdout,
"PLOT PATH VERTICIES %d WIDTH %f\n",
moutf(MOUT_PLOT, "PATH VERTICIES %d WIDTH %f",
n, plot_style_fixed_to_float(pstyle->stroke_width));
return NSERROR_OK;
}
@ -227,9 +220,8 @@ monkey_plot_bitmap(const struct redraw_context *ctx,
colour bg,
bitmap_flags_t flags)
{
fprintf(stdout,
"PLOT BITMAP X %d Y %d WIDTH %d HEIGHT %d\n",
x, y, width, height);
moutf(MOUT_PLOT, "BITMAP X %d Y %d WIDTH %d HEIGHT %d",
x, y, width, height);
return NSERROR_OK;
}
@ -253,9 +245,7 @@ monkey_plot_text(const struct redraw_context *ctx,
const char *text,
size_t length)
{
fprintf(stdout,
"PLOT TEXT X %d Y %d STR %*s\n",
x, y, (int)length, text);
moutf(MOUT_PLOT, "TEXT X %d Y %d STR %*s\n", x, y, (int)length, text);
return NSERROR_OK;
}