Skip to content

Commit 9a0c804

Browse files
GAPgap
authored andcommitted
Made setting of text themes more flexible.
git-svn-id: path/gapdoc/trunk@315
1 parent ff2f84d commit 9a0c804

File tree

4 files changed

+59
-55
lines changed

4 files changed

+59
-55
lines changed

init.g

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
##
33
#A init.g GAPDoc Frank Lübeck / Max Neunhöffer
44
##
5-
#H @(#)$Id: init.g,v 1.18 2011-07-04 14:56:25 gap Exp $
5+
#H @(#)$Id: init.g,v 1.19 2011-07-13 16:04:37 gap Exp $
66
##
77
#Y Copyright (C) 2000, Frank Lübeck and Max Neunhöffer,
88
#Y Lehrstuhl D für Mathematik, RWTH Aachen
@@ -22,8 +22,6 @@ ReadPackage("GAPDoc", "lib/GAPDoc2HTML.gd");
2222
ReadPackage("GAPDoc", "lib/Make.g");
2323
ReadPackage("GAPDoc", "lib/Examples.gd");
2424

25-
# The handler functions for GAP's help system are read now:
26-
ReadPackage("GAPDoc", "lib/HelpBookHandler.g");
2725

2826
# try to find terminal encoding
2927
GAPInfo.tmpfunc := function()

lib/HelpBookHandler.g

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
##
33
#W HelpBookHandler.g GAPDoc Frank Lübeck
44
##
5-
#H @(#)$Id: HelpBookHandler.g,v 1.13 2011-07-04 14:55:13 gap Exp $
5+
#H @(#)$Id: HelpBookHandler.g,v 1.14 2011-07-13 16:04:38 gap Exp $
66
##
77
#Y Copyright (C) 2000, Frank Lübeck, Lehrstuhl D für Mathematik,
88
#Y RWTH Aachen
@@ -42,6 +42,7 @@ HELP_BOOK_HANDLER.GapDocGAP.setTextTheme := function()
4242
SetGAPDocTextTheme(GAPInfo.UserPreferences.TextTheme);
4343
fi;
4444
end;
45+
HELP_BOOK_HANDLER.GapDocGAP.setTextTheme();
4546

4647
# helper function for showing matches in current text theme
4748
HELP_BOOK_HANDLER.GapDocGAP.apptheme := function(res, theme)
@@ -69,7 +70,7 @@ HELP_BOOK_HANDLER.GapDocGAP.ReadSix := function(stream)
6970
for a in res.entries do
7071
a[8] := a[1];
7172
od;
72-
HELP_BOOK_HANDLER.GapDocGAP.setTextTheme();
73+
## HELP_BOOK_HANDLER.GapDocGAP.setTextTheme();
7374
HELP_BOOK_HANDLER.GapDocGAP.apptheme(res, GAPDocTextTheme);
7475

7576
# in position 6 of each entry we put the corresponding search string
@@ -157,7 +158,7 @@ HELP_BOOK_HANDLER.GapDocGAP.SearchMatches := function (book, topic, frombegin)
157158
fi;
158159
fi;
159160
od;
160-
HELP_BOOK_HANDLER.GapDocGAP.setTextTheme();
161+
## HELP_BOOK_HANDLER.GapDocGAP.setTextTheme();
161162
HELP_BOOK_HANDLER.GapDocGAP.apptheme(info, GAPDocTextTheme);
162163

163164
return [exact, match];
@@ -223,7 +224,7 @@ HELP_BOOK_HANDLER.GapDocGAP.HelpData := function(book, entrynr, type)
223224
fi;
224225
sline := a[4];
225226
# set the text theme
226-
HELP_BOOK_HANDLER.GapDocGAP.setTextTheme();
227+
## HELP_BOOK_HANDLER.GapDocGAP.setTextTheme();
227228
# substitute pseudo escape sequences via GAPDocTextTheme
228229
# split into two pieces to find new start line
229230
pos := PositionLinenumber(str, sline);

lib/TextThemes.g

Lines changed: 50 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ GAPDoc2TextProcs.OtherThemes := rec();
88
# - a string a starting with TextAttr.CSI for [a, TextAttr.reset]
99
# - another string a for [a, a]
1010
GAPDoc2TextProcs.OtherThemes.classic := rec(
11+
info := "similar to GAPDoc default until GAP 4.4",
1112
reset := TextAttr.reset,
1213
Heading := Concatenation(TextAttr.bold, TextAttr.underscore, TextAttr.1),
1314
Func := Concatenation(TextAttr.bold, TextAttr.4),
@@ -32,7 +33,7 @@ GAPDoc2TextProcs.OtherThemes.classic := rec(
3233
Q := ["\"","\""],
3334
M := ["",""],
3435
Math := ["$","$"],
35-
Display := ["$$","$$"],
36+
Display := ["",""],
3637
Prompt := Concatenation(TextAttr.bold,TextAttr.4),
3738
BrkPrompt := Concatenation(TextAttr.bold,TextAttr.1),
3839
GAPInput := TextAttr.1,
@@ -48,8 +49,9 @@ GAPDoc2TextProcs.OtherThemes.classic := rec(
4849
);
4950

5051
GAPDoc2TextProcs.OtherThemes.default := rec(
52+
info := "the default theme",
5153
reset := TextAttr.reset,
52-
Heading := Concatenation(TextAttr.bold, TextAttr.underscore),
54+
Heading := Concatenation(TextAttr.normal, TextAttr.underscore),
5355
Func := Concatenation(TextAttr.normal, TextAttr.4),
5456
Arg := Concatenation(TextAttr.normal, TextAttr.2),
5557
Example := Concatenation(TextAttr.normal, TextAttr.0),
@@ -87,7 +89,8 @@ GAPDoc2TextProcs.OtherThemes.default := rec(
8789
flush := "both",
8890
);
8991

90-
GAPDoc2TextProcs.OtherThemes.gap3 := rec(
92+
GAPDoc2TextProcs.OtherThemes.old := rec(
93+
info := "similar to old style manuals in GAP 3 and GAP 4.4",
9194
reset := "",
9295
Heading := ["",""],
9396
Func := ["`","'"],
@@ -126,7 +129,13 @@ GAPDoc2TextProcs.OtherThemes.gap3 := rec(
126129
format := "",
127130
flush := "both"
128131
);
129-
132+
GAPDoc2TextProcs.OtherThemes.equalquotes := rec(
133+
info := "(together with \"old\") uses '...' instead of `...'",
134+
C := "'",
135+
F := "'",
136+
K := "'",
137+
Func := "'"
138+
);
130139

131140

132141
GAPDoc2TextProcs.OtherThemes.none := rec();
@@ -140,61 +149,55 @@ GAPDoc2TextProcs.f := function()
140149
for a in ["Q", "DefLineMarker", "ListBullet", "FillString", "EnumMarks"] do
141150
GAPDoc2TextProcs.OtherThemes.none.(a) := dt.(a);
142151
od;
152+
GAPDoc2TextProcs.OtherThemes.none.info := "plain text without markup";
143153
end;
144154
GAPDoc2TextProcs.f();
145155
Unbind(GAPDoc2TextProcs.f);
146156

157+
GAPDoc2TextProcs.OtherThemes.ColorPrompt := rec(
158+
info := "show examples in ColorPrompt(true) style",
159+
Prompt := Concatenation(TextAttr.bold,TextAttr.4),
160+
BrkPrompt := Concatenation(TextAttr.bold,TextAttr.1),
161+
GAPInput := TextAttr.1,
162+
GAPOutput := TextAttr.reset
163+
);
164+
165+
GAPDoc2TextProcs.OtherThemes.noColorPrompt := rec(
166+
info := "show examples in ColorPrompt(false) style",
167+
Prompt := "",
168+
BrkPrompt := "",
169+
GAPInput := "",
170+
GAPOutput := ""
171+
);
172+
147173
InstallValue(GAPDocTextTheme, rec());
148174

149175
# argument doesn't need all component, the missing ones are taken from default
150176
InstallGlobalFunction(SetGAPDocTextTheme, function(arg)
151-
local r, len, res, h, af, v, i, f;
177+
local r, res, h, af, v, a, nam, f, i;
152178

153-
if Length(arg) = 0 then
154-
r := rec();
155-
else
156-
r := arg[1];
157-
fi;
158-
if IsString(r) then
159-
if not IsBound(GAPDoc2TextProcs.OtherThemes.(r)) then
160-
Print("Only the following named text themes are available:\n ",
161-
RecFields(GAPDoc2TextProcs.OtherThemes), "\n");
162-
return;
163-
else
164-
r := GAPDoc2TextProcs.OtherThemes.(r);
165-
fi;
166-
fi;
167-
len := function(s) return WidthUTF8String(StripEscapeSequences(s)); end;
168-
# normalize ListBullet and EnumMarks
169-
if IsBound(r.ListBullet) then
170-
if not IsString(r.ListBullet) then
171-
r.ListBullet := r.ListBullet[1];
172-
fi;
173-
while len(r.ListBullet) < 2 do
174-
Add(r.ListBullet, ' ');
175-
od;
176-
if len(r.ListBullet) > 2 then
177-
r.ListBullet := r.ListBullet{[1..2]};
178-
fi;
179-
fi;
180-
if IsBound(r.EnumMarks) then
181-
if IsString(r.EnumMarks) then
182-
r.EnumMarks := [r.EnumMarks, r.EnumMarks];
183-
fi;
184-
if Sum(r.EnumMarks, len) > 2 then
185-
if len(r.EnumMarks[1]) = 0 then
186-
r.EnumMarks[2] := r.EnumMarks[2]{[1,2]};
187-
elif len(r.EnumMarks[2]) = 0 then
188-
r.EnumMarks[1] := r.EnumMarks[1]{[1,2]};
179+
r := rec();
180+
for a in arg do
181+
if IsString(a) then
182+
if not IsBound(GAPDoc2TextProcs.OtherThemes.(a)) then
183+
Print("Only the following named text themes are available \
184+
(choose one or several):\n");
185+
for nam in RecFields(GAPDoc2TextProcs.OtherThemes) do
186+
Print(" ",String(Concatenation("\"",nam,"\""), -25),
187+
GAPDoc2TextProcs.OtherThemes.(nam).info, "\n");
188+
od;
189+
return;
189190
else
190-
r.EnumMarks[1] := r.EnumMarks[1]{[1]};
191-
r.EnumMarks[2] := r.EnumMarks[2]{[1]};
191+
for f in RecFields(GAPDoc2TextProcs.OtherThemes.(a)) do
192+
r.(f) := GAPDoc2TextProcs.OtherThemes.(a).(f);
193+
od;
192194
fi;
195+
else
196+
for f in RecFields(a) do
197+
r.(f) := a.(f);
198+
od;
193199
fi;
194-
while Sum(r.EnumMarks, len) < 2 do
195-
Add(r.EnumMarks[2], ' ');
196-
od;
197-
fi;
200+
od;
198201

199202
res := rec(hash := [[], []]);
200203
h := res.hash;

read.g

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
##
33
#A read.g GAPDoc Frank Lübeck / Max Neunhöffer
44
##
5-
#H @(#)$Id: read.g,v 1.7 2011-07-04 14:58:18 gap Exp $
5+
#H @(#)$Id: read.g,v 1.8 2011-07-13 16:04:38 gap Exp $
66
##
77
#Y Copyright (C) 2000, Frank Lübeck and Max Neunhöffer,
88
#Y Lehrstuhl D für Mathematik, RWTH Aachen
@@ -24,3 +24,5 @@ ReadPackage("GAPDoc", "lib/TextThemes.g");
2424
ReadPackage("GAPDoc", "lib/GAPDoc2HTML.gi");
2525
ReadPackage("GAPDoc", "lib/Examples.gi");
2626

27+
# Finally the handler functions for GAP's help system:
28+
ReadPackage("GAPDoc", "lib/HelpBookHandler.g");

0 commit comments

Comments
 (0)