r12264 chris_y - in /trunk/netsurf/amiga: font.c font.h object.c object.h
by netsurf@semichrome.net
Author: chris_y
Date: Sat Apr 30 14:05:11 2011
New Revision: 12264
URL: http://source.netsurf-browser.org?rev=12264&view=rev
Log:
Don't open fonts until they are needed
Modified:
trunk/netsurf/amiga/font.c
trunk/netsurf/amiga/font.h
trunk/netsurf/amiga/object.c
trunk/netsurf/amiga/object.h
Modified: trunk/netsurf/amiga/font.c
URL: http://source.netsurf-browser.org/trunk/netsurf/amiga/font.c?rev=12264&r1...
==============================================================================
--- trunk/netsurf/amiga/font.c (original)
+++ trunk/netsurf/amiga/font.c Sat Apr 30 14:05:11 2011
@@ -21,6 +21,7 @@
#include "amiga/font.h"
#include "amiga/gui.h"
#include "amiga/utf8.h"
+#include "amiga/object.h"
#include "amiga/options.h"
#include "css/css.h"
#include "css/utils.h"
@@ -55,11 +56,15 @@
#define NSA_VALUE_SHEARSIN (1 << 14)
#define NSA_VALUE_SHEARCOS (1 << 16)
-static struct OutlineFont *of[PLOT_FONT_FAMILY_COUNT+1];
-static struct OutlineFont *ofb[PLOT_FONT_FAMILY_COUNT+1];
-static struct OutlineFont *ofi[PLOT_FONT_FAMILY_COUNT+1];
-static struct OutlineFont *ofbi[PLOT_FONT_FAMILY_COUNT+1];
-
+struct ami_font_node
+{
+ struct OutlineFont *font;
+ char *bold;
+ char *italic;
+ char *bolditalic;
+};
+
+struct MinList *ami_font_list = NULL;
ULONG ami_devicedpi;
int32 ami_font_plot_glyph(struct OutlineFont *ofont, struct RastPort *rp,
@@ -300,6 +305,45 @@
}
/**
+ * Search for a font in the list and load from disk if not present
+ */
+struct ami_font_node *ami_font_open(const char *font)
+{
+ struct nsObject *node;
+ struct ami_font_node *nodedata;
+
+ node = (struct nsObject *)FindIName((struct List *)ami_font_list, font);
+ if(node) return node->objstruct;
+
+ LOG(("Font cache miss: %s", font));
+
+ nodedata = AllocVec(sizeof(struct ami_font_node), MEMF_PRIVATE | MEMF_CLEAR);
+
+ node = AddObject(ami_font_list, AMINS_FONT);
+ if(!node) return NULL;
+
+ node->objstruct = nodedata;
+ node->dtz_Node.ln_Name = strdup(font);
+
+ nodedata->font = OpenOutlineFont(font, NULL, OFF_OPEN);
+ if(!nodedata->font)
+ {
+ LOG(("Requested font not found: %s", font));
+ warn_user("CompError", font);
+ return NULL;
+ }
+
+ nodedata->bold = (char *)GetTagData(OT_BName, 0, nodedata->font->olf_OTagList);
+ if(!nodedata->bold) LOG(("Warning: No designed bold font defined for %s", font));
+ nodedata->italic = (char *)GetTagData(OT_IName, 0, nodedata->font->olf_OTagList);
+ if(!nodedata->italic) LOG(("Warning: No designed italic font defined for %s", font));
+ nodedata->bolditalic = (char *)GetTagData(OT_BIName, 0, nodedata->font->olf_OTagList);
+ if(!nodedata->bolditalic) LOG(("Warning: No designed bold/italic font defined for %s", font));
+
+ return nodedata;
+}
+
+/**
* Open an outline font in the specified size and style
*
* \param fstyle font style structure
@@ -308,6 +352,7 @@
*/
struct OutlineFont *ami_open_outline_font(const plot_font_style_t *fstyle, BOOL fallback)
{
+ struct ami_font_node *node;
struct OutlineFont *ofont;
char *fontname;
ULONG ysize;
@@ -321,6 +366,32 @@
if(fallback) fontfamily = NSA_UNICODE_FONT;
else fontfamily = fstyle->family;
+ switch(fontfamily)
+ {
+ case PLOT_FONT_FAMILY_SANS_SERIF:
+ fontname = option_font_sans;
+ break;
+ case PLOT_FONT_FAMILY_SERIF:
+ fontname = option_font_serif;
+ break;
+ case PLOT_FONT_FAMILY_MONOSPACE:
+ fontname = option_font_mono;
+ break;
+ case PLOT_FONT_FAMILY_CURSIVE:
+ fontname = option_font_cursive;
+ break;
+ case PLOT_FONT_FAMILY_FANTASY:
+ fontname = option_font_fantasy;
+ break;
+ case NSA_UNICODE_FONT:
+ default:
+ fontname = option_font_unicode;
+ break;
+ }
+
+ node = ami_font_open(fontname);
+ if(!node) return NULL;
+
if ((fstyle->flags & FONTF_ITALIC) || (fstyle->flags & FONTF_OBLIQUE))
tstyle += NSA_ITALIC;
@@ -330,53 +401,48 @@
switch(tstyle)
{
case NSA_ITALIC:
- if(ofi[fontfamily])
- {
- ofont = ofi[fontfamily];
+ if(node->italic)
+ {
+ node = ami_font_open(node->italic);
}
else
{
- ofont = of[fontfamily];
shearsin = NSA_VALUE_SHEARSIN;
shearcos = NSA_VALUE_SHEARCOS;
}
break;
case NSA_BOLD:
- if(ofb[fontfamily])
- {
- ofont = ofb[fontfamily];
+ if(node->bold)
+ {
+ node = ami_font_open(node->bold);
}
else
{
- ofont = of[fontfamily];
emboldenx = NSA_VALUE_BOLDX;
emboldeny = NSA_VALUE_BOLDY;
}
break;
case NSA_BOLDITALIC:
- if(ofbi[fontfamily])
- {
- ofont = ofbi[fontfamily];
+ if(node->bolditalic)
+ {
+ node = ami_font_open(node->bolditalic);
}
else
{
- ofont = of[fontfamily];
emboldenx = NSA_VALUE_BOLDX;
emboldeny = NSA_VALUE_BOLDY;
shearsin = NSA_VALUE_SHEARSIN;
shearcos = NSA_VALUE_SHEARCOS;
}
break;
-
- default:
- ofont = of[fontfamily];
- break;
}
/* Scale to 16.16 fixed point */
ysize = fstyle->size * ((1 << 16) / FONT_SIZE_SCALE);
+
+ ofont = node->font;
if(ESetInfo(&ofont->olf_EEngine,
OT_DeviceDPI, ami_devicedpi,
@@ -509,113 +575,20 @@
void ami_init_fonts(void)
{
- int i;
- char *bname,*iname,*biname;
- char *deffont;
-
- switch(option_font_default)
- {
- case PLOT_FONT_FAMILY_SANS_SERIF:
- deffont = strdup(option_font_sans);
- break;
- case PLOT_FONT_FAMILY_SERIF:
- deffont = strdup(option_font_serif);
- break;
- case PLOT_FONT_FAMILY_MONOSPACE:
- deffont = strdup(option_font_mono);
- break;
- case PLOT_FONT_FAMILY_CURSIVE:
- deffont = strdup(option_font_cursive);
- break;
- case PLOT_FONT_FAMILY_FANTASY:
- deffont = strdup(option_font_fantasy);
- break;
- default:
- deffont = strdup(option_font_sans);
- break;
- }
-
- of[PLOT_FONT_FAMILY_SANS_SERIF] = OpenOutlineFont(option_font_sans,NULL,OFF_OPEN);
- of[PLOT_FONT_FAMILY_SERIF] = OpenOutlineFont(option_font_serif,NULL,OFF_OPEN);
- of[PLOT_FONT_FAMILY_MONOSPACE] = OpenOutlineFont(option_font_mono,NULL,OFF_OPEN);
- of[PLOT_FONT_FAMILY_CURSIVE] = OpenOutlineFont(option_font_cursive,NULL,OFF_OPEN);
- of[PLOT_FONT_FAMILY_FANTASY] = OpenOutlineFont(option_font_fantasy,NULL,OFF_OPEN);
- of[NSA_UNICODE_FONT] = OpenOutlineFont(option_font_unicode,NULL,OFF_OPEN);
-
- for(i=PLOT_FONT_FAMILY_SANS_SERIF;i<=NSA_UNICODE_FONT;i++)
- {
- if(!of[i])
- {
- char *tmpfontname = NULL;
- switch(i)
- {
- case PLOT_FONT_FAMILY_SANS_SERIF:
- tmpfontname = option_font_sans;
- break;
- case PLOT_FONT_FAMILY_SERIF:
- tmpfontname = option_font_serif;
- break;
- case PLOT_FONT_FAMILY_MONOSPACE:
- tmpfontname = option_font_mono;
- break;
- case PLOT_FONT_FAMILY_CURSIVE:
- tmpfontname = option_font_cursive;
- break;
- case PLOT_FONT_FAMILY_FANTASY:
- tmpfontname = option_font_fantasy;
- break;
- case NSA_UNICODE_FONT:
- tmpfontname = option_font_unicode;
- break;
- default:
- /* should never get here, but just in case */
- tmpfontname = strdup("{unknown font}");
- break;
- }
- warn_user("CompError",tmpfontname);
- }
-
- if(bname = (char *)GetTagData(OT_BName,0,of[i]->olf_OTagList))
- {
- ofb[i] = OpenOutlineFont(bname,NULL,OFF_OPEN);
- }
- else
- {
- ofb[i] = NULL;
- }
-
- if(iname = (char *)GetTagData(OT_IName,0,of[i]->olf_OTagList))
- {
- ofi[i] = OpenOutlineFont(iname,NULL,OFF_OPEN);
- }
- else
- {
- ofi[i] = NULL;
- }
-
- if(biname = (char *)GetTagData(OT_BIName,0,of[i]->olf_OTagList))
- {
- ofbi[i] = OpenOutlineFont(biname,NULL,OFF_OPEN);
- }
- else
- {
- ofbi[i] = NULL;
- }
- }
- if(deffont) free(deffont);
+ ami_font_list = NewObjList();
}
void ami_close_fonts(void)
{
- int i=0;
-
- for(i=PLOT_FONT_FAMILY_SANS_SERIF;i<=NSA_UNICODE_FONT;i++)
- {
- if(of[i]) CloseOutlineFont(of[i],NULL);
- if(ofb[i]) CloseOutlineFont(ofb[i],NULL);
- if(ofi[i]) CloseOutlineFont(ofi[i],NULL);
- if(ofbi[i]) CloseOutlineFont(ofbi[i],NULL);
- }
+ FreeObjList(ami_font_list);
+ ami_font_list = NULL;
+}
+
+void ami_font_close(struct ami_font_node *node)
+{
+ /* Called from FreeObjList if node type is AMINS_FONT */
+
+ CloseOutlineFont(node->font, NULL);
}
void ami_font_setdevicedpi(int id)
Modified: trunk/netsurf/amiga/font.h
URL: http://source.netsurf-browser.org/trunk/netsurf/amiga/font.h?rev=12264&r1...
==============================================================================
--- trunk/netsurf/amiga/font.h (original)
+++ trunk/netsurf/amiga/font.h Sat Apr 30 14:05:11 2011
@@ -22,8 +22,12 @@
#include "desktop/plotters.h"
#include <graphics/rastport.h>
-ULONG ami_unicode_text(struct RastPort *rp,const char *string,ULONG length,const plot_font_style_t *fstyle,ULONG x,ULONG y);
+struct ami_font_node;
+
+ULONG ami_unicode_text(struct RastPort *rp, const char *string,
+ ULONG length, const plot_font_style_t *fstyle, ULONG x, ULONG y);
void ami_font_setdevicedpi(int id);
void ami_init_fonts(void);
void ami_close_fonts(void);
+void ami_font_close(struct ami_font_node *node);
#endif
Modified: trunk/netsurf/amiga/object.c
URL: http://source.netsurf-browser.org/trunk/netsurf/amiga/object.c?rev=12264&...
==============================================================================
--- trunk/netsurf/amiga/object.c (original)
+++ trunk/netsurf/amiga/object.c Sat Apr 30 14:05:11 2011
@@ -19,6 +19,8 @@
#include <proto/exec.h>
#include <exec/lists.h>
#include <exec/nodes.h>
+#include <memory.h>
+
#include "amiga/object.h"
#include "amiga/schedule.h"
@@ -35,7 +37,7 @@
}
-struct nsObject *AddObject(struct MinList *objlist,ULONG otype)
+struct nsObject *AddObject(struct MinList *objlist, ULONG otype)
{
struct nsObject *dtzo;
@@ -52,6 +54,7 @@
{
Remove((struct Node *)dtzo);
if(dtzo->objstruct && free_obj) FreeVec(dtzo->objstruct);
+ if(dtzo->dtz_Node.ln_Name) free(dtzo->dtz_Node.ln_Name);
FreeVec(dtzo);
dtzo = NULL;
}
@@ -77,6 +80,7 @@
do
{
nnode=(struct nsObject *)GetSucc((struct Node *)node);
+ if(node->Type == AMINS_FONT) ami_font_close(node->objstruct);
DelObject(node);
}while(node=nnode);
Modified: trunk/netsurf/amiga/object.h
URL: http://source.netsurf-browser.org/trunk/netsurf/amiga/object.h?rev=12264&...
==============================================================================
--- trunk/netsurf/amiga/object.h (original)
+++ trunk/netsurf/amiga/object.h Sat Apr 30 14:05:11 2011
@@ -34,19 +34,19 @@
AMINS_HISTORYWINDOW,
AMINS_GUIOPTSWINDOW,
AMINS_PRINTWINDOW,
- AMINS_FETCHER,
+ AMINS_FONT,
};
struct nsObject
{
- struct MinNode dtz_Node;
+ struct Node dtz_Node;
ULONG Type;
void *objstruct;
ULONG objstruct_size;
};
struct MinList *NewObjList(void);
-struct nsObject *AddObject(struct MinList *objlist,ULONG otype);
+struct nsObject *AddObject(struct MinList *objlist, ULONG otype);
void DelObject(struct nsObject *dtzo);
void DelObjectNoFree(struct nsObject *dtzo);
void FreeObjList(struct MinList *objlist);
12 years, 4 months
r12263 chris_y - /trunk/netsurf/amiga/clipboard.c
by netsurf@semichrome.net
Author: chris_y
Date: Sat Apr 30 06:21:14 2011
New Revision: 12263
URL: http://source.netsurf-browser.org?rev=12263&view=rev
Log:
Ensure selection drags to NetSurf text boxes are always UTF-8
Modified:
trunk/netsurf/amiga/clipboard.c
Modified: trunk/netsurf/amiga/clipboard.c
URL: http://source.netsurf-browser.org/trunk/netsurf/amiga/clipboard.c?rev=122...
==============================================================================
--- trunk/netsurf/amiga/clipboard.c (original)
+++ trunk/netsurf/amiga/clipboard.c Sat Apr 30 06:21:14 2011
@@ -1,5 +1,5 @@
/*
- * Copyright 2008-2010 Chris Young <chris(a)unsatisfactorysoftware.co.uk>
+ * Copyright 2008-2011 Chris Young <chris(a)unsatisfactorysoftware.co.uk>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
@@ -42,6 +42,7 @@
#include <datatypes/pictureclass.h>
struct IFFHandle *iffh = NULL;
+bool ami_utf8_clipboard = false; // force UTF-8 in clipboard
bool ami_add_to_clipboard(const char *text, size_t length, bool space);
static bool ami_copy_selection(const char *text, size_t length,
@@ -166,7 +167,7 @@
{
if(!(PushChunk(iffh,ID_FTXT,ID_FORM,IFFSIZE_UNKNOWN)))
{
- if(option_utf8_clipboard)
+ if(option_utf8_clipboard || ami_utf8_clipboard)
{
if(!(PushChunk(iffh,0,ID_CSET,24)))
{
@@ -215,7 +216,7 @@
{
char *buffer;
- if(option_utf8_clipboard)
+ if(option_utf8_clipboard || ami_utf8_clipboard)
{
WriteChunkBytes(iffh,text,length);
}
@@ -346,6 +347,8 @@
if(text_box = ami_text_box_at_point(gwin, &x, &y))
{
+ ami_utf8_clipboard = true;
+
iffh = ami_clipboard_init_internal(1);
if(gui_copy_to_clipboard(s))
@@ -356,6 +359,7 @@
ami_clipboard_free_internal(iffh);
iffh = old_iffh;
+ ami_utf8_clipboard = false;
}
else
{
12 years, 4 months
r12262 chris_y - /trunk/netsurf/amiga/clipboard.c
by netsurf@semichrome.net
Author: chris_y
Date: Sat Apr 30 06:11:34 2011
New Revision: 12262
URL: http://source.netsurf-browser.org?rev=12262&view=rev
Log:
Ensure drags to string gadgets are in local charset
Modified:
trunk/netsurf/amiga/clipboard.c
Modified: trunk/netsurf/amiga/clipboard.c
URL: http://source.netsurf-browser.org/trunk/netsurf/amiga/clipboard.c?rev=122...
==============================================================================
--- trunk/netsurf/amiga/clipboard.c (original)
+++ trunk/netsurf/amiga/clipboard.c Sat Apr 30 06:11:34 2011
@@ -330,6 +330,7 @@
struct box *text_box;
int x;
int y;
+ char *utf8text;
struct ami_text_selection *sel;
struct IFFHandle *old_iffh = iffh;
struct gui_window_2 *gwin = ami_window_at_pointer();
@@ -365,18 +366,22 @@
{
if(sel = ami_selection_to_text(gwin))
{
+ utf8text = ami_utf8_easy(sel->text);
RefreshSetGadgetAttrs((struct Gadget *)gwin->objects[GID_URL],
- gwin->win, NULL, STRINGA_TextVal, sel->text, TAG_DONE);
+ gwin->win, NULL, STRINGA_TextVal, utf8text, TAG_DONE);
FreeVec(sel);
+ ami_utf8_free(utf8text);
}
}
else if(ami_gadget_hit(gwin->objects[GID_SEARCHSTRING], x, y))
{
if(sel = ami_selection_to_text(gwin))
{
+ utf8text = ami_utf8_easy(sel->text);
RefreshSetGadgetAttrs((struct Gadget *)gwin->objects[GID_SEARCHSTRING],
- gwin->win, NULL, STRINGA_TextVal, sel->text, TAG_DONE);
+ gwin->win, NULL, STRINGA_TextVal, utf8text, TAG_DONE);
FreeVec(sel);
+ ami_utf8_free(utf8text);
}
}
else
12 years, 4 months
r12261 chris_y - /trunk/netsurf/amiga/clipboard.c
by netsurf@semichrome.net
Author: chris_y
Date: Sat Apr 30 06:05:47 2011
New Revision: 12261
URL: http://source.netsurf-browser.org?rev=12261&view=rev
Log:
Convert _from_ UTF-8 and translate the converted string, not the original
Modified:
trunk/netsurf/amiga/clipboard.c
Modified: trunk/netsurf/amiga/clipboard.c
URL: http://source.netsurf-browser.org/trunk/netsurf/amiga/clipboard.c?rev=122...
==============================================================================
--- trunk/netsurf/amiga/clipboard.c (original)
+++ trunk/netsurf/amiga/clipboard.c Sat Apr 30 06:05:47 2011
@@ -221,13 +221,13 @@
}
else
{
- buffer = ami_to_utf8_easy(text);
+ buffer = ami_utf8_easy(text);
if(buffer)
{
char *p;
- p = text;
+ p = buffer;
while(*p != '\0')
{
@@ -235,8 +235,9 @@
p++;
}
WriteChunkBytes(iffh, buffer, strlen(buffer));
- }
- ami_utf8_free(buffer);
+
+ ami_utf8_free(buffer);
+ }
}
if(space) WriteChunkBytes(iffh," ",1);
12 years, 4 months
r12260 chris_y - /trunk/netsurf/amiga/clipboard.c
by netsurf@semichrome.net
Author: chris_y
Date: Sat Apr 30 05:54:02 2011
New Revision: 12260
URL: http://source.netsurf-browser.org?rev=12260&view=rev
Log:
Avoid crash if conversion to local charset fails.
Attempt to convert nbsp to normal spaces when converting to local charset for
clipboard
Modified:
trunk/netsurf/amiga/clipboard.c
Modified: trunk/netsurf/amiga/clipboard.c
URL: http://source.netsurf-browser.org/trunk/netsurf/amiga/clipboard.c?rev=122...
==============================================================================
--- trunk/netsurf/amiga/clipboard.c (original)
+++ trunk/netsurf/amiga/clipboard.c Sat Apr 30 05:54:02 2011
@@ -221,8 +221,21 @@
}
else
{
- utf8_to_local_encoding(text,length,&buffer);
- if(buffer) WriteChunkBytes(iffh,buffer,strlen(buffer));
+ buffer = ami_to_utf8_easy(text);
+
+ if(buffer)
+ {
+ char *p;
+
+ p = text;
+
+ while(*p != '\0')
+ {
+ if(*p == 0xa0) *p = 0x20;
+ p++;
+ }
+ WriteChunkBytes(iffh, buffer, strlen(buffer));
+ }
ami_utf8_free(buffer);
}
12 years, 4 months
r12259 chris_y - in /trunk/netsurf/amiga: clipboard.c clipboard.h context_menu.c drag.c
by netsurf@semichrome.net
Author: chris_y
Date: Fri Apr 29 13:15:20 2011
New Revision: 12259
URL: http://source.netsurf-browser.org?rev=12259&view=rev
Log:
Fix DSI when drag saving
Allow selection drags to URL and search gadgets
Modified:
trunk/netsurf/amiga/clipboard.c
trunk/netsurf/amiga/clipboard.h
trunk/netsurf/amiga/context_menu.c
trunk/netsurf/amiga/drag.c
Modified: trunk/netsurf/amiga/clipboard.c
URL: http://source.netsurf-browser.org/trunk/netsurf/amiga/clipboard.c?rev=122...
==============================================================================
--- trunk/netsurf/amiga/clipboard.c (original)
+++ trunk/netsurf/amiga/clipboard.c Fri Apr 29 13:15:20 2011
@@ -21,6 +21,7 @@
#include "desktop/selection.h"
#include "desktop/textinput.h"
+#include "amiga/clipboard.h"
#include "amiga/iff_cset.h"
#include "amiga/options.h"
#include "amiga/gui.h"
@@ -43,6 +44,9 @@
struct IFFHandle *iffh = NULL;
bool ami_add_to_clipboard(const char *text, size_t length, bool space);
+static bool ami_copy_selection(const char *text, size_t length,
+ struct box *box, void *handle, const char *whitespace_text,
+ size_t whitespace_length);
struct IFFHandle *ami_clipboard_init_internal(int unit)
{
@@ -275,11 +279,44 @@
return false;
}
+struct ami_text_selection *ami_selection_to_text(struct gui_window_2 *gwin)
+{
+ struct ami_text_selection *sel;
+
+ sel = AllocVec(sizeof(struct ami_text_selection),
+ MEMF_PRIVATE | MEMF_CLEAR);
+
+ if(sel) selection_traverse(gwin->bw->sel, ami_copy_selection, sel);
+
+ return sel;
+}
+
+static bool ami_copy_selection(const char *text, size_t length,
+ struct box *box, void *handle, const char *whitespace_text,
+ size_t whitespace_length)
+{
+ struct ami_text_selection *sel = handle;
+ int len = length;
+
+ if((length + (sel->length)) > (sizeof(sel->text)))
+ len = sizeof(sel->text) - (sel->length);
+
+ if(len <= 0) return false;
+
+ memcpy((sel->text) + (sel->length), text, len);
+ sel->length += len;
+
+ sel->text[sel->length] = '\0';
+
+ return true;
+}
+
void ami_drag_selection(struct selection *s)
{
struct box *text_box;
- ULONG x;
- ULONG y;
+ int x;
+ int y;
+ struct ami_text_selection *sel;
struct IFFHandle *old_iffh = iffh;
struct gui_window_2 *gwin = ami_window_at_pointer();
@@ -307,7 +344,31 @@
}
else
{
- DisplayBeep(scrn);
+ x = gwin->win->MouseX;
+ y = gwin->win->MouseY;
+
+ if(ami_gadget_hit(gwin->objects[GID_URL], x, y))
+ {
+ if(sel = ami_selection_to_text(gwin))
+ {
+ RefreshSetGadgetAttrs((struct Gadget *)gwin->objects[GID_URL],
+ gwin->win, NULL, STRINGA_TextVal, sel->text, TAG_DONE);
+ FreeVec(sel);
+ }
+ }
+ else if(ami_gadget_hit(gwin->objects[GID_SEARCHSTRING], x, y))
+ {
+ if(sel = ami_selection_to_text(gwin))
+ {
+ RefreshSetGadgetAttrs((struct Gadget *)gwin->objects[GID_SEARCHSTRING],
+ gwin->win, NULL, STRINGA_TextVal, sel->text, TAG_DONE);
+ FreeVec(sel);
+ }
+ }
+ else
+ {
+ DisplayBeep(scrn);
+ }
}
}
Modified: trunk/netsurf/amiga/clipboard.h
URL: http://source.netsurf-browser.org/trunk/netsurf/amiga/clipboard.h?rev=122...
==============================================================================
--- trunk/netsurf/amiga/clipboard.h (original)
+++ trunk/netsurf/amiga/clipboard.h Fri Apr 29 13:15:20 2011
@@ -1,5 +1,5 @@
/*
- * Copyright 2008,2009 Chris Young <chris(a)unsatisfactorysoftware.co.uk>
+ * Copyright 2008-2009, 2011 Chris Young <chris(a)unsatisfactorysoftware.co.uk>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
@@ -23,12 +23,20 @@
struct bitmap;
struct hlcache_handle;
struct selection;
+struct gui_window_2;
+
+struct ami_text_selection
+{
+ char text[1024];
+ int length;
+};
void ami_clipboard_init(void);
void ami_clipboard_free(void);
void ami_drag_selection(struct selection *s);
bool ami_easy_clipboard(char *text);
bool ami_easy_clipboard_bitmap(struct bitmap *bitmap);
+struct ami_text_selection *ami_selection_to_text(struct gui_window_2 *gwin);
#ifdef WITH_NS_SVG
bool ami_easy_clipboard_svg(struct hlcache_handle *c);
#endif
Modified: trunk/netsurf/amiga/context_menu.c
URL: http://source.netsurf-browser.org/trunk/netsurf/amiga/context_menu.c?rev=...
==============================================================================
--- trunk/netsurf/amiga/context_menu.c (original)
+++ trunk/netsurf/amiga/context_menu.c Fri Apr 29 13:15:20 2011
@@ -48,9 +48,6 @@
#include <string.h>
static uint32 ami_context_menu_hook(struct Hook *hook,Object *item,APTR reserved);
-static bool ami_context_menu_copy_selection(const char *text, size_t length,
- struct box *box, void *handle, const char *whitespace_text,
- size_t whitespace_length);
static bool ami_context_menu_history(const struct history *history, int x0, int y0,
int x1, int y1, const struct history_entry *entry, void *user_data);
@@ -84,12 +81,6 @@
struct PopupMenuIFace *IPopupMenu = NULL;
char *ctxmenulab[CMID_LAST];
-struct ami_context_menu_selection
-{
- char text[1024];
- int length;
-};
-
void ami_context_menu_init(void)
{
if(PopupMenuBase = OpenLibrary("popupmenu.class",0))
@@ -584,16 +575,11 @@
case CMID_SELSEARCH:
{
- struct ami_context_menu_selection *sel;
+ struct ami_text_selection *sel;
char *url;
- sel = AllocVec(sizeof(struct ami_context_menu_selection),
- MEMF_PRIVATE | MEMF_CLEAR);
-
- if(sel)
- {
- selection_traverse(gwin->bw->sel, ami_context_menu_copy_selection,
- sel);
+ if(sel = ami_selection_to_text(gwin))
+ {
url = search_web_from_term(sel->text);
browser_window_go(gwin->bw, url, NULL, true);
@@ -605,26 +591,6 @@
}
return itemid;
-}
-
-static bool ami_context_menu_copy_selection(const char *text, size_t length,
- struct box *box, void *handle, const char *whitespace_text,
- size_t whitespace_length)
-{
- struct ami_context_menu_selection *sel = handle;
- int len = length;
-
- if((length + (sel->length)) > (sizeof(sel->text)))
- len = sizeof(sel->text) - (sel->length);
-
- if(len <= 0) return false;
-
- memcpy((sel->text) + (sel->length), text, len);
- sel->length += len;
-
- sel->text[sel->length] = '\0';
-
- return true;
}
static bool ami_context_menu_history(const struct history *history, int x0, int y0,
Modified: trunk/netsurf/amiga/drag.c
URL: http://source.netsurf-browser.org/trunk/netsurf/amiga/drag.c?rev=12259&r1...
==============================================================================
--- trunk/netsurf/amiga/drag.c (original)
+++ trunk/netsurf/amiga/drag.c Fri Apr 29 13:15:20 2011
@@ -111,7 +111,7 @@
ami_drag_icon_close(NULL);
ami_autoscroll = FALSE;
- if(strcmp(option_use_pubscreen,"Workbench") == 0)
+ if(option_use_pubscreen && (strcmp(option_use_pubscreen,"Workbench") == 0))
{
which = WhichWorkbenchObject(NULL,scrn->MouseX,scrn->MouseY,
WBOBJA_Type,&type,
@@ -348,5 +348,5 @@
UnlockLayerInfo(&scrn->LayerInfo);
if(layer) return ami_find_gwin_by_id(layer->Window);
- else return NULL;
-}
+ else return NULL;
+}
12 years, 4 months
r12258 mmu_man - /branches/mmu_man/netsurf-gopher-support/render/gopher.c
by netsurf@semichrome.net
Author: mmu_man
Date: Thu Apr 28 19:20:56 2011
New Revision: 12258
URL: http://source.netsurf-browser.org?rev=12258&view=rev
Log:
Remove commented-out debug output. Change fprintf(stderr) to LOG(()).
Modified:
branches/mmu_man/netsurf-gopher-support/render/gopher.c
Modified: branches/mmu_man/netsurf-gopher-support/render/gopher.c
URL: http://source.netsurf-browser.org/branches/mmu_man/netsurf-gopher-support...
==============================================================================
--- branches/mmu_man/netsurf-gopher-support/render/gopher.c (original)
+++ branches/mmu_man/netsurf-gopher-support/render/gopher.c Thu Apr 28 19:20:56 2011
@@ -99,7 +99,6 @@
const char *p;
unsigned long left;
bool ok;
- /*fprintf(stderr, "%s()\n", __FUNCTION__);*/
data = content__get_source_data(c, &size);
@@ -334,7 +333,6 @@
static bool gopher_generate_title(const char *title, char *buffer, int buffer_length)
{
int error;
- /*fprintf(stderr, "%s(%s, %p, %d)\n", __FUNCTION__, title, buffer, buffer_length);*/
if (title == NULL)
title = "";
@@ -366,7 +364,6 @@
int error;
bool alt_port = false;
char *username = NULL;
- /*fprintf(stderr, "%s(0x%02x '%c', {%s, %s, %s, %s}, %p, %d)\n", __FUNCTION__, type, type, fields[0], fields[1], fields[2], fields[3], buffer, buffer_length);*/
if (fields[3] && strcmp(fields[3], "70"))
alt_port = true;
@@ -514,7 +511,7 @@
nice_text);
break;
default:
- fprintf(stderr, "warning: unknown gopher item type 0x%02x '%c'\n", type, type);
+ LOG(("warning: unknown gopher item type 0x%02x '%c'\n", type, type));
error = snprintf(buffer, buffer_length,
"<a href=\"gopher://%s%s%s/%c%s\">"HTML_LF
"<span class=\"dir\">%s</span><br/>"HTML_LF
@@ -567,13 +564,12 @@
const char *s = *data;
const char *p = *data;
int i;
- /*fprintf(stderr, "%s(, &%d, %p, %d)\n", __FUNCTION__, *size, buffer, buffer_length);*/
for (; *size && *p; p++, (*size)--) {
if (!type) {
type = *p;
if (!type || type == '\n' || type == '\r') {
- fprintf(stderr, "warning: invalid gopher item type 0x%02x\n", type);
+ LOG(("warning: invalid gopher item type 0x%02x\n", type));
}
/* TODO: check it's really alone on its line */
/*
@@ -585,20 +581,18 @@
}
switch (*p) {
case '\n':
- /*fprintf(stderr, "case '\\x%02x':\n", *p);*/
if (field > 0) {
- fprintf(stderr, "warning: underminated gopher item '%c'\n", type);
+ LOG(("warning: underminated gopher item '%c'\n", type));
}
//FALLTHROUGH
case '\r':
- /*fprintf(stderr, "case '\\x%02x':\n", *p);*/
if (*size < 1 || p[1] != '\n') {
- fprintf(stderr, "warning: CR without LF in gopher item '%c'\n", type);
+ LOG(("warning: CR without LF in gopher item '%c'\n", type));
}
//TODO: check gopher://gopher.floodgap.com/1/overbite/dbrowse?pluginm
// (1 extra field ??)
if (field < 3) {
- fprintf(stderr, "warning: underminated gopher item '%c'\n", type);
+ LOG(("warning: underminated gopher item '%c'\n", type));
}
fields[field] = malloc(p - s + 1);
memcpy(fields[field], s, p - s);
@@ -611,7 +605,6 @@
free(fields[i]);
fields[i] = NULL;
}
- /*fprintf(stderr, "ret: row %sok *size=%d\n", ok ? "" : "not ", *size);*/
(*size)--;
p++;
if (*size && *p == '\n') {
@@ -623,9 +616,8 @@
//break;
return ok;
case '\x09':
- /*fprintf(stderr, "case '\\x%02x':\n", *p);*/
if (field >= 4) {
- fprintf(stderr, "warning: extra tab in gopher item '%c'\n", type);
+ LOG(("warning: extra tab in gopher item '%c'\n", type));
break;
}
fields[field] = malloc(p - s + 1);
@@ -663,7 +655,6 @@
"</div>\n"
"</body>\n"
"</html>\n");
- /*fprintf(stderr, "%s(%p, %d)\n", __FUNCTION__, buffer, buffer_length);*/
if (error < 0 || error >= buffer_length)
/* Error or buffer too small */
return false;
12 years, 4 months
r12257 mmu_man - /branches/mmu_man/netsurf-gopher-support/render/gopher.c
by netsurf@semichrome.net
Author: mmu_man
Date: Thu Apr 28 18:59:42 2011
New Revision: 12257
URL: http://source.netsurf-browser.org?rev=12257&view=rev
Log:
Remove some useless includes.
Modified:
branches/mmu_man/netsurf-gopher-support/render/gopher.c
Modified: branches/mmu_man/netsurf-gopher-support/render/gopher.c
URL: http://source.netsurf-browser.org/branches/mmu_man/netsurf-gopher-support...
==============================================================================
--- branches/mmu_man/netsurf-gopher-support/render/gopher.c (original)
+++ branches/mmu_man/netsurf-gopher-support/render/gopher.c Thu Apr 28 18:59:42 2011
@@ -22,34 +22,20 @@
* Content for text/x-gopher-directory (implementation).
*/
-#include <assert.h>
#include <errno.h>
#include <stddef.h>
#include <string.h>
#include <strings.h>
#include <math.h>
-#include <parserutils/input/inputstream.h>
-
#include "content/content_protected.h"
-#include "content/hlcache.h"
-#include "css/css.h"
-#include "css/utils.h"
-#include "desktop/browser.h"
#include "desktop/gui.h"
#include "desktop/options.h"
-#include "desktop/plotters.h"
-#include "desktop/search.h"
-#include "desktop/selection.h"
-#include "render/box.h"
-#include "render/font.h"
#include "render/gopher.h"
#include "utils/http.h"
#include "utils/log.h"
#include "utils/messages.h"
-#include "utils/talloc.h"
#include "utils/utils.h"
-#include "utils/utf8.h"
static char *gen_nice_title(const char *path);
static bool gopher_generate_top(char *buffer, int buffer_length);
12 years, 4 months
r12256 mmu_man - in /branches/mmu_man/netsurf-gopher-support/render: gopher.c gopher.h
by netsurf@semichrome.net
Author: mmu_man
Date: Thu Apr 28 18:48:22 2011
New Revision: 12256
URL: http://source.netsurf-browser.org?rev=12256&view=rev
Log:
Move the render calls to the top of the tile.
Modified:
branches/mmu_man/netsurf-gopher-support/render/gopher.c
branches/mmu_man/netsurf-gopher-support/render/gopher.h
Modified: branches/mmu_man/netsurf-gopher-support/render/gopher.c
URL: http://source.netsurf-browser.org/branches/mmu_man/netsurf-gopher-support...
==============================================================================
--- branches/mmu_man/netsurf-gopher-support/render/gopher.c (original)
+++ branches/mmu_man/netsurf-gopher-support/render/gopher.c Thu Apr 28 18:48:22 2011
@@ -50,6 +50,14 @@
#include "utils/talloc.h"
#include "utils/utils.h"
#include "utils/utf8.h"
+
+static char *gen_nice_title(const char *path);
+static bool gopher_generate_top(char *buffer, int buffer_length);
+static bool gopher_generate_title(const char *title, char *buffer, int buffer_length);
+static bool gopher_generate_row(const char **data, size_t *size,
+ char *buffer, int buffer_length);
+static bool gopher_generate_bottom(char *buffer, int buffer_length);
+
static struct {
char type;
@@ -78,6 +86,71 @@
{ 'p', "image/png"}, /* at least on gopher://namcub.accelera-labs.com/1/pics */
{ 0, NULL }
};
+
+
+/**
+ * Create a CONTENT_GOPHER.
+ */
+
+bool gopher_create(struct content *c, const http_parameter *params)
+{
+ bool ok;
+ ok = html_create(c, params);
+ return ok;
+}
+
+
+/**
+ * Convert a CONTENT_GOPHER for display.
+ */
+
+bool gopher_convert(struct content *c)
+{
+ char *title;
+ char buffer[1024];
+ const char *data;
+ unsigned long size;
+ const char *p;
+ unsigned long left;
+ bool ok;
+ /*fprintf(stderr, "%s()\n", __FUNCTION__);*/
+
+ data = content__get_source_data(c, &size);
+
+ p = data;
+ left = size;
+ if (data == NULL || size == 0)
+ return false;
+
+ if (gopher_generate_bottom(buffer, sizeof(buffer))) {
+ ok = html_process_data(c, buffer, strlen(buffer));
+ if (!ok)
+ return false;
+ }
+ if (gopher_generate_top(buffer, sizeof(buffer))) {
+ ok = html_process_data(c, buffer, strlen(buffer));
+ if (!ok)
+ return false;
+ }
+ title = gen_nice_title(content__get_url(c));
+ if (gopher_generate_title(title, buffer, sizeof(buffer))) {
+ ok = html_process_data(c, buffer, strlen(buffer));
+ if (!ok)
+ return false;
+ }
+ free(title);
+
+ while (gopher_generate_row(&p, &left, buffer, sizeof(buffer))) {
+ ok = html_process_data(c, buffer, strlen(buffer));
+ if (!ok)
+ return false;
+ gui_multitask();
+ }
+
+ /* finally make it HTML so we don't have to bother for other calls */
+ c->type = CONTENT_HTML;
+ return html_convert(c);
+}
static char *html_escape_string(char *str)
@@ -614,70 +687,3 @@
}
-
-
-/**
- * Create a CONTENT_GOPHER.
- */
-
-bool gopher_create(struct content *c, const http_parameter *params)
-{
- bool ok;
- ok = html_create(c, params);
- return ok;
-}
-
-
-/**
- * Convert a CONTENT_GOPHER for display.
- */
-
-bool gopher_convert(struct content *c)
-{
- char *title;
- char buffer[1024];
- const char *data;
- unsigned long size;
- const char *p;
- unsigned long left;
- bool ok;
- /*fprintf(stderr, "%s()\n", __FUNCTION__);*/
-
- data = content__get_source_data(c, &size);
-
- p = data;
- left = size;
- if (data == NULL || size == 0)
- return false;
-
- if (gopher_generate_bottom(buffer, sizeof(buffer))) {
- ok = html_process_data(c, buffer, strlen(buffer));
- if (!ok)
- return false;
- }
- if (gopher_generate_top(buffer, sizeof(buffer))) {
- ok = html_process_data(c, buffer, strlen(buffer));
- if (!ok)
- return false;
- }
- title = gen_nice_title(content__get_url(c));
- if (gopher_generate_title(title, buffer, sizeof(buffer))) {
- ok = html_process_data(c, buffer, strlen(buffer));
- if (!ok)
- return false;
- }
- free(title);
-
- while (gopher_generate_row(&p, &left, buffer, sizeof(buffer))) {
- ok = html_process_data(c, buffer, strlen(buffer));
- if (!ok)
- return false;
- gui_multitask();
- }
-
- /* finally make it HTML so we don't have to bother for other calls */
- c->type = CONTENT_HTML;
- return html_convert(c);
-}
-
-
Modified: branches/mmu_man/netsurf-gopher-support/render/gopher.h
URL: http://source.netsurf-browser.org/branches/mmu_man/netsurf-gopher-support...
==============================================================================
--- branches/mmu_man/netsurf-gopher-support/render/gopher.h (original)
+++ branches/mmu_man/netsurf-gopher-support/render/gopher.h Thu Apr 28 18:48:22 2011
@@ -31,8 +31,6 @@
struct http_parameter;
bool gopher_create(struct content *c, const struct http_parameter *params);
-bool gopher_process_data(struct content *c,
- const char *data, unsigned int size);
bool gopher_convert(struct content *c);
12 years, 4 months
r12255 mmu_man - /branches/mmu_man/netsurf-gopher-support/render/gopher.c
by netsurf@semichrome.net
Author: mmu_man
Date: Thu Apr 28 18:37:43 2011
New Revision: 12255
URL: http://source.netsurf-browser.org?rev=12255&view=rev
Log:
Fix warnings.
Modified:
branches/mmu_man/netsurf-gopher-support/render/gopher.c
Modified: branches/mmu_man/netsurf-gopher-support/render/gopher.c
URL: http://source.netsurf-browser.org/branches/mmu_man/netsurf-gopher-support...
==============================================================================
--- branches/mmu_man/netsurf-gopher-support/render/gopher.c (original)
+++ branches/mmu_man/netsurf-gopher-support/render/gopher.c Thu Apr 28 18:37:43 2011
@@ -83,8 +83,6 @@
static char *html_escape_string(char *str)
{
char *nice_str, *cnv, *tmp;
- char *title;
- int title_length;
if (str == NULL) {
return NULL;
@@ -124,9 +122,10 @@
}
-static char *gen_nice_title(char *path)
-{
- char *nice_path, *cnv, *tmp;
+static char *gen_nice_title(const char *path)
+{
+ const char *tmp;
+ char *nice_path, *cnv;
char *title;
int title_length;
@@ -498,7 +497,7 @@
* gopher_generate_bottom()
*/
-static bool gopher_generate_row(char **data, size_t *size,
+static bool gopher_generate_row(const char **data, size_t *size,
char *buffer, int buffer_length)
{
bool ok = false;
@@ -506,8 +505,8 @@
int field = 0;
/* name, selector, host, port, gopher+ flag */
char *fields[5] = { NULL, NULL, NULL, NULL, NULL };
- char *s = *data;
- char *p = *data;
+ const char *s = *data;
+ const char *p = *data;
int i;
/*fprintf(stderr, "%s(, &%d, %p, %d)\n", __FUNCTION__, *size, buffer, buffer_length);*/
@@ -637,10 +636,10 @@
{
char *title;
char buffer[1024];
- char *data;
+ const char *data;
unsigned long size;
- char *p;
- size_t left;
+ const char *p;
+ unsigned long left;
bool ok;
/*fprintf(stderr, "%s()\n", __FUNCTION__);*/
12 years, 4 months