📄 bibtool.c
字号:
move(print_pos,5); if (use_edition != 1) { attron(A_BOLD); printw("%s","7. Edition "); attroff(A_BOLD); } else printw("%s","7. Edition "); if (set_edition == 1) addch('*'); print_pos++; } if (use_editor != 0) { move(print_pos,5); if (use_editor == 1) { attron(A_BOLD); printw("%s","8. Editor(s) "); attroff(A_BOLD); } else printw("%s","8. Editor(s) "); if (set_editor == 1) addch('*'); print_pos++; } if (use_howpublished != 0) { move(print_pos,5); if (use_howpublished == 1) { attron(A_BOLD); printw("%s","9. How published "); attroff(A_BOLD); } else printw("%s","9. How published "); if (set_howpublished == 1) addch('*'); print_pos++; } move(print_pos,5); print_pos+= field_menu(use_institution, set_institution, "A. Institution"); move(print_pos,5); print_pos+= field_menu(use_journal, set_journal, "B. Journal"); move(print_pos,5); print_pos+= field_menu(use_key, set_key, "C. Key"); move(print_pos,5); print_pos+= field_menu(use_month, set_month, "D. Month"); move(print_pos,5); print_pos+= field_menu(use_note, set_note, "E. Note"); move(print_pos,5); print_pos+= field_menu(use_number, set_number, "F. Number"); move(print_pos,5); print_pos+= field_menu(use_organisation, set_organisation, "G. Organisation"); move(print_pos,5); print_pos+= field_menu(use_pages, set_pages, "H. Pages"); move(print_pos, 5); print_pos+= field_menu(use_publisher, set_publisher, "I. Publisher"); move(print_pos, 5); print_pos+= field_menu(use_school, set_school, "J. Academic institution"); move(print_pos, 5); print_pos+= field_menu(use_series, set_series, "K. Series"); move(print_pos, 5); print_pos+= field_menu(use_title, set_title, "L. Title"); move(print_pos, 5); print_pos+= field_menu(use_type, set_type, "M. Type"); move(print_pos, 5); print_pos+= field_menu(use_volume, set_volume, "N. Volume"); move(print_pos, 5); print_pos+= field_menu(use_year, set_year, "O. Year"); refresh(); cbreak(); ch = getch(); lch = tolower(ch); if (lch == 'q') return(0); setup_screen(); move(4,5); nocbreak(); switch(lch) { case '1' : printw("%s","Please enter the address of the publisher or other institution"); move(5,5); printw("%s","For major publishing houses it is sufficient to give just the city"); move(7,5); refresh(); getstr(address); set_address = 1; break; case '2' : printw("%s","Please enter an annotation"); move(6,5); refresh(); getstr(annote); set_annote = 1; break; case '3' : printw("%s","Please enter the name(s) of the author(s)."); move(6,5); printw("%s","These may be in the form:"); move(7,8); printw("%s","John Joseph Bloggs"); move(8,5);printw("%s","or"); move(9,8); printw("%s","Bloggs, John Joseph"); move(11,5); printw("%s","Names should be separated by the word 'and', like so:"); move(12,8); printw("%s","John Joseph Bloggs and Richard Lee Head"); move(14,5); printw("%s","Double surnames without separating hyphens must be enclosed within braces"); move(16,5); printw("%s","Words added to surnames such as von or de may be entered in either form:"); move(17,8); printw("%s","Richard von Mannheim or von Mannheim, Richard"); move(19,5); refresh(); getstr(author); set_author=1; break; case '4' : printw("%s","Enter title of book which contains reference"); move(6,5); refresh(); getstr(booktitle); set_booktitle=1; break; case '5' : printw("%s","Please enter chapter or section number"); move(6,5); refresh(); getstr(chapter); set_chapter=1; break; case '6' : printw("%s","Please enter the entry to cross-reference to."); move(6,5); refresh(); getstr(crossref);set_crossref=1;break; case '7' : printw("%s","Please enter the edition."); move(5,5);printw("%s","This should be written in full and be capitalised. For example:"); move(6,8); printw("%s","Second"); move(8,5); refresh(); getstr(edition); set_edition=1; break; case '8' : printw("%s","Please enter the name(s) of the editor(s)."); move(5,5); printw("%s","These should be in the same format as the author name(s)"); move(7,5); refresh(); getstr(editor); set_editor = 1; break; case '9' : printw("%s","Please enter anything unusual about the method of publishing."); printw("%s","This should be capitalised. For example:"); move(5,8); printw("%s","Privately Published"); move(7,5); refresh(); getstr(howpublished); set_howpublished=1; break; case 'a' : printw("%s","Please enter the name of the institution"); move(6,5); refresh(); getstr(institution); set_institution=1; break; case 'b' : printw("%s","Please enter the name of the journal or magazine"); move(6,5); refresh(); getstr(journal); set_journal=1; break; case 'c' : printw("%s","Please enter a key."); printw("%s","This is for additional alphabetising when the author"); move(5,5); printw("%s","information is missing and is not the same as the entry key."); move(7,5); refresh(); getstr(key); set_key=1; break; case 'd' : printw("%s","Please enter the month in which the work was published"); move(6,5); printw("%s","If it is unpublished, enter the month it was written"); move(8,5); refresh(); getstr(month); set_month=1; break; case 'e' : printw("%s","Please enter any additional information"); move(5,5); printw("%s","The first letter should be uppercase"); move(7,5); refresh(); getstr(note); set_note = 1; break; case 'f' : printw("%s","Please enter the number of the journal, book, etc"); move(6,5); refresh(); getstr(number); set_number=1; break; case 'g' : printw("%s","Please enter the sponsoring organisation"); move(6,5); refresh(); getstr(organisation); set_organisation=1; break; case 'h' : printw("%s","Please enter a page number or range of pages"); move(5,5); printw("%s","This can take the following forms:"); move(6,8); printw("%s","33,44,56"); move(7,8); printw("%s","45--117"); move(8,8); printw("%s","87+"); move(10,5);refresh();getstr(pages);set_pages=1;break; case 'i' : printw("%s","Please enter the name of the publisher"); move(6,5);refresh();getstr(publisher);set_publisher=1; break; case 'j' : printw("%s","Please enter the name of the academic institution"); move(6,5);refresh();getstr(school);set_school=1;break; case 'k' : printw("%s","Please enter the name of the series or set of books"); move(5,5); printw("%s","When citing a book from a series, the title field gives the name"); move(6,5); printw("%s","of the book itself while series gives the title of the whole set"); move(8,5);refresh();getstr(series);set_series=1;break; case 'l' : printw("%s","Please enter the title of the work"); move(6,5); refresh(); getstr(title); set_title=1; break; case 'm' : printw("%s","Please enter the type, such as 'Research Note'"); move(6,5); refresh(); getstr(type);set_type=1;break; case 'n' : printw("%s","Please enter the volume number"); move(6,5); refresh(); getstr(volume); set_volume=1; break; case 'o' : printw("%s","Please enter the year of publication."); move(5,5); printw("%s","If the work is unpublished, enter the year it was written"); move(6,5); printw("%s","Years should be given in the four-digit form, ie. 1999"); move(8,5);refresh();getstr(year);set_year=1;break; default : break; } /* Check to see if we have all the info we need */ if (ch == 'z') { not_done =0; if (use_address==1 && set_address == 0) not_done++; if (use_annote==1 && set_annote==0) not_done++; if (use_author==1 && set_author==0) not_done++; if (use_booktitle==1 && set_booktitle==0) not_done++; if (use_chapter==1 && set_chapter==0) not_done++; if (use_edition==1 && set_edition==0) not_done++; if (use_editor==1 && set_editor==0) not_done++; if (use_howpublished==1 && set_howpublished==0) not_done++; if (use_institution==1 && set_institution==0) not_done++; if (use_journal==1 && set_journal==0) not_done++; if (use_key==1 && set_key ==0) not_done++; if (use_month==1 && set_month==0) not_done++; if (use_note==1 && set_note==0) not_done++; if (use_number==1 && set_number==0) not_done++; if (use_organisation==1 && set_organisation==0) not_done++; if (use_pages==1 && set_pages==0) not_done++; if (use_publisher==1 && set_publisher==0) not_done++; if (use_school==1 && set_school==0) not_done++; if (use_series==1 && set_series==0) not_done++; if (use_title==1 && set_title==0) not_done++; if (use_type==1 && set_type==0) not_done++; if (use_volume==1 && set_volume==0) not_done++; if (use_year==1 && set_year==0) not_done++; if (not_done > 0) { setup_screen(); move(4,5); printw("%s %d %s","You can't finish yet - there are still",not_done,"required fields missing!"); move(10,5); printw("%s","Press a key"); cbreak(); ch = getch(); } else still_setting_up = 1; } } /* Create a key name for the new entry */ setup_screen(); move(4,5); printw("%s","Please enter an entry name for the new reference "); move(5,5); refresh(); nocbreak(); getstr(entry_name); /* Add our new entry to the output file */ fin = fopen(bibfile,"r"); if (fin == NULL) { endwin(); perror("Can't open BibTeX file for reading "); exit(1); } fout = fopen("bibtool_tmp.out","w"); if (fout == NULL) { endwin(); perror("Can't write output file "); exit(1); } while((fgets(str, 99, fin)) > 0) { if (strchr(str, '@') != NULL) { entry_count++; /* We've found a reference name */ if (strchr(str, '{') != NULL) key_name = (strchr(str, '{') + 1); else key_name = (strchr(str, '(') + 1); /* Check we haven't already used the entry name */ if (strcmp(key_name, entry_name) == 0) written_new = 2; /* If the current name comes after our new one, write the new one */ if (strcmp(key_name, entry_name) > 0) { if (written_new == 0) { /* Write entire new entry to file */ switch (entry_type) { case '1' : fprintf(fout, "@article{%s", entry_name); break; case '2' : fprintf(fout,"@book{%s", entry_name); break; case '3' : fprintf(fout,"@booklet{%s", entry_name); break; case '4' : fprintf(fout,"@inproceedings{%s", entry_name); break; case '5' : fprintf(fout,"@inbook{%s", entry_name); break; case '6' : fprintf(fout,"@incollection{%s", entry_name); break; case '7' : fprintf(fout,"@manual{%s", entry_name); break; case '8' : fprintf(fout,"@mastersthesis{%s", entry_name); break; case '9' : fprintf(fout,"@misc{%s", entry_name); break; case 'a' : fprintf(fout,"@phdthesis{%s", entry_name); break; case 'b' : fprintf(fout,"@proceedings{%s", entry_name); break; case 'c' : fprintf(fout,"@techreport{%s", entry_name); break; case 'd' : fprintf(fout,"@unpublished{%s", entry_name); break; default : break; } if (set_key == 1) fprintf(fout,",\n KEY={%s}", key); if (set_crossref == 1) fprintf(fout,",\n CROSSREF={%s}", crossref); if (set_author == 1) fprintf(fout,",\n AUTHOR={%s}",author); if (set_title == 1) fprintf(fout,",\n TITLE={%s}",title); if (set_booktitle == 1) fprintf(fout,",\n BOOKTITLE={%s}", booktitle); if (set_journal == 1) fprintf(fout,",\n JOURNAL={%s}", journal); if (set_series == 1) fprintf(fout,",\n SERIES={%s}", series); if (set_edition == 1) fprintf(fout,",\n EDITION={%s}", edition); if (set_volume == 1) fprintf(fout,",\n VOLUME={%s}", volume); if (set_number == 1) fprintf(fout,",\n NUMBER={%s}", number); if (set_type == 1) fprintf(fout,",\n TYPE={%s}", type); if (set_chapter == 1) fprintf(fout,",\n CHAPTER={%s}", chapter); if (set_pages == 1) fprintf(fout,",\n PAGES={%s}", pages); if (set_editor == 1) fprintf(fout,",\n EDITOR={%s}", editor); if (set_institution == 1) fprintf(fout,",\n INSTITUTION={%s}", institution); if (set_organisation == 1) fprintf(fout,",\n ORGANIZATION={%s}", organisation); if (set_school == 1) fprintf(fout,",\n SCHOOL={%s}", school); if (set_publisher == 1) fprintf(fout,",\n PUBLISHER={%s}", publisher); if (set_address == 1) fprintf(fout,",\n ADDRESS={%s}",address);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -