Package-level declarations

Types

Link copied to clipboard
abstract class AbstractJSONFileEditor<CE>(workbench: AvailWorkbench, fileLocation: String, frameTitle: String, afterTextLoaded: (CE) -> Unit = {}) : FileEditor<CE>

An abstract FileEditor for an JSON file.

Link copied to clipboard
data class AdaptiveColor(val light: Color, val dark: Color)

An abstraction for a color that's dependent on light versus dark mode.

Link copied to clipboard
Link copied to clipboard
class AvailEditor(val workbench: AvailWorkbench, val moduleName: ModuleName, afterTextLoaded: (AvailEditor) -> Unit = {}) : WorkbenchFrame

An editor for an Avail source module. Currently supports:

Link copied to clipboard

AvailWorkbench is a simple user interface for the Avail builder.

Link copied to clipboard
class CodeOverlay(workbench: AvailWorkbench, jTextPane: JTextPane, guideLines: List<Int> = listOf(80)) : LayerUI<JScrollPane>

Draws code guides on the decorated JScrollPane after the appropriate columns.

Link copied to clipboard
data object DarkColors : SystemColors

The dark-themed palette of system colors.

Link copied to clipboard
data class DefinitionAndUsesInDocument(val definitionSpanInDocument: Pair<Position, Position>, val useSpansInDocument: List<Pair<Position, Position>>)

A class that maintains the position of the declaration of a local variable and its uses within the same StyledDocument. Within the document, this value is stored as an invisible style under the key LocalDefinitionAttributeKey for the span corresponding to the definition, and the same object is stored under LocalUseAttributeKey for the spans that are uses of the local.

Link copied to clipboard

Enumerates the feature categories of Anvil that may be turned off by including them in AvailProject.disallow.

Link copied to clipboard
abstract class FileEditor<CE>(val workbench: AvailWorkbench, fileLocation: String, frameTitle: String) : WorkbenchFrame

An editor for an arbitrary text files.

Link copied to clipboard

Unconditionally fork the current context, setting its program counter to 0. This supports matching of rules compiled from patterns with repeated prefixes, and optimizes for the case where the repetition occurs in the first succession. Always succeeds.

Link copied to clipboard
class ForkN(forkTarget: Int) : StyleRuleInstruction

Unconditionally fork the current context, setting its program counter to N, where N is supplied as an immediate operand.. This supports matching of rules compiled from patterns with repeated prefixes, and optimizes for the case where the repetition occurs in the first succession.

Link copied to clipboard
class GenericFileEditor(workbench: AvailWorkbench, fileLocation: String, val autoSave: Boolean = false, afterTextLoaded: (GenericFileEditor) -> Unit = {}) : FileEditor<GenericFileEditor>

An editor for a generic file.

Link copied to clipboard
class Glow(colors: Color)

A mechanism for highlighting explicit spans of text. It's composed of GlowHighlightRangePainters that can paint the initial and/or final characters of the span, and the interior portions of the span. Those subranges (at most 3) are added to a JTextPane's highlighter's highlighted regions, using the specific GlowHighlightRangePainter for each range.

Link copied to clipboard

A LayerPainter that is capable of highlighting text with a glowing border. The glow is accomplished through an array of colors to draw successive layers around the text in a rounded rectangle.

Link copied to clipboard
class JSONFileEditor(workbench: AvailWorkbench, filePath: String, frameTitle: String, val autoSave: Boolean = false, afterTextLoaded: (JSONFileEditor) -> Unit = {}) : AbstractJSONFileEditor<JSONFileEditor>

An AbstractJSONFileEditor for a generic JSON file.

Link copied to clipboard

The light-themed palette of system colors.

Link copied to clipboard

Match a style classifier against the special end-of-sequence classifier, represented by the empty string. On success, succeed the enclosing rule; on failure, fail the enclosing rule.

Link copied to clipboard

Match a style classifier against literal #0. On success, fall through to the next instruction of the enclosing rule and pause; on failure, fail the enclosing rule.

Link copied to clipboard

Match a style classifier against literal #1. On success, fall through to the next instruction of the enclosing rule and pause; on failure, fail the enclosing rule.

Link copied to clipboard

Match a style classifier against literal #2. On success, fall through to the next instruction of the enclosing rule and pause; on failure, fail the enclosing rule.

Link copied to clipboard

Match a style classifier against literal #3. On success, fall through to the next instruction of the enclosing rule and pause; on failure, fail the enclosing rule.

Link copied to clipboard

Match a style classifier against literal #N, where N is supplied as an immediate operand. On success, fall through to the next instruction of the enclosing rule and pause; on failure, fail the enclosing rule. Note that the encoding offsets the literal index by -4, so this cannot be used to encode indices ≤ 4.

Link copied to clipboard

Match a style classifier against literal #0. On success, fall through to the next instruction of the enclosing rule and pause; on failure, jump to the target instruction.

Link copied to clipboard

Match a style classifier against literal #1. On success, fall through to the next instruction of the enclosing rule and pause; on failure, jump to the target instruction.

Link copied to clipboard

Match a style classifier against literal #2. On success, fall through to the next instruction of the enclosing rule and pause; on failure, jump to the target instruction.

Link copied to clipboard

Match a style classifier against literal #3. On success, fall through to the next instruction of the enclosing rule and pause; on failure, jump to the target instruction.

Link copied to clipboard
class MatchLiteralClassifierOrJumpN(literalIndex: Int, jumpTarget: Int) : StyleRuleInstruction

Match a style classifier against literal #N, where N is supplied as an immediate operand. On success, fall through to the next instruction of the enclosing rule and pause; on failure, jump to the target instruction. Note that the encoding offsets the literal index by -4, so this cannot be used to encode indices ≤ 4.

Link copied to clipboard
class MenuBarBuilder(theMenuBar: JMenuBar)

A helper class for building the menu bar.

Link copied to clipboard
class MenuBuilder(theMenu: JMenu)

A helper class for building menus.

Link copied to clipboard
data class ModuleBuildProgress(val filePosition: Long, val fileSize: Long, val currentLineNumber: Int)

Contains the build progress information for the compilation of a ModuleName that is being compiled.

Link copied to clipboard

Utility for applying PhrasePathRecord's information to token ranges in a StyledDocument.

Link copied to clipboard
class ProjectWatcher(val workbench: AvailWorkbench)

Responsible for watching changes to AvailProject configuration files on disk using a DirectoryWatcher.

Link copied to clipboard
sealed class RenderingContext

A RenderingContext expresses how to render a complete set of character attributes to a contiguous region of text within an arbitrary StyledDocument.

Link copied to clipboard

Raised when rendering context validation fails for any reason.

Link copied to clipboard

The RenderingEngine renders runs of source text. To achieve this for some run R, it queries the active stylesheet with the run's style classifiers and then uses the obtained rendering context to set the character attributes of R.

Link copied to clipboard

A function that applies some style to the given range of the given StyledDocument. The range is expressed as the zero-based start in the UTF-16 String, and the zero-based just-past-end in the same string.

Link copied to clipboard
class SourceCodeInfo(val runtime: AvailRuntime, val resolverReference: ResolverReference)

Information about the source code for some module.

Link copied to clipboard
sealed class StylePattern

A persistent stylesheet maps unvalidated style patterns onto unvalidated style attributes. A StylePatternCompiler compiles a valid StylePattern with valid StyleAttributes into a ValidatedStylePattern.

Link copied to clipboard

A StylePatternCompiler parses a pattern, resolves a rendering context against a palette, and generates a rule if all syntactic and semantic requirements are met.

Link copied to clipboard
class StylePatternException(val position: Int, problem: String, cause: Exception? = null) : Exception

Raised when compilation of a StylePattern fails for any reason.

Link copied to clipboard
class StyleRule(val pattern: ValidatedStylePattern, val instructions: NybbleArray, literals: List<String>)

A StyleRule is a pattern-matching program produced by a StylePatternCompiler. A runtime stylesheet aggregates all rules that should be considered when determining how Avail source text should be rendered.

Link copied to clipboard
data class StyleRuleContext(val rule: StyleRule, val programCounter: Int, val state: StyleRuleContextState = PAUSED)

A StyleRuleContext represents the complete machine state of a running StyleRule.

Link copied to clipboard
Link copied to clipboard

The StyleRuleExecutor is a stateless virtual machine that accepts a context and executes one or more instructions of its rule, returning control immediately upon detecting that a derivative of the initial context has left the RUNNING state. The executor uses a supplied injector to feed forked contexts back into the pool of pending contexts. It should be run iteratively against a lineage of contexts and a sequence of classifiers. The special end-of-sequence classifier should terminate a sequence of classifiers (unless the rule rejects the sequence preemptively).

Link copied to clipboard

A StyleRuleInstruction is an indivisible unit of behavior within a style rule. Instructions are neither generated nor executed in reified form; the class hierarchy exists only to support disassembly for debugging and provide loci for documentation of behavior.

Link copied to clipboard

A StyleRuleInstructionCoder implements a strategy for correlating instructions and their decoders. Subclasses self-register simply by calling the superconstructor.

Link copied to clipboard
class StyleRuleTree(contexts: Set<StyleRuleContext>, val solutions: List<ValidatedStylePattern> = emptyList())

A StyleRuleTree comprises:

Link copied to clipboard
class Stylesheet(originalRules: Set<StyleRule>, palette: Palette)

An AvailProject contains a stylesheet that dictates how an Avail source viewer/editor should render a source region tagged with one or more style classifiers. A stylesheet comprises one or more patterns, each of which encodes (1) whether a region of text should be rendered and (2) how it should be rendered. Patterns are written using a simple domain-specific language (DSL); this DSL is designed to be reminiscent of Cascading Stylesheets (CSS), but, for reasons of simplicity, is not compatible with it. Each pattern compiles down into a rule. A rule is a program, comprising StyleRuleInstructions, whose input is the sequence S of style classifiers attached to some source region R and whose output is a partial rendering context that should be applied to R. The complete collection of rules is organized into a global StyleRuleTree, such that every vertex contains the StyleRuleContexts for those rules that are still live and every edge encodes a possible next style classifier, either as (1) a fixed style classifier mentioned by some active rule in the source vertex or (2) a wildcard that matches any style classifier. The RenderingEngine iteratively feeds S, one style classifier at a time, through the tree, starting at the root. At each vertex, it feeds the current classifier C to each rule therein. Each rule that accepts C generates one or more StyleRuleContexts, each of which is injected into the lazy successor vertex along the edge labeled C; each rule that rejects C is excluded from further consideration; each rule that completes adds itself to the (ordered) solution set. After consuming S entirely, the rules of the solution set are ranked according to specificity, and every rule that ties for highest specificity contributes its rendering effects to the final RenderingContext. Rendering conflicts are resolved by insertion order, with later rules prevailing over earlier ones. For computational efficiency, the final result is memoized (to the sequence S).

Link copied to clipboard
sealed class SystemColors

The abstract palette of system colors. Supports styling Avail source text and UI components.

Link copied to clipboard

SystemStyleClassifier enumerates the style classifiers that are well-known to Anvil.

Link copied to clipboard
class UnvalidatedRenderingContext(attrs: StyleAttributes) : RenderingContext
Link copied to clipboard
class UnvalidatedStylePattern(val source: String, val renderingContext: UnvalidatedRenderingContext) : StylePattern

An unvalidated style pattern.

Link copied to clipboard
class ValidatedRenderingContext(attrs: StyleAttributes, palette: Palette) : RenderingContext

A ValidatedRenderingContext has complete StyleAttributes and has been successfully validated against the palette used to construct it. It is therefore ready to render itself onto StyledDocuments.

Link copied to clipboard

A style pattern that has been successfully validated by a StylePatternCompiler.

Link copied to clipboard
class WindowAction(name: String, frame: JFrame, keyStroke: KeyStroke? = null, val action: () -> Unit) : AbstractAction
Link copied to clipboard
abstract class WorkbenchFrame(title: String) : JFrame

A JFrame that is directly associated with an AvailWorkbench.

Properties

Link copied to clipboard

Given a JTextPane that has previously had scrollTextWithLineNumbers run against it to wrap it appropriately before adding to the component hierarchy, extract the CodeOverlay associated with it. If it doesn't have one, fail.

Link copied to clipboard
val Palette.colors: Map<String, Color>

The appropriate colors to select from the receiver, depending on whether the application is using dark mode.

Functions

Link copied to clipboard
fun Highlighter.addGlow(range: IntRange, glow: Glow): List<Any>

Given a range and a Glow, apply that glow to the characters in that range, which consists of zero-based indices of the start and end inclusive. Add a highlight for the first character, the middle region if any, and the last character of that range. A size-one range acts as both a first and last character, with no middle part. This simplifies rendering of a box highlight, since the highlight mechanism is executed for each styled run separately, with no easy way to tell if the left or right walls of the box should be drawn.

Link copied to clipboard

Create a Window menu that appears suitable for the platform. Which is only Mac at the moment, although these commands should work anywhere.

Link copied to clipboard
inline fun Graphics.antiAliased(draw: Graphics2D.() -> Unit)

Perform the specified block of drawing logic using high-quality, anti-aliased drawing and font rendering operations. Restore the original rendering hints before returning control to the caller.

Link copied to clipboard

Given a receiver and argument that are optional RenderingFunctions, but not both null, produce a corresponding RenderingFunction that executes the non-null values, in arbitrary order if both are present.

Link copied to clipboard
fun StyledDocument.copyAsHtml5(start: Int, pastEnd: Int, codeBackground: Color = SystemColors.active.codeBackground): String

Copy the specified range from the receiver as a fragment of HTML5 text. Embed the style attributes directly into the HTML, using style rather than class attributes to keep the fragment portable and document-independent.

Link copied to clipboard
inline fun invokeAndWaitIfNecessary(noinline action: () -> Unit)

Perform the specified action on the event dispatch thread and wait for it to complete. If this is the event dispatch thread, then just perform the action synchronously.

Link copied to clipboard

Unapply the variable-length universal coding strategy applied by opcode to decode a nonnegative integer from the receiver. If the stored encoding does not denote a valid value, the result is undefined, and the number of bytes consumed is also undefined.

Apply a variable-length universal coding strategy to the supplied value, encoding it onto the receiver. The coding is not efficient for large instruction sets, but is quite efficient for a very small instruction set, i.e., fewer than 32 instructions.

Link copied to clipboard

Either places the given component inside a JScrollPane or answers the JScrollPane that it's already inside.

Link copied to clipboard
fun JTextPane.scrollTextWithLineNumbers(workbench: AvailWorkbench, guideLines: List<Int> = listOf(80)): JLayer<JScrollPane>

Create or look up the JLayer that contains a JScrollPane holding the receiver JTextPane plus a CodeOverlay that manages line numbers as row headers, line guides, and whatever else a CodeOverlay presents.

Link copied to clipboard
fun JTextComponent.showTextRange(rangeStart: Int, rangeEnd: Int)

Scroll the given JTextPane to ensure the given text range is visible, and preferably not jammed against the top or bottom border.

Link copied to clipboard

Extract the list of nodes along this TreePath, as a typed (but runtime erased) list.

Link copied to clipboard

Unapply the variable-length universal coding strategy applied by vlq to decode a nonnegative integer from the receiver. If the stored encoding does not denote a valid value, the result is undefined, and the number of bytes consumed is also undefined.

Link copied to clipboard

Apply a variable-length universal coding strategy to the supplied value, encoding it onto the receiver using a nybble-based variant of MIDI VLQ. The value must be non-negative.

Link copied to clipboard
inline fun Graphics.withHints(vararg hints: Pair<RenderingHints.Key, Any>, draw: Graphics2D.() -> Unit)

Perform the specified block of drawing logic using the specified rendering hints. Restore the original rendering hints before returning control to the caller.