summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
Diffstat (limited to 'desktop')
-rw-r--r--desktop/browser.c42
-rw-r--r--desktop/options.c38
-rw-r--r--desktop/textinput.c33
3 files changed, 66 insertions, 47 deletions
diff --git a/desktop/browser.c b/desktop/browser.c
index 3cfcd0352..27fcd6ad1 100644
--- a/desktop/browser.c
+++ b/desktop/browser.c
@@ -1422,7 +1422,7 @@ void browser_window_mouse_action_html(struct browser_window *bw,
if (text_box) {
int pixel_offset;
- int idx;
+ size_t idx;
nsfont_position_in_string(text_box->style,
text_box->text,
@@ -1431,7 +1431,8 @@ void browser_window_mouse_action_html(struct browser_window *bw,
&idx,
&pixel_offset);
- selection_click(bw->sel, mouse, text_box->byte_offset + idx);
+ selection_click(bw->sel, mouse,
+ text_box->byte_offset + idx);
if (selection_dragging(bw->sel)) {
bw->drag_type = DRAGGING_SELECTION;
@@ -1456,9 +1457,10 @@ void browser_window_mouse_action_html(struct browser_window *bw,
}
else if (text_box) {
int pixel_offset;
- int idx;
+ size_t idx;
- if (mouse & (BROWSER_MOUSE_DRAG_1 | BROWSER_MOUSE_DRAG_2))
+ if (mouse & (BROWSER_MOUSE_DRAG_1 |
+ BROWSER_MOUSE_DRAG_2))
selection_init(bw->sel, gadget_box);
nsfont_position_in_string(text_box->style,
@@ -1468,7 +1470,8 @@ void browser_window_mouse_action_html(struct browser_window *bw,
&idx,
&pixel_offset);
- selection_click(bw->sel, mouse, text_box->byte_offset + idx);
+ selection_click(bw->sel, mouse,
+ text_box->byte_offset + idx);
if (selection_dragging(bw->sel))
bw->drag_type = DRAGGING_SELECTION;
@@ -1546,7 +1549,7 @@ void browser_window_mouse_action_html(struct browser_window *bw,
if (text_box) {
int pixel_offset;
- int idx;
+ size_t idx;
nsfont_position_in_string(text_box->style,
text_box->text,
@@ -1555,14 +1558,18 @@ void browser_window_mouse_action_html(struct browser_window *bw,
&idx,
&pixel_offset);
- if (selection_click(bw->sel, mouse, text_box->byte_offset + idx)) {
- /* key presses must be directed at the main browser
- * window, paste text operations ignored */
+ if (selection_click(bw->sel, mouse,
+ text_box->byte_offset + idx)) {
+ /* key presses must be directed at the
+ * main browser window, paste text
+ * operations ignored */
browser_window_remove_caret(bw);
if (selection_dragging(bw->sel)) {
- bw->drag_type = DRAGGING_SELECTION;
- status = messages_get("Selecting");
+ bw->drag_type =
+ DRAGGING_SELECTION;
+ status =
+ messages_get("Selecting");
} else
status = c->status_message;
@@ -1805,7 +1812,7 @@ void browser_window_mouse_track_html(struct browser_window *bw,
&dx, &dy, dir);
if (box) {
int pixel_offset;
- int idx;
+ size_t idx;
nsfont_position_in_string(box->style,
box->text,
@@ -1814,7 +1821,8 @@ void browser_window_mouse_track_html(struct browser_window *bw,
&idx,
&pixel_offset);
- selection_track(bw->sel, mouse, box->byte_offset + idx);
+ selection_track(bw->sel, mouse,
+ box->byte_offset + idx);
}
}
break;
@@ -1877,7 +1885,7 @@ void browser_window_mouse_drag_end(struct browser_window *bw,
if (c) {
bool found = true;
int dir = -1;
- int idx;
+ size_t idx;
if (selection_dragging_start(bw->sel)) dir = 1;
@@ -1889,7 +1897,8 @@ void browser_window_mouse_drag_end(struct browser_window *bw,
box = browser_window_pick_text_box(bw, mouse, x, y,
&dx, &dy, dir);
if (box) {
- nsfont_position_in_string(box->style,
+ nsfont_position_in_string(
+ box->style,
box->text,
box->length,
dx,
@@ -1897,7 +1906,8 @@ void browser_window_mouse_drag_end(struct browser_window *bw,
&pixel_offset);
idx += box->byte_offset;
- selection_track(bw->sel, mouse, idx);
+ selection_track(bw->sel, mouse,
+ idx);
}
else
found = false;
diff --git a/desktop/options.c b/desktop/options.c
index d3eba4c8e..33a6932f5 100644
--- a/desktop/options.c
+++ b/desktop/options.c
@@ -428,11 +428,11 @@ void options_load_tree_directory(xmlNode *ul, struct node *directory) {
if (n->type != XML_ELEMENT_NODE)
continue;
- if (strcmp(n->name, "li") == 0) {
+ if (strcmp((const char *) n->name, "li") == 0) {
/* entry */
options_load_tree_entry(n, directory);
- } else if (strcmp(n->name, "h4") == 0) {
+ } else if (strcmp((const char *) n->name, "h4") == 0) {
/* directory */
title = (char *) xmlNodeGetContent(n);
if (!title) {
@@ -445,7 +445,7 @@ void options_load_tree_directory(xmlNode *ul, struct node *directory) {
n && n->type != XML_ELEMENT_NODE;
n = n->next)
;
- if (!n || strcmp(n->name, "ul") != 0) {
+ if (!n || strcmp((const char *) n->name, "ul") != 0) {
/* next element isn't expected ul */
free(title);
warn_user("HotlistLoadError", "(Expected "
@@ -478,7 +478,7 @@ void options_load_tree_entry(xmlNode *li, struct node *directory) {
for (n = li->children; n; n = n->next) {
/* The li must contain an "a" element */
if (n->type == XML_ELEMENT_NODE &&
- strcmp(n->name, "a") == 0) {
+ strcmp((const char *) n->name, "a") == 0) {
url = (char *) xmlGetProp(n, (const xmlChar *) "href");
title = (char *) xmlNodeGetContent(n);
}
@@ -526,7 +526,7 @@ xmlNode *options_find_tree_element(xmlNode *node, const char *name) {
return 0;
for (n = node->children;
n && !(n->type == XML_ELEMENT_NODE &&
- strcmp(n->name, name) == 0);
+ strcmp((const char *) n->name, name) == 0);
n = n->next)
;
return n;
@@ -545,14 +545,15 @@ bool options_save_tree(struct tree *tree, const char *filename, const char *page
/* Unfortunately the Browse Hotlist format is invalid HTML,
* so this is a lie. */
- doc = htmlNewDoc("http://www.w3.org/TR/html4/strict.dtd",
- "-//W3C//DTD HTML 4.01//EN");
+ doc = htmlNewDoc(
+ (const xmlChar *) "http://www.w3.org/TR/html4/strict.dtd",
+ (const xmlChar *) "-//W3C//DTD HTML 4.01//EN");
if (!doc) {
warn_user("NoMemory", 0);
return false;
}
- html = xmlNewNode(NULL, "html");
+ html = xmlNewNode(NULL, (const xmlChar *) "html");
if (!html) {
warn_user("NoMemory", 0);
xmlFreeDoc(doc);
@@ -560,21 +561,22 @@ bool options_save_tree(struct tree *tree, const char *filename, const char *page
}
xmlDocSetRootElement(doc, html);
- head = xmlNewChild(html, NULL, "head", NULL);
+ head = xmlNewChild(html, NULL, (const xmlChar *) "head", NULL);
if (!head) {
warn_user("NoMemory", 0);
xmlFreeDoc(doc);
return false;
}
- title = xmlNewTextChild(head, NULL, "title", page_title);
+ title = xmlNewTextChild(head, NULL, (const xmlChar *) "title",
+ (const xmlChar *) page_title);
if (!title) {
warn_user("NoMemory", 0);
xmlFreeDoc(doc);
return false;
}
- body = xmlNewChild(html, NULL, "body", NULL);
+ body = xmlNewChild(html, NULL, (const xmlChar *) "body", NULL);
if (!body) {
warn_user("NoMemory", 0);
xmlFreeDoc(doc);
@@ -611,7 +613,7 @@ bool options_save_tree_directory(struct node *directory, xmlNode *node) {
struct node *child;
xmlNode *ul, *h4;
- ul = xmlNewChild(node, NULL, "ul", NULL);
+ ul = xmlNewChild(node, NULL, (const xmlChar *) "ul", NULL);
if (!ul)
return false;
@@ -623,7 +625,9 @@ bool options_save_tree_directory(struct node *directory, xmlNode *node) {
} else {
/* directory */
/* invalid HTML */
- h4 = xmlNewTextChild(ul, NULL, "h4", child->data.text);
+ h4 = xmlNewTextChild(ul, NULL,
+ (const xmlChar *) "h4",
+ (const xmlChar *) child->data.text);
if (!h4)
return false;
@@ -649,18 +653,20 @@ bool options_save_tree_entry(struct node *entry, xmlNode *node) {
xmlAttr *href;
struct node_element *element;
- li = xmlNewChild(node, NULL, "li", NULL);
+ li = xmlNewChild(node, NULL, (const xmlChar *) "li", NULL);
if (!li)
return false;
- a = xmlNewTextChild(li, NULL, "a", entry->data.text);
+ a = xmlNewTextChild(li, NULL, (const xmlChar *) "a",
+ (const xmlChar *) entry->data.text);
if (!a)
return false;
element = tree_find_element(entry, TREE_ELEMENT_URL);
if (!element)
return false;
- href = xmlNewProp(a, "href", element->text);
+ href = xmlNewProp(a, (const xmlChar *) "href",
+ (const xmlChar *) element->text);
if (!href)
return false;
return true;
diff --git a/desktop/textinput.c b/desktop/textinput.c
index 34006dbaf..2a7f4d553 100644
--- a/desktop/textinput.c
+++ b/desktop/textinput.c
@@ -84,8 +84,9 @@ static bool textarea_cut(struct browser_window *bw,
struct box *end_box, unsigned end_idx);
static void textarea_reflow(struct browser_window *bw, struct box *textarea,
struct box *inline_container);
-static bool word_left(const char *text, int *poffset, int *pchars);
-static bool word_right(const char *text, int len, int *poffset, int *pchars);
+static bool word_left(const char *text, size_t *poffset, size_t *pchars);
+static bool word_right(const char *text, size_t len, size_t *poffset,
+ size_t *pchars);
static bool ensure_caret_visible(struct box *textarea);
/**
@@ -179,7 +180,7 @@ struct box *textarea_get_position(struct box *textarea, int x, int y,
nsfont_position_in_string(text_box->style, text_box->text,
text_box->length,
(unsigned int)(x - text_box->x),
- pchar_offset, ppixel_offset);
+ (size_t *) pchar_offset, ppixel_offset);
} else {
/* find the relevant text box */
y -= inline_container->y;
@@ -202,7 +203,8 @@ struct box *textarea_get_position(struct box *textarea, int x, int y,
text_box->text,
text_box->length,
textarea->width,
- pchar_offset, ppixel_offset);
+ (size_t *) pchar_offset,
+ ppixel_offset);
} else {
/* in a text box */
if (text_box->type == BOX_BR)
@@ -221,7 +223,8 @@ struct box *textarea_get_position(struct box *textarea, int x, int y,
text_box->text,
text_box->length,
(unsigned int)(x - text_box->x),
- pchar_offset, ppixel_offset);
+ (size_t *) pchar_offset,
+ ppixel_offset);
}
}
@@ -1023,7 +1026,7 @@ bool browser_window_input_callback(struct browser_window *bw,
break;
case KEY_WORD_LEFT: {
- int nchars;
+ size_t nchars;
/* Text box */
if (word_left(input->gadget->value, &form_offset, &nchars)) {
/* Gadget */
@@ -1037,7 +1040,7 @@ bool browser_window_input_callback(struct browser_window *bw,
break;
case KEY_WORD_RIGHT: {
- int nchars;
+ size_t nchars;
/* Text box */
if (word_right(input->gadget->value, input->gadget->length,
&form_offset, &nchars)) {
@@ -1513,7 +1516,7 @@ void input_update_display(struct browser_window *bw, struct box *input,
box_coords(input, &box_x, &box_y);
nsfont_width(text_box->style, text_box->text, box_offset,
- &pixel_offset);
+ (int *) &pixel_offset);
dx = text_box->x;
text_box->x = 0;
if (input->width < text_box->width &&
@@ -1901,11 +1904,11 @@ void textarea_reflow(struct browser_window *bw, struct box *textarea,
* \return true iff the start of a word was found before/at the string start
*/
-bool word_left(const char *text, int *poffset, int *pchars)
+bool word_left(const char *text, size_t *poffset, size_t *pchars)
{
- int offset = *poffset;
+ size_t offset = *poffset;
bool success = false;
- int nchars = 0;
+ size_t nchars = 0;
while (offset > 0) {
offset = utf8_prev(text, offset);
@@ -1914,7 +1917,7 @@ bool word_left(const char *text, int *poffset, int *pchars)
}
while (offset > 0) {
- int prev = utf8_prev(text, offset);
+ size_t prev = utf8_prev(text, offset);
success = true;
if (isspace(text[prev]))
break;
@@ -1939,11 +1942,11 @@ bool word_left(const char *text, int *poffset, int *pchars)
* \return true iff the start of a word was found before the string end
*/
-bool word_right(const char *text, int len, int *poffset, int *pchars)
+bool word_right(const char *text, size_t len, size_t *poffset, size_t *pchars)
{
- int offset = *poffset;
+ size_t offset = *poffset;
bool success = false;
- int nchars = 0;
+ size_t nchars = 0;
while (offset < len) {
if (isspace(text[offset])) break;