mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-12 20:34:19 +00:00
Estimated hours taken: 40
Branches: main
Add support for command line completion to mdb.
NEWS:
Document the change.
trace/mercury_trace_completion.{c,h}:
Define the framework for completion.
Examine command lines to determine which completers to use.
trace/mercury_trace_alias.{c,h}:
trace/mercury_trace_help.{c,h}:
trace/mercury_trace_internal.{c,h}:
trace/mercury_trace_tables.{c,h}:
trace/mercury_trace_vars.{c,h}:
Define context-specific completers.
trace/mercury_trace_help.c:
Record all help topics in an array for use by the completer.
trace/mercury_trace_internal.c:
Add completion information to the list of commands.
Add a function MR_trace_command_completion_info to access
that information.
runtime/mercury_wrapper.{c,h}
Add a runtime option `--force-readline', which tells mdb to
use readline even if MR_mdb_in is not a tty. This is needed
for tests/debugger/completion. `--force-readline' is not
documented because I'm not sure that it will work properly
in all situations (it's fine for the test).
Fix capitalisation in references to the Mercury User's Guide
in error messages.
trace/mercury_trace_readline.c:
Tell Readline to use our completer.
Handle `--force-readline'. Disable some Readline terminal
initialisation code which reports spurious warnings if the
input stream is not a tty.
trace/Mmakefile:
Add mercury_trace_completion.{c,h}.
runtime/mercury_array_macros.h:
Define a macro MR_find_first_match, which is like MR_bsearch
except that it finds the first match, not an arbitrary match.
runtime/mercury_memory.c:
Handle NULL pointers in MR_copy_string();
runtime/mercury_memory.h:
Add a macro MR_free_func which returns the address of free().
Used where it is necessary to pass the address of MR_free().
tests/debugger/Mmakefile:
tests/debugger/completion.m:
tests/debugger/completion.exp:
tests/debugger/completion.inp:
tests/debugger/completion.inputrc:
tests/debugger/completion.sub1.m:
tests/debugger/completion.sub2.m:
tests/debugger/completion.sub2.sub3.m:
Test case.
78 lines
2.2 KiB
C
78 lines
2.2 KiB
C
/*
|
|
** Copyright (C) 1998,2000-2002 The University of Melbourne.
|
|
** This file may only be copied under the terms of the GNU Library General
|
|
** Public License - see the file COPYING.LIB in the Mercury distribution.
|
|
*/
|
|
|
|
/*
|
|
** mercury_trace_alias.h
|
|
**
|
|
** Defines the interface of the alias system for the internal debugger.
|
|
*/
|
|
|
|
#ifndef MERCURY_TRACE_ALIAS_H
|
|
#define MERCURY_TRACE_ALIAS_H
|
|
|
|
#include "mercury_std.h" /* for MR_bool */
|
|
#include <stdio.h>
|
|
|
|
#include "mercury_trace_completion.h"
|
|
|
|
typedef struct {
|
|
char *MR_alias_name;
|
|
char **MR_alias_words;
|
|
int MR_alias_word_count;
|
|
} MR_Alias;
|
|
|
|
/*
|
|
** Add an alias with the given name and expansion to the list.
|
|
** The name, the words in the expansion and the array of pointers to the
|
|
** expansion will all be copied, so their storage can be released
|
|
** when MR_trace_add_alias returns.
|
|
**
|
|
** Overwrites any previous alias with the same name.
|
|
*/
|
|
|
|
extern void MR_trace_add_alias(char *name, char **words,
|
|
int word_count);
|
|
|
|
/*
|
|
** Remove the given alias from the list. Returns MR_FALSE if there is no
|
|
** such alias, and MR_TRUE if there was such an alias and the removal was
|
|
** successful.
|
|
*/
|
|
|
|
extern MR_bool MR_trace_remove_alias(const char *name);
|
|
|
|
/*
|
|
** Looks up whether the given alias exists. If yes, returns MR_TRUE, and
|
|
** sets *words_ptr to point to a vector of words forming the alias expansion,
|
|
** and *word_count_ptr to the number of words in the expansion. If no,
|
|
** returns MR_FALSE.
|
|
*/
|
|
|
|
extern MR_bool MR_trace_lookup_alias(const char *name,
|
|
char ***words_ptr, int *word_count_ptr);
|
|
|
|
/*
|
|
** Print the alias of the given name, if it exists, and an error message
|
|
** if it does not.
|
|
*/
|
|
|
|
extern void MR_trace_print_alias(FILE *fp, const char *name);
|
|
|
|
/*
|
|
** Print all the aliases to the given file. If mdb_command_format is MR_TRUE,
|
|
** print them in a form that, when sourced from mdb , recreate the aliases.
|
|
** Otherwise, print the aliases in a format that is nice for humans to read.
|
|
*/
|
|
|
|
extern void MR_trace_print_all_aliases(FILE *fp,
|
|
MR_bool mdb_command_format);
|
|
|
|
/* A Readline completer for aliases. */
|
|
extern MR_Completer_List *MR_trace_alias_completer(const char *word,
|
|
size_t word_length);
|
|
|
|
#endif /* MERCURY_TRACE_ALIAS_H */
|