Examples of SketchCode


Examples of processing.app.SketchCode

    public LineID javaToSketchLine(LineID javaLine) {
        Sketch sketch = editor.getSketch();

        // it may belong to a pure java file created in the sketch
        // try to find an exact filename match and check the extension
        SketchCode tab = editor.getTab(javaLine.fileName());
        if (tab != null && tab.isExtension("java")) {
            // can translate 1:1
            return originalToRuntimeLine(javaLine);
        }

        // check if it is the preprocessed/assembled file for this sketch
        // java file name needs to match the sketches filename
        if (!javaLine.fileName().equals(sketch.getName() + ".java")) {
            return null;
        }

        // find the tab (.pde file) this line belongs to
        // get the last tab that has an offset not greater than the java line number
        for (int i = sketch.getCodeCount() - 1; i >= 0; i--) {
            tab = sketch.getCode(i);
            // ignore .java files
            // the tab's offset must not be greater than the java line number
            if (tab.isExtension("pde") && tab.getPreprocOffset() <= javaLine.lineIdx()) {
                return originalToRuntimeLine(new LineID(tab.getFileName(), javaLine.lineIdx() - tab.getPreprocOffset()));
            }
        }

        return null;
    }
View Full Code Here

Examples of processing.app.SketchCode

     */
    public LineID sketchToJavaLine(LineID sketchLine) {
        sketchLine = runtimeToOriginalLine(sketchLine); // transform back to orig (before changes at runtime)

        // check if there is a tab for this line
        SketchCode tab = editor.getTab(sketchLine.fileName());
        if (tab == null) {
            return null;
        }

        // check if the tab is a pure java file anyway
        if (tab.isExtension("java")) {
            // 1:1 translation
            return sketchLine;
        }

        // the java file has a name sketchname.java
        // just add the tab's offset to get the java name
        LineID javaLine = new LineID(editor.getSketch().getName() + ".java", sketchLine.lineIdx() + tab.getPreprocOffset());
        return javaLine;
    }
View Full Code Here

Examples of processing.app.SketchCode

    /**
     * Start tracking all line changes (due to edits) in the current tab.
     */
    // TODO: maybe move this to the editor?
    protected void startTrackingLineChanges() {
        SketchCode tab = editor.getSketch().getCurrentCode();
        if (runtimeTabsTracked.contains(tab.getFileName())) {
            return;
        }

        for (int i = 0; i < tab.getLineCount(); i++) {
            LineID old = new LineID(tab.getFileName(), i);
            LineID tracked = new LineID(tab.getFileName(), i);
            tracked.startTracking(editor.currentDocument());
            runtimeLineChanges.put(old, tracked);
        }
        runtimeTabsTracked.add(tab.getFileName());
        //System.out.println("tracking tab: " + tab.getFileName());
    }
View Full Code Here

Examples of processing.app.SketchCode

    protected List<LineID> stripBreakpointComments() {
        List<LineID> bps = new ArrayList();
        // iterate over all tabs
        Sketch sketch = getSketch();
        for (int i = 0; i < sketch.getCodeCount(); i++) {
            SketchCode tab = sketch.getCode(i);
            String code = tab.getProgram();
            String lines[] = code.split("\\r?\\n"); // newlines not included
            //System.out.println(code);

            // scan code for breakpoint comments
            int lineIdx = 0;
            for (String line : lines) {
                //System.out.println(line);
                if (line.endsWith(breakpointMarkerComment)) {
                    LineID lineID = new LineID(tab.getFileName(), lineIdx);
                    bps.add(lineID);
                    //System.out.println("found breakpoint: " + lineID);
                    // got a breakpoint
                    //dbg.setBreakpoint(lineID);
                    int index = line.lastIndexOf(breakpointMarkerComment);
                    lines[lineIdx] = line.substring(0, index);
                }
                lineIdx++;
            }
            //tab.setProgram(code);
            code = PApplet.join(lines, "\n");
            setTabContents(tab.getFileName(), code);
        }
        return bps;
    }
View Full Code Here

Examples of processing.app.SketchCode

     * called just after saving the sketch.
     *
     * @param tabFilename the tab file name
     */
    protected void addBreakpointComments(String tabFilename) {
        SketchCode tab = getTab(tabFilename);
        List<LineBreakpoint> bps = dbg.getBreakpoints(tab.getFileName());

        // load the source file
        File sourceFile = new File(sketch.getFolder(), tab.getFileName());
        //System.out.println("file: " + sourceFile);
        try {
            String code = Base.loadFile(sourceFile);
            //System.out.println("code: " + code);
            String lines[] = code.split("\\r?\\n"); // newlines not included
View Full Code Here

Examples of processing.app.SketchCode

        }
     
        // note modified tabs
        final List<String> modified = new ArrayList();
        for (int i = 0; i < getSketch().getCodeCount(); i++) {
            SketchCode tab = getSketch().getCode(i);
            if (tab.isModified()) {
                modified.add(tab.getFileName());
            }
        }

        boolean saved = super.handleSave(immediately);
        if (saved) {
View Full Code Here

Examples of processing.app.SketchCode

     */
    protected void setTabContents(String tabFilename, String code) {
        // remove all breakpoints of this tab
        dbg.clearBreakpoints(tabFilename);

        SketchCode currentTab = getCurrentTab();

        // set code of tab
        SketchCode tab = getTab(tabFilename);
        if (tab != null) {
            tab.setProgram(code);
            // this updates document and text area
            // TODO: does this have any negative effects? (setting the doc to null)
            tab.setDocument(null);
            setCode(tab);

            // switch back to original tab
            setCode(currentTab);
        }
View Full Code Here

Examples of processing.app.SketchCode

    // Also, need to do the update in the UI thread to prevent concurrency issues.
    final int fheight = this.getHeight();
    SwingWorker worker = new SwingWorker() {

      protected Object doInBackground() throws Exception {
        SketchCode sc = editor.getSketch().getCurrentCode();
        int totalLines = 0, currentTab = editor.getSketch()
            .getCurrentCodeIndex();
        try {
          totalLines = Base.countLines(sc.getDocument()
              .getText(0, sc.getDocument().getLength())) + 1;
        } catch (BadLocationException e) {
          e.printStackTrace();
        }
        // System.out.println("Total lines: " + totalLines);
        synchronized (errorPoints) {
View Full Code Here

Examples of processing.app.SketchCode

          editor = errorCheckerService.getEditor();
          int codeIndex = editor.getSketch().getCodeIndex(editor
                                                              .getCurrentTab());
          if (codeIndex > 0)
            for (int i = 0; i < codeIndex; i++) {
              SketchCode sc = editor.getSketch().getCode(i);
              int len = Base.countLines(sc.getProgram()) + 1;
              lineNumber += len;
            }

        }
       
View Full Code Here

Examples of processing.app.SketchCode

    if (errorCheckerService != null) {
      editor = errorCheckerService.getEditor();
      int codeIndex = editor.getSketch().getCodeIndex(editor.getCurrentTab());
      if (codeIndex > 0) {
        for (int i = 0; i < codeIndex; i++) {
          SketchCode sc = editor.getSketch().getCode(i);
          int len = Base.countLines(sc.getProgram()) + 1;
          pdeLineNumber += len;
        }
      }

    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.