Changeset 1123


Ignore:
Timestamp:
Jun 29, 2011, 7:13:29 PM (6 years ago)
Author:
stefan
Message:

improved quick help and latex syntax highlighting

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/data/quickhelp/empty.html

    r1119 r1123  
    55</head>
    66<body>
     7  <p>No description available for this command.</p>
    78</body>
    89</html>
  • trunk/src/jlatexeditor/PackagesExtractor.java

    r1122 r1123  
    7373        String name = attrList.getValue("name");
    7474        int argCount = Integer.parseInt(attrList.getValue("argCount"));
    75         String title = attrList.getValue("title");
    76         String description = attrList.getValue("description");
    7775        String optionalArg = attrList.getValue("optionalArg");
    78         Command command = new Command(name, title, description, argCount, optionalArg, pack);
     76        Command command = new Command(name, argCount, optionalArg, pack);
    7977        commands.add(name, command);
    8078      } else
    8179      if (localName.equals("package")) {
    82         pack = new Package(attrList.getValue("name"), attrList.getValue("debPackage"));
     80        pack = new Package(attrList.getValue("name"), attrList.getValue("title"), attrList.getValue("description"), attrList.getValue("debPackage"));
    8381        packages.add(pack.name, pack);
    8482      }
     
    108106  public static class Package {
    109107    private String name;
     108    private String title;
     109    private String description;
    110110    private String debPackage;
    111111
    112     public Package(String name, String debPackage) {
     112    public Package(String name, String title, String description, String debPackage) {
    113113      this.name = name;
     114      this.title = title;
     115      this.description = description;
    114116      this.debPackage = debPackage;
    115117    }
     
    133135    }
    134136
     137    public String getTitle() {
     138      return title;
     139    }
     140
     141    public String getDescription() {
     142      return description;
     143    }
     144
    135145    public String getDebPackage() {
    136146      return debPackage;
     
    140150  public static class Command {
    141151    private String name;
    142     private String title;
    143     private String description;
    144152    private int argCount;
    145153    private String optionalArg;
    146154    private Package pack;
    147155
    148     public Command(String name, String title, String description, int argCount, String optionalArg, Package pack) {
     156    public Command(String name, int argCount, String optionalArg, Package pack) {
    149157      this.name = name;
    150       this.title = title;
    151       this.description = description;
    152158      this.argCount = argCount;
    153159      this.optionalArg = optionalArg;
     
    173179    }
    174180
    175     public String getTitle() {
    176       return title;
    177     }
    178 
    179     public String getDescription() {
    180       return description;
    181     }
    182 
    183181    public int getArgCount() {
    184182      return argCount;
  • trunk/src/jlatexeditor/quickhelp/HelpUrlHandler.java

    r1122 r1123  
    3131    }
    3232    final URL realUrl = new URL(realUrlString);
    33 
    3433    final String finalCommand = command;
    3534
    3635    return new URLConnection(realUrl) {
     36      private URLConnection realConnection = realUrl.openConnection();
     37
    3738      @Override
    3839      public void connect() throws IOException {
     40        realConnection.connect();
     41      }
     42
     43      @Override
     44      public String getContentType() {
     45        return realConnection.getContentType();
    3946      }
    4047
    4148      @Override
    4249      public InputStream getInputStream() throws IOException {
    43         String content = HelpUrlHandler.getHelpTextAt(finalCommand, realUrl);
     50        String content = HelpUrlHandler.getHelpTextAt(finalCommand, realConnection);
    4451
    4552        return new ByteArrayInputStream(content.getBytes());
     
    4855  }
    4956
    50   public static String getHelpTextAt(String command, URL url) {
    51     String content = "<html><body>";
     57  public static String getHelpTextAt(String command, URLConnection urlConnection) {
     58    String content = "content-type: text/html\n\n";
     59    content += "<html><body>";
    5260
    53     if (url != null) {
     61    if (urlConnection != null) {
    5462      try {
    55         BufferedInputStream in = (BufferedInputStream) url.getContent();
     63        BufferedInputStream in = (BufferedInputStream) urlConnection.getContent();
    5664        content = readContent(in);
    5765      } catch (IOException e) {
     
    6674      String commandsDoc = getPackagesString(PackagesExtractor.getDocClassesParser().getCommands().get(command.substring(1)));
    6775      if (commandsPack != null || commandsDoc != null) {
    68         content += "<h3>This command is provided by ...</h3>";
     76        content += "<hr/>";
     77        content += "<h3>Packages providing this command</h3>";
    6978        content += "<ul>";
    7079        if (commandsPack != null) {
     
    9099      for (PackagesExtractor.Command cmd : commands) {
    91100        String hintString = "";
    92         if (cmd.getDescription() != null) {
    93           hintString = " hint=\"" + cmd.getDescription() + "\"";
     101        if (cmd.getPack().getDescription() != null) {
     102          hintString = " - " + cmd.getPack().getDescription();
    94103        }
    95         packs.add("<span" + hintString + ">" + cmd.getPack().getName() + "</span>");
     104        packs.add("<li>" + cmd.getPack().getName() + hintString + "</li>");
    96105      }
    97106      Collections.sort(packs);
    98       return CollectionUtils.join(packs, ", ");
     107      return "<ul>" + CollectionUtils.join(packs, "") + "</ul>";
    99108    }
    100109  }
     
    119128
    120129    try {
    121       System.out.println(new URL("help:file:data/quickhelp/index.html").getContent());
     130      System.out.println(new URL("help:file:/home/stefan/programmierung/java/JLatexEditor/data/quickhelp/index.html").getContent());
    122131    } catch (IOException e) {
    123132      e.printStackTrace();
  • trunk/src/jlatexeditor/syntaxhighlighting/LatexSyntaxHighlighting.java

    r1071 r1123  
    174174            }
    175175            if (svnRow) {
    176               for (int i = 0; i < chars.length; i++) {
    177                 SCEDocumentChar aChar = chars[i];
     176              for (SCEDocumentChar aChar : chars) {
    178177                aChar.style = state.getStyles()[LatexStyles.ERROR];
    179178                //aChar.overlayStyle = 0;
     
    261260              } else
    262261              if (argumentTypeName.equals("label_def")) {
    263                 boolean definedOnce = backgroundParser.getLabelDefs().count(param) == 1;
     262                BackgroundParser.FilePos existingDef = backgroundParser.getLabelDefs().get(param);
     263                boolean alreadyDefined = existingDef != null && existingDef.getLineNr() != row_nr;
    264264                boolean labelReferenced = backgroundParser.getLabelRefs().contains(param);
    265265                byte style;
    266                 if (definedOnce) {
     266                if (alreadyDefined) {
     267                  style = stateStyles[getStyle("label_duplicate", LatexStyles.TEXT)];
     268                } else {
    267269                  style = stateStyles[getStyle(labelReferenced ? "label_exists" : "label_not_referenced", LatexStyles.TEXT)];
    268                 } else {
    269                   style = stateStyles[getStyle("label_duplicate", LatexStyles.TEXT)];
    270270                }
    271271                char_nr = setStyle(param, style, chars, char_nr + 1);
  • trunk/src/util/SystemUtils.java

    r923 r1123  
    11package util;
    22
    3 import java.io.File;
     3import java.io.*;
    44import java.util.regex.Pattern;
    55
     
    3737  }
    3838
     39  public static String getLinuxDistribution() throws IOException {
     40    Process process = Runtime.getRuntime().exec(new String[]{"lsb_release", "-i"});
     41    InputStream in = process.getInputStream();
     42    BufferedReader r = new BufferedReader(new InputStreamReader(in));
     43    try {
     44      String[] parts = r.readLine().split(":");
     45      return parts[1].trim();
     46    } catch (Exception e) {
     47      throw new IOException("lsb_release produced unexpected output");
     48    }
     49  }
     50
    3951  public static File newFile(File parent, String fileName) {
    4052    if (absoluteFile.matcher(fileName).matches()) return new File(fileName);
Note: See TracChangeset for help on using the changeset viewer.