diff options
author | Chris Young <chris@unsatisfactorysoftware.co.uk> | 2008-10-26 12:25:26 +0000 |
---|---|---|
committer | Chris Young <chris@unsatisfactorysoftware.co.uk> | 2008-10-26 12:25:26 +0000 |
commit | 124899e5bc2b18c93e943950056a7e22318be125 (patch) | |
tree | 817b9c328cc3372bf5e2747f4da53cd17b0a1ebe /amiga | |
parent | 30b09368e7980def81ccfd7b4038225e7ec13ed9 (diff) | |
download | netsurf-124899e5bc2b18c93e943950056a7e22318be125.tar.gz netsurf-124899e5bc2b18c93e943950056a7e22318be125.tar.bz2 |
ARexx menu with items populated from arexx_dir.
svn path=/trunk/netsurf/; revision=5632
Diffstat (limited to 'amiga')
-rwxr-xr-x | amiga/arexx.c | 21 | ||||
-rwxr-xr-x | amiga/dist/NetSurf.guide | 25 | ||||
-rw-r--r-- | amiga/dist/Rexx.info | bin | 0 -> 6206 bytes | |||
-rwxr-xr-x | amiga/gui.c | 31 | ||||
-rwxr-xr-x | amiga/menu.c | 139 | ||||
-rwxr-xr-x | amiga/menu.h | 24 | ||||
-rw-r--r-- | amiga/options.h | 8 |
7 files changed, 233 insertions, 15 deletions
diff --git a/amiga/arexx.c b/amiga/arexx.c index bbd7b9aa8..6a85510e0 100755 --- a/amiga/arexx.c +++ b/amiga/arexx.c @@ -47,7 +47,7 @@ STATIC struct ARexxCmd Commands[] = { NULL, 0, NULL, NULL, 0, NULL, 0, 0, NULL } }; -void ami_arexx_init() +void ami_arexx_init(void) { if(arexx_obj = ARexxObject, AREXX_HostName,"NETSURF", @@ -61,12 +61,17 @@ void ami_arexx_init() } } -void ami_arexx_handle() +void ami_arexx_handle(void) { RA_HandleRexx(arexx_obj); } -void ami_arexx_cleanup() +void ami_arexx_execute(char *script) +{ + IDoMethod(arexx_obj, AM_EXECUTE, script, NULL, NULL, NULL, NULL, NULL); +} + +void ami_arexx_cleanup(void) { if(arexx_obj) DisposeObject(arexx_obj); } @@ -95,7 +100,15 @@ STATIC VOID rx_tofront(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__(( STATIC VOID rx_geturl(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((unused))) { - strcpy(result,curbw->current_content->url); + if(curbw) + { + strcpy(result,curbw->current_content->url); + } + else + { + strcpy(result,"\0"); + } + cmd->ac_Result = result; } diff --git a/amiga/dist/NetSurf.guide b/amiga/dist/NetSurf.guide index bf80975df..5a086ec36 100755 --- a/amiga/dist/NetSurf.guide +++ b/amiga/dist/NetSurf.guide @@ -25,12 +25,12 @@ URL = address of page to open on startup. @endnode @node options "Options file" -The options file is stored in Resources/Options by default. The following options are specific to the Amiga version although there are other relevant options in the file: +The options file is stored in @{"Resources/Options" link Resources/Options/Main} by default. The following options are specific to the Amiga version although there are other relevant options in the file: @{b}url_file@{ub} Path to URL database file @{b}hotlist_file@{ub} Path to Hotlist file @{b}use_workbench@{ub} Open NetSurf in a window on Workbench screen (default is to open a custom screen) -@{b}screen_modeid@{ub} Mode ID for NetSurf's custom screen +@{b}screen_modeid@{ub} Mode ID for NetSurf's custom screen. If not specified, NetSurf will use @{b}window_screen_width@{ub} and @{b}window_screen_height@{ub} to find the best mode. @{b}theme@{ub} Path to theme (default is Resources/Themes/Default - an alternative included theme is Resources/Themes/AISS) @{b}no_iframes@{ub} Disable IFrames @{b}clipboard_write_utf8@{ub} Write UTF-8 strings to the clipboard along with a charset identifier (when this option is 0, NetSurf will convert copied strings to local charset) @@ -42,6 +42,8 @@ The options file is stored in Resources/Options by default. The following optio @{b}new_tab_is_active@{ub} Make new tab the active one @{b}kiosk_mode@{ub} No gadgets @{b}recent_file@{ub} Path to file to store recent history list +@{b}arexx_dir@{ub} Path to ARexx scripts dir +@{b}download_dir@{ub} default download destination (not used yet) @endnode @node arexx "ARexx port" @@ -49,8 +51,25 @@ NetSurf's ARexx port is called NETSURF. Commands are: -@{b}OPEN URL/A@{ub} Opens URL in a new window +@{b}OPEN URL/A,NEW=NEWWINDOW/S@{ub} Opens URL in current window or a new window if NEWWINDOW is specified. @{b}QUIT@{ub} Quits NetSurf +@{b}TOFRONT@{ub} Brings NetSurf's screen to the front +@{b}GETURL@{ub} Puts the URL displayed in the current window/tab into RESULT + +The ARexx menu will be populated with scripts named #?.nsrx in @{"arexx_dir" link options 18}, up to a maximum of 20 entries. The titles of these entries will be the comments field of the file (or the filename if comments field is empty). + + +@{u}OpenURL configuration@{uu} + +Click Add on the Browsers page and fill in the details as follows: +Name: NetSurf +Path: NetSurf %u +ARexx port: NETSURF +Show: +To front: TOFRONT +Open URL: OPEN "%u" +New window: OPEN "%u" NEW + @endnode @node hotlist "Hotlist menu" diff --git a/amiga/dist/Rexx.info b/amiga/dist/Rexx.info Binary files differnew file mode 100644 index 000000000..2cb135722 --- /dev/null +++ b/amiga/dist/Rexx.info diff --git a/amiga/gui.c b/amiga/gui.c index f7e107360..51a48b7b3 100755 --- a/amiga/gui.c +++ b/amiga/gui.c @@ -65,6 +65,7 @@ #include "amiga/context_menu.h" #include "amiga/cookies.h" #include "amiga/clipboard.h" +#include <proto/keymap.h> #ifdef WITH_HUBBUB #include <hubbub/hubbub.h> @@ -101,6 +102,8 @@ struct Device *TimerBase; struct TimerIFace *ITimer; struct Library *PopupMenuBase = NULL; struct PopupMenuIFace *IPopupMenu = NULL; +struct Library *KeymapBase = NULL; +struct KeymapIFace *IKeymap = NULL; struct BitMap *throbber = NULL; ULONG throbber_width,throbber_height,throbber_frames; @@ -183,9 +186,12 @@ void gui_init(int argc, char** argv) IPopupMenu = (struct PopupMenuIFace *)GetInterface(PopupMenuBase,"main",1,NULL); } - filereq = (struct FileRequester *)AllocAslRequest(ASL_FileRequest,NULL); + if(KeymapBase = OpenLibrary("keymap.library",37)) + { + IKeymap = (struct KeymapIFace *)GetInterface(KeymapBase,"main",1,NULL); + } - ami_arexx_init(); + filereq = (struct FileRequester *)AllocAslRequest(ASL_FileRequest,NULL); ami_clipboard_init(); @@ -194,6 +200,7 @@ void gui_init(int argc, char** argv) options_read("Resources/Options"); verbose_log = option_verbose_log; + ami_init_mouse_pointers(); nsscreentitle = ASPrintf("NetSurf %s",netsurf_version); @@ -283,6 +290,9 @@ void gui_init(int argc, char** argv) if((!option_theme) || (option_theme[0] == '\0')) option_theme = (char *)strdup("Resources/Themes/Default"); + if((!option_arexx_dir) || (option_arexx_dir[0] == '\0')) + option_arexx_dir = (char *)strdup("Rexx"); + if(!option_window_width) option_window_width = 800; if(!option_window_height) option_window_height = 600; if(!option_window_screen_width) option_window_screen_width = 800; @@ -310,6 +320,7 @@ void gui_init(int argc, char** argv) } /* end Amiupdate */ + ami_arexx_init(); ami_init_menulabs(); if(option_context_menu) ami_context_menu_init(); @@ -627,7 +638,14 @@ void ami_handle_msg(void) break; case GID_RELOAD: - browser_window_reload(gwin->bw,false); + if(gwin->key_state & BROWSER_MOUSE_MOD_1) + { + browser_window_reload(gwin->bw,true); + } + else + { + browser_window_reload(gwin->bw,false); + } break; case GID_BACK: @@ -689,6 +707,7 @@ void ami_handle_msg(void) storage = result & WMHI_GADGETMASK; GetAttr(WINDOW_InputEvent,gwin->objects[OID_MAIN],(ULONG *)&ie); + switch(storage) { case RAWKEY_CRSRUP: @@ -718,6 +737,9 @@ void ami_handle_msg(void) case 0xe3: // lctrl up gwin->key_state = 0; break; + default: + /*MapRawKey etc */ + break; } break; @@ -1076,6 +1098,9 @@ void gui_quit(void) if(IPopupMenu) DropInterface((struct Interface *)IPopupMenu); if(PopupMenuBase) CloseLibrary(PopupMenuBase); + if(IKeymap) DropInterface((struct Interface *)IKeymap); + if(KeymapBase) CloseLibrary(KeymapBase); + if(ITimer) { DropInterface((struct Interface *)ITimer); diff --git a/amiga/menu.c b/amiga/menu.c index 055bf7652..481438d8c 100755 --- a/amiga/menu.c +++ b/amiga/menu.c @@ -34,9 +34,14 @@ #include "amiga/tree.h" #include "amiga/history.h" #include "amiga/cookies.h" +#include <proto/exec.h> +#include "amiga/arexx.h" + +BOOL menualreadyinit; void ami_menu_scan(struct tree *tree,struct NewMenu *menu); void ami_menu_scan_2(struct tree *tree,struct node *root,WORD *gen,ULONG *item,struct NewMenu *menu); +void ami_menu_arexx_scan(struct NewMenu *menu); void ami_free_menulabs(void) { @@ -79,6 +84,9 @@ void ami_init_menulabs(void) menulab[65] = ami_utf8_easy((char *)messages_get("Settings")); menulab[66] = ami_utf8_easy((char *)messages_get("SnapshotWindow")); menulab[67] = ami_utf8_easy((char *)messages_get("SettingsSave")); + menulab[68] = ami_utf8_easy((char *)messages_get("ARexx")); + menulab[69] = ami_utf8_easy((char *)messages_get("ARexxExecute")); + menulab[70] = NM_BARLABEL; } struct NewMenu *ami_create_menu(ULONG type) @@ -154,6 +162,29 @@ struct NewMenu *ami_create_menu(ULONG type) {NM_TITLE,0,0,0,0,0,}, // settings { NM_ITEM,0,0,0,0,0,}, // snapshot window { NM_ITEM,0,0,0,0,0,}, // save settings + {NM_TITLE,0,0,0,0,0,}, // arexx + { NM_ITEM,0,0,0,0,0,}, // execute arexx + { NM_ITEM,NM_BARLABEL,0,0,0,0,}, + { NM_IGNORE,0,0,0,0,0,}, // ** arexx entry ** + { NM_IGNORE,0,0,0,0,0,}, // ** arexx entry ** + { NM_IGNORE,0,0,0,0,0,}, // ** arexx entry ** + { NM_IGNORE,0,0,0,0,0,}, // ** arexx entry ** + { NM_IGNORE,0,0,0,0,0,}, // ** arexx entry ** + { NM_IGNORE,0,0,0,0,0,}, // ** arexx entry ** + { NM_IGNORE,0,0,0,0,0,}, // ** arexx entry ** + { NM_IGNORE,0,0,0,0,0,}, // ** arexx entry ** + { NM_IGNORE,0,0,0,0,0,}, // ** arexx entry ** + { NM_IGNORE,0,0,0,0,0,}, // ** arexx entry ** + { NM_IGNORE,0,0,0,0,0,}, // ** arexx entry ** + { NM_IGNORE,0,0,0,0,0,}, // ** arexx entry ** + { NM_IGNORE,0,0,0,0,0,}, // ** arexx entry ** + { NM_IGNORE,0,0,0,0,0,}, // ** arexx entry ** + { NM_IGNORE,0,0,0,0,0,}, // ** arexx entry ** + { NM_IGNORE,0,0,0,0,0,}, // ** arexx entry ** + { NM_IGNORE,0,0,0,0,0,}, // ** arexx entry ** + { NM_IGNORE,0,0,0,0,0,}, // ** arexx entry ** + { NM_IGNORE,0,0,0,0,0,}, // ** arexx entry ** + { NM_IGNORE,0,0,0,0,0,}, // ** arexx entry ** { NM_END,0,0,0,0,0,}, }; @@ -176,11 +207,75 @@ struct NewMenu *ami_create_menu(ULONG type) menu[7].nm_Flags = NM_ITEMDISABLED; #endif - ami_menu_scan(hotlist,menu); + if(!menualreadyinit) + { + ami_menu_scan(hotlist,menu); + ami_menu_arexx_scan(menu); + menualreadyinit = TRUE; + } return(menu); } +void ami_menu_arexx_scan(struct NewMenu *menu) +{ + int item = AMI_MENU_AREXX; + BPTR lock = 0; + UBYTE *buffer; + struct ExAllControl *ctrl; + char matchpatt[16]; + LONG cont; + struct ExAllData *ead; + + if(lock = Lock(option_arexx_dir,SHARED_LOCK)) + { + if(buffer = AllocVec(1024,MEMF_PRIVATE | MEMF_CLEAR)) + { + if(ctrl = AllocDosObject(DOS_EXALLCONTROL,NULL)) + { + ctrl->eac_LastKey = 0; + + if(ParsePatternNoCase("#?.nsrx",(char *)&matchpatt,16) != -1) + { + ctrl->eac_MatchString = (char *)&matchpatt; + } + + do + { + cont = ExAll(lock,buffer,1024,ED_COMMENT,ctrl); + if((!cont) && (IoErr() != ERROR_NO_MORE_ENTRIES)) break; + if(!ctrl->eac_Entries) continue; + + for(ead = (struct ExAllData *)buffer; ead; ead = ead->ed_Next) + { + if(item >= AMI_MENU_AREXX_MAX) continue; + if(EAD_IS_FILE(ead)) + { + menu[item].nm_Type = NM_ITEM; + if(ead->ed_Comment[0] != '\0') + { + menulab[item] = (char *)strdup(ead->ed_Comment); + } + else + { + menulab[item] = (char *)strdup(ead->ed_Name); + } + + menu[item].nm_Label = menulab[item]; + menu[item].nm_UserData = (char *)strdup(ead->ed_Name); + + item++; + } + } + }while(cont); + FreeDosObject(DOS_EXALLCONTROL,ctrl); + } + FreeVec(buffer); + } + UnLock(lock); + } +} + void ami_menu_scan(struct tree *tree,struct NewMenu *menu) { struct node *root = tree->root->child; @@ -224,7 +319,7 @@ void ami_menu_scan_2(struct tree *tree,struct node *root,WORD *gen,ULONG *item,s if(strcmp(element->text,"--")) { - menulab[*item] = ami_utf8_easy(element->text); + menulab[*item] = ami_utf8_easy((char *)element->text); } else { @@ -234,7 +329,7 @@ void ami_menu_scan_2(struct tree *tree,struct node *root,WORD *gen,ULONG *item,s menu[*item].nm_Label = menulab[*item]; element = tree_find_element(node, TREE_ELEMENT_URL); - if(element && element->text) menu[*item].nm_UserData = element->text; + if(element && element->text) menu[*item].nm_UserData = (void *)element->text; if(node->folder && (!node->child)) menu[*item].nm_Flags = NM_ITEMDISABLED; @@ -260,6 +355,7 @@ void ami_menupick(ULONG code,struct gui_window_2 *gwin,struct MenuItem *item) subnum = SUBNUM(code); bool openwin=false; bool opentab=true; + char *temp; if(option_force_tabs) { @@ -433,5 +529,42 @@ void ami_menupick(ULONG code,struct gui_window_2 *gwin,struct MenuItem *item) break; } break; + + case 5: // arexx + switch(itemnum) + { + case 0: // execute arexx + if(AslRequestTags(filereq, + ASLFR_TitleText,messages_get("NetSurf"), + ASLFR_Screen,scrn, + ASLFR_DoSaveMode,FALSE, + ASLFR_InitialDrawer,option_arexx_dir, + ASLFR_InitialPattern,"#?.nsrx", + TAG_DONE)) + { + if(temp = AllocVec(1024,MEMF_PRIVATE | MEMF_CLEAR)) + { + strlcpy(temp,filereq->fr_Drawer,1024); + AddPart(temp,filereq->fr_File,1024); + ami_arexx_execute(temp); + FreeVec(temp); + } + } + break; + + default: // arexx menu items + if(GTMENUITEM_USERDATA(item)) + { + if(temp = AllocVec(1024,MEMF_PRIVATE | MEMF_CLEAR)) + { + strcpy(temp,option_arexx_dir); + AddPart(temp,GTMENUITEM_USERDATA(item),1024); + ami_arexx_execute(temp); + FreeVec(temp); + } + } + break; + } + break; } } diff --git a/amiga/menu.h b/amiga/menu.h index 0726842c6..d475a3f09 100755 --- a/amiga/menu.h +++ b/amiga/menu.h @@ -22,10 +22,32 @@ #include "amiga/gui.h" #include <intuition/intuition.h> +/* Number of hotlist items, menu structure needs to be changed in ami_create_menu() + * if this value is changed. */ #define AMI_HOTLIST_ITEMS 40 -#define AMI_MENU_MAX 28 + AMI_HOTLIST_ITEMS + +/* Maximum number of menu items - first value is number of static items + * (ie. everything not intially defined as NM_IGNORE) */ +#define AMI_MENU_MAX 31 + AMI_HOTLIST_ITEMS + +/* Where the hotlist entries start */ #define AMI_MENU_HOTLIST 25 + +/* Where the hotlist entries end */ #define AMI_MENU_HOTLIST_MAX AMI_MENU_HOTLIST+AMI_HOTLIST_ITEMS + +/* Number of ARexx menu items. menu structure in ami_create_menu() needs to be + * changed if this value is modified. */ +#define AMI_MENU_AREXX_ITEMS 20 + +/* Where the ARexx menu items start. ARexx menu items are right at the end... + * for now, at least. We can get away with AMI_MENU_MAX falling short as it is + * only used for freeing the UTF-8 converted menu labels */ +#define AMI_MENU_AREXX AMI_MENU_MAX + +/* Where the ARexx menu items end (incidentally this is the real AMI_MENU_MAX) */ +#define AMI_MENU_AREXX_MAX AMI_MENU_AREXX+AMI_MENU_AREXX_ITEMS + char *menulab[AMI_MENU_MAX+1]; struct NewMenu *ami_create_menu(ULONG type); diff --git a/amiga/options.h b/amiga/options.h index 74fd76ca7..0efef1896 100644 --- a/amiga/options.h +++ b/amiga/options.h @@ -36,6 +36,8 @@ extern bool option_force_tabs; extern bool option_new_tab_active; extern bool option_kiosk_mode; extern char *option_recent_file; +extern char *option_arexx_dir; +extern char *option_download_dir; #define EXTRA_OPTION_DEFINE \ bool option_verbose_log = false; \ @@ -54,6 +56,8 @@ bool option_force_tabs = false; \ bool option_new_tab_active = false; \ bool option_kiosk_mode = false; \ char *option_recent_file = 0; \ +char *option_arexx_dir = 0; \ +char *option_download_dir = 0; \ #define EXTRA_OPTION_TABLE \ { "verbose_log", OPTION_BOOL, &option_verbose_log}, \ @@ -71,5 +75,7 @@ char *option_recent_file = 0; \ { "always_open_tabs", OPTION_BOOL, &option_force_tabs}, \ { "new_tab_is_active", OPTION_BOOL, &option_new_tab_active}, \ { "kiosk_mode", OPTION_BOOL, &option_kiosk_mode}, \ -{ "recent_file", OPTION_STRING, &option_recent_file }, +{ "recent_file", OPTION_STRING, &option_recent_file }, \ +{ "arexx_dir", OPTION_STRING, &option_arexx_dir }, \ +{ "download_dir", OPTION_STRING, &option_download_dir }, #endif |