mirror of
https://github.com/netsurf-browser/netsurf
synced 2025-01-23 19:02:07 +03:00
Merge branch 'master' of git://git.netsurf-browser.org/netsurf
This commit is contained in:
commit
e7e914b624
110
amiga/gui.c
110
amiga/gui.c
@ -113,6 +113,7 @@
|
||||
#include <proto/bevel.h>
|
||||
#include <proto/bitmap.h>
|
||||
#include <proto/button.h>
|
||||
#include <proto/chooser.h>
|
||||
#include <proto/clicktab.h>
|
||||
#include <proto/layout.h>
|
||||
#include <proto/space.h>
|
||||
@ -122,6 +123,7 @@
|
||||
|
||||
#include <classes/window.h>
|
||||
#include <gadgets/button.h>
|
||||
#include <gadgets/chooser.h>
|
||||
#include <gadgets/clicktab.h>
|
||||
#include <gadgets/layout.h>
|
||||
#include <gadgets/scroller.h>
|
||||
@ -197,8 +199,6 @@ void ami_try_quit(void);
|
||||
void ami_quit_netsurf_delayed(void);
|
||||
Object *ami_gui_splash_open(void);
|
||||
void ami_gui_splash_close(Object *win_obj);
|
||||
static uint32 ami_set_search_ico_render_hook(struct Hook *hook, APTR space,
|
||||
struct gpRender *msg);
|
||||
static uint32 ami_set_favicon_render_hook(struct Hook *hook, APTR space,
|
||||
struct gpRender *msg);
|
||||
static uint32 ami_set_throbber_render_hook(struct Hook *hook, APTR space,
|
||||
@ -1786,6 +1786,11 @@ void ami_handle_msg(void)
|
||||
search_web_select_provider(-1);
|
||||
break;
|
||||
|
||||
case GID_SEARCH_ICON:
|
||||
GetAttr(CHOOSER_Selected, gwin->objects[GID_SEARCH_ICON], (ULONG *)&storage);
|
||||
search_web_select_provider(storage);
|
||||
break;
|
||||
|
||||
case GID_SEARCHSTRING:
|
||||
{
|
||||
nserror ret;
|
||||
@ -3241,9 +3246,6 @@ gui_window_create(struct browser_window *bw,
|
||||
g->shared->scrollerhook.h_Entry = (void *)ami_scroller_hook;
|
||||
g->shared->scrollerhook.h_Data = g->shared;
|
||||
|
||||
g->shared->search_ico_hook.h_Entry = (void *)ami_set_search_ico_render_hook;
|
||||
g->shared->search_ico_hook.h_Data = g->shared;
|
||||
|
||||
g->shared->favicon_hook.h_Entry = (void *)ami_set_favicon_render_hook;
|
||||
g->shared->favicon_hook.h_Data = g->shared;
|
||||
|
||||
@ -3278,6 +3280,9 @@ gui_window_create(struct browser_window *bw,
|
||||
TAG_DONE);
|
||||
AddTail(&g->shared->tab_list,g->tab_node);
|
||||
|
||||
g->shared->web_search_list = ami_gui_opts_websearch();
|
||||
g->shared->search_bm = NULL;
|
||||
|
||||
g->shared->tabs=1;
|
||||
g->shared->next_tab=1;
|
||||
|
||||
@ -3387,12 +3392,12 @@ gui_window_create(struct browser_window *bw,
|
||||
}
|
||||
|
||||
g->shared->objects[OID_MAIN] = WindowObject,
|
||||
WA_ScreenTitle,nsscreentitle,
|
||||
WA_Activate, TRUE,
|
||||
WA_DepthGadget, TRUE,
|
||||
WA_DragBar, TRUE,
|
||||
WA_CloseGadget, TRUE,
|
||||
WA_SizeGadget, TRUE,
|
||||
WA_ScreenTitle,nsscreentitle,
|
||||
WA_Activate, TRUE,
|
||||
WA_DepthGadget, TRUE,
|
||||
WA_DragBar, TRUE,
|
||||
WA_CloseGadget, TRUE,
|
||||
WA_SizeGadget, TRUE,
|
||||
WA_Top,cury,
|
||||
WA_Left,curx,
|
||||
WA_Width,curw,
|
||||
@ -3401,12 +3406,12 @@ gui_window_create(struct browser_window *bw,
|
||||
WA_ReportMouse,TRUE,
|
||||
refresh_mode, TRUE,
|
||||
WA_SizeBBottom, TRUE,
|
||||
WA_IDCMP, IDCMP_MENUPICK | IDCMP_MOUSEMOVE |
|
||||
IDCMP_MOUSEBUTTONS | IDCMP_NEWSIZE |
|
||||
IDCMP_RAWKEY | idcmp_sizeverify |
|
||||
IDCMP_GADGETUP | IDCMP_IDCMPUPDATE |
|
||||
IDCMP_REFRESHWINDOW |
|
||||
IDCMP_ACTIVEWINDOW | IDCMP_EXTENDEDMOUSE,
|
||||
WA_IDCMP, IDCMP_MENUPICK | IDCMP_MOUSEMOVE |
|
||||
IDCMP_MOUSEBUTTONS | IDCMP_NEWSIZE |
|
||||
IDCMP_RAWKEY | idcmp_sizeverify |
|
||||
IDCMP_GADGETUP | IDCMP_IDCMPUPDATE |
|
||||
IDCMP_REFRESHWINDOW |
|
||||
IDCMP_ACTIVEWINDOW | IDCMP_EXTENDEDMOUSE,
|
||||
WINDOW_IconifyGadget, iconifygadget,
|
||||
WINDOW_NewMenu, g->shared->menu,
|
||||
WINDOW_MenuUserData, WGUD_HOOK,
|
||||
@ -3419,8 +3424,8 @@ gui_window_create(struct browser_window *bw,
|
||||
WINDOW_BuiltInScroll, TRUE,
|
||||
WINDOW_GadgetHelp, TRUE,
|
||||
WINDOW_UserData, g->shared,
|
||||
WINDOW_ParentGroup, g->shared->objects[GID_MAIN] = VGroupObject,
|
||||
LAYOUT_SpaceOuter, TRUE,
|
||||
WINDOW_ParentGroup, g->shared->objects[GID_MAIN] = VGroupObject,
|
||||
LAYOUT_SpaceOuter, TRUE,
|
||||
LAYOUT_AddChild, g->shared->objects[GID_TOOLBARLAYOUT] = HGroupObject,
|
||||
LAYOUT_VertAlignment, LALIGN_CENTER,
|
||||
LAYOUT_AddChild, g->shared->objects[GID_BACK] = ButtonObject,
|
||||
@ -3532,13 +3537,13 @@ gui_window_create(struct browser_window *bw,
|
||||
LAYOUT_WeightBar, TRUE,
|
||||
LAYOUT_AddChild, HGroupObject,
|
||||
LAYOUT_VertAlignment, LALIGN_CENTER,
|
||||
LAYOUT_AddChild, g->shared->objects[GID_SEARCH_ICON] = SpaceObject,
|
||||
LAYOUT_AddChild, g->shared->objects[GID_SEARCH_ICON] = ChooserObject,
|
||||
GA_ID, GID_SEARCH_ICON,
|
||||
SPACE_MinWidth, 16,
|
||||
SPACE_MinHeight, 16,
|
||||
SPACE_Transparent, FALSE,
|
||||
SPACE_RenderHook, &g->shared->search_ico_hook,
|
||||
SpaceEnd,
|
||||
GA_RelVerify, TRUE,
|
||||
CHOOSER_DropDown, TRUE,
|
||||
CHOOSER_Labels, g->shared->web_search_list,
|
||||
CHOOSER_MaxLabels, 40, /* Same as options GUI */
|
||||
ChooserEnd,
|
||||
CHILD_WeightedWidth,0,
|
||||
CHILD_WeightedHeight,0,
|
||||
LAYOUT_AddChild, g->shared->objects[GID_SEARCHSTRING] =StringObject,
|
||||
@ -3746,8 +3751,6 @@ gui_window_create(struct browser_window *bw,
|
||||
|
||||
if(locked_screen) UnlockPubScreen(NULL,scrn);
|
||||
|
||||
/* set web search provider */
|
||||
search_web_select_provider(nsoption_int(search_provider));
|
||||
refresh_search_ico = TRUE;
|
||||
|
||||
ScreenToFront(scrn);
|
||||
@ -3912,6 +3915,9 @@ static void gui_window_destroy(struct gui_window *g)
|
||||
DisposeObject(g->shared->objects[GID_FAVE_ADD]);
|
||||
DisposeObject(g->shared->objects[GID_FAVE_RMV]);
|
||||
|
||||
ami_gui_opts_websearch_free(g->shared->web_search_list);
|
||||
if(g->shared->search_bm) DisposeObject(g->shared->search_bm);
|
||||
|
||||
ami_free_menulabs(g->shared);
|
||||
free(g->shared->wintitle);
|
||||
ami_utf8_free(g->shared->status);
|
||||
@ -4678,57 +4684,27 @@ static nserror gui_search_web_provider_update(const char *provider_name,
|
||||
|
||||
if(node->Type == AMINS_WINDOW)
|
||||
{
|
||||
GetAttr(SPACE_AreaBox, gwin->objects[GID_SEARCH_ICON], (ULONG *)&bbox);
|
||||
if(gwin->search_bm != NULL)
|
||||
DisposeObject(gwin->search_bm);
|
||||
|
||||
gwin->search_bm = BitMapObject,
|
||||
BITMAP_Screen, scrn,
|
||||
BITMAP_Width, 16,
|
||||
BITMAP_Height, 16,
|
||||
BITMAP_BitMap, bm,
|
||||
BitMapEnd;
|
||||
|
||||
RefreshSetGadgetAttrs((struct Gadget *)gwin->objects[GID_SEARCH_ICON],
|
||||
gwin->win, NULL,
|
||||
GA_HintInfo, provider_name,
|
||||
GA_Image, gwin->search_bm,
|
||||
TAG_DONE);
|
||||
|
||||
EraseRect(gwin->win->RPort, bbox->Left, bbox->Top,
|
||||
bbox->Left+16, bbox->Top+16);
|
||||
|
||||
if(bm)
|
||||
{
|
||||
ULONG tag, tag_data, minterm;
|
||||
|
||||
if(ami_plot_screen_is_palettemapped() == false) {
|
||||
tag = BLITA_UseSrcAlpha;
|
||||
tag_data = !ico_bitmap->opaque;
|
||||
minterm = 0xc0;
|
||||
} else {
|
||||
tag = BLITA_MaskPlane;
|
||||
tag_data = (ULONG)ami_bitmap_get_mask(ico_bitmap, 16, 16, bm);
|
||||
minterm = (ABC|ABNC|ANBC);
|
||||
}
|
||||
|
||||
BltBitMapTags(BLITA_SrcX, 0,
|
||||
BLITA_SrcY, 0,
|
||||
BLITA_DestX, bbox->Left,
|
||||
BLITA_DestY, bbox->Top,
|
||||
BLITA_Width, 16,
|
||||
BLITA_Height, 16,
|
||||
BLITA_Source, bm,
|
||||
BLITA_Dest, gwin->win->RPort,
|
||||
BLITA_SrcType, BLITT_BITMAP,
|
||||
BLITA_DestType, BLITT_RASTPORT,
|
||||
BLITA_Minterm, minterm,
|
||||
tag, tag_data,
|
||||
TAG_DONE);
|
||||
}
|
||||
}
|
||||
} while(node = nnode);
|
||||
|
||||
return NSERROR_OK;
|
||||
}
|
||||
|
||||
static uint32 ami_set_search_ico_render_hook(struct Hook *hook, APTR space,
|
||||
struct gpRender *msg)
|
||||
{
|
||||
refresh_search_ico = TRUE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static uint32 ami_set_throbber_render_hook(struct Hook *hook, APTR space,
|
||||
struct gpRender *msg)
|
||||
{
|
||||
|
@ -111,6 +111,8 @@ struct gui_window_2 {
|
||||
ULONG hotlist_items;
|
||||
char *hotlist_toolbar_lab[AMI_GUI_TOOLBAR_MAX];
|
||||
struct List hotlist_toolbar_list;
|
||||
struct List *web_search_list;
|
||||
Object *search_bm;
|
||||
char *svbuffer;
|
||||
char *status;
|
||||
char *wintitle;
|
||||
@ -120,7 +122,6 @@ struct gui_window_2 {
|
||||
BOOL rmbtrapped;
|
||||
struct AppIcon *appicon; /* iconify appicon */
|
||||
struct DiskObject *dobj; /* iconify appicon */
|
||||
struct Hook search_ico_hook;
|
||||
struct Hook favicon_hook;
|
||||
struct Hook throbber_hook;
|
||||
gui_drag_type drag_op;
|
||||
|
@ -216,10 +216,7 @@ CONST_STRPTR nativebmopts[OPTS_MAX_NATIVEBM];
|
||||
CONST_STRPTR ditheropts[OPTS_MAX_DITHER];
|
||||
CONST_STRPTR fontopts[6];
|
||||
CONST_STRPTR gadlab[OPTS_LAST];
|
||||
STRPTR *websearch_list;
|
||||
|
||||
STRPTR *ami_gui_opts_websearch(void);
|
||||
void ami_gui_opts_websearch_free(STRPTR *websearchlist);
|
||||
struct List *websearch_list;
|
||||
|
||||
void ami_gui_opts_setup(void)
|
||||
{
|
||||
@ -1312,7 +1309,7 @@ void ami_gui_opts_open(void)
|
||||
GA_ID, GID_OPTS_SEARCH_PROV,
|
||||
GA_RelVerify, TRUE,
|
||||
CHOOSER_PopUp, TRUE,
|
||||
CHOOSER_LabelArray, websearch_list,
|
||||
CHOOSER_Labels, websearch_list,
|
||||
CHOOSER_Selected, nsoption_int(search_provider),
|
||||
CHOOSER_MaxLabels, 40,
|
||||
ChooserEnd,
|
||||
@ -2118,39 +2115,41 @@ BOOL ami_gui_opts_event(void)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
STRPTR *ami_gui_opts_websearch(void)
|
||||
struct List *ami_gui_opts_websearch(void)
|
||||
{
|
||||
char buf[300];
|
||||
ULONG ref = 0;
|
||||
STRPTR *websearchlist;
|
||||
struct List *list;
|
||||
struct Node *node;
|
||||
const char *name;
|
||||
int iter;
|
||||
|
||||
websearchlist = AllocVecTagList(200, NULL); /* NB: Was not MEMF_PRIVATE */
|
||||
list = AllocVecTagList(sizeof(struct List), NULL);
|
||||
NewList(list);
|
||||
|
||||
if (nsoption_charp(search_engines_file) == NULL) return websearchlist;
|
||||
if (nsoption_charp(search_engines_file) == NULL) return list;
|
||||
|
||||
FILE *f = fopen(nsoption_charp(search_engines_file), "r");
|
||||
if (f == NULL) return websearchlist;
|
||||
|
||||
while (fgets(buf, sizeof(buf), f) != NULL) {
|
||||
if (buf[0] == '\0') continue;
|
||||
buf[strlen(buf)-1] = '\0';
|
||||
websearchlist[ref] = strdup(strtok(buf, "|"));
|
||||
ref++;
|
||||
for (iter = search_web_iterate_providers(0, &name);
|
||||
iter != -1;
|
||||
iter = search_web_iterate_providers(iter, &name)) {
|
||||
node = AllocChooserNode(CNA_Text, name, TAG_DONE);
|
||||
AddTail(list, node);
|
||||
}
|
||||
fclose(f);
|
||||
websearchlist[ref] = NULL;
|
||||
|
||||
return websearchlist;
|
||||
return list;
|
||||
}
|
||||
|
||||
void ami_gui_opts_websearch_free(STRPTR *websearchlist)
|
||||
void ami_gui_opts_websearch_free(struct List *websearchlist)
|
||||
{
|
||||
ULONG ref = 0;
|
||||
struct Node *node;
|
||||
struct Node *nnode;
|
||||
|
||||
while (websearchlist[ref] != NULL) {
|
||||
free(websearchlist[ref]);
|
||||
ref++;
|
||||
}
|
||||
if(IsListEmpty(websearchlist)) return;
|
||||
node = GetHead(websearchlist);
|
||||
|
||||
do {
|
||||
nnode = GetSucc(node);
|
||||
Remove(node);
|
||||
} while(node = nnode);
|
||||
|
||||
FreeVec(websearchlist);
|
||||
}
|
||||
|
||||
|
@ -18,9 +18,15 @@
|
||||
|
||||
#ifndef AMIGA_GUI_OPTIONS_H
|
||||
#define AMIGA_GUI_OPTIONS_H
|
||||
/* Prefs GUI control */
|
||||
void ami_gui_opts_open(void);
|
||||
BOOL ami_gui_opts_event(void);
|
||||
void ami_gui_opts_close(void);
|
||||
|
||||
/* Web search list */
|
||||
struct List *ami_gui_opts_websearch(void);
|
||||
void ami_gui_opts_websearch_free(struct List *websearchlist);
|
||||
|
||||
char *current_user_options;
|
||||
#endif
|
||||
|
||||
|
@ -287,11 +287,24 @@ static nserror utf8_from_local(const char *string,
|
||||
return NSERROR_OK;
|
||||
}
|
||||
|
||||
|
||||
static bool nsfont_width(const plot_font_style_t *fstyle,
|
||||
const char *string, size_t length,
|
||||
int *width)
|
||||
{
|
||||
*width = FB_FONT_WIDTH * utf8_bounded_length(string, length);
|
||||
size_t nxtchr = 0;
|
||||
|
||||
*width = 0;
|
||||
while (nxtchr < length) {
|
||||
uint32_t ucs4;
|
||||
ucs4 = utf8_to_ucs4(string + nxtchr, length - nxtchr);
|
||||
if (codepoint_displayable(ucs4)) {
|
||||
*width += FB_FONT_WIDTH;
|
||||
}
|
||||
|
||||
nxtchr = utf8_next(string, length, nxtchr);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -315,10 +328,15 @@ static bool nsfont_position_in_string(const plot_font_style_t *fstyle,
|
||||
int x_pos = 0;
|
||||
|
||||
while (nxtchr < length) {
|
||||
uint32_t ucs4;
|
||||
if (abs(x_pos - x) <= (FB_FONT_WIDTH / 2))
|
||||
break;
|
||||
|
||||
x_pos += FB_FONT_WIDTH;
|
||||
ucs4 = utf8_to_ucs4(string + nxtchr, length - nxtchr);
|
||||
if (codepoint_displayable(ucs4)) {
|
||||
x_pos += FB_FONT_WIDTH;
|
||||
}
|
||||
|
||||
nxtchr = utf8_next(string, length, nxtchr);
|
||||
}
|
||||
|
||||
@ -363,13 +381,18 @@ static bool nsfont_split(const plot_font_style_t *fstyle,
|
||||
|
||||
*actual_x = 0;
|
||||
while (nxtchr < length) {
|
||||
uint32_t ucs4;
|
||||
|
||||
if (string[nxtchr] == ' ') {
|
||||
last_space_x = *actual_x;
|
||||
last_space_idx = nxtchr;
|
||||
}
|
||||
|
||||
*actual_x += FB_FONT_WIDTH;
|
||||
ucs4 = utf8_to_ucs4(string + nxtchr, length - nxtchr);
|
||||
if (codepoint_displayable(ucs4)) {
|
||||
*actual_x += FB_FONT_WIDTH;
|
||||
}
|
||||
|
||||
if (*actual_x > x && last_space_idx != 0) {
|
||||
/* string has exceeded available width and we've
|
||||
* found a space; return previous space */
|
||||
|
@ -19,6 +19,8 @@
|
||||
#ifndef NETSURF_FB_FONT_INTERNAL_H
|
||||
#define NETSURF_FB_FONT_INTERNAL_H
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
struct fb_font_desc {
|
||||
const char *name;
|
||||
int width, height, pitch;
|
||||
@ -39,5 +41,8 @@ enum fb_font_style fb_get_font_style(const plot_font_style_t *fstyle);
|
||||
|
||||
const uint8_t * fb_get_glyph(uint32_t ucs4, enum fb_font_style style);
|
||||
|
||||
#define codepoint_displayable(u) \
|
||||
(!(u >= 0x200b && u <= 0x200f))
|
||||
|
||||
#endif /* NETSURF_FB_FONT_INTERNAL_H */
|
||||
|
||||
|
@ -140,6 +140,9 @@ static bool framebuffer_plot_text(int x, int y, const char *text, size_t length,
|
||||
ucs4 = utf8_to_ucs4(text + nxtchr, length - nxtchr);
|
||||
nxtchr = utf8_next(text, length, nxtchr);
|
||||
|
||||
if (!codepoint_displayable(ucs4))
|
||||
continue;
|
||||
|
||||
loc.x0 = x;
|
||||
loc.y0 = y;
|
||||
loc.x1 = loc.x0 + FB_FONT_WIDTH;
|
||||
|
Loading…
Reference in New Issue
Block a user