25 #include "pips_config.h"
38 #include <sys/ioctl.h>
40 #include <sys/filio.h>
43 #include <xview/xview.h>
44 #include <xview/panel.h>
45 #include <xview/notify.h>
107 (void)
printf(
"%s", some_text);
140 char * module_string_list_string =
strdup(
"(");
145 for(i = 0; i < module_list_length; i++) {
146 char * new_module_string_list_string =
150 free(module_string_list_string);
151 module_string_list_string = new_module_string_list_string;
158 free(module_string_list_string);
194 unsigned int number_of_characters_written;
195 char full_path[1000];
199 (void) sprintf(full_path,
"%s/%s%n",
get_cwd(), the_file_name,
200 &number_of_characters_written);
202 number_of_characters_written <
sizeof(full_path));
213 (void) sprintf(
a_string,
"%d", number);
223 char * prompt_string;
225 va_start(ap, first_line);
228 while((prompt_string = va_arg(ap,
char *)) != NULL)
258 int new_module_list_length;
259 int module_list_length = 0;
264 "No workspace selected or created yet !\n");
271 if (module_list_length == 0)
274 prompt_user(
"No module available in this workspace");
278 for(i = 0; i < module_list_length; i++) {
284 if (i == module_list_length)
286 "The module \"%s\" does not exist.\n",
module_name);
289 new_module_list_length = module_list_length;
292 if (module_list_length == 0 || i == module_list_length)
304 bool module_selection_result = TRUE;
311 if (module_selection_result)
329 char * command_name, * command_content;
335 if (separator_index == NULL) {
342 *separator_index =
'\0';
343 command_content = separator_index + 1;
344 debug(2,
"epips_execute_command",
345 "command_name: \"%s\", command_content: \"%s\"\n",
356 "Cannot understand command \"%s\" with argument \"%s\"\n",
357 command_name, command_content);
368 (void) write(fileno(stderr), entry_buffer, length);
381 unsigned long int length)
383 pips_assert(
"add_command_to_buffer in emacs.c: command too big !!!",
400 char * epips_packet_begin_position =
401 (
char*) index(entry_buffer,
403 debug(8,
"unframe_commands_from_emacs",
404 "epips_packet_begin_position = %8X\n", epips_packet_begin_position);
405 if (epips_packet_begin_position == NULL) {
409 entry_buffer += *length;
416 epips_packet_begin_position - entry_buffer);
422 *length -= epips_packet_begin_position + 1 - entry_buffer;
423 return epips_packet_begin_position + 1;
428 char * epips_packet_end_position =
429 (
char*) index(entry_buffer,
431 debug(8,
"unframe_commands_from_emacs",
432 "epips_packet_end_position = %8X\n", epips_packet_end_position);
433 if (epips_packet_end_position == NULL) {
438 entry_buffer += *length;
444 epips_packet_end_position - entry_buffer);
449 *length -= epips_packet_end_position + 1 - entry_buffer;
450 return epips_packet_end_position + 1;
461 char emacs_entry_buffer[1000];
466 if (ioctl(fd, FIONREAD, &length) == -1 || length == 0) {
471 debug(3,
"read_commands_from_emacs",
472 "Detach the notifyer from stdin (length to read is %d)\n",
474 (void) notify_set_input_func(client,
480 long int read_length;
481 char * entry_buffer = emacs_entry_buffer;
483 read_length = read(fd,
485 sizeof(emacs_entry_buffer) - 1);
486 if (read_length > 0) {
487 long int analyze_length = read_length;
490 emacs_entry_buffer[length] =
'\0';
491 debug(9,
"read_commands_from_emacs",
"Read got \"%s\"\n",
496 debug(8,
"unframe_commands_from_emacs",
"Return \"%s\"\n",
501 }
while (read_length > 0 && (length -= read_length) > 0);
515 Notify_client notifier_client = (Notify_client) 1234;
520 (void) notify_set_input_func(notifier_client,
size_t gen_array_nitems(const gen_array_t a)
void gen_array_full_free(gen_array_t a)
void * gen_array_item(const gen_array_t a, size_t i)
static unsigned int command_buffer_length
static char EMACS_AVAILABLE_MODULES_NAME[]
The title of the commands used by the emacs interface:
static void epips_execute_command(char *command_buffer)
void initialize_emacs_mode()
The function to initialize some things in the emacs mode:
static bool epips_select_module(char *module_name)
Here are described all the functions used to receive informations from emacs:
void ask_emacs_to_open_a_new_daVinci_context()
void send_the_names_of_the_available_modules_to_emacs(void)
Tell Emacs about what are the modules available in the current workspace, if any:
static void send_command_to_emacs(char *command_title, char *command_content)
The function that frames the command to emacs:
void send_user_error_to_emacs(char *some_text)
static epips_input_automaton_states epips_input_automaton_state
void send_prompt_user_to_emacs(char *some_text)
void ask_emacs_to_display_a_graph(string file_name)
@ EPIPS_COMMAND_BUFFER_SIZE
void send_user_warning_to_emacs(char *some_text)
static char EMACS_MODULE_NAME[]
static char command_buffer[EPIPS_COMMAND_BUFFER_SIZE]
bool wpips_emacs_mode
Here are all the stuff to interface Pips with Emacs.
void send_window_number_to_emacs(int number)
static char EMACS_VIEW_DAVINCI_GRAPH[]
static void epips_sequential_view(char *module_name)
Emacs said to display a sequential view:
epips_input_automaton_states
At initialization, we are waiting for an input command:
static Notify_value read_commands_from_emacs(Notify_client client, int fd)
The function that accept commands from emacs:
static char epips_begin_of_command_token[]
The token to mark the begin and end of command.
static char epips_end_of_command_token[]
static void trow_away_epips_input(char *entry_buffer, long int length)
static void epips_execute_and_display_something(char *view_label, char *module_name)
Emacs said to display a sequential view:
static char EMACS_PROMPT_USER[]
void send_view_to_emacs(char *view_name, char *the_file_name)
void send_user_log_to_emacs(char *some_text)
void send_module_name_to_emacs(char *some_text)
Here are all the methods used to send an object to Emacs:
static char EMACS_USER_LOG[]
static void send_text_to_emacs(char *some_text)
Here are described all the functions used to send informations to emacs:
static char EMACS_SEQUENTIAL_VIEW[]
static char epips_receive_begin_of_command_token[]
static char EMACS_WINDOW_NUMBER[]
void send_notice_prompt_to_emacs(char *first_line,...)
static void add_command_to_buffer(char *entry_buffer, unsigned long int length)
Copy a part of the entry_buffer in the command_buffer:
static char * unframe_commands_from_emacs(char *entry_buffer, long int *length)
Try to unframe one half of command sent by emacs.
static char epips_receive_end_of_command_token[]
static char EMACS_USER_WARNING[]
static char EMACS_NEW_DAVINCI_CONTEXT[]
static char EMACS_USER_ERROR[]
const char * module_name(const char *s)
Return the module part of an entity name.
char * get_cwd(void)
returns the current working directory name.
gen_array_t db_get_module_list(void)
Get an array of all the modules (functions, procedures and compilation units) of a workspace.
void prompt_user(string a_printf_format,...)
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
#define user_warning(fn,...)
void debug(const int the_expected_debug_level, const char *calling_function_name, const char *a_message_format,...)
ARARGS0.
string concatenate(const char *,...)
Return the concatenation of the given strings.
string db_get_current_workspace_name(void)
the function is used to check that there is some current workspace...
void set_bool_property(const char *, bool)
#define INITIAL_NUMBER_OF_WPIPS_WINDOWS
void wpips_execute_and_display_something_from_alias(char *alias_name)
To execute something and display some Pips output with wpips or epips by knowing its alias:
void end_select_module_notify(string name)