summaryrefslogtreecommitdiff
path: root/amiga
diff options
context:
space:
mode:
Diffstat (limited to 'amiga')
-rwxr-xr-xamiga/arexx.c207
-rwxr-xr-xamiga/dist/NetSurf.guide52
-rw-r--r--amiga/dist/Rexx/ShowTitles.nsrx18
3 files changed, 226 insertions, 51 deletions
diff --git a/amiga/arexx.c b/amiga/arexx.c
index 1be7b452b..e7b31dd65 100755
--- a/amiga/arexx.c
+++ b/amiga/arexx.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2008-9 Chris Young <chris@unsatisfactorysoftware.co.uk>
+ * Copyright 2008-2010 Chris Young <chris@unsatisfactorysoftware.co.uk>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
@@ -21,12 +21,16 @@
#include <string.h>
#include <proto/intuition.h>
#include "desktop/browser.h"
+#include "desktop/history_core.h"
#include "amiga/gui.h"
#include <proto/dos.h>
#include <proto/exec.h>
#include "amiga/download.h"
#include "amiga/options.h"
+#include <proto/clicktab.h>
+#include <gadgets/clicktab.h>
+
const char * const verarexx;
const int verver;
const int verrev;
@@ -47,7 +51,8 @@ enum
RX_BACK,
RX_FORWARD,
RX_HOME,
- RX_RELOAD
+ RX_RELOAD,
+ RX_WINDOWS
};
STATIC char result[100];
@@ -64,21 +69,23 @@ STATIC VOID rx_back(struct ARexxCmd *, struct RexxMsg *);
STATIC VOID rx_forward(struct ARexxCmd *, struct RexxMsg *);
STATIC VOID rx_home(struct ARexxCmd *, struct RexxMsg *);
STATIC VOID rx_reload(struct ARexxCmd *, struct RexxMsg *);
+STATIC VOID rx_windows(struct ARexxCmd *, struct RexxMsg *);
STATIC struct ARexxCmd Commands[] =
{
- {"OPEN",RX_OPEN,rx_open,"URL/A,NEW=NEWWINDOW/S,SAVEAS/K", 0, NULL, 0, 0, NULL },
+ {"OPEN",RX_OPEN,rx_open,"URL/A,NEW=NEWWINDOW/S,NEWTAB/S,SAVEAS/K,WINDOW/K/N,TAB/K/N", 0, NULL, 0, 0, NULL },
{"QUIT",RX_QUIT,rx_quit,NULL, 0, NULL, 0, 0, NULL },
{"TOFRONT",RX_TOFRONT,rx_tofront,NULL, 0, NULL, 0, 0, NULL },
- {"GETURL",RX_GETURL,rx_geturl,NULL, 0, NULL, 0, 0, NULL },
- {"GETTITLE",RX_GETTITLE,rx_gettitle,NULL, 0, NULL, 0, 0, NULL },
+ {"GETURL",RX_GETURL,rx_geturl, "WINDOW/K/N,TAB/K/N", 0, NULL, 0, 0, NULL },
+ {"GETTITLE",RX_GETTITLE,rx_gettitle, "WINDOW/K/N,TAB/K/N", 0, NULL, 0, 0, NULL },
{"VERSION",RX_VERSION,rx_version,"VERSION/N,SVN=REVISION/N,RELEASE/S", 0, NULL, 0, 0, NULL },
- {"SAVE",RX_SAVE,rx_save,"FILENAME/A", 0, NULL, 0, 0, NULL },
+ {"SAVE",RX_SAVE,rx_save,"FILENAME/A,WINDOW/K/N,TAB/K/N", 0, NULL, 0, 0, NULL },
{"GETSCREENNAME",RX_PUBSCREEN,rx_pubscreen,NULL, 0, NULL, 0, 0, NULL },
- {"BACK", RX_BACK, rx_back, "WINDOW/K/N, TAB/K/N", 0, NULL, 0, 0, NULL },
- {"FORWARD", RX_FORWARD, rx_forward, "WINDOW/K/N, TAB/K/N", 0, NULL, 0, 0, NULL },
- {"HOME", RX_HOME, rx_home, "WINDOW/K/N, TAB/K/N", 0, NULL, 0, 0, NULL },
- {"RELOAD", RX_RELOAD, rx_reload, "FORCE/S, WINDOW/K/N, TAB/K/N", 0, NULL, 0, 0, NULL },
+ {"BACK", RX_BACK, rx_back, "WINDOW/K/N,TAB/K/N", 0, NULL, 0, 0, NULL },
+ {"FORWARD", RX_FORWARD, rx_forward, "WINDOW/K/N,TAB/K/N", 0, NULL, 0, 0, NULL },
+ {"HOME", RX_HOME, rx_home, "WINDOW/K/N,TAB/K/N", 0, NULL, 0, 0, NULL },
+ {"RELOAD", RX_RELOAD, rx_reload, "FORCE/S,WINDOW/K/N,TAB/K/N", 0, NULL, 0, 0, NULL },
+ {"WINDOWS", RX_WINDOWS, rx_windows, "WINDOW/K/N", 0, NULL, 0, 0, NULL },
{ NULL, 0, NULL, NULL, 0, NULL, 0, 0, NULL }
};
@@ -125,20 +132,77 @@ void ami_arexx_cleanup(void)
if(arexx_obj) DisposeObject(arexx_obj);
}
+struct browser_window *ami_find_tab_gwin(struct gui_window_2 *gwin, int tab)
+{
+ int tabs = 0;
+ struct Node *ctab;
+ struct Node *ntab;
+ struct browser_window *bw;
+
+ if((tab == 0) || (gwin->tabs == 0)) return gwin->bw;
+
+ ctab = GetHead(&gwin->tab_list);
+
+ do
+ {
+ tabs++;
+ ntab=GetSucc(ctab);
+ GetClickTabNodeAttrs(ctab,
+ TNA_UserData, &bw,
+ TAG_DONE);
+ if(tabs == tab) return bw;
+ } while(ctab=ntab);
+
+ return NULL;
+}
+
+struct browser_window *ami_find_tab(int window, int tab)
+{
+ int windows = 0, tabs = 0;
+ struct nsObject *node, *nnode;
+ struct gui_window_2 *gwin;
+
+ if(!IsMinListEmpty(window_list))
+ {
+ node = (struct nsObject *)GetHead((struct List *)window_list);
+
+ do
+ {
+ nnode=(struct nsObject *)GetSucc((struct Node *)node);
+
+ if(node->Type == AMINS_WINDOW)
+ {
+ windows++;
+ if(windows == window)
+ return ami_find_tab_gwin(node->objstruct, tab);
+ }
+ } while(node = nnode);
+ }
+ return NULL;
+}
+
STATIC VOID rx_open(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((unused)))
{
struct dlnode *dln;
+ struct browser_window *bw = curbw;
- if(cmd->ac_ArgList[2])
+ if((cmd->ac_ArgList[4]) && (cmd->ac_ArgList[5]))
+ bw = ami_find_tab(*(ULONG *)cmd->ac_ArgList[4], *(ULONG *)cmd->ac_ArgList[5]);
+
+ if(cmd->ac_ArgList[3])
{
- if(!curbw) return;
+ if(!bw) return;
dln = AllocVec(sizeof(struct dlnode),MEMF_PRIVATE | MEMF_CLEAR);
- dln->filename = strdup((char *)cmd->ac_ArgList[2]);
+ dln->filename = strdup((char *)cmd->ac_ArgList[3]);
dln->node.ln_Name = strdup((char *)cmd->ac_ArgList[0]);
dln->node.ln_Type = NT_USER;
- AddTail(&curbw->window->dllist,dln);
- if(!curbw->download) browser_window_download(curbw,(char *)cmd->ac_ArgList[0],NULL);
+ AddTail(&bw->window->dllist,dln);
+ if(!bw->download) browser_window_download(curbw,(char *)cmd->ac_ArgList[0],NULL);
+ }
+ else if(cmd->ac_ArgList[2])
+ {
+ browser_window_create((char *)cmd->ac_ArgList[0],NULL,NULL,true,true);
}
else if(cmd->ac_ArgList[1])
{
@@ -146,9 +210,9 @@ STATIC VOID rx_open(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((unu
}
else
{
- if(curbw)
+ if(bw)
{
- browser_window_go(curbw,(char *)cmd->ac_ArgList[0],NULL,true);
+ browser_window_go(bw,(char *)cmd->ac_ArgList[0],NULL,true);
}
else
{
@@ -162,19 +226,24 @@ STATIC VOID rx_save(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((unu
BPTR fh = 0;
ULONG source_size;
char *source_data;
- if(!curbw) return;
+ struct browser_window *bw = curbw;
+
+ if((cmd->ac_ArgList[1]) && (cmd->ac_ArgList[2]))
+ bw = ami_find_tab(*(ULONG *)cmd->ac_ArgList[1], *(ULONG *)cmd->ac_ArgList[2]);
- ami_update_pointer(curbw->window->shared->win,GUI_POINTER_WAIT);
+ if(!bw) return;
+
+ ami_update_pointer(bw->window->shared->win,GUI_POINTER_WAIT);
if(fh = FOpen(cmd->ac_ArgList[0],MODE_NEWFILE,0))
{
- if(source_data = content_get_source_data(curbw->current_content, &source_size))
+ if(source_data = content_get_source_data(bw->current_content, &source_size))
FWrite(fh, source_data, 1, source_size);
FClose(fh);
- SetComment(cmd->ac_ArgList[0], content_get_url(curbw->current_content));
+ SetComment(cmd->ac_ArgList[0], content_get_url(bw->current_content));
}
- ami_update_pointer(curbw->window->shared->win,GUI_POINTER_DEFAULT);
+ ami_update_pointer(bw->window->shared->win,GUI_POINTER_DEFAULT);
}
STATIC VOID rx_quit(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((unused)))
@@ -189,9 +258,14 @@ STATIC VOID rx_tofront(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((
STATIC VOID rx_geturl(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((unused)))
{
- if(curbw && curbw->current_content)
+ struct browser_window *bw = curbw;
+
+ if((cmd->ac_ArgList[0]) && (cmd->ac_ArgList[1]))
+ bw = ami_find_tab(*(ULONG *)cmd->ac_ArgList[0], *(ULONG *)cmd->ac_ArgList[1]);
+
+ if(bw && bw->current_content)
{
- strcpy(result, content_get_url(curbw->current_content));
+ strcpy(result, content_get_url(bw->current_content));
}
else
{
@@ -203,9 +277,17 @@ STATIC VOID rx_geturl(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((u
STATIC VOID rx_gettitle(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((unused)))
{
- if(curbw)
+ struct browser_window *bw = curbw;
+
+ if((cmd->ac_ArgList[0]) && (cmd->ac_ArgList[1]))
+ bw = ami_find_tab(*(ULONG *)cmd->ac_ArgList[0], *(ULONG *)cmd->ac_ArgList[1]);
+
+ if(bw)
{
- strcpy(result,curbw->window->shared->win->Title);
+ if(bw->window->tabtitle)
+ strcpy(result,bw->window->tabtitle);
+ else
+ strcpy(result,bw->window->shared->win->Title);
}
else
{
@@ -295,45 +377,92 @@ STATIC VOID rx_pubscreen(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__
STATIC VOID rx_back(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((unused)))
{
- if(curbw)
+ struct browser_window *bw = curbw;
+
+ if((cmd->ac_ArgList[0]) && (cmd->ac_ArgList[1]))
+ bw = ami_find_tab(*(ULONG *)cmd->ac_ArgList[0], *(ULONG *)cmd->ac_ArgList[1]);
+
+ if(bw)
{
- if(browser_window_back_available(curbw))
+ if(browser_window_back_available(bw))
{
- history_back(curbw, curbw->history);
+ history_back(bw, bw->history);
}
}
}
STATIC VOID rx_forward(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((unused)))
{
- if(curbw)
+ struct browser_window *bw = curbw;
+
+ if((cmd->ac_ArgList[0]) && (cmd->ac_ArgList[1]))
+ bw = ami_find_tab(*(ULONG *)cmd->ac_ArgList[0], *(ULONG *)cmd->ac_ArgList[1]);
+
+ if(bw)
{
- if(browser_window_forward_available(curbw))
+ if(browser_window_forward_available(bw))
{
- history_forward(curbw, curbw->history);
+ history_forward(bw, bw->history);
}
}
}
STATIC VOID rx_home(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((unused)))
{
- if(curbw)
- {
- browser_window_go(curbw, option_homepage_url, NULL, true);
- }
+ struct browser_window *bw = curbw;
+
+ if((cmd->ac_ArgList[0]) && (cmd->ac_ArgList[1]))
+ bw = ami_find_tab(*(ULONG *)cmd->ac_ArgList[0], *(ULONG *)cmd->ac_ArgList[1]);
+
+ if(bw) browser_window_go(bw, option_homepage_url, NULL, true);
}
STATIC VOID rx_reload(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((unused)))
{
- if(curbw)
+ struct browser_window *bw = curbw;
+
+ if((cmd->ac_ArgList[1]) && (cmd->ac_ArgList[2]))
+ bw = ami_find_tab(*(ULONG *)cmd->ac_ArgList[1], *(ULONG *)cmd->ac_ArgList[2]);
+
+ if(bw)
{
if(cmd->ac_ArgList[0]) /* FORCE */
{
- browser_window_reload(curbw, true);
+ browser_window_reload(bw, true);
}
else
{
- browser_window_reload(curbw, false);
+ browser_window_reload(bw, false);
}
}
}
+
+STATIC VOID rx_windows(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((unused)))
+{
+ int windows = 0, tabs = 0;
+ struct nsObject *node, *nnode;
+ struct gui_window_2 *gwin;
+
+ if(!IsMinListEmpty(window_list))
+ {
+ node = (struct nsObject *)GetHead((struct List *)window_list);
+
+ do
+ {
+ nnode=(struct nsObject *)GetSucc((struct Node *)node);
+
+ gwin = node->objstruct;
+
+ if(node->Type == AMINS_WINDOW)
+ {
+ windows++;
+ if((cmd->ac_ArgList[0]) && (*(ULONG *)cmd->ac_ArgList[0] == windows))
+ tabs = gwin->tabs;
+ }
+ } while(node = nnode);
+ }
+
+ if(cmd->ac_ArgList[0]) sprintf(result, "%ld", tabs);
+ else sprintf(result, "%ld", windows);
+ cmd->ac_Result = result;
+}
diff --git a/amiga/dist/NetSurf.guide b/amiga/dist/NetSurf.guide
index 2f8f63668..39304a131 100755
--- a/amiga/dist/NetSurf.guide
+++ b/amiga/dist/NetSurf.guide
@@ -71,18 +71,46 @@ NetSurf's ARexx port is called NETSURF.
Commands are:
-@{b}OPEN URL/A,NEW=NEWWINDOW/S,SAVEAS/K@{ub} Opens URL in current window or a new window if NEWWINDOW is specified. Saves the location without displaying if SAVEAS and a filename is specified (SAVEAS available in 2.6325)
-@{b}SAVE FILENAME/A@{ub} (2.6027) Saves current page source to FILENAME
-@{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
-@{b}GETTITLE@{ub} Puts the title of the page displayed in the current window/tab into RESULT
-@{b}GETSCREENNAME@{ub} (2.8303) Puts the name of the screen NetSurf is running on into RESULT.
-@{b}BACK@{ub} (2.10626) Move back one page in history.
-@{b}FORWARD@{ub} (2.10626) Move forward one page in history.
-@{b}HOME@{ub} (2.10626) Move back to the home page.
-@{b}RELOAD FORCE/S@{ub} (2.10626) Reload the current page, FORCE will do a full reload.
-@{b}VERSION VERSION/N REVISION/N RELEASE/S@{ub} Returns the current version of NetSurf in RESULT. You can also do version checking by supplying a VERSION and optional REVISION to check against. If the version of NetSurf is the same or higher 1 will be returned, if it is older 0. If RELEASE is specified, the command operates on the release version rather than the internal version number.
+@{b}OPEN URL/A,NEW=NEWWINDOW/S,NEWTAB/S,SAVEAS/K,WINDOW/K/N,TAB/K/N@{ub}
+Opens URL in current window or a new window/tab if NEWWINDOW/NEWTAB is specified. Saves the location without displaying if SAVEAS and a filename is specified (SAVEAS available in 2.6325)
+
+@{b}SAVE FILENAME/A,WINDOW/K/N,TAB/K/N@{ub} (2.6027)
+Saves current page source to FILENAME
+
+@{b}QUIT@{ub}
+Quits NetSurf
+
+@{b}TOFRONT@{ub}
+Brings NetSurf's screen to the front
+
+@{b}GETURL WINDOW/K/N,TAB/K/N@{ub}
+Puts the URL displayed in the current window/tab into RESULT
+
+@{b}GETTITLE WINDOW/K/N,TAB/K/N@{ub}
+Puts the title of the page displayed in the current window/tab into RESULT
+
+@{b}GETSCREENNAME@{ub} (2.8303)
+Puts the name of the screen NetSurf is running on into RESULT.
+
+@{b}BACK WINDOW/K/N,TAB/K/N@{ub} (2.10626)
+Move back one page in history.
+
+@{b}FORWARD WINDOW/K/N,TAB/K/N@{ub} (2.10626)
+Move forward one page in history.
+
+@{b}HOME WINDOW/K/N,TAB/K/N@{ub} (2.10626)
+Move back to the home page.
+
+@{b}RELOAD FORCE/S,WINDOW/K/N,TAB/K/N@{ub} (2.10626)
+Reload the current page, FORCE will do a full reload.
+
+@{b}VERSION VERSION/N REVISION/N RELEASE/S@{ub}
+Returns the current version of NetSurf in RESULT. You can also do version checking by supplying a VERSION and optional REVISION to check against. If the version of NetSurf is the same or higher 1 will be returned, if it is older 0. If RELEASE is specified, the command operates on the release version rather than the internal version number.
+
+@{b}WINDOWS WINDOW/K/N@{ub} (2.10656)
+Puts the number of windows into RESULT. If the WINDOW keyword is specified, will put the number of tabs in that window into RESULT.
+
+The WINDOW/K/N,TAB/K/N parameters were added in 2.10656 and allow targetting a window other than the current one. Both WINDOW and TAB must be specified (TAB=1 for tabless window)
The ARexx menu will be populated with scripts named #?.nsrx in @{"arexx_dir" link options 9}, 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).
@endnode
diff --git a/amiga/dist/Rexx/ShowTitles.nsrx b/amiga/dist/Rexx/ShowTitles.nsrx
new file mode 100644
index 000000000..27de74122
--- /dev/null
+++ b/amiga/dist/Rexx/ShowTitles.nsrx
@@ -0,0 +1,18 @@
+/* Show all NetSurf windows and tabs open */
+
+options results
+address netsurf
+
+windows
+wins = result
+
+do w=1 to wins
+ windows window w
+ tabs = result
+ say "Window" w "(" || tabs "tabs)"
+
+ do t=1 to tabs
+ gettitle window w tab t
+ say " Tab" t || ":" result
+ end
+end