📄 bibtool.c
字号:
/* Bibtool - a curses-based BibTeX bibliography file editor Copyright (C) 1999 - 2001 Dominic Tristram This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Bibtool Homepage - http://bibtool.sourceforge.net Dominic Tristram - dominic@rampant.cx - http://www.rampant.cx I apologise for the code - it's a bit crap and messy... */#include <stdio.h>#include <stdlib.h>#include <unistd.h>#include <curses.h>#include <string.h>int rec_count;char bibfile[100];void add_bold(char letter);void general_help();void setup_screen() { clear(); move(0,0); attron(A_BOLD); printw("%s", "bibtool - Dominic Tristram, 2001"); attroff(A_BOLD); printw("%s %d"," Entries in bibliography :", rec_count); }void menu() { int ch, lch; setup_screen(); move(4,5); add_bold('S'); printw("%s","earch and query"); move(5,5); add_bold('A'); printw("%s","dd a new entry"); move(6,5); add_bold('D'); printw("%s","elete an entry"); move(7,5); printw("%s","View or "); add_bold('C'); printw("%s","hange an existing entry"); /*move(8,5); add_bold('B'); printw("%s","eautify/check the BibTeX file"); move(9,5); printw("%s","Distributed ser"); add_bold('V'); printw("er menu"); move(10,5); printw("%s","Configuration "); add_bold('O'); printw("ptions");a */ move(11,5); add_bold('H'); printw("%s","elp"); move(12,5); add_bold('Q'); printw("%s","uit"); move(15,5); printw("What do you want to do? "); refresh(); cbreak(); ch = getch(); lch = tolower(ch); switch (lch) { case 's' : search_menu(); break; case 'a' : add_entry(); break; case 'd' : delete_entry(); break; case 'c' : change_entry(); break; case 'b' : beautify(); break; case 'v' : server_menu(); break; case 'o' : config_options(); break; case 'h' : help(); break; case 'q' : quit_prog(); break; default : break; } }help() { char tmp_char, lch; setup_screen(); move(4,0); printw("%s\n","This is the main bibtool screen. You can choose from four main"); printw("%s\n","options. Press 's' to search for key words in your BibTeX file."); printw("%s\n","You will be given a list of entry names containing the search"); printw("%s\n","term. You can then display these by using the 'C' option on"); printw("%s\n\n","this screen."); printw("%s\n","The Add option will ask you for details about your new"); printw("%s\n","reference, then add it to the database. The delete option will"); printw("%s\n","remove a reference with the ID you supply from the database."); move(14,5); printw("%s","Press a key to continue, or H for more help"); refresh(); cbreak(); tmp_char = getch(); lch = tolower(tmp_char); if (lch == 'h') general_help(); }void general_help() { char tmp_char; setup_screen(); move(4,5); printw("%s","Please refer to the man page and documentation provided"); move(5,5); printw("%s","with this distribution. Check the bibtool website at:"); move(7,8); printw("%s","http://bibtool.sourceforge.net/"); move(9,5); printw("%s","before sending any queries to me at:"); move(11,8); printw("%s","dominic@rampant.cx"); move(13,5); printw("%s","quoting the version information below."); move(15,8); printw("%s","Version info : 1.7.1 build 1 07/03/2001"); move(17,5); printw("%s","Press any key to continue"); refresh(); cbreak(); tmp_char = getch(); }config_options() { /* For future use */ }add_entry() { char ch, lch, entry_type; int use_author = 0, use_title = 0, use_journal = 0, use_year = 0; int use_volume = 0, use_number = 0, use_series = 0, use_address = 0; int use_pages = 0, use_month = 0, use_note = 0, use_editor = 0; int use_publisher = 0, use_edition = 0, use_howpublished = 0, use_type =0; int use_booktitle = 0, use_chapter = 0, use_organisation = 0; int use_school = 0, use_institution = 0, use_annote = 0, use_key = 0; int set_address = 0, set_annote = 0, set_author = 0, set_booktitle = 0; int set_chapter = 0, set_crossref = 0, set_edition = 0, set_editor = 0; int set_howpublished = 0, set_institution = 0, set_journal = 0; int set_key = 0, set_month = 0, set_note = 0, set_number = 0; int set_organisation = 0, set_pages = 0, set_publisher = 0, set_school = 0; int set_series = 0, set_title = 0, set_type = 0, set_volume = 0; int set_year = 0, not_done=0; int print_pos = 6; int still_setting_up = 0, written_new=0; int entry_count = 0; char address[100], annote[100], author[100], booktitle[100], chapter[10], crossref[100], edition[100]; char editor[100], howpublished[100], institution[100], journal[200], key[50], month[15]; char note[400], number[10], organisation[100], pages[10], publisher[100], school[100], series[100]; char title[200], type[100], volume[10], year[5]; char entry_name[100], out_string[100], str[100], *key_name; FILE *fin, *fout; setup_screen(); move(4,5); printw("%s","Please choose entry type"); move(6,8); printw("%s","1. Article - paper or article in journal"); move(7,8); printw("%s","2. Book - whole book"); move(8,8); printw("%s","3. Booklet - bound work with no publisher name"); move(9,8); printw("%s","4. Conference / in proceedings - paper or article from proceedings"); move(10,8); printw("%s","5. In book - extract from a book"); move(11,8); printw("%s","6. In collection - part of book with its own title"); move(12,8); printw("%s","7. Manual - technical documentation"); move(13,8); printw("%s","8. Masters thesis"); move(14,8); printw("%s","9. Miscellaneous - anything not covered by other options"); move(15,8); printw("%s","A. PhD thesis"); move(16,8); printw("%s","B. Proceedings - whole proceedings"); move(17,8); printw("%s","C. Technical report - report published by institution"); move(18,8); printw("%s","D. Unpublished - unpublished work with author and title"); move(20,8); printw("%s","Q. None of these! Go back!"); refresh(); cbreak(); ch = getch(); entry_type = tolower(ch); if (entry_type == 'q') return(0); /* Set which fields to prompt for */ switch(entry_type) { case '1' : use_author = 1; use_title = 1; use_journal = 1; use_year = 1; use_volume = 2; use_number = 2; use_pages = 2; use_month = 2; use_note = 2; break; case '2' : use_author = 1; use_editor = 2; use_title = 1; use_publisher = 1; use_year = 1; use_volume = 2; use_number = 2; use_series = 2; use_address = 2; use_edition = 2; use_month = 2; use_note = 2; break; case '3' : use_title = 1; use_author = 2; use_howpublished = 2; use_address = 2; use_month = 2; use_year = 2; use_note = 2; break; case '4' : use_author = 1; use_title = 1; use_booktitle = 1; use_year =1; use_editor = 2; use_volume = 2; use_number = 2; use_series =2; use_pages = 2; use_address = 2; use_month = 2; use_organisation = 2; use_publisher = 2; use_note = 2; break; case '5' : use_author = 1; use_editor = 1; use_title = 1; use_chapter =1; use_pages = 1; use_publisher = 1; use_year = 1; use_volume = 2; use_number = 2; use_series=2; use_type = 2; use_address = 2; use_edition = 2; use_month = 2; use_note = 2; break; case '6' : use_author = 1; use_title = 1; use_booktitle = 1; use_publisher = 1; use_year = 1; use_editor = 1; use_chapter = 1; use_pages = 2; use_address = 2; use_month = 2; use_note = 2; break; case '7' : use_title = 1; use_author =2; use_organisation=2; use_address=2; use_edition=2; use_month=2; use_year=2; use_note=2; break; case '8' : use_author=2; use_title=1; use_school=1; use_year=1; use_type=2; use_address=2; use_month=2; use_note=2; break; case '9' : use_author=2; use_title=2; use_howpublished=2; use_month=2; use_year=2; use_note=2; break; case 'a' : use_author=1; use_title=1; use_school=1; use_year=1; use_type=2; use_address=2; use_month=2; use_note=2; break; case 'b' : use_title=1; use_year=1; use_editor=2; use_volume=2; use_number=2; use_series=2; use_address=2; use_month=2; use_organisation=2; use_publisher=2; use_note=2; break; case 'c' : use_author=1; use_title=1; use_institution=1; use_year=1; use_type=2; use_number=2; use_address=2; use_month=2; use_note=2; break; case 'd' : use_author=1; use_title=1; use_note=1; use_month=2; use_year=2; break; default : return(0); break; } while (still_setting_up == 0) { print_pos = 7; setup_screen(); move(3,5); attron(A_BOLD); printw("%s","Bold"); attroff(A_BOLD); printw("%s"," fields are required and must be used - others are optional"); move(4,5); printw("%s","Fields marked with a * have been set. Press Z when done or"); move(5,5); printw("%s","Q to quit"); if (use_address != 0) { move(print_pos,5); if (use_address == 1) { attron(A_BOLD); printw("%s","1. Address "); attroff(A_BOLD); } else printw("%s","1. Address "); if (set_author == 1) addch('*'); print_pos++; } if (use_annote != 0) { move(print_pos,5); if (use_annote == 1) { attron(A_BOLD); printw("%s","2. Annote "); attroff(A_BOLD); } else printw("%s","2. Annote "); if (set_annote == 1) addch('*'); print_pos++; } if (use_author != 0) { move(print_pos,5); if (use_author == 1) { attron(A_BOLD); printw("%s","3. Author(s) "); attroff(A_BOLD); } else printw("%s","3. Author(s) "); if (set_author == 1) addch('*'); print_pos++; } if (use_booktitle != 0) { move(print_pos, 5); if (use_booktitle == 1) { attron(A_BOLD); printw("%s","4. Booktitle "); attroff(A_BOLD); } else printw("%s","4. Booktitle "); if (set_booktitle == 1) addch('*'); print_pos++; } if (use_chapter != 0) { move(print_pos,5); if (use_chapter == 1) { attron(A_BOLD); printw("%s","5. Chapter "); attroff(A_BOLD); } else printw("%s","5. Chapter "); if (set_chapter == 1) addch('*'); print_pos++; } move(print_pos,5); printw("%s","6. Cross-reference "); if (set_crossref == 1) addch('*'); print_pos++; if (use_edition != 0) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -