SLrline_Type *SLrline_open2 (SLFUTURE_CONST char *name, unsigned int width, unsigned int flags) { SLrline_Type *rli; SLrline_Type *arli; char hookname [1024]; if (NULL == (rli = SLrline_open (width, flags))) return NULL; if (NULL != rli->name) SLang_free_slstring (rli->name); if (NULL == (rli->name = SLang_create_slstring (name))) { SLrline_close (rli); return NULL; } arli = Active_Rline_Info; Active_Rline_Info = rli; SLsnprintf (hookname, sizeof(hookname), "%s_rline_open_hook", name); if (0 == SLang_run_hooks (hookname, 0)) (void) SLang_run_hooks ("rline_open_hook", 1, name); Active_Rline_Info = arli; return rli; }
void SLrline_close (SLrline_Type *rli) { if (rli == NULL) return; if (rli->name != NULL) { char hookname[1024]; SLrline_Type *arli = Active_Rline_Info; Active_Rline_Info = rli; SLsnprintf (hookname, sizeof(hookname), "%s_rline_close_hook", rli->name); if (0 == SLang_run_hooks (hookname, 0)) (void) SLang_run_hooks ("rline_close_hook", 1, rli->name); Active_Rline_Info = arli; SLang_free_slstring (rli->name); } free_history (rli->root); free_history_item (rli->saved_line); SLang_free_function (rli->list_completions_callback); SLang_free_function (rli->completion_callback); SLfree ((char *)rli->prompt); SLfree ((char *)rli->buf); SLfree ((char *)rli); }
static void suspend_slsh (void) { reset_tty (); (void) SLang_run_hooks ("slsh_readline_suspend_before_hook", 0); kill (0, SIGSTOP); (void) SLang_run_hooks ("slsh_readline_suspend_after_hook", 0); init_tty (); if (Active_Rline_Info != NULL) { SLsig_block_signals (); SLrline_set_display_width (Active_Rline_Info->rli, SLtt_Screen_Cols); SLrline_redraw (Active_Rline_Info->rli); SLsig_unblock_signals (); } }
int input_new_helptopic(struct dsc$descriptor_s *newtopic, /*{{{*/ struct dsc$descriptor_s *prompt, unsigned int *len_newtopic) { char *newtop, prompt_buf[256]; int dofree; strncpy(prompt_buf,prompt->dsc$a_pointer,prompt->dsc$w_length); prompt_buf[prompt->dsc$w_length] = 0; newtop = ""; dofree = 0; if ((SLang_run_hooks("vms_help_newtopic", 1, prompt_buf + 2) > 0) && (0 == SLpop_string (&newtop))) dofree = 1; strcpy (newtopic->dsc$a_pointer, newtop); *len_newtopic = newtopic->dsc$w_length = strlen (newtop); newtopic->dsc$b_dtype = DSC$K_DTYPE_T; newtopic->dsc$b_class = DSC$K_CLASS_S; if (dofree) SLfree(newtop); return(1); /* should add codes that LIB$GET_INPUT can return */ }
static int move_to_hook_matched_hdu (cfitsfile *fptr, const char *hook_name) { SLang_Array_Type *as = NULL; int status = -1; SLindex_Type i, num; char *s; if (hook_name == NULL) return -1; /* Does the user-defined hook exist? */ if (2 != SLang_is_defined ((char *) hook_name)) return -1; if ((-1 == SLang_run_hooks ((char *)hook_name, 0)) || (-1 == SLang_pop_array_of_type (&as, SLANG_STRING_TYPE))) goto return_error; num = as->num_elements; for (i = 0; i < num; i++) { if (-1 == SLang_get_array_element (as, &i, &s)) goto return_error; if (0 == cfits_movnam_hdu (fptr, s)) { status = 0; break; } } return_error: SLang_free_array (as); return status; }
int slsh_interactive (void) { Slsh_Quit = 0; (void) SLang_add_cleanup_function (close_interactive); if (-1 == open_interactive ()) return -1; (void) SLang_run_hooks ("slsh_interactive_hook", 0); while (Slsh_Quit == 0) { if (SLang_get_error ()) { SLang_restart(1); /* SLang_set_error (0); */ } SLKeyBoard_Quit = 0; SLang_load_object (Readline_Load_Object); } close_interactive (); return 0; }
int isis_fit_report_statistic (Isis_Fit_Type *f, FILE *fp, double stat, unsigned int npts, unsigned int nvpars) /*{{{*/ { if ((f == NULL) || (f->stat->report == NULL)) return -1; if (Isis_Verbose >= 0) { (void) SLang_run_hooks ("_isis->check_optimizer_context", 0); } return f->stat->report (f->stat, fp, stat, npts, nvpars); }
static char *read_using_readline (SLang_Load_Type *x) { char *s; static char *last_s; if (last_s != NULL) { SLfree (last_s); last_s = NULL; } if (SLang_get_error ()) return NULL; SLKeyBoard_Quit = 0; s = get_input_line (x); if (s == NULL) return NULL; if ((x->parse_level == 0) && (1 == SLang_run_hooks ("slsh_interactive_massage_hook", 1, s))) { SLfree (s); if (-1 == SLpop_string (&s)) return NULL; } if (SLang_get_error ()) { SLfree (s); return NULL; } last_s = s; return s; }
/* This routine is a mess and it, do_dialog, and the Mini_Ghost flag needs * to be totally redesigned. */ void update(Line *line, int force, int flag, int run_update_hook) { int pc_flag = 1; int col; static unsigned long last_time; Line *hscroll_line_save; if (0 == Jed_Display_Initialized) return; #if JED_HAS_SUBPROCESSES if (Child_Status_Changed_Flag) { jed_get_child_status (); force = 1; } #endif if (Batch) return; if (!force && !SLang_get_error () && !SLKeyBoard_Quit && (!*Error_Buffer)) { if (screen_input_pending (0)) { JWindow->trashed = 1; return; } } if (last_time + 30 < Status_This_Time) { if (last_time == 0) last_time = Status_This_Time; else { last_time = Status_This_Time; if (SLang_run_hooks ("update_timer_hook", 0)) flag = 0; } } if (run_update_hook && (CBuf->buffer_hooks != NULL) && (CBuf->buffer_hooks->update_hook != NULL) && (SLang_get_error () == 0)) { Suspend_Screen_Update = 1; SLexecute_function (CBuf->buffer_hooks->update_hook); if (SLang_get_error ()) CBuf->buffer_hooks->update_hook = NULL; } if (Suspend_Screen_Update != 0) { Suspend_Screen_Update = 0; touch_screen (); } if (X_Update_Open_Hook != NULL) (*X_Update_Open_Hook) (); #ifdef FIX_CHAR_WIDTH FIX_CHAR_WIDTH; #endif col = calculate_column (); HScroll_Line = NULL; if (Wants_HScroll) set_hscroll(col); else HScroll = 0; hscroll_line_save = HScroll_Line; if (SLang_get_error ()) flag = 0; /* update hook invalidates flag */ if (SLang_get_error () && !(*Error_Buffer || SLKeyBoard_Quit)) { SLang_verror (0, "%s", SLerr_strerror (0)); } if (!flag && (*Error_Buffer || SLKeyBoard_Quit)) { do_dialog(Error_Buffer); #if 0 SLKeyBoard_Quit = 0; SLang_restart(0); SLang_set_error (0); #endif Mini_Ghost = 1; (void) update_1(line, 1); update_minibuffer(); } else if ((flag == 0) && *Message_Buffer) { if (!update_1(line, force)) goto done; do_dialog(Message_Buffer); Mini_Ghost = 1; update_minibuffer(); } else { pc_flag = JWindow->trashed || (JWindow != JWindow->next) || Cursor_Motion; if (!flag) update_minibuffer(); if (!update_1(line, force)) goto done; } if (!flag) *Error_Buffer = *Message_Buffer = 0; #if JED_HAS_MENUS update_top_screen_line (); #else if ((Top_Window_SY > 0) && JScreen[0].is_modified) { update_top_screen_line (); } #endif done: HScroll_Line = hscroll_line_save; if (MiniBuf_Get_Response_String != NULL) { do_dialog (MiniBuf_Get_Response_String); Mini_Ghost = 1; } else if (Point_Cursor_Flag || pc_flag) point_cursor(col); if (X_Update_Close_Hook != NULL) (*X_Update_Close_Hook) (); SLsmg_refresh (); }
void user_close_source (void) { (void) SLang_run_hooks ("user_close_source", 0); }
/* Returns a malloced value */ static char *get_input_line (SLang_Load_Type *x) { char *line; int parse_level; int free_prompt = 0; char *prompt; parse_level = x->parse_level; if (Prompt_Hook != NULL) { if ((-1 == SLang_start_arg_list ()) || (-1 == SLang_push_int (parse_level)) || (-1 == SLang_end_arg_list ()) || (-1 == SLexecute_function (Prompt_Hook)) || (-1 == SLang_pop_slstring (&prompt))) { SLang_verror (SL_RunTime_Error, "Disabling prompt hook"); SLang_free_function (Prompt_Hook); Prompt_Hook = NULL; return NULL; } free_prompt = 1; } else if (parse_level == 0) prompt = (char *) "slsh> "; else prompt = (char *) " "; if (parse_level == 0) { if (-1 == SLang_run_hooks ("slsh_interactive_before_hook", 0)) { if (free_prompt) SLang_free_slstring (prompt); return NULL; } } line = read_input_line (Default_Readline_Info, prompt, 0); if (free_prompt) SLang_free_slstring (prompt); if ((line == NULL) && (parse_level == 0) && (SLang_get_error() == 0)) { Slsh_Quit = 1; return NULL; } if (line == NULL) { return NULL; } /* This hook is used mainly for logging input */ (void) SLang_run_hooks ("slsh_interactive_after_hook", 1, line); (void) save_input_line (Default_Readline_Info, line); return line; }
/* format paragraph and if Prefix argument justify_hook is called. */ int text_format_paragraph () /*{{{*/ { unsigned char *p; int indent_col, col; Line *end, *beg, *next; Jed_Buffer_Hook_Type *h = CBuf->buffer_hooks; CHECK_READ_ONLY if ((h != NULL) && (h->format_paragraph_hook != NULL)) return SLexecute_function (h->format_paragraph_hook); push_spot(); get_current_indent(&indent_col); if (indent_col + 1 >= Buffer_Local.wrap_column) indent_col = 0; if (-1 == mark_paragraph (&beg, &end)) goto return_error; get_current_indent (&col); /* col is the indentation of the first line of the paragraph-- don't change it */ bol (); while (CLine != end) { if (-1 == wrap_line1 (0, 0)) goto return_error; if (0 == jed_down (1)) break; } while ((CLine != beg) && (0 != jed_up (1))) ; if (col + 1 >= Buffer_Local.wrap_column) indent_to (indent_col); bol (); /* Now loop formatting as we go until the end is reached */ while(CLine != end) { int status; /* eol(); */ if (CLine != beg) indent_to(indent_col); status = wrap_line1(1, 1); if (status == -1) goto return_error; if (status == 1) { (void) jed_down(1); /* indent_to(indent_col); */ continue; } else if (CLine->next == end) break; next = CLine->next; if (next != end) { unsigned char *pmax; /* Now count the length of the word on the next line. */ (void) jed_down(1); /* at bol too */ if (-1 == jed_trim_whitespace()) goto return_error; p = CLine->data; pmax = jed_eol_position (CLine); /* FIXME for other multibyte whitespace chars */ while ((p < pmax) && (*p > ' ')) p++; jed_up(1); /* at eol too */ col = calculate_column(); /* FIXME for multibyte */ if ((p - next->data) + col < Buffer_Local.wrap_column - 1) { if (-1 == _jed_replace_wchar (' ')) goto return_error; } else { (void) jed_down(1); } } } if (Repeat_Factor != NULL) { SLang_run_hooks("format_paragraph_hook", 0); Repeat_Factor = NULL; } pop_spot(); return(1); return_error: pop_spot (); return -1; }