📄 paste.c
字号:
/* Copyright (c) 1995 Entropic Research Laboratory, Inc. *//* Copyright (c) 1987, 1988, 1989 AT&T *//* 1990-1993 Entropic Research Laboratory, Inc. *//* All Rights Reserved. *//* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T *//* AND ENTROPIC RESEARCH LABORATORY, INC. *//* The copyright notice above does not evidence any *//* actual or intended publication of such source code. *//* paste.c *//* Segment Concatenation: ---------------------- Three interactive operations will be supported: insert segment at cursor; prepend segment to file; and append segment to file. How should the source and resulting signals be named? Note that it may be desirable to operate on ensembles of signals. For now, ensemble operations will not be available for splice/paste operations. The "file browser menus" will used as a source of file names for the paste operation. Segments will be set aside using the "save segment in file" operation. The resulting files may then be pasted into any other file of the same type at the cursor location. The paste operation will be added to the right mouse menu; the ability to flag a file as paste source will be added to the browser menus. The file which is the sink for the paste operation will maintain its original start time unless the paste is a prepend in which case the inserted file's start time will be adopted. The file name for the sink will be taken from the OUTPUTfile: item as usual. When the paste operation is performed a disc image of the file will be created and then the display will be updated to reflect the changes. So, the procedure is: Select a source filename from a browser window (entire file will be source). If no name is selected, most recently created "New File" will be used. Enter desired name for sink file in OUTPUTfile: item. If output file is null, quit. Move cursor to desired insert point in sink file display. Select "paste" item from waveform menu. Details of paste operation: -------------------------- Generate an OUTPUTfile name for the sink file. If sink file is SIG_NEW, do a put_signal() (source will always be on disc). Create a temp SIG file for result. Except for ascii/binary differences, source and sink files must agree in type, dimensions and sampling frequency; Source type will be changed to ascii or binary to match sink. Set header start_time, file_size, operator... Put_header() to temp file. Transfer initial part (if any) of sink file to temp file. Transfer source file to temp file. Transfer remainder of sink file to temp file and close it. If all operations were successful, relink the temp file to the desired name, else delete the temp file, yell and quit. If the new filename doesn't appear in the "New Files" list, add it.*/#ifndef lintstatic char *sccs_id = "@(#)paste.c 1.7 9/28/98 ATT/ERL";#endif#include <Objects.h>#include <file_ext.h>#include <esps/esps.h>#include <esps/fea.h>extern void set_pvd();extern int debug_level;extern char *remove_reg_exp();extern char *cleaned_for_input();/*********************************************************************/static char designated_source[NAMELEN] = "";set_designated_source(name) char *name;{ if(name && *name && (strlen(name) < NAMELEN)) strcpy(designated_source, name); else *designated_source = 0; return;}/*********************************************************************/Pending_input *get_designated_source(le,name) Menu_list **le; char *name;{ Pending_input *pi; extern Pending_input *input_pending; extern Panel_item newFile_item; Menu_list *ml; char *cp; if(*designated_source) { strcpy(name, designated_source); *designated_source = 0; return((Pending_input*)TRUE); } pi = input_pending; while(pi) { if(((pi->banner && !strcmp("New Files",pi->banner)) || (pi->item == newFile_item)) && (ml = (Menu_list*)pi->list) && pi->canvas) { while(ml) { if(ml->str && *(ml->str) && ml->tapped) { if(name) { if(pi->path_prefix) strcpy(name,remove_reg_exp(pi->path_prefix)); else *name = 0; strcat(name,cleaned_for_input(ml->str)); } if(le) *le = ml; return(pi); } ml = ml->next; } } pi = pi->next; } return(NULL);}/*********************************************************************//* Look at the input pending lists for New Files and INPUTfile for a designated source. If neither list contains entries, return NULL. If neither list contains a designated source file, use the top entry in the New Files list, if it exists, else use the top entry in the INPUTfile list. If the top entry option is taken, make the next item in the host list the top. */Signal *find_source_signal(){ extern Pending_input *input_pending; Pending_input *pi; extern Panel_item newFile_item; char *cp, result[200]; Signal *get_any_signal(); Menu_list *ml; /* first look for "designated" source */ if((pi = get_designated_source(&ml,result))) { return(get_any_signal(expand_name(NULL,result),0.0,0.0,NULL)); } pi = input_pending; while(pi) { /* just find top of New Files or INPUTfile: list */ if(((pi->banner && !strcmp("New Files",pi->banner)) || (pi->item == newFile_item)) && (ml = (Menu_list *)pi->list) && pi->canvas) { while(ml) { if(ml->str && *(ml->str) && ml->active) { if(pi->path_prefix) strcpy(result,remove_reg_exp(pi->path_prefix)); else *result = 0; strcat(result,cleaned_for_input(ml->str)); if(ml->next) { ml->active = FALSE; ml->next->active = TRUE; if(pi->canvas) menu_redoit(pi->canvas,NULL,NULL); } return(get_any_signal(expand_name(NULL,result),0.0,0.0,NULL)); } ml = ml->next; } } pi = pi->next; } return(NULL);}/*********************************************************************/paste(s,time) Signal *s; double time;{ Signal *s2, *snew, *insert_signal(); View *v; double start, page_time, diff, lc_time, rc_time; extern Pending_input new_files; int i; char mes[400]; if(!s) return(FALSE); if(! IS_GENERIC(s->type)) { sprintf(notice_msg, "Signals of type %x are not supported by paste",s->type); show_notice(1,notice_msg); return(FALSE); } if(s2 = find_source_signal()) { if(time < s->start_time) time = s->start_time; if(time > SIG_END_TIME(s)) time = SIG_END_TIME(s); if(s->file == SIG_NEW) put_waves_signal(s); if(s2->file == SIG_NEW) put_waves_signal(s2); if((snew = insert_signal(s,s2,time))) { char newname[200]; if(make_edited_filename(s,newname)) { close_sig_file(snew); unlink(newname); /* in case a file of this name exists */ sprintf(mes,"/bin/mv %s %s\n",snew->name,newname); if(i = system(mes)) sprintf(mes,"/bin/cp %s %s; rm %s",snew->name,newname,snew->name); if(!i || !system(mes)) { char *na = malloc(strlen(newname) + 1); strcpy(na, newname); free(snew->name); snew->name = na; } else { sprintf(notice_msg, "Couldn't rename %s to %s in paste", snew->name,newname); show_notice(1,notice_msg); } } else { sprintf(notice_msg, "make_edited_filename() failed (%s %s) in paste", s->name,newname); show_notice(1,notice_msg); } if(time <= s->start_time) lc_time = s2->start_time; else lc_time = time; rc_time = lc_time + SIG_DURATION(s2); snew->views = v = s->views; s->views = NULL; snew->obj = s->obj;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -