Package avail.anvil

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
class AnvilException : RuntimeException

A RuntimeException specific to Anvil.

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
class AvailWorkbench : WorkbenchFrame

AvailWorkbench is a simple user interface for the Avail builder.

Link copied to clipboard
class CodeGuide(    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
object DarkColors : SystemColors

The dark-themed palette of system colors.

Link copied to clipboard
enum FeatureCategory : Enum<FeatureCategory>

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
object Fork : StyleRuleInstructionCoder, StyleRuleInstruction

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 GlowHighlightPainter(color: Color) : DefaultHighlighter.DefaultHighlightPainter
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
object LightColors : SystemColors

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
class MatchLiteralClassifierN(literalIndex: 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, 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
class MatchLiteralClassifierOrJump0(jumpTarget: Int) : StyleRuleInstruction

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
class MatchLiteralClassifierOrJump1(jumpTarget: Int) : StyleRuleInstruction

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
class MatchLiteralClassifierOrJump2(jumpTarget: Int) : StyleRuleInstruction

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
class MatchLiteralClassifierOrJump3(jumpTarget: Int) : StyleRuleInstruction

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
object PhrasePathStyleApplicator

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
class RenderingContextValidationException(message: String) : Exception

Raised when rendering contextvalidation fails for any reason.

Link copied to clipboard
object RenderingEngine

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
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
class StylePatternCompiler

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
enum StyleRuleContextState : Enum<StyleRuleContextState>

The execution state of a style rule.

Link copied to clipboard
object StyleRuleExecutor

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
interface StyleRuleInstruction

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
sealed class StyleRuleInstructionCoder

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
enum SystemStyleClassifier : Enum<SystemStyleClassifier>

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
class ValidatedStylePattern : StylePattern

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.

Functions

Link copied to clipboard
fun MenuBarBuilder.addWindowMenu(frame: JFrame)

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 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
fun NybbleInputStream.opcode(): Int

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.

fun NybbleOutputStream.opcode(value: Int)

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
fun Component.scroll(): JScrollPane

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>

Either places the receiver JTextArea inside a JScrollPane with line numbers presented as row headers, or answers the JScrollPane that it's already inside.

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
fun NybbleInputStream.unvlq(): Int

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
fun NybbleOutputStream.vlq(value: Int)

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.

Properties

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.