API Reference
Fugl.ButtonState
— TypeEnum representing the state of a mouse button.
IsReleased
: The button is currently released.IsPressed
: The button is currently pressed.
Fugl.CursorPosition
— TypeRepresents the position of a cursor in the editor.
line
: Line number (1-based)column
: Column number (1-based, character position within the line)
Fugl.EditorState
— TypeCreate a new EditorState with the given text and language.
Fugl.EditorState
— TypeState for the code editor containing text, cursor position, and cached tokenization.
text
: The full text contentcursor
: Current cursor positionis_focused
: Whether the editor is focusedcached_lines
: Cache of tokenized line datatext_hash
: Hash of the text to detect changes
Fugl.EditorState
— MethodCreate a new EditorState with updated text, preserving cursor and focus state from the old state.
Fugl.EditorState
— MethodCreate a new EditorState with updated focus state, preserving text and cursor from the old state.
Fugl.KeyEvent
— TypeStruct representing a keyboard event.
key
: GLFW key code (e.g., GLFW.KEYA, GLFW.KEYENTER)scancode
: Hardware-specific scancodeaction
: GLFW action (GLFW.PRESS, GLFW.RELEASE, GLFW.REPEAT)mods
: Modifier key flags (GLFW.MODSHIFT, GLFW.MODCONTROL, etc.)
Fugl.LineTokenData
— TypeCached tokenization data for a line of code.
line_number
: The line number this data belongs toline_text
: The original line texttokens
: Vector of tokens for this linetoken_data
: Processed token data with positions and colors
Fugl.MouseButton
— TypeEnum representing the different mouse buttons.
LeftButton
: The left mouse button.RightButton
: The right mouse button.MiddleButton
: The middle mouse button (scroll button).
Fugl.SizedView
— TypeAbstract type for views that have constrained/intrinsic sizing behavior. These views know their preferred dimensions and can be used with alignment components. Examples: IntrinsicSize, FixedSize, IntrinsicWidth, IntrinsicHeight, etc.
Fugl.AlignHorizontal
— FunctionAlignHorizontal(child::SizedView, alignment::Symbol)
Aligns a sized child component horizontally within its container.
Arguments
child
: A SizedView component that has intrinsic dimensionsalignment
: Horizontal alignment (:left, :center, :right)
Example
AlignHorizontal(IntrinsicSize(Image("logo.png")), :left)
AlignHorizontal(FixedSize(Text("Hello"), 100.0f0, 50.0f0), :right)
Fugl.AlignVertical
— FunctionAlignVertical(child::SizedView, alignment::Symbol)
Aligns a sized child component vertically within its container.
Arguments
child
: A SizedView component that has intrinsic dimensionsalignment
: Vertical alignment (:top, :center, :bottom)
Example
AlignVertical(IntrinsicSize(Image("logo.png")), :top)
AlignVertical(FixedSize(Text("Hello"), 100.0f0, 50.0f0), :center)
Fugl.Container
— FunctionThe Container
is the most basic GUI component that can contain another component. It is the most basic building block of the GUI system.
Fugl.FixedSize
— MethodFixedSize(child::AbstractView, width::Real, height::Real)
Creates a view that has a fixed size, regardless of the child's intrinsic size. The child will be rendered at the specified width and height.
Fugl.IconButton
— MethodA button consisting of the icon only.
Fugl.IntrinsicSize
— FunctionIntrinsicSize(child::AbstractView=EmptyView())
The IntrinsicSize
component is used to wrap a child view and ensure that it uses its intrinsic size for layout. This is useful for components that should not stretch to fill their parent container, but rather use their natural size.
Fugl.TextButton
— MethodA button containing text only.
Fugl.apply_clipboard_action!
— MethodApply clipboard action (placeholder for now).
Fugl.apply_delete_text!
— MethodApply delete text action.
Fugl.apply_editor_action!
— MethodApply an editor action to the editor state.
Fugl.apply_insert_text!
— MethodApply text insertion action.
Fugl.apply_layout
— Methodapply_layout(component::AbstractView)
Apply layout to a GUI component and its children. This function calculates and applies the layout to components. The interpret_view
function then uses the positions and sizes calculated by this function.
Fugl.apply_move_cursor!
— MethodApply cursor movement action.
Fugl.char_callback
— MethodAlternative signature in case GLFW passes Char directly This function adds a character directly to the key buffer.
Fugl.char_callback
— MethodNew character callback for proper text input This function handles character input from the keyboard, converting Unicode codepoints to characters.
Fugl.delete_range!
— MethodDelete text between two cursor positions.
Fugl.detect_click
— MethodDetect click events and handle focus and cursor positioning.
Fugl.detect_click
— MethodDetect click events and handle focus and cursor positioning for TextBox.
Fugl.draw_closed_lines
— Methoddraw_closed_lines(vertices::Vector{Point2f}, color_rgba::Vec4{<:AbstractFloat})
Draw closed lines using the provided vertices and color.
Fugl.draw_cursor
— FunctionDraw the cursor at the specified position.
Fugl.draw_rectangle
— Methoddraw_rectangle(vertices::Vector{Point2f}, color_rgba::Vec4{<:AbstractFloat}, projection_matrix::Mat4{Float32})
Draw a rectangle using the provided vertices and color.
Fugl.draw_rounded_rectangle
— Methoddraw_rounded_rectangle(
vertices::Vector{Point2f},
width::Float32, height::Float32,
fill_color_rgba::Vec4{<:AbstractFloat}, border_color_rgba::Vec4{<:AbstractFloat},
border_width::Float32, radius::Float32,
projection_matrix::Mat4{Float32}
)
Draw a rounded rectangle with border using the custom shader.
Fugl.ensure_line_tokenized!
— MethodEnsure tokenization data is cached for the given line.
Fugl.find_word_boundary
— MethodFind word boundary for word-based movement.
Fugl.generate_rectangle_vertices
— Methodgenerate_rectangle_vertices(x, y, width, height)
Function to generate a rectangle with specified position and size in pixel coordinates.
This function creates a rectangle defined by its top-left corner (x, y), width, and height.
Fugl.get_lines
— MethodGet the lines of text from the editor state.
Fugl.get_orthographic_matrix
— Methodget_orthographic_matrix(left::T, right::T, bottom::T, top::T, near::T, far::T)::Matrix{T} where {T<:Real}
Create an orthographic projection matrix.
Fugl.handle_key_input
— MethodHandle key input for TextBox (same as CodeEditor but without syntax highlighting).
Fugl.initialize_shaders
— MethodInitialize the shader program (must be called after OpenGL context is created)
Fugl.interpret_view
— Methodinterpret_view(component::AbstractView, x::Float32, y::Float32, width::Float32, height::Float32, projection_matrix::Mat4{Float32})
Interpret the view of a GUI component. This function is responsible for interpreting the view of a GUI component based on its layout and properties.
Fugl.key_event_to_action
— MethodConvert a GLFW key event to an EditorAction.
Fugl.render_line_from_cache
— MethodRender a line using cached tokenization data.
Fugl.run
— Methodrun(ui_ref[]::AbstractView; title::String="Fugl", window_width_px::Integer=1920, window_height_px::Integer=1080)
Run the main loop for the GUI application. This function handles the rendering and event processing for the GUI.
Fugl.tokenize_julia_line
— MethodTokenize a Julia line and return tokens with color data. Returns (tokens, tokendata) where tokendata is [(position, text, color), ...]
Fugl.tokenize_line_with_colors
— MethodTokenize a line of code and return tokens with color data. Returns (tokens, tokendata) where tokendata is [(position, text, color), ...]
Fugl.update_text!
— MethodUpdate the text in the editor state and invalidate caches if needed.