parent
7f40cf6a9e
commit
07bae6a264
|
@ -11,9 +11,9 @@ libEterm_la_SOURCES = actions.c actions.h buttons.c buttons.h command.c
|
||||||
events.c events.h feature.h font.c font.h grkelot.c \
|
events.c events.h feature.h font.c font.h grkelot.c \
|
||||||
grkelot.h icon.h menus.c menus.h misc.c misc.h netdisp.c \
|
grkelot.h icon.h menus.c menus.h misc.c misc.h netdisp.c \
|
||||||
options.c options.h pixmap.c pixmap.h profile.h screen.c \
|
options.c options.h pixmap.c pixmap.h profile.h screen.c \
|
||||||
screen.h scrollbar.c scrollbar.h startup.c startup.h \
|
screen.h script.c script.h scrollbar.c scrollbar.h \
|
||||||
system.c system.h term.c term.h timer.c timer.h utmp.c \
|
startup.c startup.h system.c system.h term.c term.h \
|
||||||
windows.c windows.h
|
timer.c timer.h utmp.c windows.c windows.h
|
||||||
EXTRA_libEterm_la_SOURCES = $(MMX_SRCS)
|
EXTRA_libEterm_la_SOURCES = $(MMX_SRCS)
|
||||||
|
|
||||||
libEterm_la_LDFLAGS = -release $(VERSION)
|
libEterm_la_LDFLAGS = -release $(VERSION)
|
||||||
|
|
|
@ -38,6 +38,7 @@ static const char cvs_ident[] = "$Id$";
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
#include "pixmap.h"
|
#include "pixmap.h"
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
|
#include "script.h"
|
||||||
#include "scrollbar.h"
|
#include "scrollbar.h"
|
||||||
#include "term.h"
|
#include "term.h"
|
||||||
#include "windows.h"
|
#include "windows.h"
|
||||||
|
@ -63,9 +64,9 @@ action_handle_echo(event_t *ev, action_t *action) {
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char
|
unsigned char
|
||||||
action_handle_function(event_t *ev, action_t *action) {
|
action_handle_script(event_t *ev, action_t *action) {
|
||||||
REQUIRE_RVAL(action->param.string != NULL, 0);
|
REQUIRE_RVAL(action->param.script != NULL, 0);
|
||||||
/* To be continued.... :-) */
|
script_parse(action->param.script);
|
||||||
return 1;
|
return 1;
|
||||||
ev = NULL;
|
ev = NULL;
|
||||||
}
|
}
|
||||||
|
@ -165,7 +166,7 @@ action_add(unsigned short mod, unsigned char button, KeySym keysym, action_type_
|
||||||
action->next = action_list;
|
action->next = action_list;
|
||||||
action_list = action;
|
action_list = action;
|
||||||
} else {
|
} else {
|
||||||
if (action->type == ACTION_STRING || action->type == ACTION_ECHO || action->type == ACTION_FUNCTION) {
|
if (action->type == ACTION_STRING || action->type == ACTION_ECHO || action->type == ACTION_SCRIPT) {
|
||||||
if (action->param.string) {
|
if (action->param.string) {
|
||||||
FREE(action->param.string);
|
FREE(action->param.string);
|
||||||
}
|
}
|
||||||
|
@ -188,11 +189,10 @@ action_add(unsigned short mod, unsigned char button, KeySym keysym, action_type_
|
||||||
strcpy(action->param.string, (char *) param);
|
strcpy(action->param.string, (char *) param);
|
||||||
parse_escaped_string(action->param.string);
|
parse_escaped_string(action->param.string);
|
||||||
break;
|
break;
|
||||||
case ACTION_FUNCTION:
|
case ACTION_SCRIPT:
|
||||||
action->handler = (action_handler_t) action_handle_function;
|
action->handler = (action_handler_t) action_handle_script;
|
||||||
action->param.string = (char *) MALLOC(strlen((char *) param) + 2);
|
action->param.script = (char *) MALLOC(strlen((char *) param) + 2);
|
||||||
strcpy(action->param.string, (char *) param);
|
strcpy(action->param.script, (char *) param);
|
||||||
parse_escaped_string(action->param.string);
|
|
||||||
break;
|
break;
|
||||||
case ACTION_MENU:
|
case ACTION_MENU:
|
||||||
action->handler = (action_handler_t) action_handle_menu;
|
action->handler = (action_handler_t) action_handle_menu;
|
||||||
|
|
|
@ -35,7 +35,7 @@ typedef enum {
|
||||||
ACTION_NONE = 0,
|
ACTION_NONE = 0,
|
||||||
ACTION_STRING,
|
ACTION_STRING,
|
||||||
ACTION_ECHO,
|
ACTION_ECHO,
|
||||||
ACTION_FUNCTION,
|
ACTION_SCRIPT,
|
||||||
ACTION_MENU
|
ACTION_MENU
|
||||||
} action_type_t;
|
} action_type_t;
|
||||||
|
|
||||||
|
@ -70,6 +70,7 @@ struct action_struct {
|
||||||
action_handler_t handler;
|
action_handler_t handler;
|
||||||
union {
|
union {
|
||||||
char *string;
|
char *string;
|
||||||
|
char *script;
|
||||||
menu_t *menu;
|
menu_t *menu;
|
||||||
} param;
|
} param;
|
||||||
struct action_struct *next;
|
struct action_struct *next;
|
||||||
|
@ -83,7 +84,7 @@ _XFUNCPROTOBEGIN
|
||||||
|
|
||||||
extern unsigned char action_handle_string(event_t *ev, action_t *action);
|
extern unsigned char action_handle_string(event_t *ev, action_t *action);
|
||||||
extern unsigned char action_handle_echo(event_t *ev, action_t *action);
|
extern unsigned char action_handle_echo(event_t *ev, action_t *action);
|
||||||
extern unsigned char action_handle_function(event_t *ev, action_t *action);
|
extern unsigned char action_handle_script(event_t *ev, action_t *action);
|
||||||
extern unsigned char action_handle_menu(event_t *ev, action_t *action);
|
extern unsigned char action_handle_menu(event_t *ev, action_t *action);
|
||||||
extern action_t *action_find_match(unsigned short mod, unsigned char button, KeySym keysym);
|
extern action_t *action_find_match(unsigned short mod, unsigned char button, KeySym keysym);
|
||||||
extern unsigned char action_dispatch(event_t *ev, KeySym keysym);
|
extern unsigned char action_dispatch(event_t *ev, KeySym keysym);
|
||||||
|
|
|
@ -40,6 +40,7 @@ static const char cvs_ident[] = "$Id$";
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
#include "pixmap.h"
|
#include "pixmap.h"
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
|
#include "script.h"
|
||||||
#include "term.h"
|
#include "term.h"
|
||||||
#include "windows.h"
|
#include "windows.h"
|
||||||
|
|
||||||
|
@ -654,6 +655,10 @@ button_set_action(button_t *button, action_type_t type, char *action)
|
||||||
strcpy(button->action.string, action);
|
strcpy(button->action.string, action);
|
||||||
parse_escaped_string(button->action.string);
|
parse_escaped_string(button->action.string);
|
||||||
break;
|
break;
|
||||||
|
case ACTION_SCRIPT:
|
||||||
|
button->action.script = (char *) MALLOC(strlen(action) + 2);
|
||||||
|
strcpy(button->action.script, action);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -736,8 +741,9 @@ button_check_action(buttonbar_t *bbar, button_t *button, unsigned char press, Ti
|
||||||
tt_write((unsigned char *) button->action.string, strlen(button->action.string));
|
tt_write((unsigned char *) button->action.string, strlen(button->action.string));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ACTION_FUNCTION:
|
case ACTION_SCRIPT:
|
||||||
if (!press) {
|
if (!press) {
|
||||||
|
script_parse((char *) button->action.script);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -62,6 +62,7 @@ typedef struct button_struct {
|
||||||
action_type_t type;
|
action_type_t type;
|
||||||
union {
|
union {
|
||||||
menu_t *menu;
|
menu_t *menu;
|
||||||
|
char *script;
|
||||||
char *string;
|
char *string;
|
||||||
} action;
|
} action;
|
||||||
char *text;
|
char *text;
|
||||||
|
|
|
@ -1043,7 +1043,8 @@ handle_child_signal(int sig)
|
||||||
/* If the child that exited is the command we spawned, or if the
|
/* If the child that exited is the command we spawned, or if the
|
||||||
child exited before fork() returned in the parent, it must be
|
child exited before fork() returned in the parent, it must be
|
||||||
our immediate child that exited. We exit gracefully. */
|
our immediate child that exited. We exit gracefully. */
|
||||||
if (pid == cmd_pid && cmd_pid != -1) {
|
if ((pid == cmd_pid && cmd_pid != -1)
|
||||||
|
|| (pid == -1 && errno == ECHILD && cmd_pid != -1)) {
|
||||||
if (Options & Opt_pause) {
|
if (Options & Opt_pause) {
|
||||||
paused = 1;
|
paused = 1;
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -57,6 +57,8 @@
|
||||||
# define D_BBAR(x) DPRINTF2(x)
|
# define D_BBAR(x) DPRINTF2(x)
|
||||||
# define DEBUG_TIMER 2
|
# define DEBUG_TIMER 2
|
||||||
# define D_TIMER(x) DPRINTF2(x)
|
# define D_TIMER(x) DPRINTF2(x)
|
||||||
|
# define DEBUG_SCRIPT 2
|
||||||
|
# define D_SCRIPT(x) DPRINTF2(x)
|
||||||
|
|
||||||
# define DEBUG_MENU 3
|
# define DEBUG_MENU 3
|
||||||
# define D_MENU(x) DPRINTF3(x)
|
# define D_MENU(x) DPRINTF3(x)
|
||||||
|
|
|
@ -267,13 +267,8 @@ inline void *memmove(void *, const void *, size_t);
|
||||||
#define APL_NAME "Eterm"
|
#define APL_NAME "Eterm"
|
||||||
|
|
||||||
/* COLORTERM, TERM environment variables */
|
/* COLORTERM, TERM environment variables */
|
||||||
#ifdef MULTI_CHARSET
|
#define TERMENV "Eterm"
|
||||||
# define TERMENV "kterm"
|
#define COLORTERMENV "Eterm"
|
||||||
# define COLORTERMENV "Eterm"
|
|
||||||
#else
|
|
||||||
# define TERMENV "xterm"
|
|
||||||
# define COLORTERMENV "Eterm"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef NO_MOUSE_REPORT
|
#ifdef NO_MOUSE_REPORT
|
||||||
# ifndef NO_MOUSE_REPORT_SCROLLBAR
|
# ifndef NO_MOUSE_REPORT_SCROLLBAR
|
||||||
|
|
|
@ -1593,28 +1593,6 @@ builtin_appname(char *param)
|
||||||
return (STRDUP(APL_NAME "-" VERSION));
|
return (STRDUP(APL_NAME "-" VERSION));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* chomp() removes leading and trailing whitespace/quotes from a string */
|
|
||||||
char *
|
|
||||||
chomp(char *s)
|
|
||||||
{
|
|
||||||
|
|
||||||
register char *front, *back;
|
|
||||||
|
|
||||||
for (front = s; *front && isspace(*front); front++);
|
|
||||||
/*
|
|
||||||
if (*front == '\"') front++;
|
|
||||||
*/
|
|
||||||
for (back = s + strlen(s) - 1; *back && isspace(*back) && back > front; back--);
|
|
||||||
/*
|
|
||||||
if (*back == '\"') back--;
|
|
||||||
*/
|
|
||||||
|
|
||||||
*(++back) = 0;
|
|
||||||
if (front != s)
|
|
||||||
memmove(s, front, back - front + 1);
|
|
||||||
return (s);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* shell_expand() takes care of shell variable expansion, quote conventions,
|
/* shell_expand() takes care of shell variable expansion, quote conventions,
|
||||||
calling of built-in functions, etc. -- mej */
|
calling of built-in functions, etc. -- mej */
|
||||||
char *
|
char *
|
||||||
|
@ -3027,6 +3005,10 @@ parse_actions(char *buff, void *state)
|
||||||
menu = find_menu_by_title(menu_list, str);
|
menu = find_menu_by_title(menu_list, str);
|
||||||
action_add(mod, button, keysym, ACTION_MENU, (void *) menu);
|
action_add(mod, button, keysym, ACTION_MENU, (void *) menu);
|
||||||
FREE(str);
|
FREE(str);
|
||||||
|
} else if (!BEG_STRCASECMP(str, "script")) {
|
||||||
|
str = get_word(i+1, buff);
|
||||||
|
action_add(mod, button, keysym, ACTION_SCRIPT, (void *) str);
|
||||||
|
FREE(str);
|
||||||
} else {
|
} else {
|
||||||
print_error("Parse error in file %s, line %lu: Syntax error (\"to\" not found)\n", file_peek_path(), file_peek_line());
|
print_error("Parse error in file %s, line %lu: Syntax error (\"to\" not found)\n", file_peek_path(), file_peek_line());
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -3250,6 +3232,8 @@ parse_bbar(char *buff, void *state)
|
||||||
button_set_action(button, ACTION_STRING, action);
|
button_set_action(button, ACTION_STRING, action);
|
||||||
} else if (!BEG_STRCASECMP(type, "echo ")) {
|
} else if (!BEG_STRCASECMP(type, "echo ")) {
|
||||||
button_set_action(button, ACTION_ECHO, action);
|
button_set_action(button, ACTION_ECHO, action);
|
||||||
|
} else if (!BEG_STRCASECMP(type, "script ")) {
|
||||||
|
button_set_action(button, ACTION_SCRIPT, action);
|
||||||
} else {
|
} else {
|
||||||
print_error("Parse error in file %s, line %lu: Invalid button action \"%s\"\n", file_peek_path(), file_peek_line(), type);
|
print_error("Parse error in file %s, line %lu: Invalid button action \"%s\"\n", file_peek_path(), file_peek_line(), type);
|
||||||
FREE(action);
|
FREE(action);
|
||||||
|
|
|
@ -261,7 +261,6 @@ extern unsigned char conf_register_fstate(FILE *fp, char *path, char *outfile, u
|
||||||
extern unsigned char conf_register_builtin(char *name, eterm_func_ptr_t ptr);
|
extern unsigned char conf_register_builtin(char *name, eterm_func_ptr_t ptr);
|
||||||
extern unsigned char conf_register_context_state(unsigned char ctx_id);
|
extern unsigned char conf_register_context_state(unsigned char ctx_id);
|
||||||
extern void conf_free_subsystem(void);
|
extern void conf_free_subsystem(void);
|
||||||
extern char *chomp(char *);
|
|
||||||
extern char *shell_expand(char *);
|
extern char *shell_expand(char *);
|
||||||
extern char *conf_find_file(const char *file, const char *dir, const char *pathlist);
|
extern char *conf_find_file(const char *file, const char *dir, const char *pathlist);
|
||||||
extern FILE *open_config_file(char *name);
|
extern FILE *open_config_file(char *name);
|
||||||
|
|
49
src/script.c
49
src/script.c
|
@ -38,11 +38,12 @@ static const char cvs_ident[] = "$Id$";
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
#include "pixmap.h"
|
#include "pixmap.h"
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
|
#include "script.h"
|
||||||
|
|
||||||
|
#if 0
|
||||||
void
|
void
|
||||||
eterm_handle_winop(char *action)
|
eterm_handle_winop(char *action)
|
||||||
{
|
{
|
||||||
#if 0
|
|
||||||
char *winid;
|
char *winid;
|
||||||
Window win = 0;
|
Window win = 0;
|
||||||
|
|
||||||
|
@ -100,10 +101,54 @@ eterm_handle_winop(char *action)
|
||||||
} else {
|
} else {
|
||||||
print_error("IPC Error: Unrecognized window operation \"%s\"\n", action);
|
print_error("IPC Error: Unrecognized window operation \"%s\"\n", action);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void
|
void
|
||||||
script_parse(char *s)
|
script_parse(char *s)
|
||||||
{
|
{
|
||||||
|
char **token_list, **param_list;
|
||||||
|
register char *pstr;
|
||||||
|
register unsigned long i;
|
||||||
|
char *func_name, *params;
|
||||||
|
size_t len;
|
||||||
|
|
||||||
|
REQUIRE(s != NULL);
|
||||||
|
|
||||||
|
D_SCRIPT(("Parsing: \"%s\"\n", s));
|
||||||
|
|
||||||
|
token_list = split(";", s);
|
||||||
|
if (token_list == NULL) {
|
||||||
|
D_SCRIPT(("No tokens found; ignoring script.\n"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; token_list[i]; i++) {
|
||||||
|
pstr = token_list[i];
|
||||||
|
chomp(pstr);
|
||||||
|
if (!(*pstr)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if ((params = strchr(pstr, '(')) != NULL) {
|
||||||
|
if (params != pstr) {
|
||||||
|
len = params - pstr;
|
||||||
|
func_name = (char *) MALLOC(len + 1);
|
||||||
|
strncpy(func_name, pstr, len);
|
||||||
|
func_name[len] = 0;
|
||||||
|
} else {
|
||||||
|
print_error("Error in script \"%s\": Missing function name before \"%s\".\n", s, params);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
func_name = STRDUP(pstr);
|
||||||
|
}
|
||||||
|
if (func_name) {
|
||||||
|
chomp(func_name);
|
||||||
|
}
|
||||||
|
if (params) {
|
||||||
|
chomp(params);
|
||||||
|
}
|
||||||
|
D_SCRIPT(("Calling function %s with parameters: %s\n", NONULL(func_name), NONULL(params)));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
/************ Function Prototypes ************/
|
/************ Function Prototypes ************/
|
||||||
_XFUNCPROTOBEGIN
|
_XFUNCPROTOBEGIN
|
||||||
|
|
||||||
|
extern void script_parse(char *);
|
||||||
|
|
||||||
_XFUNCPROTOEND
|
_XFUNCPROTOEND
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue