/usr/share/gap/lib/helpview.gi is in gap-libs 4r6p5-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 | #############################################################################
##
#W helpview.gi GAP Library Frank Lübeck
##
##
#Y Copyright (C) 2001, Lehrstuhl D für Mathematik, RWTH Aachen, Germany
#Y (C) 2001 School Math and Comp. Sci., University of St Andrews, Scotland
#Y Copyright (C) 2002 The GAP Group
##
## The files helpview.g{d,i} contain the configuration mechanism for the
## different help viewer.
##
#############################################################################
##
## the user interface for the help viewer choice
##
#############################################################################
##
#V HELP_VIEWER_INFO
##
## This record contains records for each possible help viewer: each
## stores the `.type' of the output data (currently supported: "text",
## "url", "pdf", "dvi") and a function `.show' for showing the output
## data.
##
## The output data (from handler.HelpData) must have the following
## form:
##
## "text": a format as allowed by `Pager' (usually rec(lines:=text,
## start:=linenr, formatted:=true))
##
## "url": an URL (usually local `file://' URL)
##
## "dvi": a filename or a record rec(file:=filename, page:=pagenr)
## where pagenr is the first page to show
##
## "pdf": same as for "dvi"
##
# The preferred help viewers can be specified via a user preference.
DeclareUserPreference( rec(
name:= [ "HelpViewers", "XpdfOptions", "XdviOptions" ],
description:= [
"Here you can choose your preferred help viewers. See the help for \
'SetHelpViewer' for further options.",
"Try 'HelpViewers:= [ \"screen\", \"firefox\", \"xpdf\" ];'.",
"(For \"screen\" we also suggest to set the 'Pager' entry to \"less\".)"
],
default:= [ [ "screen" ], "", "" ],
check:= function( helpviewers, xpdfoptions, xdvioptions )
return IsList( helpviewers ) and ForAll( helpviewers, IsString )
and IsString( xpdfoptions ) and IsString( xdvioptions );
end,
) );
InstallValue(HELP_VIEWER_INFO, rec());
# text on screen
HELP_VIEWER_INFO.screen := rec(
type := "text",
show := PagerAsHelpViewer,
);
if ARCH_IS_WINDOWS() then
# html version on Windows
HELP_VIEWER_INFO.browser := rec(
type := "url",
show := function( filename )
local winfilename, pos;
if not filename{[1..9]}="/cygdrive" then
Error( "corrupted name of the help file ", filename );
fi;
winfilename := filename{[10..11]}; # to get the name of the drive, e.g. "/c"
winfilename[3] := ':';
Append( winfilename, filename{[12..Length(filename)]});
Print( "Opening help page in default windows browser ... \c" );
Process( DirectoryCurrent(),
Filename( DirectoriesLibrary( "bin" ), "cygstart.exe" ),
InputTextNone(),
OutputTextNone(),
[ Concatenation( "file:///", winfilename ) ] );
Print( "done! \n" );
end
);
elif ARCH_IS_MAC_OS_X() then
# html version using Mac OS X default browser
HELP_VIEWER_INFO.("mac default browser") := rec (
type := "url",
show := function (url)
Exec ( Concatenation( "osascript <<ENDSCRIPT\n",
"open location \"file://", url, "\"\n",
"ENDSCRIPT\n" ) );
return;
end
);
HELP_VIEWER_INFO.browser := HELP_VIEWER_INFO.("mac default browser");
# html version using Mac OS X browser Safari
HELP_VIEWER_INFO.safari := rec (
type := "url",
show := function (url)
Exec ( Concatenation( "osascript <<ENDSCRIPT\n",
"tell application \"Safari\"\n",
"activate\n",
"open location \"file://", url, "\"\n",
"end tell\n",
"ENDSCRIPT\n" ) );
return;
end);
# html version using Mac OS X browser Firefox
HELP_VIEWER_INFO.firefox := rec (
type := "url",
show := function (url)
Exec ( Concatenation( "osascript <<ENDSCRIPT\n",
"tell application \"Firefox\"\n",
"activate\n",
"open location \"file://", url, "\"\n",
"end tell\n",
"ENDSCRIPT\n" ) );
return;
end);
HELP_VIEWER_INFO.preview := rec(
type := "pdf",
show := function(file)
local page;
# unfortunately one cannot (yet?) give a start page to Preview.app
# it is currently ignored
page := 1;
if IsRecord(file) then
if IsBound(file.page) then
page := file.page;
fi;
file := file.file;
fi;
Exec(Concatenation("open -a Preview ", file));
Print("# see page ", page, " in the Preview window.\n");
end
);
HELP_VIEWER_INFO.("adobe reader") := rec(
type := "pdf",
show := function(file)
local page;
# unfortunately one cannot (yet?) give a start page to acroread
# it is currently ignored
page := 1;
if IsRecord(file) then
if IsBound(file.page) then
page := file.page;
fi;
file := file.file;
fi;
Exec(Concatenation("open -a \"Adobe Reader\" ", file));
Print("# see page ", page, " in the Adobe Reader window.\n");
end
);
HELP_VIEWER_INFO.("pdf viewer") := rec(
type := "pdf",
show := function(file)
local page;
# unfortunately one cannot (yet?) give a start page to acroread
# it is currently ignored
page := 1;
if IsRecord(file) then
if IsBound(file.page) then
page := file.page;
fi;
file := file.file;
fi;
Exec(Concatenation("open ", file));
Print("# see page ", page, " in the pdf viewer window.\n");
end
);
HELP_VIEWER_INFO.("skim") := rec(
type := "pdf",
show := function(file)
local page;
page := 1;
if IsRecord(file) then
if IsBound(file.page) then
page := file.page;
fi;
file := file.file;
fi;
Exec( Concatenation(
"osascript <<ENDSCRIPT\n",
"tell application \"Skim\"\n",
"activate\n",
"open \"", file, "\"\n",
"set theDoc to document of front window\n",
"go theDoc to page ",String(page)," of theDoc\n",
"end tell\n",
"ENDSCRIPT\n" ) );
return;
end
);
else # UNIX but not Mac OS X
# html version with netscape
HELP_VIEWER_INFO.netscape := rec(
type := "url",
show := function(url)
Exec(Concatenation("netscape -remote \"openURL(file:", url, ")\""));
end
);
# html version with mozilla
HELP_VIEWER_INFO.mozilla := rec(
type := "url",
show := function(url)
Exec(Concatenation("mozilla -remote \"openURL(file:", url, ")\""));
end
);
# html version with firefox
HELP_VIEWER_INFO.firefox := rec(
type := "url",
show := function(url)
Exec(Concatenation("firefox -remote \"openURL(file:", url, ")\""));
end
);
# html version with chrome
HELP_VIEWER_INFO.chrome := rec(
type := "url",
show := function(url)
Exec(Concatenation("chromium-browser \"file://", url,"\" >/dev/null 2>1 &"));
end
);
# html version with konqueror - doesn't work with 'file://...#...' URLs
HELP_VIEWER_INFO.konqueror := rec(
type := "url",
show := function(url)
Exec(Concatenation("konqueror \"file://", url,"\" >/dev/null 2>1 &"));
end
);
# html version with lynx
HELP_VIEWER_INFO.lynx := rec(
type := "url",
show := function(url)
Exec(Concatenation("lynx \"", url, "\""));
end
);
# html version with w3m
HELP_VIEWER_INFO.w3m := rec(
type := "url",
show := function(url)
Exec(Concatenation("w3m \"", url, "\""));
end
);
HELP_VIEWER_INFO.elinks := rec(
type := "url",
show := function(url)
Exec(Concatenation("elinks \"", url, "\""));
end
);
HELP_VIEWER_INFO.links2ng := rec(
type := "url",
show := function(url)
Exec(Concatenation("links2 \"", url, "\""));
end
);
HELP_VIEWER_INFO.links2 := rec(
type := "url",
show := function(url)
Exec(Concatenation("links2 -g \"", url, "\""));
end
);
fi;
# Function to find the X-windows window ID of a program accessing file
# <bookf>. Used for a hack below: xdvi doesn't provide a -remote control.
# Having compiled GAPHOME/etc/xrmtcmd.c one can reuse running xdvi's for
# each help file. This was provided by Alexander Hulpke.
#
# This may not work if several people on the same machine want to use it.
#
# Set "XLSCLIENTSCMD := fail;" to turn this off.
FWITF:=fail;
XLSCLIENTSCMD:=false;
InstallGlobalFunction(FindWindowId, function(prog,bookf)
local s,l,a,e,n,c;
if FWITF=fail then
FWITF:=Filename(DirectoryTemporary(),"clients");
fi;
if XLSCLIENTSCMD=false then
XLSCLIENTSCMD:=Filename(DirectoriesSystemPrograms(),"xlsclients");
fi;
if XLSCLIENTSCMD=fail then
return fail;
fi;
Exec(Concatenation(XLSCLIENTSCMD," -l >",FWITF));
s:=InputTextFile(FWITF);
# find the proper jobs
#T also get the right display/user. Probably this has to be done via the
#T `Machine' parameter.
while not IsEndOfStream(s) do
l:=ReadLine(s);
if l<>fail then
e:=Length(l);
if l[e]='\n' then
e:=e-1;
fi;
a:=1;
while l[a]=' ' do
a:=a+1;
od;
if l{[a..a+6]}="Window " then
n:=l{[a+7..e-1]};
elif l{[a..a+7]}="Command:" then
c:=l{[a+10..e]};
a:=PositionSublist(c,prog);
e:=Length(c);
# does the program name occur and is called on the right file?
if a<>fail and e>Length(bookf)
and c{[e-Length(bookf)+1..e]}=bookf then
# now convert n in an integer
e:=0;
a:="0123456789abcdef";
c:=3; # first two characters are 0x
while c<=Length(n) do
e:=e*16+Position(a,n[c])-1;
c:=c+1;
od;
return e;
fi;
fi;
fi;
od;
CloseStream(s);
return fail;
end);
XRMTCMD:=false;
## dvi version with xdvi
## default options, can be adjusted in gap.ini file or by environment
## variables
## longer example:
#SetUserPreference("XdviOptions", " -geometry 739x577 -paper a4 -s 6 -fg \"#111111\" -bg \"#dddddd\" -margins 1cm -gamma 0.8");
HELP_VIEWER_INFO.xdvi := rec(
type := "dvi",
show := function(file)
local page,wnum;
page := 1;
if IsRecord(file) then
if IsBound(file.page) then
page := file.page;
fi;
file := file.file;
fi;
if XRMTCMD=false then
XRMTCMD:=Filename(DirectoriesSystemPrograms(),"xrmtcmd");
fi;
if XRMTCMD<>fail then
wnum:=FindWindowId("xdvi",file); # get the window ID of a running XDVI
# for the right book
else
wnum:=fail;
fi;
if wnum=fail or XRMTCMD=fail then
Exec(Concatenation("xdvi ", UserPreference("XdviOptions"), " +",
String(page), " ", file, " &"));
else
#Print("Window: ",wnum,"\n");
# command for xdvi: a (to \relax), pagenumber, goto
file:=Concatenation("a",String(page),"g");
Exec(Concatenation(XRMTCMD," ",String(wnum)," ",file));
fi;
end
);
# pdf version with xpdf (very good with well configured fonts!)
HELP_VIEWER_INFO.xpdf := rec(
type := "pdf",
show := function(file)
local page;
page := 1;
if IsRecord(file) then
if IsBound(file.label) then
page := Concatenation("+", file.label);
elif IsBound(file.page) then
page := String(file.page);
else
page := "";
fi;
file := file.file;
fi;
Exec(Concatenation("xpdf -remote gap4 -raise ",
UserPreference("XpdfOptions"),
" ", file, " ", page, " 2>/dev/null &"));
end
);
# pdf version with acroread: less nice since there is no start page argument
# and no remote control.
# When accessing several sections of the same file in a row this viewer
# assumes that acroread is still running and only tells the page number
# to visit.
ACROREAD_OPTIONS := "";
ACROREAD_FILE := "";
HELP_VIEWER_INFO.acroread := rec(
type := "pdf",
show := function(file)
local page;
# unfortunately one cannot (yet?) give a start page to acroread
# it is currently ignored
page := 1;
if IsRecord(file) then
if IsBound(file.page) then
page := file.page;
fi;
file := file.file;
fi;
if file <> ACROREAD_FILE then
Exec(Concatenation("acroread ", ACROREAD_OPTIONS, " ", file, " &"));
ACROREAD_FILE := file;
fi;
Print("# see page ", page, " in acroread window.\n");
end
);
#############################################################################
##
#F SetHelpViewer(<viewer>): Set the viewer used for help
##
# Can give one or more strings for the preferred help viewer;
# the HELP tries to get the data for the viewer in the order given here.
# No argument shows current setting.
InstallGlobalFunction(SetHelpViewer, function(arg)
local view, i, a;
if Length(arg) = 0 then
return UserPreference("HelpViewers");
fi;
view := List(arg, LowercaseString);
for i in [1..Length(view)] do
a := view[i];
# special handling of help viewer `less'
if a = "less" then
Info(InfoWarning, 2,
"Help viewer \"less\": interpreted as ",
"viewer \"screen\" and setting:\n#I ",
"SetUserPreference(\"Pager\",\"less\");\n#I ",
"SetUserPreference(\"PagerOptions\", ",
"[\"-f\",\"-r\",\"-a\",\"-i\",\"-M\",\"-j2\"]);");
SetUserPreference("Pager", "less");
SetUserPreference("PagerOptions", ["-f","-r","-a","-i","-M","-j2"]);
view[i] := "screen";
elif a = "more" then
Info(InfoWarning, 2,
"Help viewer \"more\": interpreted as ",
"viewer \"screen\" and setting:\n#I ",
"SetUserPreferences(\"Pager\", \"more\");\n#I ",
"SetUserPreference(\"PagerOptions\", []);");
SetUserPreference("Pager", "more");
SetUserPreference("PagerOptions", []);
view[i] := "screen";
elif not IsBound(HELP_VIEWER_INFO.(a)) then
Info(InfoWarning, 1, Concatenation(
"GAP's help system has NO support for help viewer ",a,"!\n"));
view[i] := fail;
fi;
od;
if not "screen" in view then
Add(view, "screen");
fi;
SetUserPreference("HelpViewers", Filtered(view, a-> a<>fail));
if Length( UserPreference("HelpViewers") ) > 1 then
Info( InfoWarning, 2, "Trying to use\n#I ",
UserPreference("HelpViewers"),
"\n#I (in this order) as help viewer.");
else
Info(InfoWarning, 2, Concatenation(
"Using ", UserPreference("HelpViewers")[1],
" as help viewer."));
fi;
end);
|