frysk.gui.srcwin
Class SourceBuffer

java.lang.Object
  extended by org.gnu.glib.Struct
      extended by org.gnu.glib.GObject
          extended by org.gnu.gtk.TextBuffer
              extended by frysk.gui.srcwin.SourceBuffer
Direct Known Subclasses:
InlineBuffer

public class SourceBuffer
extends org.gnu.gtk.TextBuffer

This class is a wrapper around TextBuffer, it allows for extra functionality needed by the SourceViewWidget. It will need to be retrofited to use correct model objects once these are set, instead of SourceCodeLine and so on.


Constructor Summary
SourceBuffer()
          Creates a new SourceBuffer
SourceBuffer(DebugInfoFrame scope)
          Creates a new SourceBuffer with the given scope
SourceBuffer(DebugInfoFrame scope, int mode)
           
 
Method Summary
 void addComment(int lineStart, int colStart, int lineEnd, int colEnd)
          Adds a comment to be highlighted in the text
 void clear()
           
 void clearAnchorAtCurrentLine()
          Removed the anchor created by createAnchorAtCurrentLine()
 org.gnu.gtk.TextChildAnchor createAnchorAtCurrentLine()
          Creates the anchor at the current line that will to which the inlined code will be attached.
 void disassembleFrame(DebugInfoFrame frame)
           
 boolean findNext(String toFind, boolean matchCase, boolean findAll)
          Find the next instance of toFind in the buffer.
 boolean findPrevious(String toFind, boolean matchCase)
          Finds the previous entry of toFind in the buffer and highlights it.
 int getCurrentLine()
           
 List getFunctions()
           
 DOMInlineInstance getInlineInstance(int lineNumber)
           
 int getLastLine()
           
 int getLineCount()
          Returns the number of lines in the given file, with the option to include inlined code in that count
 int getNumberOfAssemblyLines(int sourceLine)
          Returns the number of lines of assembly code for each line of source code.
 DebugInfoFrame getScope()
           
 org.gnu.gtk.TextIter getStartCurrentFind()
           
 Value getVariable(DOMTag tag, DOMLine line)
          Searches for a variable at the location specified by tag and line and returns a VariableLocation if a variable was found there.
 String getVariable(org.gnu.gtk.TextIter iter)
          Searches for a variable at the location specified by iter, and returns a VariableLocation if a variable was found there.
 boolean hasInlineCode(int lineNumber)
           
 boolean isLineBroken(int lineNo)
          Returns true if the given line has a breakpoint set.
 boolean isLineExecutable(int lineNo)
          Returns true if the given line is executable.
 void setLineBroken(boolean breakpoint, int lineNo)
           
 void setMode(int mode)
           
 void setScope(DebugInfoFrame scope)
           
 boolean toggleBreakpoint(int lineNum)
          Toggles the breakpoint on line lineNum, returning the previous state of the breakpoint on that line.
 
Methods inherited from class org.gnu.gtk.TextBuffer
addClipboard, addListener, applyTag, applyTag, backspace, beginUserAction, copyClipboard, createChildAnchor, createMark, createTag, cutClipboard, deleteMark, deleteMark, deleteSelection, deleteText, deleteTextInteractive, endUserAction, getCharCount, getEndIter, getEventListenerClass, getEventType, getInsert, getIter, getIter, getIter, getIter, getLineIter, getMark, getModified, getSelected, getSelectionBound, getSelectionEnd, getSelectionStart, getSlice, getStartIter, getText, getTextTagTable, getType, inserChildAnchor, insertPixbuf, insertRange, insertRangeInteractive, insertText, insertText, insertText, insertText, insertTextInteractive, insertTextInteractive, markExists, moveMark, moveMark, pasteClipboard, pasteClipboard, placeCursor, removeAllTags, removeAllTags, removeClipboard, removeListener, removeTag, removeTag, selectRange, setModified, setText
 
Methods inherited from class org.gnu.glib.GObject
addEventHandler, addEventHandler, addEventHandler, addEventHandler, addEventHandler, addEventHandler, addEventHandler, addListener, collect, freezeNotify, getBooleanProperty, getData, getDoubleProperty, getFloatProperty, getGObjectFromHandle, getIntProperty, getJavaObjectProperty, getLongProperty, getPixbufProperty, getProperty, getStringProperty, hasProperty, notify, removeEventHandler, removeListener, setBooleanProperty, setData, setDoubleProperty, setFloatProperty, setIntProperty, setJavaObjectProperty, setLongProperty, setPixbufProperty, setProperty, setStringProperty, thawNotify
 
Methods inherited from class org.gnu.glib.Struct
equals, getHandle, getNullHandle, hashCode
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SourceBuffer

public SourceBuffer()
Creates a new SourceBuffer


SourceBuffer

public SourceBuffer(DebugInfoFrame scope)
Creates a new SourceBuffer with the given scope

Parameters:
scope -

SourceBuffer

public SourceBuffer(DebugInfoFrame scope,
                    int mode)
Method Detail

isLineExecutable

public boolean isLineExecutable(int lineNo)
Returns true if the given line is executable.

Parameters:
lineNo - The line to check
Returns:
Whether or not the line is executable

isLineBroken

public boolean isLineBroken(int lineNo)
Returns true if the given line has a breakpoint set.

Parameters:
lineNo -
Returns:

setLineBroken

public void setLineBroken(boolean breakpoint,
                          int lineNo)

toggleBreakpoint

public boolean toggleBreakpoint(int lineNum)
Toggles the breakpoint on line lineNum, returning the previous state of the breakpoint on that line.

Parameters:
lineNum - the number of the line to toggle the breakpoint for, starting at 0
Returns:
true if breakpoint was previously set on lineNum, false otherwise
Throws:
ArrayIndexOutOfBoundsException - thrown if the line number given does not correspond to a valid line number

getCurrentLine

public int getCurrentLine()
Returns:
The current PC line

findNext

public boolean findNext(String toFind,
                        boolean matchCase,
                        boolean findAll)
Find the next instance of toFind in the buffer. If findAll is set, all instances will be highlighted, otherwise will return after the first.

Parameters:
toFind - The string to locate
matchCase - Whether to do a case sensitive search
findAll - Whether to locate all instances
Returns:
Whether the search was successful

findPrevious

public boolean findPrevious(String toFind,
                            boolean matchCase)
Finds the previous entry of toFind in the buffer and highlights it. Returns true if successful, false otherwise

Parameters:
toFind - The string to find
matchCase - Whether to do a case sensitive search
Returns:
Whether the search was successful

getStartCurrentFind

public org.gnu.gtk.TextIter getStartCurrentFind()
Returns:
The TextIter at the start of the currently searched for string

getVariable

public String getVariable(org.gnu.gtk.TextIter iter)
Searches for a variable at the location specified by iter, and returns a VariableLocation if a variable was found there. Returns null otherwise

Parameters:
iter - The location to look for a variable
Returns:
The variable at that location, or null

getVariable

public Value getVariable(DOMTag tag,
                         DOMLine line)
Searches for a variable at the location specified by tag and line and returns a VariableLocation if a variable was found there. Returns null otherwise

Parameters:
tag - The DOMTag to examine for a variable
line - The DOMLine containing Source information
Returns:
The variable at that location, or null

getFunctions

public List getFunctions()
Returns:
The list of functions found by the parser

addComment

public void addComment(int lineStart,
                       int colStart,
                       int lineEnd,
                       int colEnd)
Adds a comment to be highlighted in the text

Parameters:
lineStart - The line the comment starts on
colStart - The offset from the the start of the line that the comment starts on
lineEnd - The line the comment ends on
colEnd - the offset from the start of the line that the comment ends on

getLineCount

public int getLineCount()
Returns the number of lines in the given file, with the option to include inlined code in that count

Overrides:
getLineCount in class org.gnu.gtk.TextBuffer
Parameters:
includeInlindes - Whether to include inlined code in the line count
Returns:
The number of lines in the file

getLastLine

public int getLastLine()
Returns:
The number of the last line in the buffer, which may or may not be the same as the number of lines in the buffer due to an initial offset

hasInlineCode

public boolean hasInlineCode(int lineNumber)
Parameters:
lineNumber - the line to check
Returns:
true iff the given line has inlined code

getInlineInstance

public DOMInlineInstance getInlineInstance(int lineNumber)
Parameters:
lineNumber - The line number to get Inline information from
Returns:
The DOMInlineInstance containing the inlined code information, or null if no information exists

setScope

public void setScope(DebugInfoFrame scope)

setMode

public void setMode(int mode)

disassembleFrame

public void disassembleFrame(DebugInfoFrame frame)

createAnchorAtCurrentLine

public org.gnu.gtk.TextChildAnchor createAnchorAtCurrentLine()
Creates the anchor at the current line that will to which the inlined code will be attached. If a previous anchor exists it will be overridden.

Returns:
The created anchor.

clearAnchorAtCurrentLine

public void clearAnchorAtCurrentLine()
Removed the anchor created by createAnchorAtCurrentLine()


getScope

public DebugInfoFrame getScope()
Returns:
The stack frame currently being displayed

getNumberOfAssemblyLines

public int getNumberOfAssemblyLines(int sourceLine)
Returns the number of lines of assembly code for each line of source code. This is used mostly internally to aid in drawing line numbers.

Parameters:
sourceLine - The line of source code
Returns:
The number of assembly instructions associated with the line.

clear

public void clear()