aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans-Christoph Steiner <eighthave@users.sourceforge.net>2010-05-07 20:08:48 +0000
committerHans-Christoph Steiner <eighthave@users.sourceforge.net>2010-05-07 20:08:48 +0000
commite88278c7c8628df0b943d0ffc962f9be48ef89aa (patch)
tree5be78ee4765101bb7582b12a4f0a838c8cd6652a
parentfec8d07685f163c82d2d3d9144d9d885639577e0 (diff)
purged pddplink code that is not needed for helplink
svn path=/trunk/externals/pddp/; revision=13508
-rw-r--r--helplink-help.pd25
-rw-r--r--helplink.c107
2 files changed, 18 insertions, 114 deletions
diff --git a/helplink-help.pd b/helplink-help.pd
index 675458f..3ec1d63 100644
--- a/helplink-help.pd
+++ b/helplink-help.pd
@@ -1,14 +1,11 @@
-#N canvas 314 87 424 397 12;
-#X text 20 10 first entry;
-#X text 50 50 three ways of linking to a;
-#X text 50 170 three ways of linking to a;
-#X obj 50 195 helplink http://puredata.info;
-#X obj 50 230 helplink http://puredata.info -box;
-#X text 50 290 three ways of linking to;
-#X obj 260 290 helplink dsp-help.pd -text another local patch;
-#X obj 50 315 helplink dsp-help.pd;
-#X obj 50 350 helplink dsp-help.pd -box;
-#X obj 270 170 helplink http://puredata.info -text remote URL;
-#X obj 270 50 helplink README.txt -text local file;
-#X obj 50 75 helplink README.txt;
-#X obj 50 110 helplink README.txt -box;
+#N canvas 275 101 468 415 12;
+#X text 20 10 [helplink] makes a clickable link to a help patch based
+on the object name. It is useful for providing links to help patches
+in other patches.;
+#X obj 51 101 helplink select;
+#X obj 54 304 helplink;
+#X obj 50 143 helplink cyclone/counter;
+#X obj 50 181 helplink iemguts/propertybang;
+#X text 29 234 If the help patch or object does not exist \, [helplink]
+will not output an error until someone clicks on the link.;
+#X obj 55 339 helplink Gem/scale;
diff --git a/helplink.c b/helplink.c
index 468fba5..db70f25 100644
--- a/helplink.c
+++ b/helplink.c
@@ -9,7 +9,6 @@
#include <stdio.h>
#include <string.h>
#include "m_pd.h"
-#include "m_imp.h" /* FIXME need access to c_externdir... */
#include "g_canvas.h"
/* this isn't in any header, but its declared in s_path.c */
@@ -19,22 +18,16 @@ typedef struct _helplink
{
t_object x_ob;
t_glist *x_glist;
- int x_isboxed;
int x_isgopvisible;
char *x_vistext;
int x_vissize;
int x_vislength;
int x_rtextactive;
t_symbol *x_ulink;
- t_atom x_openargs[2];
- int x_linktype;
- int x_ishit;
} t_helplink;
static t_class *helplink_class;
-/* Code that might be merged back to g_text.c starts here: */
-
static void helplink_getrect(t_gobj *z, t_glist *glist,
int *xp1, int *yp1, int *xp2, int *yp2)
{
@@ -140,35 +133,10 @@ static t_widgetbehavior helplink_widgetbehavior =
helplink_wbclick,
};
-/* Code that might be merged back to g_text.c ends here. */
-
-/* FIXME need access to glob_pdobject... */
-static t_pd *helplink_pdtarget(t_helplink *x)
-{
- t_pd *pdtarget = gensym("pd")->s_thing;
- if (pdtarget && !strcmp(class_getname(*pdtarget), "pd"))
- return (pdtarget);
- else
- return ((t_pd *)x); /* internal error */
-}
-
-static void helplink_anything(t_helplink *x, t_symbol *s, int ac, t_atom *av)
-{
- if (x->x_ishit)
- {
- startpost("helplink: internal error (%s", (s ? s->s_name : ""));
- postatom(ac, av);
- post(")");
- }
-}
-
static void helplink_click(t_helplink *x, t_floatarg xpos, t_floatarg ypos,
t_floatarg shift, t_floatarg ctrl, t_floatarg alt)
{
- x->x_ishit = 1;
-// open_via_helppath("intro.pd", canvas_getdir((t_canvas *)x)->s_name);
- open_via_helppath(x->x_ulink->s_name, "");
- x->x_ishit = 0;
+ open_via_helppath(x->x_ulink->s_name, canvas_getdir(x->x_glist)->s_name);
}
static int helplink_wbclick(t_gobj *z, t_glist *glist, int xpix, int ypix,
@@ -185,86 +153,26 @@ static int helplink_wbclick(t_gobj *z, t_glist *glist, int xpix, int ypix,
else return (0);
}
-static int helplink_dooptext(char *dst, int maxsize, int ac, t_atom *av)
-{
- int i, sz, sep, len;
- char buf[32], *src;
- for (i = 0, sz = 0, sep = 0; i < ac; i++, av++)
- {
- if (sep)
- {
- sz++;
- if (sz >= maxsize)
- break;
- else if (dst)
- {
- *dst++ = ' ';
- *dst = 0;
- }
- }
- else sep = 1;
- if (av->a_type == A_SYMBOL)
- src = av->a_w.w_symbol->s_name;
- else if (av->a_type == A_FLOAT)
- {
- src = buf;
- sprintf(src, "%g", av->a_w.w_float);
- }
- else
- {
- sep = 0;
- continue;
- }
- len = strlen(src);
- sz += len;
- if (sz >= maxsize)
- break;
- else if (dst)
- {
- strcpy(dst, src);
- dst += len;
- }
- }
- return (sz);
-}
-
-static char *helplink_optext(int *sizep, int ac, t_atom *av)
-{
- char *result;
- int sz = helplink_dooptext(0, MAXPDSTRING, ac, av);
- *sizep = sz + (sz >= MAXPDSTRING ? 4 : 1);
- result = getbytes(*sizep);
- helplink_dooptext(result, sz + 1, ac, av);
- if (sz >= MAXPDSTRING)
- {
- sz = strlen(result);
- strcpy(result + sz, "...");
- }
- return (result);
-}
-
static void helplink_free(t_helplink *x)
{
if (x->x_vistext)
- freebytes(x->x_vistext, x->x_vissize);
+ freebytes(x->x_vistext, x->x_vissize);
}
static void *helplink_new(t_symbol *s)
{
t_helplink *x = (t_helplink *) pd_new(helplink_class);
- int skip;
x->x_isgopvisible = 0;
x->x_vistext = 0;
x->x_vissize = 0;
x->x_vislength = (x->x_vistext ? strlen(x->x_vistext) : 0);
x->x_rtextactive = 0;
x->x_glist = canvas_getcurrent();
- x->x_ulink = s;
- if (! x->x_ulink)
- x->x_ulink = gensym("helplink");
- SETSYMBOL(&x->x_openargs[0], x->x_ulink);
- x->x_ishit = 0;
+ if (s == &s_)
+ x->x_ulink = gensym("helplink"); /* default to helplink help patch */
+ else
+ x->x_ulink = s;
/* do we need to set ((t_text *)x)->te_type = T_TEXT; ? */
if (!x->x_vistext)
{
@@ -284,7 +192,6 @@ void helplink_setup(void)
sizeof(t_helplink),
CLASS_NOINLET | CLASS_PATCHABLE,
A_DEFSYMBOL, 0);
- class_addanything(helplink_class, helplink_anything);
- class_setwidget(helplink_class, &helplink_widgetbehavior);
+ class_setwidget(helplink_class, &helplink_widgetbehavior);
}