2006-01-31 00:51:50 +08:00
|
|
|
/** \file parse_util.h
|
|
|
|
|
2006-02-19 09:54:38 +08:00
|
|
|
Various mostly unrelated utility functions related to parsing,
|
|
|
|
loading and evaluating fish code.
|
2006-01-31 00:51:50 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef FISH_PARSE_UTIL_H
|
|
|
|
#define FISH_PARSE_UTIL_H
|
|
|
|
|
|
|
|
#include <wchar.h>
|
|
|
|
|
|
|
|
/**
|
2006-02-19 09:54:38 +08:00
|
|
|
Find the beginning and end of the first subshell in the specified string.
|
2006-01-31 00:51:50 +08: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,
|
|
|
|
const wchar_t **begin,
|
|
|
|
const wchar_t **end,
|
|
|
|
int allow_incomplete );
|
|
|
|
|
2006-02-09 02:47:37 +08:00
|
|
|
/**
|
|
|
|
Find the beginning and end of the command substitution under the cursor
|
2006-02-19 09:54:38 +08: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-09 02:47:37 +08:00
|
|
|
*/
|
2006-01-31 00:51:50 +08:00
|
|
|
void parse_util_cmdsubst_extent( const wchar_t *buff,
|
|
|
|
int cursor_pos,
|
|
|
|
const wchar_t **a,
|
|
|
|
const wchar_t **b );
|
|
|
|
|
2006-02-09 02:47:37 +08:00
|
|
|
/**
|
|
|
|
Find the beginning and end of the process definition under the cursor
|
2006-02-19 09:54:38 +08: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-09 02:47:37 +08:00
|
|
|
*/
|
2006-01-31 00:51:50 +08:00
|
|
|
void parse_util_process_extent( const wchar_t *buff,
|
2006-02-19 09:54:38 +08:00
|
|
|
int cursor_pos,
|
2006-01-31 00:51:50 +08:00
|
|
|
const wchar_t **a,
|
|
|
|
const wchar_t **b );
|
|
|
|
|
|
|
|
|
2006-02-09 02:47:37 +08:00
|
|
|
/**
|
|
|
|
Find the beginning and end of the job definition under the cursor
|
2006-02-19 09:54:38 +08: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-09 02:47:37 +08:00
|
|
|
*/
|
2006-01-31 00:51:50 +08:00
|
|
|
void parse_util_job_extent( const wchar_t *buff,
|
2006-02-19 09:54:38 +08:00
|
|
|
int cursor_pos,
|
2006-01-31 00:51:50 +08:00
|
|
|
const wchar_t **a,
|
|
|
|
const wchar_t **b );
|
|
|
|
|
2006-02-09 02:47:37 +08:00
|
|
|
/**
|
|
|
|
Find the beginning and end of the token under the cursor
|
2006-02-19 09:54:38 +08: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-09 02:47:37 +08:00
|
|
|
*/
|
2006-01-31 00:51:50 +08:00
|
|
|
void parse_util_token_extent( const wchar_t *buff,
|
|
|
|
int cursor_pos,
|
|
|
|
const wchar_t **tok_begin,
|
|
|
|
const wchar_t **tok_end,
|
|
|
|
const wchar_t **prev_begin,
|
|
|
|
const wchar_t **prev_end );
|
|
|
|
|
2006-02-09 02:47:37 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
Get the linenumber at the specified character offset
|
|
|
|
*/
|
2006-02-05 21:10:35 +08:00
|
|
|
int parse_util_lineno( const wchar_t *str, int len );
|
|
|
|
|
2006-02-09 02:47:37 +08:00
|
|
|
/**
|
|
|
|
Autoload the specified file, if it exists in the specified path. Do
|
|
|
|
not load it multiple times unless it's timestamp changes.
|
|
|
|
|
|
|
|
\param cmd the filename to search for. The suffix '.fish' is always added to this name
|
|
|
|
\param path_var a list of paths to search in.
|
|
|
|
\param on_load a callback function to run if a suitable file is found, which has not already been run
|
|
|
|
\param reload wheter to recheck file timestamps on already loaded files
|
|
|
|
*/
|
2006-02-08 17:20:05 +08:00
|
|
|
int parse_util_load( const wchar_t *cmd,
|
|
|
|
const wchar_t *path_var,
|
|
|
|
void (*on_load)(const wchar_t *cmd),
|
|
|
|
int reload );
|
|
|
|
|
2006-02-19 09:54:38 +08:00
|
|
|
/**
|
|
|
|
Reset the loader for the specified path value
|
|
|
|
*/
|
2006-02-15 10:46:44 +08:00
|
|
|
void parse_util_load_reset( const wchar_t *path_var );
|
|
|
|
|
2006-02-15 10:24:15 +08:00
|
|
|
/**
|
|
|
|
Set the argv environment variable to the specified null-terminated
|
2006-02-19 09:54:38 +08:00
|
|
|
array of strings.
|
2006-02-15 10:24:15 +08:00
|
|
|
*/
|
|
|
|
void parse_util_set_argv( wchar_t **argv );
|
|
|
|
|
2006-02-19 09:14:32 +08:00
|
|
|
/**
|
2006-02-19 09:54:38 +08:00
|
|
|
Make a duplicate of the specified string, unescape wildcard
|
|
|
|
characters but not performing any other character transformation.
|
2006-02-19 09:14:32 +08:00
|
|
|
*/
|
|
|
|
wchar_t *parse_util_unescape_wildcards( const wchar_t *in );
|
|
|
|
|
2006-01-31 00:51:50 +08:00
|
|
|
#endif
|