예제 #1
0
 static {
   HEADING_LIST.put("H1 head line", 35);
   HEADING_LIST.put("H2 head line", 30);
   HEADING_LIST.put("H3 head line", 25);
   HEADING_LIST.put("H4 head line", 20);
   HEADING_LIST.put("H5 head line", 15);
   HEADING_LIST.put("Paragraph", 10);
   HEADING_LIST.put("Quote", 10);
 }
  private void validateRegions() {
    if (region_map == null) return;

    synchronized (region_map) {
      if (regions_valid) return;

      Segment s = new Segment();

      region_map.clear();

      for (BaleRegion br : fragment_regions) {
        RegionData rd = new RegionData(indent_size);
        region_map.put(br, rd);
        int soff = br.getStart();
        int eoff = br.getEnd();
        if (eoff < soff) continue;
        try {
          base_document.getText(soff, eoff - soff, s);
        } catch (BadLocationException e) {
          BoardLog.logE("BALE", "Problem getting region indentation", e);
          continue;
        }
        int ln = s.length();

        LineData ld;
        boolean sol = true;
        for (int i = 0; i < ln; ++i) {
          char c = s.charAt(i);
          if (sol) {
            ld = computeLineData(i, s);
            rd.add(ld);
            sol = false;
          }
          if (c == '\n') sol = true;
        }
        if (!sol) {
          ld = computeLineData(ln, s);
          rd.add(ld);
          ++ln;
        }
      }

      regions_valid = true;
    }
  }
예제 #3
0
  public void refreshErrorDisplay() {
    if (parseErrorHighlightKey != null)
      editor.getHighlighter().removeHighlight(parseErrorHighlightKey);

    /* Mapping for gutter */
    Map<Integer, String> errorLines = new HashMap<Integer, String>();

    if (parseError != null && parseError.hasLineNumbers()) {
      String error = parseError.getMessage();

      // Just the first line.
      errorLines.put(parseError.getBeginLine(), error);

      // If error spans multiple lines, this code will put
      // an error in every line of the gutter.
      /*for (int line = parseError.getBeginLine();
           line <= parseError.getEndLine();
           line++)
      {
      	errorLines.put(line, error);
      }*/
    }

    gutter.setParseErrors(errorLines);

    /* Highlighting errors in editor */
    if (parseError != null && parseError.hasLineNumbers()) {
      /* Remove existing highlight */
      try {
        parseErrorHighlightKey =
            editor
                .getHighlighter()
                .addHighlight(
                    computeDocumentOffset(parseError.getBeginLine(), parseError.getBeginColumn()),
                    computeDocumentOffset(parseError.getEndLine(), parseError.getEndColumn()) + 1,
                    errorHighlightPainter);
      } catch (BadLocationException e) {

      }
    }
  }