Package winterwell.markdown.pagemodel

Examples of winterwell.markdown.pagemodel.MarkdownPage


      if (!(editor instanceof MarkdownEditor)) {
        viewer.setText("");
        return;
      }
      MarkdownEditor ed = (MarkdownEditor) editor;
      MarkdownPage page = ed.getMarkdownPage();
      String html = page.html();
      html = addBaseURL(editor, html);
      if (page != null) viewer.setText(html);
      else viewer.setText("");
    } catch (Exception ex) {
      // Smother
View Full Code Here


      // Where is the caret?
      ISourceViewer viewer = ed.getViewer();
      int caretOffset = viewer.getTextWidget().getCaretOffset();
      int lineNum = ed.getDocument().getLineOfOffset(caretOffset);
      // Get a paragraph region
      MarkdownPage page = ed.getMarkdownPage();
      IRegion pRegion = getParagraph(page, lineNum, ed.getDocument());
      if (pRegion==null) {
        // Not in a paragraph - so give up
         // TODO tell the user why we've given up
        return;
View Full Code Here

    int end = s.getEndLine();
    IDocument doc = ed.getDocument();
    int soff = doc.getLineOffset(start);
    int eoff = lineEndOffset(end, doc);   
    IntRange editedRegion = new IntRange(soff, eoff);   
    MarkdownPage page = ed.getMarkdownPage();
    StringBuilder sb = new StringBuilder(s.getLength());
    for(int i=start; i<=end; i++) {
      IRegion para = getParagraph(page, i, ed.getDocument());
      if (para==null) {
        sb.append(page.getText().get(i));
        continue;
      }
      String paragraph = ed.getDocument().get(para.getOffset(), para.getLength());
//      int lines = StrUtils.splitLines(paragraph).length;
      String formatted = MarkdownFormatter.format(paragraph, cols);
View Full Code Here

   */
  protected void doSyncToEditor() throws BadLocationException {
    TreeViewer viewer = getTreeViewer();
    if (viewer == null) return;
    // Get header
    MarkdownPage page = fTextEditor.getMarkdownPage();
    int caretOffset = fTextEditor.getViewer().getTextWidget().getCaretOffset();
    IDocument doc = fTextEditor.getDocument();
    int line = doc.getLineOfOffset(caretOffset);
    List<KLineType> lineTypes = page.getLineTypes();
    for(; line>-1; line--) {
      KLineType lt = lineTypes.get(line);
      if (lt.toString().startsWith("H")) break;
    }
    if (line<0) return;
    Header header = (Header) page.getPageObject(line);
    // Set
    IStructuredSelection selection = new StructuredSelection(header);
    viewer.setSelection(selection , true);
  }
View Full Code Here

    if (selectedHeaders == null || selectedHeaders.size() == 0)
      return;
    HashSet<Header> toAdjust = new HashSet<Header>(selectedHeaders);
    HashSet<Header> adjusted = new HashSet<Header>();
    // Adjust
    MarkdownPage mdPage = fTextEditor.getMarkdownPage();
    List<String> lines = new ArrayList<String>(mdPage.getText());
    while(toAdjust.size() != 0) {
      Header h = toAdjust.iterator().next();
      toAdjust.remove(h);
      adjusted.add(h);
      String line = lines.get(h.getLineNumber());
View Full Code Here

  }

  private void updateMarkdownPage() {
    String text = getText();
    if (text==null) text="";
    page = new MarkdownPage(text);
    pageDirty = false;
  }
View Full Code Here

   */
  private void updateSectionFoldingAnnotations(IRegion region) {
    if (!haveRunFolding) region = null; // Do the whole doc
    if ( ! (getSourceViewer() instanceof ProjectionViewer)) return;
    ProjectionViewer viewer = ((ProjectionViewer)getSourceViewer());
    MarkdownPage mPage = getMarkdownPage();
    List<Header> headers = mPage.getHeadings(null);
    // this will hold the new annotations along
    // with their corresponding positions
    Map<Annotation, Position> annotations = new HashMap<Annotation, Position>();
    IDocument doc = getDocument();
    updateSectionFoldingAnnotations2(doc, headers, annotations, doc.getLength());
View Full Code Here

TOP

Related Classes of winterwell.markdown.pagemodel.MarkdownPage

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.