Changeset 1124


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

improved quick search

Location:
trunk/src/jlatexeditor/quickhelp
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/jlatexeditor/quickhelp/HelpUrlHandler.java

    r1123 r1124  
    3131    }
    3232    final URL realUrl = new URL(realUrlString);
    33     final String finalCommand = command;
    34 
     33    final String finalCommand = command == null || command.equals("") ? null : command;
    3534    return new URLConnection(realUrl) {
    3635      private URLConnection realConnection = realUrl.openConnection();
  • trunk/src/jlatexeditor/quickhelp/LatexQuickHelp.java

    r1119 r1124  
    33import de.endrullis.utils.CollectionUtils;
    44import jlatexeditor.PackagesExtractor;
     5import sce.codehelper.PatternPair;
     6import sce.codehelper.WordWithPos;
    57import sce.component.SCEDocument;
    68import sce.quickhelp.QuickHelp;
     
    3537   */
    3638  static final Pattern htmlCommandsPattern = Pattern.compile("<li>.*<a href=\"([^\"]+)\">(.*)</a>.*</li>");
    37   /**
    38    * Command has to start with a backslash and may only contain letters.
    39    */
    40   static final Pattern commandStartPattern = Pattern.compile("(\\\\\\w*)$");
    41   /**
    42    * End of a command may end with an arbitrary number of letters.
    43    */
    44   static final Pattern commandEndPattern = Pattern.compile("^(\\w*)");
     39  /**
     40   * PatternPair to find command under cursor.
     41   */
     42  static final PatternPair commandPattern = new PatternPair("(\\\\\\w*)", "(\\w*)");
    4543
    4644  /**
     
    106104    String line = document.getRow(row);
    107105
    108     Matcher startMatcher = commandStartPattern.matcher(line.substring(0, column));
    109     Matcher endMatcher = commandEndPattern.matcher(line.substring(column, line.length()));
     106    List<WordWithPos> groups = commandPattern.find(line, row, column);
    110107
    111     if (startMatcher.find() && endMatcher.find()) {
    112       return startMatcher.group(1) + endMatcher.group(1);
     108    if (groups != null) {
     109      return groups.get(0).word;
    113110    }
    114111
    115     return "";
     112    return null;
    116113  }
    117114
     
    123120   */
    124121  public String getHelpUrl(String command) {
     122    if (command == null) return null;
     123
    125124    String fileName = commands.get(command);
    126125    if (fileName == null) fileName = commands.get("<empty>");
Note: See TracChangeset for help on using the changeset viewer.