void CUI_Config::draw(Drawable *S) { char buf[1024]; if (S->lock()==0) { sprintf(buf,"\n|U|Current Settings in memory:\n"); if(tb->text != NULL) { free(tb->text); tb->text = NULL; } sprintf(buf+strlen(buf),"\n|U| Full Screen |L|[|H|%s|L|]",zt_config_globals.full_screen?"On":"Off"); // sprintf(buf+strlen(buf),"\n|U| Fade In/Out |L|[|H|%s|L|]",zt_config_globals.do_fade?"On":"Off"); sprintf(buf+strlen(buf),"\n|U| Auto-Open MIDI |L|[|H|%s|L|]",zt_config_globals.auto_open_midi?"On":"Off"); tb->text = _strdup(buf); UI->draw(S); draw_status(S); status(S); printtitle(11,"Global Configuration",COLORS.Text,COLORS.Background,S); print(row(2),col(14)," Full Screen",COLORS.Text,S); print(row(2),col(16)," Key Repeat",COLORS.Text,S); print(row(2),col(18)," Key Wait",COLORS.Text,S); print(row(2),col(20)," Skin",COLORS.Text,S); // print(row(2),col(26)," .ZT directory",COLORS.Text,S); printtitle(32,"Current Global Settings",COLORS.Text,COLORS.Background,S); need_refresh = 0; updated=2; S->unlock(); } }
// ------------------------------------------------------------------------------------------------ // // void CUI_Savescreen::draw(Drawable *S) { if (clear) { if (S->lock() == 0) { S->fillRect(col(1),row(12),RESOLUTION_X,424,COLORS.Background); S->unlock(); clear=0; } } S->copy(CurrentSkin->bmSave, LOADORSAVE_IMAGE_X, LOADORSAVE_IMAGE_Y); if (S->lock() == 0) { UI->draw(S); if (!is_saving) draw_status(S); printtitle(11, "File Save", COLORS. Text, COLORS.Background, S) ; need_refresh = 0; updated=2; S->unlock(); } }
void CUI_Sysconfig::draw(Drawable *S) { if (S->lock()==0) { UI->draw(S); draw_status(S); status(S); printtitle(11,"System Configuration",COLORS.Text,COLORS.Background,S); print(row(4),col(14)," Prebuffer",COLORS.Text,S); print(row(4),col(16)," Panic on stop",COLORS.Text,S); print(row(4),col(18)," MIDI-IN Slave",COLORS.Text,S); print(row(4),col(20),"Auto-open MIDI",COLORS.Text,S); print(row(4),col(22)," Full Screen",COLORS.Text,S); //print(row(4),col(24)," Step Editing",COLORS.Text,S); print(row(4),col(24)," Key Repeat",COLORS.Text,S); print(row(4),col(26)," Key Wait",COLORS.Text,S); print(row(4+37+8),col(14),"Skin Selection",COLORS.Text,S); print(row(4),col(30),"MIDI Out Device Selection",COLORS.Text,S); print(row(4+37),col(30),"MIDI In Device Selection",COLORS.Text,S); print(row(5),col(47),"Latency ",COLORS.Text,S); print(row(5),col(49),"Reverse Bank Select ",COLORS.Text,S); print(row(5),col(51),"Device Alias",COLORS.Text,S); need_refresh = 0; updated=2; S->unlock(); } }
void CUI_Help::draw(Drawable *S) { if (S->lock()==0) { UI->draw(S); draw_status(S); printtitle(11,"Help",COLORS.Text,COLORS.Background,S); need_refresh = 0; updated=2; ztPlayer->num_orders(); S->unlock(); } }
void CUI_Midimacroeditor::draw(Drawable *S) { if (S->lock()==0) { UI->draw(S); draw_status(S); printtitle(11,"Midimacro Editor",COLORS.Text,COLORS.Background,S); print(col(12),row(BASE_Y),"name",COLORS.Text,S); need_refresh = 0; updated=2; ztPlayer->num_orders(); S->unlock(); } }
int usnic_vnic_dump(struct usnic_vnic *vnic, char *buf, int buf_sz, void *hdr_obj, int (*printtitle)(void *, char*, int), int (*printcols)(char *, int), int (*printrow)(void *, char *, int)) { struct usnic_vnic_res_chunk *chunk; struct usnic_vnic_res *res; struct vnic_dev_bar *bar0; int i, j, offset; offset = 0; bar0 = usnic_vnic_get_bar(vnic, 0); offset += scnprintf(buf + offset, buf_sz - offset, "VF:%hu BAR0 bus_addr=%pa vaddr=0x%p size=%ld ", usnic_vnic_get_index(vnic), &bar0->bus_addr, bar0->vaddr, bar0->len); if (printtitle) offset += printtitle(hdr_obj, buf + offset, buf_sz - offset); offset += scnprintf(buf + offset, buf_sz - offset, "\n"); offset += scnprintf(buf + offset, buf_sz - offset, "|RES\t|CTRL_PIN\t\t|IN_USE\t"); if (printcols) offset += printcols(buf + offset, buf_sz - offset); offset += scnprintf(buf + offset, buf_sz - offset, "\n"); spin_lock(&vnic->res_lock); for (i = 0; i < ARRAY_SIZE(vnic->chunks); i++) { chunk = &vnic->chunks[i]; for (j = 0; j < chunk->cnt; j++) { res = chunk->res[j]; offset += scnprintf(buf + offset, buf_sz - offset, "|%s[%u]\t|0x%p\t|%u\t", usnic_vnic_res_type_to_str(res->type), res->vnic_idx, res->ctrl, !!res->owner); if (printrow) { offset += printrow(res->owner, buf + offset, buf_sz - offset); } offset += scnprintf(buf + offset, buf_sz - offset, "\n"); } } spin_unlock(&vnic->res_lock); return offset; }
void CUI_Loadscreen::draw(Drawable *S) { if (clear) { if (S->lock() == 0) { S->fillRect(col(1),row(12),CONSOLE_WIDTH,424,COLORS.Background); S->unlock(); clear=0; } } S->copy(CurrentSkin->bmLoad, 275, 267); if (S->lock()==0) { UI->draw(S); if (!is_loading) draw_status(S); printtitle(11,"File Load",COLORS.Text,COLORS.Background,S); need_refresh = 0; updated=2; S->unlock(); } }
void CUI_About::draw(Drawable *S) { S->copy(CurrentSkin->bmAbout,5,row(12)); /* if (640 == RESOLUTION_X && 480 == RESOLUTION_Y) { S->copy(CurrentSkin->bmAbout,5,row(12)); } else { double xscale = (double)RESOLUTION_X / 640; double yscale = (double)RESOLUTION_Y / 480; Drawable ss( zoomSurface(CurrentSkin->bmAbout->surface, xscale, yscale ,SMOOTHING_ON) , true ); S->copy(&ss,5,row(12)); } */ UI->full_refresh(); if (S->lock()==0) { printtitle(11,"About zt",COLORS.Text,COLORS.Background,S); need_refresh = 0; updated=2; UI->draw(S); S->unlock(); } }
void play(char *song) { char **command; char *kill[3]; int i, pid; struct sigaction sa1; //setup sigchld handler #if 0 //mcli modify sa1.sa_mask = 0; //dont block any signals while this one is working sa1.sa_flags = 0; //restart the signal sa1.sa_restorer = 0; #else memset(&sa1,0,sizeof(struct sigaction)); #endif sa1.sa_handler = next_song; sigaction(SIGCHLD, &sa1, NULL); //kill current song kill[0] = KILLALL; kill[1] = MP3PLAYER; kill[2] = NULL; pid = exec_command(kill); // wait for kill command to return while (waitpid(pid, NULL, 0) != pid); usleep(10000); if (song) { // copy song to command argv getmp3taginfo(song); mp3play_options[mp3play_option_count + 1] = (char *) calloc(1, strlen(song) + 1); strcpy(mp3play_options[mp3play_option_count + 1], song); mp3play_options[mp3play_option_count + 2] = NULL; mp3playpid = exec_command(mp3play_options); printtitle(song); free(mp3play_options[mp3play_option_count + 1]); } else { if (lcddev) { fprintf(lcddev, "\f"); fflush(lcddev); } } }
//------------------------------------------------------------------- int main( int argc, char **argv) { int c; int y; if( !init() ) { endwin(); printf( "init screen failed\n"); return 0; } if( !cfgread() ) { endwin(); printf( "config file open error\n"); return 0; } printtitle(); dsphelp(); y = 0; dspcaption(y); dspcomment( y); dsppage(); while( 1) { c = wgetch(wMain); switch( c) { case KEY_UP: case '8': case 'k': y--; break; case KEY_DOWN: case 'j': case '2': y++; break; case KEY_LEFT: case '4': case 'h': page --; if( page < 0 ) page = 0; else { dsppage(); } break; case KEY_RIGHT: case '6': case 'l': page ++; if( page > maxpage ) page = maxpage ; else { if( y+page*LINENUM >= menucnt) y = 0; dsppage(); } break; case 'q': exitmain( 0); break; case 10: case 13: case KEY_ENTER: werase( wMsg); wrefresh( wMsg); if( menu[y].sure ) { int recv; mvwprintw( wMsg, 0,0, "are you sure? [y]\n"); recv = wgetch( wMsg); werase( wMsg); wrefresh( wMsg); if( tolower(recv) != 'y' ) break; } wprintw( wMsg, " "); wrefresh(wMsg); system( menu[y+page*LINENUM].script); { int recv; mvwprintw( wMsg, 0,0,"\nhit any key\n"); recv = wgetch( wMsg); erase(); refresh(); werase( wMsg); wrefresh( wMsg); werase( wComment); werase( wMain); printtitle(); dsphelp(); dsppage(); } } if( y < 0 ) y = 0; if( y >= LINENUM ) y = LINENUM -1; if( y+page*LINENUM >= menucnt ) y --; // move( y,2); dspcaption( y); dspcomment( y); } return 0; }
int main (int argc, char *argv[]) { char *playlist_filename; int shuffle = 0; int random_play = 0; int repeat = 0; int slptime = 0; FILE *playlist_file; char **playlist; char *line; char *ptr; int volume = 80; int balance; int playlist_size; int argnr; int current_song = 0; int songs = 0; int i,x,j,pid; #ifdef LCD lcddev = fopen(LCD_DEV, "w"); if (lcddev == NULL) { fprintf(stderr, "Open failed for %s\n", LCD_DEV); return -1; } fprintf(lcddev, "\f"); fflush(lcddev); #else lcddev = stdout; #endif atexit(exit_code); #ifdef KEYPAD // keypad = openkeypad(KEYPAD_DEV); keypad = open(KEYPAD_DEV, O_RDONLY); if (keypad == -1) { fprintf(stderr, "Open failed for %s\n",KEYPAD_DEV); return -1; } #else keypad = 0; // assign stdinput to keypad savelocaltermios(); setlocaltermios(); #endif playlist_filename = NULL; mp3play_options = NULL; playlist_size = PLAYLIST_SIZE; i = 0; if (argc < 2) usage(0); // process options while ((i = getopt(argc, argv, "?hzvZR@:M:s:")) >= 0) { switch (i) { case 'z': shuffle = 1; break; case 'Z': random_play = 1; break; case 'R': repeat = 1; break; case 's': slptime = atoi(optarg); break; case '@': playlist_filename = (char *) malloc(strlen(optarg) + 1); strcpy(playlist_filename, optarg); break; case 'M': line = (char *) malloc(strlen(optarg) + 1); strcpy(line, optarg); mp3play_option_count = strchrcnt(line, ' ') + 1; mp3play_options = (char **) calloc(mp3play_option_count + 7, sizeof(char *)); mp3play_options[0] = MP3PLAYER; ptr = line; for (i = 1; i <= mp3play_option_count; i++) { mp3play_options[i] = (char *) calloc(1, strlen(line) + 1); ptr = strtok(ptr, " "); strcpy(mp3play_options[i], ptr); ptr = NULL; } free(line); break; case 'v': verbose = 1; break; case 'h': case '?': usage(0); break; } } argnr = optind; if (!playlist_filename) if (argnr >= argc) usage(1); if (!mp3play_options) { mp3play_options = (char **) calloc(4, sizeof(char *)); mp3play_options[0] = MP3PLAYER; mp3play_option_count = 1; mp3play_options[mp3play_option_count] = (char *) malloc(strlen("-l") + 1); strcpy(mp3play_options[mp3play_option_count], "-t"); mp3play_option_count++; mp3play_options[mp3play_option_count] = (char *) malloc(strlen("0") + 1); strcpy(mp3play_options[mp3play_option_count], "2"); } else { mp3play_option_count++; mp3play_options[mp3play_option_count] = (char *) malloc(strlen("-l") + 1); strcpy(mp3play_options[mp3play_option_count], "-l"); mp3play_option_count++; mp3play_options[mp3play_option_count] = (char *) malloc(strlen("0") + 1); strcpy(mp3play_options[mp3play_option_count], "0"); mp3play_option_count++; mp3play_options[mp3play_option_count] = (char *) malloc(strlen("-l") + 1); strcpy(mp3play_options[mp3play_option_count], "-t"); mp3play_option_count++; mp3play_options[mp3play_option_count] = (char *) malloc(strlen("0") + 1); strcpy(mp3play_options[mp3play_option_count], "2"); } srandom(time(NULL)); if (playlist_filename) { if (verbose) fprintf(stdout, "Reading Playlist from file:%s\n", playlist_filename); playlist_file = fopen(playlist_filename, "r"); if (playlist_file == NULL) { fprintf(stderr, "Open failed for playlist file:%s\n", playlist_filename); return -1; } playlist = (char **) calloc(playlist_size, sizeof(char *)); line = (char *) calloc(1, MAX_LINE + 1); if (verbose) fprintf(stdout, "Playlist entries:\n"); while(line != NULL) { if (songs >= playlist_size) { playlist_size += PLAYLIST_SIZE; playlist = (char **) realloc(playlist, playlist_size * sizeof(char *)); } line = fgets(line, MAX_LINE, playlist_file); if (*line != '\0') { playlist[songs] = (char *) calloc(1, strlen(line) + 1); line = strtok(line, "\n"); playlist[songs] = strcpy(playlist[songs], line); if (verbose) fprintf(stdout, "[%d] - %s\n",songs, playlist[songs]); songs++; } } free(line); songs--; } else { playlist = (char **) calloc(argc, sizeof(char *)); for (i = 0; i < (argc - argnr) ; i++) { playlist[i] = (char *) malloc(strlen(argv[i + argnr]) + 1); playlist[i] = strcpy(playlist[i], argv[i + argnr]); } songs = i - 1; } if (shuffle) { if (verbose) fprintf(stdout, "Shuffling.....\n"); for (x = 0; (x < 10000); x++) { i = ((unsigned int) random()) % songs; j = ((unsigned int) random()) % songs; line = playlist[i]; playlist[i] = playlist[j]; playlist[j] = line; } } if (verbose) fprintf(stdout, "Init complete - %d songs in playlist\n", songs + 1); // main menu loop current_song = 0; pid = 1; #ifdef KEYPAD for (;;) { #else while (input != QUIT) { #endif input = my_getchar(keypad); while ((pid = waitpid(-1, NULL, WNOHANG)) > 0) { if (pid == mp3playpid) { if (verbose) fprintf(stdout, "mp3play child died\n"); if (lcddev) { fprintf(lcddev, "\f"); fflush(lcddev); } } else { if (verbose) fprintf(stdout, "another child died\n"); } } #ifndef KEYPAD if (input == 0x1b) { input = my_getchar(keypad); input = my_getchar(keypad); } #endif switch (input) { case UP: volume+=10; if (volume > 100) { volume = 100; } else { set_volume(volume); printtitle(playlist[current_song]); } input = 'c'; break; case DOWN: volume-=10; if (volume < 0) { volume = 0; break; } else { set_volume(volume); printtitle(playlist[current_song]); } input = 'c'; break; case RIGHT : if (slptime) sleep(slptime); if (random_play) { current_song = ((unsigned int) random()) % songs; if (verbose) fprintf(stdout, "[Random Song] - %d\n",current_song); } else { current_song++; if (verbose) fprintf(stdout, "[Next song]\n"); } if (current_song > songs) { if (repeat) { current_song = 0; play(playlist[current_song]); } else { current_song--; } } else play(playlist[current_song]); input = 'c'; break; case SELECT : if (verbose) fprintf(stdout, "[Play]\n"); play(playlist[current_song]); input = 'c'; break; case LEFT : if (random_play) { current_song = ((unsigned int) random()) % songs; if (verbose) fprintf(stdout, "[Random Song] - %d\n",current_song); } else { current_song--; if (verbose) fprintf(stdout, "[Prev song]\n"); } if (current_song < 0) { current_song = 0; } else play(playlist[current_song]); input = 'c'; break; case EXIT : if (verbose) fprintf(stdout, "[Stop]\n"); play(NULL); input = 'c'; break; default : break; } } play(NULL); } /****************************************************************************/ int exec_command(char **argv) { int i = 0; int pid; if (verbose) { fprintf(stdout, "executing: "); for (i = 0; argv[i] != NULL; i++) { fprintf(stdout, "%s ",argv[i]); } fprintf(stdout, "\n"); } pid = vfork(); if(pid == 0) { // close(0); // close(1); // close(2); execvp(argv[0], argv); _exit(0); } return pid; }
/* modify by Suttipong Kanakakorn Tue 08-29-1989 23:53:53 */ void printing(void) { extern int blankskip(); extern int pic_print; int i,j ; int printquit; char st[5] ; char s[500] ; char p[500] ; char scol ; if (graphicprint==YES) /* if print in graphic mode */ initializebufferandfont(); /* allocate graphic buffer and load font */ scol=7; dispstrhgc("¡ÓÅѧ¾ÔÁ¾ì COPY·Õè : ",10-scol,12,0); dispstrhgc(" ˹éÒ·Õè : ",30-scol,12,0); dispstrhgc(" ºÃ÷Ѵ·Õè : ",43-scol,12,0); dispstrhgc(" ËÂØ´ªÑèǤÃÒÇ <P> àÅÔ¡¾ÔÁ¾ì <Q>",58-scol,12,BOLDATTR); printquit = NO; PrinterInitialize(); /* initialize printer */ PrinterMasterSelectMode(0); /* Set to 10 Cpi */ for (i=1; i<=copytoprint; i++) { linespace = find_line_space(); PrinterSetFormLenghtInch(pagelength); seekbeginline(); /* itoa(i,st,10); dispstrhgc(" ",25 - scol,12,0); dispstrhgc(st,30 - strlen(st) - scol,12,2); */ dispprintf(25 - scol, 12 ,2, "%5d", i); curpage = pagenumberoffset; /* itoa(curpage,st,10); dispstrhgc(" ",38 - scol ,12,0); dispstrhgc(st,43 - strlen(st) - scol ,12,2); */ dispprintf(38 - scol, 12, 0, "%5d", curpage); curline = 0; pic_print = NO; while ((fgets(s,500,fp) != NULL) && (printquit==NO)) { strfilter(s,0x8d); /* delete 0x8d */ strcpy(p,s); j=0; while ((p[j]<32) && (p[j]!=NULL)) j++; if (p[j] == '.') { /* -to allow free format. */ dotcommand(&p[j]); /* do dotcommand then read next */ if (newpage == YES) { /* page break dotcmd (.pa ,.cp) found */ newpage = NO; /* reset pagebreak status */ /* PrinterSkipLine(((29+1)-(locpagetitle!=0)-(locheading!=0) -(locfooting!=0)-curline)*2 ); */ skip_line((userlineperpage+1) - curline); curline = 0 ; printtitle(footing,locfooting); PrinterFormFeed(); if (curpage >= pageend-pagebegin+pagenumberoffset) break; pagewait(0); /* finish each page */ curpage++ ; /* itoa(curpage,st,10); dispstrhgc(" ",38 - scol ,12,0); dispstrhgc(st,43 - strlen(st) - scol ,12,2); */ dispprintf(38 - scol, 12, 0, "%5d", curpage); } } else { /* Not dot commands */ if (mailmergeflag == YES) { mailmerge(s,p); strcpy(s,p); } if (stdcode == NO) { contostd(s); /* convert from ku to so-mo-or */ } marginset(s); /* set left-right margin */ if (curline == 0) { printtitle(heading,locheading); sprintf(p,pageformat,curpage); printtitle(p,locpagetitle); curline++; /* begin curline = 1 */ } /* itoa(curline,st,10); dispstrhgc(" ",53 - scol ,12,0); dispstrhgc(st,58 - strlen(st) - scol ,12,2); dispstrhgc(blankline,2,13,0); */ dispprintf(53 - scol, 12, 0, "%5d", curline); dispprintf(2, 13, NORMALATTR, "%77s", " "); /* Clear Line */ dispprintf(2, 13, 0, "%-77.77s", s); /* Disp CurLine */ /* dispstrhgc(extbarprinting ? "*":"-",1,1,REVERSEATTR); */ preprinterloadline(s); curline++; if (curline > userlineperpage) { curline = 0 ; printtitle(footing,locfooting); PrinterFormFeed(); if (curpage >= pageend-pagebegin+pagenumberoffset) break; pagewait(0); /* finish each page */ curpage++ ; itoa(curpage,st,10); dispstrhgc(" ",38 - scol ,12,0); dispstrhgc(st,43 - strlen(st) - scol ,12,2); } linewait(&printquit); } /* end case of non-dotcommand */ } /* end while */ if (curline != 0) { /* PrinterSkipLine(((29+1)-(locpagetitle!=0)-(locheading!=0) -(locfooting!=0)-curline) *2 ); /* skip to bottom */ */ skip_line((userlineperpage+1) - curline); printtitle(footing,locfooting); PrinterFormFeed(); } fseek(fp,0L,SEEK_SET); /* rewind file pointer */ if (printquit==YES) break; /* exit for loop */ pagewait(1); /* finish each copy */ }