processing.app

## Class SketchCode

- Object
- - SketchCode

-     public class SketchCode
      extends Object

  Represents a single tab of a sketch.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `SketchCode(File file, String extension)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addPreprocOffset(int extra)`
    `void` | `copyTo(File dest)`
    `Document` | `getDocument()`
    `String` | `getExtension()`
    `File` | `getFile()`
    `String` | `getFileName()`
    `int` | `getLineCount()`
    `int` | `getPreprocOffset()`
    `String` | `getPrettyName()`
    `String` | `getProgram()` get the current text for this tab
    `String` | `getSavedProgram()` get the last version saved of this tab
    `int` | `getScrollPosition()`
    `int` | `getSelectionStart()`
    `int` | `getSelectionStop()`
    `UndoManager` | `getUndo()`
    `boolean` | `isExtension(String what)`
    `boolean` | `isModified()`
    `long` | `lastVisited()`
    `void` | `load()` Load this piece of code from a file.
    `void` | `save()` Save this piece of code, regardless of whether the modified flag is set or not.
    `void` | `saveAs(File newFile)` Save this file to another location, used by Sketch.saveAs()
    `void` | `setDocument(Document d)`
    `void` | `setFolder(File sketchFolder)` Called when the sketch folder name/location has changed.
    `void` | `setModified(boolean modified)`
    `void` | `setPreprocOffset(int preprocOffset)`
    `void` | `setProgram(String replacement)` set the current text for this tab

    - ### Methods inherited from class Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### SketchCode

          public SketchCode(File file,
                    String extension)

  - ### Method Detail

    - #### getFile

          public File getFile()

    - #### copyTo

          public void copyTo(File dest)
                      throws IOException

      Throws:
        `IOException`

    - #### getFileName

          public String getFileName()

    - #### getPrettyName

          public String getPrettyName()

    - #### getExtension

          public String getExtension()

    - #### isExtension

          public boolean isExtension(String what)

    - #### getProgram

          public String getProgram()

      get the current text for this tab

    - #### setProgram

          public void setProgram(String replacement)

      set the current text for this tab

    - #### getSavedProgram

          public String getSavedProgram()

      get the last version saved of this tab

    - #### getLineCount

          public int getLineCount()

    - #### setModified

          public void setModified(boolean modified)

    - #### isModified

          public boolean isModified()

    - #### setPreprocOffset

          public void setPreprocOffset(int preprocOffset)

    - #### getPreprocOffset

          public int getPreprocOffset()

    - #### addPreprocOffset

          public void addPreprocOffset(int extra)

    - #### getDocument

          public Document getDocument()

    - #### setDocument

          public void setDocument(Document d)

    - #### getUndo

          public UndoManager getUndo()

    - #### getSelectionStart

          public int getSelectionStart()

    - #### getSelectionStop

          public int getSelectionStop()

    - #### getScrollPosition

          public int getScrollPosition()

    - #### lastVisited

          public long lastVisited()

    - #### load

          public void load()
                    throws IOException

      Load this piece of code from a file.
      Throws:
        `IOException`

    - #### save

          public void save()
                    throws IOException

      Save this piece of code, regardless of whether the modified flag is set or not.
      Throws:
        `IOException`

    - #### saveAs

          public void saveAs(File newFile)
                      throws IOException

      Save this file to another location, used by Sketch.saveAs()
      Throws:
        `IOException`

    - #### setFolder

          public void setFolder(File sketchFolder)

      Called when the sketch folder name/location has changed. Called when renaming tab 0, the main code.