2006-01-30 16:51:50 +00:00
|
|
|
/** \file parse_util.h
|
|
|
|
|
2006-02-19 01:54:38 +00:00
|
|
|
Various mostly unrelated utility functions related to parsing,
|
|
|
|
loading and evaluating fish code.
|
2006-01-30 16:51:50 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef FISH_PARSE_UTIL_H
|
|
|
|
#define FISH_PARSE_UTIL_H
|
|
|
|
|
|
|
|
#include <wchar.h>
|
|
|
|
|
|
|
|
/**
|
2006-02-19 01:54:38 +00:00
|
|
|
Find the beginning and end of the first subshell in the specified string.
|
2006-01-30 16:51:50 +00:00
|
|
|
|
|
|
|
\param in the string to search for subshells
|
|
|
|
\param begin the starting paranthesis of the subshell
|
|
|
|
\param end the ending paranthesis of the subshell
|
|
|
|
\param flags set this variable to ACCEPT_INCOMPLETE if in tab_completion mode
|
|
|
|
\return -1 on syntax error, 0 if no subshells exist and 1 on sucess
|
|
|
|
*/
|
|
|
|
|
|
|
|
int parse_util_locate_cmdsubst( const wchar_t *in,
|
2006-06-14 13:22:40 +00:00
|
|
|
wchar_t **begin,
|
|
|
|
wchar_t **end,
|
2006-06-20 00:50:10 +00:00
|
|
|
int flags );
|
2006-01-30 16:51:50 +00:00
|
|
|
|
2006-02-08 18:47:37 +00:00
|
|
|
/**
|
2006-07-03 10:46:47 +00:00
|
|
|
Find the beginning and end of the command substitution under the
|
|
|
|
cursor. If no subshell is found, the entire string is returned. If
|
|
|
|
the current command substitution is not ended, i.e. the closing
|
|
|
|
parenthesis is missing, then the string from the beginning of the
|
|
|
|
substitution to the end of the string is returned.
|
2006-02-19 01:54:38 +00:00
|
|
|
|
|
|
|
\param buff the string to search for subshells
|
|
|
|
\param cursor_pos the position of the cursor
|
|
|
|
\param a the start of the searched string
|
|
|
|
\param b the end of the searched string
|
2006-02-08 18:47:37 +00:00
|
|
|
*/
|
2006-01-30 16:51:50 +00:00
|
|
|
void parse_util_cmdsubst_extent( const wchar_t *buff,
|
|
|
|
int cursor_pos,
|
2006-06-14 13:22:40 +00:00
|
|
|
wchar_t **a,
|
|
|
|
wchar_t **b );
|
2006-01-30 16:51:50 +00:00
|
|
|
|
2006-02-08 18:47:37 +00:00
|
|
|
/**
|
|
|
|
Find the beginning and end of the process definition under the cursor
|
2006-02-19 01:54:38 +00:00
|
|
|
|
|
|
|
\param buff the string to search for subshells
|
|
|
|
\param cursor_pos the position of the cursor
|
|
|
|
\param a the start of the searched string
|
|
|
|
\param b the end of the searched string
|
2006-02-08 18:47:37 +00:00
|
|
|
*/
|
2006-01-30 16:51:50 +00:00
|
|
|
void parse_util_process_extent( const wchar_t *buff,
|
2006-02-19 01:54:38 +00:00
|
|
|
int cursor_pos,
|
2006-06-14 13:22:40 +00:00
|
|
|
wchar_t **a,
|
|
|
|
wchar_t **b );
|
2006-01-30 16:51:50 +00:00
|
|
|
|
|
|
|
|
2006-02-08 18:47:37 +00:00
|
|
|
/**
|
|
|
|
Find the beginning and end of the job definition under the cursor
|
2006-02-19 01:54:38 +00:00
|
|
|
|
|
|
|
\param buff the string to search for subshells
|
|
|
|
\param cursor_pos the position of the cursor
|
|
|
|
\param a the start of the searched string
|
|
|
|
\param b the end of the searched string
|
2006-02-08 18:47:37 +00:00
|
|
|
*/
|
2006-01-30 16:51:50 +00:00
|
|
|
void parse_util_job_extent( const wchar_t *buff,
|
2006-02-19 01:54:38 +00:00
|
|
|
int cursor_pos,
|
2006-06-14 13:22:40 +00:00
|
|
|
wchar_t **a,
|
|
|
|
wchar_t **b );
|
2006-01-30 16:51:50 +00:00
|
|
|
|
2006-02-08 18:47:37 +00:00
|
|
|
/**
|
2006-06-20 00:50:10 +00:00
|
|
|
Find the beginning and end of the token under the cursor and the
|
|
|
|
toekn before the current token. Any combination of tok_begin,
|
|
|
|
tok_end, prev_begin and prev_end may be null.
|
2006-02-19 01:54:38 +00:00
|
|
|
|
|
|
|
\param buff the string to search for subshells
|
|
|
|
\param cursor_pos the position of the cursor
|
2006-06-20 00:50:10 +00:00
|
|
|
\param tok_begin the start of the current token
|
|
|
|
\param tok_end the end of the current token
|
|
|
|
\param prev_begin the start o the token before the current token
|
|
|
|
\param prev_end the end of the token before the current token
|
2006-02-08 18:47:37 +00:00
|
|
|
*/
|
2006-01-30 16:51:50 +00:00
|
|
|
void parse_util_token_extent( const wchar_t *buff,
|
|
|
|
int cursor_pos,
|
2006-06-14 13:22:40 +00:00
|
|
|
wchar_t **tok_begin,
|
|
|
|
wchar_t **tok_end,
|
|
|
|
wchar_t **prev_begin,
|
|
|
|
wchar_t **prev_end );
|
2006-01-30 16:51:50 +00:00
|
|
|
|
2006-02-08 18:47:37 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Get the linenumber at the specified character offset
|
|
|
|
*/
|
2006-02-05 13:10:35 +00:00
|
|
|
int parse_util_lineno( const wchar_t *str, int len );
|
|
|
|
|
2006-02-08 18:47:37 +00:00
|
|
|
/**
|
|
|
|
Autoload the specified file, if it exists in the specified path. Do
|
2006-07-12 14:22:42 +00:00
|
|
|
not load it multiple times unless it's timestamp changes or
|
|
|
|
parse_util_unload is called.
|
2006-02-08 18:47:37 +00:00
|
|
|
|
2006-10-10 22:45:46 +00:00
|
|
|
Autoloading one file may unload another.
|
|
|
|
|
2006-02-08 18:47:37 +00:00
|
|
|
\param cmd the filename to search for. The suffix '.fish' is always added to this name
|
2006-07-12 14:22:42 +00:00
|
|
|
\param path_var_name the environment variable giving the search path
|
2006-10-19 11:46:32 +00:00
|
|
|
\param on_unload a callback function to run if a suitable file is found, which has not already been run. unload will also be called for old files which are unloaded.
|
2006-02-08 18:47:37 +00:00
|
|
|
\param reload wheter to recheck file timestamps on already loaded files
|
|
|
|
*/
|
2006-02-08 09:20:05 +00:00
|
|
|
int parse_util_load( const wchar_t *cmd,
|
2006-02-19 17:01:16 +00:00
|
|
|
const wchar_t *path_var_name,
|
2006-10-19 11:46:32 +00:00
|
|
|
void (*on_unload)(const wchar_t *cmd),
|
2006-02-08 09:20:05 +00:00
|
|
|
int reload );
|
|
|
|
|
2006-02-19 01:54:38 +00:00
|
|
|
/**
|
2006-07-12 14:22:42 +00:00
|
|
|
Reset the loader for the specified path variable. This will cause
|
|
|
|
all information on loaded files in the specified directory to be
|
|
|
|
reset.
|
|
|
|
|
|
|
|
\param path_var_name the environment variable giving the search path
|
2006-10-19 11:46:32 +00:00
|
|
|
\param on_unload a callback function which will be called before (re)loading a file, may be used to unload the previous file.
|
2006-07-12 14:22:42 +00:00
|
|
|
*/
|
|
|
|
void parse_util_load_reset( const wchar_t *path_var_name,
|
2006-10-19 11:46:32 +00:00
|
|
|
void (*on_unload)(const wchar_t *cmd) );
|
2006-07-12 14:22:42 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Tell the autoloader that the specified file, in the specified path,
|
|
|
|
is no longer loaded.
|
|
|
|
|
|
|
|
\param cmd the filename to search for. The suffix '.fish' is always added to this name
|
|
|
|
\param path_var_name the environment variable giving the search path
|
2006-10-19 11:46:32 +00:00
|
|
|
\param on_unload a callback function which will be called before (re)loading a file, may be used to unload the previous file.
|
2006-07-12 14:22:42 +00:00
|
|
|
\return non-zero if the file was removed, zero if the file had not yet been loaded
|
2006-02-19 01:54:38 +00:00
|
|
|
*/
|
2006-07-12 14:22:42 +00:00
|
|
|
int parse_util_unload( const wchar_t *cmd,
|
|
|
|
const wchar_t *path_var_name,
|
2006-10-19 11:46:32 +00:00
|
|
|
void (*on_unload)(const wchar_t *cmd) );
|
2006-02-15 02:46:44 +00:00
|
|
|
|
2006-02-15 02:24:15 +00:00
|
|
|
/**
|
|
|
|
Set the argv environment variable to the specified null-terminated
|
2006-02-19 01:54:38 +00:00
|
|
|
array of strings.
|
2006-02-15 02:24:15 +00:00
|
|
|
*/
|
2007-04-16 20:06:11 +00:00
|
|
|
void parse_util_set_argv( wchar_t **argv, array_list_t *named_arguments );
|
2006-02-15 02:24:15 +00:00
|
|
|
|
2006-02-19 01:14:32 +00:00
|
|
|
/**
|
2006-02-19 01:54:38 +00:00
|
|
|
Make a duplicate of the specified string, unescape wildcard
|
|
|
|
characters but not performing any other character transformation.
|
2006-02-19 01:14:32 +00:00
|
|
|
*/
|
|
|
|
wchar_t *parse_util_unescape_wildcards( const wchar_t *in );
|
|
|
|
|
2006-01-30 16:51:50 +00:00
|
|
|
#endif
|