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
|
%------------------------------------------------------------------------------%
% Copyright (C) 1999 INRIA/INSA.
--- /soft/eclipse/eclipse4.1/lib_pd/opium_light/help.op Sat Feb 20 16:09:16 1999
+++ help.op Thu Nov 4 09:00:02 1999
@@ -41,8 +41,28 @@
:- tool(show_all/2).
help_Op :-
- opium_write(help, "\nThere are the following help commands: \n"),
- show_all(commands, help).
+ opium_write(help,
+ "\nThere are the following help commands for Opium-M: \n"),
+ show_all(commands, help),
+
+ % I copied this message here because I found no way to extend the
+ % help/0 command by using its previous definition.
+ opium_write(help, "\nAnd here is the help message for ECLiPSe: \n\n"),
+ opium_write(help,
+ " After the prompt [<module>]: ECLiPSe waits for a goal.\n"),
+ opium_write(help,
+ " To type in clauses, call [user] or compile(user), and then\n"),
+ opium_write(help,
+ " enter the clauses ended by ^D (EOF).\n\n"),
+ opium_write(help,
+ " Call help(Pred/Arity) or help(Pred) or help(String)\n"),
+ opium_write(help,
+ " to get help on a specific built-in predicate.\n\n"),
+ opium_write(help,
+ " Call demo (in xeclipse) to invoke the demo programs.\n\n"),
+ opium_write(help,
+ " This message can be modified by setting the handler for event 231.\n").
+
/* if a user types "help" he will see opium_help and not the sepia help
* opium_help is explicitly defined here, only so that the error handler
@@ -284,6 +304,9 @@
man_Op(X) :-
opium_nl(help).
+% To avoid typing brackets when using the man command.
+:- op(1190, fy, man).
+
/*
* man_int/1
* print help information on object with name Name
@@ -328,7 +351,7 @@
parameters : [],
message :
"Command which shows all the scenarios, their commands and the corresponding \n\
-explanations in the file \"File\" (in LaTex format). It also does some fixes \n\
+explanations in the file \"File\" (in LaTeX format). It also does some fixes \n\
in the LaTeX file. The LaTeX file will then be called <File>.tex afterwards. \n\
In order to get a printable <File>.dvi, use command latex_manual/1."
).
@@ -357,8 +380,7 @@
writeln(Manual, "\\tableofcontents"),
writeln(Manual, "\\end{document}"),
close(Manual),
- get_opium_file(fixmanual, FixF),
- concat_atom([FixF, ' ', File, '> /dev/null'], Cmd1),
+ concat_atom([fixmanual, ' ', File, '> /dev/null'], Cmd1),
system(Cmd1),
concat_atom([File, '.tex'], LatexFile),
concat_atom(['rm -f ', LatexFile], Cmd2),
@@ -777,5 +799,63 @@
-
-
+%------------------------------------------------------------------------------%
+opium_command(
+ name : apropos,
+ arg_list : [Name],
+ arg_type_list : [atom],
+ abbrev : a,
+ interface : button,
+ command_type : opium,
+ implementation : apropos_Op,
+ parameters : [],
+ message :
+"Command which displays all the commands, primitives, procedures, parameters, \
+or types for which Name is a substring of.\n\
+Example: \n\
+[Opium-M]: apropos man.\n\
+ man\n\
+ manual\n\
+ latex_manual\n\
+ window_command\n\
+ opium_command_in_module\n\
+ print_man\n\
+" ).
+
+apropos_Op(X) :-
+ findall(Result, apropos(X, Result), Found),
+ display_apropos_result(Found),
+ nl.
+
+apropos(X, Result) :-
+ setof(Names, get_help_info(_, Names,_,_,_,_,_,_,_,_), L),
+ maplist(atom_string, L, Lstr),
+ atom_string(X, Xstr),
+ find_in_list(Xstr, Lstr, Result).
+
+% get_help_info(Type, Name, ArgList, ArgType, Abbrev, Scenario, Module, Message,
+% DefaultValue, ObjType)
+
+
+find_in_list(String, [Names|_], Names) :-
+ substring(Names, String, _).
+find_in_list(String, [_|Xs], Result) :-
+ find_in_list(String, Xs, Result).
+
+display_apropos_result([]).
+display_apropos_result([NamesStr|Xs]) :-
+ atom_string(Names, NamesStr),
+ get_help_info(Type, Names,_,_,Abbrev,_,_,_,_,_),
+ (
+ nonvar(Abbrev),
+ ( Type = commands ; Type = primitives),
+ printf(" %s (%w)\n", [Names, Abbrev]),
+ !
+ ;
+ printf(" %s\n", [Names])
+ ),
+ display_apropos_result(Xs).
+
+% To avoid typing brackets when using the apropos command.
+:- op(1190, fy, apropos).
+:- op(1190, fy, a).
|