All predicatesShow sourceprolog_colour.pl -- Prolog syntax colouring support.

This module defines reusable code to colourise Prolog source.

To be done
- : The one-term version
Source prolog_colourise_stream(+Stream, +SourceID, :ColourItem) is det
Determine colour fragments for the data on Stream. SourceID is the canonical identifier of the input as known to the cross-referencer, i.e., as created using xref_source(SourceID).

ColourItem is a closure that is called for each identified fragment with three additional arguments:

  • The syntactical category
  • Start position (character offset) of the fragment
  • Length of the fragment (in characters).
Source source_module(+State, -Module) is semidet[private]
True when Module is the module context into which the file is loaded. This is the module of the file if File is a module file, or the load context of File if File is not included or the module context of the file into which the file was included.
Source read_error(+Error, +TB, +Start, +Stream) is failure[private]
If this is a syntax error, create a syntax-error fragment.
Source colour_item(+Class, +TB, +Pos) is det[private]
Source safe_push_op(+Prec, +Type, :Name, +State)[private]
Define operators into the default source module and register them to be undone by pop_operators/0.
Source fix_operators(+Term, +Module, +State) is det[private]
Fix flags that affect the syntax, such as operators and some style checking options. Src is the canonical source as required by the cross-referencer.
Source process_use_module(+Imports, +Src)[private]
Get the exported operators from the referenced files.
Source prolog_colourise_query(+Query:string, +SourceId, :ColourItem)
Colourise a query, to be executed in the context of SourceId.
Arguments:
SourceId- Execute Query in the context of the cross-referenced environment SourceID.
Source prolog_colourise_term(+Stream, +SourceID, :ColourItem, +Options)
Colourise the next term on Stream. Unlike prolog_colourise_stream/3, this predicate assumes it is reading a single term rather than the entire stream. This implies that it cannot adjust syntax according to directives that preceed it.

Options:

subterm_positions(-TermPos)
Return complete term-layout. If an error is read, this is a term error_position(StartClause, EndClause, ErrorPos)
Source colourise_term(+Term, +TB, +Termpos, +Comments)[private]
Colourise the next Term.
bug
- The colour spec is closed with fullstop, but the position information does not include the full stop location, so all we can do is assume it is behind the term.
Source structured_comment_start(-Start)[private]
Copied from library(pldoc/doc_process). Unfortunate, but we do not want to force loading pldoc.
Source colourise_term(+Term, +TB, +Pos)[private]
Colorise a file toplevel term.
Source colourise_extended_head(+Head, +ExtraArgs, +TB, +Pos) is det[private]
Colourise a clause-head that is extended by term_expansion, getting ExtraArgs more arguments (e.g., DCGs add two more arguments.
Source colourise_extern_head(+Head, +Module, +TB, +Pos)[private]
Colourise the head specified as Module:Head. Normally used for adding clauses to multifile predicates in other modules.
Source functor_position(+Term, -FunctorPos, -ArgPosList)[private]
Get the position of a functor and its argument. Unfortunately this goes wrong for lists, who have two `functor-positions'.
Source colourise_directive(+Body, +TB, +Pos)[private]
Colourise the body of a directive.
Source colourise_method_body(+MethodBody, +TB, +Pos)[private]
Colourise the optional "comment":: as pce(comment) and proceed with the body.
To be done
- Get this handled by a hook.
Source colourise_goals(+Body, +Origin, +TB, +Pos)[private]
Colourise the goals in a body.
Source colourise_dcg(+Body, +Head, +TB, +Pos)[private]
Breaks down to colourise_dcg_goal/3.
Source colourise_goal(+Goal, +Origin, +TB, +Pos)[private]
Colourise access to a single goal.
To be done
- Quasi Quotations are coloured as a general term argument. Possibly we should do something with the goal information it refers to, in particular if this goal is not defined.
Source colourise_goal_args(+Goal, +TB, +Pos)[private]
Colourise the arguments to a goal. This predicate deals with meta- and database-access predicates.
Source meta_args(+Goal, +TB, -ArgSpec) is semidet[private]
Return a copy of Goal, where each meta-argument is an integer representing the number of extra arguments or the atom // for indicating a DCG body. The non-meta arguments are unbound variables.

E.g. meta_args(maplist(foo,x,y), X) --> X = maplist(2,_,_)

NOTE: this could be cached if performance becomes an issue.

Source expand_meta(+MetaSpec, +Goal, -Expanded) is semidet[private]
Add extra arguments to the goal if the meta-specifier is an integer (see above).
Source colourise_setof(+Term, +TB, +Pos)[private]
Colourise the 2nd argument of setof/bagof
 colourise_option_args(+Goal, +Module, +Arg:integer, +TB, +ArgPos) is semidet[private]
Colourise predicate options for the Arg-th argument of Module:Goal
Source colourise_files(+Arg, +TB, +Pos, +Why)[private]
Colourise the argument list of one of the file-loading predicates.
Arguments:
Why- is one of any or imported
Source colourise_directory(+Arg, +TB, +Pos)[private]
Colourise argument that should be an existing directory.
Source colourise_langoptions(+Term, +TB, +Pos) is det[private]
Colourise the 3th argument of module/3
Source colourise_class(ClassName, TB, Pos)[private]
Colourise an XPCE class.
Source classify_class(+SourceId, +ClassName, -Classification)[private]
Classify an XPCE class. As long as this code is in this module rather than using hooks, we do not want to load xpce unless it is already loaded.
Source colourise_term_args(+Term, +TB, +Pos)[private]
colourise head/body principal terms.
Source colourise_qq_type(+QQType, +TB, +QQTypePos)[private]
Colouring the type part of a quasi quoted term
Source colourise_dict_kv(+Dict, +TB, +KVPosList)[private]
Colourise the name-value pairs in the dict
Source colourise_exports(+List, +TB, +Pos)[private]
Colourise the module export-list (or any other list holding terms of the form Name/Arity referring to predicates).
Source colourise_imports(+List, +File, +TB, +Pos)[private]
Colourise import list from use_module/2, importing from File.
Source colourise_declarations(+Term, +TB, +Pos)[private]
Colourise the Predicate indicator lists of dynamic, multifile, etc declarations.
Source colourise_declaration(+Decl, +TB, +Pos) is det[private]
Colourise declaration sequences as used by module/2, dynamic/1, etc.
Source colourise_op_declaration(Op, TB, Pos) is det[private]
Source colourise_prolog_flag_name(+Name, +TB, +Pos)[private]
Colourise the name of a Prolog flag
Source goal_classification(+TB, +Goal, +Origin, -Class)[private]
Classify Goal appearing in TB and called from a clause with head Origin. For directives, Origin is [].
Source goal_classification(+Goal, -Class)[multifile]
Multifile hookable classification for non-local goals.
Source vararg_goal_classification(+Name, +Arity, -Class) is semidet[multifile]
Multifile hookable classification for vararg predicates.
Source def_style(+Pattern, -Style)[private]
Define the style used for the given pattern. Definitions here can be overruled by defining rules for style/2
Source syntax_colour(?Class, ?Attributes) is nondet
True when a range classified Class must be coloured using Attributes. Attributes is a list of:
  • colour(ColourName)
  • background(ColourName)
  • bold(Boolean)
  • underline(Boolean)

Attributes may be the empty list. This is used for cases where -for example- a menu is associated with the fragment. If syntax_colour/2 fails, no fragment is created for the region.

 term_colours(+Term, -FunctorColour, -ArgColours)[private]
Define colourisation for specific terms.
Source specified_item(+Specified, +Term, +TB, +TermPosition) is det[private]
Colourise an item that is explicitly classified by the user using term_colours/2 or goal_colours/2.
Source specified_items(+Spec, +Term, +TB, +PosList)[private]
Source specified_dict_kv(+PosList, +Term, +TB, +Specs)[private]
Arguments:
Specs- is a list of dict_kv(+Key, +KeySpec, +ArgSpec)

Undocumented predicates

The following predicates are exported, but not or incorrectly documented.

Source syntax_message(Arg1, Arg2, Arg3)