Changeset 911


Ignore:
Timestamp:
Nov 2, 2010, 7:46:17 PM (7 years ago)
Author:
joerg
Message:

forward search

Location:
trunk/src/jlatexeditor
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/jlatexeditor/JLatexEditorJFrame.java

    r898 r911  
    215215    editMenu.add(createMenuItem("Uncomment", "uncomment", 'u'));
    216216    editMenu.addSeparator();
     217    editMenu.add(createMenuItem("Forward Search", "forward search", null));
     218    editMenu.addSeparator();
    217219    editMenu.add(createMenuItem("Diff", "diff", 'D'));
    218220
     
    260262
    261263    settingsMenu.add(createMenuItem("Font", "font", 'F'));
     264    JMenu forwardSearch = new JMenu("Forward Search"); {
     265      forwardSearch.add(createMenuItem("Skim", "forward search: /Applications/Skim.app/Contents/SharedSupport/displayline %line \"%file.pdf\" \"%texfile\"", null));
     266      forwardSearch.add(createMenuItem("xdvi", "forward search: xdvi -sourceposition \"%line %file.dvi\" -nofork", null));
     267      forwardSearch.add(createMenuItem("kdvi", "forward search: kdvi \"file:%file.dvi#src:%line %texfile\"", null));
     268    }
     269    settingsMenu.add(forwardSearch);
    262270    settingsMenu.add(createMenuItem("Global Settings", "global settings", 'G'));
    263271
     
    10091017      statusBar.setVisible(!statusBar.isVisible());
    10101018    } else
     1019
     1020    // forward search
     1021    if (action.startsWith("forward search: ")) {
     1022      String command = action.substring("forward search: ".length());
     1023      GProperties.set("viewer.forward search", command);
     1024    } else
     1025
     1026    if (action.equals("forward search")) {
     1027      try {
     1028        SourceCodeEditor editor = getActiveEditor();
     1029        int line = editor.getTextPane().getCaret().getRow()+1;
     1030        String texfile = editor.getFile().getAbsolutePath();
     1031        String file = texfile.substring(0, texfile.lastIndexOf(".tex"));;
     1032
     1033        ArrayList<String> list = StringUtils.tokenize(GProperties.getString("viewer.forward search"));
     1034        String[] array = new String[list.size()];
     1035        list.toArray(array);
     1036
     1037        for(int index = 0; index < array.length; index++) {
     1038          String token = array[index];
     1039          token = token.replaceAll("%line", line+"");
     1040          token = token.replaceAll("%file", file);
     1041          token = token.replaceAll("%texfile", texfile);
     1042          token = token.replaceAll("&nbsp;", " ");
     1043          array[index] = token;
     1044        }
     1045        ProcessUtil.exec(array, mainEditor.getFile().getParentFile());
     1046      } catch(Exception ex) {
     1047        System.err.println("Forward search failed: " + ex.getMessage());
     1048      }
     1049    } else
    10111050
    10121051    // diff
  • trunk/src/jlatexeditor/gproperties/GProperties.java

    r907 r911  
    156156    properties.addEntry(new Def("shortcut.uncomment", SHORTCUT, "control shift D"));
    157157    properties.addEntry(new Def("shortcut.diff", SHORTCUT, "alt D"));
     158    properties.addEntry(new Def("shortcut.forward search", SHORTCUT, "control shift F"));
    158159    properties.addEntry(new Comment(" View"));
    159160    properties.addEntry(new Def("shortcut.symbols", SHORTCUT, "alt Y"));
     
    186187    properties.addEntry(new Comment(" pdflatex"));
    187188    properties.addEntry(new Def("compiler.pdflatex.executable", STRING, "pdflatex"));
    188     properties.addEntry(new Def("compiler.pdflatex.parameters", STRING, ""));
     189    properties.addEntry(new Def("compiler.pdflatex.parameters", STRING, "-synctex=1"));
    189190    properties.addEntry(new Comment(" latex"));
    190191    properties.addEntry(new Def("compiler.latex.executable", STRING, "latex"));
    191     properties.addEntry(new Def("compiler.latex.parameters", STRING, ""));
     192    properties.addEntry(new Def("compiler.latex.parameters", STRING, "--src-specials"));
     193    properties.addEntry(new Comment(" forward search"));
     194    properties.addEntry(new Def("viewer.forward search", STRING, ""));
    192195
    193196    load();
Note: See TracChangeset for help on using the changeset viewer.