mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-16 01:43:35 +00:00
Estimated hours taken: 0.1 extras/morphine/source/patch.help: Tiny cosmetic change (add a space at the end of a line) to see whether .nocopyright works.
197 lines
6.0 KiB
Plaintext
197 lines
6.0 KiB
Plaintext
--- /soft/eclipse/eclipse4.1/lib_pd/opium_light/help.op Sat Feb 20 16:09:16 1999
|
|
+++ help.op Tue Aug 15 17:03:29 2000
|
|
@@ -41,8 +41,28 @@
|
|
:- tool(show_all/2).
|
|
|
|
help_Op :-
|
|
- opium_write(help, "\nThere are the following help commands: \n"),
|
|
- show_all(commands, help).
|
|
+ write(help,
|
|
+ "\nThere are the following help commands for Morphine: \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.
|
|
+ write(help, "\nAnd here is the help message for ECLiPSe: \n\n"),
|
|
+ write(help,
|
|
+ " After the prompt [<module>]: ECLiPSe waits for a goal.\n"),
|
|
+ write(help,
|
|
+ " To type in clauses, call [user] or compile(user), and then\n"),
|
|
+ write(help,
|
|
+ " enter the clauses ended by ^D (EOF).\n\n"),
|
|
+ write(help,
|
|
+ " Call help(Pred/Arity) or help(Pred) or help(String)\n"),
|
|
+ write(help,
|
|
+ " to get help on a specific built-in predicate.\n\n"),
|
|
+ write(help,
|
|
+ " Call demo (in xeclipse) to invoke the demo programs.\n\n"),
|
|
+ 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),
|
|
@@ -728,16 +750,65 @@
|
|
opium_printf(help, "demo_goal: %w\ncondition: %w\n%w\n", [DemoGoal, Condition, Message]).
|
|
print_man_Op(tty, ArgList, ArgType, Message, DefaultValue, ObjType) :-
|
|
!,
|
|
- opium_printf(help, "%w\n", [Message]),
|
|
+ print_message(help, Message), nl,
|
|
print_arg_type(tty, ArgList, ArgType),
|
|
print_default_value(tty, DefaultValue),
|
|
print_object_type(tty, DefaultValue, ObjType).
|
|
print_man_Op(Manual, ArgList, ArgType, Message, DefaultValue, ObjType) :-
|
|
- writeln(Manual, Message),
|
|
+ print_message(Manual, Message), nl,
|
|
print_arg_type(Manual, ArgList, ArgType),
|
|
print_default_value(Manual, DefaultValue),
|
|
print_object_type(Manual, DefaultValue, ObjType).
|
|
|
|
+
|
|
+% Print on-line help messages in such a way that they fit into 80 columns.
|
|
+print_message(Stream, Msg) :-
|
|
+ % To make sure that Msg is a string
|
|
+ ( string(Msg) -> MsgStr = Msg ; atom_string(Msg, MsgStr) ),
|
|
+ % To take into account the existing `\n\'.
|
|
+ split_string(MsgStr, "\n\\", "", ListStr),
|
|
+ print_message_list(Stream, ListStr).
|
|
+
|
|
+print_message_list(Stream, []).
|
|
+print_message_list(Stream, [X|Tail]) :-
|
|
+ print_message2([Stream, X]),
|
|
+ print_message_list(Stream, Tail).
|
|
+
|
|
+print_message2([Stream, Msg]) :-
|
|
+ Max = 80,
|
|
+ string_length(Msg, Length),
|
|
+ ( Length > Max ->
|
|
+ print_message3(Stream, Msg, Max)
|
|
+ ;
|
|
+ writeln(Stream, Msg)
|
|
+ ).
|
|
+
|
|
+print_message3(Stream, Msg, Max) :-
|
|
+ (
|
|
+ % Make sure that there is at least one " " character in the Msg
|
|
+ % before trying to truncate the line at the first " ".
|
|
+ not(substring(Msg, " ", _)),
|
|
+ write(Stream, Msg),
|
|
+ !
|
|
+ ;
|
|
+ (
|
|
+ % The Max th character is a " ". We truncate the line here.
|
|
+ substring(Msg, " ", Max),
|
|
+ substring(Msg, 1, Max, MsgBegin),
|
|
+ append_strings(MsgBegin, MsgEnd, Msg),
|
|
+ writeln(Stream, MsgBegin),
|
|
+ print_message2([Stream, MsgEnd]),
|
|
+ !
|
|
+ ;
|
|
+ % The Max nt character is not a " ". We recursively try again
|
|
+ % Max - 1.
|
|
+ Max2 is Max - 1,
|
|
+ print_message3(Stream, Msg, Max2)
|
|
+ )
|
|
+ ).
|
|
+% To prevent print_message3/3 from looping. Should not be necessary
|
|
+print_message3(_,_,0).
|
|
+
|
|
print_arg_type(_, _, []) :- !.
|
|
print_arg_type(tty, [Arg | AList], [Type | TList]) :-
|
|
!,
|
|
@@ -777,5 +848,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\
|
|
+[morphine]: 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).
|