Changeset 1054


Ignore:
Timestamp:
Jun 11, 2011, 1:58:24 AM (6 years ago)
Author:
joerg
Message:

towards marking unused bibtex items

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/data/styles/user.xml

    r1033 r1054  
    2929  <element name="label_not_found" style="plain" foreground="ff0000"/>
    3030  <element name="label_not_referenced" style="plain" background="fdffc5"/>
    31   <element name="label_duplicate" style="plain" foreground="ff0000"/>
     31  <element name="label_duplicate" style="plain" foreground="ff0000"/>
    3232
    3333  <element name="file_exists" style="plain" foreground="800080"/>
    3434  <element name="file_not_found" style="plain" foreground="ff0000"/>
    3535
    36   <element name="cite_exists" style="plain" foreground="800080"/>
    37   <element name="cite_not_found" style="plain" foreground="ff0000"/>
     36  <element name="cite_exists" style="plain" foreground="800080"/>
     37  <element name="cite_not_found" style="plain" foreground="ff0000"/>
    3838
    3939</styles>
  • trunk/src/jlatexeditor/JLatexEditorJFrame.java

    r1053 r1054  
    4545import javax.swing.event.TreeSelectionEvent;
    4646import javax.swing.event.TreeSelectionListener;
    47 import javax.swing.filechooser.FileNameExtensionFilter;
    4847import javax.swing.plaf.basic.BasicSplitPaneUI;
    4948import java.awt.*;
     
    677676
    678677    // syntax highlighting
    679     BibSyntaxHighlighting syntaxHighlighting = new BibSyntaxHighlighting(scePane);
     678    BibSyntaxHighlighting syntaxHighlighting = new BibSyntaxHighlighting(scePane, backgroundParser);
    680679    syntaxHighlighting.start();
    681680
  • trunk/src/jlatexeditor/bib/BibParserState.java

    r789 r1054  
    1717  public static final int STATE_VALUE_QUOTED = 7;
    1818  public static final int STATE_VALUE_BRACED = 8;
     19  public static final int STATE_EXPECT_CLOSE = 9;
    1920
    2021  private int state = STATE_NOTHING;
  • trunk/src/jlatexeditor/bib/BibSyntaxHighlighting.java

    r1048 r1054  
    11package jlatexeditor.bib;
    22
     3import jlatexeditor.JLatexEditorJFrame;
     4import jlatexeditor.codehelper.BackgroundParser;
     5import jlatexeditor.codehelper.BibParser;
    36import jlatexeditor.syntaxhighlighting.LatexStyles;
    47import jlatexeditor.syntaxhighlighting.LatexSyntaxHighlighting;
     
    69import sce.syntaxhighlighting.ParserStateStack;
    710import sce.syntaxhighlighting.SyntaxHighlighting;
     11import util.TrieSet;
    812
    913import java.util.ArrayList;
     
    1620  private static char[] COMMA_OR_BRACKET = new char[] {'}', ',', ' '};
    1721  private static char[] EQ_COMMA_OR_BRACKET = new char[] {'=', '}', ',', ' '};
     22  private static char[] EQ = new char[] {'=', ' '};
    1823  static {
    1924    Arrays.sort(COMMA_OR_BRACKET);
     
    2429  private SCEPane pane = null;
    2530  private SCEDocument document = null;
     31  private static BackgroundParser backgroundParser = null;
    2632
    2733  // do we need to parse
     
    2935  private boolean currentlyChanging = false;
    3036
    31   public BibSyntaxHighlighting(SCEPane pane) {
     37  public BibSyntaxHighlighting(SCEPane pane, BackgroundParser parser) {
    3238    super("BibTexSyntaxHighlighting");
    3339    this.pane = pane;
    3440    document = pane.getDocument();
    3541    document.addSCEDocumentListener(this);
     42
     43    backgroundParser = parser;
    3644
    3745    // initialize
     
    187195        state.setState(BibParserState.STATE_EXPECT_NAME);
    188196        continue;
     197      }
     198
     199      // close string entry }
     200      if(state.getState() == BibParserState.STATE_EXPECT_CLOSE && !Character.isWhitespace(c)) {
     201        sce_char.style = stateStyles[LatexStyles.BRACKET];
     202        if(c != '}') {
     203          sce_char.style = LatexStyles.ERROR;
     204          continue;
     205        }
    189206      }
    190207
     
    215232      // entry name
    216233      if(state.getState() == BibParserState.STATE_EXPECT_NAME && !Character.isWhitespace(c)) {
    217         String entryName = LatexSyntaxHighlighting.getUntil(row, char_nr + 1, COMMA_OR_BRACKET);
     234        boolean isString = state.getEntryType().toLowerCase().equals("string");
     235        char delimiter[] = !isString ? COMMA_OR_BRACKET: EQ;
     236        String entryName = LatexSyntaxHighlighting.getUntil(row, char_nr, delimiter);
    218237        if(c == ',' || entryName == null) {
    219238          sce_char.style = stateStyles[LatexStyles.TEXT];
    220           sce_char.style = stateStyles[LatexStyles.ERROR];
    221239          if(c == ',') state.setState(BibParserState.STATE_EXPECT_KEY);
    222240          continue;
    223241        }
    224242
    225         byte entryStyle = stateStyles[LatexStyles.ERROR];
     243        byte entryStyle = stateStyles[LatexStyles.getStyle("begin")];
     244        // is the bib item used?
     245        if(backgroundParser != null) {
     246          TrieSet<BackgroundParser.FilePos> bibRefs = backgroundParser.getBibRefs();
     247          if(!bibRefs.contains(entryName)) {
     248            entryStyle = stateStyles[LatexStyles.COMMENT];
     249          }
     250        }
     251
    226252        for (int i = 0; i <= entryName.length(); i++) {
    227253          chars[char_nr + i].style = entryStyle;
    228254        }
    229         char_nr += entryName.length();
    230 
    231         state.setState(BibParserState.STATE_EXPECT_COMMA);
     255        char_nr += entryName.length()-1;
     256
     257        state.setState(!isString ? BibParserState.STATE_EXPECT_COMMA : BibParserState.STATE_EXPECT_EQ);
    232258        continue;
    233259      }
     
    302328        } else
    303329        if(c == '"') {
    304           state.setState(BibParserState.STATE_EXPECT_COMMA);
     330          boolean isString = state.getEntryType().toLowerCase().equals("string");
     331          state.setState(!isString ? BibParserState.STATE_EXPECT_COMMA : BibParserState.STATE_EXPECT_CLOSE);
    305332        }
    306333
     
    323350        } else
    324351        if(state.getBracketLevel() == 0 && c == ',') {
    325           state.setState(BibParserState.STATE_EXPECT_COMMA);
     352          boolean isString = state.getEntryType().toLowerCase().equals("string");
     353          state.setState(!isString ? BibParserState.STATE_EXPECT_COMMA : BibParserState.STATE_EXPECT_CLOSE);
    326354          char_nr--;
    327355        }
  • trunk/src/jlatexeditor/errorhighlighting/LatexCompiler.java

    r1048 r1054  
    280280    try {
    281281      errorView.compileStarted("bibtex");
    282       bibtex = ProcessUtil.exec(new String[]{"bibtex", baseName}, file.getParentFile());
     282      String exe = GProperties.getString("compiler.bibtex.executable");
     283      bibtex = ProcessUtil.exec(new String[]{exe, baseName}, file.getParentFile());
    283284      bibtex.waitFor();
    284285
  • trunk/src/jlatexeditor/gproperties/GProperties.java

    r1050 r1054  
    227227    properties.addEntry(new Def("compiler.latex.executable", STRING, "latex"));
    228228    properties.addEntry(new Def("compiler.latex.parameters", STRING, "--src-specials"));
     229    properties.addEntry(new Comment(" bibtex"));
     230    properties.addEntry(new Def("compiler.bibtex.executable", STRING, "bibtex"));
    229231    properties.addEntry(new Comment(" forward search"));
    230232    properties.addEntry(new Def("forward search.viewer", STRING, ""));
Note: See TracChangeset for help on using the changeset viewer.