ref: 9bc8b2e4caa3d228bf5669e2e8c64820a5e76c6b
parent: 3d33563e7a7a4d0772f70260cbedb89d5f175ab2
author: Ali Gholami Rudi <ali@rudi.ir>
date: Wed Oct 25 13:05:36 EDT 2017
post: support links with "x X link" To use it in Neatroff, use \X'link http://link.to.somewhere/ hwid vwid', in which hwid is the width and vwid is the height of the link.
--- a/out.c
+++ b/out.c
@@ -305,3 +305,16 @@
outf("%%%%EndDocument\n");
outf("EPSFEND\n");
}
+
+void outlink(char *spec)
+{
+ char lnk[1 << 12];
+ int hwid, vwid;
+ int nspec;
+ if ((nspec = sscanf(spec, "%s %d %d", lnk, &hwid, &vwid)) < 3)
+ return;
+ o_flush();
+ outf("[ /Rect [ %d %d t %d %d t ] /Action << /Subtype /URI /URI (%s) >> "
+ "/Open true /Subtype /Link /LNK pdfmark\n",
+ o_h, o_v, o_h + hwid, o_v + vwid, lnk);
+}
--- a/post.c
+++ b/post.c
@@ -1,7 +1,7 @@
/*
* NEATPOST: NEATROFF'S POSTSCRIPT POSTPROCESSOR
*
- * Copyright (C) 2013-2016 Ali Gholami Rudi <ali at rudi dot ir>
+ * Copyright (C) 2013-2017 Ali Gholami Rudi <ali at rudi dot ir>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -259,6 +259,8 @@
outrotate(atoi(arg));
if (!strcmp("eps", cmd))
outeps(arg);
+ if (!strcmp("link", cmd))
+ outlink(arg);
if (!strcmp("BeginObject", cmd))
drawmbeg(arg);
if (!strcmp("EndObject", cmd))
--- a/post.h
+++ b/post.h
@@ -53,6 +53,7 @@
void outcolor(int c);
void outrotate(int deg);
void outeps(char *eps);
+void outlink(char *spec);
void outpage(void);
void outmnt(int f);
void outgname(int g);
--- a/ps.c
+++ b/ps.c
@@ -42,6 +42,15 @@
" } if\n"
"} def\n"
"\n"
+ "/pdfmark where\n"
+ " { pop globaldict /?pdfmark /exec load put }\n"
+ " { globaldict begin\n"
+ " /?pdfmark /pop load def\n"
+ " /pdfmark /cleartomark load def\n"
+ " end }\n"
+ " ifelse\n"
+ "\n"
+ "/t {neg} bind def\n"
"/w {neg moveto show} bind def\n"
"/m {neg moveto} bind def\n"
"/g {neg moveto {glyphshow} forall} bind def\n"