📄 xaw_i.c
字号:
snprintf(window_title, sizeof(window_title), "%s", local_buf+2); break; case 'O' : offPlayButton();break; case 'L' : a_print_msg(lyric_t); break; case 'Q' : exit(0); case 'V': amplitude=atoi(local_buf+2); thumb = (float)amplitude / (float)MAXVOLUME; sprintf(s, "%d", amplitude); XtVaSetValues(vol_l, XtNlabel, s, NULL); if (sizeof(thumb) > sizeof(XtArgVal)) { XtVaSetValues(vol_bar, XtNtopOfThumb, &thumb, NULL); } else { XtArgVal *l_thumb = (XtArgVal *) &thumb; XtVaSetValues(vol_bar, XtNtopOfThumb,*l_thumb, NULL); } break; case 'v': c= *(local_buf+1); n= atoi(local_buf+2); if(c == 'L') voices = n; else last_voice = n; if(IsTracePlaying()) drawVoices(); break; case 'g': case '\0' : break; case 'X': n=max_files; max_files+=atoi(local_buf+2); for (i=n;i<max_files;i++) { a_pipe_read(local_buf,sizeof(local_buf)); addOneFile(max_files,i,local_buf,True); } if(popup_shell_exist & FLIST_WINDOW){ Dimension h,w; XtVaGetValues(file_list,XtNwidth,&w,NULL); XawListChange(file_list,flist,max_files,w,True); /* to keep Viewport size */ XtVaGetValues(file_vport,XtNwidth,&w,XtNheight,&h,NULL); XtVaSetValues(file_vport,XtNheight,((h>FILEVPORT_HEIGHT)? h:FILEVPORT_HEIGHT),NULL); } break; case 'Y': if(ctl->trace_playing) { ch= *(local_buf+1) - 'A'; c= *(local_buf+2); note= (*(local_buf+3)-'0')*100 + (*(local_buf+4)-'0')*10 + *(local_buf+5)-'0'; n= atoi(local_buf+6); if (c == '*' || c == '&') { Panel->c_flags[ch] |= FLAG_PROG_ON; } else { Panel->c_flags[ch] &= ~FLAG_PROG_ON; n= 0; } ctl_channel_note(ch, note, n); draw1Note(ch,note,c); draw1Chan(ch,Panel->ctotal[ch],c); } break; case 'I': if(IsTracePlaying()) { ch= *(local_buf+1) - 'A'; strncpy(inst_name[ch], (char *)&local_buf[2], INST_NAME_SIZE); drawInstname(ch, inst_name[ch]); } break; case 'i': if(IsTracePlaying()) { ch= *(local_buf+1) - 'A'; Panel->is_drum[ch]= *(local_buf+2) - 'A'; drawDrumPart(ch, Panel->is_drum[ch]); } break; case 'P': if(IsTracePlaying()) { c= *(local_buf+1); ch= *(local_buf+2)-'A'; n= atoi(local_buf+3); switch(c) { case 'A': /* panning */ Panel->channel[ch].panning = n; Panel->c_flags[ch] |= FLAG_PAN; drawPan(ch,n,True); break; case 'B': /* pitch_bend */ Panel->channel[ch].pitchbend = n; Panel->c_flags[ch] |= FLAG_BENDT; if (!plane) drawPitch(ch,n); break; case 'b': /* tonebank */ Panel->channel[ch].bank = n; if (plane) drawBank(ch,n); break; case 'r': /* reverb */ Panel->reverb[ch] = n; if (plane) drawReverb(ch,n); break; case 'c': /* chorus */ Panel->channel[ch].chorus_level = n; if (plane) drawChorus(ch,n); break; case 'S': /* sustain */ Panel->channel[ch].sustain = n; Panel->c_flags[ch] |= FLAG_SUST; break; case 'P': /* program */ Panel->channel[ch].program = n; Panel->c_flags[ch] |= FLAG_PROG; drawProg(ch,n,4,pl[plane].ofs[CL_PR],True); break; case 'E': /* expression */ Panel->channel[ch].expression = n; ctl_channel_note(ch, Panel->cnote[ch], Panel->cvel[ch]); drawExp(ch,n); break; case 'V': /* volume */ Panel->channel[ch].volume = n; ctl_channel_note(ch, Panel->cnote[ch], Panel->cvel[ch]); drawVol(ch,n); break; } } break; case 'R': redrawTrace(True); break; case 'U': /* update timer */ if(ctl->trace_playing) { static double last_time = 0; double d, t; Bool need_flush; double delta_time; t = get_current_calender_time(); d = t - last_time; if(d > 1) d = 1; delta_time = d / XAW_UPDATE_TIME; last_time = t; need_flush = False; for(i=0; i<MAX_XAW_MIDI_CHANNELS; i++) if (Panel->v_flags[i]) { if (Panel->v_flags[i] == FLAG_NOTE_OFF) { Panel->ctotal[i] -= DELTA_VEL * delta_time; if (Panel->ctotal[i] <= 0) { Panel->ctotal[i] = 0; Panel->v_flags[i] = 0; } draw1Chan(i,Panel->ctotal[i],'*'); need_flush = True; } else { Panel->v_flags[i] = 0; } } if(need_flush) XFlush(XtDisplay(trace)); } break; case 'm': n= atoi(local_buf+1); switch(n) { case GM_SYSTEM_MODE: sprintf(s,"%d:%02d / GM",total_time/60,total_time%60); break; case GS_SYSTEM_MODE: sprintf(s,"%d:%02d / GS",total_time/60,total_time%60); break; case XG_SYSTEM_MODE: sprintf(s,"%d:%02d / XG",total_time/60,total_time%60); break; default: sprintf(s,"%d:%02d",total_time/60,total_time%60); break; } XtVaSetValues(time_l,XtNlabel,s,NULL); break; case 's': n= atoi(local_buf+1); pp = current_flist; if(pp != NULL) { while(*pp != NULL) free(*pp++); free(current_flist); } current_flist = (char **)safe_malloc(sizeof(char *) * (n+1)); if ('\0' != *dotfile) { FILE *fp; if (savelist) { if (NULL != (fp=fopen(dotfile, "a+"))) { for(i=0; i<n; i++) { a_pipe_read(local_buf,sizeof(local_buf)); current_flist[i]=(char *)safe_malloc(sizeof(char)*(strlen(local_buf)+1)); strcpy(current_flist[i], local_buf); fprintf(fp,"set %s %s\n",cfg_items[S_MidiFile],current_flist[i]); } fclose(fp); } } else for(i=0; i<n; i++) a_pipe_read(local_buf,sizeof(local_buf)); } current_flist[n] = NULL; break; default : fprintf(stderr,"Unkown message '%s' from CONTROL" NLS,local_buf); }}static int configcmp(char *s, int *num) { int i; char *p; for (i= 0; i < CFGITEMSNUMBER; i++) { if (0 == strncasecmp(s, cfg_items[i], strlen(cfg_items[i]))) { p = s + strlen(cfg_items[i]); while (*p == SPACE || *p == TAB) p++; if(i == S_MidiFile) *num = p - s; else *num = atoi(p); return i; } } return(-1);}static char *strmatch(char *s1, char *s2) { char *p = s1; while (*p != '\0' && *p == *s2++) p++; *p = '\0'; return(s1);}/* Canonicalize by removing /. and /foo/.. if they appear. */static char *canonicalize_path(char *path){ char *o, *p, *target; int abspath; o = p = path; while(*p) { if(p[0] == '/' && p[1] == '/') p++; else *o++ = *p++; } while(path < o-1 && path[o - path - 1] == '/') o--; path[o - path] = '\0'; if((p = strchr(path, '/')) == NULL) return path; abspath = (p == path); o = target = p; while(*p) { if(*p != '/') *o++ = *p++; else if(p[0] == '/' && p[1] == '.' && (p[2]=='/' || p[2] == '\0')) { /* If "/." is the entire filename, keep the "/". Otherwise, just delete the whole "/.". */ if(o == target && p[2] == '\0') *o++ = *p; p += 2; } else if(p[0] == '/' && p[1] == '.' && p[2] == '.' /* `/../' is the "superroot" on certain file systems. */ && o != target && (p[3]=='/' || p[3] == '\0')) { while(o != target && (--o) && *o != '/') ; p += 3; if(o == target && !abspath) o = target = p; } else *o++ = *p++; } target[o - target] = '\0'; if(!*path) strcpy(path, "/"); return path;}static char *expandDir(char *path, DirPath *full) { static char tmp[PATH_MAX]; static char newfull[PATH_MAX]; char *p, *tail; p = path; if (path == NULL) { strcpy(tmp, "/"); full->dirname = tmp; full->basename = NULL; strcpy(newfull, tmp); return newfull; } else if (*p != '~' && NULL == (tail = strrchr(path, '/'))) { p = tmp; strncpy(p, basepath, PATH_MAX - 1); full->dirname = p; while (*p++ != '\0') ; strncpy(p, path, PATH_MAX - (p - tmp) - 1); tmp[PATH_MAX-1] = '\0'; snprintf(newfull,sizeof(newfull),"%s/%s", basepath, path); full->basename = p; return newfull; } if (*p == '/') { strncpy(tmp, path, PATH_MAX - 1); } else { if (*p == '~') { struct passwd *pw; p++; if (*p == '/' || *p == '\0') { pw = getpwuid(getuid()); } else { char buf[80], *bp = buf; while (*p != '/' && *p != '\0') *bp++ = *p++; *bp = '\0'; pw = getpwnam(buf); } if (pw == NULL) { ctl->cmsg(CMSG_WARNING, VERB_NORMAL, "something wrong with getting path."); return NULL; } while (*p == '/') p++; snprintf(tmp, sizeof(tmp), "%s/%s", pw->pw_dir, p); } else { /* *p != '~' */ snprintf(tmp, sizeof(tmp), "%s/%s", basepath, path); } } p = canonicalize_path(tmp); tail = strrchr(p, '/'); *tail++ = '\0'; full->dirname = p; full->basename = tail; snprintf(newfull,sizeof(newfull),"%s/%s", p, tail); return newfull;}/*ARGSUSED*/static void setDirAction(Widget w,XEvent *e,String *v,Cardinal *n) { char *p, *p2; struct stat st; DirPath full; XawListReturnStruct lrs; p = XawDialogGetValueString(load_d); if (NULL != (p2 = expandDir(p, &full))) p = p2; if(stat(p, &st) == -1) return; if(S_ISDIR(st.st_mode)) { strncpy(basepath,p,sizeof(basepath)-1); p = strrchr(basepath, '/'); if (*(p+1) == '\0') *p = '\0'; lrs.string = ""; if(dirlist != NULL) { free(dirlist_top); free(dirlist); dirlist = NULL; } setDirList(load_flist, cwd_l, &lrs); }}/* * sort algorithm for DirList: * - directories before files */static int dirlist_cmp (const void *p1, const void *p2){ int i1, i2; char *s1, *s2; s1 = *((char **)p1); s2 = *((char **)p2); i1 = strlen (s1) - 1; i2 = strlen (s2) - 1; if (i1 >= 0 && i2 >= 0) { if (s1 [i1] == '/' && s2 [i2] != '/') return -1; if (s1 [i1] != '/' && s2 [i2] == '/') return 1; } return strcmp (s1, s2);}#ifndef ORIGINAL/* RAKK/HIOENS: Save a string on the heap. Addition for 'common.c' ? */static char * strsav( char * str ) { char * tp = safe_malloc( strlen(str)+1 ); strcpy(tp, str); return tp;}#endif /* RAKK/HIOENS */static void setDirList(Widget list, Widget label, XawListReturnStruct *lrs) { URL dirp; struct stat st; char currdir[PATH_MAX], filename[PATH_MAX]; int i, d_num, f_num; snprintf(currdir, sizeof(currdir)-1, "%s/%s", basepath, lrs->string); canonicalize_path(currdir); if(stat(currdir, &st) == -1) return; if(!S_ISDIR(st.st_mode)) {#ifdef ORIGINAL XtVaSetValues(load_d,XtNvalue,currdir,NULL);#else /* RAKK/HIOENS */ XtVaSetValues(load_d,XtNvalue,strsav(currdir),NULL);#endif /* ORIGINAL */ return; } if (NULL != (dirp=url_dir_open(currdir))) { char *fullpath; MBlockList pool; StringTable strtab; init_mblock(&pool); if(dirlist != NULL) { free(dirlist_top); free(dirlist); } init_string_table(&strtab); i = 0; d_num = 0; f_num = 0; while (url_gets(dirp, filename, sizeof(filename)) != NULL) { fullpath = (char *)new_segment(&pool,strlen(currdir) +strlen(filename) +2); sprintf(fullpath, "%s/%s", currdir, filename); if(stat(fullpath, &st) == -1) continue; if(filename[0] == '.' && filename[1] == '\0') continue;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -