summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorJohn Tytgat <joty@netsurf-browser.org>2004-07-05 20:19:52 +0000
committerJohn Tytgat <joty@netsurf-browser.org>2004-07-05 20:19:52 +0000
commita0d511734ae464d6e7b4d2f5e019611c0cdafea9 (patch)
tree3427f02b2f829492f6bf89d16c7af91726878e9c /desktop
parentab11d2c94d0ed5c4ed9ab4f32417e3c1c4cf8fb9 (diff)
downloadnetsurf-a0d511734ae464d6e7b4d2f5e019611c0cdafea9.tar.gz
netsurf-a0d511734ae464d6e7b4d2f5e019611c0cdafea9.tar.bz2
[project @ 2004-07-05 20:19:51 by joty]
Using UTF-8 instead of Latin1 encoding. svn path=/import/netsurf/; revision=1049
Diffstat (limited to 'desktop')
-rw-r--r--desktop/browser.c49
-rw-r--r--desktop/netsurf.c15
-rw-r--r--desktop/save_text.c2
3 files changed, 41 insertions, 25 deletions
diff --git a/desktop/browser.c b/desktop/browser.c
index e6a8f1cbf..929b0a7ab 100644
--- a/desktop/browser.c
+++ b/desktop/browser.c
@@ -364,12 +364,16 @@ void browser_window_stop_throbber(struct browser_window *bw)
void browser_window_update(struct browser_window *bw,
bool scroll_to_top)
{
+ const char *title_local_enc;
+
if (!bw->current_content)
return;
- if (bw->current_content->title)
- gui_window_set_title(bw->window, bw->current_content->title);
- else
+ if (bw->current_content->title != NULL
+ && (title_local_enc = cnv_str_local_enc(bw->current_content->title)) != NULL) {
+ gui_window_set_title(bw->window, title_local_enc);
+ free(title_local_enc);
+ } else
gui_window_set_title(bw->window, bw->current_content->url);
gui_window_set_extent(bw->window, bw->current_content->width,
@@ -739,7 +743,7 @@ void browser_window_textarea_click(struct browser_window* bw,
text_box = inline_container->last;
assert(text_box->type == BOX_INLINE);
assert(text_box->text && text_box->font);
- font_position_in_string(text_box->text, text_box->font,
+ nsfont_position_in_string(text_box->font, text_box->text,
text_box->length,
(unsigned int)textarea->width,
&char_offset, &pixel_offset);
@@ -756,7 +760,8 @@ void browser_window_textarea_click(struct browser_window* bw,
text_box = inline_container->last;
assert(text_box->type == BOX_INLINE);
assert(text_box->text && text_box->font);
- font_position_in_string(text_box->text, text_box->font,
+ nsfont_position_in_string(text_box->font,
+ text_box->text,
text_box->length,
(unsigned int)textarea->width,
&char_offset, &pixel_offset);
@@ -764,7 +769,8 @@ void browser_window_textarea_click(struct browser_window* bw,
/* in a text box */
assert(text_box->type == BOX_INLINE);
assert(text_box->text && text_box->font);
- font_position_in_string(text_box->text, text_box->font,
+ nsfont_position_in_string(text_box->font,
+ text_box->text,
text_box->length,
(unsigned int)(x - text_box->x),
&char_offset, &pixel_offset);
@@ -1098,8 +1104,8 @@ void browser_window_textarea_callback(struct browser_window *bw, char key, void
for (ic = textarea->children; ic; ic = ic->next)
ic->y += dy;
- pixel_offset = font_width(text_box->font, text_box->text,
- (unsigned int)char_offset);
+ pixel_offset = nsfont_width(text_box->font, text_box->text,
+ (unsigned int)char_offset);
textarea->gadget->caret_inline_container = inline_container;
textarea->gadget->caret_text_box = text_box;
@@ -1130,7 +1136,7 @@ void browser_window_input_click(struct browser_window* bw,
int char_offset, pixel_offset;
struct box *text_box = input->children->children;
- font_position_in_string(text_box->text, text_box->font,
+ nsfont_position_in_string(text_box->font, text_box->text,
text_box->length, x - text_box->x,
&char_offset, &pixel_offset);
@@ -1170,7 +1176,7 @@ void browser_window_input_callback(struct browser_window *bw, char key, void *p)
box_coords(input, &actual_x, &actual_y);
- if ((32 <= key && key != 127) && text_box->length < input->gadget->maxlength) {
+ if (32 <= key && key != 127 && text_box->length < input->gadget->maxlength) {
/* normal character insertion */
text_box->text = xrealloc(text_box->text, text_box->length + 2);
input->gadget->value = xrealloc(input->gadget->value, text_box->length + 2);
@@ -1183,7 +1189,7 @@ void browser_window_input_callback(struct browser_window *bw, char key, void *p)
if (input->gadget->type == GADGET_PASSWORD)
text_box->text[char_offset] = '*';
else
- text_box->text[char_offset] = key == ' ' ? 160 : key;
+ text_box->text[char_offset] = key; /* /todo was a test on space -> change into NBSP, still needed ? */
input->gadget->value[char_offset] = key;
text_box->length++;
text_box->text[text_box->length] = 0;
@@ -1282,12 +1288,12 @@ void browser_window_input_callback(struct browser_window *bw, char key, void *p)
return;
}
- text_box->width = font_width(text_box->font, text_box->text,
+ text_box->width = nsfont_width(text_box->font, text_box->text,
(unsigned int)text_box->length);
- pixel_offset = font_width(text_box->font, text_box->text,
- (unsigned int)char_offset);
+ pixel_offset = nsfont_width(text_box->font, text_box->text,
+ (unsigned int)char_offset);
text_box->x = 0;
- if ((input->width < text_box->width) && (input->width / 2 < pixel_offset)) {
+ if (input->width < text_box->width && input->width / 2 < pixel_offset) {
text_box->x = input->width / 2 - pixel_offset;
if (text_box->x < input->width - text_box->width)
text_box->x = input->width - text_box->width;
@@ -1670,15 +1676,10 @@ void browser_window_text_selection(struct browser_window *bw,
if (click_boxes[i].box->text
&& click_boxes[i].box->font) {
- font_position_in_string(click_boxes[i].
- box->text,
- click_boxes[i].
- box->font,
- click_boxes[i].
- box->length,
- click_x -
- click_boxes[i].
- actual_x,
+ nsfont_position_in_string(click_boxes[i].box->font,
+ click_boxes[i].box->text,
+ click_boxes[i].box->length,
+ click_x - click_boxes[i].actual_x,
&click_char_offset,
&click_pixel_offset);
} else {
diff --git a/desktop/netsurf.c b/desktop/netsurf.c
index 55020354f..96745b989 100644
--- a/desktop/netsurf.c
+++ b/desktop/netsurf.c
@@ -26,6 +26,7 @@ bool netsurf_quit = false;
static void netsurf_init(int argc, char** argv);
static void netsurf_poll(void);
static void netsurf_exit(void);
+static void lib_init(void);
#ifndef curl_memdebug
extern void curl_memdebug(const char *logname);
@@ -68,6 +69,7 @@ void netsurf_init(int argc, char** argv)
utsname.nodename, utsname.release,
utsname.version, utsname.machine));
+ lib_init();
gui_init(argc, argv);
setlocale(LC_ALL, "");
fetch_init();
@@ -97,3 +99,16 @@ void netsurf_exit(void)
fetch_quit();
gui_quit();
}
+
+
+/**
+ * Initialises the libraries used in NetSurf.
+ */
+static void lib_init(void)
+{
+ /* Using encoding "X-SJIS" (unknown to libxmp2/iconv) instead as
+ * "Shift-JIS" is rather popular.
+ */
+ if (xmlAddEncodingAlias(xmlGetCharEncodingName(XML_CHAR_ENCODING_SHIFT_JIS), "X-SJIS") != 0)
+ die(("Failed to add encoding alias"));
+}
diff --git a/desktop/save_text.c b/desktop/save_text.c
index 98c0a8a88..9b3ff563f 100644
--- a/desktop/save_text.c
+++ b/desktop/save_text.c
@@ -93,7 +93,7 @@ void extract_text_from_tree(xmlNode *n)
/* do nothing, we just recurse through these nodes */
}
else if (n->type == XML_TEXT_NODE) {
- if ((text = squash_tolat1(n->content)) != NULL) {
+ if ((text = squash_whitespace(n->content)) != NULL) {
fputs(text, out);
free(text);
}