/* * Needed for SIGWINCH handling. */ void pad_resize(void) { set_size(main_pad); if(!main_pad->wd) return; // wresize(border_wd, main_pad->size_y-PAD_Y+3, main_pad->size_x-PAD_X+3); wresize(border_wd, BORDER_ROWS+1, BORDER_COLS+1); werase(border_wd); box(border_wd, ACS_VLINE, ACS_HLINE); print_titles(); wbkgd(main_pad->wd, COLOR_PAIR(8)); werase(main_pad->wd); pad_draw(); pad_refresh(); }
/* * If subwindow with detailed information doesn't exists then create it. * Otherwise destroy. */ static void sub_change(struct subwin *w) { if(w->arrow >= 0) w->arrow = arrow_prev = 0; if(main_pad->wd) { box(border_wd, ACS_VLINE, ACS_HLINE); print_titles(); } if(!main_pad->wd) pad_create(w); assert(w->plugin_draw); pad_draw(); // } else { // if(w->plugin_clear) w->plugin_clear(); // pad_destroy(); // } }
/* * Create ncurses pad with a frame. */ static void pad_create(struct subwin *w) { assert(sub_current); main_pad->wd = newpad(SUBWIN_ROWS, SUBWIN_COLS); if(!main_pad->wd) prg_exit("pad_create(): cannot create details window. [1]"); set_size(main_pad); w->offset = w->lines = w->xoffset = 0; border_wd = newpad(BORDER_ROWS+1, BORDER_COLS+1); if(!border_wd) prg_exit("pad_create(): cannot create details window. [2]"); wbkgd(border_wd, COLOR_PAIR(8)); werase(border_wd); box(border_wd, ACS_VLINE, ACS_HLINE); print_titles(); wbkgd(main_pad->wd, COLOR_PAIR(8)); werase(main_pad->wd); }
main(){ FILE *fp; fp=fopen("all_callisto4.txt", "r"); if (fp==NULL){ printf("failed to open file \n"); return -1; } int counter=0; int c; while((c=fgetc(fp))!=EOF){ if (c=='\n'){ counter++; } } rewind(fp); printf("there are %d+1 lines \n",counter); int max_lines=counter+1; int max_char=2808; char **all_lines; all_lines=malloc(sizeof(char*)*max_lines); int i=0; for (i;i<max_lines;i++){ all_lines[i]=malloc(sizeof(char)*max_char); } int n_lines=getlines(all_lines, max_lines, max_char, fp); printf("n_lines is %d \n", n_lines); titles ** titles_head=malloc(sizeof(titles*)); *titles_head=NULL; int n_titles=title_find(all_lines,n_lines,titles_head, max_title_length); printf("%d titles\n",n_titles); FILE *text_file; text_file=fopen("titles_callisto", "wb"); print_titles(*titles_head, text_file); fclose(text_file); int n_posts=line_find(all_lines,n_lines,job_id,job_id_len); printf("there are %d job posts\n",n_posts); counter=line_find(all_lines,n_lines,"Location:",9); printf("there are %d Locations\n",counter); counter=line_find(all_lines,n_lines,"Job Location(s):",16); printf("there are %d Location(s)\n",counter); counter=line_find(all_lines,n_lines,"Description:",12); printf("there are %d Descriptions\n",counter); counter=line_find(all_lines,n_lines,"Job Function:",13); printf("there are %d Job Functions\n",counter); counter=line_find(all_lines,n_lines,"Job Functions:",16); printf("there are %d Job Functions\n",counter); title_lists *all_titles=sep_titles("titles_callisto",n_titles,max_title_length); job_posts * head_post=parse_posts(all_lines, all_titles, n_lines); filter_posts(head_post,all_lines,n_posts); return 0; }